Generic.Unix.AMD64.Glue.Mod 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. MODULE Glue; (** AUTHOR "GF"; PURPOSE "Interface to OberonLoader"; *)
  2. IMPORT SYSTEM, Trace;
  3. CONST
  4. debug* = {};
  5. VAR
  6. last-: RECORD END; (* empty variable linked to end of kernel *)
  7. baseAdr*: ADDRESS;
  8. endAdr*: ADDRESS;
  9. dlsym- : PROCEDURE {C} ( handle: ADDRESS; name: ADDRESS ): ADDRESS;
  10. dlopen- : PROCEDURE {C} ( pathname: ADDRESS; mode: LONGINT ): ADDRESS;
  11. dlclose- : PROCEDURE {C} ( handle: ADDRESS );
  12. cout : PROCEDURE {C} ( ch: CHAR ); (* console output *)
  13. stackBottom- : ADDRESS; (* of main thread *)
  14. argc-: WORD;
  15. argv-: ADDRESS;
  16. environ-: ADDRESS;
  17. PROCEDURE {INITIAL, NOPAF} Header; (* header needed by OberonLoader *)
  18. CODE
  19. DB 'Oberon64G.binary' ; ID (24 byte)
  20. DD 0
  21. DD 0
  22. DD 0 ; size of statially linked binary ( filled in by static linker )
  23. DD 0 ; # relocations ( filled in by static linker )
  24. DQ @Init0 ; Loader <-- Oberon (entrypoint)
  25. DQ @dlopen ; Loader --> Oberon
  26. DQ @dlclose ; Loader --> Oberon
  27. DQ @dlsym ; Loader --> Oberon
  28. DQ @argc ; Loader --> Oberon
  29. DQ @argv ; Loader --> Oberon
  30. DQ @environ ; Loader --> Oberon
  31. DQ @cout ; Loader --> Oberon
  32. END Header;
  33. PROCEDURE Char ( c: CHAR );
  34. BEGIN
  35. cout( c )
  36. END Char;
  37. PROCEDURE Dlsym*( handle: ADDRESS; CONST name: ARRAY OF CHAR; adr: ADDRESS );
  38. VAR val: ADDRESS;
  39. BEGIN
  40. val := dlsym( handle, ADDRESSOF( name[0] ) );
  41. SYSTEM.PUT64( adr, val );
  42. END Dlsym;
  43. PROCEDURE {INITIAL, NOPAF} Init0;
  44. VAR localvar: ADDRESS;
  45. CONST CR = 0DX; NL = 0AX;
  46. BEGIN
  47. baseAdr := ADDRESSOF( Header );
  48. endAdr := ADDRESSOF( last );
  49. Trace.Init;
  50. Trace.Char := Char;
  51. stackBottom := ADDRESSOF( localvar ) + 2*SIZEOF( ADDRESS );
  52. END Init0;
  53. PROCEDURE Initialize*;
  54. BEGIN
  55. (* nothing, only for compatibility *)
  56. END Initialize;
  57. END Glue.
  58. Building the SolarisA2 Generic elf binary:
  59. Compiler.Compile -p=Linux64G
  60. Runtime.Mod Trace.Mod
  61. Generic.Unix.I386.Glue.Mod Generic.Solaris.I386.Unix.Mod Generic.Unix.I386.Machine.Mod
  62. Heaps.Mod Generic.Modules.Mod Generic.Solaris.Objects.Mod Unix.Kernel.Mod
  63. KernelLog.Mod Streams.Mod Pipes.Mod Commands.Mod TrapWriters.Mod Generic.Reflection.Mod
  64. Unix.StdIO.Mod Generic.Unix.Traps.Mod UTF8Strings.Mod Files.Mod Unix.UnixFiles.Mod
  65. RelativeFileSystem.Mod StringPool.Mod BitSets.Mod ObjectFile.Mod
  66. I386.Reals.Mod Unix.Clock.Mod Dates.Mod Strings.Mod Diagnostics.Mod
  67. GenericLinker.Mod GenericLoader.Mod Unix.BootConsole.Mod
  68. UnixBinary.Mod
  69. ~
  70. StaticLinker.Link -p=Solaris64G
  71. Runtime Trace Glue
  72. Unix Machine Heaps Modules Objects Kernel KernelLog
  73. Streams Pipes Commands StdIO TrapWriters Traps
  74. Files UnixFiles Clock Dates Reals Strings Diagnostics
  75. BitSets StringPool GenericLinker Reflection GenericLoader
  76. BootConsole
  77. ~
  78. Build 'A2Core' by joining OberonLoader (C) and oberon.bin (Oberon).
  79. UnixBinary.Build oberon.bin -> A2Core ~