shut down option
shut down option
for the turn off option in my os are the statments
cli
hlt
enough or do i need to do anything more??
i just store kernel and some programs on the ram.i am working on 16 bit real mode and coding in assembly language.
cli
hlt
enough or do i need to do anything more??
i just store kernel and some programs on the ram.i am working on 16 bit real mode and coding in assembly language.
Do you mean to holt your OS (as in sleep) or turn the PC off ?.
For turning off , most coders reboot, first Printing a mesage "Please remove disk from A: drive and press anykey to reboot"
eg:
For turning off , most coders reboot, first Printing a mesage "Please remove disk from A: drive and press anykey to reboot"
eg:
Code: Select all
ReBootMe:
DB 0EAh ; Machine language to jump to address FFFF:0000 (reboot)
DW 0000h
DW 0FFFFh ; No return required we're rebooting!
jmp $ ; Just incase ;-)
or you can use this in PMode:
but if you want to turn off (via code) the power supply unit ?
Code: Select all
mov al, 0FEh
out 64h, al ;this cause a soft resetKeep coding...
...the sky is the limit
AsteriOS project: http://www.mindfields.gr/main/index.php ... &Itemid=27
...the sky is the limit
AsteriOS project: http://www.mindfields.gr/main/index.php ... &Itemid=27
i have given the user another option for reboot.
after the user selects the os to turn off the computer
i have to
1) cli
2) hlt
3) turn off the power supply
do i need to do anything more/less to turn off the computer?
and how do i turn off the power supply via code ?
i am coding in assembly language (16 bit real mode)
after the user selects the os to turn off the computer
i have to
1) cli
2) hlt
3) turn off the power supply
do i need to do anything more/less to turn off the computer?
and how do i turn off the power supply via code ?
i am coding in assembly language (16 bit real mode)
Last edited by vishal on Tue Feb 26, 2008 3:10 am, edited 1 time in total.
Maybe this:
Using APM 1.2 (I have tried it in an AMD64 3000+ in a 2 year old motherboard and worked):
http://www.osdev.org/phpBB2/viewtopic.p ... c&start=13
Using APM 1.2 (I have tried it in an AMD64 3000+ in a 2 year old motherboard and worked):
Code: Select all
;***remove this if your are using real/unreal mode***
xor eax,eax
mov cr0,eax
;***to here***
mov ax,5301h
xor bx,bx
int 15h
mov ax,530Eh
mov cx,0102h
int 15h
mov ax,5307h
mov bl,0001h
mov cx,0003h
int 15h
;***system will shutdown, or else there was a error***
Error:But you need to make sure you don't overwrite the real mode IVT while you are in PMODE if you want this to work. That obviously does not apply to the OP as he is creating a real mode OS.~ wrote:Maybe this:
Using APM 1.2 (I have tried it in an AMD64 3000+ in a 2 year old motherboard and worked):
http://www.osdev.org/phpBB2/viewtopic.p ... c&start=13Code: Select all
;***remove this if your are using real/unreal mode*** xor eax,eax mov cr0,eax ;***to here*** mov ax,5301h xor bx,bx int 15h mov ax,530Eh mov cx,0102h int 15h mov ax,5307h mov bl,0001h mov cx,0003h int 15h ;***system will shutdown, or else there was a error*** Error:
Code: Select all
/* world's last mistake in C */
if(code = CODE_RED) {
launch_missles();
}First you do not do the cli or hlt, here is the code from DexOS that shuts down
Code: Select all
mov ax,5300h ; See if APM available
mov bx,0 ; device = BIOS
int 15h
mov si,NoPowerManagment
jc .Error
cmp ax,101h ; See if version 1.1 or greater
mov dx,WrongVersion
jc .Error
mov [PowerManagmentVersion],ax
mov ax,5301h ; Do a real mode connection
mov bx,0 ; device = BIOS
int 15h
jnc .NoConnectionError
cmp ah,2 ; Pass if already connected
mov si,ErrorMessage ; else error
jnz .Error
.NoConnectionError:
mov ax,530eh ; Enable latest version of APM
mov bx,0 ; device = BIOS
mov cx,[PowerManagmentVersion] ; version
int 15h
mov si,ErrorMessage
jc .Error
mov ax,530dh ; Now engage and enable CPU management
mov bx,1 ; device = all
mov cx,1 ; enable
int 15h
mov si,ErrorMessage
jc .Error
mov ax,530fh
mov bx,1 ; device = ALL
mov cx,1 ; enable
int 15h
mov si,ErrorMessage
jc .Error
mov ax,5307h ; Do the power down
mov bx,1 ; device = ALL
mov cx,3 ; mode = OFF
int 15h ; shutdown CPU
mov si,ErrorMessage
.Error:
call PrintString
jmp ReBoot ; reboot
PowerManagmentVersion dw 0
NoPowerManagment db 'No power management functionality',10,13,0
ErrorMessage db 'Power management error',10,13,0
WrongVersion db 'Need APM version 1.1 or better',10,13,0
-
StephanvanSchaik
- Member

- Posts: 127
- Joined: Sat Sep 29, 2007 5:43 pm
- Location: Amsterdam, The Netherlands
If you want to shutdown you have 4 methods you can use in total...
1. Try to shutdown with ACPI.
2. Try to shutdown with APM.
3. Ehm forgot this one... (Should be a hack or something, I don't remember, but there's always the search function
)
4. There's no way to shutdown the PC, just display a message like "You can now turn off your computer.".
If I am right MenuetOS has some code to shutdown properly via APM if I remember well or it was some other operating system.
You can check the wiki and google is your friend.
Regards, Stephan J.R. van Schaik.
1. Try to shutdown with ACPI.
2. Try to shutdown with APM.
3. Ehm forgot this one... (Should be a hack or something, I don't remember, but there's always the search function
4. There's no way to shutdown the PC, just display a message like "You can now turn off your computer.".
If I am right MenuetOS has some code to shutdown properly via APM if I remember well or it was some other operating system.
You can check the wiki and google is your friend.
Regards, Stephan J.R. van Schaik.


