Read the clock in the CMOS memory

Source: Internet
Author: User

I. CMOS memory details
General PCs/AT, 286, 386, 486 and other computers are equipped with CMOS chips, CMOS & 127; the chip contains a real clock
And 64-byte CMOS memory. In the CMOS memory, 0-0dh indicates information about the real clock. 0e-& 127; 3fh contains
Computer hardware configuration information, such as the general memory size, extended memory size, & 127; floppy disk type, fixed
Disk Type, physical parameters, display type, etc. These parameters are closely related to whether the computer can work normally.
And the computer's boot password and other auxiliary settings. Table 1 lists the CMOS memory characters.
Section.

Offset
(Hexadecimal)
Offset
(Decimal)
Field Length
(Bytes)
Function Description
00 h 0 1 Current second described in BCD (00-59)
01 H 1 1 Alarm clock seconds described in BCD
02 h 2 1 Alarm current minute (00-59) described in BCD)
03 h 3 1 Alarm clock minutes described in BCD
04 H 4 1 Alarm current hour (00-23) described in BCD)
05 h 5 1 Alarm clock (in hours) described in BCD)
06 h 6 1 Current date (day of the week) described in BCD (00-06)
07 h 7 1 Current date (day) (00-31) described in BCD)
08 h 8 1 Current month described in BCD (00-12)
09 h 9 1 Current year (00-99) described in BCD)
0ah 10 1 Status Registration Code
0bh 11 1 Status Registration Code B
0ch 12 1 Status Registration Code C
0dh 13 1 Status registration code D
0eh 14 1 Diagnostic status
0fh 15 1 System close code
10 h 16 1 Floppy Disk Drive Type
11 h 17 1 Advanced BIOS settings
12 h 18 1 Hard Disk o/I type (0-15)
13 H 19 1 Keyboard input speed and latency
14 h 20 1 Install a device
15 h 21 1 Basic memory counted from low byte to 1 KB
16 h 22 1 The basic memory counted from the high byte, measured in 1 KB
17 h 23 1 Extended memory from low byte count, with 1 K count
18 h 24 1 Extended memory from high byte count, with 1 K count
19 h 25 1 Hard Disk expansion type 0 (0-255)
1ah 26 1 Hard Disk expansion type 1 (0-255)
1bh 27 8 User-Defined type information of Hard Disk 0
24 h 36 8 Disk 1 user-defined type information
2dh 45 1 Advanced BIOS settings
2EH 46 1 High-byte CMOS checksum
2fh 47 1 Low-byte CMOS checksum
30 h 48 1 Extended memory from Post reports with low Byte Count
31 H 49 1 Extended memory from Post reports with high byte count
32 h 50 1 BCD code a.m. (00-90)
33 H 51 1 Power-on self-check information mark
34 h 52 2 Advanced BIOS settings
36 h 54 1 Specify BIOS settings for the chipset
37 h 55 7 Power-on password (usually encrypted)
3eh 62 1 Extended CMOS checksum from high byte count
3fh 63 1 Extended CMOS checksum from low Byte Count

 

Ii. read/write CMOS memory
The addresses of the CMOS memory and Data ports are respectively 70 h and 71 h. When writing CMOS memory
The address of the CMOS memory to be written to is 70 h and 127; the address of the data to be written is 71 h. In
When reading the CMOS memory, the address of the CMOS memory to be read is sent to the port address 70 h, and then 71 h from the port address.
Read data to the Al register.

3. The C program in Linux is as follows:

# Include <unistd. h> <br/> # include <malloc. h> <br/> # include <stdio. h> <br/> # include <time. h> <br/> # include <sys/Io. h> <br/> # define cmos_read (ADDR) ({/<br/> outb (0x80 | ADDR, 0x70); INB (0x71 );}) <br/> # define bcd_to_bin (VAL) = (VAL) & 15) + (VAL)> 4) * 10) <br/> int main () <br/> {<br/> iopl (3); <br/> struct TM * time; <br/> time = (struct TM *) malloc (sizeof (struct TM); <br/> do {<br/> time-> tm_sec = cmos_read (0 ); < Br/> time-> tm_min = cmos_read (2); <br/> time-> tm_hour = cmos_read (4); <br/>}while (time-> tm_sec! = Cmos_read (0); <br/> bcd_to_bin (time-> tm_sec); <br/> bcd_to_bin (time-> tm_min ); <br/> bcd_to_bin (time-> tm_hour); <br/> printf ("% d-% d", time-> tm_sec, time-> tm_min, time-> tm_hour); <br/> return 0; <br/>}< br/>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.