Import backup from 2004-01-26
This commit is contained in:
parent
21e3943b5e
commit
311b8afc83
85
Functions.c
85
Functions.c
@ -45,6 +45,18 @@ char *strcat(char *dest, char *src)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//converts a binary-coded-decimal byte to its decimal equivalent
|
||||||
|
inline byte bcd2byte(byte bcd)
|
||||||
|
{
|
||||||
|
return (10* ((bcd & 0xF0) >> 4)) + (bcd & 0x0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
//converts a binary-coded-decimal byte to its decimal equivalent
|
||||||
|
inline byte byte2bcd(byte bite)
|
||||||
|
{
|
||||||
|
return ((bite / 10) << 4) | (bite % 10);
|
||||||
|
}
|
||||||
|
|
||||||
void rtrim(char *str)
|
void rtrim(char *str)
|
||||||
{
|
{
|
||||||
str += strlen(str); //now points to the null character at the end of the string
|
str += strlen(str); //now points to the null character at the end of the string
|
||||||
@ -182,6 +194,79 @@ inline dword kernel_size()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//These functions are for reading and writing various values stored on the CMOS Real Time Clock
|
||||||
|
byte rtc_readDay()
|
||||||
|
{
|
||||||
|
outportb(0x70, 7);
|
||||||
|
return bcd2byte(inportb(0x71));
|
||||||
|
}
|
||||||
|
|
||||||
|
byte rtc_readMonth()
|
||||||
|
{
|
||||||
|
outportb(0x70, 8);
|
||||||
|
return bcd2byte(inportb(0x71));
|
||||||
|
}
|
||||||
|
|
||||||
|
byte rtc_readYear()
|
||||||
|
{
|
||||||
|
outportb(0x70, 9);
|
||||||
|
return bcd2byte(inportb(0x71));
|
||||||
|
}
|
||||||
|
|
||||||
|
byte rtc_readSecond()
|
||||||
|
{
|
||||||
|
outportb(0x70, 0);
|
||||||
|
return bcd2byte(inportb(0x71));
|
||||||
|
}
|
||||||
|
|
||||||
|
byte rtc_readMinute()
|
||||||
|
{
|
||||||
|
outportb(0x70, 2);
|
||||||
|
return bcd2byte(inportb(0x71));
|
||||||
|
}
|
||||||
|
|
||||||
|
byte rtc_readHour()
|
||||||
|
{
|
||||||
|
outportb(0x70, 4);
|
||||||
|
return bcd2byte(inportb(0x71));
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtc_setDay(byte day)
|
||||||
|
{
|
||||||
|
outportb(0x70, 7);
|
||||||
|
outportb(0x71, byte2bcd(day));
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtc_setMonth(byte month)
|
||||||
|
{
|
||||||
|
outportb(0x70, 8);
|
||||||
|
outportb(0x71, byte2bcd(month));
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtc_setYear(byte year)
|
||||||
|
{
|
||||||
|
outportb(0x70, 9);
|
||||||
|
outportb(0x71, byte2bcd(year));
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtc_setSecond(byte second)
|
||||||
|
{
|
||||||
|
outportb(0x70, 0);
|
||||||
|
outportb(0x71, byte2bcd(second));
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtc_setMinute(byte minute)
|
||||||
|
{
|
||||||
|
outportb(0x70, 2);
|
||||||
|
outportb(0x71, byte2bcd(minute));
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtc_setHour(byte hour)
|
||||||
|
{
|
||||||
|
outportb(0x70, 4);
|
||||||
|
outportb(0x71, byte2bcd(hour));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
15
functions.h
15
functions.h
@ -25,7 +25,20 @@ char *strcat(char *dest, char *src);
|
|||||||
void rtrim(char *str);
|
void rtrim(char *str);
|
||||||
char *ucase(char *str);
|
char *ucase(char *str);
|
||||||
char *lcase(char *str);
|
char *lcase(char *str);
|
||||||
|
inline byte bcd2byte(byte bcd);
|
||||||
|
inline byte byte2bcd(byte bite);
|
||||||
|
byte rtc_readDay();
|
||||||
|
byte rtc_readMonth();
|
||||||
|
byte rtc_readYear();
|
||||||
|
byte rtc_readSecond();
|
||||||
|
byte rtc_readMinute();
|
||||||
|
byte rtc_readHour();
|
||||||
|
void rtc_setDay(byte dat);
|
||||||
|
void rtc_setMonth(byte month);
|
||||||
|
void rtc_setYear(byte year);
|
||||||
|
void rtc_setSecond(byte second);
|
||||||
|
void rtc_setMinute(byte minute);
|
||||||
|
void rtc_setHour(byte hour);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
5
kernel.c
5
kernel.c
@ -82,9 +82,11 @@ void k_init()
|
|||||||
printf("HOS 0.13 - Kernel File Size: %u kb\tData Size: %u bytes\n", kernel_size()>>10, (dword)(&_end)-(dword)(&_code));
|
printf("HOS 0.13 - Kernel File Size: %u kb\tData Size: %u bytes\n", kernel_size()>>10, (dword)(&_end)-(dword)(&_code));
|
||||||
printf("Memory available to OS: %u MB (%u bytes)\n", mm_megabytes, mm_totalmem);
|
printf("Memory available to OS: %u MB (%u bytes)\n", mm_megabytes, mm_totalmem);
|
||||||
printf("Free memory: %u bytes (%u pages)\n", mm_freemem(), mm_freemem()>>12);
|
printf("Free memory: %u bytes (%u pages)\n", mm_freemem(), mm_freemem()>>12);
|
||||||
|
printf("%d/%d/%d\t%d:%d:%d\n", rtc_readMonth(), rtc_readDay(), rtc_readYear(), rtc_readHour(), rtc_readMinute(), rtc_readSecond());
|
||||||
printf("Root Directory: %s/\n", rootDevice->id);
|
printf("Root Directory: %s/\n", rootDevice->id);
|
||||||
|
|
||||||
int a;
|
|
||||||
|
/* int a;
|
||||||
byte *addr = 0;
|
byte *addr = 0;
|
||||||
for (a = 0; a < 5; a++)
|
for (a = 0; a < 5; a++)
|
||||||
{
|
{
|
||||||
@ -97,6 +99,7 @@ void k_init()
|
|||||||
memcpy(0, addr, 4192);
|
memcpy(0, addr, 4192);
|
||||||
asm("call 0");
|
asm("call 0");
|
||||||
free(addr);
|
free(addr);
|
||||||
|
*/
|
||||||
|
|
||||||
dword key = 0;
|
dword key = 0;
|
||||||
for (;;)
|
for (;;)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user