Shutdown code??
Re:Shutdown code??
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.
Re:Shutdown code??
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
Re:Shutdown code??
This code works for me:
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? :)
Re:Shutdown code??
hello...
I have refered Ralph Brown's Interrupt List... The code is giving me error:
(86h) => Advance Power Management not present.
But windows is working nicely..!!
I have refered Ralph Brown's Interrupt List... The code is giving me error:
(86h) => Advance Power Management not present.
But windows is working nicely..!!
Re:Shutdown code??
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).
Re:Shutdown code??
Viral, your code works on my computer, so the problem is that your computer uses another method.Not a problem for windows or linux, they have one GB of drivers.
Re:Shutdown code??
Hello...
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?
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?
Re:Shutdown code??
Hi,
For example:
Of course "display a message and loop forever" is the only option that is guaranteed to work on all computers...
Cheers,
Brendan
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?
- - use ACPI if it's present
- use APM if it's present
- use a chipset driver if it's present
- display a message and loop forever
For example:
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(;;) {}
}
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re:Shutdown code??
hi..
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?
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?
Re:Shutdown code??
Hi,
For chipset drivers, each chipset is different and you'd need to look at the datasheets/manuals for each specific chipset. Ralph Brown's lists aren't useful for this either.
Even though you'll eventually need to look at ACPI and/or chipset drivers, both of these options aren't easy and you don't need to do them now. As an example, after about 5 years of work (with many developers and help from Intel ) Linux almost has ACPI working, and Linux doesn't have much in the way of chipset drivers (a few options when you configure the kernel for a few chipsets, but not much else).
For now, I'd do something lke this:
Then, later on when you're adding ACPI support and/or adding a generic interface for chipset drivers you can uncomment the lines above.
For now, I'd recommend having a quick look at the ACPI specification and browsing through the chipset datasheets/manuals for an Intel chipset, but I wouldn't worry about writing any code for them until you've got a web browser, word-processor, native compiler/tools, etc...
Cheers,
Brendan
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?
For chipset drivers, each chipset is different and you'd need to look at the datasheets/manuals for each specific chipset. Ralph Brown's lists aren't useful for this either.
Even though you'll eventually need to look at ACPI and/or chipset drivers, both of these options aren't easy and you don't need to do them now. As an example, after about 5 years of work (with many developers and help from Intel ) Linux almost has ACPI working, and Linux doesn't have much in the way of chipset drivers (a few options when you configure the kernel for a few chipsets, but not much else).
For now, I'd do something lke 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 now, I'd recommend having a quick look at the ACPI specification and browsing through the chipset datasheets/manuals for an Intel chipset, but I wouldn't worry about writing any code for them until you've got a web browser, word-processor, native compiler/tools, etc...
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.