Subversion Repositories Kolibri OS

Rev

Go to most recent revision | 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. ; The following macro assume that we are on uniprocessor machine.
  38. ; Serious work is needed for multiprocessor machines.
  39. macro spin_lock_irqsave spinlock
  40. {
  41.         pushf
  42.         cli
  43. }
  44. macro spin_unlock_irqrestore spinlock
  45. {
  46.         popf
  47. }
  48. macro spin_lock_irq spinlock
  49. {
  50.         cli
  51. }
  52. macro spin_unlock_irq spinlock
  53. {
  54.         sti
  55. }
  56.  
  57. ; \begin{diamond}[29.09.2006]
  58. ; may be useful for kernel debugging
  59. ; example 1:
  60. ;       dbgstr 'Hello, World!'
  61. ; example 2:
  62. ;       dbgstr 'Hello, World!', save_flags
  63. macro dbgstr string*, f
  64. {
  65. local a
  66. iglobal_nested
  67. a db 'K : ',string,13,10,0
  68. endg_nested
  69. if ~ f eq
  70.         pushfd
  71. end if
  72.         push    esi
  73.         mov     esi, a
  74. if defined SysMsgBoardStr._pe_import
  75.         invoke  SysMsgBoardStr
  76. else
  77.         call    SysMsgBoardStr
  78. end if
  79.         pop     esi
  80. if ~ f eq
  81.         popfd
  82. end if
  83. }
  84. ; \end{diamond}[29.09.2006]
  85.  
  86. ; MOV Immediate.
  87. ; Useful for things like movi eax,10:
  88. ; shorter than regular mov, but slightly slower,
  89. ; do not use it in performance-critical places.
  90. macro movi dst, imm
  91. {
  92. if imm >= -0x80 & imm <= 0x7F
  93.         push    imm
  94.         pop     dst
  95. else
  96.         mov     dst, imm
  97. end if
  98. }
  99.  
  100. macro call name
  101. {
  102. if name eqtype func & defined name#._pe_import
  103. err Use invoke, not call/stdcall for PE imports!
  104. end if
  105.         call    name
  106. }
  107.