瀏覽代碼

Adapted winaos with generic kernel -- setup boot driven by Machine.Init (called by Modules).
Mechanism for separation of modules before and after module Modules:
- linked modules register themselves at Modules
- Kernel32.Entry does the absolutely minimal setup for windows (called before all bodies, linked in front)
- Modules.Init calls all bodies (as "FINAL" procedure it will be linked after all bodies.
- Before calling module bodies, Modules.Init calls Machine.Init in order to have a minimal setup for the remaining module bodies



git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@6347 8c9fc860-2736-0410-a75d-ab315db34111

felixf 9 年之前
父節點
當前提交
ad5b8a6cf0
共有 3 個文件被更改,包括 20 次插入19 次删除
  1. 1 1
      source/Generic.Modules.Mod
  2. 12 11
      source/Generic.Win32.Kernel32.Mod
  3. 7 7
      source/Win32.Machine.Mod

+ 1 - 1
source/Generic.Modules.Mod

@@ -943,7 +943,7 @@ END PublishRegisteredModules;
 PROCEDURE {FINAL} Main;
 BEGIN
 	Machine.Init;
-	Trace.String("published registered modules"); Trace.Ln;
+	Trace.String("publish registered modules"); Trace.Ln;
 	PublishRegisteredModules;
 END Main;
 

+ 12 - 11
source/Generic.Win32.Kernel32.Mod

@@ -332,6 +332,9 @@ TYPE
 	END;
 
 VAR
+	hInstance-: HINSTANCE;   (* init by linker/loader *)
+	isEXE-: BOOLEAN;
+
 	(* the procedure variables getProcAddress and LoadLibrary  must be patched by linker / PE loader *)
 	(** The GetProcAddress function returns the address of the specified exported dynamic-link library (DLL) function.
 			Use the GetProcAddress Oberon wrapper. *)
@@ -789,7 +792,7 @@ VAR
 		ExitProcess(l);
 	END ShutdownP;
 
-	PROCEDURE Init;
+	PROCEDURE Init*;
 	VAR mod: HMODULE;
 	BEGIN
 		Shutdown := ShutdownP;
@@ -924,7 +927,14 @@ VAR
 		GetProcAddress(mod, "WaitForSingleObject",SYSTEM.VAL(ADDRESS,WaitForSingleObject));
 		GetProcAddress(mod, "WriteFile",SYSTEM.VAL(ADDRESS,WriteFile));
 		GetProcAddress(mod, "GlobalMemoryStatusEx",SYSTEM.VAL(ADDRESS,GlobalMemoryStatusEx));
-		END Init;
+		isEXE := hInstance = NULL;
+		IF isEXE THEN hInstance := GetModuleHandle( NIL ) END;
+		IF IsDebuggerPresent()=True THEN
+			OutputString := OutputDebugString
+		ELSE
+			OutputString := NoOutputString
+		END;
+	END Init;
 
 
 
@@ -974,14 +984,5 @@ VAR
 			
 		END EntryPoint;
 		
-
-		
-BEGIN
-	Init;
-	IF IsDebuggerPresent()=True THEN
-		OutputString := OutputDebugString
-	ELSE
-		OutputString := NoOutputString
-	END;
 END Kernel32.
 	

+ 7 - 7
source/Win32.Machine.Mod

@@ -50,11 +50,12 @@ CONST
 
 	Second* = 1000; (* frequency of ticks increments in Hz *)
 
+
 CONST
 		(* error codes *)
 		Ok* = 0;
 		NilAdr* = -1;	(* nil value for addresses (not same as pointer NIL value) *)
-
+		IsCooperative* = FALSE;
 TYPE
 	Vendor* = ARRAY 13 OF CHAR;
 	IDMap* = ARRAY 16 OF SHORTINT;
@@ -690,9 +691,13 @@ BEGIN
 	fullName[j] := 0X;
 END ToExecutablePath;
 
-PROCEDURE Init;
+PROCEDURE Init*;
 VAR vendor: Vendor; ver: LONGINT; hfile: Kernel32.HANDLE;
 BEGIN
+	Kernel32.Init;
+	trace[1] := 0X; Trace.Char := LogChar; Trace.Color := TraceColor;
+	InitLocks();
+	Trace.String("Machine");
 	boottime:=GetTimer();
 
 	COPY( Version, version );
@@ -1231,9 +1236,4 @@ CODE{SYSTEM.i386}
 END Portout32;
 
 
-
-BEGIN
-	trace[1] := 0X; Trace.Char := LogChar; Trace.Color := TraceColor;
-	InitLocks();
-	Init;
 END Machine.