
Bootup von Topsy v3
============================================================

Boot Messages:
  Core Boot 0.15                                          Lukas Ruf, June 4th 1998
  --------------------------------------------------------------------------------
  - VGA was set to support direct access.

  Core Loader 0.50                                        Lukas Ruf, June     1998
  Core Loader 0.51                                        Lukas Ruf, July     2000
  --------------------------------------------------------------------------------
  - Verify Processor...
  - Control Mode...
  - Load Kernel...
  - Enable A20...
  - Remap IRQs...
  - Create Initial GDT...
  - Switch to Protected Mode...
  - Execute Kernel in Protected Mode...
  - 80386 detected.
  - Real Mode
  - Topsy i386 Kernel loading: #######-###### => and loaded!
  - Topsy i386 User   loading: ###### => and loaded!
  - Enabling Address Line 20 => successfully completed.
  - Remapping IRQs to INT 20h..2Fh => successfully completed.
  - Creating intial GDT => successfully completed.
  - Now about to switch to PM => successfully completed.
  ==> Topsy i386, Kernel Startup 0.114 Lukas Ruf July 2000 <==
  GDT State: GDTR.limit: 0x30 // GDTR.base: 0x1000
  IDT Alias Selector : 060
  IDT State: IDTR.limit: 0x7ff // IDTR.base: 0x10000
  Kernel TSS: 070 // TSS Alias: 0100
  USER TSS: 0110 // TSS Alias: 0120
  TextSize = 94208
  DataSize = 8192
  Processor Exceptions   : IDT Vectors 0x00..0x1F
  Memory Management {Topsy i386, v2.0}
  Physical memory        : 0x00000000-0x 2000000 = 32768KB (32MB)
  Memory management      : 0x00000000-0x 8000000 = 131072KB (128MB)
  Control structures     : 0x00000000-0x00020000
  Kernel space           : 0x00020000-0x   39000
  Hardware IO            : 0x000A0000-0x00100000
  Not physically avail.  : 0x 2000000-0x 8000000
  Available memory       : 32156KB (31MB)
  Kernel Selectors: CODE 0x       8   DATA 0x      10
  User   Selectors: CODE 0x      60   DATA 0x      68
  Peripheral IRQ Handler : IRQs 0x00..0x0F (mapped to 0x20..0x2F)
  Internal   INT Handler : Installed at 0x30
  Blocking all unregistered Interrupts...Blocked !!
  Interrupt Request Line 0x02 (Cascade) started
  Binary Watch Handling Enabled
  Interrupt Request Line 0x00 (Timer Channel 0) started 
  Startup/ia32/Init.c: before BuildSegMap()











-------------------------------------------------------------------


BIOS
  - POST
  - HW initialisieren
  - Sprung in den MBR (CoreBoot)

CoreBoot: Boot/ia32/LowCore/CoreBoot/
  - coreboot.asm
    erstelle Stack
    initialisiere VGA
    kopiere CoreLoad ins Ram und führe CoreLoader aus
    
    
CoreLoad: Boot/ia32/LowCore/CoreLoad/coreload.asm
  Enable A20: a20gate.inc
  Mask IRQ: maksirq.inc
  Create GDT: creategdt.inc
  Turn on Protected Mode: pmswtch.inc
    lidt, lgdt
    switch to Protected Mode
    Far Jump to C-Kernel at gOSCode_Sel:cOSKern_Begin = 0x8:0x40 (Magic, do not change ;) )
  

Kernel
  Startup/ia32/Init.c: main()
      KernelConcatenate()   : macht Speicherbereich wieder zusammenhängend. Dieser wurde fragmentiert, da das Binary im Real Mode in den Speicher kopiert wurde. Dabei wird eine ganze Anzahl Tracks (7 Tracks à 9216Byte) in 64KB grosse Segmente gefüllt. Da dies nicht aufgeht, entstehen am Schluss jedes Segments Löcher von 1024Bytes. 
      VideoInit()           : initialisiere Statusvariablen
      ClearScreen()         : 
      ShowTopsyi386()       : zeige Topsy-Footer 
    
    Memory/ia32/MMHal.c:
      GDTInit()             : initialisiere gNr_Of_GDTE, print Status        
      IDTInit();            : mache Eintrag für  in GDT bei 0x10000, 2te Page
      TSSInit();            : mache Einträge für 
                                  Kernel TSS      : TSS  Segment bei K_TSS_Base
                                  Kernel TSS Alias: Data Segment bei K_TSS_Base
                                  User TSS        : TSS  Segment bei U_TSS_Base
                                  User TSS Alias  : Data Segment bei U_TSS_BASE
                                Initialisiere Kernel TSS mit Datem vom Kernel: __createTSS(K_TSS_Alias)
                                Lade Task Register mit TSS vom Kernel
                                Initialisiere User TSS mit Datem vom Kernel ????
    Threads/ia32/TMHal.c:
      ExceptionInit()       : initialisiere IDT Einträge 0 bis 31 mit Funktionen __NEx_** aus TMHalAsm.S:
                                   #define TRAP(_irqno_) pushal ; nop ; pushl $(_irqno_) ; jmp __general_ExceptionHandler
                                   rufen _INTHandler() auf
                                   
    Memory/ia32/MMHal.c:
      MemoryInit()          : erweitere Kernel Daten Segment auf 4GB
                              mache neuen GDT Eintrag für Memory bei MEMPAGEUSEDADDR   
                              markiere benützte Bereiche mit SetMemRangeUsed() 
                                __setPageUsed(MemSelector,i) setzt Bits in Page-Bitmap
                              erstelle User Code Segment: KUSEG_BASE bis zum ende des physikalischen Speichers
                              erstelle User Data Segment: dito
                              printfs
    
    Threads/ia32/TMHal.c:
      InterruptInit()       : initialisiere HW Interrupts 0-15 (IDT Einträge 32-47) mit Funktionen __NIR_** aus TMHalAsm.S:
                                #define IRQ(_name_,_irqno_) .align 4 ; .globl _name_ ; _name_: ; cli ; pushl $0 ; TRAP(_irqno_)
                              initialisiere SW Interrupts 0x30
                              blockiere restliche Interrupt Einträge mit __INT_31
                              CascStart():
                                __enable_IRQ(0x22) ???
                                __endOf_IRQ(0x22) ???
    
    Threads/ia32/TMClock.ch:
      TimerInit()           : initialisiert Uhr, aktiviert Timer Interrupt
                                RTC Doku ???                   
                                      
      BuildSegMap();        : Dies wird im TopsyMain() mit vm_init() erledigt...
                                Concatenate() des User-Load-Adressbereichs 
    
    ClearScreen();
    topsyMain();

  Startup/Startup.c: topsyMain()



INTERRUPTS
-------------------------------------------------------------------

TMHalAsm.S: __general_ExceptionHandler
TMHal.c:      _INTHandler

0x00: Timer
----------------------------
TMClock.c:      _TimerISR()
                  - print Output: Clock, 
TMHal.c:        intDispatcher(&frame);
TMScheduler.c:    tmClockHandler()
                    - wird in tmInit() konfiguriert.
                    - ruft schedule() auf


0x30: Syscall
----------------------------
TMIPC.c:      msgDispatcher(currentThread->id,        /* Sender is retrieved from Message */
                    msg,                              /* Address of Message is passed by esi */
                    (unsigned long int)frame.tf_edx,  /* timeout in milliseconds (if receiving) */
                    (MsgOpCode)frame.tf_eax );        /* Message OpCode */
                  - Ruft entweder kSend() oder oder kRecv() auf
                  - Setzt Rückgabewerte (architekturabhängig)
TMIPC.c:        kSend()
                    - vm_region_loan_out
                    - Kopiere Msg in Queue, oder wecke Thread auf
                    - moveMessageToPD()
                    - schedule()       
TMIPC.c         kRecv()
                    - schaue in Queue, evtl vm_region_loan_in()
                    - sonst returne Fehlermeldung 
                      -> msgDispatcher() markiert Thread als blockiert und ruft schedule() auf



