Programming the wake-up time

Only for programmers and BIOS gurus with technical questions.
Post Reply
DougButtimer
New visitors - please read the rules.
Posts: 9
Joined: Sat Jul 28, 2007 10:46 pm

I want my application to be able to wake up (power-up) the computer at a time of it's choosing. I have managed to get it to write the wake-up time ot the RTC registers (offsets 1,3 and 5) accessible via I/O address 0x70 and 0x71. I can read these back O.K. However, if I restart the PC, the values are overwritten by the values in the BIOS setup screen. So where are these values stored - I obviously need to overwrite these, so that the required values end up in the RTC. Can anyone help with how BIOS works in this respect ? Any help would be greatly appreciated !
cp
BIOS Guru
Posts: 1914
Joined: Mon Oct 21, 2002 9:07 pm
Location: Germany

Those values are stored in the mainboard's cmos memory (which is powered by the small coin battery). While it is possible to get access to the cmos memory and thus alter the values, it may be impossible to get to know WHERE in the cmos the wakeup time is stored. placing of variables is totally free for every bios manufacturer..
a possible cmos memory map MAY be:
http://www.bioscentral.com/misc/cmosmap.htm

the only way to find out: trail and error.
DougButtimer
New visitors - please read the rules.
Posts: 9
Joined: Sat Jul 28, 2007 10:46 pm

Thanks for your reply CP ! You've confirmed my suspicions ! Clearly, it must be stored SOMEWHERE - I've trawled through the 128 bytes of CMOS (it repeats over the next 128, so it's an image) and looked for the data but it doesn't seem to be there. Also, changed the BIOS values, and the CMOS data (apart from the RTC regs) doesn't change, so I DON'T believe that it's stored in CMOS memory- what I don't understand is why the BIOS initialises the RTC alarm/wakeup registers on power-down when it could write them to the NV RTC registers directly. I have JUST had a thought - I wonder if it ACTUALLY writes to some area in main memory, knowing that power is on, and that either it, or the OS copies it to RTC at shut down ? Either way, I STILL don't know where that is !!! How do applications that control power up/down manage to do it without knowing either the BIOS or OS ? I'd appreciate your thought on that !
DougButtimer
New visitors - please read the rules.
Posts: 9
Joined: Sat Jul 28, 2007 10:46 pm

Hi again CP ! Looking through the CMOS map that you supplied, I noticed the Serial Number bytes and that got me looking again at the CMOS data that I said that had not changed with the BIOS wakeup time settings. I was wrong (I am frequently according to my wife !) and I see three bytes different in that area (0x44,45 and 46) !!! If you ignore the 3 MSB's, the bottom 5 bits of each byte IS the binary equivalent of the BCD values stored in the RTC regs !!!!!! So, by expaining the problem to you, I think that I've solved my problem !!! Now to try it for REAL ........... !! Thanks for your help !
cp
BIOS Guru
Posts: 1914
Joined: Mon Oct 21, 2002 9:07 pm
Location: Germany

as i wrote in my first post: they are totally free putting those bytes anywhere in the cmos. but they have to put them somewhere in there. all user-made changes will be saved into the cmos memory. otherwise all changes would be lost if you power off the computer (and pull the plug to get rid of standby). the cmos is SRAM which holds the data as long as there is a power source connected to it, like a coin battery. the main memory is DRAM which needs to be refreshed once in a while (every 15.6µs for 100MHz FSB) otherwise it loses its data.
in the LinuxBIOS project they saved the cmos layouts of some boards..
DougButtimer
New visitors - please read the rules.
Posts: 9
Joined: Sat Jul 28, 2007 10:46 pm

Hi cp, Yes, but the BIOS wakeup change is made by the user before the OS loads, so BIOS can load the RTC immediately. Why does it reload the RTC AGAIN at power-down - that's what I don't understand ! If an application wants to CHANGE this setting, then it need to know some arbitrary locations in CMOS (decided by the BIOS writers as you say) whereas the location of the RTC is well established. I just don't understand the complication being imposed ! Incidently, as our TV has just gone "on the blink", I haven't had time to do the REAL test of my earlier "find" ! I will post my success/failure !!
cp
BIOS Guru
Posts: 1914
Joined: Mon Oct 21, 2002 9:07 pm
Location: Germany

why should an application want to CHANGE the settings done by the user in the bios? the reason why those settings are done in the bios is quite simple: they should work without anything else (like OS or any 3rd tools). the bios just enforces its settings..there's nothing bad about that.
if a 3rd party tool would want to use alarm timers it should be able to detect various multi I/O chips (or integrated parts of the southbridge) and correctly write data into them even without using bios int-functions.
DougButtimer
New visitors - please read the rules.
Posts: 9
Joined: Sat Jul 28, 2007 10:46 pm

Hi cp, I think we may be talking at cross purposes here. When I talk about the BIOS setup, I'm refering to the action of entering BIOS at power-up (typically by pressing del, F1, F12 or some other keyboard key) - I didn't mean calling BIOS functions ! My application is a bolt-on to a commercial PVR program and currently has no automatic power-up capability - that is what I am endeavouring to add by modifying the CMOS data(and thereby altering the alarm setting of the RTC). However, it's a bit like climbing a mountain - you reach a peak, and there's another one beyond !!!! Cheers for now !
DougButtimer
New visitors - please read the rules.
Posts: 9
Joined: Sat Jul 28, 2007 10:46 pm

Although I have had SOME success with this project, I'm sorry to say that I still haven't been able to make it work as it should (.. yet !) I have discovered which CMOS locations to write the alarm data to, and the BIOS successfully transfers this data to the RTC. However, the PC still will not power-up automatically. As a test, I have written the RTC and then monitored the interrupt status register (obviously with power on all the time), and an interrupt DOES occur. My conclusion is that the interrupt is not getting though to the PSU and that BIOS must do "something else" to make that happen. As the RTC and CMOS are buried in the chipset, I'm convinced that the actions required will be common to lots of PC's (viz. the allocation of I/O addresses 0x70 and 0x71). Does anyone have any knowledge in this area that might help with my problem, or suggest any "experiments" to do ?
apple_rom
Use my patch at your own risk!!
Posts: 125
Joined: Tue Jan 07, 2003 11:39 am
Location: Minsk
Contact:

1. Fix CMOS CRC after change values.
2. Set "Enable Resume on Alarm" to "Enable".
cp
BIOS Guru
Posts: 1914
Joined: Mon Oct 21, 2002 9:07 pm
Location: Germany

http://www.winbond.com/NR/rdonlyres/585 ... 3977GA.pdf

take a look at pages 96 to 106. the 'on now' feature is what you are looking for. as you can see this is just ONE example how it could be implemented in a chip. if you now crank your pc open and another pc and take a look at the multi i/o chips you will (most probably) find that they are different. okay, you COULD write an application that queries the multi i/o (by reading various registers) and set the appropriate registers to make the alarm go off..but you would have to implement different register locations for every single multi i/o that was ever build onto a mainboard. that's what i meant when i said that certain things should be left to the bios..
DougButtimer
New visitors - please read the rules.
Posts: 9
Joined: Sat Jul 28, 2007 10:46 pm

apple_rom wrote:1. Fix CMOS CRC after change values.
2. Set "Enable Resume on Alarm" to "Enable".
I have set the CRC at locations 0x4c & 0x4d for changes made at 0x40, 0x42,3&4.
Where is this "Enable Resume on Alarm" ?? In BIOS setup ? If so, hopefully this is already set from the previous Alarm setting within BIOS setup - all I am doing is changing the time. If in CMOS, more details would really be appreciated !
apple_rom
Use my patch at your own risk!!
Posts: 125
Joined: Tue Jan 07, 2003 11:39 am
Location: Minsk
Contact:

3. Read APM/ACPI specifications
4. Search by:
  • RTC_STS
    RTC_EN
    DAY_ALRM
    MON_ALRM
    "ACPI WakeUp"
    "RTC alarm"
    "Resume by Alarm"

5. http://sourceforge.net/projects/nvram-wakeup/
6. http://www.bessems.biz/wakeup/
DougButtimer
New visitors - please read the rules.
Posts: 9
Joined: Sat Jul 28, 2007 10:46 pm

apple_rom wrote:3. Read APM/ACPI specifications
4. Search by:
  • RTC_STS
    RTC_EN
    DAY_ALRM
    MON_ALRM
    "ACPI WakeUp"
    "RTC alarm"
    "Resume by Alarm"

5. http://sourceforge.net/projects/nvram-wakeup/
6. http://www.bessems.biz/wakeup/
Hi, I've been searching around for the APM/ACPI specs but can't find them ! Do you happened to have a link ?

UPDATE !!! As luck would have it, I have JUST found them !!!
Last edited by DougButtimer on Wed Aug 01, 2007 11:44 pm, edited 1 time in total.
DougButtimer
New visitors - please read the rules.
Posts: 9
Joined: Sat Jul 28, 2007 10:46 pm

cp wrote:http://www.winbond.com/NR/rdonlyres/585 ... 3977GA.pdf

take a look at pages 96 to 106. the 'on now' feature is what you are looking for. as you can see this is just ONE example how it could be implemented in a chip. if you now crank your pc open and another pc and take a look at the multi i/o chips you will (most probably) find that they are different. okay, you COULD write an application that queries the multi i/o (by reading various registers) and set the appropriate registers to make the alarm go off..but you would have to implement different register locations for every single multi i/o that was ever build onto a mainboard. that's what i meant when i said that certain things should be left to the bios..
So, how would I request BIOS to set the wake-up time from my MSVC++ program - sorry, I have no experience of such interaction under Windows (2000 in my case)
Post Reply