Well, part of it is going to depend on how you get into p-mode; offhand, I'm not sure if the APM hooks are part of the information that GRUB passes to you, though I recall that there is a command-line option to return whether APM is supported or not, so I would assume so.
To do it yourself, you'd have to first write a real-mode routine to check for APM 32-bit support, and to retrieve the hooks (code is written for NASM, and is
not tested):
Code: Select all
get_apm:
mov ax, 0x5300
int 0x15
jc .apm_error ; if CF is set, then there was an error in processing the service
test ax, 0x0002 ; test bit 1 - if set, then p-mode is supported
jne .apm32_nosup
; 32-bit APM os supported, now get the descriptors
mov ax, 0x5303
int 0x15
jc .apm_hook_error
; no error, so save the returned values in memory
mov word [pmode_base], ax
mov dword [pmode_offset], ebx
mov word [rmode_code], cx
mov word [rmode_data], dx
mov word [code_length], si ; will be garbage if not APM 1.1 or higher
mov word [data_length], di
ret
.apm_error:
;; do whatever error handling you want to do
ret
.apm_hook_error
;; do whatever error handling you want to do
ret
.apm32_nosup:
;; do whatever you need to do to indicate that there was no p-mode support to the p-mode kernel
After that, you would use the values in pmode_base, rmode_code and rmode_data to create descriptors for your GDT; how you would do this would depend on how you initialize your GDT.
HTH. C&CW.