Subversion Repositories Kolibri OS

Rev

Rev 4419 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. include 'kglobals.inc'
  2.  
  3. PG_UNMAP            equ 0x000
  4. PG_MAP              equ 0x001
  5. PG_WRITE            equ 0x002
  6. PG_SW               equ 0x003
  7. PG_USER             equ 0x005
  8. PG_UW               equ 0x007
  9. PG_NOCACHE          equ 0x018
  10. PG_LARGE            equ 0x080
  11. PG_GLOBAL           equ 0x100
  12.  
  13. DRV_ENTRY    equ  1
  14. DRV_EXIT     equ -1
  15.  
  16. struct  LHEAD
  17.         next            dd ?   ;next object in list
  18.         prev            dd ?   ;prev object in list
  19. ends
  20.  
  21. struct  MUTEX
  22.         lhead   LHEAD
  23.         count   dd ?
  24. ends
  25.  
  26. struct  PCIDEV
  27.         bk              dd ?
  28.         fd              dd ?
  29.         vendor_device_id dd ?
  30.         class           dd ?
  31.         devfn           db ?
  32.         bus             db ?
  33.                         rb 2
  34.         owner           dd ? ; pointer to SRV or 0
  35. ends
  36.  
  37. struct IOCTL
  38.         handle          dd ?
  39.         io_code         dd ?
  40.         input           dd ?
  41.         inp_size        dd ?
  42.         output          dd ?
  43.         out_size        dd ?
  44. ends
  45.  
  46. ; The following macro assume that we are on uniprocessor machine.
  47. ; Serious work is needed for multiprocessor machines.
  48. macro spin_lock_irqsave spinlock
  49. {
  50.         pushf
  51.         cli
  52. }
  53. macro spin_unlock_irqrestore spinlock
  54. {
  55.         popf
  56. }
  57. macro spin_lock_irq spinlock
  58. {
  59.         cli
  60. }
  61. macro spin_unlock_irq spinlock
  62. {
  63.         sti
  64. }
  65.  
  66. ; \begin{diamond}[29.09.2006]
  67. ; may be useful for kernel debugging
  68. ; example 1:
  69. ;       dbgstr 'Hello, World!'
  70. ; example 2:
  71. ;       dbgstr 'Hello, World!', save_flags
  72. macro dbgstr string*, f
  73. {
  74. local a
  75. iglobal_nested
  76. a db 'K : ',string,13,10,0
  77. endg_nested
  78. if ~ f eq
  79.         pushfd
  80. end if
  81.         push    esi
  82.         mov     esi, a
  83. if defined SysMsgBoardStr._pe_import
  84.         invoke  SysMsgBoardStr
  85. else
  86.         call    SysMsgBoardStr
  87. end if
  88.         pop     esi
  89. if ~ f eq
  90.         popfd
  91. end if
  92. }
  93. ; \end{diamond}[29.09.2006]
  94.  
  95. ; MOV Immediate.
  96. ; Useful for things like movi eax,10:
  97. ; shorter than regular mov, but slightly slower,
  98. ; do not use it in performance-critical places.
  99. macro movi dst, imm
  100. {
  101. if imm >= -0x80 & imm <= 0x7F
  102.         push    imm
  103.         pop     dst
  104. else
  105.         mov     dst, imm
  106. end if
  107. }
  108.  
  109. macro call name
  110. {
  111. if name eqtype func & defined name#._pe_import
  112. err Use invoke, not call/stdcall for PE imports!
  113. end if
  114.         call    name
  115. }
  116.