Shutdown code??
Shutdown code??
hello...
I want to implement "turn off" command like windows os.
The ATX should be turned off after executing this command. I was going through Tim's code of Mobiues.. but not getting anything..
can anyone help me with a piece of code or steps to follow..... Thanks in advance...
I want to implement "turn off" command like windows os.
The ATX should be turned off after executing this command. I was going through Tim's code of Mobiues.. but not getting anything..
can anyone help me with a piece of code or steps to follow..... Thanks in advance...
Re:Shutdown code??
run the code with octasm for dos and the computer will power
off, search in RBIL for explanations.
off, search in RBIL for explanations.
Code: Select all
LANG OCTASM,0.1
\OCTASM.SYM
{
ax=5300h bx=0 int 15h jc fin
test cx,1 jz fin
push ax ax=5301h bx=0 int 15h
pop cx jnc >1
cmp ah,2 jne fin
# ax=530eh bx=0 int 15h
ax=5307h bx=1 cx=3 int 15h jc fin
ret
#fin
prn("%nb %13 function not supported")
ret
}
Re:Shutdown code??
Ah, yet another assembler around, and with lib dependencies, even. Let's see if I can do the Intel equivalent:
Any of the Intel / NASM coders around is invited to correct me, I suck at ASM.
Code: Select all
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:
prn("function not supported")
ret
Every good solution is obvious once you've found it.
Re:Shutdown code??
hello....
thanks for that.. but my OS is in protected mode. So how can i call int 15h ?
Is it so that i have to switch first from PMode -> Real mode and than call this interrupt?
thanks for that.. but my OS is in protected mode. So how can i call int 15h ?
Is it so that i have to switch first from PMode -> Real mode and than call this interrupt?
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Shutdown code??
most indeed do get back to realmode first and then shutdown. That's not terribly hard, though, as long as you have a way to allocate memory below 1MB, getting back to realmode is sensibly simpler than setting up pmode (and iirc, in that case, you even do not need to bother to reset IRQs setup or whatever): just reset PG and PM bits of CR0, far jump and voil?
Re:Shutdown code??
Hi,
It would be possible to use one of the protected mode interfaces to shutdown the computer without going to real mode first on almost all modern computers.
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).
Cheers,
Brendan
The APM specification includes a real mode interface, a 16 bit protected mode interface and a 32 bit protected mode interface. Both of the protected mode interfaces were optional in early versions of the specification, but became mandatory in APM version 1.2 (February 1996).viral wrote:hello....
thanks for that.. but my OS is in protected mode. So how can i call int 15h ?
Is it so that i have to switch first from PMode -> Real mode and than call this interrupt?
It would be possible to use one of the protected mode interfaces to shutdown the computer without going to real mode first on almost all modern computers.
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).
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??
Hello...
@Brenden: Sorry but not getting anything.. Can you try to elaborate yourself please...
@Pype: I havent try to switch in real mode.. I guess the steps are:
1. Load our Shutdown code in memory < 1 mb (jumphere:)
2. Reset PM & PG bit
3. Jump to new location below 1 mb(goto jumphere;)
4. Just wait & watch....
And one more question.. Is bochs emulate shutdown of pc?
@Brenden: Sorry but not getting anything.. Can you try to elaborate yourself please...
@Pype: I havent try to switch in real mode.. I guess the steps are:
1. Load our Shutdown code in memory < 1 mb (jumphere:)
2. Reset PM & PG bit
3. Jump to new location below 1 mb(goto jumphere;)
4. Just wait & watch....
And one more question.. Is bochs emulate shutdown of pc?
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Shutdown code??
haven't tried so far ... what about getting a disk image of The Mobius and finding out ?viral wrote:
And one more question.. Is bochs emulate shutdown of pc?
Re:Shutdown code??
Hi,
For ACPI, welcome to hell!
Cheers,
Brendan
For the APM functions, there's protected mode interfaces (similar to the protected mode interface for VBE video). To use them, you need to detect if any of the protected mode interfaces are supported and enable the protected mode interface you want to use during boot (i.e. in real mode). Then you set up some GDT entries for the protected mode interface and can use them to access APM functions directly from protected mode without switching back to real mode at all. It's been a long time since I've looked at the APM Specification though - it'd be best to download it and have a look...viral wrote:@Brenden: Sorry but not getting anything.. Can you try to elaborate yourself please...
For ACPI, welcome to hell!
More completely, the "recommended" steps would be:viral wrote:@Pype: I havent try to switch in real mode.. I guess the steps are:
- 1. Load your shutdown code in memory < 1 mb (jumphere:)
2. Load "real mode compatible" segments (16 bit protected mode segments with limit = 64 KB)
3. Reset PM & PG bit
4. Far jump to new location below 1 mb (which reloads CS)
5. Load real mode segments for data segments and stack
6. Set SP to something
Bochs does (should)....viral wrote:And one more question.. Is bochs emulate shutdown of pc?
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??
Hello...
I tried above code.. What i did. I made a small "Hello world" bootloader and tried to shutdown after printing hello world. But it is giving error "Function Not Supported". Now why is it so?
My PC is P4 1.7Ghz, Intel 845GLLY. Windows is properly shut down... so is there something else i have to see ?
I tried above code.. What i did. I made a small "Hello world" bootloader and tried to shutdown after printing hello world. But it is giving error "Function Not Supported". Now why is it so?
My PC is P4 1.7Ghz, Intel 845GLLY. Windows is properly shut down... so is there something else i have to see ?
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Shutdown code??
wrong API version ? or maybe your PC only supports ACPI and not APM ... I'd say the "power & batteries" settings on your control panel should tell what is used by windows ...
Re:Shutdown code??
whos givin that error? probably bochs... did u tyr on a real machine?viral wrote: it is giving error "Function Not Supported". Now why is it so?
Re:Shutdown code??
The code give posted by Solar is giving this error.whos givin that error? probably bochs... did u tyr on a real machine?
I think my PC doesnt support that int. Is there any other way getting around it?
Re:Shutdown code??
post your code, perhaps you did some mistake. Is rare that a modern computer don?t support this.
Re:Shutdown code??
Code: Select all
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:
prn("function not supported")
ret