SirCmpwn

Untitled

Apr 26th, 2012
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. ===driver support in 0x42c-kernel===
  2.  
  3. ---ExampleDriver.asm---
  4.  
  5. .dw stack_size ; Size of stack that this driver needs
  6. .dw driver_id
  7. ; ---Everything past this point is loaded into RAM when the driver is loaded---
  8. .dw interrupt_handler ; Pointer to handler
  9.  
  10. ; Jump table
  11. SET PC, subroutine1
  12. SET PC, subroutine2
  13. SET PC, subroutine3 ; These are relative and made absolute when the driver is loaded
  14. .dw 0xFFFF ; Signals the end of the jump table for the loader
  15.  
  16. ; Relocation table goes here
  17.  
  18. interrupt_handler: ; Called when the device this driver supports triggers an interrupt
  19. ; handle interrupt...
  20. SET PC, POP
  21.  
  22. subroutine1:
  23. ; ...etc...
  24.  
  25. ---Kernel-level---
  26. All devices are told to use their device number as the interrupt message (assuming the device supports being told this).
  27. When an interrupt with that message is fired, the appropriate driver will handle it.
  28. All drivers are loaded into RAM and made absolute. They must specify an interrupt handler, and may specify any number of subroutines.
  29. A program may use the kernel routine kernel_device_loaded with a device ID (32 bit) to see if a device is plugged in and has a loaded driver.
  30. The OS bootloader will load drivers for all connected devices through the kernel via kernel_load_driver.
  31. A program may use a driver subroutine in a similar fashion to how it uses library subroutines.
Advertisement
Add Comment
Please, Sign In to add comment