Subversion Repositories Kolibri OS

Rev

Rev 9342 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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