Rev 110 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
110 | heavyiron | 1 | Advanced Power Management |
2 | |||
3 | SYSTEM CALL |
||
4 | |||
263 | Ghost | 5 | eax = 49 |
110 | heavyiron | 6 | dx = номер функции APM BIOS (аналогичен ax в реальном режиме) |
7 | остальные (bx, cx) регистры по спецификации (см. apm.txt) |
||
8 | результат : по спецификации (включая CF), старшая часть 32 битных регистров не определена |
||
9 | |||
10 | |||
11 | MEMORY MAP |
||
12 | |||
13 | Boot: |
||
14 | 0x9040 - dword - entry point of APM BIOS |
||
15 | 0x9044 - word - version (BCD) |
||
16 | 0x9046 - word - flags |
||
17 | |||
18 | |||
19 | ИЗМЕНЕНИЯ |
||
20 | |||
263 | Ghost | 21 | bootcode.inc |
110 | heavyiron | 22 | syscall.inc |
23 | kernel.asm |
||
24 | bootcode.inc |
||
263 | Ghost | 25 | shutdown.inc |
110 | heavyiron | 26 | |
263 | Ghost | 27 | ##############[boot\bootcode.inc]################## |
110 | heavyiron | 28 | |
29 | Три новых дескриптора |
||
30 | |||
31 | ............. |
||
32 | ............. |
||
33 | |||
34 | ; GDT TABLE |
||
35 | |||
36 | gdts: |
||
37 | |||
38 | dw gdte-$-1 |
||
39 | dd gdts |
||
40 | dw 0 |
||
41 | |||
42 | int_code_l: |
||
43 | os_code_l: |
||
44 | |||
45 | dw 0xffff |
||
46 | dw 0x0000 |
||
47 | db 0x00 |
||
48 | dw 11011111b *256 +10011010b |
||
49 | db 0x00 |
||
50 | |||
51 | int_data_l: |
||
52 | os_data_l: |
||
53 | |||
54 | dw 0xffff |
||
55 | dw 0x0000 |
||
56 | db 0x00 |
||
57 | dw 11011111b *256 +10010010b |
||
58 | db 0x00 |
||
59 | ; --------------- APM --------------------- |
||
60 | apm_code_32: |
||
263 | Ghost | 61 | dw 0x0f ; limit 64kb |
110 | heavyiron | 62 | db 0, 0, 0 |
263 | Ghost | 63 | dw 11010000b *256 +10011010b |
110 | heavyiron | 64 | db 0x00 |
65 | apm_code_16: |
||
263 | Ghost | 66 | dw 0x0f |
110 | heavyiron | 67 | db 0, 0, 0 |
263 | Ghost | 68 | dw 10010000b *256 +10011010b |
110 | heavyiron | 69 | db 0x00 |
70 | apm_data_16: |
||
263 | Ghost | 71 | dw 0x0f |
110 | heavyiron | 72 | db 0, 0, 0 |
263 | Ghost | 73 | dw 10010000b *256 +10010010b |
110 | heavyiron | 74 | db 0x00 |
75 | ; ----------------------------------------- |
||
76 | app_code_l: |
||
77 | dw ((0x80000000-std_application_base_address) shr 12) and 0xffff |
||
78 | dw 0 |
||
79 | db 0 |
||
80 | dw 11010000b*256+11111010b+256*((0x80000000-std_application_base_address) shr 28) |
||
81 | db std_application_base_address shr 24 |
||
82 | |||
83 | app_data_l: |
||
84 | dw (0x80000000-std_application_base_address) shr 12 and 0xffff |
||
85 | dw 0 |
||
86 | db 0 |
||
87 | dw 11010000b*256+11110010b+256*((0x80000000-std_application_base_address) shr 28) |
||
88 | db std_application_base_address shr 24 |
||
89 | |||
90 | graph_data_l: |
||
91 | |||
92 | dw 0x3ff |
||
93 | dw 0x0000 |
||
94 | db 0x00 |
||
95 | dw 11010000b *256 +11110010b |
||
96 | db 0x00 |
||
97 | |||
98 | tss0_l: |
||
99 | |||
100 | ............. |
||
101 | ............. |
||
102 | |||
103 | ##############[core\syscall.inc]################### |
||
104 | |||
105 | ............. |
||
106 | ............. |
||
107 | |||
108 | |||
263 | Ghost | 109 | dd display_number ; 47-WriteNum |
110 | dd display_settings ; 48-SetRedrawType and SetButtonType |
||
111 | dd sys_apm ; 49-Advanced Power Management (APM) |
||
112 | dd random_shaped_window ; 50-Window shape & scale |
||
113 | dd syscall_threads ; 51-Threads |
||
110 | heavyiron | 114 | |
115 | |||
116 | ............. |
||
117 | ............. |
||
118 | |||
119 | ##############[kernel.asm]######################### |
||
120 | |||
121 | |||
122 | Часть 1 (после метки "; SAVE REAL MODE VARIABLES"): |
||
123 | |||
124 | ............. |
||
125 | ............. |
||
126 | |||
127 | ; SAVE REAL MODE VARIABLES |
||
128 | |||
129 | ; --------------- APM --------------------- |
||
130 | mov eax, [0x2f0000 + 0x9040] ; entry point |
||
131 | mov dword[apm_entry], eax |
||
132 | mov word [apm_entry + 4], apm_code_32 - gdts |
||
133 | |||
134 | mov eax, [0x2f0000 + 0x9044] ; version & flags |
||
135 | mov [apm_vf], eax |
||
136 | ; ----------------------------------------- |
||
137 | |||
138 | ............. |
||
139 | ............. |
||
140 | |||
141 | Часть 2 (системный вызов, расположение не критично, |
||
142 | я расположил перед меткой "undefined_syscall:") |
||
143 | |||
144 | ............. |
||
145 | ............. |
||
146 | |||
147 | ; --------------- APM --------------------- |
||
148 | apm_entry dp 0 |
||
149 | apm_vf dd 0 |
||
150 | align 4 |
||
151 | sys_apm: |
||
152 | cmp word [apm_vf], 0 ; Check APM BIOS enable |
||
153 | jne @f |
||
263 | Ghost | 154 | or [esp + 56], byte 1 ; error |
110 | heavyiron | 155 | mov [esp + 36], dword 8 ; 32-bit protected-mode interface not supported |
156 | ret |
||
157 | |||
158 | @@: xchg eax, ecx |
||
159 | xchg ebx, ecx |
||
160 | |||
161 | cmp al, 3 |
||
162 | ja @f |
||
263 | Ghost | 163 | and [esp + 56], byte 0xfe ; emulate func 0..3 as func 0 |
110 | heavyiron | 164 | mov eax, [apm_vf] |
165 | mov [esp + 36], eax |
||
166 | shr eax, 16 |
||
167 | mov [esp + 32], eax |
||
168 | ret |
||
169 | |||
170 | @@: call pword [apm_entry] ; call APM BIOS |
||
171 | mov [esp + 8 ], edi |
||
172 | mov [esp + 12], esi |
||
173 | mov [esp + 24], ebx |
||
174 | mov [esp + 28], edx |
||
175 | mov [esp + 32], ecx |
||
176 | mov [esp + 36], eax |
||
177 | setc al |
||
263 | Ghost | 178 | and [esp + 56], byte 0xfe |
179 | or [esp + 56], al |
||
110 | heavyiron | 180 | ret |
181 | ; ----------------------------------------- |
||
182 | |||
183 | align 4 |
||
184 | |||
185 | undefined_syscall: ; Undefined system call |
||
186 | |||
187 | ............. |
||
188 | ............. |
||
189 | |||
190 | ##############[boot\bootcode.inc]################## |
||
191 | |||
192 | Перед меткой "; DISPLAY VESA INFORMATION" |
||
193 | |||
194 | ............. |
||
195 | ............. |
||
196 | |||
197 | ; --------------- APM --------------------- |
||
198 | push 0 |
||
199 | pop es |
||
200 | mov word [es : 0x9044], 0 ; ver = 0.0 (APM not found) |
||
201 | mov ax, 0x5300 |
||
202 | xor bx, bx |
||
203 | int 0x15 |
||
204 | jc apm_end ; APM not found |
||
205 | test cx, 2 |
||
206 | jz apm_end ; APM 32-bit protected-mode interface not supported |
||
207 | mov [es : 0x9044], ax ; Save APM Version |
||
208 | mov [es : 0x9046], cx ; Save APM flags |
||
209 | |||
210 | ; Write APM ver ---- |
||
211 | jmp @f |
||
212 | msg_apm:db ' APM x.x ', 0 |
||
213 | @@: and ax, 0xf0f |
||
214 | add ax, '00' |
||
263 | Ghost | 215 | mov si, msg_apm - 0x10000 |
216 | mov [si + 5], ah |
||
217 | mov [si + 7], al |
||
110 | heavyiron | 218 | _setcursor 0, 3 |
219 | call printplain |
||
220 | _setcursor d80x25_top_num,0 |
||
221 | ; ------------------ |
||
222 | |||
223 | mov ax, 0x5304 ; Disconnect interface |
||
224 | xor bx, bx |
||
225 | int 0x15 |
||
226 | mov ax, 0x5303 ; Connect 32 bit mode interface |
||
227 | xor bx, bx |
||
228 | int 0x15 |
||
229 | ; init selectors |
||
230 | movzx eax, ax ; real-mode segment base address of protected-mode 32-bit code segment |
||
231 | shl eax, 4 |
||
232 | mov [apm_code_32 - 0x10000 + 2], ax |
||
233 | shr eax, 16 |
||
234 | mov [apm_code_32 - 0x10000 + 4], al |
||
235 | movzx ecx, cx ; real-mode segment base address of protected-mode 16-bit code segment |
||
236 | shl ecx, 4 |
||
237 | mov [apm_code_16 - 0x10000 + 2], cx |
||
238 | shr ecx, 16 |
||
239 | mov [apm_code_16 - 0x10000 + 4], cl |
||
240 | movzx edx, dx ; real-mode segment base address of protected-mode 16-bit data segment |
||
241 | shl edx, 4 |
||
242 | mov [apm_data_16 - 0x10000 + 2], dx |
||
243 | shr edx, 16 |
||
244 | mov [apm_data_16 - 0x10000 + 4], dl |
||
245 | mov [es : 0x9040], ebx ; offset of APM entry point |
||
246 | apm_end: |
||
247 | ; ----------------------------------------- |
||
248 | |||
249 | |||
250 | ; DISPLAY VESA INFORMATION |
||
251 | |||
252 | ............. |
||
253 | ............. |
||
254 | |||
263 | Ghost | 255 | ##############[boot\shutdown.inc]################## |
256 | |||
257 | Решение проблемы APM poweroff |
||
258 | |||
259 | ............. |
||
260 | ............. |
||
261 | |||
262 | APM_PowerOff: |
||
263 | mov ax, 5304h |
||
264 | xor bx, bx |
||
265 | int 15h |
||
266 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
||
267 | mov ax,0x5300 |
||
268 | xor bx,bx |
||
269 | int 0x15 |
||
270 | push ax |
||
271 | |||
272 | ............. |
||
273 | ............. |