/*-----------------------------
//静态函数
//函数的功能
*/
static void time_init(void)
{
struct tm time; //结构体
do {
time.tm_sec = CMOS_READ(0);
time.tm_min = CMOS_READ(2);
time.tm_hour = CMOS_READ(4);
time.tm_mday = CMOS_READ(7);
time.tm_mon = CMOS_READ(8)-1;
time.tm_year = CMOS_READ(9);
} while (time.tm_sec != CMOS_READ(0)); //
BCD_TO_BIN(time.tm_sec);
BCD_TO_BIN(time.tm_min);
BCD_TO_BIN(time.tm_hour);
BCD_TO_BIN(time.tm_mday);
BCD_TO_BIN(time.tm_mon);
BCD_TO_BIN(time.tm_year);
startup_time = kernel_mktime(&time);
}
#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) //这个写的比较经典 呵呵二进制编码的十进制表示
#define CMOS_READ(addr) ({ \ //禁止NMI(不可屏蔽中断)
outb_p(0x80|addr,0x70); \
inb_p(0x71); \
})
需要学习汇编语言了
嗨!编程能力实在是很差