1 | ; ----------------------------------------------------------------------------
|
---|
2 | ; Initialization routines and segment mappings for idctest driver.
|
---|
3 | ;
|
---|
4 | ; This is a stripped down version of os2ahci's init.asm.
|
---|
5 |
|
---|
6 | include devhdr.inc
|
---|
7 |
|
---|
8 | ; -----------------------------------------------------------------------------
|
---|
9 | ; Public symbols
|
---|
10 |
|
---|
11 | PUBLIC _asm_strat ; low-level strategy routine
|
---|
12 | PUBLIC _end_of_data ; end of all data (label)
|
---|
13 | PUBLIC _end_of_code ; end of all code (label)
|
---|
14 |
|
---|
15 | ; ----------------------------------------------------------------------------
|
---|
16 | ; Device Driver Header
|
---|
17 |
|
---|
18 | DEVHDR SEGMENT WORD PUBLIC 'DATA'
|
---|
19 | _dev_hdr dd -1 ; next device header
|
---|
20 | dw DEVLEV_3 + DEV_CHAR_DEV ; flags for ADD drivers
|
---|
21 | dw OFFSET _asm_strat ; strategy routine
|
---|
22 | dw 0 ; IDC entry point
|
---|
23 | db "IDCTEST$" ; name of character device
|
---|
24 | dq 0 ; 8 reserved bytes
|
---|
25 | dd 0 ; ADD flags
|
---|
26 | dw 0
|
---|
27 | DEVHDR ENDS
|
---|
28 |
|
---|
29 | ; ----------------------------------------------------------------------------
|
---|
30 | ; Segment Definitions. We need to reference all segments here, even if they
|
---|
31 | ; are not used, to allow proper grouping of all segments into one group for
|
---|
32 | ; data and one group for code as well as proper ordering of the segments
|
---|
33 | ; within each group to make sure the end of segment markers are at the end
|
---|
34 | ; of each group.
|
---|
35 |
|
---|
36 | ; On top of that, we need to make sure that the end of segment marker is in
|
---|
37 | ; a data segment of class 'BSS' because BSS segments are always put towards
|
---|
38 | ; the end of the executable when linking with high-level language objects
|
---|
39 | ; such as C.
|
---|
40 |
|
---|
41 | _DATA SEGMENT WORD PUBLIC 'DATA'
|
---|
42 | _DATA ENDS
|
---|
43 |
|
---|
44 | CONST SEGMENT WORD PUBLIC 'CONST'
|
---|
45 | CONST ENDS
|
---|
46 |
|
---|
47 | _BSS SEGMENT WORD PUBLIC 'BSS'
|
---|
48 | _BSS ENDS
|
---|
49 |
|
---|
50 | c_common SEGMENT WORD PUBLIC 'BSS'
|
---|
51 | c_common ENDS
|
---|
52 |
|
---|
53 | _z_data SEGMENT WORD PUBLIC 'BSS'
|
---|
54 | _end_of_data db 0
|
---|
55 | _z_data ENDS
|
---|
56 |
|
---|
57 | _TEXT SEGMENT WORD PUBLIC 'CODE'
|
---|
58 | EXTRN _c_strat_idc : NEAR ; C strategy routine
|
---|
59 | _TEXT ENDS
|
---|
60 |
|
---|
61 | CODE SEGMENT WORD PUBLIC 'CODE'
|
---|
62 | CODE ENDS
|
---|
63 |
|
---|
64 | RMCode SEGMENT WORD PUBLIC 'CODE'
|
---|
65 | RMCode ENDS
|
---|
66 |
|
---|
67 | LIBCODE SEGMENT WORD PUBLIC 'CODE'
|
---|
68 | LIBCODE ENDS
|
---|
69 |
|
---|
70 | _z_text SEGMENT WORD PUBLIC 'CODE'
|
---|
71 | _end_of_code LABEL NEAR
|
---|
72 | _z_text ENDS
|
---|
73 |
|
---|
74 | DGROUP GROUP DEVHDR, _DATA, CONST, _BSS, c_common, _z_data
|
---|
75 | TGROUP GROUP _TEXT, CODE, _z_text
|
---|
76 |
|
---|
77 | ; ----------------------------------------------------------------------------
|
---|
78 | ; Start of code
|
---|
79 |
|
---|
80 | _TEXT SEGMENT WORD PUBLIC 'CODE'
|
---|
81 | ASSUME DS:DGROUP
|
---|
82 | ASSUME ES:NOTHING
|
---|
83 | ASSUME SS:NOTHING
|
---|
84 |
|
---|
85 |
|
---|
86 | ; Device driver main entry point (strategy routine)
|
---|
87 | _asm_strat PROC FAR
|
---|
88 |
|
---|
89 | ; push request packet address
|
---|
90 | PUSH ES
|
---|
91 | PUSH BX
|
---|
92 | CLD
|
---|
93 |
|
---|
94 | ; call C strategy routine
|
---|
95 | CALL _c_strat_idc
|
---|
96 |
|
---|
97 | POP BX
|
---|
98 | POP ES
|
---|
99 | MOV WORD PTR ES:[BX+3], AX
|
---|
100 | RET
|
---|
101 | _asm_strat ENDP
|
---|
102 |
|
---|
103 |
|
---|
104 | _TEXT ENDS
|
---|
105 |
|
---|
106 | END
|
---|
107 |
|
---|