User:Johnburger/Demo/Data.inc

From OSDev Wiki
Jump to: navigation, search

Device interrupts may need access to a Data Segment - for example, the Keyboard handler needs to put the keycodes somewhere! This Data segment cannot be in a Local Descriptor Table, since the LDT may not be the one that is active when the interrupt occurs - unless the interrupt handler is a full-blown TSS that switches in its own LDT. That may not be a good idea for a frequent interrupt, but may be OK for something as slow as a keyboard.

So this code is for the global Data Segment. The Keyboard handler uses it, as does the Memory Allocator - for which the RAMMap has already been filled in at boot time by Boot/RAM.

Demo/Data.inc

;
; Data.inc
;
 
; This is the definition for the global Data Segment. Note that it is
; mostly populated at Boot by Boot/RAM.inc
 
                 SEGMENT        Data  START=0  ALIGN=16  NOBITS
 
                 USE32
 
Data.RAM         RESD           1       ; Beginning of available RAM
Data.RAMTop      RESD           1       ; Top of RAM as reported by BIOS
 
Data.Key.Code    RESB           1       ; Storage for key scan-code
Data.Key.Shifts  RESB           1       ; Storage for current Key Shift states
 
                 RESB           12      ; Reserved
 
Data.RAMMap.Num  RESW           1       ; Number of BIOS.RAMMap entries
 
Data.RAMMap      RESB           Data.Size - ($-$$) ; RAMMap
Data.RAMMap.Size EQU            $ - Data.RAMMap
Data.RAMMap.Max  EQU            Data.RAMMap.Size / BIOS.RAMMap_size
Personal tools
Namespaces
Variants
Actions
Navigation
About
Toolbox