Re:Shutdown code??
Posted: Wed Apr 26, 2006 4:56 am
This is a copy of the solar post , i meant the complete code of
the boot sector you wrote to make a test.
the boot sector you wrote to make a test.
Code: Select all
[BITS 16]
[ORG 0x7C00]
mov ax,0x0000
mov ds,ax
mov si, HelloWorld
call PutStr
; Shutdown when RETURN pressed
Not_CR:
mov ah,0
int 0x16
cmp al,0x0D
jne Not_CR
;;//////////// SHUT DOWN CODE//////////////
mov ax, 5300h
mov bx, 0
int 15h
jc fin
test cx, 1
jz fin
push ax
mov ax, 5301h
mov bx, 0
int 15h
pop cx
jnc forward
cmp ah, 2
jne fin
forward:
mov ax, 530eh
mov bx, 0
int 15h
mov ax, 5307h
mov bx, 1
mov cx, 3
int 15h
jc fin
ret
fin:
mov si, ErrorMsg
call PutStr
;;///////////////////////////////////////////
jmp $ ; Never ending loop
PutStr:
mov ah,0x0E
mov bh,0x00
mov bl,0x07
.nextchar:
lodsb
or al,al
jz .return
int 0x10
jmp .nextchar
.return:
ret
HelloWorld db 'Hello World',13,10,0
ErrorMsg db 'Function is not supported', 13, 10, 0
times 510-($-$$) db 0
dw 0xAA55
octavio wrote: search in RBIL for explanations.
Code: Select all
;ATX shutdown
mov ax,0x5301
xor bx,bx
int 0x15
mov ax,0x530e
xor bx,bx
mov cx,01
int 0x15
mov ax,0x530f
mov bx,1
mov cx,bx
int 0x15
mov ax,0x5308
mov bx,1
mov cx,bx
int 0x15
mov ax,0x5307
mov bx,1
mov cx,3
int 0x15
hlt ;no atx? then stop!
jmp $ ;do you know the hlt bug? :)
Brendan wrote: BTW Windows probably uses ACPI instead (i.e. does a transition to the "S5 Soft Off" state using values from the "\_S5" object in the ASL/AML namespace).
I see four choices you could make:viral wrote: So there is problem with my PC only.. As this code is working in others.. Its giving me error (APM not present).
Is there any other way of doing this?
Code: Select all
shutdown {
if( ACPI_supported == YES ) attempt_ACPI_shutdown();
if( APM_supported == YES ) attempt_APM_shutdown();
if( chipset_driver_present == YES ) attempt_chipset_shutdown();
printf("\n\nYou can turn the computer off now!\n");
for(;;) {}
}
For ACPI, there's tables that your OS can search for that provides information needed by an "ACPI OS" to boot. This information includes some "AML" ("ACPI Machine Language"), which is byte-code for an interpretted OOP language that the OS uses after boot. There are no interrupts, I/O ports, BIOS functions, etc - see the ACPI specification/s for details.viral wrote: So I have to go for ACPI and chipset driver... But how ??? I dont know interrupts that'll do that work? What part of Ralph Brown's Int List I have to study for this?
Code: Select all
shutdown {
// if( ACPI_supported == YES ) attempt_ACPI_shutdown();
if( APM_supported == YES ) attempt_APM_shutdown();
// if( chipset_driver_present == YES ) attempt_chipset_shutdown();
printf("\n\nYou can turn the computer off now!\n");
for(;;) {}
}