Subversion Repositories Kolibri OS

Rev

Rev 5201 | Rev 5577 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                              ;;
  3. ;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
  4. ;; Distributed under terms of the GNU General Public License    ;;
  5. ;;                                                              ;;
  6. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7.  
  8. $Revision: 5565 $
  9.  
  10.  
  11. dpl0    equ  10010000b     ; data read       dpl0
  12. drw0    equ  10010010b      ; data read/write dpl0
  13. drw3    equ  11110010b      ; data read/write dpl3
  14. cpl0    equ  10011010b      ; code read dpl0
  15. cpl3    equ  11111010b      ; code read dpl3
  16.  
  17. D32     equ  01000000b      ; 32bit segment
  18. G32     equ  10000000b      ; page gran
  19.  
  20.  
  21. ;;;;;;;;;;;;cpu_caps flags;;;;;;;;;;;;;;;;
  22.  
  23. CPU_386        equ 3
  24. CPU_486        equ 4
  25. CPU_PENTIUM    equ 5
  26. CPU_P6         equ 6
  27. CPU_PENTIUM4   equ 0x0F
  28.  
  29. CAPS_FPU       equ    00 ;on-chip x87 floating point unit
  30. CAPS_VME       equ    01 ;virtual-mode enhancements
  31. CAPS_DE        equ    02 ;debugging extensions
  32. CAPS_PSE       equ    03 ;page-size extensions
  33. CAPS_TSC       equ    04 ;time stamp counter
  34. CAPS_MSR       equ    05 ;model-specific registers
  35. CAPS_PAE       equ    06 ;physical-address extensions
  36. CAPS_MCE       equ    07 ;machine check exception
  37. CAPS_CX8       equ    08 ;CMPXCHG8B instruction
  38. CAPS_APIC      equ    09 ;on-chip advanced programmable
  39.                          ; interrupt controller
  40. ;                     10 ;unused
  41. CAPS_SEP       equ    11 ;SYSENTER and SYSEXIT instructions
  42. CAPS_MTRR      equ    12 ;memory-type range registers
  43. CAPS_PGE       equ    13 ;page global extension
  44. CAPS_MCA       equ    14 ;machine check architecture
  45. CAPS_CMOV      equ    15 ;conditional move instructions
  46. CAPS_PAT       equ    16 ;page attribute table
  47.  
  48. CAPS_PSE36     equ    17 ;page-size extensions
  49. CAPS_PSN       equ    18 ;processor serial number
  50. CAPS_CLFLUSH   equ    19 ;CLFUSH instruction
  51.  
  52. CAPS_DS        equ    21 ;debug store
  53. CAPS_ACPI      equ    22 ;thermal monitor and software
  54.                          ;controlled clock supported
  55. CAPS_MMX       equ    23 ;MMX instructions
  56. CAPS_FXSR      equ    24 ;FXSAVE and FXRSTOR instructions
  57. CAPS_SSE       equ    25 ;SSE instructions
  58. CAPS_SSE2      equ    26 ;SSE2 instructions
  59. CAPS_SS        equ    27 ;self-snoop
  60. CAPS_HTT       equ    28 ;hyper-threading technology
  61. CAPS_TM        equ    29 ;thermal monitor supported
  62. CAPS_IA64      equ    30 ;IA64 capabilities
  63. CAPS_PBE       equ    31 ;pending break enable
  64.  
  65. ;ecx
  66. CAPS_SSE3      equ    32 ;SSE3 instructions
  67. ;                     33
  68. ;                     34
  69. CAPS_MONITOR   equ    35 ;MONITOR/MWAIT instructions
  70. CAPS_DS_CPL    equ    36 ;
  71. CAPS_VMX       equ    37 ;virtual mode extensions
  72. ;                     38 ;
  73. CAPS_EST       equ    39 ;enhansed speed step
  74. CAPS_TM2       equ    40 ;thermal monitor2 supported
  75. ;                     41
  76. CAPS_CID       equ    42 ;
  77. ;                     43
  78. ;                     44
  79. CAPS_CX16      equ    45 ;CMPXCHG16B instruction
  80. CAPS_xTPR      equ    46 ;
  81. ;
  82. ;reserved
  83. ;
  84. ;ext edx /ecx
  85. CAPS_SYSCAL    equ    64 ;
  86. CAPS_XD        equ    65 ;execution disable
  87. CAPS_FFXSR     equ    66 ;
  88. CAPS_RDTSCP    equ    67 ;
  89. CAPS_X64       equ    68 ;
  90. CAPS_3DNOW     equ    69 ;
  91. CAPS_3DNOWEXT  equ    70 ;
  92. CAPS_LAHF      equ    71 ;
  93. CAPS_CMP_LEG   equ    72 ;
  94. CAPS_SVM       equ    73 ;secure virual machine
  95. CAPS_ALTMOVCR8 equ    74 ;
  96.  
  97. ; CPU MSR names
  98. MSR_SYSENTER_CS         equ     0x174
  99. MSR_SYSENTER_ESP        equ     0x175
  100. MSR_SYSENTER_EIP        equ     0x176
  101. MSR_CR_PAT              equ     0x277
  102. MSR_MTRR_DEF_TYPE       equ     0x2FF
  103.  
  104. MSR_AMD_EFER            equ     0xC0000080      ; Extended Feature Enable Register
  105. MSR_AMD_STAR            equ     0xC0000081      ; SYSCALL/SYSRET Target Address Register
  106.  
  107. CR0_PE         equ    0x00000001   ;protected mode
  108. CR0_MP         equ    0x00000002   ;monitor fpu
  109. CR0_EM         equ    0x00000004   ;fpu emulation
  110. CR0_TS         equ    0x00000008   ;task switch
  111. CR0_ET         equ    0x00000010   ;extension type hardcoded to 1
  112. CR0_NE         equ    0x00000020   ;numeric error
  113. CR0_WP         equ    0x00010000   ;write protect
  114. CR0_AM         equ    0x00040000   ;alignment check
  115. CR0_NW         equ    0x20000000   ;not write-through
  116. CR0_CD         equ    0x40000000   ;cache disable
  117. CR0_PG         equ    0x80000000   ;paging
  118.  
  119.  
  120. CR4_VME        equ    0x0001
  121. CR4_PVI        equ    0x0002
  122. CR4_TSD        equ    0x0004
  123. CR4_DE         equ    0x0008
  124. CR4_PSE        equ    0x0010
  125. CR4_PAE        equ    0x0020
  126. CR4_MCE        equ    0x0040
  127. CR4_PGE        equ    0x0080
  128. CR4_PCE        equ    0x0100
  129. CR4_OSFXSR     equ    0x0200
  130. CR4_OSXMMEXPT  equ    0x0400
  131.  
  132. SSE_IE         equ    0x0001
  133. SSE_DE         equ    0x0002
  134. SSE_ZE         equ    0x0004
  135. SSE_OE         equ    0x0008
  136. SSE_UE         equ    0x0010
  137. SSE_PE         equ    0x0020
  138. SSE_DAZ        equ    0x0040
  139. SSE_IM         equ    0x0080
  140. SSE_DM         equ    0x0100
  141. SSE_ZM         equ    0x0200
  142. SSE_OM         equ    0x0400
  143. SSE_UM         equ    0x0800
  144. SSE_PM         equ    0x1000
  145. SSE_FZ         equ    0x8000
  146.  
  147. SSE_INIT equ (SSE_IM+SSE_DM+SSE_ZM+SSE_OM+SSE_UM+SSE_PM)
  148.  
  149. IRQ_PIC        equ    0
  150. IRQ_APIC       equ    1
  151.  
  152. struct  TSS
  153.         _back       rw 2
  154.         _esp0       rd 1
  155.         _ss0        rw 2
  156.         _esp1       rd 1
  157.         _ss1        rw 2
  158.         _esp2       rd 1
  159.         _ss2        rw 2
  160.         _cr3        rd 1
  161.         _eip        rd 1
  162.         _eflags     rd 1
  163.         _eax        rd 1
  164.         _ecx        rd 1
  165.         _edx        rd 1
  166.         _ebx        rd 1
  167.         _esp        rd 1
  168.         _ebp        rd 1
  169.         _esi        rd 1
  170.         _edi        rd 1
  171.         _es         rw 2
  172.         _cs         rw 2
  173.         _ss         rw 2
  174.         _ds         rw 2
  175.         _fs         rw 2
  176.         _gs         rw 2
  177.         _ldt        rw 2
  178.         _trap       rw 1
  179.         _io         rw 1
  180.                     rb 24
  181.         _io_map_0   rb 4096
  182.         _io_map_1   rb 4096
  183. ends
  184.  
  185. DRIVE_DATA_SIZE     equ 16
  186.  
  187. OS_BASE             equ 0x80000000
  188.  
  189. window_data         equ (OS_BASE+0x0001000)
  190.  
  191. CURRENT_TASK        equ (OS_BASE+0x0003000)
  192. TASK_COUNT          equ (OS_BASE+0x0003004)
  193. TASK_BASE           equ (OS_BASE+0x0003010)
  194. TASK_DATA           equ (OS_BASE+0x0003020)
  195. TASK_EVENT          equ (OS_BASE+0x0003020)
  196.  
  197. CDDataBuf           equ (OS_BASE+0x0005000)
  198.  
  199. ;unused                 0x6000 - 0x8fff
  200.  
  201. BOOT_VARS           equ (OS_BASE)               ;0x9000
  202.  
  203. idts                equ (OS_BASE+0x000B100)
  204. WIN_STACK           equ (OS_BASE+0x000C000)
  205. WIN_POS             equ (OS_BASE+0x000C400)
  206. FDD_BUFF            equ (OS_BASE+0x000D000)     ;512
  207.  
  208. WIN_TEMP_XY         equ (OS_BASE+0x000F300)
  209. KEY_COUNT           equ (OS_BASE+0x000F400)
  210. KEY_BUFF            equ (OS_BASE+0x000F401) ; 120*2 + 2*2 = 244 bytes, actually 255 bytes
  211.  
  212. BTN_COUNT           equ (OS_BASE+0x000F500)
  213. BTN_BUFF            equ (OS_BASE+0x000F501)
  214.  
  215.  
  216. BTN_ADDR            equ (OS_BASE+0x000FE88)
  217. MEM_AMOUNT          equ (OS_BASE+0x000FE8C)
  218.  
  219. SYS_SHUTDOWN        equ (OS_BASE+0x000FF00)
  220. TASK_ACTIVATE       equ (OS_BASE+0x000FF01)
  221.  
  222.  
  223. TMP_STACK_TOP       equ 0x006CC00
  224.  
  225. sys_proc            equ (OS_BASE+0x006F000)
  226.  
  227. SLOT_BASE           equ (OS_BASE+0x0080000)
  228.  
  229. VGABasePtr          equ (OS_BASE+0x00A0000)
  230.  
  231. CLEAN_ZONE          equ (_CLEAN_ZONE-OS_BASE)
  232. IDE_DMA             equ (_IDE_DMA-OS_BASE)
  233.  
  234. UPPER_KERNEL_PAGES  equ (OS_BASE+0x0400000)
  235.  
  236. virtual at              (OS_BASE+0x05FFF80)
  237.   tss  TSS
  238. end virtual
  239.  
  240. HEAP_BASE           equ (OS_BASE+0x0800000)
  241. HEAP_MIN_SIZE       equ 0x01000000
  242.  
  243. page_tabs           equ 0xFDC00000
  244. app_page_tabs       equ 0xFDC00000
  245. kernel_tabs         equ (page_tabs+ (OS_BASE shr 10))   ;0xFDE00000
  246. master_tab          equ (page_tabs+ (page_tabs shr 10)) ;0xFDFF70000
  247.  
  248. LFB_BASE            equ 0xFE000000
  249.  
  250.  
  251. new_app_base        equ 0;
  252.  
  253. twdw                equ 0x2000   ;(CURRENT_TASK-window_data)
  254.  
  255. std_application_base_address   equ new_app_base
  256. RING0_STACK_SIZE    equ (0x2000 - 512)    ;512 байт для контекста FPU
  257.  
  258. REG_SS              equ (RING0_STACK_SIZE-4)
  259. REG_APP_ESP         equ (RING0_STACK_SIZE-8)
  260. REG_EFLAGS          equ (RING0_STACK_SIZE-12)
  261. REG_CS              equ (RING0_STACK_SIZE-16)
  262. REG_EIP             equ (RING0_STACK_SIZE-20)
  263. REG_EAX             equ (RING0_STACK_SIZE-24)
  264. REG_ECX             equ (RING0_STACK_SIZE-28)
  265. REG_EDX             equ (RING0_STACK_SIZE-32)
  266. REG_EBX             equ (RING0_STACK_SIZE-36)
  267. REG_ESP             equ (RING0_STACK_SIZE-40)  ;RING0_STACK_SIZE-20
  268. REG_EBP             equ (RING0_STACK_SIZE-44)
  269. REG_ESI             equ (RING0_STACK_SIZE-48)
  270. REG_EDI             equ (RING0_STACK_SIZE-52)
  271. REG_RET             equ (RING0_STACK_SIZE-56)  ;irq0.return
  272.  
  273.  
  274. PAGE_SIZE           equ 4096
  275.  
  276. PG_UNMAP            equ 0x000
  277. PG_READ             equ 0x001
  278. PG_WRITE            equ 0x002
  279. PG_USER             equ 0x004
  280. PG_PCD              equ 0x008
  281. PG_PWT              equ 0x010
  282. PG_ACCESSED         equ 0x020
  283. PG_DIRTY            equ 0x040
  284. PG_PAT              equ 0x080
  285. PG_GLOBAL           equ 0x100
  286. PG_SHARED           equ 0x200
  287.  
  288. PG_SWR              equ 0x003 ; (PG_WRITE+PG_READ)
  289. PG_UR               equ 0x005 ; (PG_USER+PG_READ)
  290. PG_UWR              equ 0x007 ; (PG_USER+PG_WRITE+PG_READ)
  291. PG_NOCACHE          equ 0x018 ; (PG_PCD+PG_PWT)
  292.  
  293. PDE_LARGE           equ 0x080
  294.  
  295. PAT_WB              equ 0x000
  296. PAT_WC              equ 0x008
  297. PAT_UCM             equ 0x010
  298. PAT_UC              equ 0x018
  299.  
  300. PAT_TYPE_UC         equ 0
  301. PAT_TYPE_WC         equ 1
  302. PAT_TYPE_WB         equ 6
  303. PAT_TYPE_UCM        equ 7
  304.  
  305. PAT_VALUE           equ 0x00070106; (UC<<24)|(UCM<<16)|(WC<<8)|WB
  306.  
  307. ;;;;;;;;;;;boot time variables
  308.  
  309. BOOT_BPP            equ 0x9000    ;byte   bits per pixel
  310. BOOT_PITCH          equ 0x9001    ;word   scanline length
  311. BOOT_VESA_MODE      equ 0x9008    ;word   vesa video mode
  312. BOOT_X_RES          equ 0x900A    ;word   X res
  313. BOOT_Y_RES          equ 0x900C    ;word   Y res
  314. BOOT_BANK_SW        equ 0x9014    ;dword  Vesa 1.2 pm bank switch
  315. BOOT_LFB            equ 0x9018    ;dword  Vesa 2.0 LFB address
  316. BOOT_MTRR           equ 0x901C    ;byte   0 or 1 : enable MTRR graphics acceleration
  317. ;BOOT_LOG            equ 0x901D    ;byte   not used anymore (0 or 1 : enable system log display)
  318. BOOT_LAUNCHER_START equ 0x901D    ;byte  (0 or 1) start the first app (right now it's LAUNCHER) after kernel is loaded?
  319. ;BOOT_DIRECT_LFB     equ 0x901E    ;byte   0 or 1 : enable direct lfb write, paging disabled
  320. BOOT_DEBUG_PRINT    equ 0x901E    ;byte   If nonzero, duplicates debug output to the screen.
  321. BOOT_DMA            equ 0x901F    ;
  322. BOOT_PCI_DATA       equ 0x9020    ;8bytes pci data
  323. BOOT_VRR            equ 0x9030    ;byte   VRR start enabled 1, 2-no
  324. ;BOOT_IDE_BASE_ADDR  equ 0x9031   ;word   IDEContrRegsBaseAddr ; now free and is not used
  325. BOOT_MEM_AMOUNT     equ 0x9034    ;dword  memory amount
  326.  
  327. BOOT_APM_ENTRY      equ 0x9040
  328. BOOT_APM_VERSION    equ 0x9044
  329. BOOT_APM_FLAGS      equ 0x9046    ;unused
  330. BOOT_APM_CODE_32    equ 0x9050
  331. BOOT_APM_CODE_16    equ 0x9052
  332. BOOT_APM_DATA_16    equ 0x9054
  333. ;BOOT_IDE_BAR0_16    equ 0x9056 ; now free and is not used
  334. ;BOOT_IDE_BAR1_16    equ 0x9058 ; now free and is not used
  335. ;BOOT_IDE_BAR2_16    equ 0x905A ; now free and is not used
  336. ;BOOT_IDE_BAR3_16    equ 0x905C ; now free and is not used
  337. ;BOOT_IDE_PI_16      equ 0x905E ; now free and is not used
  338. ;BOOT_IDE_INTERR_16  equ 0x9060 ; now free and is not used
  339.  
  340. TMP_FILE_NAME       equ     0
  341. TMP_CMD_LINE        equ  1024
  342. TMP_ICON_OFFS       equ  1280
  343.  
  344.  
  345. EVENT_REDRAW       equ 0x00000001
  346. EVENT_KEY          equ 0x00000002
  347. EVENT_BUTTON       equ 0x00000004
  348. EVENT_BACKGROUND   equ 0x00000010
  349. EVENT_MOUSE        equ 0x00000020
  350. EVENT_IPC          equ 0x00000040
  351. EVENT_NETWORK      equ 0x00000080
  352. EVENT_DEBUG        equ 0x00000100
  353. EVENT_NETWORK2     equ 0x00000200
  354. EVENT_EXTENDED     equ 0x00000400
  355.  
  356. EV_INTR            equ 1
  357.  
  358. struct  THR_DATA
  359.                         rb (8192-512)
  360. ;       pl0_stack
  361.         fpu_state       rb 512
  362.         tls_page        rb 4096
  363.         pdbr            rb 4096
  364. ends
  365.  
  366. virtual at (OS_BASE-sizeof.THR_DATA)
  367.   thr_data  THR_DATA
  368. end virtual
  369.  
  370. struct  SYS_VARS
  371.         bpp             dd ?
  372.         scanline        dd ?
  373.         vesa_mode       dd ?
  374.         x_res           dd ?
  375.         y_res           dd ?
  376. ends
  377.  
  378. struct  APPOBJ                  ; common object header
  379.         magic           dd ?    ;
  380.         destroy         dd ?    ; internal destructor
  381.         fd              dd ?    ; next object in list
  382.         bk              dd ?    ; prev object in list
  383.         pid             dd ?    ; owner id
  384. ends
  385.  
  386. APP_OBJ_OFFSET  equ 48
  387. APP_EV_OFFSET   equ 40
  388.  
  389. struct  CURSOR          APPOBJ
  390.         base            dd ?   ;allocated memory
  391.         hot_x           dd ?   ;hotspot coords
  392.         hot_y           dd ?
  393.  
  394.         list_next       dd ?   ;next cursor in cursor list
  395.         list_prev       dd ?   ;prev cursor in cursor list
  396.         dev_obj         dd ?   ;device depended data
  397. ends
  398.  
  399.  
  400. struct  EVENT           APPOBJ
  401.         id              dd ?   ;event uid
  402.         state           dd ?   ;internal flags
  403.         code            dd ?
  404.                         rd 5
  405. ends
  406.  
  407.  
  408. struct  SMEM
  409.         bk              dd ?
  410.         fd              dd ?    ;+4
  411.         base            dd ?    ;+8
  412.         size            dd ?    ;+12
  413.         access          dd ?    ;+16
  414.         refcount        dd ?    ;+20
  415.         name            rb 32   ;+24
  416. ends
  417.  
  418. struct  SMAP            APPOBJ
  419.         base            dd ?   ;mapped base
  420.         parent          dd ?   ;SMEM
  421. ends
  422.  
  423. struct  DLLDESCR
  424.         bk              dd ?
  425.         fd              dd ?    ;+4
  426.         data            dd ?    ;+8
  427.         size            dd ?    ;+12
  428.         timestamp       dq ?
  429.         refcount        dd ?
  430.         defaultbase     dd ?
  431.         coff_hdr        dd ?
  432.         symbols_ptr     dd ?
  433.         symbols_num     dd ?
  434.         symbols_lim     dd ?
  435.         exports         dd ?   ;export table
  436.         name            rb 260
  437. ends
  438.  
  439. struct  HDLL
  440.         fd              dd ?   ;next object in list
  441.         bk              dd ?   ;prev object in list
  442.         pid             dd ?   ;owner id
  443.  
  444.         base            dd ?   ;mapped base
  445.         size            dd ?   ;mapped size
  446.         refcount        dd ?   ;reference counter for this process and this lib
  447.         parent          dd ?   ;DLLDESCR
  448. ends
  449.  
  450.  
  451. struct  BOOT_DATA
  452.         bpp             dd ?
  453.         scanline        dd ?
  454.         vesa_mode       dd ?
  455.         x_res           dd ?
  456.         y_res           dd ?
  457.         mouse_port      dd ?
  458.         bank_switch     dd ?
  459.         lfb             dd ?
  460.         vesa_mem        dd ?
  461.         log             dd ?
  462.         direct_lfb      dd ?
  463.         pci_data        dd ?
  464.                         dd ?
  465.         vrr             dd ?
  466.         ide_base        dd ?
  467.         mem_amount      dd ?
  468.         pages_count     dd ?
  469.         pagemap_size    dd ?
  470.         kernel_max      dd ?
  471.         kernel_pages    dd ?
  472.         kernel_tables   dd ?
  473.  
  474.         cpu_vendor      dd ?
  475.                         dd ?
  476.                         dd ?
  477.         cpu_sign        dd ?
  478.         cpu_info        dd ?
  479.         cpu_caps        dd ?
  480.                         dd ?
  481.                         dd ?
  482. ends
  483.  
  484. struct  LHEAD
  485.         next            dd ?   ;next object in list
  486.         prev            dd ?   ;prev object in list
  487. ends
  488.  
  489. struct  MUTEX
  490.         wait_list       LHEAD
  491.         count           dd ?
  492. ends
  493.  
  494. struct  RWSEM
  495.         wait_list       LHEAD
  496.         count   dd ?
  497. ends
  498.  
  499. struct  display_t
  500.         x               dd ?
  501.         y               dd ?
  502.         width           dd ?
  503.         height          dd ?
  504.         bits_per_pixel  dd ?
  505.         vrefresh        dd ?
  506.         lfb             dd ?
  507.         lfb_pitch       dd ?
  508.  
  509.         win_map_lock    RWSEM
  510.         win_map         dd ?
  511.         win_map_pitch   dd ?
  512.         win_map_size    dd ?
  513.  
  514.         modes           dd ?
  515.         ddev            dd ?
  516.         connector       dd ?
  517.         crtc            dd ?
  518.  
  519.         cr_list.next    dd ?
  520.         cr_list.prev    dd ?
  521.  
  522.         cursor          dd ?
  523.  
  524.         init_cursor     dd ?
  525.         select_cursor   dd ?
  526.         show_cursor     dd ?
  527.         move_cursor     dd ?
  528.         restore_cursor  dd ?
  529.         disable_mouse   dd ?
  530.         mask_seqno      dd ?
  531.         check_mouse     dd ?
  532.         check_m_pixel   dd ?
  533.  
  534.         bytes_per_pixel dd ?
  535. ends
  536.  
  537.  
  538. struct  PCIDEV
  539.         bk              dd ?
  540.         fd              dd ?
  541.         vendor_device_id dd ?
  542.         class           dd ?
  543.         devfn           db ?
  544.         bus             db ?
  545.                         rb 2
  546.         owner           dd ? ; pointer to SRV or 0
  547. ends
  548.  
  549. ; The following macro assume that we are on uniprocessor machine.
  550. ; Serious work is needed for multiprocessor machines.
  551. macro spin_lock_irqsave spinlock
  552. {
  553.         pushf
  554.         cli
  555. }
  556. macro spin_unlock_irqrestore spinlock
  557. {
  558.         popf
  559. }
  560. macro spin_lock_irq spinlock
  561. {
  562.         cli
  563. }
  564. macro spin_unlock_irq spinlock
  565. {
  566.         sti
  567. }
  568.  
  569. struct  MEM_STATE
  570.         mutex           MUTEX
  571.         smallmap        dd ?
  572.         treemap         dd ?
  573.         topsize         dd ?
  574.         top             dd ?
  575.         smallbins       rd 4*32
  576.         treebins        rd 32
  577. ends
  578.  
  579. struct  PG_DATA
  580.         mem_amount      dd ?
  581.         vesa_mem        dd ?
  582.         pages_count     dd ?
  583.         pages_free      dd ?
  584.         pages_faults    dd ?
  585.         pagemap_size    dd ?
  586.         kernel_pages    dd ?
  587.         kernel_tables   dd ?
  588.         sys_page_dir    dd ?
  589.         mutex           MUTEX
  590. ends
  591.  
  592. struct  SRV
  593.         srv_name        rb 16    ;ASCIIZ string
  594.         magic           dd ?     ;+0x10 ;'SRV '
  595.         size            dd ?     ;+0x14 ;size of structure SRV
  596.         fd              dd ?     ;+0x18 ;next SRV descriptor
  597.         bk              dd ?     ;+0x1C ;prev SRV descriptor
  598.         base            dd ?     ;+0x20 ;service base address
  599.         entry           dd ?     ;+0x24 ;service START function
  600.         srv_proc        dd ?     ;+0x28 ;user mode service handler
  601.         srv_proc_ex     dd ?     ;+0x2C ;kernel mode service handler
  602. ends
  603.  
  604. struct USBSRV
  605.         srv             SRV
  606.         usb_func        dd ?
  607. ends
  608.  
  609. struct USBFUNC
  610.         strucsize       dd ?
  611.         add_device      dd ?
  612.         device_disconnect dd ?
  613. ends
  614.  
  615. DRV_ENTRY    equ  1
  616. DRV_EXIT     equ -1
  617.  
  618. struct  COFF_HEADER
  619.         machine         dw ?
  620.         nSections       dw ?
  621.         DataTime        dd ?
  622.         pSymTable       dd ?
  623.         nSymbols        dd ?
  624.         optHeader       dw ?
  625.         flags           dw ?
  626. ends
  627.  
  628. struct  COFF_SECTION
  629.         Name            rb 8
  630.         VirtualSize     dd ?
  631.         VirtualAddress  dd ?
  632.         SizeOfRawData   dd ?
  633.         PtrRawData      dd ?
  634.         PtrReloc        dd ?
  635.         PtrLinenumbers  dd ?
  636.         NumReloc        dw ?
  637.         NumLinenum      dw ?
  638.         Characteristics dd ?
  639. ends
  640.  
  641. struct  COFF_RELOC
  642.         VirtualAddress  dd ?
  643.         SymIndex        dd ?
  644.         Type            dw ?
  645. ends
  646.  
  647. struct  COFF_SYM
  648.         Name            rb 8
  649.         Value           dd ?
  650.         SectionNumber   dw ?
  651.         Type            dw ?
  652.         StorageClass    db ?
  653.         NumAuxSymbols   db ?
  654. ends
  655.  
  656. struct  STRIPPED_PE_HEADER
  657.         Signature           dw ?
  658.         Characteristics     dw ?
  659.         AddressOfEntryPoint dd ?
  660.         ImageBase           dd ?
  661.         SectionAlignmentLog db ?
  662.         FileAlignmentLog    db ?
  663.         MajorOSVersion      db ?
  664.         MinorOSVersion      db ?
  665.         SizeOfImage         dd ?
  666.         SizeOfStackReserve  dd ?
  667.         SizeOfHeapReserve   dd ?
  668.         SizeOfHeaders       dd ?
  669.         Subsystem           db ?
  670.         NumberOfRvaAndSizes db ?
  671.         NumberOfSections    dw ?
  672. ends
  673. STRIPPED_PE_SIGNATURE = 0x4503 ; 'PE' xor 'S'
  674. SPE_DIRECTORY_IMPORT    = 0
  675. SPE_DIRECTORY_EXPORT    = 1
  676. SPE_DIRECTORY_BASERELOC = 2
  677.  
  678. struct  IOCTL
  679.         handle          dd ?
  680.         io_code         dd ?
  681.         input           dd ?
  682.         inp_size        dd ?
  683.         output          dd ?
  684.         out_size        dd ?
  685. ends
  686.  
  687. struct  IRQH
  688.         list            LHEAD
  689.         handler         dd ?   ;handler roututine
  690.         data            dd ?   ;user-specific data
  691.         num_ints        dd ?   ;how many times handled
  692. ends
  693.