diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-06-21 05:55:02 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-06-21 05:56:26 +0200 |
| commit | f3432c10bd694344f7e1f82ed8cd793358f1a400 (patch) | |
| tree | b2ac11c9c1378cb24e046185b6d2eeb1b0e16e98 | |
| parent | 3a11be8c6f15cb03b483e2693bcd244846c6d61d (diff) | |
IMP: protect other computers which doesnt support EPM layout (AMD64)
IMP: Add LTE builtin and NetworkDevice of type LTE.
UPDATE: Also updated ReadMe.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
| -rw-r--r-- | Boot/Sources/HEL/AMD64/BootMain.cxx | 18 | ||||
| -rw-r--r-- | Comm/newstd.hxx | 73 | ||||
| -rw-r--r-- | Drv/GSMDrv/CheckStck.c | 11 | ||||
| -rw-r--r-- | Drv/GSMDrv/DriverRsrc.rsrc | 25 | ||||
| -rw-r--r-- | Drv/GSMDrv/GSMDrv.c | 25 | ||||
| -rw-r--r-- | Drv/GSMDrv/x86_64.make | 51 | ||||
| -rw-r--r-- | Drv/VideoDrv/DriverRsrc.rsrc | 8 | ||||
| -rw-r--r-- | Kernel/Builtins/GSM/IO.hxx | 29 | ||||
| -rw-r--r-- | Kernel/Builtins/LTE/.keepme (renamed from Kernel/Builtins/GSM/.keepme) | 0 | ||||
| -rw-r--r-- | Kernel/Builtins/LTE/IO.hxx | 29 | ||||
| -rw-r--r-- | Kernel/HALKit/ARM64/Storage/HalFlash.cxx | 54 | ||||
| -rw-r--r-- | Kernel/NetworkKit/LTE.hxx (renamed from Kernel/NetworkKit/GSM.hxx) | 10 | ||||
| -rw-r--r-- | Kernel/NetworkKit/NetworkDevice.hpp | 3 | ||||
| -rw-r--r-- | Kernel/Sources/KeMain.cxx | 19 | ||||
| -rw-r--r-- | Kernel/amd64-efi.make | 2 | ||||
| -rw-r--r-- | ReadMe.md | 12 |
16 files changed, 171 insertions, 198 deletions
diff --git a/Boot/Sources/HEL/AMD64/BootMain.cxx b/Boot/Sources/HEL/AMD64/BootMain.cxx index fab212ee..145bdadb 100644 --- a/Boot/Sources/HEL/AMD64/BootMain.cxx +++ b/Boot/Sources/HEL/AMD64/BootMain.cxx @@ -77,7 +77,7 @@ STATIC Bool CheckBootDevice(BootDeviceATA& ataDev) /// @brief Main EFI entrypoint. /// @param ImageHandle Handle of this image. /// @param SystemTable The system table of it. -/// @return +/// @return nothing, never returns. EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, EfiSystemTable* SystemTable) { @@ -91,9 +91,19 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, writer.Write(L"Zeta Electronics Corporation (R) newosldr: ") .Write(BVersionString::The()); - writer.Write(L"\rnewosldr: Firmware Vendor: ") - .Write(SystemTable->FirmwareVendor) - .Write(L"\r"); + if (SystemTable->FirmwareVendor[0] != '\\' || + SystemTable->FirmwareVendor[1] != 'E' || + SystemTable->FirmwareVendor[2] != 'P' || + SystemTable->FirmwareVendor[3] != 'M') + { + writer.Write(L"\rnewosldr: vendor: ") + .Write(SystemTable->FirmwareVendor) + .Write(L" isn't supported.\r"); + + EFI::Stop(); + + CANT_REACH(); + } UInt32* MapKey = new UInt32(); UInt32* SizePtr = new UInt32(); diff --git a/Comm/newstd.hxx b/Comm/newstd.hxx index 9bf690cd..57ffc756 100644 --- a/Comm/newstd.hxx +++ b/Comm/newstd.hxx @@ -14,16 +14,81 @@ #endif // __KERNEL__
class NUser; /// @brief User application class.
-class NCallback; /// @brief User callback class.
+class NWindow; /// @brief Window class.
+class NWindowAlert;
#define IMPORT_CXX extern "C++"
#define IMPORT_C extern "C"
/**
-@brief a class which helps the user do application I/O.
+@brief Class which exposes the app I/O.
*/
-class NUser
+class NUser final
{
public:
+ /// THOSE REQUIRES PERMISSIONS FROM THE USER. ///
-};
\ No newline at end of file + static void Poweroff();
+ static void Reboot();
+
+ /// THOSE REQUIRES PERMISSIONS FROM THE USER. ///
+
+ static bool IsWokeup();
+ static void Terminate();
+
+ /// THOSE DOESNT REQUIRE PERMISSIONS FROM THE USER. ///
+
+ static bool Exit(int code);
+ static void* New(long long sz);
+ static void Delete(void* ptr);
+
+ /// THOSE MAY REQUIRE PERMISSIONS FROM THE USER. ///
+
+ static int Open(const char* path);
+ static void Close(int fd);
+ static void Execute(const char* command);
+ static void* Read(const char* forkName, int fd);
+ static void* Write(const char* forkName, int fd);
+};
+
+typedef void(*NWindowCallback)(NWindow*);
+
+/**
+@brief Class which exposes the app UI API.
+*/
+class NWindowAlert
+{
+public:
+ virtual NWindowAlert* Alert(const char* message, const char* title) = 0;
+ virtual NWindowAlert* Prompt(const char* message, const char* title) = 0;
+
+ virtual NWindowAlert* Collect(const char* resultBuf, long resultBufSz) = 0;
+
+public:
+ bool fAsyncOperationMode;
+ NWindowCallback fAsyncOnComplete;
+
+};
+
+class NWindow
+{
+public:
+ virtual NWindow* New(const char* pageName) = 0;
+ virtual NWindow* Ref(NWindow* pagee) = 0;
+
+ virtual NWindow* Button(const char* text, NWindowCallback onClick = nullptr,
+ NWindowCallback onDblClick = nullptr) = 0;
+
+ virtual NWindow* Checkbox(const char* text, NWindowCallback onSelect = nullptr,
+ NWindowCallback onUnselect = nullptr) = 0;
+
+ virtual NWindow* Radio(const char* text, NWindowCallback onSelect = nullptr,
+ NWindowCallback onUnselect = nullptr) = 0;
+
+ virtual NWindow* Link(const char* where, const char* textIfAny = "", NWindowCallback onClick = nullptr,
+ NWindowCallback onHover = nullptr) = 0;
+
+public:
+ bool fEnabled;
+
+};
diff --git a/Drv/GSMDrv/CheckStck.c b/Drv/GSMDrv/CheckStck.c deleted file mode 100644 index 3eb157ba..00000000 --- a/Drv/GSMDrv/CheckStck.c +++ /dev/null @@ -1,11 +0,0 @@ -/* -------------------------------------------
-
- Copyright Zeta Electronics Corporation
-
-------------------------------------------- */
-
-///! @brief Use this to check your stack, if using MinGW/MSVC/CodeTools.
-void ___chkstk_ms(void)
-{
- (void)0;
-}
diff --git a/Drv/GSMDrv/DriverRsrc.rsrc b/Drv/GSMDrv/DriverRsrc.rsrc deleted file mode 100644 index f8e9c05f..00000000 --- a/Drv/GSMDrv/DriverRsrc.rsrc +++ /dev/null @@ -1,25 +0,0 @@ -1 ICON "../../Icons/driver-logo.ico" - -1 VERSIONINFO -FILEVERSION 1,0,0,0 -PRODUCTVERSION 1,0,0,0 -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "080904E4" - BEGIN - VALUE "CompanyName", "Zeta Electronics Corporation" - VALUE "FileDescription", "New OS driver." - VALUE "FileVersion", "1.00" - VALUE "InternalName", "SampleDriver" - VALUE "LegalCopyright", "Copyright Zeta Electronics Corporation, all rights reserved." - VALUE "OriginalFilename", "SampleDriver.exe" - VALUE "ProductName", "SampleDriver" - VALUE "ProductVersion", "1.00" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x809, 1252 - END -END diff --git a/Drv/GSMDrv/GSMDrv.c b/Drv/GSMDrv/GSMDrv.c deleted file mode 100644 index 1b7cfed6..00000000 --- a/Drv/GSMDrv/GSMDrv.c +++ /dev/null @@ -1,25 +0,0 @@ -/* ------------------------------------------- - - Copyright Zeta Electronics Corporation - -------------------------------------------- */ - -#include <DDK/KernelString.h> -#include <DDK/KernelPrint.h> - -/// @brief GSM entrypoint. -int __at_enter(void) -{ - kernelPrintStr("GSMDrv: Starting up...\r"); - - /// @brief activate SIM 0..n - - return 0; -} - -/// @brief GSM 'atexit' function. -int __at_exit(void) -{ - kernelPrintStr("GSMDrv: Shutting down...\r"); - return 0; -} diff --git a/Drv/GSMDrv/x86_64.make b/Drv/GSMDrv/x86_64.make deleted file mode 100644 index a47c40ae..00000000 --- a/Drv/GSMDrv/x86_64.make +++ /dev/null @@ -1,51 +0,0 @@ -################################################## -# (C) Zeta Electronics Corporation, all rights reserved. -# This is the sample driver makefile. -################################################## - -CC_GNU=x86_64-w64-mingw32-gcc -LD_GNU=x86_64-w64-mingw32-ld - -WINDRES=x86_64-w64-mingw32-windres - -ADD_FILE=touch -COPY=cp -HTTP_GET=wget - -LD_FLAGS=-e __ImageStart --subsystem=17 - -OBJ=*.o - - -REM=rm -REM_FLAG=-f - -FLAG_ASM=-f win64 -FLAG_GNU=-fshort-wchar -D__EFI_x86_64__ -mgeneral-regs-only -mno-red-zone -D__KERNEL__ -DEFI_FUNCTION_WRAPPER -I../ -I../../ -I./ -c -ffreestanding -std=c17 -D__HAVE_MAHROUSS_APIS__ -D__MAHROUSS__ -D__BOOTLOADER__ -I./ - -.PHONY: invalid-recipe -invalid-recipe: - @echo "invalid-recipe: Use make all instead." - -.PHONY: all -all: compile-amd64 - $(LD_GNU) $(OBJ) $(LD_FLAGS) -o GSMDrv.exe - -ifneq ($(DEBUG_SUPPORT), ) -DEBUG = -D__DEBUG__ -endif - -.PHONY: compile-amd64 -compile-amd64: - $(WINDRES) DriverRsrc.rsrc -O coff -o DriverRsrc.o - $(CC_GNU) $(FLAG_GNU) $(DEBUG) $(wildcard *.c) $(wildcard ../../DDK/*.c) $(wildcard ../../DDK/*.S) - -.PHONY: clean -clean: - $(REM) $(REM_FLAG) $(OBJ) GSMDrv.exe - -.PHONY: help -help: - @echo "=== HELP ===" - @echo "clean: Clean driver." - @echo "compile-amd64: Build driver." diff --git a/Drv/VideoDrv/DriverRsrc.rsrc b/Drv/VideoDrv/DriverRsrc.rsrc index f8e9c05f..827fd205 100644 --- a/Drv/VideoDrv/DriverRsrc.rsrc +++ b/Drv/VideoDrv/DriverRsrc.rsrc @@ -9,12 +9,12 @@ BEGIN BLOCK "080904E4" BEGIN VALUE "CompanyName", "Zeta Electronics Corporation" - VALUE "FileDescription", "New OS driver." + VALUE "FileDescription", "CG HW video driver." VALUE "FileVersion", "1.00" VALUE "InternalName", "SampleDriver" - VALUE "LegalCopyright", "Copyright Zeta Electronics Corporation, all rights reserved." - VALUE "OriginalFilename", "SampleDriver.exe" - VALUE "ProductName", "SampleDriver" + VALUE "LegalCopyright", "2024 Copyright Zeta Electronics Corporation, all rights reserved." + VALUE "OriginalFilename", "VideoDrv.exe" + VALUE "ProductName", "VideoDrv" VALUE "ProductVersion", "1.00" END END diff --git a/Kernel/Builtins/GSM/IO.hxx b/Kernel/Builtins/GSM/IO.hxx deleted file mode 100644 index 39de1a0f..00000000 --- a/Kernel/Builtins/GSM/IO.hxx +++ /dev/null @@ -1,29 +0,0 @@ -/* -------------------------------------------
-
-Copyright Zeta Electronics Corporation.
-
-File: GSM\IO.hxx.
-Purpose: GSM I/O.
-
-------------------------------------------- */
-
-#ifndef _INC_NETWORK_GSM_IO_HXX_
-#define _INC_NETWORK_GSM_IO_HXX_
-
-#include <NewKit/Defines.hpp>
-#include <NewKit/String.hpp>
-
-/// @brief GSM I/O routines.
-
-/// @brief Turn on SIM slot.
-NewOS::Boolean gsm_turn_on_slot(NewOS::Int32 slot);
-
-/// @brief Turn off SIM slot.
-NewOS::Boolean gsm_turn_off_slot(NewOS::Int32 slot);
-
-/// @brief Send AT command.
-NewOS::Boolean gsm_send_at_command(NewOS::Char* buf,
- NewOS::Size bufSz);
-
-
-#endif // ifndef _INC_NETWORK_GSM_IO_HXX_
diff --git a/Kernel/Builtins/GSM/.keepme b/Kernel/Builtins/LTE/.keepme index e69de29b..e69de29b 100644 --- a/Kernel/Builtins/GSM/.keepme +++ b/Kernel/Builtins/LTE/.keepme diff --git a/Kernel/Builtins/LTE/IO.hxx b/Kernel/Builtins/LTE/IO.hxx new file mode 100644 index 00000000..a3f62fa9 --- /dev/null +++ b/Kernel/Builtins/LTE/IO.hxx @@ -0,0 +1,29 @@ +/* -------------------------------------------
+
+Copyright Zeta Electronics Corporation.
+
+File: LTE\IO.hxx.
+Purpose: LTE I/O.
+
+------------------------------------------- */
+
+#ifndef _INC_NETWORK_LTE_IO_HXX_
+#define _INC_NETWORK_LTE_IO_HXX_
+
+#include <NewKit/Defines.hpp>
+#include <NewKit/String.hpp>
+
+/// @brief LTE I/O routines.
+
+/// @brief Turn on SIM slot.
+NewOS::Boolean lte_turn_on_slot(NewOS::Int32 slot);
+
+/// @brief Turn off SIM slot.
+NewOS::Boolean lte_turn_off_slot(NewOS::Int32 slot);
+
+/// @brief Send AT command.
+NewOS::Boolean lte_send_at_command(NewOS::Char* buf,
+ NewOS::Size bufSz);
+
+
+#endif // ifndef _INC_NETWORK_LTE_IO_HXX_
diff --git a/Kernel/HALKit/ARM64/Storage/HalFlash.cxx b/Kernel/HALKit/ARM64/Storage/HalFlash.cxx index 7bc9c8c0..4466963e 100644 --- a/Kernel/HALKit/ARM64/Storage/HalFlash.cxx +++ b/Kernel/HALKit/ARM64/Storage/HalFlash.cxx @@ -12,41 +12,55 @@ #ifdef __FLASH_MEM__ +#define cMaxFlash (4U) + namespace NewOS { - /// /:\\BRIDGE\\FLSH\\1 - constexpr auto cFlashBridgeMagic = "FLSH"; - constexpr auto cFlashBridgeRevision = 1; + /// /:\\BRIDGE\\FLSH\\1 + constexpr auto cFlashBridgeMagic = "FLSH"; + constexpr auto cFlashBridgeRevision = 1; - STATIC const Boolean kFlashEnabled = No; - STATIC SizeT kFlashSize = 0UL; - STATIC SizeT kFlashSectorSz = 0UL; + STATIC const Boolean kFlashEnabled = No; + STATIC SizeT kFlashSize[cMaxFlash] = {}; + STATIC SizeT kFlashSectorSz[cMaxFlash] = {}; - /// @brief Enable flash memory builtin. - STATIC Void drv_enable_builtin(Void); + /// @brief Enable flash memory builtin. + STATIC Void drv_enable_flash(Int32 slot); - /// @brief Disable flash memory builtin. - STATIC Void drv_disable_builtin(Void); + /// @brief Disable flash memory builtin. + STATIC Void drv_disable_flash(Int32 slot); - /// @brief get sector count. - /// @return drive sector count. - SizeT drv_std_get_sector_count(void) + /// @brief get sector count. + /// @return drive sector count. + SizeT drv_std_get_sector_count(Int32 slot) { - return kFlashSectorSz; + if (slot > cMaxFlash) + return 0; + + return kFlashSectorSz[slot]; } /// @brief get device size. /// @return drive size - SizeT drv_std_get_drv_size(void) + SizeT drv_std_get_drv_size(Int32 slot) { - return kFlashSize; + if (slot > cMaxFlash) + return 0; + + return kFlashSize[slot]; } - /// @brief Enable flash memory builtin. - STATIC Void drv_enable_builtin(Void) {} + /// @brief Enable flash memory at slot. + STATIC Void drv_enable_flash(Int32 arg) + { + kcout << "newoskrnl: enabled hardware.\r"; + } - /// @brief Disable flash memory builtin. - STATIC Void drv_disable_builtin(Void) {} + /// @brief Disable flash memory at slot. + STATIC Void drv_disable_flash(Int32 arg) + { + kcout << "newoskrnl: disabled hardware.\r"; + } } // namespace NewOS #endif // if __FLASH_MEM__ (Bridge) diff --git a/Kernel/NetworkKit/GSM.hxx b/Kernel/NetworkKit/LTE.hxx index f4b040b3..cb3aa1e1 100644 --- a/Kernel/NetworkKit/GSM.hxx +++ b/Kernel/NetworkKit/LTE.hxx @@ -2,15 +2,15 @@ Copyright Zeta Electronics Corporation. - File: GSM.hxx. - Purpose: GSM protocol classes. + File: LTE.hxx. + Purpose: LTE protocol classes. ------------------------------------------- */ -#ifndef _INC_NETWORK_GSM_HXX_ -#define _INC_NETWORK_GSM_HXX_ +#ifndef _INC_NETWORK_LTE_HXX_ +#define _INC_NETWORK_LTE_HXX_ #include <NewKit/Defines.hpp> #include <NewKit/String.hpp> -#endif // ifndef _INC_NETWORK_GSM_HXX_ +#endif // ifndef _INC_NETWORK_LTE_HXX_ diff --git a/Kernel/NetworkKit/NetworkDevice.hpp b/Kernel/NetworkKit/NetworkDevice.hpp index 9b251c2e..c6f0cca3 100644 --- a/Kernel/NetworkKit/NetworkDevice.hpp +++ b/Kernel/NetworkKit/NetworkDevice.hpp @@ -71,6 +71,9 @@ namespace NewOS /// @brief GSM device. using GSMNetworkDevice = NetworkDevice; + + /// @brief LTE device. + using LTENetworkDevice = NetworkDevice; } // namespace NewOS #include <NetworkKit/NetworkDevice.inl> diff --git a/Kernel/Sources/KeMain.cxx b/Kernel/Sources/KeMain.cxx index 59f53f34..3ff754c2 100644 --- a/Kernel/Sources/KeMain.cxx +++ b/Kernel/Sources/KeMain.cxx @@ -26,8 +26,7 @@ namespace NewOS::Detail { - /// @brief Filesystem auto mounter, additional checks are also done by the - /// class. + /// @brief Filesystem auto installer, additional checks are also done by the class. class FilesystemInstaller final { NewOS::NewFilesystemManager* fNewFS{nullptr}; @@ -105,12 +104,8 @@ namespace NewOS::Detail auto catalogSystem = fNewFS->GetParser()->GetCatalog(cDirStr[dirIndx]); - kcout << "newoskrnl: write fork...\r"; - fNewFS->GetParser()->CreateFork(catalogSystem, theFork); - kcout << "newoskrnl: write catalog...\r"; - fNewFS->GetParser()->WriteCatalog( catalogSystem, (NewOS::VoidPtr)(metadataFolder.CData()), metadataSz, cFolderInfo); @@ -186,11 +181,12 @@ namespace NewOS::Detail } }; - /// @brief Loads necessary servers for the OS to work. - /// @param void no parameters. + /// @brief Loads necessary servers for the kernel -> user mode switch. + /// @param void no args. /// @return void no return value. STATIC NewOS::Void ke_launch_srv(NewOS::Void) { + // load security server. NewOS::PEFLoader secureSrv("C:\\System\\securesrv.exe"); if (!secureSrv.IsLoaded()) @@ -201,14 +197,15 @@ namespace NewOS::Detail NewOS::Utils::execute_from_image(secureSrv, NewOS::ProcessHeader::kAppKind); - NewOS::PEFLoader uiSrv("C:\\System\\uisrv.exe"); + /// load middleware service. + NewOS::PEFLoader middlewareSvc("C:\\System\\middlewaresvc.exe"); - if (!uiSrv.IsLoaded()) + if (!middlewareSvc.IsLoaded()) { NewOS::ke_stop(RUNTIME_CHECK_FAILED); } - NewOS::Utils::execute_from_image(uiSrv, + NewOS::Utils::execute_from_image(middlewareSvc, NewOS::ProcessHeader::kAppKind); } } // namespace NewOS::Detail diff --git a/Kernel/amd64-efi.make b/Kernel/amd64-efi.make index 9421f63a..c230bc48 100644 --- a/Kernel/amd64-efi.make +++ b/Kernel/amd64-efi.make @@ -84,4 +84,4 @@ help: .PHONY: clean clean: - rm -f $(LDOBJ) $(wildcard *.o) $(KERNEL) + rm -f $(LDOBJ) $(wildcard *.o) $(KERNEL) $(KERNEL_512K) @@ -1,14 +1,10 @@ <!-- README --> -<div align="center"> -<img src="Meta/NewOS.svg"/> -</div> - -NewOS is an operating system based on Common User Access and the microkernel NewKernel codename: 'Ne'. +NewOS is an operating system based on Zeta^1 and a microkernel codenamed 'Ne'. <br> You need: -- MinGW/CodeTools for the kernel and bootloader. +- MinGW/GCC for the kernel and bootloader. - Netwide Assembler/CodeTools to output COFF/PEF object code. Start by cloning the repo: @@ -20,9 +16,9 @@ git clone git@bitbucket.org:mahrouss/microkernel.git And execute: ``` -make all +make -f amd64-efi.make all ``` -for the default target (AMD64 EPM) +for the custom target 'AMD64 EPM' ##### Copyright, Zeta Electronics Corporation, all rights reserved. |
