Subversion Repositories Kolibri OS

Rev

Rev 9325 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. ; TODO: SPDX
  2.  
  3. format ELF
  4.  
  5. __DEBUG__ = 1
  6. __DEBUG_LEVEL__ = 1
  7.  
  8. UMKA_SHELL = 1
  9. UMKA_FUSE  = 2
  10. UMKA_OS    = 3
  11.  
  12. UMKA_MEMORY_BYTES = 256 SHL 20
  13.  
  14. public umka_sys_put_image_palette
  15. public disk_add
  16. public disk_del
  17. public disk_list
  18. public disk_media_changed
  19.  
  20. public xfs._.user_functions as 'xfs_user_functions'
  21. public ext_user_functions
  22. public fat_user_functions
  23. public ntfs_user_functions
  24.  
  25. public i40
  26.  
  27. public coverage_begin
  28. public coverage_end
  29.  
  30. public sha3_256_oneshot as 'hash_oneshot'
  31. public kos_time_to_epoch
  32. public umka_init
  33.  
  34. public current_process as 'kos_current_process'
  35. public current_slot as 'kos_current_slot'
  36. public current_slot_idx as 'kos_current_slot_idx'
  37.  
  38. public thread_count as 'kos_thread_count'
  39. public TASK_TABLE as 'kos_task_table'
  40. public TASK_BASE as 'kos_task_base'
  41. public TASK_DATA as 'kos_task_data'
  42. public SLOT_BASE as 'kos_slot_base'
  43. public window_data as 'kos_window_data'
  44.  
  45. public WIN_STACK as 'kos_win_stack'
  46. public WIN_POS as 'kos_win_pos'
  47. public lfb_base as 'kos_lfb_base'
  48.  
  49. public RAMDISK as 'kos_ramdisk'
  50. public ramdisk_init as 'kos_ramdisk_init'
  51.  
  52. public acpi_ssdt_cnt as 'kos_acpi_ssdt_cnt'
  53. public acpi_ssdt_base as 'kos_acpi_ssdt_base'
  54. public acpi_ssdt_size as 'kos_acpi_ssdt_size'
  55.  
  56. public stack_init as 'kos_stack_init'
  57. public net_add_device
  58.  
  59. public draw_data
  60. public img_background
  61. public mem_BACKGROUND
  62. public sys_background
  63. public REDRAW_BACKGROUND as 'kos_redraw_background'
  64. public new_sys_threads as 'kos_new_sys_threads'
  65. public osloop as 'kos_osloop'
  66. public set_mouse_data as 'kos_set_mouse_data'
  67. public scheduler_current as 'kos_scheduler_current'
  68. public eth_input as 'kos_eth_input'
  69. public net_buff_alloc as 'kos_net_buff_alloc'
  70.  
  71. public mem_block_list
  72.  
  73. public acpi_dev_data as "kos_acpi_dev_data"
  74. public acpi_dev_size as "kos_acpi_dev_size"
  75. public kernel_alloc as "kos_kernel_alloc"
  76.  
  77. public window._.set_screen as 'kos_window_set_screen'
  78. public _display as 'kos_display'
  79.  
  80. public BOOT as 'kos_boot'
  81.  
  82. macro cli {
  83.         pushfd
  84.         bts     dword[esp], 21
  85.         popfd
  86. }
  87.  
  88. macro sti {
  89.         pushfd
  90.         btr     dword[esp], 21
  91.         popfd
  92. }
  93.  
  94.         iretd   equ retd
  95.  
  96. lang fix en
  97.  
  98. macro int n {
  99.   if n eq 0x40
  100.         call    i40
  101.   else
  102.         int     n
  103.   end if
  104. }
  105.  
  106. section '.text' executable align 64
  107.  
  108. coverage_begin:
  109.  
  110. include 'macros.inc'
  111.  
  112. macro diff16 msg,blah2,blah3 {
  113.   if msg eq "end of .data segment"
  114. ; fasm doesn't align on 65536, but ld script does
  115. section '.bss.aligned65k' writeable align 65536
  116. bss_base:
  117.   end if
  118. }
  119. include 'proc32.inc'
  120. include 'struct.inc'
  121. macro BOOT_LO a {}
  122. macro BOOT a {}
  123. window_data equ __pew01
  124. TASK_TABLE equ __pew02
  125. TASK_BASE equ __pew03
  126. TASK_DATA equ __pew04
  127. CDDataBuf equ __pew06
  128. idts equ __pew07
  129. WIN_STACK equ __pew08
  130. WIN_POS equ __pew09
  131. FDD_BUFF equ __pew10
  132. WIN_TEMP_XY equ __pew11
  133. KEY_COUNT equ __pew12
  134. KEY_BUFF equ __pew13
  135. BTN_COUNT equ __pew14
  136. BTN_BUFF equ __pew15
  137. BTN_ADDR equ __pew16
  138. MEM_AMOUNT equ __pew17
  139. SYS_SHUTDOWN equ __pew18
  140. SLOT_BASE equ __pew20
  141. sys_proc equ __pew21
  142. VGABasePtr equ __pew22
  143. HEAP_BASE equ __pew23
  144. ;macro OS_BASE [x] {
  145. ;  OS_BASE equ os_base
  146. ;}
  147. include 'const.inc'
  148. restore window_data
  149. restore TASK_TABLE
  150. restore TASK_BASE,TASK_DATA,CDDataBuf,idts,WIN_STACK,WIN_POS
  151. restore FDD_BUFF,WIN_TEMP_XY,KEY_COUNT,KEY_BUFF,BTN_COUNT,BTN_BUFF,BTN_ADDR
  152. restore MEM_AMOUNT,SYS_SHUTDOWN,SLOT_BASE,sys_proc,VGABasePtr
  153. restore HEAP_BASE
  154. purge BOOT_LO,BOOT
  155.  
  156. LFB_BASE = lfb_base
  157.  
  158. macro save_ring3_context {
  159.         pushad
  160. }
  161.  
  162. macro restore_ring3_context {
  163.         popad
  164. }
  165.  
  166. macro add r, v {
  167.   if v eq TASK_TABLE - (SLOT_BASE shr 3)
  168.         push    r
  169.         mov     r, SLOT_BASE
  170.         shr     r, 3
  171.         neg     r
  172.         add     r, TASK_TABLE
  173.         add     esp, 4
  174.         add     r, [esp-4]
  175.   else
  176.         add     r, v
  177.   end if
  178. }
  179.  
  180. macro stdcall target, [args] {
  181. common
  182.   if target eq is_region_userspace
  183.         cmp     esp, esp        ; ZF
  184.   else
  185.         stdcall target, args
  186.   end if
  187. }
  188.  
  189. include 'system.inc'
  190. include 'fdo.inc'
  191.  
  192. include 'core/sync.inc'
  193. ;include 'core/sys32.inc'
  194. macro call target {
  195.   if target eq do_change_task
  196.         call    _do_change_task
  197.   else
  198.         call    target
  199.   end if
  200. }
  201. ;macro mov r, v {
  202. ;  if r eq byte [current_slot_idx] & v eq bh
  203. ;        push    eax
  204. ;        mov     eax, ebx
  205. ;        sub     eax, SLOT_BASE
  206. ;        shr     eax, BSF sizeof.APPDATA
  207. ;        mov     [current_slot_idx], eax
  208. ;        pop     eax
  209. ;  else
  210. ;        mov     r, v
  211. ;  end if
  212. ;}
  213. do_change_task equ hjk
  214. irq0 equ jhg
  215. include 'core/sched.inc'
  216. purge call, mov
  217. restore irq0
  218. include 'core/syscall.inc'
  219. ;include 'core/fpu.inc'
  220. ;include 'core/memory.inc'
  221. ;include 'core/mtrr.inc'
  222. include 'core/heap.inc'
  223. include 'core/malloc.inc'
  224. include 'core/taskman.inc'
  225. include 'core/dll.inc'
  226. ;include 'core/peload.inc'
  227. ;include 'core/exports.inc'
  228. include 'core/string.inc'
  229. ;include 'core/v86.inc'
  230. include 'core/irq.inc'
  231. include 'core/apic.inc'
  232. include 'core/hpet.inc'
  233. include 'core/timers.inc'
  234. include 'core/clipboard.inc'
  235. include 'core/slab.inc'
  236.  
  237. include 'posix/posix.inc'
  238.  
  239. ;include 'boot/shutdown.inc'
  240.  
  241. include 'video/vesa20.inc'
  242. include 'video/blitter.inc'
  243. include 'video/vga.inc'
  244. include 'video/cursors.inc'
  245. include 'video/framebuffer.inc'
  246.  
  247. include 'gui/window.inc'
  248. include 'gui/event.inc'
  249. include 'gui/font.inc'
  250. include 'gui/button.inc'
  251. include 'gui/mouse.inc'
  252. include 'gui/skincode.inc'
  253.  
  254. include 'hid/keyboard.inc'
  255. include 'hid/mousedrv.inc'
  256. ;include 'hid/set_dtc.inc'      ; setting date,time,clock and alarm-clock
  257.  
  258. include 'sound/playnote.inc'
  259.  
  260. ;include 'bus/pci/pci32.inc'
  261. ;include 'bus/usb/init.inc'
  262.  
  263. ;include 'blkdev/flp_drv.inc'   ; floppy driver
  264. ;include 'blkdev/fdc.inc'
  265. ;include 'blkdev/cd_drv.inc'    ; CD driver
  266. ;include 'blkdev/ide_cache.inc' ; CD cache
  267. ;include 'blkdev/hd_drv.inc'    ; HDD driver
  268. ;include 'blkdev/bd_drv.inc'    ; BIOS disks driver
  269. include 'blkdev/rd.inc'         ; ramdisk driver
  270. include 'blkdev/disk.inc'
  271. include 'blkdev/disk_cache.inc'
  272.  
  273. include 'fs/fs_lfn.inc'
  274.  
  275. include 'network/stack.inc'
  276.  
  277. include 'crc.inc'
  278. include 'unicode.inc'
  279. include 'acpi/acpi.inc'
  280.  
  281. include 'unpacker.inc'
  282.  
  283. LIBCRASH_CTX_LEN = 0x500   ; FIXME
  284. include 'sha3.asm'
  285.  
  286. ; TODO: stdcall attribute in umka.h
  287. proc sha3_256_oneshot c uses ebx esi edi ebp, _ctx, _data, _len
  288.         stdcall sha3_256.oneshot, [_ctx], [_data], [_len]
  289.         ret
  290. endp
  291.  
  292. proc kos_time_to_epoch c uses ebx esi edi ebp, _time
  293.         mov     esi, [_time]
  294.         call    fsCalculateTime
  295.         add     eax, 978307200  ; epoch to 2001.01.01
  296.         ret
  297. endp
  298.  
  299. proc umka._.check_alignment
  300.         mov     eax, HEAP_BASE
  301.         and     eax, PAGE_SIZE - 1
  302.         jz      @f
  303.         mov     ecx, PAGE_SIZE
  304.         sub     ecx, eax
  305.         DEBUGF 4, "HEAP_BASE must be aligned on PAGE_SIZE: 0x%x", HEAP_BASE
  306.         DEBUGF 4, ", add 0x%x or sub 0x%x\n", ecx, eax
  307.         int3
  308. @@:
  309.         ret
  310. endp
  311.  
  312. proc umka_init c uses ebx esi edi ebp
  313.         mov     [umka_initialized], 1
  314.         call    umka._.check_alignment
  315.  
  316.         mov     edi, endofcode
  317.         mov     ecx, uglobals_size
  318.         xor     eax, eax
  319.         rep stosb
  320.  
  321.         mov     [xsave_area_size], 0x1000
  322.  
  323.         mov     ecx, pg_data.mutex
  324.         call    mutex_init
  325.  
  326.         mov     ecx, disk_list_mutex
  327.         call    mutex_init
  328.  
  329.         mov     ecx, keyboard_list_mutex
  330.         call    mutex_init
  331.  
  332.         mov     ecx, unpack_mutex
  333.         call    mutex_init
  334.  
  335.         mov     ecx, application_table_mutex
  336.         call    mutex_init
  337.  
  338.         mov     ecx, ide_mutex
  339.         call    mutex_init
  340.         mov     ecx, ide_channel1_mutex
  341.         call    mutex_init
  342.         mov     ecx, ide_channel2_mutex
  343.         call    mutex_init
  344.         mov     ecx, ide_channel3_mutex
  345.         call    mutex_init
  346.         mov     ecx, ide_channel4_mutex
  347.         call    mutex_init
  348.         mov     ecx, ide_channel5_mutex
  349.         call    mutex_init
  350.         mov     ecx, ide_channel6_mutex
  351.         call    mutex_init
  352.  
  353.         mov     [pg_data.mem_amount], UMKA_MEMORY_BYTES
  354.         mov     [pg_data.pages_count], UMKA_MEMORY_BYTES / PAGE_SIZE
  355.         mov     [pg_data.pages_free], UMKA_MEMORY_BYTES / PAGE_SIZE
  356.         mov     eax, UMKA_MEMORY_BYTES SHR 12
  357.         mov     [pg_data.kernel_pages], eax
  358.         shr     eax, 10
  359.         mov     [pg_data.kernel_tables], eax
  360.         call    init_kernel_heap
  361.         call    init_malloc
  362.  
  363.         mov     eax, sys_proc
  364.         list_init eax
  365.         add     eax, PROC.thr_list
  366.         list_init eax
  367.  
  368.         mov     [BOOT.lfb], LFB_BASE
  369.         call    init_video
  370.  
  371.         stdcall alloc_kernel_space, 0x50000         ; FIXME check size
  372.         mov     [default_io_map], eax
  373.  
  374.         add     eax, 0x2000
  375.         mov     [ipc_tmp], eax
  376.         mov     ebx, 0x1000
  377.  
  378.         add     eax, 0x40000
  379.         mov     [proc_mem_map], eax
  380.  
  381.         add     eax, 0x8000
  382.         mov     [proc_mem_pdir], eax
  383.  
  384.         add     eax, ebx
  385.         mov     [proc_mem_tab], eax
  386.  
  387.         add     eax, ebx
  388.         mov     [tmp_task_ptab], eax
  389.  
  390.         add     eax, ebx
  391.         mov     [ipc_pdir], eax
  392.  
  393.         add     eax, ebx
  394.         mov     [ipc_ptab], eax
  395.  
  396.         stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \
  397.                 (unpack.lc+unpack.lp)))*4
  398.         mov     [unpack.p], eax
  399.  
  400.         call    init_events
  401.         mov     eax, srv.fd-SRV.fd
  402.         mov     [srv.fd], eax
  403.         mov     [srv.bk], eax
  404.  
  405.         stdcall kernel_alloc, [_display.win_map_size]
  406.         mov     [_display.win_map], eax
  407.  
  408. ; set background
  409.         movi    eax, 1
  410.         mov     [BgrDrawMode], eax
  411.         mov     [BgrDataWidth], eax
  412.         mov     [BgrDataHeight], eax
  413.         mov     [mem_BACKGROUND], 4
  414.         mov     [img_background], static_background_data
  415.  
  416. ; set clipboard
  417.         xor     eax, eax
  418.         mov     [clipboard_slots], eax
  419.         mov     [clipboard_write_lock], eax
  420.         stdcall kernel_alloc, 4096
  421.         test    eax, eax
  422.         jnz     @f
  423.  
  424.         dec     eax
  425. @@:
  426.         mov     [clipboard_main_list], eax
  427.  
  428.         mov     dword[sysdir_name], 'sys'
  429.         mov     dword[sysdir_path], 'RD/1'
  430.         mov     word[sysdir_path+4], 0
  431.  
  432.         ;call    ramdisk_init
  433.  
  434.         mov     [X_UNDER], 500
  435.         mov     [Y_UNDER], 500
  436.         mov     word[MOUSE_X], 40
  437.         mov     word[MOUSE_Y], 30
  438.  
  439.         mov     eax, -1
  440.         mov     edi, thr_slot_map+4
  441.         mov     [edi-4], dword 0xFFFFFFF8
  442.         stosd
  443.         stosd
  444.         stosd
  445.         stosd
  446.         stosd
  447.         stosd
  448.         stosd
  449.  
  450.         mov     [current_process], sys_proc
  451.  
  452.         mov     [current_slot_idx], 0
  453.         mov     [thread_count], 0
  454.  
  455.         mov     eax, [xsave_area_size]
  456.         add     eax, RING0_STACK_SIZE
  457.         stdcall kernel_alloc, eax
  458.         mov     ebx, eax
  459.         mov     edx, SLOT_BASE+256*1
  460.         call    setup_os_slot
  461.         mov     dword[edx], 'IDLE'
  462.         sub     [edx+APPDATA.saved_esp], 4
  463.         mov     eax, [edx+APPDATA.saved_esp]
  464.         mov     dword[eax], idle
  465.         mov     ecx, IDLE_PRIORITY
  466.         call    scheduler_add_thread
  467.  
  468.         mov     eax, [xsave_area_size]
  469.         add     eax, RING0_STACK_SIZE
  470.         stdcall kernel_alloc, eax
  471.         mov     ebx, eax
  472.         mov     edx, SLOT_BASE+256*2
  473.         call    setup_os_slot
  474.         mov     dword[edx], 'OS'
  475.         sub     [edx+APPDATA.saved_esp], 4
  476.         mov     eax, [edx+APPDATA.saved_esp]
  477.         mov     dword[eax], 0
  478.         xor     ecx, ecx
  479.         call    scheduler_add_thread
  480.  
  481.         mov     [current_slot_idx], 2
  482.         mov     [thread_count], 2
  483.         mov     dword[TASK_BASE], TASK_TABLE + 2*sizeof.TASKDATA
  484.         mov     [current_slot], SLOT_BASE+2*sizeof.APPDATA
  485.         mov     [TASK_TABLE + 2*sizeof.TASKDATA + TASKDATA.pid], 2
  486.  
  487.         call    set_window_defaults
  488.         call    init_background
  489.         call    calculatebackground
  490.         call    init_display
  491.         mov     eax, [def_cursor]
  492.         mov     [SLOT_BASE+APPDATA.cursor+sizeof.APPDATA], eax
  493.         mov     [SLOT_BASE+APPDATA.cursor+sizeof.APPDATA*2], eax
  494.  
  495.         ; from set_variables
  496.         xor     eax, eax
  497.         mov     [BTN_ADDR], dword BUTTON_INFO   ; address of button list
  498.         mov     byte [KEY_COUNT], al            ; keyboard buffer
  499.         mov     byte [BTN_COUNT], al            ; button buffer
  500.  
  501.         mov     ebx, SLOT_BASE + 2*sizeof.APPDATA
  502.         mov     word[cur_dir.path], '/'
  503.         mov     [ebx+APPDATA.cur_dir], cur_dir
  504.  
  505.         ret
  506. endp
  507.  
  508. public skin_udata
  509. proc idle uses ebx esi edi
  510. .loop:
  511.         mov     ecx, 10000000
  512. @@:
  513.         loop    @b
  514. ;        DEBUGF 1, "1 idle\n"
  515.         jmp     .loop
  516.  
  517.         ret
  518. endp
  519.  
  520. extrn pci_read
  521. proc pci_read_reg uses ebx esi edi
  522.         mov     ecx, eax
  523.         and     ecx, 3
  524.         movi    edx, 1
  525.         shl     edx, cl
  526.         push    edx     ; len
  527.         movzx   edx, bl
  528.         push    edx     ; offset
  529.         movzx   edx, bh
  530.         and     edx, 7
  531.         push    edx     ; fun
  532.         movzx   edx, bh
  533.         shr     edx, 3
  534.         push    edx     ; dev
  535.         movzx   edx, ah
  536.         push    edx     ; bus
  537.         call    pci_read
  538.         ret
  539. endp
  540.  
  541. proc sys_msg_board
  542.         cmp     cl, 0x0d
  543.         jz      @f
  544.         pushad
  545.         mov     eax, SYS_WRITE
  546.         mov     ebx, STDOUT
  547.         push    ecx
  548.         mov     ecx, esp
  549.         mov     edx, 1
  550.         int     0x80
  551.         pop     ecx
  552.         popad
  553. @@:
  554.         ret
  555. endp
  556.  
  557. proc delay_ms
  558.  
  559.         ret
  560. endp
  561.  
  562. public umka_cli
  563. proc umka_cli
  564.         cli     ; macro
  565.         ret
  566. endp
  567.  
  568. public umka_sti
  569. proc umka_sti
  570.         sti     ; macro
  571.         ret
  572. endp
  573.  
  574. proc umka_sys_put_image_palette c, image, xsize, ysize, x, y, bpp, palette, row_offset
  575.         pushad
  576.         push    ebp
  577.         mov     eax, 65
  578.         mov     ebx, [image]
  579.         mov     ecx, [xsize]
  580.         shl     ecx, 16
  581.         or      ecx, [ysize]
  582.         mov     edx, [x]
  583.         shl     edx, 16
  584.         or      edx, [y]
  585.         mov     esi, [bpp]
  586.         mov     edi, [palette]
  587.         mov     ebp, [row_offset]
  588.         call    i40
  589.         pop     ebp
  590.         popad
  591.         ret
  592. endp
  593.  
  594. extrn reset_procmask
  595. extrn get_fake_if
  596. public irq0
  597. proc irq0 c, _signo, _info, _context
  598.         DEBUGF 2, "### irq0\n"
  599.         pushfd
  600.         cli
  601.         pushad
  602.  
  603.         inc     [timer_ticks]
  604.         call    updatecputimes
  605.         ccall   reset_procmask
  606.         ccall   get_fake_if, [_context]
  607.         test    eax, eax
  608.         jnz     @f
  609.         DEBUGF 2, "### cli\n"
  610.         jmp     .done
  611. @@:
  612.  
  613.         mov     bl, SCHEDULE_ANY_PRIORITY
  614.         call    find_next_task
  615.         jz      .done  ; if there is only one running process
  616.         call    _do_change_task
  617. .done:
  618.         popad
  619.         popfd
  620.         ret
  621. endp
  622.  
  623. proc _do_change_task
  624.         mov     eax, [current_slot]
  625.         sub     eax, SLOT_BASE
  626.         shr     eax, 8
  627.         mov     ecx, ebx
  628.         sub     ecx, SLOT_BASE
  629.         shr     ecx, 8
  630.         DEBUGF 2, "### switching task from %d to %d\n",eax,ecx
  631.  
  632.         mov     esi, ebx
  633.         xchg    esi, [current_slot]
  634. ; set new stack after saving old
  635.         mov     [esi+APPDATA.saved_esp], esp
  636.         mov     esp, [ebx+APPDATA.saved_esp]
  637.         ret
  638. endp
  639.  
  640. proc map_io_mem _base, _size, _flags
  641.         mov     eax, [_base]
  642.         ret
  643. endp
  644.  
  645. sysfn_saveramdisk:
  646. sysfn_meminfo:
  647. check_fdd_motor_status:
  648. check_ATAPI_device_event:
  649. check_fdd_motor_status_has_work?:
  650. check_ATAPI_device_event_has_work?:
  651. request_terminate:
  652. system_shutdown:
  653. terminate:
  654. LoadMedium:
  655. clear_CD_cache:
  656. allow_medium_removal:
  657. EjectMedium:
  658. save_image:
  659. init_sys_v86:
  660. pci_enum:
  661. load_pe_driver:
  662. usb_init:
  663. fdc_init:
  664. mtrr_validate:
  665. protect_from_terminate:
  666. unprotect_from_terminate:
  667. ReadCDWRetr:
  668. WaitUnitReady:
  669. prevent_medium_removal:
  670. Read_TOC:
  671. commit_pages:
  672. release_pages:
  673. lock_application_table:
  674. unlock_application_table:
  675. get_pg_addr:
  676. free_page:
  677. build_interrupt_table:
  678. init_fpu:
  679. init_mtrr:
  680. create_trampoline_pgmap:
  681. alloc_page:
  682. pci_write_reg:
  683.  
  684. sys_settime:
  685. sys_pcibios:
  686. sys_IPC:
  687. pci_api:
  688. sys_resize_app_memory:
  689. f68:
  690. v86_irq:
  691. test_cpu:
  692. acpi_locate:
  693. init_BIOS32:
  694. mem_test:
  695. init_mem:
  696. init_page_map:
  697. ahci_init:
  698.         ret
  699.  
  700. alloc_pages:
  701.         ret     4
  702. create_ring_buffer:
  703.         ret     8
  704. map_page:
  705.         ret     12
  706. map_memEx:
  707.         ret     20
  708.  
  709. sys_msg_board equ __pex0
  710. delay_ms equ __pex1
  711.  
  712. include fix pew
  713. macro pew x {}
  714. macro pew x {inclu#de `x}
  715. macro org x {}
  716. macro format [x] {}
  717.  
  718. macro lea r, v {
  719.   if v eq [(ecx-(TASK_TABLE and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE]
  720.         int3
  721.   else if v eq [(edx-(TASK_TABLE and 1FFFFFFFh))*8+SLOT_BASE]
  722.         int3
  723.   else
  724.         lea     r, v
  725.   end if
  726. }
  727.  
  728. include 'kernel.asm'
  729.  
  730. purge lea,add,org,mov
  731. restore lea,add,org,mov
  732. purge sys_msg_board,delay_ms
  733. restore sys_msg_board,delay_ms
  734.  
  735. coverage_end:
  736.  
  737. ; fasm doesn't align on 65536, but ld script does
  738. section '.data.aligned65k' writeable align 65536
  739. public umka_tool
  740. umka_tool dd ?
  741. public umka_initialized
  742. umka_initialized dd 0
  743. fpu_owner dd ?
  744.  
  745. BOOT boot_data
  746. virtual at BOOT
  747. BOOT_LO boot_data
  748. end virtual
  749.  
  750. uglobal
  751. align 64
  752. os_base:        rb PAGE_SIZE
  753. window_data:    rb sizeof.WDATA * 256
  754. TASK_TABLE:     rb 16
  755. TASK_BASE:      rd 4
  756. TASK_DATA:      rd sizeof.TASKDATA * 255 / 4
  757. CDDataBuf:      rb 0x1000
  758. idts            rb IRQ_RESERVED * 8     ; IDT descriptor is 8 bytes long
  759. WIN_STACK       rw 0x200        ; why not 0x100?
  760. WIN_POS         rw 0x200
  761. FDD_BUFF:       rb 0x400
  762. WIN_TEMP_XY     rb 0x100
  763. KEY_COUNT       db ?
  764. KEY_BUFF        rb 255  ; 120*2 + 2*2 = 244 bytes, actually 255 bytes
  765. BTN_COUNT       db ?
  766. BTN_BUFF        rd 0x261
  767. BTN_ADDR        dd ?
  768. MEM_AMOUNT      rd 0x1d
  769. SYS_SHUTDOWN    db ?
  770. sys_proc:       rb sizeof.PROC * 256
  771.                 rb 0x10000 - (($-bss_base) AND (0x10000-1)) ; align on 0x10000
  772. SLOT_BASE:      rb sizeof.APPDATA * 256
  773. VGABasePtr      rb 640*480
  774.                 rb PAGE_SIZE - (($-bss_base) AND (PAGE_SIZE-1)) ; align on page
  775. HEAP_BASE       rb UMKA_MEMORY_BYTES - (HEAP_BASE - os_base + \
  776.                                         PAGE_SIZE * sizeof.MEM_BLOCK)
  777. endg
  778.  
  779. uglobal
  780. v86_irqhooks rd IRQ_RESERVED*2
  781. cache_ide0  IDE_CACHE
  782. cache_ide1  IDE_CACHE
  783. DiskNumber db ?
  784. ChannelNumber db ?
  785. DevErrorCode dd ?
  786. CDSectorAddress dd ?
  787. CDDataBuf_pointer dd ?
  788. allow_dma_access db ?
  789. ide_mutex MUTEX
  790. ide_channel1_mutex MUTEX
  791. ide_channel2_mutex MUTEX
  792. ide_channel3_mutex MUTEX
  793. ide_channel4_mutex MUTEX
  794. ide_channel5_mutex MUTEX
  795. ide_channel6_mutex MUTEX
  796. ide_channel7_mutex MUTEX
  797. ide_channel8_mutex MUTEX
  798.  
  799. lfb_base        rd MAX_SCREEN_WIDTH*MAX_SCREEN_HEIGHT
  800.  
  801. align 4096
  802. cur_dir:
  803. .encoding rb 1
  804. .path     rb maxPathLength
  805.  
  806. BgrAuxTable     rb  32768
  807. BgrAuxTable     equ
  808. SB16Buffer      rb  65536
  809. SB16Buffer      equ
  810. BUTTON_INFO     rb  64*1024
  811. BUTTON_INFO     equ
  812. endg
  813.  
  814. macro org x {
  815.   if x eq (OS_BASE+0x0100000)
  816.   else
  817.     org x
  818.   end if
  819. }
  820.  
  821. macro align x {
  822.   if x eq 65536
  823.   else if x eq 4096
  824.   else
  825.     align x
  826.   end if
  827. }
  828.  
  829. macro assert [x] {}
  830. include 'data32.inc'
  831.