download SHUTDOWN.ASM
Language: Assembler
License: GPL
Copyright: (C) 1988-2000, Leif Ekblad
LOC: 503
Project Info
RDOS operating system(rdos)
Server: SourceForge
Type: cvs
SourceForge\r\rdos\rdos\bur\
   ad.cpp
   ad.def
   BOOT.ASM
   bur2bin.asm
   burload.cpp
   burload.def
   CFG2ROM.ASM
   CLEAN.BAT
   DEMO.CFG
   FLASH.ASM
   LCD.ASM
   MK.BAT
   SDRAM.ASM
   SHUTDOWN.ASM
   TEST.ASM
   TEST.DEF
   YMODEM.CPP
   YMODEM.H
   ZFX86.ASM

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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; RDOS operating system
; Copyright (C) 1988-2000, Leif Ekblad
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version. The only exception to this rule
; is for commercial usage in embedded systems. For information on
; usage in commercial embedded systems, contact embedded@rdos.net
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
;
; The author of this program may be contacted at leif@rdos.net
;
; SHUTDOWN.ASM
; ZFX86 COM1 "panic" module
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
						
		NAME shutdown

GateSize = 16

INCLUDE ..\os\system.def
INCLUDE ..\os\protseg.def
INCLUDE ..\os\user.def
INCLUDE ..\os\os.def

	.386p

WriteSIO    Macro index, data
    mov al,index
    out 2Eh,al
    mov al,data
    out 2Fh,al
        ENDM

ReadSIO    Macro index
    mov al,index
    out 2Eh,al
    in al,2Fh
        ENDM

code	SEGMENT byte public use16 'CODE'

	assume cs:code

PAGE
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;	
;
;		NAME:			boot_ram
;
;		DESCRIPTION:	get free ram during boot
;
;		RETURNS:		ESI		address to use
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

boot_ram	Proc near
	push ds
	push ax
	mov ax,system_data_sel
	mov ds,ax
	mov esi,ds:alloc_base
    mov ax,flat_sel
    mov ds,ax
    jmp RamNext
RamLoop:
    mov eax,AllocMemSign
    mov [esi],eax
    cmp eax,[esi]
    je RamFound
RamNext:
    add esi,1000h
    jmp RamLoop
    
RamFound:
	mov ax,system_data_sel
	mov ds,ax
	mov ds:alloc_base,esi
	pop ax
	pop ds
	ret
boot_ram	Endp

PAGE
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;	
;
;		NAME:			StartSerial
;
;		DESCRIPTION:	start serial port
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

StartSerial	Proc near
    WriteSIO 7, 3
    WriteSIO 30h, 1
    WriteSIO 60h, 3
    WriteSIO 61h, 0F8h
;
	mov al,83h
	mov dx,3F8h + 3
	out dx,al				; set line control to divisor access
;
	mov dx,3F8h
	mov al,1
	out dx,al				; output LSB divisor latch
;
	mov dx,3F8h + 1
	mov al,0
	out dx,al				; output MSB divisor latch
;
    mov dx,3F8h + 2
    mov al,1
    out dx,al               ; enable FIFOs if present
;
	mov al,3
	mov dx,3F8h + 3
	out dx,al				; set line control 
;
	mov dx,3F8h + 1
	mov al,0
	out dx,al				; disable rx ints, disable tx, line and modem ints
;
	mov dx,3F8h + 4
	mov al,0Bh
	out dx,al				; modem control, DTR = high, RTS = high
	ret
StartSerial	Endp

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;
;		NAME:			WriteChar
;
;		DESCRIPTION:	Write a char to serial port
;
;		PARAMETERS:		AL		CHAR
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

WriteChar	PROC near
    push ax
    push dx
;
    mov ah,al
    
WriteCharWaitLoop:
    mov dx,3F8h+5
    in al,dx
    test al,40h
    jz WriteCharWaitLoop
;
    mov dx,3F8h
    mov al,ah
    out dx,al
;
    pop dx
    pop ax
	ret
WriteChar	ENDP

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;
;		NAME:			WriteCRLF
;
;		DESCRIPTION:
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

WriteCRLF	Proc near
    push ax
    push dx
    mov al,0Dh
    call WriteChar
    mov al,0Ah
    call WriteChar
    pop dx
    pop ax
    ret
WriteCRLF   Endp


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;
;		NAME:			SingleHex
;
;		DESCRIPTION:
;
;		PARAMETERS:		AL		Value in
;						AX		Value out
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

SingleHex	Proc near
	mov ah,al
	and al,0F0h
	rol al,4
	cmp al,0Ah
	jb ok_low1
	add al,7
ok_low1:
	add al,30h
	and ah,0Fh
	cmp ah,0Ah
	jb ok_high1
	add ah,7
ok_high1:
	add ah,30h
	ret
SingleHex   Endp

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;
;		NAME:			WriteHexByte
;
;		DESCRIPTION:
;
;		PARAMETERS:		AL		HEX DATA IN
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

WriteHexByte    Proc near
    push ax
	call SingleHex
	call WriteChar
	xchg al,ah
    call WriteChar
    pop ax
    ret
WriteHexByte    Endp

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;
;		NAME:			WriteHexWord
;
;		DESCRIPTION:
;
;		PARAMETERS:		AX		HEX DATA IN
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

WriteHexWord	Proc near
    xchg al,ah
    call WriteHexByte
    xchg al,ah
    call WriteHexByte
    ret
WriteHexWord    Endp

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;
;		NAME:			WriteHexDword
;
;		DESCRIPTION:
;
;		PARAMETERS:		EAX		HEX DATA IN
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

WriteHexDword	Proc near
    push eax
    shr eax,16
    call WriteHexWord
    pop eax
    call WriteHexWord
    ret
WriteHexDword   Endp

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;
;		NAME:			WriteSizeString
;
;		DESCRIPTION:	Write string to screen
;
;		PARAMETERS:		ES:DI	Address to string
;                       CX      Number of chars
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

WriteSizeString	PROC near
    push ax
    push di

WriteSizeStringLoop:
	mov al,es:[di]
    call WriteChar
	inc di
    loop WriteSizeStringLoop

WriteSizeStringDone:
    pop di
    pop ax       
	ret
WriteSizeString	ENDP


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;
;		NAME:		    WriteDwordReg
;
;		DESCRIPTION:	Write 32-bit registers
;
;		PARAMETERS:		ES:DI	ADDRESS TO TABLE
;						GS		TSS
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	assume gs:tss_seg

WriteDwordReg	PROC near
	push cx
	mov cx,4
	call WriteSizeString
	pop cx
;
	add di,4
	mov bx,es:[di]
	mov eax,gs:[bx]
	call WriteHexDword
	add di,2
	mov al,' '
	call WriteChar
	mov al,es:[di]
	or al,al
	jnz WriteDwordReg
;
	ret
WriteDwordReg	ENDP

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;
;		NAME:			WriteWordReg
;
;		DESCRIPTION:	Write 16-bit registers
;
;		PARAMETERS:		ES:DI	ADDRESS TO TABLE
;						GS		TSS
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	assume gs:tss_seg

WriteWordReg	PROC near
	push cx
	mov cx,3
	call WriteSizeString
	pop cx
;
	add di,3
	mov bx,es:[di]
	mov ax,gs:[bx]
	call WriteHexWord
	add di,2
	mov al,' '
	call WriteChar
	mov al,es:[di]
	or al,al
	jnz WriteWordReg
;
	ret
WriteWordReg	ENDP


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;
;		NAME:			WriteElags
;
;		DESCRIPTION:	Write EFLAGS
;
;		PARAMETERS:		GS		TSS
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


eflags_tab:
;
;		reset		set
et_cf	DB 'NC ',	'CY '
et_1	DB 0,0,0,	0,0,0
et_pf	DB 'PO ',	'PE '
et_3	DB 0,0,0,	0,0,0
et_af	DB 'NA ',	'AC '
et_5	DB 0,0,0,	0,0,0
et_zf	DB 'NZ ',	'ZR '
et_sf	DB 'PL ',	'NG '
et_tf	DB 0,0,0,	0,0,0
et_if	DB 'DI ',	'EI '
et_df	DB 'UP ',	'DN '
et_of	DB 'NV ',	'OV '
et_12	DB 0,0,0,	0,0,0
et_13	DB 0,0,0,	0,0,0
et_14	DB 'PR ' ,	'NT '
et_15	DB 0,0,0,	0,0,0
et_16	DB 0,0,0,	0,0,0
et_vm	DB 'PM ',	'VM '
et_end	DB 0FFh

WriteEflags	PROC near
	mov bx,OFFSET tss_eflags
	mov eax,gs:[bx]
	mov di,OFFSET eflags_tab
	mov cx,cs
	mov es,cx
eflags_loop:
	mov ch,es:[di]
	or ch,ch
	je eflags_next
	cmp ch,0FFh
	je eflags_done
	push di
	mov cl,10
	test ax,1
	jz eflags_pos_ok
	add di,3
eflags_pos_ok:
	push ax
	mov cx,3
	call WriteSizeString
	pop ax
	pop di
eflags_next:
	add di,6
	shr eax,1
	jmp eflags_loop
eflags_done:
	ret
WriteEflags	ENDP

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;
;		NAME:			WriteFault
;
;		DESCRIPTION:	Write fault string
;
;		PARAMETERS:		GS		TSS
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

ft_idt	DB 'Idt '
ft_ldt	DB 'Ldt '
ft_gdt	DB 'Gdt '

WriteFault	PROC near
	mov ax,cs
	mov es,ax
	mov ax,gs:tss_error_code
	test ax,2
	jz fault_not_idt
	mov di,OFFSET ft_idt
	jmp write_fault_reason
fault_not_idt:
	mov di,OFFSET ft_gdt
	test ax,4
	jz write_fault_reason
	mov di,OFFSET ft_ldt
write_fault_reason:
	mov cx,4
	call WriteSizeString
	mov ax,gs:tss_error_code
	and ax,0FFF8h
	call WriteHexWord
write_fault_end:
	ret
WriteFault	ENDP

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;
;		NAME:			ABORT_PR
;
;		DESCRIPTION:	Abort app and display dump
;
;		PARAMETERS:		DS		Readable TSS for thread
;						ES		Readable GDT
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	assume ds:tss_seg

error_code_tab:
ke00	DB 'Divide error            '
ke01	DB 'Single step             '
ke02	DB 'NMI                     '
ke03	DB 'Breakpoint              '
ke04	DB 'Overflow                '
ke05	DB 'Array bounds error      '
ke06	DB 'Invalid OP-code         '
ke07	DB '80387 not present       '
ke08	DB 'Double fault            '
ke09	DB '80387 overrun           '
ke0A	DB 'Invalid TSS             '
ke0B	DB 'Segment not present     '
ke0C	DB 'Stack fault             '
ke0D	DB 'Protection fault        '
ke0E	DB 'Page fault              '
ke0F	DB 'Unknown Fault           '
ke10	DB '80387 error             '
ke11	DB 'Cannot emulate          '
ke12	DB 'Cannot emulate 80387    '
ke13	DB 'Now in real mode        '
ke14	DB '----------------------- '
ke15	DB 'Illegal int request     '
ke16	DB 'Undefined method        '
ke17	DB 'Invalid handle          '
ke18	DB 'Invalid selector        '

dword_reg_tab1:
	DB 'EAX='
	DW OFFSET tss_eax
	DB 'EBX='
	DW OFFSET tss_ebx
	DB 'ECX='
	DW OFFSET tss_ecx
	DB 'EDX='
	DW OFFSET tss_edx
	DB 'ESI='
	DW OFFSET tss_esi
	DB 'EDI='
	DW OFFSET tss_edi
	DB 0
dword_reg_tab2:
	DB 'EPC='
	DW OFFSET tss_eip
	DB 'ESP='
	DW OFFSET tss_esp
	DB 'EBP='
	DW OFFSET tss_ebp
	DB 0
word_reg_tab:
	DB 'CS='
	DW OFFSET tss_cs
	DB 'SS='
	DW OFFSET tss_ss
	DB 'DS='
	DW OFFSET tss_ds
	DB 'ES='
	DW OFFSET tss_es
	DB 'FS='
	DW OFFSET tss_fs
	DB 'GS='
	DW OFFSET tss_gs
	DB 0

pm_es	EQU -12

abort_pretask:
	cli
	cld
	push es
	movzx bx,al
;
	mov ax,system_data_sel
	mov es,ax
	mov eax,[bp].vm_eip
	mov dword ptr es:tss_eip,eax
	mov eax,[bp].vm_eflags
	mov dword ptr es:tss_eflags,eax
	mov ax,[bp].vm_err
	mov word ptr es:tss_error_code,ax
	mov eax,[bp].vm_eax
	mov dword ptr es:tss_eax,eax
	mov dword ptr es:tss_ecx,ecx
	mov dword ptr es:tss_edx,edx
	mov eax,[bp].vm_ebx
	mov dword ptr es:tss_ebx,eax
	mov ax,[bp].vm_bp
	mov word ptr es:tss_ebp,ax
	movzx eax,bp
	add eax,18
	mov dword ptr es:tss_esp,eax
	mov dword ptr es:tss_esi,esi
	mov dword ptr es:tss_edi,edi
	mov ax,[bp].vm_cs
	mov es:tss_cs,ax
	mov es:tss_ss,ss
	mov ax,[bp].pm_ds
	mov es:tss_ds,ax
	mov ax,[bp].pm_es
	mov es:tss_es,ax
	mov es:tss_fs,fs
	mov es:tss_gs,gs
	mov bp,[bp].vm_bp
	mov dword ptr es:tss_ebp,ebp
	sldt ax
	mov es:tss_ldt,ax	
	mov ax,es
	mov gs,ax

abort_fatal_write:
	push bx
	call StartSerial
	mov di,bx
	shl di,3
	mov ax,di
	add ax,ax
	add di,ax
	mov ax,cs
	mov es,ax
	call WriteCRLF
	add di,OFFSET error_code_tab
	mov cx,24
	call WriteSizeString
	mov al,' '
	call WriteChar
	call WriteFault
	call WriteCRLF
;
	mov ax,cs
	mov es,ax
	mov di,OFFSET dword_reg_tab1
	call WriteDwordReg
	call WriteCRLF
;
	mov ax,cs
	mov es,ax
	mov di,OFFSET dword_reg_tab2
	call WriteDwordReg
	call WriteEflags
	call WriteCRLF
;
	mov ax,cs
	mov es,ax
	mov di,OFFSET word_reg_tab
	call WriteWordReg
	call WriteCRLF

halt_sys:
	jmp halt_sys
	
abort_task:
	cli
	cld
	call StartSerial
	xor dx,dx
	mov ax,system_data_sel
	mov ds,ax
		assume ds:system_seg
	mov si,OFFSET debug_list
remove_next_waiting:
	mov ax,[si]
	or ax,ax
	jz abort_system
		assume ds:thread_seg,es:thread_seg
	push si
	mov es,[si]
	push di
	push ds
	mov di,es:p_prev
	cmp di,[si]
	mov [si],di
	mov si,es:p_next
	mov ds,di
	mov ds:p_next,si
	mov ds,si
	mov ds:p_prev,di
	pop ds
	pop di
	pop si
	jne not_empty_r
	mov word ptr [si],0
not_empty_r:
	push ds
	push si
	mov ax,es
	call WriteHexWord
	mov al,' '
	call WriteChar
;
	mov di,OFFSET thread_name
	mov cx,30
	call WriteSizeString
;
	mov di,es:p_error_code
	mov gs,es:p_tss_data_sel
	shl di,3
	mov ax,di
	add ax,ax
	add di,ax
	mov ax,cs
	mov es,ax
	add di,OFFSET error_code_tab
	mov cx,24
	call WriteSizeString
	call WriteFault
	call WriteCRLF
;
	mov ax,cs
	mov es,ax
	mov di,OFFSET dword_reg_tab1
	call WriteDwordReg
	call WriteCRLF
;
	mov ax,cs
	mov es,ax
	mov di,OFFSET dword_reg_tab2
	call WriteDwordReg
	call WriteEflags
	call WriteCRLF
;
	mov ax,cs
	mov es,ax
	mov di,OFFSET word_reg_tab
	call WriteWordReg
	call WriteCRLF
;
	pop si
	pop ds
	add dh,2
	jmp remove_next_waiting

abort_system:
	jmp abort_system

PAGE

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;
;		NAME:			Init
;
;		DESCRIPTION:	Initialize module
;
;		PARAMETERS:		
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

init	Proc far
	mov ax,gdt_sel
	mov ds,ax
;
	mov bx,shutdown_pretask_gate
	mov word ptr [bx],OFFSET abort_pretask
	mov [bx+2],cs
	mov word ptr [bx+4],8400h
	mov word ptr [bx+6],0
;
	mov bx,shutdown_task_gate
	mov word ptr [bx],OFFSET abort_task
	mov [bx+2],cs
	mov word ptr [bx+4],8400h
	mov word ptr [bx+6],0
	ret
init	Endp

code	ENDS

.186

END init

About Koders | Resources | Downloads | Support | Black Duck | Submit Project | Terms of Service | DMCA | Privacy Policy | Site Map| Contact Us