-
Notifications
You must be signed in to change notification settings - Fork 1
/
SYS32.INC
3878 lines (3017 loc) · 81.3 KB
/
SYS32.INC
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; MenuetOS process management, protected ring3 ;;
;; ;;
;; Distributed under GPL. See file COPYING for details. ;;
;; Copyright 2003 Ville Turjanmaa ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
align 4
irq0:
cmp [error_interrupt],-1
je no_error_in_previous_process
mov edi,[error_interrupt]
imul edi,8
mov [edi+tss0i_l +5], word 01010000b *256 +11101001b
mov edi,[error_interrupt]
imul edi,128
add edi,0x290000
mov esi,[error_interrupt_entry]
mov [edi+l.eip-tss_sceleton],esi
mov [edi+l.eflags-tss_sceleton],dword 0x11002
mov [0xffff],byte 0
mov [error_interrupt],-1
no_error_in_previous_process:
mov edi,[0x3000]
imul edi,8
mov [edi+gdts+ tss0 +5], word 01010000b *256 +11101001b
inc dword [0xfdf0]
mov eax,[0xfdf0]
cmp eax,[next_usage_update]
jb nocounter
add eax,100
mov [next_usage_update],eax
call updatecputimes
nocounter:
mov edi,[0x3010]
mov ebx,[edi+0x18]
call _rdtsc
sub eax,ebx
add eax,[edi+0x14]
mov [edi+0x14],eax
mov ebx,[0x3000]
cmp [0xffff],byte 1
je do_not_change_task
waiting_for_termination:
waiting_for_reuse:
add edi,0x20
inc ebx
cmp [edi+0xa],byte 3
je waiting_for_termination
cmp [edi+0xa],byte 4
je waiting_for_termination
cmp [edi+0xa],byte 9
je waiting_for_reuse
cmp ebx,[0x3004]
jbe nsched0
mov ebx,1
mov edi,0x3020
nsched0:
mov [0x3000],ebx
mov [0x3010],edi
do_not_change_task:
call _rdtsc
mov [edi+0x18],eax
cmp [0xffff],byte 0
je nodecffff
dec byte [0xffff]
nodecffff:
shl bx,3
add bx,tss0
mov [tss_s],bx
mov al,0x20
mov dx,0x20
out dx,al
db 0xea
tss_t dd 0
tss_s dw tss0t
jmp irq0
next_usage_update dd 100
change_task:
mov [0xffff],byte 2
dec dword [0xfdf0]
int 0x20
ret
align 4
; GDT TABLE
gdts:
dw gdte-$-1
dd gdts
dw 0
os_code_l:
dw 0xffff
dw 0x0000
db 0x00
dw 11011111b *256 +10011010b
db 0x00
os_data_l:
dw 0xffff
dw 0x0000
db 0x00
dw 11011111b *256 +10010010b
db 0x00
graph_data_l:
dw 0xff
dw 0x0000
db 0x00
dw 11011111b *256 +11110010b
db 0x00
ring3_code_l:
dw 0xffff
dw 0x0000
db 0x00
dw 11011111b *256 +11111010b
db 0x00
ring3_data_l:
dw 0xffff
dw 0x0000
db 0x00
dw 11011111b *256 +11110010b
db 0x00
ring2_code_l:
dw 0xffff
dw 0x0000
db 0x00
dw 11011111b *256 +11011010b
db 0x00
ring2_data_l:
dw 0xffff
dw 0x0000
db 0x00
dw 11011111b *256 +11010010b
db 0x00
ring1_code_l:
dw 0xffff
dw 0x0000
db 0x00
dw 11011111b *256 +10111010b
db 0x00
ring1_data_l:
dw 0xffff
dw 0x0000
db 0x00
dw 11011111b *256 +10110010b
db 0x00
int_code_l:
dw 0xffff
dw 0x0000
db 0x00
dw 11011111b *256 +10011110b
db 0x00
int_data_l:
dw 0xffff
dw 0x0000
db 0x00
dw 11011111b *256 +10010010b
db 0x00
tss0_l:
times (max_processes+10) dd 0,0
tss0t_l:
times (max_processes+10) dd 0,0
tss0i_l:
times (256+10) dd 0,0
app_code_l:
times (max_processes+10) dd 0,0
app_data_l:
times (max_processes+10) dd 0,0
tss0sys_l:
times (max_processes+10) dd 0,0
gdte:
idts:
dw idte-$-1
dd idts+8
dw 0
times 0x62 dd 0,0
idte:
build_process_gdt_tss_pointer:
mov ecx,tss_data
mov edi,0
setgdtl2:
mov [edi+gdts+ tss0 +0], word tss_step
mov [edi+gdts+ tss0 +2], cx
mov eax,ecx
shr eax,16
mov [edi+gdts+ tss0 +4], al
mov [edi+gdts+ tss0 +7], ah
mov [edi+gdts+ tss0 +5], word 01010000b *256 +11101001b
add ecx,tss_step
add edi,8
cmp edi,8*(max_processes+5)
jbe setgdtl2
ret
build_process_gdt_gate_pointer:
mov edi,0
mov dx,tss0
setidtl1:
mov ecx,[esi]
mov [edi+gdts+ tss0t +0], word 0
mov [edi+gdts+ tss0t +2], dx
mov [edi+gdts+ tss0t +4], word 11100101b*256
mov [edi+gdts+ tss0t +6], word 0
add dx,8
add edi,8
cmp edi,8*(max_processes+5)
jb setidtl1
ret
build_interrupt_table:
mov [l.eflags],dword 0x11002
mov [l.ss0], int_data
mov [l.ss1], ring1_data
mov [l.ss2], ring2_data
mov [l.esp0], 0x52000
mov [l.esp1], 0x53000
mov [l.esp2], 0x54000
mov eax,cr3
mov [l.cr3],eax
mov [l.cs],int_code
mov [l.ss],int_data
mov [l.ds],int_data
mov [l.es],int_data
mov [l.fs],int_data
mov [l.gs],int_data
mov eax,sys_int
mov [l.esp],0x720000
mov edi,0x290000
newint:
push edi
mov ebx,[eax]
mov [l.eip],ebx
mov esi,tss_sceleton
mov ecx,120/4
cld
rep movsd
pop edi
add edi,128
add [l.esp],1024
add eax,4
cmp eax,sys_int+4*0x60
jb newint
;;
mov esi,boot_sched_3_2
call boot_log
mov ecx,0x290000
mov edi,0
setgdtl2i:
mov [edi+gdts+ tss0i +0], word 128
mov [edi+gdts+ tss0i +2], cx
mov eax,ecx
shr eax,16
mov [edi+gdts+ tss0i +4], al
mov [edi+gdts+ tss0i +7], ah
mov [edi+gdts+ tss0i +5], word 01010000b *256 +11101001b
add ecx,128
add edi,8
cmp edi,8*0x60
jbe setgdtl2i
;;
mov esi,boot_sched_3_3
call boot_log
mov edi,0
mov edx,tss0i
setidtl2:
mov [edi+idts+ 8 +0], word 0
mov [edi+idts+ 8 +2], dx
mov [edi+idts+ 8 +4], word 10000101b*256
cmp edi,0x40*8
jne no_sw_int
mov [edi+idts+ 8 +4], word 11100101b*256
no_sw_int:
mov [edi+idts+ 8 +6], word 0
add edx,8
add edi,8
cmp edi,8*0x60
jb setidtl2
ret
build_syscall_interrupt_table:
mov [l.eflags],dword 0x11002
mov [l.ss0], int_data
mov [l.ss1], ring1_data
mov [l.ss2], ring2_data
mov [l.esp0], 0x52000
mov [l.esp1], 0x53000
mov [l.esp2], 0x54000
mov eax,cr3
mov [l.cr3],eax
mov [l.cs],int_code
mov [l.ss],int_data
mov [l.ds],int_data
mov [l.es],int_data
mov [l.fs],int_data
mov [l.gs],int_data
mov [l.esp],sysint_stack_data
mov edi,0x298000
newint2:
push edi
mov ebx,i40
mov [l.eip],ebx
mov esi,tss_sceleton
mov ecx,120/4
cld
rep movsd
pop edi
add [l.esp],4096
add edi,128
add eax,4
cmp edi,0x298000+128*(max_processes+5)
jb newint2
;;
mov ecx,0x298000
mov edi,0
setgdtl2i2:
mov [edi+gdts+ tss0sys +0], word 128
mov [edi+gdts+ tss0sys +2], cx
mov eax,ecx
shr eax,16
mov [edi+gdts+ tss0sys +4], al
mov [edi+gdts+ tss0sys +7], ah
mov [edi+gdts+ tss0sys +5], word 01010000b *256 +11101001b
add ecx,128
add edi,8
cmp edi,8*(max_processes+5)
jbe setgdtl2i2
;;
mov dx,tss0sys
mov edi,8*0x40
mov [edi+idts+ 8 +0], word 0
mov [edi+idts+ 8 +2], dx
mov [edi+idts+ 8 +4], word 11100101b*256
mov [edi+idts+ 8 +6], word 0
ret
updatecputimes:
pusha
call _rdtsc
mov eax,[idleuse]
mov [idleusesec],eax
mov [idleuse],dword 0
mov ecx,[0x3004]
mov edi,0x3020
newupdate:
mov ebx,[edi+0x14]
mov [edi+0x1c],ebx
mov [edi+0x14],dword 0
add edi,0x20
loop newupdate
popa
ret
sys_int:
dd s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,sa,sb,sc,sd,se,sf
dd s10 ,s11 ,i_unknown12,i_unknown13
dd i_unknown14,i_unknown15,i_unknown16,i_unknown17
dd i_unknown18,i_unknown19,i_unknown1a,i_unknown1b
dd i_unknown1c,i_unknown1d,i_unknown1e,i_unknown1f
dd irq0 ,irq1 ,p_irq2 ,p_irq3 ,p_irq4 ,p_irq5,p_irq6 ,p_irq7
dd p_irq8,p_irq9,p_irq10,p_irq11,p_irq12,irqD ,p_irq14,p_irq15
dd i_unknown30,i_unknown31,i_unknown32,i_unknown33
dd i_unknown34,i_unknown35,i_unknown36,i_unknown37
dd i_unknown38,i_unknown39,i_unknown3a,i_unknown3b
dd i_unknown3c,i_unknown3d,i_unknown3e,i_unknown3f
dd i40 ,i_unknown41,i_unknown42,i_unknown43
dd i_unknown44,i_unknown45,i_unknown46,i_unknown47
dd i_unknown48,i_unknown49,i_unknown4a,i_unknown4b
dd i_unknown4c,i_unknown4d,i_unknown4e,i_unknown4f
dd i_unknown50,i_unknown51,i_unknown52,i_unknown53
dd i_unknown54,i_unknown55,i_unknown56,i_unknown57
dd i_unknown58,i_unknown59,i_unknown5a,i_unknown5b
dd i_unknown5c,i_unknown5d,i_unknown5e,i_unknown5f
dd i_unknown60,i_unknown61,i_unknown62,i_unknown63
dd i_unknown64,i_unknown65,i_unknown66,i_unknown67
dd i_unknown68,i_unknown69,i_unknown6a,i_unknown6b
dd i_unknown6c,i_unknown6d,i_unknown6e,i_unknown6f
dd i_unknown70,i_unknown71,i_unknown72,i_unknown73
dd i_unknown74,i_unknown75,i_unknown76,i_unknown77
dd i_unknown78,i_unknown79,i_unknown7a,i_unknown7b
dd i_unknown7c,i_unknown7d,i_unknown7e,i_unknown7f
dd i_unknown80,i_unknown81,i_unknown82,i_unknown83
dd i_unknown84,i_unknown85,i_unknown86,i_unknown87
dd i_unknown88,i_unknown89,i_unknown8a,i_unknown8b
dd i_unknown8c,i_unknown8d,i_unknown8e,i_unknown8f
dd i_unknown90,i_unknown91,i_unknown92,i_unknown93
dd i_unknown94,i_unknown95,i_unknown96,i_unknown97
dd i_unknown98,i_unknown99,i_unknown9a,i_unknown9b
dd i_unknown9c,i_unknown9d,i_unknown9e,i_unknown9f
dd i_unknowna0,i_unknowna1,i_unknowna2,i_unknowna3
dd i_unknowna4,i_unknowna5,i_unknowna6,i_unknowna7
dd i_unknowna8,i_unknowna9,i_unknownaa,i_unknownab
dd i_unknownac,i_unknownad,i_unknownae,i_unknownaf
dd i_unknownb0,i_unknownb1,i_unknownb2,i_unknownb3
dd i_unknownb4,i_unknownb5,i_unknownb6,i_unknownb7
dd i_unknownb8,i_unknownb9,i_unknownba,i_unknownbb
dd i_unknownbc,i_unknownbd,i_unknownbe,i_unknownbf
dd i_unknownc0,i_unknownc1,i_unknownc2,i_unknownc3
dd i_unknownc4,i_unknownc5,i_unknownc6,i_unknownc7
dd i_unknownc8,i_unknownc9,i_unknownca,i_unknowncb
dd i_unknowncc,i_unknowncd,i_unknownce,i_unknowncf
dd i_unknownd0,i_unknownd1,i_unknownd2,i_unknownd3
dd i_unknownd4,i_unknownd5,i_unknownd6,i_unknownd7
dd i_unknownd8,i_unknownd9,i_unknownda,i_unknowndb
dd i_unknowndc,i_unknowndd,i_unknownde,i_unknowndf
dd i_unknowne0,i_unknowne1,i_unknowne2,i_unknowne3
dd i_unknowne4,i_unknowne5,i_unknowne6,i_unknowne7
dd i_unknowne8,i_unknowne9,i_unknownea,i_unknowneb
dd i_unknownec,i_unknowned,i_unknownee,i_unknownef
dd i_unknownf0,i_unknownf1,i_unknownf2,i_unknownf3
dd i_unknownf4,i_unknownf5,i_unknownf6,i_unknownf7
dd i_unknownf8,i_unknownf9,i_unknownfa,i_unknownfb
dd i_unknownfc,i_unknownfd,i_unknownfe,i_unknownff
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; SYSTEM CALL ENTRY ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
align 4
i40:
cli
mov edi,[0x3000]
imul edi,8
mov [edi+gdts+ tss0 +5], word 01010000b *256 +11101001b
mov eax,[schd]
mov [usedi40+eax],byte 1
push eax
mov edi,[0x3000]
imul edi,256
mov [edi+0x80000+0xB0],eax
mov eax,1 ; search from 1 ( 0 reserved for 'not used' in app )
search_free_i40:
cmp [usedi40+eax],byte 0
je found_free_i40
inc eax
cmp eax,max_processes+10
jbe search_free_i40
jmp $
found_free_i40:
mov [schd],eax
mov edx,8
imul edx,[schd]
add edx,tss0sys
mov edi,8*0x40
mov [edi+idts+ 8 +0], word 0
mov [edi+idts+ 8 +2], dx
mov [edi+idts+ 8 +4], word 11100101b*256
mov [edi+idts+ 8 +6], word 0
mov ebx,[0x3000]
shl ebx,3
add ebx,tss0_l
mov ecx,[0x3000]
shl ecx,2
mov eax,[0x3000]
mov [tasknum+ecx],eax
mov eax,[ebx]
mov [reg1+ecx],eax
mov eax,[ebx+4]
mov [reg2+ecx],eax
mov ecx,8
imul ecx,[esp]
mov eax,[tss0sys_l+ecx]
mov [ebx],eax
mov eax,[tss0sys_l+ecx+4]
mov [ebx+4],eax
call save_registers
mov esi,[0x3000]
imul esi,tss_step
add esi,tss_data
mov eax,[esi+l.eax-tss_sceleton]
mov ebx,[esi+l.ebx-tss_sceleton]
mov ecx,[esi+l.ecx-tss_sceleton]
pusha
mov edi,[esi+l.eax-tss_sceleton]
mov eax,[esi+l.ebx-tss_sceleton]
mov ebx,[esi+l.ecx-tss_sceleton]
mov ecx,[esi+l.edx-tss_sceleton]
mov edx,[esi+l.esi-tss_sceleton]
mov esi,[esi+l.edi-tss_sceleton]
sti
push eax
and edi,0xff
call dword [servetable+edi*4]
pop eax
cli
popa
mov esi,[0x3000]
imul esi,tss_step
add esi,tss_data
mov [esi+l.eax-tss_sceleton],eax
mov [esi+l.ebx-tss_sceleton],ebx
mov [esi+l.ecx-tss_sceleton],ecx
mov ebx,[0x3000]
shl ebx,3
add ebx,tss0_l
mov ecx,[0x3000]
shl ecx,2
mov eax,[reg1+ecx]
mov [ebx],eax
mov eax,[reg2+ecx]
mov [ebx+4],eax
mov edi,[0x3000] ; no syscall interrupt in use anymore
imul edi,256
mov [edi+0x80000+0xB0],eax
mov [tasknum+ecx],dword 0
mov edi,8
pop eax ; this handler
mov [usedi40+eax],byte 0
imul edi,eax
mov [edi+tss0sys_l +5], word 01010000b *256 +11101001b
mov ebx,[0x3000]
shl bx,3
add bx,tss0t
mov [tss_s3],bx
db 0xea
tss_t3 dd 0
tss_s3 dw tss0t
jmp i40
tasknum: times (max_processes+10) dd 0,0
reg1: times (max_processes+10) dd 0,0
reg2: times (max_processes+10) dd 0,0
usedi40: times (max_processes+10) db 0,0
schd dd 0x0
save_registers:
mov esi,[0x3000]
imul esi,tss_step
add esi,tss_data
mov eax,[esi+l.eax-tss_sceleton]
mov ebx,[esi+l.ebx-tss_sceleton]
mov ecx,[esi+l.ecx-tss_sceleton]
mov edx,[esi+l.edx-tss_sceleton]
mov edi,[esi+l.edi-tss_sceleton]
mov ebp,[esi+l.ebp-tss_sceleton]
mov esi,[esi+l.esi-tss_sceleton]
pusha
mov esi,[0x3010]
mov eax,[esi+0x4]
mov esi,esp
inc [save_syscall_count]
mov edi,[save_syscall_count]
and edi,15
shl edi,6
add edi,save_syscall_data+32
mov [edi-32],eax
mov ecx,32 / 4
cld
rep movsd
popa
ret
save_syscall_count dd 0x0
save_syscall_data: times 64*16 dd 0x0
align 4
servetable:
dd sys_drawwindow ; 0-DrawWindow
dd syscall_setpixel ; 1-SetPixel
dd sys_getkey ; 2-GetKey
dd sys_clock ; 3-GetTime
dd syscall_writetext ; 4-WriteText
dd delay_hs ; 5-DelayHs
dd syscall_openramdiskfile ; 6-OpenRamdiskFile
dd syscall_putimage ; 7-PutImage
dd sys_button ; 8-DefineButton
dd sys_cpuusage ; 9-GetProcessInfo
dd sys_waitforevent ; 10-WaitForEvent
dd sys_getevent ; 11-CheckForEvent
dd sys_redrawstat ; 12-BeginDraw and EndDraw
dd syscall_drawrect ; 13-DrawRect
dd syscall_getscreensize ; 14-GetScreenSize
dd sys_background ; 15-bgr
dd sys_cachetodiskette ; 16-FlushFloppyCache
dd sys_getbutton ; 17-GetButton
dd syscall_system ; 18-Shutdown,KillApp,WindowActivate
dd syscall_startapp ; 19-StartApp
dd sys_midi ; 20-ResetMidi and OutputMidi
dd sys_setup ; 21-SetMidiBase,SetKeymap,SetShiftKeymap,.
dd undefined_syscall ; 22-not used
dd sys_wait_event_timeout ; 23-TimeOutWaitForEvent
dd syscall_cdaudio ; 24-PlayCdTrack,StopCd and GetCdPlaylist
dd sys_sb16 ; 25-SetSb16
dd sys_getsetup ; 26-GetMidiBase,GetKeymap,GetShiftKeymap,.
dd sys_wss ; 27-SetWssMainVol and SetWssCdVol
dd sys_sb16II ; 28-SetSb16
dd sys_date ; 29-GetDate
dd syscall_readhd ; 30-ReadHd
dd syscall_starthdapp ; 31-StartHdApp
dd syscall_delramdiskfile ; 32-DelRamdiskFile
dd syscall_writeramdiskfile; 33-WriteRamdiskFile
dd read_floppy_file ; 34-ReadFloppyDrive
dd syscall_getpixel ; 35-GetPixel
dd syscall_readstring ; 36-ReadString (not yet ready)
dd readmousepos ; 37-GetMousePosition_ScreenRelative,.
dd syscall_drawline ; 38-DrawLine
dd sys_getbackground ; 39-GetBackgroundSize,ReadBgrData,.
dd set_app_param ; 40-WantEvents
dd syscall_getirqowner ; 41-GetIrqOwner
dd get_irq_data ; 42-ReadIrqData
dd sys_outport ; 43-SendDeviceData
dd sys_programirq ; 44-ProgramIrqs
dd reserve_free_irq ; 45-ReserveIrq and FreeIrq
dd syscall_reserveportarea ; 46-ReservePortArea and FreePortArea
dd display_number ; 47-WriteNum
dd display_settings ; 48-SetRedrawType and SetButtonType
dd syscall_appints ; 49-AppInts
dd random_shaped_window ; 50-Window shape & scale
dd syscall_threads ; 51-Threads
dd stack_driver_stat ; 52-Stack driver status
dd socket ; 53-Socket interface
dd user_events ; 54-User events
dd sound_interface ; 55-Sound interface
dd write_to_hd ; 56-Write a file to hd
dd delete_from_hd ; 57-Delete a file from hd
dd file_system ; 58-Common file system interface
dd sys_trace ; 59-System call trace
dd sys_ipc ; 60-Inter Process Communication
dd sys_gs ; 61-Direct graphics access
dd sys_pci ; 62-PCI functions
dd sys_msg_board ; 63-System message board
dd sys_resize_app_memory ; 64-Resize application memory usage
dd undefined_syscall ; 65-UTF
dd sys_process_def ; 66-Process definitions - keyboard
dd sys_window_move ; 67-Window move or resize
times (113-67-1) dd undefined_syscall
dd sys_scroll ; 113-Srolls
times 255 - ( ($-servetable) /4 ) dd undefined_syscall
dd sys_end ; -1-end application
tss_sceleton:
l.back dw 0,0
l.esp0 dd 0
l.ss0 dw 0,0
l.esp1 dd 0
l.ss1 dw 0,0
l.esp2 dd 0
l.ss2 dw 0,0
l.cr3 dd 0
l.eip dd 0
l.eflags dd 0
l.eax dd 0
l.ecx dd 0
l.edx dd 0
l.ebx dd 0
l.esp dd 0
l.ebp dd 0
l.esi dd 0
l.edi dd 0
l.es dw 0,0
l.cs dw 0,0
l.ss dw 0,0
l.ds dw 0,0
l.fs dw 0,0
l.gs dw 0,0
l.ldt dw 0,0
l.trap dw 0
l.io dw 0
s0:
cli
mov [error_interrupt],0x0
mov [error_interrupt_entry],dword s0
call show_error_parameters
mov edx,[0x3010]
mov [edx+0xa],byte 4
jmp change_task
s1:
cli
mov [error_interrupt],0x1
mov [error_interrupt_entry],dword s1
call show_error_parameters
mov edx,[0x3010]
mov [edx+0xa],byte 4
jmp change_task
s2:
cli
mov [error_interrupt],0x2
mov [error_interrupt_entry],dword s2
call show_error_parameters
mov edx,[0x3010]
mov [edx+0xa],byte 4
jmp change_task
s3:
cli
mov [error_interrupt],0x3
mov [error_interrupt_entry],dword s3
call show_error_parameters
mov edx,[0x3010]
mov [edx+0xa],byte 4
jmp change_task
s4:
cli
mov [error_interrupt],0x4
mov [error_interrupt_entry],dword s4
call show_error_parameters
mov edx,[0x3010]
mov [edx+0xa],byte 4
jmp change_task
s5:
cli
mov [error_interrupt],0x5
mov [error_interrupt_entry],dword s5
call show_error_parameters
mov edx,[0x3010]
mov [edx+0xa],byte 4
jmp change_task
s6:
cli
mov [error_interrupt],0x6
mov [error_interrupt_entry],dword s6
call show_error_parameters
mov edx,[0x3010]
mov [edx+0xa],byte 4
jmp change_task
prev_user_of_fpu dd 0x1 ; set to OS
s7:
mov edi,7
imul edi,8
mov [edi+gdts+ tss0i +5], word 01010000b *256 +11101001b
mov edi,[0x3000]
imul edi,8
mov [edi+gdts+ tss0 +5], word 01010000b *256 +11101001b
mov esi,[0x3000]
imul esi,tss_step
add esi,tss_data
mov edi,fpu_tss
mov ecx,120
cld
rep movsb
mov esi,[0x3000]
imul esi,tss_step
add esi,tss_data
mov word [esi+l.cs-tss_sceleton],int_code
mov word [esi+l.ss-tss_sceleton],int_data
mov word [esi+l.ds-tss_sceleton],int_data
mov word [esi+l.es-tss_sceleton],int_data
mov word [esi+l.fs-tss_sceleton],int_data
mov word [esi+l.gs-tss_sceleton],int_data
mov dword [esi+l.esp-tss_sceleton],fpu_stack+4*8
mov dword [esi+l.eip-tss_sceleton],fpu_handler
mov dword [esi+l.eflags-tss_sceleton],0x11002
mov ebx,[0x3000]
shl bx,3
add bx,tss0t
mov [tss_s7],bx
db 0xea
dd 0
tss_s7 dw tss0t
jmp s7
fpu_tss: times 128 db 0
fpu_handler:
clts
mov eax,[prev_user_of_fpu]
shl eax,8
add eax,0x80000+0x10
fsave [eax]
mov eax,[0x3000]
mov [prev_user_of_fpu],eax
shl eax,8
add eax,0x80000
cmp [eax+0x7f],byte 0
je bs7_first_fpu
frstor [eax+0x10]
bs7_first_fpu:
mov [eax+0x7f],byte 1
movzx eax,word [fpu_tss+l.ss-tss_sceleton] ; push ss
push eax
mov eax,[fpu_tss+l.esp-tss_sceleton] ; push esp
push eax
mov eax,[fpu_tss+l.eflags-tss_sceleton] ; push eflags
push eax
movzx eax,word [fpu_tss+l.cs-tss_sceleton] ; push cs
push eax
mov eax,[fpu_tss+l.eip-tss_sceleton] ; push eip