Import backup from 2004-03-02
This commit is contained in:
parent
48f4046e79
commit
0b9d7fde22
340
Functions.c
340
Functions.c
@ -1,340 +0,0 @@
|
|||||||
//Functions.c
|
|
||||||
//05/07/03 Josh Holtrop
|
|
||||||
//for HOS
|
|
||||||
//Modified: 10/30/03
|
|
||||||
|
|
||||||
//Writes a byte out to a port
|
|
||||||
inline void outportb(unsigned int port, unsigned char value) // Output a byte to a port
|
|
||||||
{
|
|
||||||
asm volatile ("outb %%al,%%dx"::"d" (port), "a" (value));
|
|
||||||
};
|
|
||||||
|
|
||||||
//Writes a word out to a port
|
|
||||||
inline void outportw(unsigned int port, unsigned int value) // Output a word to a port
|
|
||||||
{
|
|
||||||
asm volatile ("outw %%ax,%%dx"::"d" (port), "a" (value));
|
|
||||||
};
|
|
||||||
|
|
||||||
//Reads a byte from a port
|
|
||||||
inline byte inportb(unsigned short port)
|
|
||||||
{
|
|
||||||
unsigned char ret_val;
|
|
||||||
|
|
||||||
asm volatile("inb %w1,%b0"
|
|
||||||
: "=a"(ret_val)
|
|
||||||
: "d"(port));
|
|
||||||
return ret_val;
|
|
||||||
};
|
|
||||||
|
|
||||||
//Enables (SeTs) Interrupt Flag on the processor
|
|
||||||
inline void enable_ints()
|
|
||||||
{
|
|
||||||
asm("sti");
|
|
||||||
};
|
|
||||||
|
|
||||||
//Disables (CLears) Interrupt Flag on the processor
|
|
||||||
inline void disable_ints()
|
|
||||||
{
|
|
||||||
asm("cli");
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
char *strcat(char *dest, char *src)
|
|
||||||
{
|
|
||||||
strcpy(dest+strlen(dest), src);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//Splits a string into multiple strings by turning all characters
|
|
||||||
// equal to delim into null values (string termination character)
|
|
||||||
//Returns the number of strings after the split, 1 if no delim chars
|
|
||||||
int string_split(char *str, char delim)
|
|
||||||
{
|
|
||||||
if (strlen(str) < 1)
|
|
||||||
return 0; //empty string
|
|
||||||
int count = 1;
|
|
||||||
for (; *str; str++)
|
|
||||||
{
|
|
||||||
if (*str == delim)
|
|
||||||
{
|
|
||||||
count++;
|
|
||||||
*str = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//Advances a char pointer to the byte after the current string's
|
|
||||||
// null-terminating character
|
|
||||||
//Useful after calling string_split()
|
|
||||||
//Returns a pointer to the following string
|
|
||||||
char *string_advance(char *str)
|
|
||||||
{
|
|
||||||
for (; *str; str++);
|
|
||||||
return str+1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//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)
|
|
||||||
{
|
|
||||||
str += strlen(str); //now points to the null character at the end of the string
|
|
||||||
str--;
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
if ((*str == ' ') || (*str == '\t') || (*str == '\n'))
|
|
||||||
*str-- = 0;
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
char *ucase(char *str)
|
|
||||||
{
|
|
||||||
char *ret = str;
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
if (*str == 0)
|
|
||||||
break;
|
|
||||||
if ((*str >= 'a') && (*str <= 'z'))
|
|
||||||
*str = (*str) - 32;
|
|
||||||
str++;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
char *lcase(char *str)
|
|
||||||
{
|
|
||||||
char *ret = str;
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
if (*str == 0)
|
|
||||||
break;
|
|
||||||
if ((*str >= 'A') && (*str <= 'Z'))
|
|
||||||
*str = (*str) + 32;
|
|
||||||
str++;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//Re-maps the Programmable Interrupr Controllers so IRQ0->pic1 base address, IRG8->pic2 base address
|
|
||||||
void remap_pics(int pic1, int pic2)
|
|
||||||
{
|
|
||||||
byte a1, a2;
|
|
||||||
|
|
||||||
a1 = inportb(PIC1_DATA); //0x21
|
|
||||||
a2 = inportb(PIC2_DATA); //0xA1
|
|
||||||
|
|
||||||
outportb(PIC1_COMMAND, ICW1_INIT+ICW1_ICW4); //0x20, 0x10+0x01 00010001b
|
|
||||||
outportb(PIC2_COMMAND, ICW1_INIT+ICW1_ICW4); //0xA0, 0x10+0x01 00010001b
|
|
||||||
outportb(PIC1_DATA, pic1); //0x21, pic1
|
|
||||||
outportb(PIC2_DATA, pic2); //0xA1, pic2
|
|
||||||
outportb(PIC1_DATA, 4); //0x21, 0x04 00000100b
|
|
||||||
outportb(PIC2_DATA, 2); //0xA1, 0x02 00000010b
|
|
||||||
outportb(PIC1_DATA, ICW4_8086); //0x21, 0x01 00000001b
|
|
||||||
outportb(PIC2_DATA, ICW4_8086); //0xA1, 0x01 00000001b
|
|
||||||
|
|
||||||
outportb(PIC1_DATA, a1); //0x21
|
|
||||||
outportb(PIC2_DATA, a2); //0xA1
|
|
||||||
}
|
|
||||||
|
|
||||||
//Masks interrupts on first Programmable Interrupt Controller
|
|
||||||
inline void pic1_mask(byte mask)
|
|
||||||
{
|
|
||||||
outportb(PIC1_DATA, mask); //0x21, maskfield *OCW1*
|
|
||||||
}
|
|
||||||
|
|
||||||
//Masks interrupts on second Programmable Interrupt Controller
|
|
||||||
inline void pic2_mask(byte mask)
|
|
||||||
{
|
|
||||||
outportb(PIC2_DATA, mask); //0xA1, maskfield *OCW1*
|
|
||||||
}
|
|
||||||
|
|
||||||
//Restarts the computer
|
|
||||||
inline void restart()
|
|
||||||
{
|
|
||||||
enable_ints();
|
|
||||||
byte temp;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
temp = inportb(0x64);
|
|
||||||
if (temp & 1)
|
|
||||||
inportb(0x60);
|
|
||||||
} while(temp & 2);
|
|
||||||
|
|
||||||
|
|
||||||
outportb (0x64, 0xfe);
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Halts (freezes) the computer
|
|
||||||
inline void halt()
|
|
||||||
{
|
|
||||||
asm("cli");
|
|
||||||
asm("hlt");
|
|
||||||
while (1)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Initializes 8253 Programmable Interrupt Timer
|
|
||||||
inline void init_timer()
|
|
||||||
{
|
|
||||||
//set timer : 2e9c = 100hz
|
|
||||||
outportb(0x43, 0x34);
|
|
||||||
outportb(0x40, 0x9c); //lsb
|
|
||||||
outportb(0x40, 0x2e); //msb
|
|
||||||
}
|
|
||||||
|
|
||||||
//Signals an End Of Interrupt signal to the first PIC
|
|
||||||
inline void eoi()
|
|
||||||
{
|
|
||||||
outportb(0x20, 0x20);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Signals an End Of Interrupt signal to both the second and first PIC unit
|
|
||||||
inline void eoi2()
|
|
||||||
{
|
|
||||||
outportb(0xA0, 0x20);
|
|
||||||
outportb(0x20, 0x20);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Returns the size of the kernel (code & data)
|
|
||||||
// - this does not include the bss section
|
|
||||||
// - this should be 4kb aligned per the linker script
|
|
||||||
// - this should be the size of kernel.bin
|
|
||||||
inline dword kernel_size()
|
|
||||||
{
|
|
||||||
return (dword)(&_bss)-(dword)(&_code);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//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));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//Returns the cmos type of floppy disk drive 0 (0 = not present)
|
|
||||||
byte cmos_getfd0()
|
|
||||||
{
|
|
||||||
outportb(0x70, 0x10);
|
|
||||||
return (inportb(0x71) >> 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//Returns the cmos type of floppy disk drive 1 (0 = not present)
|
|
||||||
byte cmos_getfd1()
|
|
||||||
{
|
|
||||||
outportb(0x70, 0x10);
|
|
||||||
return (inportb(0x71) & 0x0F);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//Returns the cmos type of hard disk drive 0 (0 = not present)
|
|
||||||
byte cmos_gethd0()
|
|
||||||
{
|
|
||||||
outportb(0x70, 0x12);
|
|
||||||
return (inportb(0x71) >> 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//Returns the cmos type of hard disk drive 1 (0 = not present)
|
|
||||||
byte cmos_gethd1()
|
|
||||||
{
|
|
||||||
outportb(0x70, 0x12);
|
|
||||||
return (inportb(0x71) & 0x0F);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
12
backup.bat
12
backup.bat
@ -1,12 +0,0 @@
|
|||||||
@echo off
|
|
||||||
echo Backing up to .\Backup\%1
|
|
||||||
|
|
||||||
mkdir .\Backup\%1
|
|
||||||
|
|
||||||
copy *.h .\Backup\%1
|
|
||||||
copy *.c .\Backup\%1
|
|
||||||
copy *.inc .\Backup\%1
|
|
||||||
copy *.asm .\Backup\%1
|
|
||||||
copy *.ld .\Backup\%1
|
|
||||||
copy *.bat .\Backup\%1
|
|
||||||
|
|
1
c2.bat
1
c2.bat
@ -1 +0,0 @@
|
|||||||
gcc -ffreestanding -fno-builtin -nostdlib -nodefaultlibs -c kernel.c -o kernel.o
|
|
@ -1,2 +0,0 @@
|
|||||||
rem rawrite -f stage1.bin -d a -n
|
|
||||||
partcopy stage1.bin 0 200 -f0
|
|
345
fat12.c
345
fat12.c
@ -1,345 +0,0 @@
|
|||||||
// fat12.c
|
|
||||||
// Author: Josh Holtrop
|
|
||||||
// Created: 01/04/04
|
|
||||||
// Modified: 01/14/04
|
|
||||||
|
|
||||||
|
|
||||||
byte *fat12_readFile(char *fileName, DiskDevice *dd)
|
|
||||||
{
|
|
||||||
char *fileNameUCase = malloc(strlen(fileName) + 1);
|
|
||||||
strcpy(fileNameUCase, fileName);
|
|
||||||
ucase(fileNameUCase);
|
|
||||||
dword iMadeClusterChain = getClusterChain(dd);
|
|
||||||
Fat12Entry fe;
|
|
||||||
if (fat12_getFileHandle(fileNameUCase, dd, &fe))
|
|
||||||
{
|
|
||||||
free(fileNameUCase);
|
|
||||||
if (iMadeClusterChain)
|
|
||||||
{
|
|
||||||
free(clusterChain);
|
|
||||||
clusterChain = 0;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
byte *fp = (byte *)fat12_readClusterChain(dd, &fe);
|
|
||||||
free(fileNameUCase);
|
|
||||||
if (iMadeClusterChain)
|
|
||||||
{
|
|
||||||
free(clusterChain);
|
|
||||||
clusterChain = 0;
|
|
||||||
}
|
|
||||||
return fp;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
dword fat12_getFileHandle(char *fileName, DiskDevice *dd, Fat12Entry *destination)
|
|
||||||
{
|
|
||||||
if (strlen(fileName) < 1)
|
|
||||||
return 1;
|
|
||||||
if (fileName[strlen(fileName)-1] == '/')
|
|
||||||
return 2;
|
|
||||||
dword iMadeClusterChain = getClusterChain(dd);
|
|
||||||
int fileName_length = strlen(fileName);
|
|
||||||
int a;
|
|
||||||
int entries = 1;
|
|
||||||
for (a = 0; a < fileName_length; a++)
|
|
||||||
{
|
|
||||||
if (fileName[a] == '/')
|
|
||||||
{
|
|
||||||
fileName[a] = 0;
|
|
||||||
entries++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
char *pointer = fileName;
|
|
||||||
Fat12Entry *workingDirectory = 0;
|
|
||||||
Fat12Entry workingDir;
|
|
||||||
for (a = 0; a < (entries - 1); a++)
|
|
||||||
{
|
|
||||||
if (fat12_getDirectoryHandle(pointer, dd, workingDirectory, &workingDir)) //an error occurred if this returns nonzero
|
|
||||||
{
|
|
||||||
if (iMadeClusterChain)
|
|
||||||
{
|
|
||||||
free(clusterChain);
|
|
||||||
clusterChain = 0;
|
|
||||||
}
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
workingDirectory = &workingDir;
|
|
||||||
for (;;) //advance to the next dir name
|
|
||||||
{
|
|
||||||
pointer++;
|
|
||||||
if (*pointer == 0)
|
|
||||||
{
|
|
||||||
pointer++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (fat12_getFileHandleInDirectory(pointer, dd, workingDirectory, destination)) //an error occurred if this returns nonzero
|
|
||||||
{
|
|
||||||
if (iMadeClusterChain)
|
|
||||||
{
|
|
||||||
free(clusterChain);
|
|
||||||
clusterChain = 0;
|
|
||||||
}
|
|
||||||
return 4;
|
|
||||||
}
|
|
||||||
if (iMadeClusterChain)
|
|
||||||
{
|
|
||||||
free(clusterChain);
|
|
||||||
clusterChain = 0;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
dword fat12_getFileHandleInDirectory(char *fileName, DiskDevice *dd, Fat12Entry *currDir, Fat12Entry *destination)
|
|
||||||
{
|
|
||||||
if (!currDir) // we are working in the root directory
|
|
||||||
{
|
|
||||||
Fat12Entry *rootDir = malloc(14*512); //root directory is 14 sectors long
|
|
||||||
vfs_readSector(dd, 19, (byte *)rootDir, 14);
|
|
||||||
int a;
|
|
||||||
for (a = 0; a < 224; a++) //224 max root directory entries in 14 sectors
|
|
||||||
{
|
|
||||||
if (rootDir[a].fileName[0] == 0)
|
|
||||||
break;
|
|
||||||
if ((byte)rootDir[a].fileName[0] != 0xE5)
|
|
||||||
{
|
|
||||||
if ((rootDir[a].attributes & 0x18) == 0) //this entry is a directory
|
|
||||||
{
|
|
||||||
char dirName[9];
|
|
||||||
char dirExt[4];
|
|
||||||
memcpy(dirName, rootDir[a].fileName, 8);
|
|
||||||
dirName[8] = 0;
|
|
||||||
memcpy(dirExt, rootDir[a].ext, 3);
|
|
||||||
dirExt[3] = 0;
|
|
||||||
rtrim(dirName);
|
|
||||||
rtrim(dirExt);
|
|
||||||
char dirWhole[14];
|
|
||||||
strcpy(dirWhole, dirName);
|
|
||||||
if (strlen(dirExt) > 0) //the directory has an extension
|
|
||||||
{
|
|
||||||
strcat(dirWhole, ".");
|
|
||||||
strcat(dirWhole, dirExt);
|
|
||||||
}
|
|
||||||
if (strcmp(dirWhole, fileName)) //the entry found is a match
|
|
||||||
{
|
|
||||||
free(rootDir);
|
|
||||||
*destination = rootDir[a];
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free(rootDir);
|
|
||||||
return 1; //no match found
|
|
||||||
}
|
|
||||||
dword retVal = 2;
|
|
||||||
dword iMadeClusterChain = getClusterChain(dd);
|
|
||||||
Fat12Entry *subDirectory = fat12_readClusterChain(dd, currDir);
|
|
||||||
if (!subDirectory)
|
|
||||||
return 5;
|
|
||||||
dword numberOfClusters = fat12_readClusterChainCount(dd, currDir);
|
|
||||||
int a;
|
|
||||||
for (a = 0; a < (numberOfClusters * 16); a++)
|
|
||||||
{
|
|
||||||
if (subDirectory[a].fileName[0] == 0)
|
|
||||||
break;
|
|
||||||
if ((byte)subDirectory[a].fileName[0] != 0xE5)
|
|
||||||
{
|
|
||||||
if ((subDirectory[a].attributes & 0x18) == 0) //this entry is a directory
|
|
||||||
{
|
|
||||||
char dirName[9];
|
|
||||||
char dirExt[4];
|
|
||||||
memcpy(dirName, subDirectory[a].fileName, 8);
|
|
||||||
dirName[8] = 0;
|
|
||||||
memcpy(dirExt, subDirectory[a].ext, 3);
|
|
||||||
dirExt[3] = 0;
|
|
||||||
rtrim(dirName);
|
|
||||||
rtrim(dirExt);
|
|
||||||
char dirWhole[14];
|
|
||||||
strcpy(dirWhole, dirName);
|
|
||||||
if (strlen(dirExt) > 0) //the directory has an extension
|
|
||||||
{
|
|
||||||
strcat(dirWhole, ".");
|
|
||||||
strcat(dirWhole, dirExt);
|
|
||||||
}
|
|
||||||
if (strcmp(dirWhole, fileName)) //the entry found is a match
|
|
||||||
{
|
|
||||||
*destination = subDirectory[a];
|
|
||||||
retVal = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free(subDirectory);
|
|
||||||
if (iMadeClusterChain)
|
|
||||||
{
|
|
||||||
free(clusterChain);
|
|
||||||
clusterChain = 0;
|
|
||||||
}
|
|
||||||
return retVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
dword fat12_getDirectoryHandle(char *directory, DiskDevice *dd, Fat12Entry *currDir, Fat12Entry *destination)
|
|
||||||
{
|
|
||||||
if (!currDir) // we are working in the root directory
|
|
||||||
{
|
|
||||||
Fat12Entry *rootDir = malloc(14*512); //root directory is 14 sectors long
|
|
||||||
vfs_readSector(dd, 19, (byte *)rootDir, 14);
|
|
||||||
int a;
|
|
||||||
for (a = 0; a < 224; a++) //224 max root directory entries in 14 sectors
|
|
||||||
{
|
|
||||||
if (rootDir[a].fileName[0] == 0)
|
|
||||||
break;
|
|
||||||
if ((byte)rootDir[a].fileName[0] != 0xE5)
|
|
||||||
{
|
|
||||||
if ((rootDir[a].attributes & 0x18) == 0x10) //this entry is a directory
|
|
||||||
{
|
|
||||||
char dirName[9];
|
|
||||||
char dirExt[4];
|
|
||||||
memcpy(dirName, rootDir[a].fileName, 8);
|
|
||||||
dirName[8] = 0;
|
|
||||||
memcpy(dirExt, rootDir[a].ext, 3);
|
|
||||||
dirExt[3] = 0;
|
|
||||||
rtrim(dirName);
|
|
||||||
rtrim(dirExt);
|
|
||||||
char dirWhole[14];
|
|
||||||
strcpy(dirWhole, dirName);
|
|
||||||
if (strlen(dirExt) > 0) //the directory has an extension
|
|
||||||
{
|
|
||||||
strcat(dirWhole, ".");
|
|
||||||
strcat(dirWhole, dirExt);
|
|
||||||
}
|
|
||||||
if (strcmp(dirWhole, directory)) //the entry found is a match
|
|
||||||
{
|
|
||||||
free(rootDir);
|
|
||||||
*destination = rootDir[a];
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free(rootDir);
|
|
||||||
return 1; //no match found
|
|
||||||
}
|
|
||||||
dword retVal = 2;
|
|
||||||
dword iMadeClusterChain = getClusterChain(dd);
|
|
||||||
Fat12Entry *subDirectory = fat12_readClusterChain(dd, currDir);
|
|
||||||
if (!subDirectory)
|
|
||||||
return 5;
|
|
||||||
dword numberOfClusters = fat12_readClusterChainCount(dd, currDir);
|
|
||||||
int a;
|
|
||||||
for (a = 0; a < (numberOfClusters * 16); a++)
|
|
||||||
{
|
|
||||||
if (subDirectory[a].fileName[0] == 0)
|
|
||||||
break;
|
|
||||||
if ((byte)subDirectory[a].fileName[0] != 0xE5)
|
|
||||||
{
|
|
||||||
if ((subDirectory[a].attributes & 0x18) == 0x10) //this entry is a directory
|
|
||||||
{
|
|
||||||
char dirName[9];
|
|
||||||
char dirExt[4];
|
|
||||||
memcpy(dirName, subDirectory[a].fileName, 8);
|
|
||||||
dirName[8] = 0;
|
|
||||||
memcpy(dirExt, subDirectory[a].ext, 3);
|
|
||||||
dirExt[3] = 0;
|
|
||||||
rtrim(dirName);
|
|
||||||
rtrim(dirExt);
|
|
||||||
char dirWhole[14];
|
|
||||||
strcpy(dirWhole, dirName);
|
|
||||||
if (strlen(dirExt) > 0) //the directory has an extension
|
|
||||||
{
|
|
||||||
strcat(dirWhole, ".");
|
|
||||||
strcat(dirWhole, dirExt);
|
|
||||||
}
|
|
||||||
if (strcmp(dirWhole, directory)) //the entry found is a match
|
|
||||||
{
|
|
||||||
*destination = subDirectory[a];
|
|
||||||
retVal = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free(subDirectory);
|
|
||||||
if (iMadeClusterChain)
|
|
||||||
{
|
|
||||||
free(clusterChain);
|
|
||||||
clusterChain = 0;
|
|
||||||
}
|
|
||||||
return retVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Fat12Entry *fat12_readClusterChain(DiskDevice *dd, Fat12Entry *directory)
|
|
||||||
{
|
|
||||||
dword numberOfClusters = fat12_readClusterChainCount(dd, directory);
|
|
||||||
if (numberOfClusters == 0)
|
|
||||||
return 0;
|
|
||||||
byte *bp = malloc(numberOfClusters * 512);
|
|
||||||
Fat12Entry *retVal = (Fat12Entry *)bp;
|
|
||||||
dword cluster = directory->firstCluster;
|
|
||||||
while (cluster < 0xFF0)
|
|
||||||
{
|
|
||||||
vfs_readSector(dd, cluster + 31, bp, 1);
|
|
||||||
cluster = fat12_getNextCluster(cluster);
|
|
||||||
bp += 512;
|
|
||||||
}
|
|
||||||
return retVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
dword fat12_readClusterChainCount(DiskDevice *dd, Fat12Entry *directory)
|
|
||||||
{
|
|
||||||
dword numberOfClusters = 0;
|
|
||||||
dword cluster = directory->firstCluster;
|
|
||||||
if (cluster == 0)
|
|
||||||
return 0;
|
|
||||||
while (cluster < 0xFF0)
|
|
||||||
{
|
|
||||||
cluster = fat12_getNextCluster(cluster);
|
|
||||||
numberOfClusters++;
|
|
||||||
}
|
|
||||||
return numberOfClusters;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
dword fat12_getNextCluster(dword thisCluster)
|
|
||||||
{
|
|
||||||
dword nextCluster = *(word *)((dword)clusterChain + ((thisCluster * 3) >> 1));
|
|
||||||
if (thisCluster & 0x01) //this is an odd cluster
|
|
||||||
return nextCluster >> 4;
|
|
||||||
else //this is an even cluster
|
|
||||||
return nextCluster & 0x0FFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
dword fat12_getFileSize(char *fileName, DiskDevice *dd)
|
|
||||||
{
|
|
||||||
Fat12Entry fe;
|
|
||||||
if (fat12_getFileHandle(fileName, dd, &fe))
|
|
||||||
return 0xFFFFFFFF;
|
|
||||||
return fe.fileSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
dword getClusterChain(DiskDevice *dd)
|
|
||||||
{
|
|
||||||
if (!clusterChain)
|
|
||||||
{
|
|
||||||
clusterChain = malloc(9*512); //9 sectors for File Allocation Table (cluster chain)
|
|
||||||
vfs_readSector(dd, 1, clusterChain, 9); //sectors 1 through 9 contain the first FAT
|
|
||||||
return 1; //this call created the cluster chain
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return 0; //this call did not create the cluster chain
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
58
fat12.h
58
fat12.h
@ -1,58 +0,0 @@
|
|||||||
// fat12.h
|
|
||||||
// Author: Josh Holtrop
|
|
||||||
// Created: 01/04/04
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
char fileName[8];
|
|
||||||
char ext[3];
|
|
||||||
byte attributes;
|
|
||||||
dword createTime;
|
|
||||||
word createDate;
|
|
||||||
word accessDate;
|
|
||||||
word unused0;
|
|
||||||
word modifiedDate;
|
|
||||||
word modifiedTime;
|
|
||||||
word firstCluster;
|
|
||||||
dword fileSize;
|
|
||||||
} __attribute__((packed)) Fat12Entry;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
byte jump[3];
|
|
||||||
byte sysName[8];
|
|
||||||
word bytesPerSector;
|
|
||||||
byte sectorsPerCluster;
|
|
||||||
word reservedSectors;
|
|
||||||
byte FATcount;
|
|
||||||
word maxRootEntries;
|
|
||||||
word totalSectors1;
|
|
||||||
byte mediaDescriptor;
|
|
||||||
word sectorsPerFAT;
|
|
||||||
word sectorsPerTrack;
|
|
||||||
word headCount;
|
|
||||||
dword hiddenSectors;
|
|
||||||
dword totalSectors2;
|
|
||||||
byte driveNumber;
|
|
||||||
byte reserved1;
|
|
||||||
byte extBootSignature;
|
|
||||||
dword volumeSerial;
|
|
||||||
char volumeLabel[11];
|
|
||||||
char fileSystemID[8];
|
|
||||||
} __attribute__((packed)) Fat12BootSector;
|
|
||||||
|
|
||||||
|
|
||||||
byte *fat12_readFile(char *fileName, DiskDevice *dd);
|
|
||||||
dword fat12_getFileHandle(char *fileName, DiskDevice *dd, Fat12Entry *destination);
|
|
||||||
dword fat12_getDirectoryHandle(char *directory, DiskDevice *dd, Fat12Entry *currDir, Fat12Entry *destination);
|
|
||||||
Fat12Entry *fat12_readClusterChain(DiskDevice *dd, Fat12Entry *directory);
|
|
||||||
dword fat12_getFileHandleInDirectory(char *fileName, DiskDevice *dd, Fat12Entry *currDir, Fat12Entry *destination);
|
|
||||||
dword fat12_readClusterChainCount(DiskDevice *dd, Fat12Entry *directory);
|
|
||||||
dword fat12_getFileSize(char *fileName, DiskDevice *dd);
|
|
||||||
dword getClusterChain(DiskDevice *dd);
|
|
||||||
dword fat12_getNextCluster(dword thisCluster);
|
|
||||||
|
|
||||||
byte *clusterChain = 0;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
9
fdc.c
9
fdc.c
@ -1,9 +0,0 @@
|
|||||||
//fdc.c
|
|
||||||
//Author: Josh Holtrop
|
|
||||||
//Date: 10/30/03
|
|
||||||
|
|
||||||
|
|
||||||
inline void fdc_sendDOR(byte dor)
|
|
||||||
{
|
|
||||||
outportb(FDC_DOR, dor);
|
|
||||||
}
|
|
12
fdc.h
12
fdc.h
@ -1,12 +0,0 @@
|
|||||||
//fdc.h
|
|
||||||
//Author: Josh Holtrop
|
|
||||||
//Date: 10/30/03
|
|
||||||
|
|
||||||
|
|
||||||
#define FDC_DOR 0x3f2
|
|
||||||
#define FDC_MSR 0x3f4
|
|
||||||
|
|
||||||
|
|
||||||
inline void fdc_sendDOR(byte dor);
|
|
||||||
|
|
||||||
|
|
52
functions.h
52
functions.h
@ -1,52 +0,0 @@
|
|||||||
//functions.h
|
|
||||||
//05/07/03 Josh Holtrop
|
|
||||||
//for HOS
|
|
||||||
//Modified: 10/30/03
|
|
||||||
|
|
||||||
extern dword _code;
|
|
||||||
extern dword _bss;
|
|
||||||
extern dword _end;
|
|
||||||
|
|
||||||
inline void outportb(unsigned int port, unsigned char value);
|
|
||||||
inline void outportw(unsigned int port, unsigned int value);
|
|
||||||
inline byte inportb(unsigned short port);
|
|
||||||
inline void enable_ints();
|
|
||||||
inline void disable_ints();
|
|
||||||
inline void restart();
|
|
||||||
inline void halt();
|
|
||||||
void remap_pics(int pic1, int pic2);
|
|
||||||
inline void pic1_mask(byte mask);
|
|
||||||
inline void pic2_mask(byte mask);
|
|
||||||
inline void eoi();
|
|
||||||
inline void eoi2();
|
|
||||||
inline dword kernel_size();
|
|
||||||
inline void init_timer();
|
|
||||||
char *strcat(char *dest, char *src);
|
|
||||||
int string_split(char *str, char delim);
|
|
||||||
char *string_advance(char *str);
|
|
||||||
void rtrim(char *str);
|
|
||||||
char *ucase(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);
|
|
||||||
byte cmos_getfd0();
|
|
||||||
byte cmos_getfd1();
|
|
||||||
byte cmos_gethd0();
|
|
||||||
byte cmos_gethd1();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1 +0,0 @@
|
|||||||
gcc -S kernel.c -masm=intel -fno-builtin
|
|
@ -1 +0,0 @@
|
|||||||
partcopy -f0 0 168000 flop.img
|
|
55
k_defines.h
55
k_defines.h
@ -1,55 +0,0 @@
|
|||||||
//k_defines.h
|
|
||||||
//03/17/03 Josh Holtrop
|
|
||||||
//Modified: 10/30/03
|
|
||||||
|
|
||||||
#define PIC1 0x20
|
|
||||||
#define PIC2 0xA0
|
|
||||||
#define PIC1_COMMAND PIC1
|
|
||||||
#define PIC1_DATA (PIC1+1)
|
|
||||||
#define PIC2_COMMAND PIC2
|
|
||||||
#define PIC2_DATA (PIC2+1)
|
|
||||||
#define PIC_EOI 0x20
|
|
||||||
|
|
||||||
#define ICW1_ICW4 0x01 /* ICW4 (not) needed */
|
|
||||||
#define ICW1_SINGLE 0x02 /* Single (cascade) mode */
|
|
||||||
#define ICW1_INTERVAL4 0x04 /* Call address interval 4 (8) */
|
|
||||||
#define ICW1_LEVEL 0x08 /* Level triggered (edge) mode */
|
|
||||||
#define ICW1_INIT 0x10 /* Initialization - required! */
|
|
||||||
|
|
||||||
#define ICW4_8086 0x01 /* 8086/88 (MCS-80/85) mode */
|
|
||||||
#define ICW4_AUTO 0x02 /* Auto (normal) EOI */
|
|
||||||
#define ICW4_BUF_SLAVE 0x08 /* Buffered mode/slave */
|
|
||||||
#define ICW4_BUF_MASTER 0x0C /* Buffered mode/master */
|
|
||||||
#define ICW4_SFNM 0x10 /* Special fully nested (not) */
|
|
||||||
|
|
||||||
#define BLUE_TXT 0x01
|
|
||||||
#define RED_TXT 0x04
|
|
||||||
#define WHITE_TXT 0x07
|
|
||||||
#define CYAN_TXT 0x0B
|
|
||||||
#define YELLOW_TXT 0x0E
|
|
||||||
#define BRWHITE_TXT 0x0F
|
|
||||||
|
|
||||||
#define FREERAM_START 0x368000 // 0x368000 is first available byte (this is right after the initrd @ 2mb, 1440kb.
|
|
||||||
#define MAX_RAM 0x40000000 //1gb maximum RAM supported
|
|
||||||
|
|
||||||
#define PID_KERNEL 0x02 //kernel's PID
|
|
||||||
#define PID_VMM 0x03
|
|
||||||
#define PID_USER 0x10000 //user processes' start PID
|
|
||||||
|
|
||||||
typedef unsigned char byte;
|
|
||||||
typedef unsigned short word;
|
|
||||||
typedef unsigned int dword;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
dword lowdword;
|
|
||||||
dword highdword;
|
|
||||||
} __attribute__((packed)) qword;
|
|
||||||
|
|
||||||
|
|
||||||
//these defines are the memory locations of values saved by the stage 2 bootloader
|
|
||||||
#define BOOT_MEMMAP_ENTRIES 0xC009040A
|
|
||||||
#define BOOT_FIRST_MEMMAP 0xC0092000
|
|
||||||
#define BOOT_VIDEO_MODE 0xC0090002
|
|
||||||
#define BOOT_VIDEO_MODE_INFO_BLOCK 0xC0090306
|
|
||||||
|
|
||||||
|
|
1
link.bat
1
link.bat
@ -1 +0,0 @@
|
|||||||
ld -nodefaultlibs -nostdlib -T link.ld -o kernel.bin -Map .\lst\LDout.doc ks.o kernel.o asmfuncs.o
|
|
17
mouse.h
17
mouse.h
@ -1,17 +0,0 @@
|
|||||||
// mouse.h
|
|
||||||
// 10/03/03
|
|
||||||
// Author: Josh Holtrop
|
|
||||||
|
|
||||||
|
|
||||||
int mouse_x;
|
|
||||||
int mouse_y;
|
|
||||||
int mouse_bytesRead = 0;
|
|
||||||
byte mouse_inbuffer[16];
|
|
||||||
|
|
||||||
void mouse_init();
|
|
||||||
void isr_mouse();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
14
rd.c
14
rd.c
@ -1,14 +0,0 @@
|
|||||||
// rd.c
|
|
||||||
// Author: Josh Holtrop
|
|
||||||
// Created: 12/31/03
|
|
||||||
// Modified: 01/04/04
|
|
||||||
|
|
||||||
|
|
||||||
byte *rd_readSector(DiskDevice *rd, dword sector, byte *dest)
|
|
||||||
{
|
|
||||||
memcpy(dest, (void *)(rd->location + (sector * 512)), 512);
|
|
||||||
return dest;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
9
rd.h
9
rd.h
@ -1,9 +0,0 @@
|
|||||||
// rd.h
|
|
||||||
// Author: Josh Holtrop
|
|
||||||
// Created: 12/31/03
|
|
||||||
// Modified: 01/04/04
|
|
||||||
|
|
||||||
|
|
||||||
byte *rd_readSector(DiskDevice *rd, dword sector, byte *dest);
|
|
||||||
|
|
||||||
|
|
192
src/Makefile
Normal file
192
src/Makefile
Normal file
@ -0,0 +1,192 @@
|
|||||||
|
#####################################################################
|
||||||
|
# Author: Benjamen R. Meyer #
|
||||||
|
# Date: 2004-2-15 #
|
||||||
|
# Purpose: To build Josh Holtrop's OS (HOS) using GNU make #
|
||||||
|
# Note: This makefile is for use on Linux & other Unix-like systems #
|
||||||
|
#####################################################################
|
||||||
|
|
||||||
|
##############
|
||||||
|
# Variables: #
|
||||||
|
##############
|
||||||
|
|
||||||
|
# Format of kernel binary:
|
||||||
|
# Do not change unless you know what you are doing
|
||||||
|
# Original:
|
||||||
|
KERNEL_FORMAT=aout
|
||||||
|
# CygWin: ??
|
||||||
|
#KERNEL_FORMAT=
|
||||||
|
|
||||||
|
# Assembler information:
|
||||||
|
NASM_BIN=nasm
|
||||||
|
NASM_FLAGS_IPL=-f bin
|
||||||
|
NASM_FLAGS_KERNEL=-f $(KERNEL_FORMAT)
|
||||||
|
|
||||||
|
# C Compile Information:
|
||||||
|
CC=gcc
|
||||||
|
CC_FLAGS=-ffreestanding -fno-builtin -nostdlib -nodefaultlibs -I.
|
||||||
|
|
||||||
|
# Linker Information:
|
||||||
|
LD=ld
|
||||||
|
LD_FLAGS=-nodefaultlibs -nostdlib -T link.ld
|
||||||
|
|
||||||
|
# Information for creating a floppy image
|
||||||
|
# Note: FLOPPY_FS and FLOPPY_FAT_SIZE are related fields.
|
||||||
|
# FLOPPY_FAT_SIZE should be either 12 or 16,
|
||||||
|
# depending on if FLOPPY_FS is FAT12 or FAT16, respectively.
|
||||||
|
MKDOSFS_PROG=/sbin/mkdosfs
|
||||||
|
FLOPPY_IMAGE=floppy.img
|
||||||
|
FLOPPY_BLOCK_COUNT=1440
|
||||||
|
FLOPPY_FS=FAT12
|
||||||
|
FLOPPY_FAT_SIZE=12
|
||||||
|
FLOPPY_MOUNT=./floppy_image
|
||||||
|
|
||||||
|
# Floppy images are good for programs like VMware and Bochs Pentium Emulator. ;-)
|
||||||
|
|
||||||
|
# Program for copying
|
||||||
|
COPY_BIN=cp
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# Build the IPL (Boot Loader) and Kernel #
|
||||||
|
##########################################
|
||||||
|
all: Boot Link_Kernel
|
||||||
|
# A word of warning to users :-> And a little helpful information ;-)
|
||||||
|
@echo "Installation must be done as root."
|
||||||
|
@echo "Type 'make install' to install to a floppy in drive '/dev/fd0'"
|
||||||
|
@echo "Type 'make install_img' to create a floppy image and install to it."
|
||||||
|
|
||||||
|
#################################################
|
||||||
|
# Clean up the source directory of any binaries #
|
||||||
|
#################################################
|
||||||
|
clean:
|
||||||
|
- rm *.o ./lst/*.lst *.bin $(FLOPPY_IMAGE)
|
||||||
|
|
||||||
|
#################
|
||||||
|
# Build the IPL #
|
||||||
|
#################
|
||||||
|
Boot:
|
||||||
|
boot/make
|
||||||
|
|
||||||
|
###############################
|
||||||
|
# Linking the kernel together #
|
||||||
|
###############################
|
||||||
|
Link_Kernel: Asm_Kernel Asm_Functions FAT_12 FDC Functions Keyboard KIO MM Mouse RD STDFONT VFS Video VMM C_Kernel
|
||||||
|
$(LD) $(LD_FLAGS) -o kernel.bin -Map ./lst/LDout.doc ks.o fat12.o fdc.o functions.o kernel.o keyboard.o kio.o mm.o mouse.o rd.o stdfont.o vfs.o video.o vmm.o asmfuncs.o
|
||||||
|
|
||||||
|
##########################
|
||||||
|
# Assembly Kernel Loader #
|
||||||
|
##########################
|
||||||
|
Asm_Kernel: kernel.asm
|
||||||
|
$(NASM_BIN) $(NASM_FLAGS_KERNEL) -o ks.o -l ./lst/kernel.lst kernel.asm
|
||||||
|
|
||||||
|
#################################
|
||||||
|
# Assembly Functions for Kernel #
|
||||||
|
#################################
|
||||||
|
Asm_Functions: asmfuncs.asm
|
||||||
|
$(NASM_BIN) $(NASM_FLAGS_KERNEL) -o asmfuncs.o -l ./lst/asmfuncs.lst asmfuncs.asm
|
||||||
|
|
||||||
|
############
|
||||||
|
# C Kernel #
|
||||||
|
############
|
||||||
|
FAT_12: fat12.c fat12.h k_defines.h vfs.h
|
||||||
|
$(CC) $(CC_FLAGS) -c fat12.c -o fat12.o
|
||||||
|
|
||||||
|
FDC: fdc.c fdc.h k_defines.h
|
||||||
|
$(CC) $(CC_FLAGS) -c fdc.c -o fdc.o
|
||||||
|
|
||||||
|
Functions: functions.c functions.h k_defines.h
|
||||||
|
$(CC) $(CC_FLAGS) -c functions.c -o functions.o
|
||||||
|
|
||||||
|
Keyboard: keyboard.c keyboard.h k_defines.h
|
||||||
|
$(CC) $(CC_FLAGS) -c keyboard.c -o keyboard.o
|
||||||
|
|
||||||
|
KIO: kio.c kio.h k_defines.h video.h
|
||||||
|
$(CC) $(CC_FLAGS) -c kio.c -o kio.o
|
||||||
|
|
||||||
|
MM: mm.c mm.h k_defines.h
|
||||||
|
$(CC) $(CC_FLAGS) -c mm.c -o mm.o
|
||||||
|
|
||||||
|
Mouse: mouse.c mouse.h k_defines.h video.h
|
||||||
|
$(CC) $(CC_FLAGS) -c mouse.c -o mouse.o
|
||||||
|
|
||||||
|
RD: rd.c rd.h k_defines.h vfs.h
|
||||||
|
$(CC) $(CC_FLAGS) -c rd.c -o rd.o
|
||||||
|
|
||||||
|
STDFONT: stdfont.h stdfont.c
|
||||||
|
$(CC) $(CC_FLAGS) -c stdfont.c -o stdfont.o
|
||||||
|
|
||||||
|
VFS: vfs.c vfs.h k_defines.h
|
||||||
|
$(CC) $(CC_FLAGS) -c vfs.c -o vfs.o
|
||||||
|
|
||||||
|
Video: video.c video.h k_defines.h stdfont.h
|
||||||
|
$(CC) $(CC_FLAGS) -c video.c -o video.o
|
||||||
|
|
||||||
|
# Why does this rely on video.h???
|
||||||
|
VMM: vmm.c vmm.h k_defines.h video.h
|
||||||
|
$(CC) $(CC_FLAGS) -c vmm.c -o vmm.o
|
||||||
|
|
||||||
|
C_Kernel: kernel.c k_defines.h fat12.h fdc.h functions.h keyboard.h kio.h mm.h mouse.h rd.h vfs.h video.h vmm.h
|
||||||
|
$(CC) $(CC_FLAGS) -c kernel.c -o kernel.o
|
||||||
|
|
||||||
|
###########################################
|
||||||
|
# The following is for the floppy drive #
|
||||||
|
# Note: This must be done on *nix as root #
|
||||||
|
###########################################
|
||||||
|
|
||||||
|
##########################
|
||||||
|
# Make install to floppy #
|
||||||
|
##########################
|
||||||
|
install: Install_IPL File_Copy
|
||||||
|
|
||||||
|
|
||||||
|
############################################
|
||||||
|
# Write the Stage 1 IPL to the boot sector #
|
||||||
|
############################################
|
||||||
|
Install_IPL:
|
||||||
|
boot/make install
|
||||||
|
|
||||||
|
#################################
|
||||||
|
# Copy the files onto the drive #
|
||||||
|
#################################
|
||||||
|
File_Copy: kernel.bin
|
||||||
|
@echo -n "Copying kernel to the floppy: "
|
||||||
|
cp kernel.bin /dev/fd0
|
||||||
|
|
||||||
|
############################################
|
||||||
|
# The following is for the floppy image. #
|
||||||
|
# Note: This must be done on *nix as root. #
|
||||||
|
############################################
|
||||||
|
|
||||||
|
########################
|
||||||
|
# Make a floppy image: #
|
||||||
|
########################
|
||||||
|
floppy_image: image_IPL image_file_copy
|
||||||
|
|
||||||
|
######################################
|
||||||
|
# Create and Format the floppy image #
|
||||||
|
######################################
|
||||||
|
install_img: $(FLOPPY_IMAGE)
|
||||||
|
$(MKDOSFS_PROG) -C -F $(FLOPPY_FAT_SIZE) -r 112 $(FLOPPY_IMAGE) $(FLOPPY_BLOCK_COUNT)
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# Mount the floppy on a loop back device #
|
||||||
|
##########################################
|
||||||
|
floppy_mount:
|
||||||
|
@echo "Mounting a file as a drive..."
|
||||||
|
mount $(FLOPPY_IMAGE) $(FLOPPY_MOUNT) -o loop
|
||||||
|
|
||||||
|
############################################
|
||||||
|
# Write the Stage 1 IPL to the boot sector #
|
||||||
|
############################################
|
||||||
|
image_IPL: stage1.bin floppy_format
|
||||||
|
@echo "Writing boot sector to image..."
|
||||||
|
dd if=stage1.bin of=$(FLOPPY_MOUNT) seek=0
|
||||||
|
|
||||||
|
#################################
|
||||||
|
# Copy the files onto the image #
|
||||||
|
#################################
|
||||||
|
image_file_copy: stage2.bin kernel.bin
|
||||||
|
@echo -n "Copying files onto it: "
|
||||||
|
@echo -n "IPL Stage 2 "
|
||||||
|
$(COPY_BIN) stage2.bin $(FLOPPY_MOUNT)
|
||||||
|
@echo ", HOS Kernel"
|
||||||
|
$(COPY_BIN) kernel.bin $(FLOPPY_MOUNT)
|
30
src/boot/Makefile
Normal file
30
src/boot/Makefile
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
########################
|
||||||
|
# Author: Josh Holtrop #
|
||||||
|
# Date: 2004-2-15 #
|
||||||
|
########################
|
||||||
|
|
||||||
|
# Assembler information:
|
||||||
|
NASM_BIN=nasm
|
||||||
|
|
||||||
|
#################
|
||||||
|
# Build the IPL #
|
||||||
|
#################
|
||||||
|
all: stage1 stage2
|
||||||
|
|
||||||
|
################
|
||||||
|
# IPL: Stage 1 #
|
||||||
|
################
|
||||||
|
stage1: stage1.asm
|
||||||
|
$(NASM_BIN) stage1.asm -o stage1.bin
|
||||||
|
|
||||||
|
################
|
||||||
|
# IPL: Stage 2 #
|
||||||
|
################
|
||||||
|
stage2: stage2.asm
|
||||||
|
$(NASM_BIN) stage2.asm -o stage2.bin
|
||||||
|
|
||||||
|
#########
|
||||||
|
# Clean #
|
||||||
|
#########
|
||||||
|
clean:
|
||||||
|
rm *.bin
|
@ -1,7 +1,7 @@
|
|||||||
; asmfuncs.asm
|
; asmfuncs.asm
|
||||||
; Josh Holtrop
|
; Josh Holtrop
|
||||||
; Created: 10/23/03
|
; Created: 10/23/03
|
||||||
; Modified: 12/25/03
|
; Modified: 02/26/04
|
||||||
|
|
||||||
[extern _putc]
|
[extern _putc]
|
||||||
[extern _console_memory]
|
[extern _console_memory]
|
||||||
@ -137,27 +137,6 @@ _memcpy:
|
|||||||
pop ebp
|
pop ebp
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;copies memory of n dwords (n*4 bytes) from src to destination
|
|
||||||
;extern void memcpyd(dword dest, dword src, dword n);
|
|
||||||
[global _memcpyd]
|
|
||||||
_memcpyd:
|
|
||||||
push ebp
|
|
||||||
mov ebp, esp
|
|
||||||
push esi
|
|
||||||
push edi
|
|
||||||
push ecx
|
|
||||||
mov edi, [ebp+8]
|
|
||||||
mov esi, [ebp+12]
|
|
||||||
mov ecx, [ebp+16]
|
|
||||||
|
|
||||||
rep movsd
|
|
||||||
|
|
||||||
pop ecx
|
|
||||||
pop edi
|
|
||||||
pop esi
|
|
||||||
pop ebp
|
|
||||||
ret
|
|
||||||
|
|
||||||
;returns the number of characters in a string
|
;returns the number of characters in a string
|
||||||
;extern dword strlen(char *str);
|
;extern dword strlen(char *str);
|
||||||
[global _strlen]
|
[global _strlen]
|
26
src/kernel/asmfuncs.h
Normal file
26
src/kernel/asmfuncs.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// asmfuncs.h
|
||||||
|
// Author: Josh Holtrop
|
||||||
|
// Created: 02/26/04
|
||||||
|
|
||||||
|
#ifndef __HOS_ASMFUNCS__
|
||||||
|
#define __HOS_ASMFUNCS__ __HOS_ASMFUNCS__
|
||||||
|
|
||||||
|
dword write_cr0(dword cr0);
|
||||||
|
dword read_cr0();
|
||||||
|
dword write_cr3(dword cr3);
|
||||||
|
dword read_cr2();
|
||||||
|
dword read_cr3();
|
||||||
|
void writeCursorPosition(dword pos);
|
||||||
|
dword getCursorPosition();
|
||||||
|
void console_scroll();
|
||||||
|
void console_cls();
|
||||||
|
int puts(char *str);
|
||||||
|
int putDec(int number);
|
||||||
|
int putDecu(dword number);
|
||||||
|
void strcpy(char *dest, char *src);
|
||||||
|
void memcpy(void *dest, void *src, dword n);
|
||||||
|
dword strlen(char *str);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
9
src/kernel/block/fdc.c
Normal file
9
src/kernel/block/fdc.c
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
//fdc.c
|
||||||
|
//Author: Josh Holtrop
|
||||||
|
//Created: 10/30/03
|
||||||
|
//Modified: 02/26/04
|
||||||
|
|
||||||
|
#include "fdc.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
21
src/kernel/block/fdc.h
Normal file
21
src/kernel/block/fdc.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
//fdc.h
|
||||||
|
//Author: Josh Holtrop
|
||||||
|
//Date: 10/30/03
|
||||||
|
//Modified: 02/26/04
|
||||||
|
|
||||||
|
#ifndef __HOS_FDC__
|
||||||
|
#define __HOS_FDC__ __HOS_FDC__
|
||||||
|
|
||||||
|
#define FDC_DOR 0x3f2
|
||||||
|
#define FDC_MSR 0x3f4
|
||||||
|
|
||||||
|
inline void fdc_sendDOR(byte dor);
|
||||||
|
|
||||||
|
inline void fdc_sendDOR(byte dor)
|
||||||
|
{
|
||||||
|
outportb(FDC_DOR, dor);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
@ -1,254 +1,246 @@
|
|||||||
//Keyboard.c
|
// keyboard.c
|
||||||
// Created: 04/17/03 Josh Holtrop
|
// Author: Josh Holtrop
|
||||||
// Modified: 10/30/03
|
// Created: 04/17/03
|
||||||
//for HOS
|
// Modified: 03/02/04
|
||||||
|
|
||||||
#define KBD_BUFFER_LENGTH 64
|
#include "hos_defines.h"
|
||||||
|
#include "keyboard.h"
|
||||||
byte kbdFlags = 0; //holds current keyboard flags - caps/num/scroll/shift/ctrl/alt
|
|
||||||
byte kbdAscii = 0; //holds ASCII value of a key pressed
|
#define KBD_BUFFER_LENGTH 64
|
||||||
byte kbdScan = 0; //holds the keyboard scan code of a key pressed
|
|
||||||
|
byte kbdFlags = 0; //holds current keyboard flags - caps/num/scroll/shift/ctrl/alt
|
||||||
dword kbdBuffer[KBD_BUFFER_LENGTH]; //a buffer for all keypresses
|
byte kbdAscii = 0; //holds ASCII value of a key pressed
|
||||||
int kbdBufferStart = 0; //position of next key in buffer
|
byte kbdScan = 0; //holds the keyboard scan code of a key pressed
|
||||||
int kbdBufferLen = 0; //number of keys left in the buffer
|
|
||||||
byte kbdExt = 0; //# of extended key codes left to input
|
dword kbdBuffer[KBD_BUFFER_LENGTH]; //a buffer for all keypresses
|
||||||
byte kbdExt2 = 0; //# of 2nd-set-extended key codes left to input
|
int kbdBufferStart = 0; //position of next key in buffer
|
||||||
byte ackReason = 0; //used to record the reason why we would get an acknowledge byte (0xFA)
|
int kbdBufferLen = 0; //number of keys left in the buffer
|
||||||
|
byte kbdExt = 0; //# of extended key codes left to input
|
||||||
|
byte kbdExt2 = 0; //# of 2nd-set-extended key codes left to input
|
||||||
//these arrays convert a keyboard scan code to an ASCII character value
|
byte ackReason = 0; //used to record the reason why we would get an acknowledge byte (0xFA)
|
||||||
//nul esc bksp tab lctl lsft rsft lalt caps F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 numScrlNumPad------- unknown---- F11 F12 unknown....
|
|
||||||
const byte SCAN2ASCII[128] = "\000\0331234567890-=\010\011qwertyuiop[]\n\001asdfghjkl;'`\001\\zxcvbnm,./\001*\001 \001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001-\001\001\001+\001\001\001\001\001\002\002\002\001\001\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002";
|
|
||||||
const byte SCAN2ASCIISHIFT[128] = "\000\033!@#$%^&*()_+\010\011QWERTYUIOP{}\n\001ASDFGHJKL:\"~\001|ZXCVBNM<>?\001*\001 \001\001\001\001\001\001\001\001\001\001\001\001\001789-456+1230.\002\002\002\001\001\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002";
|
//these arrays convert a keyboard scan code to an ASCII character value
|
||||||
|
//nul esc bksp tab lctl lsft rsft lalt caps F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 numScrlNumPad------- unknown---- F11 F12 unknown....
|
||||||
//====FUNCTIONS:
|
const byte SCAN2ASCII[128] = "\000\0331234567890-=\010\011qwertyuiop[]\n\001asdfghjkl;'`\001\\zxcvbnm,./\001*\001 \001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001-\001\001\001+\001\001\001\001\001\002\002\002\001\001\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002";
|
||||||
// The Keyboard Interrupt Service Routine
|
const byte SCAN2ASCIISHIFT[128] = "\000\033!@#$%^&*()_+\010\011QWERTYUIOP{}\n\001ASDFGHJKL:\"~\001|ZXCVBNM<>?\001*\001 \001\001\001\001\001\001\001\001\001\001\001\001\001789-456+1230.\002\002\002\001\001\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002";
|
||||||
void isr_keyboard()
|
|
||||||
{
|
//====FUNCTIONS:
|
||||||
kbdScan = inportb(0x60);
|
// The Keyboard Interrupt Service Routine
|
||||||
//printf("\nKEYBOARD INTERRUPT: 0x%x", kbdScan);
|
void isr_keyboard()
|
||||||
byte inState = inportb(0x61);
|
{
|
||||||
outportb(0x61, inState|0x80);
|
kbdScan = inportb(0x60);
|
||||||
outportb(0x61, inState);
|
//printf("\nKEYBOARD INTERRUPT: 0x%x", kbdScan);
|
||||||
|
byte inState = inportb(0x61);
|
||||||
//printf("IRQ 1: %x\n", kbdScan);
|
outportb(0x61, inState|0x80);
|
||||||
|
outportb(0x61, inState);
|
||||||
if (kbdScan == 0xFA) //250 //ACKnowledge
|
|
||||||
{
|
//printf("IRQ 1: %x\n", kbdScan);
|
||||||
//printf("KBD_ACK 0x%x!\n", ackReason);
|
|
||||||
if (ackReason == 0xED) //reset LEDs
|
if (kbdScan == 0xFA) //250 //ACKnowledge
|
||||||
{
|
{
|
||||||
outportb(0x60, (kbdFlags & 0x07));
|
//printf("KBD_ACK 0x%x!\n", ackReason);
|
||||||
}
|
if (ackReason == 0xED) //reset LEDs
|
||||||
ackReason = 0;
|
{
|
||||||
}
|
outportb(0x60, (kbdFlags & 0x07));
|
||||||
if (kbdScan == 224) //extended key
|
}
|
||||||
{
|
ackReason = 0;
|
||||||
kbdExt = 1;
|
}
|
||||||
eoi();
|
if (kbdScan == 224) //extended key
|
||||||
return;
|
{
|
||||||
}
|
kbdExt = 1;
|
||||||
if (kbdScan == 225) //2nd-set-extended key
|
eoi();
|
||||||
{
|
return;
|
||||||
kbdExt2 = 2;
|
}
|
||||||
eoi();
|
if (kbdScan == 225) //2nd-set-extended key
|
||||||
return;
|
{
|
||||||
}
|
kbdExt2 = 2;
|
||||||
|
eoi();
|
||||||
//====handle control keys::
|
return;
|
||||||
kbdAscii = 2;
|
}
|
||||||
switch (kbdScan) //control keys
|
|
||||||
{
|
//====handle control keys::
|
||||||
case KBD_SCAN_LSHIFT:
|
kbdAscii = 2;
|
||||||
kbdFlags |= KBD_SHIFT;
|
switch (kbdScan) //control keys
|
||||||
kbdAscii = 1;
|
{
|
||||||
break;
|
case KBD_SCAN_LSHIFT:
|
||||||
case KBD_SCAN_RSHIFT:
|
kbdFlags |= KBD_SHIFT;
|
||||||
kbdFlags |= KBD_SHIFT;
|
kbdAscii = 1;
|
||||||
kbdAscii = 1;
|
break;
|
||||||
break;
|
case KBD_SCAN_RSHIFT:
|
||||||
case KBD_SCAN_LCTRL:
|
kbdFlags |= KBD_SHIFT;
|
||||||
kbdFlags |= KBD_CTRL;
|
kbdAscii = 1;
|
||||||
kbdAscii = 1;
|
break;
|
||||||
break;
|
case KBD_SCAN_LCTRL:
|
||||||
case KBD_SCAN_LALT:
|
kbdFlags |= KBD_CTRL;
|
||||||
kbdFlags |= KBD_ALT;
|
kbdAscii = 1;
|
||||||
kbdAscii = 1;
|
break;
|
||||||
break;
|
case KBD_SCAN_LALT:
|
||||||
|
kbdFlags |= KBD_ALT;
|
||||||
case KBD_SCAN_LSHIFT + KBD_SCAN_RELEASED:
|
kbdAscii = 1;
|
||||||
kbdFlags &= (KBD_SHIFT ^ 0xFF);
|
break;
|
||||||
kbdAscii = 1;
|
|
||||||
break;
|
case KBD_SCAN_LSHIFT + KBD_SCAN_RELEASED:
|
||||||
case KBD_SCAN_RSHIFT + KBD_SCAN_RELEASED:
|
kbdFlags &= (KBD_SHIFT ^ 0xFF);
|
||||||
kbdFlags &= (KBD_SHIFT ^ 0xFF);
|
kbdAscii = 1;
|
||||||
kbdAscii = 1;
|
break;
|
||||||
break;
|
case KBD_SCAN_RSHIFT + KBD_SCAN_RELEASED:
|
||||||
case KBD_SCAN_LCTRL + KBD_SCAN_RELEASED:
|
kbdFlags &= (KBD_SHIFT ^ 0xFF);
|
||||||
kbdFlags &= (KBD_CTRL ^ 0xFF);
|
kbdAscii = 1;
|
||||||
kbdAscii = 1;
|
break;
|
||||||
break;
|
case KBD_SCAN_LCTRL + KBD_SCAN_RELEASED:
|
||||||
case KBD_SCAN_LALT + KBD_SCAN_RELEASED:
|
kbdFlags &= (KBD_CTRL ^ 0xFF);
|
||||||
kbdFlags &= (KBD_ALT ^ 0xFF);
|
kbdAscii = 1;
|
||||||
kbdAscii = 1;
|
break;
|
||||||
break;
|
case KBD_SCAN_LALT + KBD_SCAN_RELEASED:
|
||||||
|
kbdFlags &= (KBD_ALT ^ 0xFF);
|
||||||
case KBD_SCAN_CAPS+KBD_SCAN_RELEASED:
|
kbdAscii = 1;
|
||||||
kbdFlags ^= KBD_CAPS;
|
break;
|
||||||
kbdAscii = 1;
|
|
||||||
kbd_resetLEDs(); //update LEDs
|
case KBD_SCAN_CAPS+KBD_SCAN_RELEASED:
|
||||||
break;
|
kbdFlags ^= KBD_CAPS;
|
||||||
case KBD_SCAN_SCROLL+KBD_SCAN_RELEASED:
|
kbdAscii = 1;
|
||||||
kbdFlags ^= KBD_SCROLL;
|
kbd_resetLEDs(); //update LEDs
|
||||||
kbdAscii = 1;
|
break;
|
||||||
kbd_resetLEDs(); //update LEDs
|
case KBD_SCAN_SCROLL+KBD_SCAN_RELEASED:
|
||||||
break;
|
kbdFlags ^= KBD_SCROLL;
|
||||||
case KBD_SCAN_NUM+KBD_SCAN_RELEASED:
|
kbdAscii = 1;
|
||||||
kbdFlags ^= KBD_NUM;
|
kbd_resetLEDs(); //update LEDs
|
||||||
kbdAscii = 1;
|
break;
|
||||||
kbd_resetLEDs(); //update LEDs
|
case KBD_SCAN_NUM+KBD_SCAN_RELEASED:
|
||||||
break;
|
kbdFlags ^= KBD_NUM;
|
||||||
}
|
kbdAscii = 1;
|
||||||
if (kbdAscii == 1)
|
kbd_resetLEDs(); //update LEDs
|
||||||
{
|
break;
|
||||||
if (kbdExt > 0)
|
}
|
||||||
kbdExt--;
|
if (kbdAscii == 1)
|
||||||
eoi();
|
{
|
||||||
return;
|
if (kbdExt > 0)
|
||||||
}
|
kbdExt--;
|
||||||
//====determine ASCII value of key::
|
eoi();
|
||||||
if (kbdExt > 0) //extended key, kbdScan holds extended key
|
return;
|
||||||
{
|
}
|
||||||
kbdExt--;
|
//====determine ASCII value of key::
|
||||||
kbdAscii = 1;
|
if (kbdExt > 0) //extended key, kbdScan holds extended key
|
||||||
switch (kbdScan)
|
{
|
||||||
{
|
kbdExt--;
|
||||||
case KBD_SCANE_ENTER:
|
kbdAscii = 1;
|
||||||
kbdAscii = '\n'; break;
|
switch (kbdScan)
|
||||||
case 53: // '/' character (divide on numpad)
|
{
|
||||||
kbdAscii = '/'; break;
|
case KBD_SCANE_ENTER:
|
||||||
}
|
kbdAscii = '\n'; break;
|
||||||
}
|
case 53: // '/' character (divide on numpad)
|
||||||
else if (kbdExt2 > 0) //extended key 2
|
kbdAscii = '/'; break;
|
||||||
{
|
}
|
||||||
kbdExt2--;
|
}
|
||||||
// if (kbdScan == 69) // (pause|break)
|
else if (kbdExt2 > 0) //extended key 2
|
||||||
// kbdAscii = 2; //flag ascii value of 1 means control character (pausebreak)
|
{
|
||||||
// else
|
kbdExt2--;
|
||||||
kbdAscii = 2; //flag ascii value of 2 means ignore key (or unknown value)
|
// if (kbdScan == 69) // (pause|break)
|
||||||
}
|
// kbdAscii = 2; //flag ascii value of 1 means control character (pausebreak)
|
||||||
else //not an extended key
|
// else
|
||||||
{
|
kbdAscii = 2; //flag ascii value of 2 means ignore key (or unknown value)
|
||||||
// if letter key
|
}
|
||||||
if (((kbdScan >= 16) && (kbdScan <= 25)) || ((kbdScan >= 30) && (kbdScan <= 38)) || ((kbdScan >= 44) && (kbdScan <= 50)))
|
else //not an extended key
|
||||||
{
|
{
|
||||||
// if caps and shift are different (either one pressed, not both)
|
// if letter key
|
||||||
if (((kbdFlags & KBD_SHIFT) != 0) & ((kbdFlags & KBD_CAPS) != 0))
|
if (((kbdScan >= 16) && (kbdScan <= 25)) || ((kbdScan >= 30) && (kbdScan <= 38)) || ((kbdScan >= 44) && (kbdScan <= 50)))
|
||||||
kbdAscii = SCAN2ASCII[kbdScan & 0x7F];
|
{
|
||||||
else if (((kbdFlags & KBD_SHIFT) == 0) & ((kbdFlags & KBD_CAPS) == 0))
|
// if caps and shift are different (either one pressed, not both)
|
||||||
kbdAscii = SCAN2ASCII[kbdScan & 0x7F];
|
if (((kbdFlags & KBD_SHIFT) != 0) & ((kbdFlags & KBD_CAPS) != 0))
|
||||||
else
|
kbdAscii = SCAN2ASCII[kbdScan & 0x7F];
|
||||||
kbdAscii = SCAN2ASCIISHIFT[kbdScan & 0x7F];
|
else if (((kbdFlags & KBD_SHIFT) == 0) & ((kbdFlags & KBD_CAPS) == 0))
|
||||||
}
|
kbdAscii = SCAN2ASCII[kbdScan & 0x7F];
|
||||||
// if numpad key
|
else
|
||||||
else if ((kbdScan >= 71) && (kbdScan <= 83))
|
kbdAscii = SCAN2ASCIISHIFT[kbdScan & 0x7F];
|
||||||
{
|
}
|
||||||
// if numlock on
|
// if numpad key
|
||||||
if (kbdFlags & KBD_NUM)
|
else if ((kbdScan >= 71) && (kbdScan <= 83))
|
||||||
kbdAscii = SCAN2ASCIISHIFT[kbdScan & 0x7F];
|
{
|
||||||
else
|
// if numlock on
|
||||||
kbdAscii = SCAN2ASCII[kbdScan & 0x7F];
|
if (kbdFlags & KBD_NUM)
|
||||||
}
|
kbdAscii = SCAN2ASCIISHIFT[kbdScan & 0x7F];
|
||||||
// other key
|
else
|
||||||
else
|
kbdAscii = SCAN2ASCII[kbdScan & 0x7F];
|
||||||
{
|
}
|
||||||
if ((kbdFlags & KBD_SHIFT) != 0)
|
// other key
|
||||||
kbdAscii = SCAN2ASCIISHIFT[kbdScan & 0x7F];
|
else
|
||||||
else
|
{
|
||||||
kbdAscii = SCAN2ASCII[kbdScan & 0x7F];
|
if ((kbdFlags & KBD_SHIFT) != 0)
|
||||||
}
|
kbdAscii = SCAN2ASCIISHIFT[kbdScan & 0x7F];
|
||||||
}
|
else
|
||||||
|
kbdAscii = SCAN2ASCII[kbdScan & 0x7F];
|
||||||
//====do something with key::
|
}
|
||||||
// printf("kbdScan == %d\nkbdAscii == %d\nkbdFlags == %d\n", kbdScan, kbdAscii, kbdFlags);
|
}
|
||||||
if ((kbdScan == 83) && (kbdFlags & KBD_CTRL) && (kbdFlags & KBD_ALT))
|
|
||||||
{
|
//====do something with key::
|
||||||
printf("Initiating reboot.");
|
// printf("kbdScan == %d\nkbdAscii == %d\nkbdFlags == %d\n", kbdScan, kbdAscii, kbdFlags);
|
||||||
restart();
|
if ((kbdScan == 83) && (kbdFlags & KBD_CTRL) && (kbdFlags & KBD_ALT))
|
||||||
}
|
{
|
||||||
if (kbdAscii == 2) //unknown key / ignore key
|
printf("Initiating reboot.");
|
||||||
{
|
restart();
|
||||||
eoi();
|
}
|
||||||
return;
|
if (kbdAscii == 2) //unknown key / ignore key
|
||||||
}
|
{
|
||||||
if (kbdScan < KBD_SCAN_RELEASED) //a key was pressed, save it
|
eoi();
|
||||||
{
|
return;
|
||||||
if (kbdBufferLen >= KBD_BUFFER_LENGTH) //no key slots available
|
}
|
||||||
{
|
if (kbdScan < KBD_SCAN_RELEASED) //a key was pressed, save it
|
||||||
eoi();
|
{
|
||||||
return;
|
if (kbdBufferLen >= KBD_BUFFER_LENGTH) //no key slots available
|
||||||
}
|
{
|
||||||
else
|
eoi();
|
||||||
{
|
return;
|
||||||
kbdBuffer[(kbdBufferStart+kbdBufferLen++)%KBD_BUFFER_LENGTH] = (dword) ((kbdFlags << 16) | (kbdScan << 8) | kbdAscii);
|
}
|
||||||
// printf("S:%d\tL:%d\tR:%x\n", kbdBufferStart, kbdBufferLen, kbdBuffer[kbdBufferStart]);
|
else
|
||||||
}
|
{
|
||||||
}
|
kbdBuffer[(kbdBufferStart+kbdBufferLen++)%KBD_BUFFER_LENGTH] = (dword) ((kbdFlags << 16) | (kbdScan << 8) | kbdAscii);
|
||||||
|
// printf("S:%d\tL:%d\tR:%x\n", kbdBufferStart, kbdBufferLen, kbdBuffer[kbdBufferStart]);
|
||||||
eoi();
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
eoi();
|
||||||
//Switches the case of an ASCII character
|
|
||||||
/*inline byte (byte asciiCode)
|
}
|
||||||
{
|
|
||||||
if ((asciiCode >= 'A') & (asciiCode <= 'Z'))
|
//Gets a key from the buffer, returns 0 if no keys available, returns immediately
|
||||||
return (asciiCode + ('a' - 'A'));
|
dword kbdGetKey()
|
||||||
if ((asciiCode >= 'a') & (asciiCode <= 'z'))
|
{
|
||||||
return (asciiCode - ('a' - 'A'));
|
if (kbdBufferLen == 0) //buffer empty
|
||||||
return asciiCode;
|
return 0;
|
||||||
}*/
|
dword retVal = kbdBuffer[kbdBufferStart];
|
||||||
|
kbdBufferStart++;
|
||||||
//Gets a key from the buffer, returns 0 if no keys available, returns immediately
|
kbdBufferLen--;
|
||||||
dword kbdGetKey()
|
if (kbdBufferStart >= KBD_BUFFER_LENGTH)
|
||||||
{
|
kbdBufferStart = 0;
|
||||||
if (kbdBufferLen == 0) //buffer empty
|
return retVal;
|
||||||
return 0;
|
}
|
||||||
dword retVal = kbdBuffer[kbdBufferStart];
|
|
||||||
kbdBufferStart++;
|
//Gets a key from the buffer, if no keys available, waits for one to be entered
|
||||||
kbdBufferLen--;
|
dword kbdWaitKey()
|
||||||
if (kbdBufferStart >= KBD_BUFFER_LENGTH)
|
{
|
||||||
kbdBufferStart = 0;
|
for (;;)
|
||||||
return retVal;
|
{
|
||||||
}
|
if (kbdBufferLen != 0) //buffer empty
|
||||||
|
break;
|
||||||
//Gets a key from the buffer, if no keys available, waits for one to be entered
|
}
|
||||||
dword kbdWaitKey()
|
dword retVal = kbdBuffer[kbdBufferStart];
|
||||||
{
|
kbdBufferStart++;
|
||||||
for (;;)
|
kbdBufferLen--;
|
||||||
{
|
if (kbdBufferStart >= KBD_BUFFER_LENGTH)
|
||||||
if (kbdBufferLen != 0) //buffer empty
|
kbdBufferStart = 0;
|
||||||
break;
|
return retVal;
|
||||||
}
|
}
|
||||||
dword retVal = kbdBuffer[kbdBufferStart];
|
|
||||||
kbdBufferStart++;
|
//Resets the keyboard LEDs to reflect the current state of the num lock, caps lock, and scroll lock bits
|
||||||
kbdBufferLen--;
|
void kbd_resetLEDs()
|
||||||
if (kbdBufferStart >= KBD_BUFFER_LENGTH)
|
{
|
||||||
kbdBufferStart = 0;
|
outportb(0x60, 0xED);
|
||||||
return retVal;
|
ackReason = 0xED;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Resets the keyboard LEDs to reflect the current state of the num lock, caps lock, and scroll lock bits
|
|
||||||
inline void kbd_resetLEDs()
|
|
||||||
{
|
|
||||||
outportb(0x60, 0xED);
|
|
||||||
//outportb(0x60, (kbdFlags & 0x07));
|
|
||||||
ackReason = 0xED;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,47 +1,50 @@
|
|||||||
//Keyboard.h
|
// keyboard.h
|
||||||
// Created: 04/17/03 Josh Holtrop
|
// Author: Josh Holtrop
|
||||||
// Modified: 05/07/03
|
// Created: 04/17/03
|
||||||
//for HOS
|
// Modified: 03/02/04
|
||||||
|
|
||||||
#define KBD_SCROLL 0x01
|
#include "hos_defines.h"
|
||||||
#define KBD_NUM 0x02
|
|
||||||
#define KBD_CAPS 0x04
|
#ifndef __HOS_KEYBOARD__
|
||||||
#define KBD_SHIFT 0x10
|
#define __HOS_KEYBOARD__ __HOS_KEYBOARD__
|
||||||
#define KBD_CTRL 0x20
|
|
||||||
#define KBD_ALT 0x40
|
#define KBD_SCROLL 0x01
|
||||||
|
#define KBD_NUM 0x02
|
||||||
#define KBD_SCAN_RELEASED 128
|
#define KBD_CAPS 0x04
|
||||||
|
#define KBD_SHIFT 0x10
|
||||||
#define KBD_SCAN_LCTRL 29
|
#define KBD_CTRL 0x20
|
||||||
#define KBD_SCAN_LSHIFT 42
|
#define KBD_ALT 0x40
|
||||||
#define KBD_SCAN_RSHIFT 54
|
|
||||||
#define KBD_SCAN_LALT 56
|
#define KBD_SCAN_RELEASED 128
|
||||||
#define KBD_SCAN_SCROLL 70
|
|
||||||
#define KBD_SCAN_CAPS 58
|
#define KBD_SCAN_LCTRL 29
|
||||||
#define KBD_SCAN_NUM 69
|
#define KBD_SCAN_LSHIFT 42
|
||||||
|
#define KBD_SCAN_RSHIFT 54
|
||||||
#define KBD_SCANE_PRINTSCREEN 55
|
#define KBD_SCAN_LALT 56
|
||||||
#define KBD_SCANE_INS 82
|
#define KBD_SCAN_SCROLL 70
|
||||||
#define KBD_SCANE_HOME 71
|
#define KBD_SCAN_CAPS 58
|
||||||
#define KBD_SCANE_PGUP 73
|
#define KBD_SCAN_NUM 69
|
||||||
#define KBD_SCANE_DEL 83
|
|
||||||
#define KBD_SCANE_END 79
|
#define KBD_SCANE_PRINTSCREEN 55
|
||||||
#define KBD_SCANE_PGDN 81
|
#define KBD_SCANE_INS 82
|
||||||
#define KBD_SCANE_ENTER 28
|
#define KBD_SCANE_HOME 71
|
||||||
|
#define KBD_SCANE_PGUP 73
|
||||||
#define KBD_SCANE_NULL 42
|
#define KBD_SCANE_DEL 83
|
||||||
|
#define KBD_SCANE_END 79
|
||||||
|
#define KBD_SCANE_PGDN 81
|
||||||
|
#define KBD_SCANE_ENTER 28
|
||||||
//====PROTOTYPES:
|
|
||||||
|
#define KBD_SCANE_NULL 42
|
||||||
void isr_keyboard();
|
|
||||||
inline void kbd_resetLEDs();
|
|
||||||
inline byte kbd_ascii(dword keycode);
|
|
||||||
inline byte kbd_scancode(dword keycode);
|
//====PROTOTYPES:
|
||||||
inline byte kbd_flags(dword keycode);
|
|
||||||
inline byte switchCase(byte asciiCode);
|
void isr_keyboard();
|
||||||
dword kbdGetKey();
|
void kbd_resetLEDs();
|
||||||
dword kbdWaitKey();
|
dword kbdGetKey();
|
||||||
|
dword kbdWaitKey();
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -1,60 +1,69 @@
|
|||||||
// mouse.c
|
// mouse.c
|
||||||
// 10/03/03
|
// 10/03/03
|
||||||
// Author: Josh Holtrop
|
// Author: Josh Holtrop
|
||||||
|
|
||||||
|
#include "mouse.h"
|
||||||
//This method initializes the ps/2 mouse
|
#include "hos_defines.h"
|
||||||
void mouse_init()
|
|
||||||
{
|
#define MOUSE_BUFFER_LENGTH 16
|
||||||
outportb(0x64, 0x20); //tell keyboard controller we are going to read keyboard controller command byte
|
|
||||||
byte temp = inportb(0x60); //read keyboard controller command byte
|
int mouse_x;
|
||||||
outportb(0x64, 0x60); //tell keyboard controller we are going to write keyboard controller command byte
|
int mouse_y;
|
||||||
outportb(0x60, 0x03 | (temp&0x40)); //write keyboard controller command byte: enable mouse/keyboard ints, include original XLATE bit from temp (bit6)
|
int mouse_bytesRead = 0;
|
||||||
|
byte mouse_inbuffer[MOUSE_BUFFER_LENGTH];
|
||||||
outportb(0x64, 0xA8); //enable mouse port
|
|
||||||
|
//This method initializes the ps/2 mouse
|
||||||
outportb(0x64, 0xD4); //send command to mouse, not kbd
|
void mouse_init()
|
||||||
outportb(0x60, 0xF4); //enable data reporting
|
{
|
||||||
|
outportb(0x64, 0x20); //tell keyboard controller we are going to read keyboard controller command byte
|
||||||
mouse_x = video_mode.XResolution >> 1;
|
byte temp = inportb(0x60); //read keyboard controller command byte
|
||||||
mouse_y = video_mode.YResolution >> 1;
|
outportb(0x64, 0x60); //tell keyboard controller we are going to write keyboard controller command byte
|
||||||
|
outportb(0x60, 0x03 | (temp&0x40)); //write keyboard controller command byte: enable mouse/keyboard ints, include original XLATE bit from temp (bit6)
|
||||||
//outportb(0x64, 0xD4);
|
|
||||||
//outportb(0x60, 0xE7); //scaling 2:1
|
outportb(0x64, 0xA8); //enable mouse port
|
||||||
}
|
|
||||||
|
outportb(0x64, 0xD4); //send command to mouse, not kbd
|
||||||
|
outportb(0x60, 0xF4); //enable data reporting
|
||||||
//This method is called when a mouse interrupt occurs
|
|
||||||
void isr_mouse()
|
mouse_x = video_mode.XResolution >> 1;
|
||||||
{
|
mouse_y = video_mode.YResolution >> 1;
|
||||||
byte inb = inportb(0x60); //read mouse byte
|
|
||||||
if ((inb == 0xFA) && (mouse_bytesRead < 1)) //ACK
|
//outportb(0x64, 0xD4);
|
||||||
return;
|
//outportb(0x60, 0xE7); //scaling 2:1
|
||||||
mouse_inbuffer[mouse_bytesRead] = inb;
|
}
|
||||||
mouse_bytesRead++;
|
|
||||||
if (mouse_bytesRead == 3) //complete packet received
|
|
||||||
{
|
//This method is called when a mouse interrupt occurs
|
||||||
mouse_bytesRead = 0;
|
void isr_mouse()
|
||||||
int adjx = (char) mouse_inbuffer[1];
|
{
|
||||||
int adjy = (char) mouse_inbuffer[2];
|
byte inb = inportb(0x60); //read mouse byte
|
||||||
mouse_x += adjx;
|
if ((inb == 0xFA) && (mouse_bytesRead < 1)) //ACK
|
||||||
mouse_y -= adjy; //-= because screen y coordinates are opposite mouse y coordinates
|
return;
|
||||||
if (mouse_x < 0)
|
mouse_inbuffer[mouse_bytesRead] = inb;
|
||||||
mouse_x = 0;
|
mouse_bytesRead++;
|
||||||
if (mouse_x >= video_mode.XResolution)
|
if (mouse_bytesRead == 3) //complete packet received
|
||||||
mouse_x = video_mode.XResolution - 1;
|
{
|
||||||
if (mouse_y < 0)
|
mouse_bytesRead = 0;
|
||||||
mouse_y = 0;
|
int adjx = (char) mouse_inbuffer[1];
|
||||||
if (mouse_y >= video_mode.YResolution)
|
int adjy = (char) mouse_inbuffer[2];
|
||||||
mouse_y = video_mode.YResolution - 1;
|
mouse_x += adjx;
|
||||||
if (mouse_inbuffer[0] & 0x01) //left button
|
mouse_y -= adjy; //-= because screen y coordinates are opposite mouse y coordinates
|
||||||
video_pset(mouse_x, mouse_y, 0x00FF8800);
|
if (mouse_x < 0)
|
||||||
else
|
mouse_x = 0;
|
||||||
video_pset(mouse_x, mouse_y, 0x00FFFFFF);
|
if (mouse_x >= video_mode.XResolution)
|
||||||
}
|
mouse_x = video_mode.XResolution - 1;
|
||||||
}
|
if (mouse_y < 0)
|
||||||
|
mouse_y = 0;
|
||||||
|
if (mouse_y >= video_mode.YResolution)
|
||||||
|
mouse_y = video_mode.YResolution - 1;
|
||||||
|
if (mouse_inbuffer[0] & 0x01) //left button
|
||||||
|
video_pset(mouse_x, mouse_y, 0x00FF8800);
|
||||||
|
else
|
||||||
|
video_pset(mouse_x, mouse_y, 0x00FFFFFF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
15
src/kernel/char/mouse.h
Normal file
15
src/kernel/char/mouse.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// mouse.h
|
||||||
|
// Author: Josh Holtrop
|
||||||
|
// Date: 10/03/03
|
||||||
|
// Modified: 03/02/04
|
||||||
|
|
||||||
|
#ifndef __HOS_MOUSE__
|
||||||
|
#define __HOS_MOUSE__ __HOS_MOUSE__
|
||||||
|
|
||||||
|
|
||||||
|
void mouse_init();
|
||||||
|
void isr_mouse();
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
8
src/kernel/functions.c
Normal file
8
src/kernel/functions.c
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
//Functions.c
|
||||||
|
//05/07/03 Josh Holtrop
|
||||||
|
//for HOS
|
||||||
|
//Modified: 02/26/04
|
||||||
|
|
||||||
|
#include "functions.h"
|
||||||
|
|
||||||
|
|
96
src/kernel/functions.h
Normal file
96
src/kernel/functions.h
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
//functions.h
|
||||||
|
//05/07/03 Josh Holtrop
|
||||||
|
//for HOS
|
||||||
|
//Modified: 02/26/04
|
||||||
|
|
||||||
|
#include "hos_defines.h"
|
||||||
|
|
||||||
|
#ifndef __HOS_FUNCTIONS__
|
||||||
|
#define __HOS_FUNCTIONS__ __HOS_FUNCTIONS__
|
||||||
|
|
||||||
|
extern dword _code;
|
||||||
|
extern dword _bss;
|
||||||
|
extern dword _end;
|
||||||
|
|
||||||
|
inline void enable_ints();
|
||||||
|
inline void disable_ints();
|
||||||
|
inline void restart();
|
||||||
|
inline void halt();
|
||||||
|
inline dword kernel_size();
|
||||||
|
inline void timer_init();
|
||||||
|
inline byte bcd2byte(byte bcd);
|
||||||
|
inline byte byte2bcd(byte bite);
|
||||||
|
|
||||||
|
//Enables (SeTs) Interrupt Flag on the processor
|
||||||
|
inline void enable_ints()
|
||||||
|
{
|
||||||
|
asm("sti");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Disables (CLears) Interrupt Flag on the processor
|
||||||
|
inline void disable_ints()
|
||||||
|
{
|
||||||
|
asm("cli");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Restarts the computer
|
||||||
|
inline void restart()
|
||||||
|
{
|
||||||
|
enable_ints();
|
||||||
|
byte temp;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
temp = inportb(0x64);
|
||||||
|
if (temp & 1)
|
||||||
|
inportb(0x60);
|
||||||
|
} while(temp & 2);
|
||||||
|
|
||||||
|
|
||||||
|
outportb (0x64, 0xfe);
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Halts (freezes) the computer
|
||||||
|
inline void halt()
|
||||||
|
{
|
||||||
|
asm("cli");
|
||||||
|
asm("hlt");
|
||||||
|
while (1)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Initializes 8253 Programmable Interrupt Timer
|
||||||
|
inline void timer_init()
|
||||||
|
{
|
||||||
|
//set timer : 2e9c = 100hz
|
||||||
|
outportb(0x43, 0x34);
|
||||||
|
outportb(0x40, 0x9c); //lsb
|
||||||
|
outportb(0x40, 0x2e); //msb
|
||||||
|
}
|
||||||
|
|
||||||
|
//Returns the size of the kernel (code & data)
|
||||||
|
// - this does not include the bss section
|
||||||
|
// - this should be 4kb aligned per the linker script
|
||||||
|
// - this should be the size of kernel.bin
|
||||||
|
inline dword kernel_size()
|
||||||
|
{
|
||||||
|
return (dword)(&_bss)-(dword)(&_code);
|
||||||
|
}
|
||||||
|
|
||||||
|
//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);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
@ -1,71 +1,71 @@
|
|||||||
;gdt.inc
|
;gdt.inc
|
||||||
;Author: Josh Holtrop
|
;Author: Josh Holtrop
|
||||||
;for HOS
|
;Date: 10/30/03
|
||||||
;Modified: 10/30/03
|
;Modified: 03/02/04
|
||||||
|
|
||||||
gdtr:
|
gdtr:
|
||||||
dw gdt_end-gdt-1
|
dw gdt_end-gdt-1
|
||||||
dd GDT_P
|
dd GDT_V
|
||||||
gdt:
|
gdt:
|
||||||
dd 0
|
dd 0
|
||||||
dd 0
|
dd 0
|
||||||
KERNEL_CODE equ $-gdt
|
KERNEL_CODE equ $-gdt
|
||||||
dw 0xffff ;limit 15:0
|
dw 0xffff ;limit 15:0
|
||||||
dw 0x0000 ;base 15:0
|
dw 0x0000 ;base 15:0
|
||||||
db 0x00 ;base 23:16
|
db 0x00 ;base 23:16
|
||||||
db 0x9A ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
|
db 0x9A ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
|
||||||
db 0xCF ;flags ([G][D/B][0][0]) / limit 19:16
|
db 0xCF ;flags ([G][D/B][0][0]) / limit 19:16
|
||||||
db 0x00 ;base 31:24
|
db 0x00 ;base 31:24
|
||||||
KERNEL_DATA equ $-gdt
|
KERNEL_DATA equ $-gdt
|
||||||
dw 0xffff ;limit 15:0
|
dw 0xffff ;limit 15:0
|
||||||
dw 0x0000 ;base 15:0
|
dw 0x0000 ;base 15:0
|
||||||
db 0x00 ;base 23:16
|
db 0x00 ;base 23:16
|
||||||
db 0x92 ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
|
db 0x92 ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
|
||||||
db 0xCF ;flags ([G][D/B][0][0]) / limit 19:16
|
db 0xCF ;flags ([G][D/B][0][0]) / limit 19:16
|
||||||
db 0x00 ;base 31:24
|
db 0x00 ;base 31:24
|
||||||
VESA_CODE equ $-gdt
|
USER_CODE equ $-gdt
|
||||||
dw 0xffff ;limit 15:0
|
dw 0xffff ;limit 15:0
|
||||||
dw 0x0000 ;base 15:0
|
dw 0x0000 ;base 15:0
|
||||||
db 0x00 ;base 23:16
|
db 0x00 ;base 23:16
|
||||||
db 0x9A ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
|
db 0xFA ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
|
||||||
db 0x40 ;flags ([G][D/B][0][0]) / limit 19:16
|
db 0xCF ;flags ([G][D/B][0][0]) / limit 19:16
|
||||||
db 0x00 ;base 31:24
|
db 0x00 ;base 31:24
|
||||||
VESA_DATA equ $-gdt
|
USER_DATA equ $-gdt
|
||||||
dw 0xffff ;limit 15:0
|
dw 0xffff ;limit 15:0
|
||||||
dw 0x0000 ;base 15:0
|
dw 0x0000 ;base 15:0
|
||||||
db 0x00 ;base 23:16
|
db 0x00 ;base 23:16
|
||||||
db 0x92 ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
|
db 0xF2 ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
|
||||||
db 0x40 ;flags ([G][D/B][0][0]) / limit 19:16
|
db 0xCF ;flags ([G][D/B][0][0]) / limit 19:16
|
||||||
db 0x00 ;base 31:24
|
db 0x00 ;base 31:24
|
||||||
VIDEO_TEXT equ $-gdt
|
gVESA_CODE equ $-gdt
|
||||||
dw 0x7FFF ;limit 15:0
|
dw 0xffff ;limit 15:0
|
||||||
dw 0x8000 ;base 15:0
|
dw 0x0000 ;base 15:0
|
||||||
db 0x0B ;base 23:16
|
db 0x00 ;base 23:16
|
||||||
db 0x92 ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
|
db 0x9A ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
|
||||||
db 0x40 ;flags ([G][D/B][0][0]) / limit 19:16
|
db 0x40 ;flags ([G][D/B][0][0]) / limit 19:16
|
||||||
db 0x00 ;base 31:24
|
db 0x00 ;base 31:24
|
||||||
VIDEO_GRAPHICS equ $-gdt
|
VESA_DATA equ $-gdt
|
||||||
dw 0xFFFF ;limit 15:0
|
dw 0xffff ;limit 15:0
|
||||||
dw 0x0000 ;base 15:0
|
dw 0x0000 ;base 15:0
|
||||||
db 0x0A ;base 23:16
|
db 0x00 ;base 23:16
|
||||||
db 0x92 ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
|
db 0x92 ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
|
||||||
db 0x40 ;flags ([G][D/B][0][0]) / limit 19:16
|
db 0x40 ;flags ([G][D/B][0][0]) / limit 19:16
|
||||||
db 0x00 ;base 31:24
|
db 0x00 ;base 31:24
|
||||||
USER_CODE equ $-gdt
|
VIDEO_TEXT equ $-gdt
|
||||||
dw 0xffff ;limit 15:0
|
dw 0x7FFF ;limit 15:0
|
||||||
dw 0x0000 ;base 15:0
|
dw 0x8000 ;base 15:0
|
||||||
db 0x00 ;base 23:16
|
db 0x0B ;base 23:16
|
||||||
db 0xFA ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
|
db 0x92 ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
|
||||||
db 0xCF ;flags ([G][D/B][0][0]) / limit 19:16
|
db 0x40 ;flags ([G][D/B][0][0]) / limit 19:16
|
||||||
db 0x00 ;base 31:24
|
db 0x00 ;base 31:24
|
||||||
USER_DATA equ $-gdt
|
VIDEO_GRAPHICS equ $-gdt
|
||||||
dw 0xffff ;limit 15:0
|
dw 0xFFFF ;limit 15:0
|
||||||
dw 0x0000 ;base 15:0
|
dw 0x0000 ;base 15:0
|
||||||
db 0x00 ;base 23:16
|
db 0x0A ;base 23:16
|
||||||
db 0xF2 ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
|
db 0x92 ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
|
||||||
db 0xCF ;flags ([G][D/B][0][0]) / limit 19:16
|
db 0x40 ;flags ([G][D/B][0][0]) / limit 19:16
|
||||||
db 0x00 ;base 31:24
|
db 0x00 ;base 31:24
|
||||||
gdt_end:
|
dt_end:
|
||||||
|
|
||||||
|
|
||||||
|
|
34
src/kernel/hos_defines.h
Normal file
34
src/kernel/hos_defines.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
//hos_defines.h
|
||||||
|
//03/17/03 Josh Holtrop
|
||||||
|
//Modified: 03/02/04
|
||||||
|
|
||||||
|
#ifndef __HOS_HOS_DEFINES__
|
||||||
|
#define __HOS_HOS_DEFINES__ __HOS_HOS_DEFINES__
|
||||||
|
|
||||||
|
#define FREERAM_START 0x368000 // 0x368000 is first available byte (this is right after the initrd @ 2mb, 1440kb.
|
||||||
|
#define MAX_RAM 0x40000000 //1gb maximum RAM supported
|
||||||
|
|
||||||
|
#define PID_KERNEL 0x02 //kernel's PID
|
||||||
|
#define PID_VMM 0x03
|
||||||
|
#define PID_USER 0x10000 //user processes' start PID
|
||||||
|
|
||||||
|
|
||||||
|
//these defines are the memory locations of values saved by the stage 2 bootloader
|
||||||
|
#define BOOT_MEMMAP_ENTRIES 0xC009040A
|
||||||
|
#define BOOT_FIRST_MEMMAP 0xC0092000
|
||||||
|
#define BOOT_VIDEO_MODE 0xC0090002
|
||||||
|
#define BOOT_VIDEO_MODE_INFO_BLOCK 0xC0090306
|
||||||
|
|
||||||
|
|
||||||
|
typedef unsigned char byte;
|
||||||
|
typedef unsigned short word;
|
||||||
|
typedef unsigned int dword;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
dword lowdword;
|
||||||
|
dword highdword;
|
||||||
|
} __attribute__((packed)) qword;
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -1,117 +1,117 @@
|
|||||||
;idt.inc
|
;idt.inc
|
||||||
;Author: Josh Holtrop
|
;Author: Josh Holtrop
|
||||||
;for HOS
|
;Date: 10/30/03
|
||||||
;Modified: 10/30/03
|
;Modified: 03/02/04
|
||||||
|
|
||||||
idtr:
|
idtr:
|
||||||
dw 50*8-1 ;size of idt
|
dw 50*8-1 ;size of idt
|
||||||
dd IDT_V ;address of idt
|
dd IDT_V ;address of idt
|
||||||
|
|
||||||
|
|
||||||
%macro isr_label 1
|
%macro isr_label 1
|
||||||
isr_%1:
|
isr_%1:
|
||||||
push eax
|
push eax
|
||||||
mov eax, %1
|
mov eax, %1
|
||||||
jmp isr_main
|
jmp isr_main
|
||||||
%endmacro
|
%endmacro
|
||||||
|
|
||||||
isr_label 0
|
isr_label 0
|
||||||
isr_label 1
|
isr_label 1
|
||||||
isr_label 2
|
isr_label 2
|
||||||
isr_label 3
|
isr_label 3
|
||||||
isr_label 4
|
isr_label 4
|
||||||
isr_label 5
|
isr_label 5
|
||||||
isr_label 6
|
isr_label 6
|
||||||
isr_label 7
|
isr_label 7
|
||||||
isr_label 8
|
isr_label 8
|
||||||
isr_label 9
|
isr_label 9
|
||||||
isr_label 10
|
isr_label 10
|
||||||
isr_label 11
|
isr_label 11
|
||||||
isr_label 12
|
isr_label 12
|
||||||
isr_label 13
|
isr_label 13
|
||||||
isr_label 14
|
isr_label 14
|
||||||
isr_label 15
|
isr_label 15
|
||||||
isr_label 16
|
isr_label 16
|
||||||
isr_label 17
|
isr_label 17
|
||||||
isr_label 18
|
isr_label 18
|
||||||
isr_label 19
|
isr_label 19
|
||||||
isr_label 20
|
isr_label 20
|
||||||
isr_label 21
|
isr_label 21
|
||||||
isr_label 22
|
isr_label 22
|
||||||
isr_label 23
|
isr_label 23
|
||||||
isr_label 24
|
isr_label 24
|
||||||
isr_label 25
|
isr_label 25
|
||||||
isr_label 26
|
isr_label 26
|
||||||
isr_label 27
|
isr_label 27
|
||||||
isr_label 28
|
isr_label 28
|
||||||
isr_label 29
|
isr_label 29
|
||||||
isr_label 30
|
isr_label 30
|
||||||
isr_label 31
|
isr_label 31
|
||||||
isr_label 32
|
isr_label 32
|
||||||
isr_label 33
|
isr_label 33
|
||||||
isr_label 34
|
isr_label 34
|
||||||
isr_label 35
|
isr_label 35
|
||||||
isr_label 36
|
isr_label 36
|
||||||
isr_label 37
|
isr_label 37
|
||||||
isr_label 38
|
isr_label 38
|
||||||
isr_label 39
|
isr_label 39
|
||||||
isr_label 40
|
isr_label 40
|
||||||
isr_label 41
|
isr_label 41
|
||||||
isr_label 42
|
isr_label 42
|
||||||
isr_label 43
|
isr_label 43
|
||||||
isr_label 44
|
isr_label 44
|
||||||
isr_label 45
|
isr_label 45
|
||||||
isr_label 46
|
isr_label 46
|
||||||
isr_label 47
|
isr_label 47
|
||||||
isr_label 48
|
isr_label 48
|
||||||
isr_label 49
|
isr_label 49
|
||||||
|
|
||||||
isr_main:
|
isr_main:
|
||||||
cmp eax, 0x30
|
cmp eax, 0x30
|
||||||
jz isr_syscall
|
jz isr_syscall
|
||||||
|
|
||||||
pusha
|
pusha
|
||||||
push ds
|
push ds
|
||||||
push es
|
push es
|
||||||
|
|
||||||
push eax
|
push eax
|
||||||
|
|
||||||
call _isr
|
call _isr
|
||||||
|
|
||||||
pop eax
|
add esp, 4
|
||||||
|
|
||||||
pop es
|
pop es
|
||||||
pop ds
|
pop ds
|
||||||
popa
|
popa
|
||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
iret
|
iret
|
||||||
|
|
||||||
|
|
||||||
isr_syscall:
|
isr_syscall:
|
||||||
pop eax ;syscall function number
|
pop eax ;syscall function number
|
||||||
pusha
|
pusha
|
||||||
push ds
|
push ds
|
||||||
push es
|
push es
|
||||||
|
|
||||||
sc1:
|
sc1:
|
||||||
cmp eax, 1 ;syscall 1 - putc
|
cmp eax, 1 ;syscall 1 - putc
|
||||||
jnz sc2
|
jnz sc2
|
||||||
push ebx
|
push ebx
|
||||||
call _putc
|
call _putc
|
||||||
add esp, 4
|
add esp, 4
|
||||||
jmp scdone
|
jmp scdone
|
||||||
sc2:
|
sc2:
|
||||||
|
|
||||||
scdone:
|
scdone:
|
||||||
pop es
|
pop es
|
||||||
pop ds
|
pop ds
|
||||||
popa
|
popa
|
||||||
iret
|
iret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,101 +1,102 @@
|
|||||||
;kernel.asm
|
;kernel.asm
|
||||||
;Author: Josh Holtrop
|
;Author: Josh Holtrop
|
||||||
;Modified: 10/30/03
|
;Date: 10/30/03
|
||||||
|
;Modified: 10/30/03
|
||||||
%define GDT_P 0x100000; ;1mb physical - Global Descriptor Table space
|
|
||||||
%define GDT_V GDT_P+0xC0000000
|
%define GDT_P 0x100000; ;1mb physical - Global Descriptor Table space
|
||||||
%define IDT_P 0x102000 ;1mb+8kb - Interrupt Descriptor Table space
|
%define GDT_V GDT_P+0xC0000000
|
||||||
%define IDT_V IDT_P+0xC0000000
|
%define IDT_P 0x102000 ;1mb+8kb - Interrupt Descriptor Table space
|
||||||
%define PDBR_P 0x104000 ;1mb+16kb - Page Directory Base Register (first PD)
|
%define IDT_V IDT_P+0xC0000000
|
||||||
%define PDBR_V PDBR_P+0xC0000000
|
%define PDBR_P 0x104000 ;1mb+16kb - Page Directory Base Register (first PD)
|
||||||
%define LOPT_P 0x105000 ;1mb+20kb - LOw Page Table for mapping first 4mb
|
%define PDBR_V PDBR_P+0xC0000000
|
||||||
%define LOPT_V LOPT_P+0xC0000000
|
%define LOPT_P 0x105000 ;1mb+20kb - LOw Page Table for mapping first 4mb
|
||||||
%define KERNEL_P 0x106000 ;1mb+24kb - the kernel's physical address
|
%define LOPT_V LOPT_P+0xC0000000
|
||||||
%define KERNEL_V KERNEL_P+0xC0000000 ;3gb+1mb+24kb, the virtual address of the kernel
|
%define KERNEL_P 0x106000 ;1mb+24kb - the kernel's physical address
|
||||||
|
%define KERNEL_V KERNEL_P+0xC0000000 ;3gb+1mb+24kb, the virtual address of the kernel
|
||||||
[global start]
|
|
||||||
[extern _isr]
|
[global start]
|
||||||
[extern _k_init]
|
[extern _isr]
|
||||||
[extern _putc]
|
[extern _k_init]
|
||||||
|
[extern _putc]
|
||||||
bits 32
|
|
||||||
|
bits 32
|
||||||
;This is where the kernel begins execution
|
|
||||||
;At this point, the temporary gdt is set up to "map" 0xC000_0000 to 0x0.
|
;This is where the kernel begins execution
|
||||||
;We must enable paging with the first 4mb mapped 1:1 virtual:physical
|
;At this point, the temporary gdt is set up to "map" 0xC000_0000 to 0x0.
|
||||||
; and with the 4mb starting at 0xC000_0000 mapped to the first 4mb physical.
|
;We must enable paging with the first 4mb mapped 1:1 virtual:physical
|
||||||
;Then we can start using our "real" gdt, then unmap the lower 4mb.
|
; and with the 4mb starting at 0xC000_0000 mapped to the first 4mb physical.
|
||||||
start:
|
;Then we can start using our "real" gdt, then unmap the lower 4mb.
|
||||||
cli ;if they weren't already off
|
start:
|
||||||
|
cli ;if they weren't already off
|
||||||
xor eax, eax
|
|
||||||
mov edi, PDBR_V
|
xor eax, eax
|
||||||
mov ecx, 1024 ;clear the PDBR
|
mov edi, PDBR_V
|
||||||
rep stosd
|
mov ecx, 1024 ;clear the PDBR
|
||||||
mov [PDBR_V], dword LOPT_P|0x03 ;store the physical address of the LOw Page Table (read/write, present)
|
rep stosd
|
||||||
mov [PDBR_V+0xC00], dword LOPT_P|0x03 ;store the physical address of the LOw Page Table (read/write, present)
|
mov [PDBR_V], dword LOPT_P|0x03 ;store the physical address of the LOw Page Table (read/write, present)
|
||||||
|
mov [PDBR_V+0xC00], dword LOPT_P|0x03 ;store the physical address of the LOw Page Table (read/write, present)
|
||||||
mov edi, LOPT_V
|
|
||||||
mov ecx, 1024
|
mov edi, LOPT_V
|
||||||
mov eax, 0x03 ;starting physical address = 0x0 (read/write, present flags)
|
mov ecx, 1024
|
||||||
fill_lopt_loop: ;fill the page table
|
mov eax, 0x03 ;starting physical address = 0x0 (read/write, present flags)
|
||||||
stosd
|
fill_lopt_loop: ;fill the page table
|
||||||
add eax, 4096 ;increment next phsyical address by 4kb
|
stosd
|
||||||
loop fill_lopt_loop
|
add eax, 4096 ;increment next phsyical address by 4kb
|
||||||
|
loop fill_lopt_loop
|
||||||
mov eax, PDBR_P
|
|
||||||
mov cr3, eax ;store the Page Directory Base Address
|
mov eax, PDBR_P
|
||||||
mov eax, cr0
|
mov cr3, eax ;store the Page Directory Base Address
|
||||||
or eax, 0x80000000 ;set page enable bit
|
mov eax, cr0
|
||||||
mov cr0, eax ;now paging is active!
|
or eax, 0x80000000 ;set page enable bit
|
||||||
|
mov cr0, eax ;now paging is active!
|
||||||
|
|
||||||
mov edi, GDT_V
|
|
||||||
mov esi, gdt
|
mov edi, GDT_V
|
||||||
mov ecx, gdt_end-gdt
|
mov esi, gdt
|
||||||
copy_gdt:
|
mov ecx, gdt_end-gdt
|
||||||
lodsb
|
copy_gdt:
|
||||||
stosb
|
lodsb
|
||||||
loop copy_gdt
|
stosb
|
||||||
|
loop copy_gdt
|
||||||
mov edi, IDT_V ;destination
|
|
||||||
mov esi, isr_0 ;address of isr0
|
mov edi, IDT_V ;destination
|
||||||
mov edx, isr_1-isr_0 ;distance between isr labels
|
mov esi, isr_0 ;address of isr0
|
||||||
mov ecx, 50 ;number of isrlabels
|
mov edx, isr_1-isr_0 ;distance between isr labels
|
||||||
fill_idt:
|
mov ecx, 50 ;number of isrlabels
|
||||||
mov ebx, esi
|
fill_idt:
|
||||||
mov ax, si
|
mov ebx, esi
|
||||||
stosw ;0 offset 15:0
|
mov ax, si
|
||||||
mov ax, KERNEL_CODE
|
stosw ;0 offset 15:0
|
||||||
stosw ;2 selector 15:0
|
mov ax, KERNEL_CODE
|
||||||
mov ax, 0x8E00
|
stosw ;2 selector 15:0
|
||||||
stosw ;4 [P][DPL][0][TYPE][0][0][0][0][0][0][0][0]
|
mov ax, 0x8E00
|
||||||
shr esi, 16
|
stosw ;4 [P][DPL][0][TYPE][0][0][0][0][0][0][0][0]
|
||||||
mov ax, si
|
shr esi, 16
|
||||||
stosw ;6 offset 31:16
|
mov ax, si
|
||||||
mov esi, ebx
|
stosw ;6 offset 31:16
|
||||||
add esi, edx
|
mov esi, ebx
|
||||||
loop fill_idt
|
add esi, edx
|
||||||
mov word [IDT_V+0x30*8+4], 0xEE00 ;interrupt 0x30 has user priviledges
|
loop fill_idt
|
||||||
|
mov word [IDT_V+0x30*8+4], 0xEE00 ;interrupt 0x30 has user priviledges
|
||||||
lgdt [gdtr] ;load gdt
|
|
||||||
jmp KERNEL_CODE:newgdtcontinue
|
lgdt [gdtr] ;load gdt
|
||||||
newgdtcontinue:
|
jmp KERNEL_CODE:newgdtcontinue
|
||||||
mov ax, KERNEL_DATA
|
newgdtcontinue:
|
||||||
mov es, ax
|
mov ax, KERNEL_DATA
|
||||||
mov ds, ax
|
mov es, ax
|
||||||
mov gs, ax
|
mov ds, ax
|
||||||
mov fs, ax
|
mov gs, ax
|
||||||
mov ss, ax
|
mov fs, ax
|
||||||
mov esp, 0xc01ffffc ;stack just under 3gb+2mb, moves downward
|
mov ss, ax
|
||||||
lidt [idtr] ;load idt
|
mov esp, 0xc0200000 ;stack just under 3gb+2mb, moves downward
|
||||||
|
lidt [idtr] ;load idt
|
||||||
call _k_init
|
|
||||||
haltit:
|
call _k_init
|
||||||
hlt ;halt processor when k_init is done
|
haltit:
|
||||||
jmp haltit ;shouldn't get here...
|
hlt ;halt processor when k_init is done
|
||||||
|
jmp haltit ;shouldn't get here...
|
||||||
%include "gdt.inc"
|
|
||||||
%include "idt.inc"
|
%include "gdt.inc"
|
||||||
|
%include "idt.inc"
|
||||||
|
|
||||||
|
|
@ -1,143 +1,101 @@
|
|||||||
//kernel.c
|
// kernel.c
|
||||||
//08/13/03 Josh Holtrop
|
// Author: Josh Holtrop
|
||||||
//Holtrop's Operating System
|
// Date: 08/13/03
|
||||||
//Version: 0.12
|
// Holtrop's Operating System - Version 0.13
|
||||||
//Modified: 12/30/03
|
// Modified: 03/02/04
|
||||||
|
|
||||||
#include "k_defines.h" //#DEFINE's for kernel
|
#include "hos_defines.h" //#DEFINE's for kernel
|
||||||
|
|
||||||
|
#include "functions.h" //general functions
|
||||||
#include "functions.h" //general functions
|
#include "asmfuncs.h" //assembly functions
|
||||||
#include "video.h" //video functions
|
#include "kio.h" //kernel input/output functions
|
||||||
#include "mm.h" //physical memory management functions
|
#include "mm/mm.h" //physical memory management functions
|
||||||
#include "vmm.h" //virtual memory management & paging functions
|
#include "mm/vmm.h" //virtual memory management & paging functions
|
||||||
#include "keyboard.h" //generic keyboard driver & functions
|
#include "char/keyboard.h" //generic keyboard driver & functions
|
||||||
#include "mouse.h" //generic ps/2 mouse driver & functions
|
#include "char/mouse.h" //generic ps/2 mouse driver & functions
|
||||||
#include "fdc.h" //Floppy Disk Controller functions
|
#include "block/fdc.h" //Floppy Disk Controller functions
|
||||||
#include "stdfont.h" //Standard font bitmask array
|
#include "string/string.h" //string functions
|
||||||
#include "kio.h"
|
#include "sys/cmos.h" //CMOS interface functions
|
||||||
#include "vfs.h"
|
#include "sys/io.h" //port i/o functions
|
||||||
#include "rd.h"
|
#include "sys/pic.h" //Programmable Interrupt Controller functions
|
||||||
#include "fat12.h"
|
#include "sys/rtc.h" //Real Time Clock functions
|
||||||
|
#include "video/stdfont.h" //Standard font bitmask array
|
||||||
void isr(dword num);
|
#include "video/video.h" //video functions
|
||||||
void k_init();
|
|
||||||
|
void isr(dword num);
|
||||||
/* These functions are defined in asmfuncs.asm */
|
void k_init();
|
||||||
extern dword write_cr0(dword cr0);
|
|
||||||
extern dword read_cr0();
|
dword timer = 0;
|
||||||
extern dword write_cr3(dword cr3);
|
|
||||||
extern dword read_cr2();
|
//Main kernel initialization method
|
||||||
extern dword read_cr3();
|
void k_init()
|
||||||
extern void writeCursorPosition(dword pos);
|
{
|
||||||
extern dword getCursorPosition();
|
// ===== Initialization
|
||||||
extern void console_scroll();
|
fdc_sendDOR(0x0C); //turn off floppy motor!!
|
||||||
extern void console_cls();
|
console_cls();
|
||||||
extern int puts(char *str);
|
video_init();
|
||||||
extern int putDec(int number);
|
mm_init();
|
||||||
extern int putDecu(dword number);
|
vmm_init();
|
||||||
extern void strcpy(char *dest, char *src);
|
remap_pics(0x20, 0x28);
|
||||||
extern void memcpy(void *dest, void *src, dword n);
|
init_timer();
|
||||||
extern dword strlen(char *str);
|
mouse_init();
|
||||||
|
pic1_mask(0); //unmask IRQ's 0-7
|
||||||
#include "fat12.c"
|
pic2_mask(0); //unmask IRQ's 8-15
|
||||||
#include "rd.c"
|
vfs_init();
|
||||||
#include "vfs.c"
|
enable_ints();
|
||||||
#include "kio.c"
|
kbd_resetLEDs(); //after enabling interrupts!!
|
||||||
#include "fdc.c"
|
if (videoMode)
|
||||||
#include "mouse.c"
|
{
|
||||||
#include "keyboard.c"
|
int p = video_mode.XResolution*video_mode.YResolution-1;
|
||||||
#include "mm.c"
|
for (; p >= 0; p--)
|
||||||
#include "vmm.c"
|
video_psetp(p, 0x00000077);
|
||||||
#include "functions.c"
|
video_drawConsole();
|
||||||
#include "video.c"
|
}
|
||||||
|
|
||||||
dword timer = 0;
|
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);
|
||||||
//Main kernel initialization method
|
printf("Free memory: %u bytes (%u pages)\n", mm_freemem(), mm_freemem()>>12);
|
||||||
void k_init()
|
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);
|
||||||
// ===== Initialization
|
|
||||||
fdc_sendDOR(0x0C); //turn off floppy motor!!
|
dword key = 0;
|
||||||
console_cls();
|
for (;;)
|
||||||
video_init();
|
{
|
||||||
mm_init();
|
key = kbdWaitKey();
|
||||||
vmm_init();
|
if ((key & 0xFF) > 2) //key is not a control key
|
||||||
remap_pics(0x20, 0x28);
|
putc(key);
|
||||||
init_timer();
|
}
|
||||||
mouse_init();
|
}
|
||||||
pic1_mask(0); //unmask IRQ's 0-7
|
|
||||||
pic2_mask(0); //unmask IRQ's 8-15
|
// main Interrupt Service Routine - handles all interrupts unless caught by kernel.asm
|
||||||
vfs_init();
|
void isr(dword num)
|
||||||
enable_ints();
|
{
|
||||||
kbd_resetLEDs(); //after enabling interrupts!!
|
switch(num)
|
||||||
if (videoMode)
|
{
|
||||||
{
|
case 14:
|
||||||
int p = video_mode.XResolution*video_mode.YResolution-1;
|
printf("Page fault, CR2 = 0x%x\n", read_cr2());
|
||||||
for (; p >= 0; p--)
|
halt();
|
||||||
video_psetp(p, 0x00000077);
|
break;
|
||||||
video_drawConsole();
|
case 0x20: // IRQ0 - timer interrupt
|
||||||
}
|
timer++;
|
||||||
|
(*(byte *)(0xc00b8000))++;
|
||||||
printf("HOS 0.13 - Kernel File Size: %u kb\tData Size: %u bytes\n", kernel_size()>>10, (dword)(&_end)-(dword)(&_code));
|
eoi();
|
||||||
printf("Memory available to OS: %u MB (%u bytes)\n", mm_megabytes, mm_totalmem);
|
break;
|
||||||
printf("Free memory: %u bytes (%u pages)\n", mm_freemem(), mm_freemem()>>12);
|
case 0x21: // IRQ1 - keyboard interrupt
|
||||||
printf("%d/%d/%d\t%d:%d:%d\n", rtc_readMonth(), rtc_readDay(), rtc_readYear(), rtc_readHour(), rtc_readMinute(), rtc_readSecond());
|
isr_keyboard(); //isr_keybard() takes care of calling eoi()
|
||||||
printf("Root Directory: %s/\n", rootDevice->id);
|
break;
|
||||||
|
case 0x2C: // IRQ12 - PS/2 mouse
|
||||||
/* int a;
|
isr_mouse();
|
||||||
byte *addr = 0;
|
eoi2();
|
||||||
for (a = 0; a < 5; a++)
|
break;
|
||||||
{
|
default:
|
||||||
byte *app = mm_palloc();
|
printf("Interrupt %d (0x%x) Unhandled!!\n", num, num);
|
||||||
vmm_map1((dword)addr, (dword)app);
|
halt();
|
||||||
addr += 4096;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
addr = vfs_readFile("/bin/hash.hos");
|
|
||||||
memcpy(0, addr, 4192);
|
|
||||||
asm("call 0");
|
|
||||||
free(addr);
|
|
||||||
*/
|
|
||||||
|
|
||||||
dword key = 0;
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
key = kbdWaitKey();
|
|
||||||
if ((key & 0xFF) > 2) //key is not a control key
|
|
||||||
putc(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// main Interrupt Service Routine - handles all interrupts unless caught by kernel.asm
|
|
||||||
void isr(dword num)
|
|
||||||
{
|
|
||||||
switch(num)
|
|
||||||
{
|
|
||||||
case 14:
|
|
||||||
printf("Page fault, CR2 = 0x%x\n", read_cr2());
|
|
||||||
halt();
|
|
||||||
break;
|
|
||||||
case 0x20: // IRQ0 - timer interrupt
|
|
||||||
timer++;
|
|
||||||
(*(byte *)(0xc00b8000))++;
|
|
||||||
eoi();
|
|
||||||
break;
|
|
||||||
case 0x21: // IRQ1 - keyboard interrupt
|
|
||||||
isr_keyboard(); //isr_keybard() takes care of calling eoi()
|
|
||||||
break;
|
|
||||||
case 0x2C: // IRQ12 - PS/2 mouse
|
|
||||||
isr_mouse();
|
|
||||||
eoi2();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
printf("Interrupt %d (0x%x) Unhandled!!\n", num, num);
|
|
||||||
halt();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,133 +1,136 @@
|
|||||||
|
// kio.c
|
||||||
//kio.c
|
// Author: Josh Holtrop
|
||||||
// Author: Josh Holtrop
|
// Created: 12/25/03
|
||||||
// Created: 12/25/03
|
// Modified: 03/02/04
|
||||||
// Modified: 12/25/03
|
|
||||||
|
#include "hos_defines.h"
|
||||||
|
#include "kio.h"
|
||||||
// This is the main output routine, it uses a format string and a variable
|
|
||||||
// number of arguments to print formatted text
|
dword cursorPosition = 0; //Caches the current cursor position
|
||||||
void printf(char *fmt, ...)
|
|
||||||
{
|
// This is the main output routine, it uses a format string and a variable
|
||||||
dword *params = ((dword *)(&fmt)) + 1; //points to the first paramater
|
// number of arguments to print formatted text
|
||||||
int i;
|
void printf(char *fmt, ...)
|
||||||
int special = 0;
|
{
|
||||||
for (i = 0; ; i++)
|
dword *params = ((dword *)(&fmt)) + 1; //points to the first paramater
|
||||||
{
|
int i;
|
||||||
if (special)
|
int special = 0;
|
||||||
{
|
for (i = 0; ; i++)
|
||||||
special = 0;
|
{
|
||||||
switch (fmt[i])
|
if (special)
|
||||||
{
|
{
|
||||||
case 0:
|
special = 0;
|
||||||
return;
|
switch (fmt[i])
|
||||||
case '%':
|
{
|
||||||
putc('%');
|
case 0:
|
||||||
break;
|
return;
|
||||||
case 's': case 'S':
|
case '%':
|
||||||
puts((char *)*params);
|
putc('%');
|
||||||
params++;
|
break;
|
||||||
break;
|
case 's': case 'S':
|
||||||
case 'c': case 'C':
|
puts((char *)*params);
|
||||||
putc(*params);
|
params++;
|
||||||
params++;
|
break;
|
||||||
break;
|
case 'c': case 'C':
|
||||||
case 'd': case 'D':
|
putc(*params);
|
||||||
putDec(*params);
|
params++;
|
||||||
params++;
|
break;
|
||||||
break;
|
case 'd': case 'D':
|
||||||
case 'u': case 'U':
|
putDec(*params);
|
||||||
putDecu(*params);
|
params++;
|
||||||
params++;
|
break;
|
||||||
break;
|
case 'u': case 'U':
|
||||||
case 'x': case 'X':
|
putDecu(*params);
|
||||||
putHex(*params);
|
params++;
|
||||||
params++;
|
break;
|
||||||
break;
|
case 'x': case 'X':
|
||||||
}
|
putHex(*params);
|
||||||
}
|
params++;
|
||||||
else
|
break;
|
||||||
{
|
}
|
||||||
switch (fmt[i])
|
}
|
||||||
{
|
else
|
||||||
case '%':
|
{
|
||||||
special = 1;
|
switch (fmt[i])
|
||||||
break;
|
{
|
||||||
case 0:
|
case '%':
|
||||||
return;
|
special = 1;
|
||||||
default:
|
break;
|
||||||
putc(fmt[i]);
|
case 0:
|
||||||
}
|
return;
|
||||||
}
|
default:
|
||||||
}
|
putc(fmt[i]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// This function draws a single character
|
}
|
||||||
void putc(dword chr)
|
|
||||||
{
|
|
||||||
char charac = (char)chr;
|
// This function draws a single character
|
||||||
word *vidmem = (word *)0xC00B8000;
|
void putc(dword chr)
|
||||||
if (charac == '\n')
|
{
|
||||||
{
|
char charac = (char)chr;
|
||||||
if (cursorPosition % 80)
|
word *vidmem = (word *)0xC00B8000;
|
||||||
cursorPosition = cursorPosition + 80 - (cursorPosition % 80);
|
if (charac == '\n')
|
||||||
else
|
{
|
||||||
cursorPosition += 80;
|
if (cursorPosition % 80)
|
||||||
}
|
cursorPosition = cursorPosition + 80 - (cursorPosition % 80);
|
||||||
else if (charac == '\t')
|
else
|
||||||
{
|
cursorPosition += 80;
|
||||||
if (cursorPosition % 8)
|
}
|
||||||
cursorPosition = cursorPosition + 8 - (cursorPosition % 8);
|
else if (charac == '\t')
|
||||||
else
|
{
|
||||||
cursorPosition += 8;
|
if (cursorPosition % 8)
|
||||||
}
|
cursorPosition = cursorPosition + 8 - (cursorPosition % 8);
|
||||||
else
|
else
|
||||||
{
|
cursorPosition += 8;
|
||||||
if (videoMode)
|
}
|
||||||
{
|
else
|
||||||
console_memory[cursorPosition] = charac | 0x0700;
|
{
|
||||||
video_drawConsoleChar(cursorPosition);
|
if (videoMode)
|
||||||
}
|
{
|
||||||
else
|
console_memory[cursorPosition] = charac | 0x0700;
|
||||||
{
|
video_drawConsoleChar(cursorPosition);
|
||||||
console_memory[cursorPosition] = charac | 0x0700;
|
}
|
||||||
vidmem[cursorPosition] = charac | 0x0700;
|
else
|
||||||
}
|
{
|
||||||
cursorPosition++;
|
console_memory[cursorPosition] = charac | 0x0700;
|
||||||
}
|
vidmem[cursorPosition] = charac | 0x0700;
|
||||||
if (cursorPosition >= 2000)
|
}
|
||||||
{
|
cursorPosition++;
|
||||||
console_scroll();
|
}
|
||||||
cursorPosition = 2000-80;
|
if (cursorPosition >= 2000)
|
||||||
if (videoMode)
|
{
|
||||||
video_drawConsole();
|
console_scroll();
|
||||||
}
|
cursorPosition = 2000-80;
|
||||||
if (!videoMode)
|
if (videoMode)
|
||||||
writeCursorPosition(cursorPosition);
|
video_drawConsole();
|
||||||
}
|
}
|
||||||
|
if (!videoMode)
|
||||||
|
writeCursorPosition(cursorPosition);
|
||||||
// This function displays a number in hexadecimal
|
}
|
||||||
int putHex(dword number)
|
|
||||||
{
|
|
||||||
int hitNum = 0;
|
// This function displays a number in hexadecimal
|
||||||
int i;
|
int putHex(dword number)
|
||||||
for (i = 7; i >= 0; i--)
|
{
|
||||||
{
|
int hitNum = 0;
|
||||||
dword val = (number >> (i*4)) & 0xF;
|
int i;
|
||||||
if ((val != 0) || (i == 0))
|
for (i = 7; i >= 0; i--)
|
||||||
hitNum = 1;
|
{
|
||||||
if (hitNum)
|
dword val = (number >> (i*4)) & 0xF;
|
||||||
{
|
if ((val != 0) || (i == 0))
|
||||||
val = val + '0';
|
hitNum = 1;
|
||||||
if (val > '9')
|
if (hitNum)
|
||||||
val = val + ('A' - '9' - 1);
|
{
|
||||||
putc(val);
|
val = val + '0';
|
||||||
}
|
if (val > '9')
|
||||||
}
|
val = val + ('A' - '9' - 1);
|
||||||
}
|
putc(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,15 +1,17 @@
|
|||||||
//kio.h
|
//kio.h
|
||||||
// Author: Josh Holtrop
|
// Author: Josh Holtrop
|
||||||
// Created: 12/25/03
|
// Created: 12/25/03
|
||||||
// Modified: 12/25/03
|
// Modified: 12/25/03
|
||||||
|
|
||||||
|
#include "hos_defines.h"
|
||||||
|
|
||||||
void printf(char *fmt, ...);
|
#ifndef __HOS_KIO__
|
||||||
void putc(dword chr);
|
#define __HOS_KIO__ __HOS_KIO__
|
||||||
int putHex(dword number);
|
|
||||||
|
void printf(char *fmt, ...);
|
||||||
|
void putc(dword chr);
|
||||||
dword cursorPosition = 0; //Caches the current cursor position
|
int putHex(dword number);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -1,121 +1,124 @@
|
|||||||
// mm.c
|
// mm.c
|
||||||
// Author: Josh Holtrop
|
// Author: Josh Holtrop
|
||||||
// Created: 09/01/03
|
// Created: 09/01/03
|
||||||
// Modified: 12/28/03
|
// Modified: 03/02/04
|
||||||
|
|
||||||
//The total amount of physical memory available (bytes, 1 bit per page)
|
#include "hos_defines.h"
|
||||||
#define BITMAP_SIZE 0x20000
|
#include "mm.h"
|
||||||
dword mm_totalmem = 0;
|
|
||||||
dword mm_megabytes;
|
//The total amount of physical memory available (bytes, 1 bit per page)
|
||||||
byte page_bitmap[BITMAP_SIZE]; //used to store a bit for each page that is used, 0 if available
|
#define BITMAP_SIZE 0x20000
|
||||||
//0x20000*(8 bits/byte)=0x100000 pages in 4gb total
|
dword mm_totalmem = 0;
|
||||||
|
dword mm_megabytes;
|
||||||
//This function initializes the memory manager's linked list, filling it with the
|
byte page_bitmap[BITMAP_SIZE]; //used to store a bit for each page that is used, 0 if available
|
||||||
// memory areas returned by bios interrupt 0x8E20
|
//0x20000*(8 bits/byte)=0x100000 pages in 4gb total
|
||||||
void mm_init()
|
|
||||||
{
|
//This function initializes the memory manager's linked list, filling it with the
|
||||||
dword memmap_entries = *(dword *)BOOT_MEMMAP_ENTRIES;
|
// memory areas returned by bios interrupt 0x8E20
|
||||||
memmap_entry *maps = (memmap_entry *) BOOT_FIRST_MEMMAP;
|
void mm_init()
|
||||||
dword a;
|
{
|
||||||
for (a = 0; a < BITMAP_SIZE; a++)
|
dword memmap_entries = *(dword *)BOOT_MEMMAP_ENTRIES;
|
||||||
{
|
memmap_entry *maps = (memmap_entry *) BOOT_FIRST_MEMMAP;
|
||||||
page_bitmap[a] = 0xFF; //all pages used
|
dword a;
|
||||||
}
|
for (a = 0; a < BITMAP_SIZE; a++)
|
||||||
for (a = 0; a < memmap_entries; a++)
|
{
|
||||||
{
|
page_bitmap[a] = 0xFF; //all pages used
|
||||||
if (maps[a].attributes == 1) // (1) mem free to OS
|
}
|
||||||
{
|
for (a = 0; a < memmap_entries; a++)
|
||||||
mm_totalmem += maps[a].limit.lowdword;
|
{
|
||||||
if ((maps[a].base.lowdword + maps[a].limit.lowdword) >= (FREERAM_START+4096)) //goes past where we start freeram
|
if (maps[a].attributes == 1) // (1) mem free to OS
|
||||||
{
|
{
|
||||||
if (maps[a].base.lowdword < FREERAM_START)
|
mm_totalmem += maps[a].limit.lowdword;
|
||||||
{
|
if ((maps[a].base.lowdword + maps[a].limit.lowdword) >= (FREERAM_START+4096)) //goes past where we start freeram
|
||||||
mm_pfreen(FREERAM_START, (maps[a].limit.lowdword - (FREERAM_START - maps[a].base.lowdword)) >> 12);
|
{
|
||||||
}
|
if (maps[a].base.lowdword < FREERAM_START)
|
||||||
else
|
{
|
||||||
{
|
mm_pfreen(FREERAM_START, (maps[a].limit.lowdword - (FREERAM_START - maps[a].base.lowdword)) >> 12);
|
||||||
mm_pfreen(maps[a].base.lowdword, maps[a].limit.lowdword >> 12); //set the appropriate bits as "free" in the page bitmap
|
}
|
||||||
}
|
else
|
||||||
}
|
{
|
||||||
}
|
mm_pfreen(maps[a].base.lowdword, maps[a].limit.lowdword >> 12); //set the appropriate bits as "free" in the page bitmap
|
||||||
}
|
}
|
||||||
if (mm_totalmem % 0x100000)
|
}
|
||||||
mm_megabytes = (mm_totalmem >> 20) + 1;
|
}
|
||||||
else
|
}
|
||||||
mm_megabytes = mm_totalmem >> 20;
|
if (mm_totalmem % 0x100000)
|
||||||
}
|
mm_megabytes = (mm_totalmem >> 20) + 1;
|
||||||
|
else
|
||||||
|
mm_megabytes = mm_totalmem >> 20;
|
||||||
// This function frees a certain number of pages starting at the address
|
}
|
||||||
// specified in base for a length of pages pages
|
|
||||||
void mm_pfreen(dword base, dword pages)
|
|
||||||
{
|
// This function frees a certain number of pages starting at the address
|
||||||
dword a;
|
// specified in base for a length of pages pages
|
||||||
dword max = base + (pages << 12);
|
void mm_pfreen(dword base, dword pages)
|
||||||
for (a = base; a < max; a += 4096)
|
{
|
||||||
{
|
dword a;
|
||||||
mm_pfree(a);
|
dword max = base + (pages << 12);
|
||||||
}
|
for (a = base; a < max; a += 4096)
|
||||||
}
|
{
|
||||||
|
mm_pfree(a);
|
||||||
|
}
|
||||||
// This function frees a single page
|
}
|
||||||
void mm_pfree(dword base)
|
|
||||||
{
|
|
||||||
// dword pageNumber = base >> 12; // >>12 == /4096
|
// This function frees a single page
|
||||||
dword byteNumber = base >> 15; //pageNumber >> 3; //pageNumber/8
|
void mm_pfree(dword base)
|
||||||
dword bitNumber = (base >> 12) % 8; //pageNumber % 8;
|
{
|
||||||
page_bitmap[byteNumber] = page_bitmap[byteNumber] & ((0x01 << bitNumber) ^ 0xFF);
|
// dword pageNumber = base >> 12; // >>12 == /4096
|
||||||
}
|
dword byteNumber = base >> 15; //pageNumber >> 3; //pageNumber/8
|
||||||
|
dword bitNumber = (base >> 12) % 8; //pageNumber % 8;
|
||||||
|
page_bitmap[byteNumber] = page_bitmap[byteNumber] & ((0x01 << bitNumber) ^ 0xFF);
|
||||||
// This function allocates a single page, returning its physical address
|
}
|
||||||
void *mm_palloc()
|
|
||||||
{
|
|
||||||
dword bite;
|
// This function allocates a single page, returning its physical address
|
||||||
for (bite = 0; bite < BITMAP_SIZE; bite++)
|
void *mm_palloc()
|
||||||
{
|
{
|
||||||
if (page_bitmap[bite] != 0xFF) //there is an available page within this 8-page region
|
dword bite;
|
||||||
{
|
for (bite = 0; bite < BITMAP_SIZE; bite++)
|
||||||
int bit;
|
{
|
||||||
for (bit = 0; bit < 8; bit++)
|
if (page_bitmap[bite] != 0xFF) //there is an available page within this 8-page region
|
||||||
{
|
{
|
||||||
if (!(page_bitmap[bite] & (1 << bit))) //this bite/bit combination is available
|
int bit;
|
||||||
{
|
for (bit = 0; bit < 8; bit++)
|
||||||
page_bitmap[bite] = page_bitmap[bite] | (1 << bit); //set page as used
|
{
|
||||||
return (void *)((bite << 15) | (bit << 12));
|
if (!(page_bitmap[bite] & (1 << bit))) //this bite/bit combination is available
|
||||||
}
|
{
|
||||||
}
|
page_bitmap[bite] = page_bitmap[bite] | (1 << bit); //set page as used
|
||||||
}
|
return (void *)((bite << 15) | (bit << 12));
|
||||||
}
|
}
|
||||||
return 0; //no free page
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return 0; //no free page
|
||||||
// This function reports the number of bytes of free physical memory
|
}
|
||||||
dword mm_freemem()
|
|
||||||
{
|
|
||||||
dword a;
|
// This function reports the number of bytes of free physical memory
|
||||||
dword pages = 0;
|
dword mm_freemem()
|
||||||
for (a = 0; a < BITMAP_SIZE; a++)
|
{
|
||||||
{
|
dword a;
|
||||||
int bit;
|
dword pages = 0;
|
||||||
for (bit = 0; bit < 8; bit++)
|
for (a = 0; a < BITMAP_SIZE; a++)
|
||||||
{
|
{
|
||||||
if (!(page_bitmap[a] & (1 << bit)))
|
int bit;
|
||||||
pages++;
|
for (bit = 0; bit < 8; bit++)
|
||||||
}
|
{
|
||||||
}
|
if (!(page_bitmap[a] & (1 << bit)))
|
||||||
return pages << 12;
|
pages++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return pages << 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,21 +1,27 @@
|
|||||||
|
// mm.c
|
||||||
|
// Author: Josh Holtrop
|
||||||
typedef struct {
|
// Created: 09/01/03
|
||||||
qword base;
|
// Modified: 03/02/04
|
||||||
qword limit;
|
|
||||||
dword attributes;
|
#include "hos_defines.h"
|
||||||
} __attribute__((packed)) memmap_entry;
|
|
||||||
|
#ifndef __HOS_MM__
|
||||||
|
#define __HOS_MM__ __HOS_MM__
|
||||||
|
|
||||||
void mm_init();
|
|
||||||
void mm_pfreen(dword base, dword pages);
|
typedef struct {
|
||||||
void mm_pfree(dword base);
|
qword base;
|
||||||
void *mm_palloc();
|
qword limit;
|
||||||
dword mm_freemem();
|
dword attributes;
|
||||||
|
} __attribute__((packed)) memmap_entry;
|
||||||
|
|
||||||
|
|
||||||
|
void mm_init();
|
||||||
|
void mm_pfreen(dword base, dword pages);
|
||||||
|
void mm_pfree(dword base);
|
||||||
|
void *mm_palloc();
|
||||||
|
dword mm_freemem();
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -1,354 +1,358 @@
|
|||||||
// vmm.c
|
// vmm.c
|
||||||
// Author: Josh Holtrop
|
// Author: Josh Holtrop
|
||||||
// Date: 09/30/03
|
// Date: 09/30/03
|
||||||
// Rewritten from scratch: 12/23/03
|
// Rewritten from scratch: 12/23/03
|
||||||
// Modified: 12/30/03
|
// Modified: 03/02/04
|
||||||
|
|
||||||
|
#include "hos_defines.h"
|
||||||
// This is the initialization procedure for the Virtual Memory Manager
|
#include "vmm.h"
|
||||||
// It sets up the final page directory/page table setup and maps video memory, if present
|
|
||||||
void vmm_init()
|
HeapEntry *firstHeapEntry = (HeapEntry *)0xD0000000; //this is where heap memory starts
|
||||||
{
|
|
||||||
dword *pageTables = (dword *)0xC0104000; //this is the location of the page directory
|
// This is the initialization procedure for the Virtual Memory Manager
|
||||||
pageTables[0x3FF] = 0x104000|0x03; //the last page directory entry points to the page directory itself
|
// It sets up the final page directory/page table setup and maps video memory, if present
|
||||||
pageTables[0] = 0;
|
void vmm_init()
|
||||||
invlpg(0);
|
{
|
||||||
if (videoMode) //we are in a graphical mode
|
unsigned int *pageTables = (unsigned int *)0xC0104000; //this is the location of the page directory
|
||||||
{
|
pageTables[0x3FF] = 0x104000|0x03; //the last page directory entry points to the page directory itself
|
||||||
dword vidPages = video_mode.XResolution * video_mode.YResolution * (video_mode.BitsPerPixel >> 3);
|
pageTables[0] = 0;
|
||||||
if (vidPages % 4096)
|
invlpg(0);
|
||||||
vidPages = (vidPages >> 12) + 1;
|
if (videoMode) //we are in a graphical mode
|
||||||
else
|
{
|
||||||
vidPages = (vidPages >> 12);
|
unsigned int vidPages = video_mode.XResolution * video_mode.YResolution * (video_mode.BitsPerPixel >> 3);
|
||||||
vmm_mapn(0xF0000000, video_mode.PhysBasePtr, vidPages);
|
if (vidPages % 4096)
|
||||||
}
|
vidPages = (vidPages >> 12) + 1;
|
||||||
dword firstHeapEntryBlock = (dword)mm_palloc();
|
else
|
||||||
vmm_map1((dword)firstHeapEntry, firstHeapEntryBlock);
|
vidPages = (vidPages >> 12);
|
||||||
HeapEntryBlock *heb = (HeapEntryBlock *)firstHeapEntry;
|
vmm_mapn(0xF0000000, video_mode.PhysBasePtr, vidPages);
|
||||||
vmm_heb_init(heb);
|
}
|
||||||
heb->entry[0].base = (dword)firstHeapEntry; //start of kernel's heap memory
|
unsigned int firstHeapEntryBlock = (unsigned int)mm_palloc();
|
||||||
heb->entry[0].size = 4096; //the first HeapEntryBlock is 1 page long
|
vmm_map1((unsigned int)firstHeapEntry, firstHeapEntryBlock);
|
||||||
heb->entry[0].attributes = VMM_HE_HEB; //this is a HeapEntryBlock
|
HeapEntryBlock *heb = (HeapEntryBlock *)firstHeapEntry;
|
||||||
heb->entry[1].base = (dword)firstHeapEntry+4096; //this is the start of the rest of the kernel's heap memory
|
vmm_heb_init(heb);
|
||||||
heb->entry[1].size = 0x10000000-4096; //the rest of the kernel's heap memory: 256mb - 4kb
|
heb->entry[0].base = (unsigned int)firstHeapEntry; //start of kernel's heap memory
|
||||||
heb->entry[1].attributes = VMM_HE_HOLE; //this is a hold - an unmapped section of heap memory
|
heb->entry[0].size = 4096; //the first HeapEntryBlock is 1 page long
|
||||||
}
|
heb->entry[0].attributes = VMM_HE_HEB; //this is a HeapEntryBlock
|
||||||
|
heb->entry[1].base = (unsigned int)firstHeapEntry+4096; //this is the start of the rest of the kernel's heap memory
|
||||||
|
heb->entry[1].size = 0x10000000-4096; //the rest of the kernel's heap memory: 256mb - 4kb
|
||||||
// This function initialzes a Heap Entry Block to unused entries linked together
|
heb->entry[1].attributes = VMM_HE_HOLE; //this is a hold - an unmapped section of heap memory
|
||||||
void vmm_heb_init(HeapEntryBlock *heb)
|
}
|
||||||
{
|
|
||||||
int a;
|
|
||||||
for (a = 0; a < 256; a++)
|
// This function initialzes a Heap Entry Block to unused entries linked together
|
||||||
{
|
void vmm_heb_init(HeapEntryBlock *heb)
|
||||||
heb->entry[a].base = 0;
|
{
|
||||||
heb->entry[a].size = 0;
|
int a;
|
||||||
heb->entry[a].attributes = VMM_HE_UNUSED;
|
for (a = 0; a < 256; a++)
|
||||||
heb->entry[a].link = (dword)&(heb->entry[a+1]);
|
{
|
||||||
}
|
heb->entry[a].base = 0;
|
||||||
heb->entry[255].link = 0;
|
heb->entry[a].size = 0;
|
||||||
}
|
heb->entry[a].attributes = VMM_HE_UNUSED;
|
||||||
|
heb->entry[a].link = (unsigned int)&(heb->entry[a+1]);
|
||||||
|
}
|
||||||
// This function maps a virtual address to a physical address using the page directory / page table
|
heb->entry[255].link = 0;
|
||||||
void vmm_map1(dword virt, dword physical)
|
}
|
||||||
{
|
|
||||||
dword pde = virt >> 22;
|
|
||||||
dword pte = (virt & 0x003FF000) >> 12;
|
// This function maps a virtual address to a physical address using the page directory / page table
|
||||||
dword *pageTables = (dword *)0xC0104000; //this is the location of the page directory
|
void vmm_map1(unsigned int virt, unsigned int physical)
|
||||||
if (!(pageTables[pde] & 0x01)) //the page directory entry does not exist, we must allocate a page for it
|
{
|
||||||
{
|
unsigned int pde = virt >> 22;
|
||||||
dword *newpagetable = mm_palloc();
|
unsigned int pte = (virt & 0x003FF000) >> 12;
|
||||||
pageTables[pde] = ((dword)newpagetable) | 0x03;
|
unsigned int *pageTables = (unsigned int *)0xC0104000; //this is the location of the page directory
|
||||||
invlpg(virt);
|
if (!(pageTables[pde] & 0x01)) //the page directory entry does not exist, we must allocate a page for it
|
||||||
dword *newpteptr = (dword *)(0xFFC00000 | (pde << 12)); //points to first dword of newly allocated page table
|
{
|
||||||
int a;
|
unsigned int *newpagetable = mm_palloc();
|
||||||
for (a = 0; a < 1024; a++)
|
pageTables[pde] = ((unsigned int)newpagetable) | 0x03;
|
||||||
{
|
invlpg(virt);
|
||||||
newpteptr[a] = 0;
|
unsigned int *newpteptr = (unsigned int *)(0xFFC00000 | (pde << 12)); //points to first unsigned int of newly allocated page table
|
||||||
}
|
int a;
|
||||||
}
|
for (a = 0; a < 1024; a++)
|
||||||
dword *pteptr = (dword *)(0xFFC00000 | (pde << 12) | (pte << 2));
|
{
|
||||||
*pteptr = physical | 0x03;
|
newpteptr[a] = 0;
|
||||||
invlpg(virt);
|
}
|
||||||
}
|
}
|
||||||
|
unsigned int *pteptr = (unsigned int *)(0xFFC00000 | (pde << 12) | (pte << 2));
|
||||||
|
*pteptr = physical | 0x03;
|
||||||
// This function maps a variable number of pages in a row
|
invlpg(virt);
|
||||||
void vmm_mapn(dword virt, dword physical, dword n)
|
}
|
||||||
{
|
|
||||||
for (; n > 0; n--)
|
|
||||||
{
|
// This function maps a variable number of pages in a row
|
||||||
vmm_map1(virt, physical);
|
void vmm_mapn(unsigned int virt, unsigned int physical, unsigned int n)
|
||||||
virt += 4096;
|
{
|
||||||
physical += 4096;
|
for (; n > 0; n--)
|
||||||
}
|
{
|
||||||
}
|
vmm_map1(virt, physical);
|
||||||
|
virt += 4096;
|
||||||
|
physical += 4096;
|
||||||
// This function removes the virtual address's entry in the page directory / page table
|
}
|
||||||
void vmm_unmap1(dword virt)
|
}
|
||||||
{
|
|
||||||
dword *pteptr = (dword *)(0xFFC00000 | ((virt & 0xFFC00000) >> 10) | ((virt & 0x003FF000) >> 10));
|
|
||||||
*pteptr = 0;
|
// This function removes the virtual address's entry in the page directory / page table
|
||||||
invlpg(virt);
|
void vmm_unmap1(unsigned int virt)
|
||||||
}
|
{
|
||||||
|
unsigned int *pteptr = (unsigned int *)(0xFFC00000 | ((virt & 0xFFC00000) >> 10) | ((virt & 0x003FF000) >> 10));
|
||||||
|
*pteptr = 0;
|
||||||
// This function removes multiple pages' entries
|
invlpg(virt);
|
||||||
void vmm_unmapn(dword virt, dword n)
|
}
|
||||||
{
|
|
||||||
for (; n > 0; n--)
|
|
||||||
{
|
// This function removes multiple pages' entries
|
||||||
vmm_unmap1(virt);
|
void vmm_unmapn(unsigned int virt, unsigned int n)
|
||||||
virt += 4096;
|
{
|
||||||
}
|
for (; n > 0; n--)
|
||||||
}
|
{
|
||||||
|
vmm_unmap1(virt);
|
||||||
|
virt += 4096;
|
||||||
// Virtual Memory allocator function
|
}
|
||||||
void *malloc(dword bytes)
|
}
|
||||||
{
|
|
||||||
if (bytes % VMM_MALLOC_GRANULARITY)
|
|
||||||
bytes = bytes + VMM_MALLOC_GRANULARITY - (bytes % VMM_MALLOC_GRANULARITY);
|
// Virtual Memory allocator function
|
||||||
void *attempt = vmm_getFreeChunk(bytes);
|
void *malloc(unsigned int bytes)
|
||||||
if (attempt)
|
{
|
||||||
return attempt;
|
if (bytes % VMM_MALLOC_GRANULARITY)
|
||||||
if(vmm_moreCore(bytes))
|
bytes = bytes + VMM_MALLOC_GRANULARITY - (bytes % VMM_MALLOC_GRANULARITY);
|
||||||
return 0; //we could not get any more heap memory
|
void *attempt = vmm_getFreeChunk(bytes);
|
||||||
return vmm_getFreeChunk(bytes);
|
if (attempt)
|
||||||
}
|
return attempt;
|
||||||
|
if(vmm_moreCore(bytes))
|
||||||
|
return 0; //we could not get any more heap memory
|
||||||
// This function returns a pointer if a free chunk of memory exists
|
return vmm_getFreeChunk(bytes);
|
||||||
void *vmm_getFreeChunk(dword bytes)
|
}
|
||||||
{
|
|
||||||
HeapEntry *he = firstHeapEntry;
|
|
||||||
for (;;)
|
// This function returns a pointer if a free chunk of memory exists
|
||||||
{
|
void *vmm_getFreeChunk(unsigned int bytes)
|
||||||
if (he->attributes == VMM_HE_FREE)
|
{
|
||||||
{
|
HeapEntry *he = firstHeapEntry;
|
||||||
if (he->size > bytes)
|
for (;;)
|
||||||
{
|
{
|
||||||
HeapEntry *nhe = vmm_nextHeapEntry();
|
if (he->attributes == VMM_HE_FREE)
|
||||||
nhe->base = he->base;
|
{
|
||||||
nhe->size = bytes;
|
if (he->size > bytes)
|
||||||
nhe->attributes = VMM_HE_USED;
|
{
|
||||||
he->base += bytes;
|
HeapEntry *nhe = vmm_nextHeapEntry();
|
||||||
he->size -= bytes;
|
nhe->base = he->base;
|
||||||
return (void *)(nhe->base);
|
nhe->size = bytes;
|
||||||
}
|
nhe->attributes = VMM_HE_USED;
|
||||||
if (he->size == bytes)
|
he->base += bytes;
|
||||||
{
|
he->size -= bytes;
|
||||||
he->attributes = VMM_HE_USED;
|
return (void *)(nhe->base);
|
||||||
return (void *)(he->base);
|
}
|
||||||
}
|
if (he->size == bytes)
|
||||||
}
|
{
|
||||||
he = (HeapEntry *)he->link;
|
he->attributes = VMM_HE_USED;
|
||||||
if (!he)
|
return (void *)(he->base);
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
he = (HeapEntry *)he->link;
|
||||||
}
|
if (!he)
|
||||||
|
break;
|
||||||
|
}
|
||||||
// This function coalesces any two adjacent heap entries into one entry
|
return 0;
|
||||||
void vmm_coalesceHeapEntry(HeapEntry *he)
|
}
|
||||||
{
|
|
||||||
if (!(he->attributes == VMM_HE_FREE || he->attributes == VMM_HE_HOLE))
|
|
||||||
return;
|
// This function coalesces any two adjacent heap entries into one entry
|
||||||
if (he->size == 0)
|
void vmm_coalesceHeapEntry(HeapEntry *he)
|
||||||
{
|
{
|
||||||
he->attributes = VMM_HE_UNUSED;
|
if (!(he->attributes == VMM_HE_FREE || he->attributes == VMM_HE_HOLE))
|
||||||
return;
|
return;
|
||||||
}
|
if (he->size == 0)
|
||||||
HeapEntry *hec = firstHeapEntry;
|
{
|
||||||
for (;;)
|
he->attributes = VMM_HE_UNUSED;
|
||||||
{
|
return;
|
||||||
if (hec->attributes == he->attributes)
|
}
|
||||||
{
|
HeapEntry *hec = firstHeapEntry;
|
||||||
if ((hec->base + hec->size) == he->base) //hec ends where he begins
|
for (;;)
|
||||||
{
|
{
|
||||||
he->base = hec->base;
|
if (hec->attributes == he->attributes)
|
||||||
he->size += hec->size;
|
{
|
||||||
hec->attributes = VMM_HE_UNUSED;
|
if ((hec->base + hec->size) == he->base) //hec ends where he begins
|
||||||
}
|
{
|
||||||
if ((he->base + he->size) == hec->base) //he ends where hec begins
|
he->base = hec->base;
|
||||||
{
|
he->size += hec->size;
|
||||||
he->size += hec->size;
|
hec->attributes = VMM_HE_UNUSED;
|
||||||
hec->attributes = VMM_HE_UNUSED;
|
}
|
||||||
}
|
if ((he->base + he->size) == hec->base) //he ends where hec begins
|
||||||
}
|
{
|
||||||
hec = (HeapEntry *)hec->link;
|
he->size += hec->size;
|
||||||
if (!hec)
|
hec->attributes = VMM_HE_UNUSED;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
}
|
hec = (HeapEntry *)hec->link;
|
||||||
|
if (!hec)
|
||||||
|
break;
|
||||||
// This function retrieves more physical memory for the heap
|
}
|
||||||
int vmm_moreCore(dword bytes)
|
}
|
||||||
{
|
|
||||||
dword pages = (bytes >> 12) + 1;
|
|
||||||
bytes = pages << 12;
|
// This function retrieves more physical memory for the heap
|
||||||
HeapEntry *he = vmm_getFirstHoleHeapEntry(bytes);
|
int vmm_moreCore(unsigned int bytes)
|
||||||
dword virt = he->base;
|
{
|
||||||
for (; pages > 0; pages--)
|
unsigned int pages = (bytes >> 12) + 1;
|
||||||
{
|
bytes = pages << 12;
|
||||||
dword phys = (dword)mm_palloc();
|
HeapEntry *he = vmm_getFirstHoleHeapEntry(bytes);
|
||||||
if (!phys)
|
unsigned int virt = he->base;
|
||||||
return 1;
|
for (; pages > 0; pages--)
|
||||||
vmm_map1(virt, phys);
|
{
|
||||||
virt += 4096;
|
unsigned int phys = (unsigned int)mm_palloc();
|
||||||
}
|
if (!phys)
|
||||||
if (he->size == bytes)
|
return 1;
|
||||||
{
|
vmm_map1(virt, phys);
|
||||||
he->attributes = VMM_HE_FREE;
|
virt += 4096;
|
||||||
vmm_coalesceHeapEntry(he);
|
}
|
||||||
}
|
if (he->size == bytes)
|
||||||
else
|
{
|
||||||
{
|
he->attributes = VMM_HE_FREE;
|
||||||
HeapEntry *nhe = vmm_nextHeapEntry();
|
vmm_coalesceHeapEntry(he);
|
||||||
nhe->base = he->base;
|
}
|
||||||
nhe->size = bytes;
|
else
|
||||||
nhe->attributes = VMM_HE_FREE;
|
{
|
||||||
he->base += bytes;
|
HeapEntry *nhe = vmm_nextHeapEntry();
|
||||||
he->size -= bytes;
|
nhe->base = he->base;
|
||||||
vmm_coalesceHeapEntry(nhe);
|
nhe->size = bytes;
|
||||||
}
|
nhe->attributes = VMM_HE_FREE;
|
||||||
return 0;
|
he->base += bytes;
|
||||||
}
|
he->size -= bytes;
|
||||||
|
vmm_coalesceHeapEntry(nhe);
|
||||||
|
}
|
||||||
// This function returns the next available heap entry, creates more entries if we are running low
|
return 0;
|
||||||
HeapEntry *vmm_nextHeapEntry()
|
}
|
||||||
{
|
|
||||||
if (vmm_heapEntriesLeft() < 10)
|
|
||||||
vmm_addHeapEntryBlock();
|
// This function returns the next available heap entry, creates more entries if we are running low
|
||||||
return vmm_getFirstUnusedHeapEntry();
|
HeapEntry *vmm_nextHeapEntry()
|
||||||
}
|
{
|
||||||
|
if (vmm_heapEntriesLeft() < 10)
|
||||||
|
vmm_addHeapEntryBlock();
|
||||||
// This function creates a new block (page) of heap entries (256)
|
return vmm_getFirstUnusedHeapEntry();
|
||||||
void vmm_addHeapEntryBlock()
|
}
|
||||||
{
|
|
||||||
HeapEntry *he = vmm_getFirstHoleHeapEntry(4096);
|
|
||||||
HeapEntry *newBlock = vmm_getFirstUnusedHeapEntry();
|
// This function creates a new block (page) of heap entries (256)
|
||||||
dword heb = (dword)mm_palloc();
|
void vmm_addHeapEntryBlock()
|
||||||
vmm_map1(he->base, heb);
|
{
|
||||||
vmm_heb_init((HeapEntryBlock *)he->base);
|
HeapEntry *he = vmm_getFirstHoleHeapEntry(4096);
|
||||||
HeapEntry *lhe = vmm_getLastHeapEntry();
|
HeapEntry *newBlock = vmm_getFirstUnusedHeapEntry();
|
||||||
if (he->size == 4096)
|
unsigned int heb = (unsigned int)mm_palloc();
|
||||||
{
|
vmm_map1(he->base, heb);
|
||||||
he->attributes = VMM_HE_HEB;
|
vmm_heb_init((HeapEntryBlock *)he->base);
|
||||||
lhe->link = (dword)he->base;
|
HeapEntry *lhe = vmm_getLastHeapEntry();
|
||||||
}
|
if (he->size == 4096)
|
||||||
else
|
{
|
||||||
{
|
he->attributes = VMM_HE_HEB;
|
||||||
newBlock->base = he->base;
|
lhe->link = (unsigned int)he->base;
|
||||||
newBlock->size = 4096;
|
}
|
||||||
newBlock->attributes = VMM_HE_HEB;
|
else
|
||||||
he->base += 4096;
|
{
|
||||||
he->size -= 4096;
|
newBlock->base = he->base;
|
||||||
lhe->link = (dword)newBlock->base;
|
newBlock->size = 4096;
|
||||||
}
|
newBlock->attributes = VMM_HE_HEB;
|
||||||
return;
|
he->base += 4096;
|
||||||
}
|
he->size -= 4096;
|
||||||
|
lhe->link = (unsigned int)newBlock->base;
|
||||||
|
}
|
||||||
// This function returns the last heap entry in the linked list, useful for setting
|
return;
|
||||||
// its link field to point to the first entry of a newly allocated list
|
}
|
||||||
HeapEntry *vmm_getLastHeapEntry()
|
|
||||||
{
|
|
||||||
HeapEntry *he = firstHeapEntry;
|
// This function returns the last heap entry in the linked list, useful for setting
|
||||||
for (;;)
|
// its link field to point to the first entry of a newly allocated list
|
||||||
{
|
HeapEntry *vmm_getLastHeapEntry()
|
||||||
if (he->link == 0)
|
{
|
||||||
return he;
|
HeapEntry *he = firstHeapEntry;
|
||||||
he = (HeapEntry *)he->link;
|
for (;;)
|
||||||
}
|
{
|
||||||
}
|
if (he->link == 0)
|
||||||
|
return he;
|
||||||
|
he = (HeapEntry *)he->link;
|
||||||
// This function returns the first heap entry corresponding to a memory "hole"
|
}
|
||||||
HeapEntry *vmm_getFirstHoleHeapEntry(dword minBytes)
|
}
|
||||||
{
|
|
||||||
HeapEntry *he = firstHeapEntry;
|
|
||||||
for (;;)
|
// This function returns the first heap entry corresponding to a memory "hole"
|
||||||
{
|
HeapEntry *vmm_getFirstHoleHeapEntry(unsigned int minBytes)
|
||||||
if ((he->attributes == VMM_HE_HOLE) && (he->size >= minBytes))
|
{
|
||||||
return he;
|
HeapEntry *he = firstHeapEntry;
|
||||||
he = (HeapEntry *)he->link;
|
for (;;)
|
||||||
if (!he)
|
{
|
||||||
break;
|
if ((he->attributes == VMM_HE_HOLE) && (he->size >= minBytes))
|
||||||
}
|
return he;
|
||||||
return 0;
|
he = (HeapEntry *)he->link;
|
||||||
}
|
if (!he)
|
||||||
|
break;
|
||||||
|
}
|
||||||
// This function returns the first heap entry that is not being used
|
return 0;
|
||||||
HeapEntry *vmm_getFirstUnusedHeapEntry()
|
}
|
||||||
{
|
|
||||||
HeapEntry *he = firstHeapEntry;
|
|
||||||
for (;;)
|
// This function returns the first heap entry that is not being used
|
||||||
{
|
HeapEntry *vmm_getFirstUnusedHeapEntry()
|
||||||
if (he->attributes == VMM_HE_UNUSED)
|
{
|
||||||
return he;
|
HeapEntry *he = firstHeapEntry;
|
||||||
he = (HeapEntry *)he->link;
|
for (;;)
|
||||||
if (!he)
|
{
|
||||||
break;
|
if (he->attributes == VMM_HE_UNUSED)
|
||||||
}
|
return he;
|
||||||
return 0;
|
he = (HeapEntry *)he->link;
|
||||||
}
|
if (!he)
|
||||||
|
break;
|
||||||
|
}
|
||||||
// This function returns the number of heap entries available for use
|
return 0;
|
||||||
dword vmm_heapEntriesLeft()
|
}
|
||||||
{
|
|
||||||
HeapEntry *he = firstHeapEntry;
|
|
||||||
dword entries = 0;
|
// This function returns the number of heap entries available for use
|
||||||
for (;;)
|
unsigned int vmm_heapEntriesLeft()
|
||||||
{
|
{
|
||||||
if (he->attributes == VMM_HE_UNUSED)
|
HeapEntry *he = firstHeapEntry;
|
||||||
entries++;
|
unsigned int entries = 0;
|
||||||
he = (HeapEntry *)he->link;
|
for (;;)
|
||||||
if (!he)
|
{
|
||||||
break;
|
if (he->attributes == VMM_HE_UNUSED)
|
||||||
}
|
entries++;
|
||||||
return entries;
|
he = (HeapEntry *)he->link;
|
||||||
}
|
if (!he)
|
||||||
|
break;
|
||||||
|
}
|
||||||
// This function "frees" an area of memory previously allocated with malloc()
|
return entries;
|
||||||
int free(void *ptr)
|
}
|
||||||
{
|
|
||||||
HeapEntry *he = vmm_getHeapEntryByBase((dword)ptr);
|
|
||||||
if (!he)
|
// This function "frees" an area of memory previously allocated with malloc()
|
||||||
return 1; //a heap entry starting at the given address was not found
|
int free(void *ptr)
|
||||||
he->attributes = VMM_HE_FREE;
|
{
|
||||||
vmm_coalesceHeapEntry(he);
|
HeapEntry *he = vmm_getHeapEntryByBase((unsigned int)ptr);
|
||||||
return 0;
|
if (!he)
|
||||||
}
|
return 1; //a heap entry starting at the given address was not found
|
||||||
|
he->attributes = VMM_HE_FREE;
|
||||||
|
vmm_coalesceHeapEntry(he);
|
||||||
// This function scans the heap entry linked list for an entry that begins at the given address
|
return 0;
|
||||||
HeapEntry *vmm_getHeapEntryByBase(dword base)
|
}
|
||||||
{
|
|
||||||
HeapEntry *he = firstHeapEntry;
|
|
||||||
for (;;)
|
// This function scans the heap entry linked list for an entry that begins at the given address
|
||||||
{
|
HeapEntry *vmm_getHeapEntryByBase(unsigned int base)
|
||||||
if (he->base == base)
|
{
|
||||||
return he;
|
HeapEntry *he = firstHeapEntry;
|
||||||
he = (HeapEntry *)he->link;
|
for (;;)
|
||||||
if (!he)
|
{
|
||||||
break;
|
if (he->base == base)
|
||||||
}
|
return he;
|
||||||
return 0;
|
he = (HeapEntry *)he->link;
|
||||||
}
|
if (!he)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,55 +1,54 @@
|
|||||||
// vmm.h
|
// vmm.h
|
||||||
// Author: Josh Holtrop
|
// Author: Josh Holtrop
|
||||||
// Date: 09/30/03
|
// Date: 09/30/03
|
||||||
// Rewritten from scratch: 12/23/03
|
// Rewritten from scratch: 12/23/03
|
||||||
// Modified: 12/30/03
|
// Modified: 03/02/04
|
||||||
|
|
||||||
|
#include "hos_defines.h"
|
||||||
#define VMM_HE_UNUSED 0 //available entry
|
|
||||||
#define VMM_HE_FREE 1 //free section of memory
|
#ifndef __HOS_VMM__
|
||||||
#define VMM_HE_USED 2 //used section of memory
|
#define __HOS_VMM__ __HOS_VMM__
|
||||||
#define VMM_HE_HOLE 3 //a "hole" (unmapped) section of virtual memory
|
|
||||||
#define VMM_HE_HEB 4 //HeapEntryBlock
|
#define VMM_HE_UNUSED 0 //available entry
|
||||||
|
#define VMM_HE_FREE 1 //free section of memory
|
||||||
#define VMM_MALLOC_GRANULARITY 4 //granularity for all memory requests
|
#define VMM_HE_USED 2 //used section of memory
|
||||||
|
#define VMM_HE_HOLE 3 //a "hole" (unmapped) section of virtual memory
|
||||||
typedef struct {
|
#define VMM_HE_HEB 4 //HeapEntryBlock
|
||||||
dword base; //virtual base address
|
|
||||||
dword size; //size in bytes
|
#define VMM_MALLOC_GRANULARITY 4 //granularity for all memory requests
|
||||||
dword attributes; //free/used/hole
|
|
||||||
dword link; //link to next HeapEntry
|
typedef struct {
|
||||||
} __attribute__((packed)) HeapEntry;
|
unsigned int base; //virtual base address
|
||||||
|
unsigned int size; //size in bytes
|
||||||
|
unsigned int attributes; //free/used/hole
|
||||||
typedef struct {
|
unsigned int link; //link to next HeapEntry
|
||||||
HeapEntry entry[256]; //256 HeapEntry objects = 4kb (1 page)
|
} __attribute__((packed)) HeapEntry;
|
||||||
} __attribute__((packed)) HeapEntryBlock;
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
void vmm_init();
|
HeapEntry entry[256]; //256 HeapEntry objects = 4kb (1 page)
|
||||||
void *malloc(dword bytes);
|
} __attribute__((packed)) HeapEntryBlock;
|
||||||
int free(void *ptr);
|
|
||||||
void vmm_map1(dword virt, dword physical);
|
|
||||||
void vmm_mapn(dword virt, dword physical, dword n);
|
void vmm_init();
|
||||||
void vmm_unmap1(dword virt);
|
void *malloc(unsigned int bytes);
|
||||||
void vmm_unmapn(dword virt, dword n);
|
int free(void *ptr);
|
||||||
void vmm_heb_init(HeapEntryBlock *heb);
|
void vmm_map1(unsigned int virt, unsigned int physical);
|
||||||
void *vmm_getFreeChunk(dword bytes);
|
void vmm_mapn(unsigned int virt, unsigned int physical, unsigned int n);
|
||||||
HeapEntry *vmm_nextHeapEntry();
|
void vmm_unmap1(unsigned int virt);
|
||||||
dword vmm_heapEntriesLeft();
|
void vmm_unmapn(unsigned int virt, unsigned int n);
|
||||||
HeapEntry *vmm_getLastHeapEntry();
|
void vmm_heb_init(HeapEntryBlock *heb);
|
||||||
HeapEntry *vmm_getFirstUnusedHeapEntry();
|
void *vmm_getFreeChunk(unsigned int bytes);
|
||||||
HeapEntry *vmm_getFirstHoleHeapEntry(dword minBytes);
|
HeapEntry *vmm_nextHeapEntry();
|
||||||
void vmm_addHeapEntryBlock();
|
unsigned int vmm_heapEntriesLeft();
|
||||||
int vmm_moreCore(dword bytes);
|
HeapEntry *vmm_getLastHeapEntry();
|
||||||
void vmm_coalesceHeapEntry(HeapEntry *he);
|
HeapEntry *vmm_getFirstUnusedHeapEntry();
|
||||||
HeapEntry *vmm_getHeapEntryByBase(dword base);
|
HeapEntry *vmm_getFirstHoleHeapEntry(unsigned int minBytes);
|
||||||
|
void vmm_addHeapEntryBlock();
|
||||||
|
int vmm_moreCore(unsigned int bytes);
|
||||||
HeapEntry *firstHeapEntry = (HeapEntry *)0xD0000000; //this is where heap memory starts
|
void vmm_coalesceHeapEntry(HeapEntry *he);
|
||||||
|
HeapEntry *vmm_getHeapEntryByBase(unsigned int base);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
88
src/kernel/string/string.c
Normal file
88
src/kernel/string/string.c
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
// string.c
|
||||||
|
// Author: Josh Holtrop
|
||||||
|
// Created: 02/26/04
|
||||||
|
// Implements string functions
|
||||||
|
|
||||||
|
#include "string.h"
|
||||||
|
|
||||||
|
char *strcat(char *dest, char *src)
|
||||||
|
{
|
||||||
|
strcpy(dest+strlen(dest), src);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Splits a string into multiple strings by turning all characters
|
||||||
|
// equal to delim into null values (string termination character)
|
||||||
|
//Returns the number of strings after the split, 1 if no delim chars
|
||||||
|
int string_split(char *str, char delim)
|
||||||
|
{
|
||||||
|
if (strlen(str) < 1)
|
||||||
|
return 0; //empty string
|
||||||
|
int count = 1;
|
||||||
|
for (; *str; str++)
|
||||||
|
{
|
||||||
|
if (*str == delim)
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
*str = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Advances a char pointer to the byte after the current string's
|
||||||
|
// null-terminating character
|
||||||
|
//Useful after calling string_split()
|
||||||
|
//Returns a pointer to the following string
|
||||||
|
char *string_advance(char *str)
|
||||||
|
{
|
||||||
|
for (; *str; str++);
|
||||||
|
return str+1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void rtrim(char *str)
|
||||||
|
{
|
||||||
|
str += strlen(str); //now points to the null character at the end of the string
|
||||||
|
str--;
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
if ((*str == ' ') || (*str == '\t') || (*str == '\n'))
|
||||||
|
*str-- = 0;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char *ucase(char *str)
|
||||||
|
{
|
||||||
|
char *ret = str;
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
if (*str == 0)
|
||||||
|
break;
|
||||||
|
if ((*str >= 'a') && (*str <= 'z'))
|
||||||
|
*str = (*str) - 32;
|
||||||
|
str++;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char *lcase(char *str)
|
||||||
|
{
|
||||||
|
char *ret = str;
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
if (*str == 0)
|
||||||
|
break;
|
||||||
|
if ((*str >= 'A') && (*str <= 'Z'))
|
||||||
|
*str = (*str) + 32;
|
||||||
|
str++;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
18
src/kernel/string/string.h
Normal file
18
src/kernel/string/string.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// strings.h
|
||||||
|
// Author: Josh Holtrop
|
||||||
|
// Created: 02/26/04
|
||||||
|
// Implements string functions
|
||||||
|
|
||||||
|
#ifndef __HOS_STRING__
|
||||||
|
#define __HOS_STRING__ __HOS_STRING__
|
||||||
|
|
||||||
|
char *strcat(char *dest, char *src);
|
||||||
|
int string_split(char *str, char delim);
|
||||||
|
char *string_advance(char *str);
|
||||||
|
void rtrim(char *str);
|
||||||
|
char *ucase(char *str);
|
||||||
|
char *lcase(char *str);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
41
src/kernel/sys/cmos.c
Normal file
41
src/kernel/sys/cmos.c
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// cmos.c
|
||||||
|
// Author: Josh Holtrop
|
||||||
|
// Created: 02/26/04
|
||||||
|
// Implements various CMOS function calls
|
||||||
|
|
||||||
|
#include "hos_defines.h"
|
||||||
|
#include "cmos.h"
|
||||||
|
|
||||||
|
//Returns the cmos type of floppy disk drive 0 (0 = not present)
|
||||||
|
unsigned char cmos_getfd0()
|
||||||
|
{
|
||||||
|
outportb(0x70, 0x10);
|
||||||
|
return (inportb(0x71) >> 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Returns the cmos type of floppy disk drive 1 (0 = not present)
|
||||||
|
unsigned char cmos_getfd1()
|
||||||
|
{
|
||||||
|
outportb(0x70, 0x10);
|
||||||
|
return (inportb(0x71) & 0x0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Returns the cmos type of hard disk drive 0 (0 = not present)
|
||||||
|
unsigned char cmos_gethd0()
|
||||||
|
{
|
||||||
|
outportb(0x70, 0x12);
|
||||||
|
return (inportb(0x71) >> 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Returns the cmos type of hard disk drive 1 (0 = not present)
|
||||||
|
unsigned char cmos_gethd1()
|
||||||
|
{
|
||||||
|
outportb(0x70, 0x12);
|
||||||
|
return (inportb(0x71) & 0x0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
18
src/kernel/sys/cmos.h
Normal file
18
src/kernel/sys/cmos.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// cmos.h
|
||||||
|
// Author: Josh Holtrop
|
||||||
|
// Created: 02/26/04
|
||||||
|
// Implements various CMOS function calls
|
||||||
|
|
||||||
|
#include "hos_defines.h"
|
||||||
|
|
||||||
|
#ifndef __HOS_CMOS__
|
||||||
|
#define __HOS_CMOS__ __HOS_CMOS__
|
||||||
|
|
||||||
|
unsigned char cmos_getfd0();
|
||||||
|
unsigned char cmos_getfd1();
|
||||||
|
unsigned char cmos_gethd0();
|
||||||
|
unsigned char cmos_gethd1();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
8
src/kernel/sys/io.c
Normal file
8
src/kernel/sys/io.c
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// io.c
|
||||||
|
// Author: Josh Holtrop
|
||||||
|
// Created: 02/26/04
|
||||||
|
// Implements basic port input/output functions
|
||||||
|
|
||||||
|
#include "io.h"
|
||||||
|
|
||||||
|
|
40
src/kernel/sys/io.h
Normal file
40
src/kernel/sys/io.h
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
// io.h
|
||||||
|
// Author: Josh Holtrop
|
||||||
|
// Created: 02/26/04
|
||||||
|
// Implements basic port input/output functions
|
||||||
|
|
||||||
|
#include "hos_defines.h"
|
||||||
|
|
||||||
|
#ifndef __HOS_IO__
|
||||||
|
#define __HOS_IO__ __HOS_IO__
|
||||||
|
|
||||||
|
inline void outportb(unsigned int port, unsigned char value);
|
||||||
|
inline void outportw(unsigned int port, unsigned int value);
|
||||||
|
inline unsigned char inportb(unsigned short port);
|
||||||
|
|
||||||
|
//Writes a byte out to a port
|
||||||
|
inline void outportb(unsigned int port, unsigned char value) // Output a byte to a port
|
||||||
|
{
|
||||||
|
asm volatile ("outb %%al,%%dx"::"d" (port), "a" (value));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Writes a word out to a port
|
||||||
|
inline void outportw(unsigned int port, unsigned int value) // Output a word to a port
|
||||||
|
{
|
||||||
|
asm volatile ("outw %%ax,%%dx"::"d" (port), "a" (value));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Reads a byte from a port
|
||||||
|
inline unsigned char inportb(unsigned short port)
|
||||||
|
{
|
||||||
|
unsigned char ret_val;
|
||||||
|
|
||||||
|
asm volatile("inb %w1,%b0"
|
||||||
|
: "=a"(ret_val)
|
||||||
|
: "d"(port));
|
||||||
|
return ret_val;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
29
src/kernel/sys/pic.c
Normal file
29
src/kernel/sys/pic.c
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// pic.c
|
||||||
|
// Author: Josh Holtrop
|
||||||
|
// Created: 02/26/04
|
||||||
|
|
||||||
|
#include "hos_defines.h"
|
||||||
|
#include "pic.h"
|
||||||
|
|
||||||
|
//Re-maps the Programmable Interrupr Controllers so IRQ0->pic1 base address, IRG8->pic2 base address
|
||||||
|
void pic_remap(int pic1, int pic2)
|
||||||
|
{
|
||||||
|
byte a1, a2;
|
||||||
|
|
||||||
|
a1 = inportb(PIC1_DATA); //0x21
|
||||||
|
a2 = inportb(PIC2_DATA); //0xA1
|
||||||
|
|
||||||
|
outportb(PIC1_COMMAND, ICW1_INIT+ICW1_ICW4); //0x20, 0x10+0x01 00010001b
|
||||||
|
outportb(PIC2_COMMAND, ICW1_INIT+ICW1_ICW4); //0xA0, 0x10+0x01 00010001b
|
||||||
|
outportb(PIC1_DATA, pic1); //0x21, pic1
|
||||||
|
outportb(PIC2_DATA, pic2); //0xA1, pic2
|
||||||
|
outportb(PIC1_DATA, 4); //0x21, 0x04 00000100b
|
||||||
|
outportb(PIC2_DATA, 2); //0xA1, 0x02 00000010b
|
||||||
|
outportb(PIC1_DATA, ICW4_8086); //0x21, 0x01 00000001b
|
||||||
|
outportb(PIC2_DATA, ICW4_8086); //0xA1, 0x01 00000001b
|
||||||
|
|
||||||
|
outportb(PIC1_DATA, a1); //0x21
|
||||||
|
outportb(PIC2_DATA, a2); //0xA1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
64
src/kernel/sys/pic.h
Normal file
64
src/kernel/sys/pic.h
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
// pic.h
|
||||||
|
// Author: Josh Holtrop
|
||||||
|
// Created: 02/26/04
|
||||||
|
|
||||||
|
#include "hos_defines.h"
|
||||||
|
|
||||||
|
#ifndef __HOS_PIC__
|
||||||
|
#define __HOS_PIC__ __HOS_PIC__
|
||||||
|
|
||||||
|
#define PIC1 0x20
|
||||||
|
#define PIC2 0xA0
|
||||||
|
#define PIC1_COMMAND PIC1
|
||||||
|
#define PIC1_DATA (PIC1+1)
|
||||||
|
#define PIC2_COMMAND PIC2
|
||||||
|
#define PIC2_DATA (PIC2+1)
|
||||||
|
#define PIC_EOI 0x20
|
||||||
|
|
||||||
|
#define ICW1_ICW4 0x01 /* ICW4 (not) needed */
|
||||||
|
#define ICW1_SINGLE 0x02 /* Single (cascade) mode */
|
||||||
|
#define ICW1_INTERVAL4 0x04 /* Call address interval 4 (8) */
|
||||||
|
#define ICW1_LEVEL 0x08 /* Level triggered (edge) mode */
|
||||||
|
#define ICW1_INIT 0x10 /* Initialization - required! */
|
||||||
|
|
||||||
|
#define ICW4_8086 0x01 /* 8086/88 (MCS-80/85) mode */
|
||||||
|
#define ICW4_AUTO 0x02 /* Auto (normal) EOI */
|
||||||
|
#define ICW4_BUF_SLAVE 0x08 /* Buffered mode/slave */
|
||||||
|
#define ICW4_BUF_MASTER 0x0C /* Buffered mode/master */
|
||||||
|
#define ICW4_SFNM 0x10 /* Special fully nested (not) */
|
||||||
|
|
||||||
|
void pic_remap(int pic1, int pic2);
|
||||||
|
inline void pic_mask1(byte mask);
|
||||||
|
inline void pic_mask2(byte mask);
|
||||||
|
inline void pic_eoi();
|
||||||
|
inline void pic_eoi2();
|
||||||
|
|
||||||
|
//Masks interrupts on first Programmable Interrupt Controller
|
||||||
|
inline void pic_mask1(byte mask)
|
||||||
|
{
|
||||||
|
outportb(PIC1_DATA, mask); //0x21, maskfield *OCW1*
|
||||||
|
}
|
||||||
|
|
||||||
|
//Masks interrupts on second Programmable Interrupt Controller
|
||||||
|
inline void pic_mask2(byte mask)
|
||||||
|
{
|
||||||
|
outportb(PIC2_DATA, mask); //0xA1, maskfield *OCW1*
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Signals an End Of Interrupt signal to the first PIC
|
||||||
|
inline void pic_eoi()
|
||||||
|
{
|
||||||
|
outportb(0x20, 0x20);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Signals an End Of Interrupt signal to both the second and first PIC unit
|
||||||
|
inline void pic_eoi2()
|
||||||
|
{
|
||||||
|
outportb(0xA0, 0x20);
|
||||||
|
outportb(0x20, 0x20);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
82
src/kernel/sys/rtc.c
Normal file
82
src/kernel/sys/rtc.c
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
// rtc.c
|
||||||
|
// Author: Josh Holtrop
|
||||||
|
// Created: 02/26/04
|
||||||
|
// Implements Real-Time Clock function calls
|
||||||
|
// These functions are for reading and writing various values stored on the CMOS Real Time Clock
|
||||||
|
// Parameters / return values are in BCD format
|
||||||
|
|
||||||
|
#include "hos_defines.h"
|
||||||
|
#include "rtc.h"
|
||||||
|
|
||||||
|
unsigned char rtc_readDay()
|
||||||
|
{
|
||||||
|
outportb(0x70, 7);
|
||||||
|
return inportb(0x71);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char rtc_readMonth()
|
||||||
|
{
|
||||||
|
outportb(0x70, 8);
|
||||||
|
return inportb(0x71);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char rtc_readYear()
|
||||||
|
{
|
||||||
|
outportb(0x70, 9);
|
||||||
|
return inportb(0x71);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char rtc_readSecond()
|
||||||
|
{
|
||||||
|
outportb(0x70, 0);
|
||||||
|
return inportb(0x71);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char rtc_readMinute()
|
||||||
|
{
|
||||||
|
outportb(0x70, 2);
|
||||||
|
return inportb(0x71);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char rtc_readHour()
|
||||||
|
{
|
||||||
|
outportb(0x70, 4);
|
||||||
|
return inportb(0x71);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtc_setDay(unsigned char day)
|
||||||
|
{
|
||||||
|
outportb(0x70, 7);
|
||||||
|
outportb(0x71, day);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtc_setMonth(unsigned char month)
|
||||||
|
{
|
||||||
|
outportb(0x70, 8);
|
||||||
|
outportb(0x71, month);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtc_setYear(unsigned char year)
|
||||||
|
{
|
||||||
|
outportb(0x70, 9);
|
||||||
|
outportb(0x71, year);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtc_setSecond(unsigned char second)
|
||||||
|
{
|
||||||
|
outportb(0x70, 0);
|
||||||
|
outportb(0x71, second);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtc_setMinute(unsigned char minute)
|
||||||
|
{
|
||||||
|
outportb(0x70, 2);
|
||||||
|
outportb(0x71, minute);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtc_setHour(unsigned char hour)
|
||||||
|
{
|
||||||
|
outportb(0x70, 4);
|
||||||
|
outportb(0x71, hour);
|
||||||
|
}
|
||||||
|
|
28
src/kernel/sys/rtc.h
Normal file
28
src/kernel/sys/rtc.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// rtc.h
|
||||||
|
// Author: Josh Holtrop
|
||||||
|
// Created: 02/26/04
|
||||||
|
// Implements Real-Time Clock function calls
|
||||||
|
// These functions are for reading and writing various values stored on the CMOS Real Time Clock
|
||||||
|
// Parameters / return values are in BCD format
|
||||||
|
|
||||||
|
#include "hos_defines.h"
|
||||||
|
|
||||||
|
#ifndef __HOS_RTC__
|
||||||
|
#define __HOS_RTC__ __HOS_RTC__
|
||||||
|
|
||||||
|
unsigned char rtc_readDay();
|
||||||
|
unsigned char rtc_readMonth();
|
||||||
|
unsigned char rtc_readYear();
|
||||||
|
unsigned char rtc_readSecond();
|
||||||
|
unsigned char rtc_readMinute();
|
||||||
|
unsigned char rtc_readHour();
|
||||||
|
void rtc_setDay(unsigned char dat);
|
||||||
|
void rtc_setMonth(unsigned char month);
|
||||||
|
void rtc_setYear(unsigned char year);
|
||||||
|
void rtc_setSecond(unsigned char second);
|
||||||
|
void rtc_setMinute(unsigned char minute);
|
||||||
|
void rtc_setHour(unsigned char hour);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
545
src/kernel/video/stdfont.c
Normal file
545
src/kernel/video/stdfont.c
Normal file
@ -0,0 +1,545 @@
|
|||||||
|
// stdfont.c
|
||||||
|
// Author: Josh Holtrop
|
||||||
|
// Created: 02/26/04
|
||||||
|
|
||||||
|
#include "stdfont.h"
|
||||||
|
|
||||||
|
const unsigned char stdfont8x5[] = {
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xE0, 0xC0, 0x80,
|
||||||
|
0x00, 0x08, 0x18, 0x38, 0x78, 0x38, 0x18, 0x08,
|
||||||
|
0x00, 0x20, 0x70, 0xA8, 0x20, 0xA8, 0x70, 0x20,
|
||||||
|
0x00, 0xA0, 0xA0, 0xA0, 0xA0, 0x00, 0xA0, 0xA0,
|
||||||
|
0x00, 0x78, 0xA8, 0xA8, 0x78, 0x28, 0x28, 0x68,
|
||||||
|
0x00, 0x78, 0x80, 0x70, 0x88, 0x70, 0x08, 0xF0,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xF8,
|
||||||
|
0x00, 0x20, 0x70, 0xA8, 0x20, 0xA8, 0x70, 0xF8,
|
||||||
|
0x00, 0x20, 0x70, 0xA8, 0x20, 0x20, 0x20, 0x20,
|
||||||
|
0x00, 0x20, 0x20, 0x20, 0x20, 0xA8, 0x70, 0x20,
|
||||||
|
0x00, 0x00, 0x20, 0x10, 0xF8, 0x10, 0x20, 0x00,
|
||||||
|
0x00, 0x00, 0x20, 0x40, 0xF8, 0x40, 0x20, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x60, 0x90, 0x60, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x20, 0x70, 0xF8, 0xF8, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0xF8, 0xF8, 0x70, 0x20, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x20, 0x20, 0x20, 0x20, 0x00, 0x20, 0x20,
|
||||||
|
0x00, 0x50, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x50, 0xF8, 0x50, 0x50, 0x50, 0xF8, 0x50,
|
||||||
|
0x00, 0x20, 0x78, 0xA0, 0x70, 0x28, 0xF0, 0x20,
|
||||||
|
0x00, 0x00, 0x08, 0x90, 0x20, 0x48, 0x80, 0x00,
|
||||||
|
0x00, 0x20, 0x50, 0x50, 0x20, 0x58, 0x90, 0x68,
|
||||||
|
0x00, 0x40, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x20, 0x40, 0x40, 0x40, 0x40, 0x40, 0x20,
|
||||||
|
0x00, 0x40, 0x20, 0x20, 0x20, 0x20, 0x20, 0x40,
|
||||||
|
0x00, 0x00, 0xA8, 0x70, 0xF8, 0x70, 0xA8, 0x00,
|
||||||
|
0x00, 0x00, 0x20, 0x20, 0xF8, 0x20, 0x20, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x40,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60,
|
||||||
|
0x00, 0x00, 0x08, 0x10, 0x20, 0x40, 0x80, 0x00,
|
||||||
|
0x00, 0x70, 0x88, 0x88, 0x88, 0x88, 0x88, 0x70,
|
||||||
|
0x00, 0x20, 0x60, 0xA0, 0x20, 0x20, 0x20, 0x20,
|
||||||
|
0x00, 0x70, 0x88, 0x08, 0x10, 0x20, 0x40, 0xF8,
|
||||||
|
0x00, 0x70, 0x88, 0x08, 0x10, 0x08, 0x88, 0x70,
|
||||||
|
0x00, 0x30, 0x50, 0x90, 0x90, 0xF8, 0x10, 0x10,
|
||||||
|
0x00, 0xF8, 0x80, 0x80, 0xF8, 0x08, 0x88, 0x70,
|
||||||
|
0x00, 0x38, 0x40, 0x80, 0xF0, 0x88, 0x88, 0x70,
|
||||||
|
0x00, 0xF8, 0x08, 0x10, 0x20, 0x40, 0x40, 0x40,
|
||||||
|
0x00, 0x70, 0x88, 0x88, 0x70, 0x88, 0x88, 0x70,
|
||||||
|
0x00, 0x70, 0x88, 0x88, 0x78, 0x08, 0x10, 0x60,
|
||||||
|
0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x60, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x60, 0x40,
|
||||||
|
0x00, 0x10, 0x20, 0x40, 0x80, 0x40, 0x20, 0x10,
|
||||||
|
0x00, 0x00, 0x00, 0xF0, 0x00, 0xF0, 0x00, 0x00,
|
||||||
|
0x00, 0x80, 0x40, 0x20, 0x10, 0x20, 0x40, 0x80,
|
||||||
|
0x00, 0x70, 0x88, 0x08, 0x10, 0x20, 0x00, 0x20,
|
||||||
|
0x00, 0x70, 0x88, 0x88, 0xB8, 0xB0, 0x80, 0x78,
|
||||||
|
0x00, 0x70, 0x88, 0x88, 0xF8, 0x88, 0x88, 0x88,
|
||||||
|
0x00, 0xF0, 0x88, 0x88, 0xF0, 0x88, 0x88, 0xF0,
|
||||||
|
0x00, 0x70, 0x88, 0x80, 0x80, 0x80, 0x88, 0x70,
|
||||||
|
0x00, 0xF0, 0x88, 0x88, 0x88, 0x88, 0x88, 0xF0,
|
||||||
|
0x00, 0xF8, 0x80, 0x80, 0xF0, 0x80, 0x80, 0xF8,
|
||||||
|
0x00, 0xF8, 0x80, 0x80, 0xF0, 0x80, 0x80, 0x80,
|
||||||
|
0x00, 0x70, 0x88, 0x80, 0xB8, 0x88, 0x88, 0x70,
|
||||||
|
0x00, 0x88, 0x88, 0x88, 0xF8, 0x88, 0x88, 0x88,
|
||||||
|
0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||||
|
0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x90, 0x60,
|
||||||
|
0x00, 0x88, 0x90, 0xA0, 0xC0, 0xA0, 0x90, 0x88,
|
||||||
|
0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xF8,
|
||||||
|
0x00, 0x88, 0xD8, 0xA8, 0x88, 0x88, 0x88, 0x88,
|
||||||
|
0x00, 0x88, 0xC8, 0xE8, 0xB8, 0x98, 0x88, 0x88,
|
||||||
|
0x00, 0x70, 0x88, 0x88, 0x88, 0x88, 0x88, 0x70,
|
||||||
|
0x00, 0xF0, 0x88, 0x88, 0xF0, 0x80, 0x80, 0x80,
|
||||||
|
0x00, 0x70, 0x88, 0x88, 0x88, 0xA8, 0x98, 0x70,
|
||||||
|
0x00, 0xF0, 0x88, 0x88, 0xF0, 0xA0, 0x90, 0x88,
|
||||||
|
0x00, 0x70, 0x88, 0x80, 0x70, 0x08, 0x88, 0x70,
|
||||||
|
0x00, 0xF8, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||||
|
0x00, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x70,
|
||||||
|
0x00, 0x88, 0x88, 0x88, 0x88, 0x88, 0x50, 0x20,
|
||||||
|
0x00, 0x88, 0x88, 0x88, 0x88, 0x88, 0xA8, 0x50,
|
||||||
|
0x00, 0x88, 0x50, 0x20, 0x20, 0x50, 0x88, 0x88,
|
||||||
|
0x00, 0x88, 0x88, 0x50, 0x20, 0x20, 0x20, 0x20,
|
||||||
|
0x00, 0xF8, 0x08, 0x10, 0x20, 0x40, 0x80, 0xF8,
|
||||||
|
0x00, 0x70, 0x40, 0x40, 0x40, 0x40, 0x40, 0x70,
|
||||||
|
0x00, 0x80, 0xC0, 0x60, 0x30, 0x18, 0x08, 0x00,
|
||||||
|
0x00, 0xE0, 0x20, 0x20, 0x20, 0x20, 0x20, 0xE0,
|
||||||
|
0x00, 0x20, 0x50, 0x88, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8,
|
||||||
|
0x00, 0x60, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x70, 0x08, 0x78, 0x88, 0x78,
|
||||||
|
0x00, 0x80, 0x80, 0xF0, 0x88, 0x88, 0x88, 0xF0,
|
||||||
|
0x00, 0x00, 0x00, 0x70, 0x88, 0x80, 0x88, 0x70,
|
||||||
|
0x00, 0x08, 0x08, 0x78, 0x88, 0x88, 0x88, 0x78,
|
||||||
|
0x00, 0x00, 0x00, 0x70, 0x88, 0xF8, 0x80, 0x78,
|
||||||
|
0x00, 0x30, 0x40, 0x40, 0xE0, 0x40, 0x40, 0x40,
|
||||||
|
0x00, 0x00, 0x00, 0x78, 0x88, 0x78, 0x08, 0x70,
|
||||||
|
0x00, 0x80, 0x80, 0xF0, 0x88, 0x88, 0x88, 0x88,
|
||||||
|
0x00, 0x20, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||||
|
0x00, 0x10, 0x00, 0x10, 0x10, 0x10, 0x90, 0x60,
|
||||||
|
0x00, 0x80, 0x80, 0x90, 0xA0, 0xC0, 0xA0, 0x90,
|
||||||
|
0x00, 0xC0, 0x40, 0x40, 0x40, 0x40, 0x40, 0xE0,
|
||||||
|
0x00, 0x00, 0x00, 0xD0, 0xA8, 0xA8, 0xA8, 0xA8,
|
||||||
|
0x00, 0x00, 0x00, 0xF0, 0x88, 0x88, 0x88, 0x88,
|
||||||
|
0x00, 0x00, 0x00, 0x70, 0x88, 0x88, 0x88, 0x70,
|
||||||
|
0x00, 0x00, 0x00, 0xF0, 0x88, 0xF0, 0x80, 0x80,
|
||||||
|
0x00, 0x00, 0x00, 0x78, 0x88, 0x78, 0x08, 0x38,
|
||||||
|
0x00, 0x00, 0x00, 0x70, 0x48, 0x40, 0x40, 0x40,
|
||||||
|
0x00, 0x00, 0x00, 0x78, 0x80, 0x70, 0x08, 0xF0,
|
||||||
|
0x00, 0x40, 0x40, 0xE0, 0x40, 0x40, 0x40, 0x20,
|
||||||
|
0x00, 0x00, 0x00, 0x88, 0x88, 0x88, 0x88, 0x78,
|
||||||
|
0x00, 0x00, 0x00, 0x88, 0x88, 0x88, 0x50, 0x20,
|
||||||
|
0x00, 0x00, 0x00, 0x88, 0x88, 0x88, 0xA8, 0x50,
|
||||||
|
0x00, 0x00, 0x00, 0x88, 0x50, 0x20, 0x50, 0x88,
|
||||||
|
0x00, 0x00, 0x00, 0x88, 0x88, 0x78, 0x08, 0xF0,
|
||||||
|
0x00, 0x00, 0x00, 0xF8, 0x10, 0x20, 0x40, 0xF8,
|
||||||
|
0x00, 0x30, 0x40, 0x40, 0x80, 0x40, 0x40, 0x30,
|
||||||
|
0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||||
|
0x00, 0xC0, 0x20, 0x20, 0x10, 0x20, 0x20, 0xC0,
|
||||||
|
0x00, 0x00, 0x68, 0x90, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x70, 0x88, 0x88, 0xF8, 0x88, 0x88, 0x88,
|
||||||
|
0x00, 0xF8, 0x88, 0x80, 0xF0, 0x88, 0x88, 0xF0,
|
||||||
|
0x00, 0xF0, 0x88, 0x88, 0xF0, 0x88, 0x88, 0xF0,
|
||||||
|
0x00, 0xF8, 0x48, 0x40, 0x40, 0x40, 0x40, 0xE0,
|
||||||
|
0x00, 0xF0, 0x50, 0x50, 0x50, 0x50, 0x78, 0x88,
|
||||||
|
0x00, 0xF8, 0x80, 0x80, 0xF0, 0x80, 0x80, 0xF8,
|
||||||
|
0x00, 0xA8, 0xA8, 0x70, 0x20, 0x70, 0xA8, 0xA8,
|
||||||
|
0x00, 0x70, 0x88, 0x08, 0x30, 0x08, 0x88, 0x70,
|
||||||
|
0x00, 0x88, 0x98, 0xA8, 0xA8, 0xA8, 0xC8, 0x88,
|
||||||
|
0x00, 0xA8, 0xC8, 0x98, 0xA8, 0xA8, 0xC8, 0x88,
|
||||||
|
0x00, 0x88, 0x90, 0xA0, 0xC0, 0xA0, 0x90, 0x88,
|
||||||
|
0x00, 0xF8, 0x50, 0x50, 0x50, 0x50, 0x50, 0x90,
|
||||||
|
0x00, 0x88, 0xD8, 0xA8, 0x88, 0x88, 0x88, 0x88,
|
||||||
|
0x00, 0x88, 0x88, 0x88, 0xF8, 0x88, 0x88, 0x88,
|
||||||
|
0x00, 0x70, 0x88, 0x88, 0x88, 0x88, 0x88, 0x70,
|
||||||
|
0x00, 0xF8, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
|
||||||
|
0x00, 0xF0, 0x88, 0x88, 0xF0, 0x80, 0x80, 0x80,
|
||||||
|
0x00, 0x70, 0x88, 0x80, 0x80, 0x80, 0x88, 0x70,
|
||||||
|
0x00, 0xF8, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||||
|
0x00, 0x88, 0x88, 0x88, 0x50, 0x20, 0x40, 0x80,
|
||||||
|
0x00, 0x70, 0x20, 0xF8, 0xA8, 0xF8, 0x20, 0x70,
|
||||||
|
0x00, 0x88, 0x88, 0x50, 0x20, 0x50, 0x88, 0x88,
|
||||||
|
0x00, 0x88, 0x88, 0x88, 0x88, 0x88, 0xF8, 0x08,
|
||||||
|
0x00, 0x88, 0x88, 0x88, 0xF8, 0x08, 0x08, 0x38,
|
||||||
|
0x00, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xF8,
|
||||||
|
0x00, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xF8, 0x08,
|
||||||
|
0x00, 0xC0, 0x40, 0x40, 0x78, 0x48, 0x48, 0x78,
|
||||||
|
0x00, 0x88, 0x88, 0xC8, 0xA8, 0xA8, 0xA8, 0xE8,
|
||||||
|
0x00, 0x80, 0x80, 0xF0, 0x88, 0x88, 0x88, 0xF0,
|
||||||
|
0x00, 0xF0, 0x88, 0x08, 0x78, 0x08, 0x88, 0xF0,
|
||||||
|
0x00, 0x90, 0xA8, 0xA8, 0xE8, 0xA8, 0xA8, 0x90,
|
||||||
|
0x00, 0x78, 0x88, 0x88, 0x78, 0x28, 0x48, 0x88,
|
||||||
|
0x00, 0x00, 0x70, 0x08, 0x78, 0x88, 0x88, 0x78,
|
||||||
|
0x00, 0x00, 0xF8, 0x80, 0xF0, 0x88, 0x88, 0xF0,
|
||||||
|
0x00, 0x00, 0xF0, 0x88, 0xF0, 0x88, 0x88, 0xF0,
|
||||||
|
0x00, 0x00, 0xF8, 0x48, 0x48, 0x40, 0x40, 0xE0,
|
||||||
|
0x00, 0x00, 0x78, 0x50, 0x50, 0x50, 0x70, 0x88,
|
||||||
|
0x00, 0x00, 0x70, 0x88, 0xF8, 0x80, 0x88, 0x70,
|
||||||
|
0x00, 0x00, 0xA8, 0x70, 0x20, 0x70, 0xA8, 0xA8,
|
||||||
|
0x00, 0x00, 0x00, 0xF0, 0x88, 0x30, 0x88, 0x70,
|
||||||
|
0x00, 0x00, 0x88, 0x98, 0xA8, 0xC8, 0x88, 0x88,
|
||||||
|
0x00, 0x50, 0x20, 0x88, 0x98, 0xA8, 0xC8, 0x88,
|
||||||
|
0x00, 0x00, 0x88, 0x90, 0xA0, 0xE0, 0x90, 0x88,
|
||||||
|
0x00, 0x00, 0xF8, 0x48, 0x48, 0x48, 0x48, 0xC8,
|
||||||
|
0x00, 0x00, 0x88, 0xD8, 0xA8, 0x88, 0x88, 0x88,
|
||||||
|
0x00, 0x00, 0x88, 0x88, 0xF8, 0x88, 0x88, 0x88,
|
||||||
|
0x00, 0x00, 0x70, 0x88, 0x88, 0x88, 0x88, 0x70,
|
||||||
|
0x00, 0x00, 0xF8, 0x88, 0x88, 0x88, 0x88, 0x88,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x70, 0x50, 0x70, 0x08, 0x78, 0x88, 0x78,
|
||||||
|
0x00, 0x88, 0x00, 0x70, 0x08, 0x78, 0x88, 0x78,
|
||||||
|
0x00, 0x88, 0x00, 0x70, 0x88, 0x88, 0x88, 0x70,
|
||||||
|
0x00, 0x88, 0x00, 0x88, 0x88, 0x88, 0x88, 0x78,
|
||||||
|
0x00, 0x90, 0x00, 0xF0, 0x80, 0xE0, 0x80, 0xF0,
|
||||||
|
0x00, 0x00, 0x70, 0x48, 0x70, 0x48, 0x48, 0xF0,
|
||||||
|
0x00, 0x88, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||||
|
0x00, 0x88, 0x00, 0x70, 0x88, 0xF8, 0x80, 0x78,
|
||||||
|
0x00, 0x70, 0x50, 0x70, 0x88, 0xF8, 0x88, 0x88,
|
||||||
|
0x00, 0x88, 0x70, 0x88, 0x88, 0xF8, 0x88, 0x88,
|
||||||
|
0x00, 0x88, 0x70, 0x88, 0x88, 0x88, 0x88, 0x70,
|
||||||
|
0x00, 0x88, 0x00, 0x88, 0x88, 0x88, 0x88, 0x78,
|
||||||
|
0x00, 0x88, 0xF8, 0x80, 0xE0, 0x80, 0x80, 0xF8,
|
||||||
|
0x00, 0x40, 0x20, 0x70, 0x88, 0xF8, 0x80, 0x78,
|
||||||
|
0x00, 0x10, 0x20, 0x70, 0x88, 0xF8, 0x80, 0x78,
|
||||||
|
0x00, 0x20, 0x50, 0x70, 0x88, 0xF8, 0x80, 0x78,
|
||||||
|
0x00, 0x40, 0x20, 0x70, 0x08, 0x78, 0x88, 0x78,
|
||||||
|
0x00, 0x20, 0x50, 0x00, 0x20, 0x20, 0x20, 0x20,
|
||||||
|
0x00, 0x20, 0x10, 0x88, 0x88, 0x88, 0x88, 0x78,
|
||||||
|
0x00, 0x00, 0x00, 0x70, 0x80, 0x80, 0x70, 0x20,
|
||||||
|
0x00, 0x70, 0x88, 0x40, 0xF0, 0x40, 0x40, 0xF8,
|
||||||
|
0x00, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x88, 0x88, 0x88, 0xF0, 0x80, 0x80,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0xF0, 0x88, 0x88, 0xF0, 0x80, 0x80,
|
||||||
|
0x00, 0x00, 0x70, 0x88, 0x80, 0x80, 0x88, 0x70,
|
||||||
|
0x00, 0x00, 0xF8, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||||
|
0x00, 0x00, 0x88, 0x88, 0x50, 0x20, 0x40, 0x80,
|
||||||
|
0x00, 0x00, 0x70, 0x20, 0xF8, 0xF8, 0x20, 0x70,
|
||||||
|
0x00, 0x00, 0x88, 0x50, 0x20, 0x50, 0x88, 0x88,
|
||||||
|
0x00, 0x00, 0x88, 0x88, 0x88, 0x88, 0xF8, 0x08,
|
||||||
|
0x00, 0x00, 0x88, 0x88, 0x88, 0xF8, 0x08, 0x38,
|
||||||
|
0x00, 0x00, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xF8,
|
||||||
|
0x00, 0x00, 0xA8, 0xA8, 0xA8, 0xA8, 0xF8, 0x08,
|
||||||
|
0x00, 0x00, 0xC0, 0x40, 0x70, 0x48, 0x48, 0x70,
|
||||||
|
0x00, 0x00, 0x88, 0x88, 0xC8, 0xA8, 0xA8, 0xE8,
|
||||||
|
0x00, 0x00, 0x80, 0x80, 0xF0, 0x88, 0x88, 0xF0,
|
||||||
|
0x00, 0x00, 0x70, 0x88, 0x38, 0x08, 0x88, 0x70,
|
||||||
|
0x00, 0x00, 0x90, 0xA8, 0xA8, 0xE8, 0xA8, 0x90,
|
||||||
|
0x00, 0x00, 0x38, 0x48, 0x48, 0x38, 0x28, 0x48,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||||
|
|
||||||
|
const unsigned char stdfont10x7[] = {
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x80, 0xE0, 0xF0, 0xFC, 0xF0, 0xE0, 0x80, 0x00, 0x00,
|
||||||
|
0x00, 0x02, 0x0E, 0x1E, 0x7E, 0x1E, 0x0E, 0x02, 0x00, 0x00,
|
||||||
|
0x00, 0x10, 0x7C, 0x92, 0x10, 0x92, 0x7C, 0x10, 0x00, 0x00,
|
||||||
|
0x00, 0x90, 0x90, 0x90, 0x90, 0x00, 0x90, 0x90, 0x00, 0x00,
|
||||||
|
0x00, 0x7E, 0x92, 0x92, 0x7E, 0x12, 0x12, 0x72, 0x00, 0x00,
|
||||||
|
0x00, 0x7E, 0x80, 0x7C, 0x82, 0x7C, 0x02, 0xFC, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0x00, 0x00,
|
||||||
|
0x00, 0x10, 0x7C, 0x92, 0x10, 0x92, 0x7C, 0xFE, 0x00, 0x00,
|
||||||
|
0x00, 0x10, 0x7C, 0x92, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00,
|
||||||
|
0x00, 0x10, 0x10, 0x10, 0x10, 0x92, 0x7C, 0x10, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x08, 0x04, 0xFE, 0x04, 0x08, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x20, 0x40, 0xFE, 0x40, 0x20, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x70, 0x88, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x10, 0x7C, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0xFE, 0xFE, 0x7C, 0x10, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00,
|
||||||
|
0x00, 0x6C, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x44, 0xFE, 0x44, 0x44, 0x44, 0xFE, 0x44, 0x00, 0x00,
|
||||||
|
0x00, 0x10, 0x7E, 0x90, 0x7C, 0x12, 0xFC, 0x10, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x04, 0x88, 0x10, 0x22, 0x40, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x38, 0x44, 0x44, 0x78, 0x86, 0x84, 0x7A, 0x00, 0x00,
|
||||||
|
0x00, 0x40, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x10, 0x20, 0x40, 0x40, 0x40, 0x20, 0x10, 0x00, 0x00,
|
||||||
|
0x00, 0x40, 0x20, 0x10, 0x10, 0x10, 0x20, 0x40, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x10, 0x54, 0x38, 0x54, 0x10, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x10, 0x10, 0x7C, 0x10, 0x10, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x20, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x7C, 0x82, 0x82, 0x82, 0x82, 0x82, 0x7C, 0x00, 0x00,
|
||||||
|
0x00, 0x10, 0x30, 0x50, 0x10, 0x10, 0x10, 0x38, 0x00, 0x00,
|
||||||
|
0x00, 0x7C, 0x82, 0x02, 0x7C, 0x80, 0x80, 0xFE, 0x00, 0x00,
|
||||||
|
0x00, 0x7C, 0x82, 0x02, 0x0C, 0x02, 0x82, 0x7C, 0x00, 0x00,
|
||||||
|
0x00, 0x38, 0x48, 0x88, 0x88, 0xFE, 0x08, 0x08, 0x00, 0x00,
|
||||||
|
0x00, 0xFE, 0x80, 0x80, 0xFE, 0x02, 0x82, 0x7C, 0x00, 0x00,
|
||||||
|
0x00, 0x3E, 0x40, 0x80, 0xFC, 0x82, 0x82, 0x7C, 0x00, 0x00,
|
||||||
|
0x00, 0xFE, 0x02, 0x04, 0x08, 0x10, 0x20, 0x20, 0x00, 0x00,
|
||||||
|
0x00, 0x7C, 0x82, 0x82, 0x7C, 0x82, 0x82, 0x7C, 0x00, 0x00,
|
||||||
|
0x00, 0x7C, 0x82, 0x82, 0x7E, 0x02, 0x02, 0x7C, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x70, 0x60, 0x00, 0x00,
|
||||||
|
0x00, 0x08, 0x10, 0x20, 0x40, 0x20, 0x10, 0x08, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x40, 0x20, 0x10, 0x08, 0x10, 0x20, 0x40, 0x00, 0x00,
|
||||||
|
0x00, 0x7C, 0x82, 0x02, 0x0C, 0x10, 0x00, 0x10, 0x00, 0x00,
|
||||||
|
0x00, 0x7C, 0x82, 0x82, 0x9A, 0x9C, 0x80, 0x7E, 0x00, 0x00,
|
||||||
|
0x00, 0x7C, 0x82, 0x82, 0xFE, 0x82, 0x82, 0x82, 0x00, 0x00,
|
||||||
|
0x00, 0xFC, 0x82, 0x82, 0xFC, 0x82, 0x82, 0xFC, 0x00, 0x00,
|
||||||
|
0x00, 0x7C, 0x82, 0x80, 0x80, 0x80, 0x82, 0x7C, 0x00, 0x00,
|
||||||
|
0x00, 0xFC, 0x82, 0x82, 0x82, 0x82, 0x82, 0xFC, 0x00, 0x00,
|
||||||
|
0x00, 0xFE, 0x80, 0x80, 0xFC, 0x80, 0x80, 0xFE, 0x00, 0x00,
|
||||||
|
0x00, 0xFE, 0x80, 0x80, 0xFC, 0x80, 0x80, 0x80, 0x00, 0x00,
|
||||||
|
0x00, 0x7C, 0x82, 0x80, 0x9E, 0x82, 0x82, 0x7C, 0x00, 0x00,
|
||||||
|
0x00, 0x82, 0x82, 0x82, 0xFE, 0x82, 0x82, 0x82, 0x00, 0x00,
|
||||||
|
0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00,
|
||||||
|
0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x82, 0x7C, 0x00, 0x00,
|
||||||
|
0x00, 0x84, 0x88, 0x90, 0xE0, 0x90, 0x88, 0x84, 0x00, 0x00,
|
||||||
|
0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xFE, 0x00, 0x00,
|
||||||
|
0x00, 0x82, 0xEE, 0x92, 0x82, 0x82, 0x82, 0x82, 0x00, 0x00,
|
||||||
|
0x00, 0x82, 0xC2, 0xA2, 0x92, 0x8A, 0x86, 0x82, 0x00, 0x00,
|
||||||
|
0x00, 0x7C, 0x82, 0x82, 0x82, 0x82, 0x82, 0x7C, 0x00, 0x00,
|
||||||
|
0x00, 0xFC, 0x82, 0x82, 0xFC, 0x80, 0x80, 0x80, 0x00, 0x00,
|
||||||
|
0x00, 0x7C, 0x82, 0x82, 0x82, 0x92, 0x8A, 0x7C, 0x00, 0x00,
|
||||||
|
0x00, 0xFC, 0x82, 0x82, 0xFC, 0x88, 0x84, 0x82, 0x00, 0x00,
|
||||||
|
0x00, 0x7C, 0x82, 0x80, 0x7C, 0x02, 0x82, 0x7C, 0x00, 0x00,
|
||||||
|
0x00, 0xFE, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00,
|
||||||
|
0x00, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x7C, 0x00, 0x00,
|
||||||
|
0x00, 0x82, 0x82, 0x82, 0x82, 0x44, 0x28, 0x10, 0x00, 0x00,
|
||||||
|
0x00, 0x82, 0x82, 0x82, 0x82, 0x92, 0x92, 0x6C, 0x00, 0x00,
|
||||||
|
0x00, 0x82, 0x44, 0x28, 0x10, 0x28, 0x44, 0x82, 0x00, 0x00,
|
||||||
|
0x00, 0x82, 0x82, 0x44, 0x28, 0x10, 0x10, 0x10, 0x00, 0x00,
|
||||||
|
0x00, 0xFE, 0x02, 0x0C, 0x10, 0x60, 0x80, 0xFE, 0x00, 0x00,
|
||||||
|
0x00, 0x78, 0x40, 0x40, 0x40, 0x40, 0x40, 0x78, 0x00, 0x00,
|
||||||
|
0x00, 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x78, 0x08, 0x08, 0x08, 0x08, 0x08, 0x78, 0x00, 0x00,
|
||||||
|
0x00, 0x10, 0x28, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00,
|
||||||
|
0x00, 0x70, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x7C, 0x02, 0x7E, 0x82, 0x7E, 0x00, 0x00,
|
||||||
|
0x00, 0x80, 0x80, 0xFC, 0x82, 0x82, 0x82, 0xFC, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x7C, 0x82, 0x80, 0x82, 0x7C, 0x00, 0x00,
|
||||||
|
0x00, 0x02, 0x02, 0x7E, 0x82, 0x82, 0x82, 0x7E, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x7C, 0x82, 0xFE, 0x80, 0x7E, 0x00, 0x00,
|
||||||
|
0x00, 0x30, 0x40, 0x40, 0xE0, 0x40, 0x40, 0x40, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x7E, 0x82, 0x82, 0x82, 0x7E, 0x02, 0x7C,
|
||||||
|
0x00, 0x80, 0x80, 0xF8, 0x84, 0x84, 0x84, 0x84, 0x00, 0x00,
|
||||||
|
0x00, 0x40, 0x00, 0xC0, 0x40, 0x40, 0x40, 0xE0, 0x00, 0x00,
|
||||||
|
0x00, 0x10, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x90, 0x60,
|
||||||
|
0x00, 0x80, 0x80, 0x88, 0xB0, 0xC0, 0xB0, 0x88, 0x00, 0x00,
|
||||||
|
0x00, 0xC0, 0x40, 0x40, 0x40, 0x40, 0x40, 0xE0, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0xEC, 0x92, 0x92, 0x92, 0x92, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0xF8, 0x84, 0x84, 0x84, 0x84, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x7C, 0x82, 0x82, 0x82, 0x7C, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0xFC, 0x82, 0x82, 0x82, 0xFC, 0x80, 0x80,
|
||||||
|
0x00, 0x00, 0x00, 0x7C, 0x84, 0x84, 0x84, 0x7C, 0x04, 0x3C,
|
||||||
|
0x00, 0x00, 0x00, 0xB8, 0x44, 0x40, 0x40, 0x40, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x7C, 0x80, 0x78, 0x04, 0xF8, 0x00, 0x00,
|
||||||
|
0x00, 0x40, 0x40, 0xE0, 0x40, 0x40, 0x40, 0x20, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x84, 0x84, 0x84, 0x84, 0x7C, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x82, 0x82, 0x44, 0x28, 0x10, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x82, 0x82, 0x82, 0x92, 0x6C, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x88, 0x50, 0x20, 0x50, 0x88, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x84, 0x84, 0x84, 0x84, 0x7C, 0x04, 0xF8,
|
||||||
|
0x00, 0x00, 0x00, 0xF8, 0x10, 0x20, 0x40, 0xF8, 0x00, 0x00,
|
||||||
|
0x00, 0x18, 0x20, 0x20, 0x40, 0x20, 0x20, 0x18, 0x00, 0x00,
|
||||||
|
0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00,
|
||||||
|
0x00, 0x60, 0x10, 0x10, 0x08, 0x10, 0x10, 0x60, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x72, 0x8C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x7C, 0x82, 0x82, 0xFE, 0x82, 0x82, 0x82, 0x00, 0x00,
|
||||||
|
0x00, 0xFE, 0x82, 0x80, 0xFC, 0x82, 0x82, 0xFC, 0x00, 0x00,
|
||||||
|
0x00, 0xFC, 0x82, 0x82, 0xFC, 0x82, 0x82, 0xFC, 0x00, 0x00,
|
||||||
|
0x00, 0xFE, 0x62, 0x60, 0x60, 0x60, 0x60, 0xF0, 0x00, 0x00,
|
||||||
|
0x00, 0xFC, 0x6C, 0x6C, 0x6C, 0x6C, 0x7E, 0x82, 0x00, 0x00,
|
||||||
|
0x00, 0xFE, 0x80, 0x80, 0xFC, 0x80, 0x80, 0xFE, 0x00, 0x00,
|
||||||
|
0x00, 0x92, 0x92, 0x7C, 0x10, 0x7C, 0x92, 0x92, 0x00, 0x00,
|
||||||
|
0x00, 0x7C, 0x82, 0x02, 0x1C, 0x02, 0x82, 0x7C, 0x00, 0x00,
|
||||||
|
0x00, 0x82, 0x8E, 0x92, 0x92, 0x92, 0xE2, 0x82, 0x00, 0x00,
|
||||||
|
0x00, 0x92, 0xE2, 0x8E, 0x92, 0x92, 0xE2, 0x82, 0x00, 0x00,
|
||||||
|
0x00, 0x82, 0x8C, 0x90, 0xE0, 0x90, 0x8C, 0x82, 0x00, 0x00,
|
||||||
|
0x00, 0xFE, 0x6C, 0x6C, 0x6C, 0x6C, 0x6C, 0x8C, 0x00, 0x00,
|
||||||
|
0x00, 0x82, 0xEE, 0x92, 0x82, 0x82, 0x82, 0x82, 0x00, 0x00,
|
||||||
|
0x00, 0x82, 0x82, 0x82, 0xFE, 0x82, 0x82, 0x82, 0x00, 0x00,
|
||||||
|
0x00, 0x7C, 0x82, 0x82, 0x82, 0x82, 0x82, 0x7C, 0x00, 0x00,
|
||||||
|
0x00, 0xFE, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x00, 0x00,
|
||||||
|
0x00, 0xFC, 0x82, 0x82, 0xFC, 0x80, 0x80, 0x80, 0x00, 0x00,
|
||||||
|
0x00, 0x7C, 0x82, 0x80, 0x80, 0x80, 0x82, 0x7C, 0x00, 0x00,
|
||||||
|
0x00, 0xFE, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00,
|
||||||
|
0x00, 0x82, 0x82, 0x82, 0x6C, 0x10, 0x60, 0x80, 0x00, 0x00,
|
||||||
|
0x00, 0x7C, 0x10, 0xFE, 0x92, 0xFE, 0x10, 0x7C, 0x00, 0x00,
|
||||||
|
0x00, 0x82, 0x82, 0x6C, 0x10, 0x6C, 0x82, 0x82, 0x00, 0x00,
|
||||||
|
0x00, 0x82, 0x82, 0x82, 0x82, 0x82, 0xFE, 0x02, 0x00, 0x00,
|
||||||
|
0x00, 0x82, 0x82, 0x82, 0xFE, 0x02, 0x02, 0x1E, 0x00, 0x00,
|
||||||
|
0x00, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0xFE, 0x00, 0x00,
|
||||||
|
0x00, 0x92, 0x92, 0x92, 0x92, 0x92, 0xFE, 0x02, 0x00, 0x00,
|
||||||
|
0x00, 0xE0, 0x60, 0x60, 0x7E, 0x62, 0x62, 0x7E, 0x00, 0x00,
|
||||||
|
0x00, 0x82, 0x82, 0xE2, 0x92, 0x92, 0x92, 0xF2, 0x00, 0x00,
|
||||||
|
0x00, 0x80, 0x80, 0xFC, 0x82, 0x82, 0x82, 0xFC, 0x00, 0x00,
|
||||||
|
0x00, 0xFC, 0x82, 0x02, 0x7E, 0x02, 0x82, 0xFC, 0x00, 0x00,
|
||||||
|
0x00, 0x8C, 0x92, 0x92, 0xF2, 0x92, 0x92, 0x8C, 0x00, 0x00,
|
||||||
|
0x00, 0x7E, 0x82, 0x82, 0x7E, 0x12, 0x62, 0x82, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x7C, 0x02, 0x7E, 0x82, 0x82, 0x7E, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0xFE, 0x80, 0xFC, 0x82, 0x82, 0xFC, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0xFC, 0x82, 0xFC, 0x82, 0x82, 0xFC, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0xFE, 0x62, 0x62, 0x60, 0x60, 0xF0, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x7E, 0x6C, 0x6C, 0x6C, 0x7C, 0x82, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x7C, 0x82, 0xFE, 0x80, 0x82, 0x7C, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x92, 0x7C, 0x10, 0x7C, 0x92, 0x92, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0xFC, 0x82, 0x1C, 0x82, 0x7C, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x82, 0x8E, 0x92, 0xE2, 0x82, 0x82, 0x00, 0x00,
|
||||||
|
0x00, 0x6C, 0x10, 0x82, 0x8E, 0x92, 0xE2, 0x82, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x82, 0x8C, 0x90, 0xF0, 0x8C, 0x82, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0xFE, 0x62, 0x62, 0x62, 0x62, 0xE2, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x82, 0xEE, 0x92, 0x82, 0x82, 0x82, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x82, 0x82, 0xFE, 0x82, 0x82, 0x82, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x7C, 0x82, 0x82, 0x82, 0x82, 0x7C, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0xFE, 0x82, 0x82, 0x82, 0x82, 0x82, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x7C, 0x44, 0x7C, 0x02, 0x7E, 0x82, 0x7E, 0x00, 0x00,
|
||||||
|
0x00, 0x44, 0x00, 0x7C, 0x02, 0x7E, 0x82, 0x7E, 0x00, 0x00,
|
||||||
|
0x00, 0x44, 0x00, 0x7C, 0x82, 0x82, 0x82, 0x7C, 0x00, 0x00,
|
||||||
|
0x00, 0x82, 0x00, 0x82, 0x82, 0x82, 0x82, 0x7E, 0x00, 0x00,
|
||||||
|
0x00, 0x8C, 0x00, 0xFC, 0x80, 0xF0, 0x80, 0xFC, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x7C, 0x62, 0x7C, 0x62, 0x62, 0xFC, 0x00, 0x00,
|
||||||
|
0x00, 0x82, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00,
|
||||||
|
0x00, 0x82, 0x00, 0x7C, 0x82, 0xFE, 0x80, 0x7E, 0x00, 0x00,
|
||||||
|
0x00, 0x7C, 0x44, 0x7C, 0x82, 0xFE, 0x82, 0x82, 0x00, 0x00,
|
||||||
|
0x00, 0x82, 0x7C, 0x82, 0x82, 0xFE, 0x82, 0x82, 0x00, 0x00,
|
||||||
|
0x00, 0x82, 0x7C, 0x82, 0x82, 0x82, 0x82, 0x7C, 0x00, 0x00,
|
||||||
|
0x00, 0x82, 0x00, 0x82, 0x82, 0x82, 0x82, 0x7E, 0x00, 0x00,
|
||||||
|
0x00, 0x82, 0xFE, 0x80, 0xF0, 0x80, 0x80, 0xFE, 0x00, 0x00,
|
||||||
|
0x00, 0x60, 0x10, 0x7C, 0x82, 0xFE, 0x80, 0x7E, 0x00, 0x00,
|
||||||
|
0x00, 0x0C, 0x10, 0x7C, 0x82, 0xFE, 0x80, 0x7E, 0x00, 0x00,
|
||||||
|
0x00, 0x10, 0x6C, 0x7C, 0x82, 0xFE, 0x80, 0x7E, 0x00, 0x00,
|
||||||
|
0x00, 0x60, 0x10, 0x7C, 0x02, 0x7E, 0x82, 0x7E, 0x00, 0x00,
|
||||||
|
0x00, 0x10, 0x6C, 0x00, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00,
|
||||||
|
0x00, 0x10, 0x0C, 0x82, 0x82, 0x82, 0x82, 0x7E, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x7C, 0x80, 0x80, 0x7C, 0x10, 0x00, 0x00,
|
||||||
|
0x00, 0x7C, 0x82, 0x60, 0xFC, 0x60, 0x60, 0xFE, 0x00, 0x00,
|
||||||
|
0x00, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x82, 0x82, 0x82, 0xFC, 0x80, 0x80, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0xFC, 0x82, 0x82, 0xFC, 0x80, 0x80, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x7C, 0x82, 0x80, 0x80, 0x82, 0x7C, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0xFE, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x82, 0x82, 0x6C, 0x10, 0x60, 0x80, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x7C, 0x10, 0xFE, 0xFE, 0x10, 0x7C, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x82, 0x6C, 0x10, 0x6C, 0x82, 0x82, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x82, 0x82, 0x82, 0x82, 0xFE, 0x02, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x82, 0x82, 0x82, 0xFE, 0x02, 0x1E, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x92, 0x92, 0x92, 0x92, 0x92, 0xFE, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x92, 0x92, 0x92, 0x92, 0xFE, 0x02, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0xE0, 0x60, 0x7C, 0x62, 0x62, 0x7C, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x82, 0x82, 0xE2, 0x92, 0x92, 0xF2, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x80, 0x80, 0xFC, 0x82, 0x82, 0xFC, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x7C, 0x82, 0x1E, 0x02, 0x82, 0x7C, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x8C, 0x92, 0x92, 0xF2, 0x92, 0x8C, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x1E, 0x62, 0x62, 0x1E, 0x12, 0x62, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||||
|
|
||||||
|
StdFont fonts[] = {
|
||||||
|
{stdfont8x5, 8, 5},
|
||||||
|
{stdfont10x7, 10, 7}
|
||||||
|
};
|
||||||
|
|
||||||
|
//Returns the standard font size, 0 = invalid font
|
||||||
|
// bits 0-7 = font width
|
||||||
|
// bits 8-15 = font height
|
||||||
|
unsigned int stdfont_getFontSize(unsigned int fontNumber)
|
||||||
|
{
|
||||||
|
if (fontNumber >= STDFONTS)
|
||||||
|
return 0;
|
||||||
|
return (fonts[fontNumber].charHeight << 8) | fonts[fontNumber].charWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Returns a pointer to the desired font's bitmap representation
|
||||||
|
unsigned char *stdfont_getBitmap(unsigned int fontNumber)
|
||||||
|
{
|
||||||
|
if (fontNumber >= STDFONTS)
|
||||||
|
return 0;
|
||||||
|
return (unsigned char *)fonts[fontNumber].fontPtr;
|
||||||
|
}
|
||||||
|
|
26
src/kernel/video/stdfont.h
Normal file
26
src/kernel/video/stdfont.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// stdfont.c
|
||||||
|
// Author: Josh Holtrop
|
||||||
|
// Created: 02/26/04
|
||||||
|
// Standard font server
|
||||||
|
|
||||||
|
#ifndef __HOS_STDFONT__
|
||||||
|
#define __HOS_STDFONT__ __HOS_STDFONT__
|
||||||
|
|
||||||
|
#define STDFONTS 2
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const unsigned char *fontPtr;
|
||||||
|
unsigned int charHeight;
|
||||||
|
unsigned int charWidth;
|
||||||
|
} StdFont;
|
||||||
|
|
||||||
|
//Returns the standard font size, 0 = invalid font
|
||||||
|
// bits 0-7 = font width
|
||||||
|
// bits 8-15 = font height
|
||||||
|
unsigned int stdfont_getFontSize(unsigned int fontNumber);
|
||||||
|
|
||||||
|
//Returns a pointer to the desired font's bitmap representation
|
||||||
|
unsigned char *stdfont_getBitmap(unsigned int fontNumber);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -1,176 +1,188 @@
|
|||||||
//video.c
|
// video.c
|
||||||
// 08/13/03 Josh Holtrop
|
// 08/13/03 Josh Holtrop
|
||||||
// Modified: 11/12/03
|
// Modified: 03/02/04
|
||||||
|
|
||||||
|
#include "hos_defines.h"
|
||||||
//Initialized the video mode information block video_mode and allocated double-buffer memory for graphics display
|
#include "video.h"
|
||||||
void video_init()
|
|
||||||
{
|
ModeInfoBlock video_mode;
|
||||||
videoMode = *(word *)BOOT_VIDEO_MODE;
|
dword videoMode = 0; //what video mode # we are in, 0 for console mode
|
||||||
|
word *vid_ptr16 = (word *)0xF0000000;
|
||||||
if (!videoMode) //we are in console mode
|
byte *vid_ptr24 = (byte *)0xF0000000;
|
||||||
return;
|
dword *vid_ptr32 = (dword *)0xF0000000;
|
||||||
|
word console_memory[2000]; //holds a copy of the console's memory
|
||||||
video_mode = *(ModeInfoBlock *) BOOT_VIDEO_MODE_INFO_BLOCK;
|
void (*video_psetp)(int, dword) = video_psetpnull; //function pointer to set a pixel
|
||||||
|
|
||||||
switch(video_mode.BitsPerPixel)
|
//Initialized the video mode information block video_mode and allocated double-buffer memory for graphics display
|
||||||
{
|
void video_init()
|
||||||
case 16:
|
{
|
||||||
video_psetp = &video_psetp16;
|
videoMode = *(word *)BOOT_VIDEO_MODE;
|
||||||
break;
|
|
||||||
case 24:
|
if (!videoMode) //we are in console mode
|
||||||
video_psetp = &video_psetp24;
|
return;
|
||||||
break;
|
|
||||||
case 32:
|
video_mode = *(ModeInfoBlock *) BOOT_VIDEO_MODE_INFO_BLOCK;
|
||||||
video_psetp = &video_psetp32;
|
|
||||||
}
|
switch(video_mode.BitsPerPixel)
|
||||||
}
|
{
|
||||||
|
case 16:
|
||||||
//Renders a character using stdfont[] as a bitmask
|
video_psetp = &video_psetp16;
|
||||||
void video_renderChar(int x, int y, int character, dword color)
|
break;
|
||||||
{
|
case 24:
|
||||||
int charpos = (character & 0xFF) * 8;
|
video_psetp = &video_psetp24;
|
||||||
int row;
|
break;
|
||||||
int col;
|
case 32:
|
||||||
for (row = 0; row < 8; row++)
|
video_psetp = &video_psetp32;
|
||||||
{
|
}
|
||||||
for (col = 0; col < 5; col++)
|
}
|
||||||
{
|
|
||||||
if ((stdfont[charpos+row] >> (col+3)) & 0x01)
|
//Renders a character using stdfont[] as a bitmask
|
||||||
video_pset(x+(5-col), y+row, color);
|
void video_renderChar(int x, int y, int character, dword color)
|
||||||
}
|
{
|
||||||
}
|
int charpos = (character & 0xFF) * 8;
|
||||||
}
|
int row;
|
||||||
|
int col;
|
||||||
//Draws a horizontal line
|
for (row = 0; row < 8; row++)
|
||||||
void video_horiz(int y, int x1, int x2, dword color)
|
{
|
||||||
{
|
for (col = 0; col < 5; col++)
|
||||||
if (x1 > x2)
|
{
|
||||||
{
|
if ((stdfont[charpos+row] >> (col+3)) & 0x01)
|
||||||
int tmp = x2;
|
video_pset(x+(5-col), y+row, color);
|
||||||
x2 = x1;
|
}
|
||||||
x1 = tmp; //x2 >= x1 now
|
}
|
||||||
}
|
}
|
||||||
if (x2 < 0)
|
|
||||||
return;
|
//Draws a horizontal line
|
||||||
if (x1 > video_mode.XResolution)
|
void video_horiz(int y, int x1, int x2, dword color)
|
||||||
return;
|
{
|
||||||
if (x1 < 0)
|
if (x1 > x2)
|
||||||
x1 = 0;
|
{
|
||||||
if (x2 > video_mode.XResolution)
|
int tmp = x2;
|
||||||
x2 = video_mode.XResolution;
|
x2 = x1;
|
||||||
int pixel = y*video_mode.XResolution+x1;
|
x1 = tmp; //x2 >= x1 now
|
||||||
for (; x1 <= x2; x1++)
|
}
|
||||||
{
|
if (x2 < 0)
|
||||||
video_psetp(pixel++, color);
|
return;
|
||||||
}
|
if (x1 > video_mode.XResolution)
|
||||||
}
|
return;
|
||||||
|
if (x1 < 0)
|
||||||
//Draws a vertical line
|
x1 = 0;
|
||||||
void video_vert(int x, int y1, int y2, dword color)
|
if (x2 > video_mode.XResolution)
|
||||||
{
|
x2 = video_mode.XResolution;
|
||||||
if (y1 > y2)
|
int pixel = y*video_mode.XResolution+x1;
|
||||||
{
|
for (; x1 <= x2; x1++)
|
||||||
int tmp = y2;
|
{
|
||||||
y2 = y1;
|
video_psetp(pixel++, color);
|
||||||
y1 = tmp; //y2 >= y1 now
|
}
|
||||||
}
|
}
|
||||||
if (y2 < 0)
|
|
||||||
return;
|
//Draws a single pixel
|
||||||
if (y1 > video_mode.YResolution)
|
void video_pset(int x, int y, dword color)
|
||||||
return;
|
{
|
||||||
if (y1 < 0)
|
if ((x < 0) || (x > video_mode.XResolution) || (y < 0) || (y > video_mode.YResolution))
|
||||||
y1 = 0;
|
return;
|
||||||
if (y2 > video_mode.YResolution)
|
video_psetp(y*video_mode.XResolution+x, color);
|
||||||
y2 = video_mode.YResolution;
|
}
|
||||||
int pixel = y1*video_mode.XResolution+x;
|
|
||||||
for (; y1 <= y2; y1++)
|
//Draws a pixel at the specified pixel position
|
||||||
{
|
void video_pseti(int pixel, dword color)
|
||||||
video_psetp(pixel, color);
|
{
|
||||||
pixel+=video_mode.XResolution;
|
video_psetp(pixel, color);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
//Draws a vertical line
|
||||||
//Draws a rectangle
|
void video_vert(int x, int y1, int y2, dword color)
|
||||||
void video_rect(int x1, int y1, int x2, int y2, dword color)
|
{
|
||||||
{
|
if (y1 > y2)
|
||||||
video_horiz(y1, x1, x2, color);
|
{
|
||||||
video_horiz(y2, x1, x2, color);
|
int tmp = y2;
|
||||||
video_vert(x1, y1, y2, color);
|
y2 = y1;
|
||||||
video_vert(x2, y1, y2, color);
|
y1 = tmp; //y2 >= y1 now
|
||||||
}
|
}
|
||||||
|
if (y2 < 0)
|
||||||
//Draws a filled rectangle
|
return;
|
||||||
void video_rectf(int x1, int y1, int x2, int y2, dword color)
|
if (y1 > video_mode.YResolution)
|
||||||
{
|
return;
|
||||||
if (y2 < y1)
|
if (y1 < 0)
|
||||||
{
|
y1 = 0;
|
||||||
int tmp = y2;
|
if (y2 > video_mode.YResolution)
|
||||||
y2 = y1;
|
y2 = video_mode.YResolution;
|
||||||
y1 = tmp;
|
int pixel = y1*video_mode.XResolution+x;
|
||||||
}
|
for (; y1 <= y2; y1++)
|
||||||
for (; y1 <= y2; y1++)
|
{
|
||||||
video_horiz(y1, x1, x2, color);
|
video_psetp(pixel, color);
|
||||||
}
|
pixel+=video_mode.XResolution;
|
||||||
|
}
|
||||||
//Draws a single pixel
|
}
|
||||||
inline void video_pset(int x, int y, dword color)
|
|
||||||
{
|
//Draws a rectangle
|
||||||
if ((x < 0) || (x > video_mode.XResolution) || (y < 0) || (y > video_mode.YResolution))
|
void video_rect(int x1, int y1, int x2, int y2, dword color)
|
||||||
return;
|
{
|
||||||
video_psetp(y*video_mode.XResolution+x, color);
|
video_horiz(y1, x1, x2, color);
|
||||||
}
|
video_horiz(y2, x1, x2, color);
|
||||||
|
video_vert(x1, y1, y2, color);
|
||||||
//Draws a pixel at the specified pixel position
|
video_vert(x2, y1, y2, color);
|
||||||
void video_psetp16(int pixel, dword color)
|
}
|
||||||
{
|
|
||||||
vid_ptr16[pixel] = ((color&0xFF)>>3) | ((((color>>8)&0xFF)>>2)<<5) | ((((color>>16)&0xFF)>>3)<<11);
|
//Draws a filled rectangle
|
||||||
}
|
void video_rectf(int x1, int y1, int x2, int y2, dword color)
|
||||||
|
{
|
||||||
//Draws a pixel at the specified pixel position
|
if (y2 < y1)
|
||||||
void video_psetp24(int pixel, dword color)
|
{
|
||||||
{
|
int tmp = y2;
|
||||||
vid_ptr24[pixel*3] = color & 0xFF;
|
y2 = y1;
|
||||||
vid_ptr24[pixel*3+1] = (color>>8) & 0xFF;
|
y1 = tmp;
|
||||||
vid_ptr24[pixel*3+2] = (color>>16) & 0xFF;
|
}
|
||||||
}
|
for (; y1 <= y2; y1++)
|
||||||
|
video_horiz(y1, x1, x2, color);
|
||||||
//Draws a pixel at the specified pixel position
|
}
|
||||||
void video_psetp32(int pixel, dword color)
|
|
||||||
{
|
//Draws a pixel at the specified pixel position
|
||||||
vid_ptr32[pixel] = color;
|
void video_psetp16(int pixel, dword color)
|
||||||
}
|
{
|
||||||
|
vid_ptr16[pixel] = ((color&0xFF)>>3) | ((((color>>8)&0xFF)>>2)<<5) | ((((color>>16)&0xFF)>>3)<<11);
|
||||||
//Dummy function to not draw anything if there is no graphical mode enabled
|
}
|
||||||
void video_psetpnull(int pixel, dword color) {}
|
|
||||||
|
//Draws a pixel at the specified pixel position
|
||||||
|
void video_psetp24(int pixel, dword color)
|
||||||
// This function draws a simple "console" window in graphical mode to display text
|
{
|
||||||
void video_drawConsole()
|
vid_ptr24[pixel*3] = color & 0xFF;
|
||||||
{
|
vid_ptr24[pixel*3+1] = (color>>8) & 0xFF;
|
||||||
video_rectf(9, 9, 490, 260, 0);
|
vid_ptr24[pixel*3+2] = (color>>16) & 0xFF;
|
||||||
video_rect(8, 8, 491, 261, 0x00777777);
|
}
|
||||||
int x, y;
|
|
||||||
for (x = 0; x < 80; x++)
|
//Draws a pixel at the specified pixel position
|
||||||
{
|
void video_psetp32(int pixel, dword color)
|
||||||
for (y = 0; y < 25; y++)
|
{
|
||||||
{
|
vid_ptr32[pixel] = color;
|
||||||
video_renderChar(x*6+10, y*10+10, console_memory[y*80+x], 0x00FFFFFF);
|
}
|
||||||
}
|
|
||||||
}
|
//Dummy function to not draw anything if there is no graphical mode enabled
|
||||||
}
|
void video_psetpnull(int pixel, dword color) {}
|
||||||
|
|
||||||
|
|
||||||
// This function draws a "console" character to the graphical video screen
|
// This function draws a simple "console" window in graphical mode to display text
|
||||||
void video_drawConsoleChar(dword position)
|
void video_drawConsole()
|
||||||
{
|
{
|
||||||
int x = position % 80;
|
video_rectf(9, 9, 490, 260, 0);
|
||||||
int y = position / 80;
|
video_rect(8, 8, 491, 261, 0x00777777);
|
||||||
video_renderChar(x*6+10, y*10+10, console_memory[y*80+x], 0x00FFFFFF);
|
int x, y;
|
||||||
}
|
for (x = 0; x < 80; x++)
|
||||||
|
{
|
||||||
|
for (y = 0; y < 25; y++)
|
||||||
|
{
|
||||||
|
video_renderChar(x*6+10, y*10+10, console_memory[y*80+x], 0x00FFFFFF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// This function draws a "console" character to the graphical video screen
|
||||||
|
void video_drawConsoleChar(dword position)
|
||||||
|
{
|
||||||
|
int x = position % 80;
|
||||||
|
int y = position / 80;
|
||||||
|
video_renderChar(x*6+10, y*10+10, console_memory[y*80+x], 0x00FFFFFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1,72 +1,68 @@
|
|||||||
//video.h
|
// video.h
|
||||||
// 08/18/03 Josh Holtrop
|
// 08/18/03 Josh Holtrop
|
||||||
// Modified: 12/28/03
|
// Modified: 03/02/04
|
||||||
|
|
||||||
void video_init();
|
#include "hos_defines.h"
|
||||||
void video_horiz(int y, int x1, int x2, dword color);
|
|
||||||
void video_vert(int x, int y1, int y2, dword color);
|
#ifndef __HOS_VIDEO__
|
||||||
void video_rect(int x1, int y1, int x2, int y2, dword color);
|
#define __HOS_VIDEO__ __HOS_VIDEO__
|
||||||
void video_rectf(int x1, int y1, int x2, int y2, dword color);
|
|
||||||
inline void video_pset(int x, int y, dword color);
|
void video_init();
|
||||||
void video_psetp16(int pixel, dword color);
|
void video_horiz(int y, int x1, int x2, dword color);
|
||||||
void video_psetp24(int pixel, dword color);
|
void video_vert(int x, int y1, int y2, dword color);
|
||||||
void video_psetp32(int pixel, dword color);
|
void video_rect(int x1, int y1, int x2, int y2, dword color);
|
||||||
void video_psetpnull(int pixel, dword color);
|
void video_rectf(int x1, int y1, int x2, int y2, dword color);
|
||||||
void video_renderChar(int x, int y, int character, dword color);
|
void video_pset(int x, int y, dword color);
|
||||||
void video_drawConsole();
|
void video_pseti(int pixel, dword color);
|
||||||
void video_drawConsoleChar(dword position);
|
void video_psetp16(int pixel, dword color);
|
||||||
|
void video_psetp24(int pixel, dword color);
|
||||||
|
void video_psetp32(int pixel, dword color);
|
||||||
typedef struct{
|
void video_psetpnull(int pixel, dword color);
|
||||||
word ModeAttributes;
|
void video_renderChar(int x, int y, int character, dword color);
|
||||||
byte WinAAttributes;
|
void video_drawConsole();
|
||||||
byte WinBAttributes;
|
void video_drawConsoleChar(dword position);
|
||||||
word WinGranularity;
|
|
||||||
word WinSize;
|
|
||||||
word WinASegment;
|
typedef struct{
|
||||||
word WinBSegment;
|
word ModeAttributes;
|
||||||
dword WinFuncPtr;
|
byte WinAAttributes;
|
||||||
word BytesPerScanLine;
|
byte WinBAttributes;
|
||||||
|
word WinGranularity;
|
||||||
word XResolution;
|
word WinSize;
|
||||||
word YResolution;
|
word WinASegment;
|
||||||
byte XCharSize;
|
word WinBSegment;
|
||||||
byte YCharSize;
|
dword WinFuncPtr;
|
||||||
byte NumberOfPlanes;
|
word BytesPerScanLine;
|
||||||
byte BitsPerPixel;
|
|
||||||
byte NumberOfBanks;
|
word XResolution;
|
||||||
byte MemoryModel;
|
word YResolution;
|
||||||
byte BankSize;
|
byte XCharSize;
|
||||||
byte NumberOfImagePages;
|
byte YCharSize;
|
||||||
byte Reserved1;
|
byte NumberOfPlanes;
|
||||||
|
byte BitsPerPixel;
|
||||||
byte RedMaskSize;
|
byte NumberOfBanks;
|
||||||
byte RedFieldPosition;
|
byte MemoryModel;
|
||||||
byte GreenMaskSize;
|
byte BankSize;
|
||||||
byte GreenFieldPosition;
|
byte NumberOfImagePages;
|
||||||
byte BlueMaskSize;
|
byte Reserved1;
|
||||||
byte BlueFieldPosition;
|
|
||||||
byte RsvdMaskSize;
|
byte RedMaskSize;
|
||||||
byte RsvdFieldPosition;
|
byte RedFieldPosition;
|
||||||
byte DirectColorModeInfo;
|
byte GreenMaskSize;
|
||||||
|
byte GreenFieldPosition;
|
||||||
dword PhysBasePtr;
|
byte BlueMaskSize;
|
||||||
dword OffScreenMemOffset;
|
byte BlueFieldPosition;
|
||||||
word OffScreenMemSize;
|
byte RsvdMaskSize;
|
||||||
byte Reserved[206];
|
byte RsvdFieldPosition;
|
||||||
} ModeInfoBlock;
|
byte DirectColorModeInfo;
|
||||||
|
|
||||||
|
dword PhysBasePtr;
|
||||||
ModeInfoBlock video_mode;
|
dword OffScreenMemOffset;
|
||||||
dword videoMode = 0; //what video mode # we are in, 0 for console mode
|
word OffScreenMemSize;
|
||||||
word *vid_ptr16 = (word *)0xF0000000;
|
byte Reserved[206];
|
||||||
byte *vid_ptr24 = (byte *)0xF0000000;
|
} ModeInfoBlock;
|
||||||
dword *vid_ptr32 = (dword *)0xF0000000;
|
|
||||||
word console_memory[2000]; //holds a copy of the console's memory
|
|
||||||
void (*video_psetp)(int, dword) = video_psetpnull; //function pointer to set a pixel
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
52
src/readme.txt
Normal file
52
src/readme.txt
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
HOS - Holtrop's Operating System
|
||||||
|
|
||||||
|
|
||||||
|
HOS is a 32-bit, protected mode, graphical, multitasking operating system.
|
||||||
|
It was written by me, Josh Holtrop, with help from a few others along the way.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
History
|
||||||
|
-------------
|
||||||
|
|
||||||
|
0.14
|
||||||
|
03/01/04 - Thanks to Ben Meyer for helping me get a Makefile working and building on linux to work!
|
||||||
|
|
||||||
|
0.13
|
||||||
|
01/26/04 - functions added to read/write CMOS clock date and time
|
||||||
|
01/19/04 - fixed bug GDTR/IDTR pointing to physical rather than linear table base address
|
||||||
|
01/07/04 - fixed bug not reading sectors correctly from floppy
|
||||||
|
12/28/03 - fixed bug not storing eax on interrupt
|
||||||
|
12/25/03 - fixed bug in mm_palloc()
|
||||||
|
12/25/03 - incorporated output functions as regular functions rather than as part of a linked library
|
||||||
|
12/23/03 - re-written physical memory manager using bitmap instead of stack
|
||||||
|
12/22/03 - kernel relocated to 3gb linear / 1mb+24kb physical to allow for app. address space
|
||||||
|
|
||||||
|
0.12
|
||||||
|
12/21/03 - sample bmp loader tested, works (tests loading a kernel of size ~ 932kb
|
||||||
|
12/20/03 - GDT/IDT now located at 1mb physical, before kernel
|
||||||
|
10/30/03 - turns floppy motor off
|
||||||
|
10/30/03 - keyboard LEDs working
|
||||||
|
10/29/03 - paging functions working
|
||||||
|
10/15/03 - physical memory management page allocators working
|
||||||
|
|
||||||
|
0.11
|
||||||
|
10/09/03 - PS/2 mouse driver
|
||||||
|
|
||||||
|
0.10
|
||||||
|
09/11/03 - Rewritten C and assembly kernel with VESA GUI mode support, keyboard driver
|
||||||
|
|
||||||
|
0.05
|
||||||
|
05/14/03 - HGUI24/HGUI32 commands finished for testing GUI on both 24bpp and 32bpp graphics cards
|
||||||
|
05/14/03 - first web release!
|
||||||
|
|
||||||
|
0.04
|
||||||
|
03/09/03 - added VM shortcut command
|
||||||
|
03/09/03 - press up to fill retrieve last inputted command for Nate Scholten
|
||||||
|
03/08/03 - press clear to clear console input
|
||||||
|
03/07/03 - added "shortcut" commands PC, IC, ? for Nate Scholten
|
||||||
|
03/06/03 - added PROMPTC, INPUTC commands
|
||||||
|
|
||||||
|
0.03
|
||||||
|
12/30/02 - Command Line Interface working, accepting basic commands
|
258
stdfont.h
258
stdfont.h
@ -1,258 +0,0 @@
|
|||||||
const byte stdfont[] = {
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xE0, 0xC0, 0x80,
|
|
||||||
0x00, 0x08, 0x18, 0x38, 0x78, 0x38, 0x18, 0x08,
|
|
||||||
0x00, 0x20, 0x70, 0xA8, 0x20, 0xA8, 0x70, 0x20,
|
|
||||||
0x00, 0xA0, 0xA0, 0xA0, 0xA0, 0x00, 0xA0, 0xA0,
|
|
||||||
0x00, 0x78, 0xA8, 0xA8, 0x78, 0x28, 0x28, 0x68,
|
|
||||||
0x00, 0x78, 0x80, 0x70, 0x88, 0x70, 0x08, 0xF0,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xF8,
|
|
||||||
0x00, 0x20, 0x70, 0xA8, 0x20, 0xA8, 0x70, 0xF8,
|
|
||||||
0x00, 0x20, 0x70, 0xA8, 0x20, 0x20, 0x20, 0x20,
|
|
||||||
0x00, 0x20, 0x20, 0x20, 0x20, 0xA8, 0x70, 0x20,
|
|
||||||
0x00, 0x00, 0x20, 0x10, 0xF8, 0x10, 0x20, 0x00,
|
|
||||||
0x00, 0x00, 0x20, 0x40, 0xF8, 0x40, 0x20, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x60, 0x90, 0x60, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x20, 0x70, 0xF8, 0xF8, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0xF8, 0xF8, 0x70, 0x20, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x20, 0x20, 0x20, 0x20, 0x00, 0x20, 0x20,
|
|
||||||
0x00, 0x50, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x50, 0xF8, 0x50, 0x50, 0x50, 0xF8, 0x50,
|
|
||||||
0x00, 0x20, 0x78, 0xA0, 0x70, 0x28, 0xF0, 0x20,
|
|
||||||
0x00, 0x00, 0x08, 0x90, 0x20, 0x48, 0x80, 0x00,
|
|
||||||
0x00, 0x20, 0x50, 0x50, 0x20, 0x58, 0x90, 0x68,
|
|
||||||
0x00, 0x40, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x20, 0x40, 0x40, 0x40, 0x40, 0x40, 0x20,
|
|
||||||
0x00, 0x40, 0x20, 0x20, 0x20, 0x20, 0x20, 0x40,
|
|
||||||
0x00, 0x00, 0xA8, 0x70, 0xF8, 0x70, 0xA8, 0x00,
|
|
||||||
0x00, 0x00, 0x20, 0x20, 0xF8, 0x20, 0x20, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x40,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60,
|
|
||||||
0x00, 0x00, 0x08, 0x10, 0x20, 0x40, 0x80, 0x00,
|
|
||||||
0x00, 0x70, 0x88, 0x88, 0x88, 0x88, 0x88, 0x70,
|
|
||||||
0x00, 0x20, 0x60, 0xA0, 0x20, 0x20, 0x20, 0x20,
|
|
||||||
0x00, 0x70, 0x88, 0x08, 0x10, 0x20, 0x40, 0xF8,
|
|
||||||
0x00, 0x70, 0x88, 0x08, 0x10, 0x08, 0x88, 0x70,
|
|
||||||
0x00, 0x30, 0x50, 0x90, 0x90, 0xF8, 0x10, 0x10,
|
|
||||||
0x00, 0xF8, 0x80, 0x80, 0xF8, 0x08, 0x88, 0x70,
|
|
||||||
0x00, 0x38, 0x40, 0x80, 0xF0, 0x88, 0x88, 0x70,
|
|
||||||
0x00, 0xF8, 0x08, 0x10, 0x20, 0x40, 0x40, 0x40,
|
|
||||||
0x00, 0x70, 0x88, 0x88, 0x70, 0x88, 0x88, 0x70,
|
|
||||||
0x00, 0x70, 0x88, 0x88, 0x78, 0x08, 0x10, 0x60,
|
|
||||||
0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x60, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x60, 0x40,
|
|
||||||
0x00, 0x10, 0x20, 0x40, 0x80, 0x40, 0x20, 0x10,
|
|
||||||
0x00, 0x00, 0x00, 0xF0, 0x00, 0xF0, 0x00, 0x00,
|
|
||||||
0x00, 0x80, 0x40, 0x20, 0x10, 0x20, 0x40, 0x80,
|
|
||||||
0x00, 0x70, 0x88, 0x08, 0x10, 0x20, 0x00, 0x20,
|
|
||||||
0x00, 0x70, 0x88, 0x88, 0xB8, 0xB0, 0x80, 0x78,
|
|
||||||
0x00, 0x70, 0x88, 0x88, 0xF8, 0x88, 0x88, 0x88,
|
|
||||||
0x00, 0xF0, 0x88, 0x88, 0xF0, 0x88, 0x88, 0xF0,
|
|
||||||
0x00, 0x70, 0x88, 0x80, 0x80, 0x80, 0x88, 0x70,
|
|
||||||
0x00, 0xF0, 0x88, 0x88, 0x88, 0x88, 0x88, 0xF0,
|
|
||||||
0x00, 0xF8, 0x80, 0x80, 0xF0, 0x80, 0x80, 0xF8,
|
|
||||||
0x00, 0xF8, 0x80, 0x80, 0xF0, 0x80, 0x80, 0x80,
|
|
||||||
0x00, 0x70, 0x88, 0x80, 0xB8, 0x88, 0x88, 0x70,
|
|
||||||
0x00, 0x88, 0x88, 0x88, 0xF8, 0x88, 0x88, 0x88,
|
|
||||||
0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
|
||||||
0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x90, 0x60,
|
|
||||||
0x00, 0x88, 0x90, 0xA0, 0xC0, 0xA0, 0x90, 0x88,
|
|
||||||
0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xF8,
|
|
||||||
0x00, 0x88, 0xD8, 0xA8, 0x88, 0x88, 0x88, 0x88,
|
|
||||||
0x00, 0x88, 0xC8, 0xE8, 0xB8, 0x98, 0x88, 0x88,
|
|
||||||
0x00, 0x70, 0x88, 0x88, 0x88, 0x88, 0x88, 0x70,
|
|
||||||
0x00, 0xF0, 0x88, 0x88, 0xF0, 0x80, 0x80, 0x80,
|
|
||||||
0x00, 0x70, 0x88, 0x88, 0x88, 0xA8, 0x98, 0x70,
|
|
||||||
0x00, 0xF0, 0x88, 0x88, 0xF0, 0xA0, 0x90, 0x88,
|
|
||||||
0x00, 0x70, 0x88, 0x80, 0x70, 0x08, 0x88, 0x70,
|
|
||||||
0x00, 0xF8, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
|
||||||
0x00, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x70,
|
|
||||||
0x00, 0x88, 0x88, 0x88, 0x88, 0x88, 0x50, 0x20,
|
|
||||||
0x00, 0x88, 0x88, 0x88, 0x88, 0x88, 0xA8, 0x50,
|
|
||||||
0x00, 0x88, 0x50, 0x20, 0x20, 0x50, 0x88, 0x88,
|
|
||||||
0x00, 0x88, 0x88, 0x50, 0x20, 0x20, 0x20, 0x20,
|
|
||||||
0x00, 0xF8, 0x08, 0x10, 0x20, 0x40, 0x80, 0xF8,
|
|
||||||
0x00, 0x70, 0x40, 0x40, 0x40, 0x40, 0x40, 0x70,
|
|
||||||
0x00, 0x80, 0xC0, 0x60, 0x30, 0x18, 0x08, 0x00,
|
|
||||||
0x00, 0xE0, 0x20, 0x20, 0x20, 0x20, 0x20, 0xE0,
|
|
||||||
0x00, 0x20, 0x50, 0x88, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8,
|
|
||||||
0x00, 0x60, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x70, 0x08, 0x78, 0x88, 0x78,
|
|
||||||
0x00, 0x80, 0x80, 0xF0, 0x88, 0x88, 0x88, 0xF0,
|
|
||||||
0x00, 0x00, 0x00, 0x70, 0x88, 0x80, 0x88, 0x70,
|
|
||||||
0x00, 0x08, 0x08, 0x78, 0x88, 0x88, 0x88, 0x78,
|
|
||||||
0x00, 0x00, 0x00, 0x70, 0x88, 0xF8, 0x80, 0x78,
|
|
||||||
0x00, 0x30, 0x40, 0x40, 0xE0, 0x40, 0x40, 0x40,
|
|
||||||
0x00, 0x00, 0x00, 0x78, 0x88, 0x78, 0x08, 0x70,
|
|
||||||
0x00, 0x80, 0x80, 0xF0, 0x88, 0x88, 0x88, 0x88,
|
|
||||||
0x00, 0x20, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20,
|
|
||||||
0x00, 0x10, 0x00, 0x10, 0x10, 0x10, 0x90, 0x60,
|
|
||||||
0x00, 0x80, 0x80, 0x90, 0xA0, 0xC0, 0xA0, 0x90,
|
|
||||||
0x00, 0xC0, 0x40, 0x40, 0x40, 0x40, 0x40, 0xE0,
|
|
||||||
0x00, 0x00, 0x00, 0xD0, 0xA8, 0xA8, 0xA8, 0xA8,
|
|
||||||
0x00, 0x00, 0x00, 0xF0, 0x88, 0x88, 0x88, 0x88,
|
|
||||||
0x00, 0x00, 0x00, 0x70, 0x88, 0x88, 0x88, 0x70,
|
|
||||||
0x00, 0x00, 0x00, 0xF0, 0x88, 0xF0, 0x80, 0x80,
|
|
||||||
0x00, 0x00, 0x00, 0x78, 0x88, 0x78, 0x08, 0x38,
|
|
||||||
0x00, 0x00, 0x00, 0x70, 0x48, 0x40, 0x40, 0x40,
|
|
||||||
0x00, 0x00, 0x00, 0x78, 0x80, 0x70, 0x08, 0xF0,
|
|
||||||
0x00, 0x40, 0x40, 0xE0, 0x40, 0x40, 0x40, 0x20,
|
|
||||||
0x00, 0x00, 0x00, 0x88, 0x88, 0x88, 0x88, 0x78,
|
|
||||||
0x00, 0x00, 0x00, 0x88, 0x88, 0x88, 0x50, 0x20,
|
|
||||||
0x00, 0x00, 0x00, 0x88, 0x88, 0x88, 0xA8, 0x50,
|
|
||||||
0x00, 0x00, 0x00, 0x88, 0x50, 0x20, 0x50, 0x88,
|
|
||||||
0x00, 0x00, 0x00, 0x88, 0x88, 0x78, 0x08, 0xF0,
|
|
||||||
0x00, 0x00, 0x00, 0xF8, 0x10, 0x20, 0x40, 0xF8,
|
|
||||||
0x00, 0x30, 0x40, 0x40, 0x80, 0x40, 0x40, 0x30,
|
|
||||||
0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
|
||||||
0x00, 0xC0, 0x20, 0x20, 0x10, 0x20, 0x20, 0xC0,
|
|
||||||
0x00, 0x00, 0x68, 0x90, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x70, 0x88, 0x88, 0xF8, 0x88, 0x88, 0x88,
|
|
||||||
0x00, 0xF8, 0x88, 0x80, 0xF0, 0x88, 0x88, 0xF0,
|
|
||||||
0x00, 0xF0, 0x88, 0x88, 0xF0, 0x88, 0x88, 0xF0,
|
|
||||||
0x00, 0xF8, 0x48, 0x40, 0x40, 0x40, 0x40, 0xE0,
|
|
||||||
0x00, 0xF0, 0x50, 0x50, 0x50, 0x50, 0x78, 0x88,
|
|
||||||
0x00, 0xF8, 0x80, 0x80, 0xF0, 0x80, 0x80, 0xF8,
|
|
||||||
0x00, 0xA8, 0xA8, 0x70, 0x20, 0x70, 0xA8, 0xA8,
|
|
||||||
0x00, 0x70, 0x88, 0x08, 0x30, 0x08, 0x88, 0x70,
|
|
||||||
0x00, 0x88, 0x98, 0xA8, 0xA8, 0xA8, 0xC8, 0x88,
|
|
||||||
0x00, 0xA8, 0xC8, 0x98, 0xA8, 0xA8, 0xC8, 0x88,
|
|
||||||
0x00, 0x88, 0x90, 0xA0, 0xC0, 0xA0, 0x90, 0x88,
|
|
||||||
0x00, 0xF8, 0x50, 0x50, 0x50, 0x50, 0x50, 0x90,
|
|
||||||
0x00, 0x88, 0xD8, 0xA8, 0x88, 0x88, 0x88, 0x88,
|
|
||||||
0x00, 0x88, 0x88, 0x88, 0xF8, 0x88, 0x88, 0x88,
|
|
||||||
0x00, 0x70, 0x88, 0x88, 0x88, 0x88, 0x88, 0x70,
|
|
||||||
0x00, 0xF8, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
|
|
||||||
0x00, 0xF0, 0x88, 0x88, 0xF0, 0x80, 0x80, 0x80,
|
|
||||||
0x00, 0x70, 0x88, 0x80, 0x80, 0x80, 0x88, 0x70,
|
|
||||||
0x00, 0xF8, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
|
||||||
0x00, 0x88, 0x88, 0x88, 0x50, 0x20, 0x40, 0x80,
|
|
||||||
0x00, 0x70, 0x20, 0xF8, 0xA8, 0xF8, 0x20, 0x70,
|
|
||||||
0x00, 0x88, 0x88, 0x50, 0x20, 0x50, 0x88, 0x88,
|
|
||||||
0x00, 0x88, 0x88, 0x88, 0x88, 0x88, 0xF8, 0x08,
|
|
||||||
0x00, 0x88, 0x88, 0x88, 0xF8, 0x08, 0x08, 0x38,
|
|
||||||
0x00, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xF8,
|
|
||||||
0x00, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xF8, 0x08,
|
|
||||||
0x00, 0xC0, 0x40, 0x40, 0x78, 0x48, 0x48, 0x78,
|
|
||||||
0x00, 0x88, 0x88, 0xC8, 0xA8, 0xA8, 0xA8, 0xE8,
|
|
||||||
0x00, 0x80, 0x80, 0xF0, 0x88, 0x88, 0x88, 0xF0,
|
|
||||||
0x00, 0xF0, 0x88, 0x08, 0x78, 0x08, 0x88, 0xF0,
|
|
||||||
0x00, 0x90, 0xA8, 0xA8, 0xE8, 0xA8, 0xA8, 0x90,
|
|
||||||
0x00, 0x78, 0x88, 0x88, 0x78, 0x28, 0x48, 0x88,
|
|
||||||
0x00, 0x00, 0x70, 0x08, 0x78, 0x88, 0x88, 0x78,
|
|
||||||
0x00, 0x00, 0xF8, 0x80, 0xF0, 0x88, 0x88, 0xF0,
|
|
||||||
0x00, 0x00, 0xF0, 0x88, 0xF0, 0x88, 0x88, 0xF0,
|
|
||||||
0x00, 0x00, 0xF8, 0x48, 0x48, 0x40, 0x40, 0xE0,
|
|
||||||
0x00, 0x00, 0x78, 0x50, 0x50, 0x50, 0x70, 0x88,
|
|
||||||
0x00, 0x00, 0x70, 0x88, 0xF8, 0x80, 0x88, 0x70,
|
|
||||||
0x00, 0x00, 0xA8, 0x70, 0x20, 0x70, 0xA8, 0xA8,
|
|
||||||
0x00, 0x00, 0x00, 0xF0, 0x88, 0x30, 0x88, 0x70,
|
|
||||||
0x00, 0x00, 0x88, 0x98, 0xA8, 0xC8, 0x88, 0x88,
|
|
||||||
0x00, 0x50, 0x20, 0x88, 0x98, 0xA8, 0xC8, 0x88,
|
|
||||||
0x00, 0x00, 0x88, 0x90, 0xA0, 0xE0, 0x90, 0x88,
|
|
||||||
0x00, 0x00, 0xF8, 0x48, 0x48, 0x48, 0x48, 0xC8,
|
|
||||||
0x00, 0x00, 0x88, 0xD8, 0xA8, 0x88, 0x88, 0x88,
|
|
||||||
0x00, 0x00, 0x88, 0x88, 0xF8, 0x88, 0x88, 0x88,
|
|
||||||
0x00, 0x00, 0x70, 0x88, 0x88, 0x88, 0x88, 0x70,
|
|
||||||
0x00, 0x00, 0xF8, 0x88, 0x88, 0x88, 0x88, 0x88,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x70, 0x50, 0x70, 0x08, 0x78, 0x88, 0x78,
|
|
||||||
0x00, 0x88, 0x00, 0x70, 0x08, 0x78, 0x88, 0x78,
|
|
||||||
0x00, 0x88, 0x00, 0x70, 0x88, 0x88, 0x88, 0x70,
|
|
||||||
0x00, 0x88, 0x00, 0x88, 0x88, 0x88, 0x88, 0x78,
|
|
||||||
0x00, 0x90, 0x00, 0xF0, 0x80, 0xE0, 0x80, 0xF0,
|
|
||||||
0x00, 0x00, 0x70, 0x48, 0x70, 0x48, 0x48, 0xF0,
|
|
||||||
0x00, 0x88, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20,
|
|
||||||
0x00, 0x88, 0x00, 0x70, 0x88, 0xF8, 0x80, 0x78,
|
|
||||||
0x00, 0x70, 0x50, 0x70, 0x88, 0xF8, 0x88, 0x88,
|
|
||||||
0x00, 0x88, 0x70, 0x88, 0x88, 0xF8, 0x88, 0x88,
|
|
||||||
0x00, 0x88, 0x70, 0x88, 0x88, 0x88, 0x88, 0x70,
|
|
||||||
0x00, 0x88, 0x00, 0x88, 0x88, 0x88, 0x88, 0x78,
|
|
||||||
0x00, 0x88, 0xF8, 0x80, 0xE0, 0x80, 0x80, 0xF8,
|
|
||||||
0x00, 0x40, 0x20, 0x70, 0x88, 0xF8, 0x80, 0x78,
|
|
||||||
0x00, 0x10, 0x20, 0x70, 0x88, 0xF8, 0x80, 0x78,
|
|
||||||
0x00, 0x20, 0x50, 0x70, 0x88, 0xF8, 0x80, 0x78,
|
|
||||||
0x00, 0x40, 0x20, 0x70, 0x08, 0x78, 0x88, 0x78,
|
|
||||||
0x00, 0x20, 0x50, 0x00, 0x20, 0x20, 0x20, 0x20,
|
|
||||||
0x00, 0x20, 0x10, 0x88, 0x88, 0x88, 0x88, 0x78,
|
|
||||||
0x00, 0x00, 0x00, 0x70, 0x80, 0x80, 0x70, 0x20,
|
|
||||||
0x00, 0x70, 0x88, 0x40, 0xF0, 0x40, 0x40, 0xF8,
|
|
||||||
0x00, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x88, 0x88, 0x88, 0xF0, 0x80, 0x80,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0xF0, 0x88, 0x88, 0xF0, 0x80, 0x80,
|
|
||||||
0x00, 0x00, 0x70, 0x88, 0x80, 0x80, 0x88, 0x70,
|
|
||||||
0x00, 0x00, 0xF8, 0x20, 0x20, 0x20, 0x20, 0x20,
|
|
||||||
0x00, 0x00, 0x88, 0x88, 0x50, 0x20, 0x40, 0x80,
|
|
||||||
0x00, 0x00, 0x70, 0x20, 0xF8, 0xF8, 0x20, 0x70,
|
|
||||||
0x00, 0x00, 0x88, 0x50, 0x20, 0x50, 0x88, 0x88,
|
|
||||||
0x00, 0x00, 0x88, 0x88, 0x88, 0x88, 0xF8, 0x08,
|
|
||||||
0x00, 0x00, 0x88, 0x88, 0x88, 0xF8, 0x08, 0x38,
|
|
||||||
0x00, 0x00, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xF8,
|
|
||||||
0x00, 0x00, 0xA8, 0xA8, 0xA8, 0xA8, 0xF8, 0x08,
|
|
||||||
0x00, 0x00, 0xC0, 0x40, 0x70, 0x48, 0x48, 0x70,
|
|
||||||
0x00, 0x00, 0x88, 0x88, 0xC8, 0xA8, 0xA8, 0xE8,
|
|
||||||
0x00, 0x00, 0x80, 0x80, 0xF0, 0x88, 0x88, 0xF0,
|
|
||||||
0x00, 0x00, 0x70, 0x88, 0x38, 0x08, 0x88, 0x70,
|
|
||||||
0x00, 0x00, 0x90, 0xA8, 0xA8, 0xE8, 0xA8, 0x90,
|
|
||||||
0x00, 0x00, 0x38, 0x48, 0x48, 0x38, 0x28, 0x48,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
|
||||||
|
|
91
vfs.c
91
vfs.c
@ -1,91 +0,0 @@
|
|||||||
// vfs.c
|
|
||||||
// Author: Josh Holtrop
|
|
||||||
// Created: 12/31/03
|
|
||||||
// Modified: 01/04/04
|
|
||||||
|
|
||||||
|
|
||||||
void vfs_init()
|
|
||||||
{
|
|
||||||
firstDiskDevice = malloc(sizeof(DiskDevice));
|
|
||||||
firstDiskDevice->type = VFS_DISK_FD;
|
|
||||||
firstDiskDevice->fileSystem = VFS_FS_FAT12;
|
|
||||||
firstDiskDevice->location = VFS_LOC_FD0;
|
|
||||||
firstDiskDevice->link = 0;
|
|
||||||
strcpy(firstDiskDevice->id, "fd0");
|
|
||||||
rootDevice = firstDiskDevice;
|
|
||||||
if (*(byte *)0xC0090000) // the user chose to load an initial ram disk from the floppy
|
|
||||||
{
|
|
||||||
DiskDevice *rd = malloc(sizeof(DiskDevice));
|
|
||||||
firstDiskDevice->link = (dword)rd;
|
|
||||||
rd->type = VFS_DISK_RD;
|
|
||||||
rd->fileSystem = VFS_FS_FAT12;
|
|
||||||
rd->location = 0xC0200000;
|
|
||||||
rd->link = 0;
|
|
||||||
strcpy(rd->id, "rd0");
|
|
||||||
rootDevice = rd;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
byte *vfs_readFile(char *fileName)
|
|
||||||
{
|
|
||||||
DiskDevice *dd;
|
|
||||||
dword fileStartPosition;
|
|
||||||
if (fileName[0] == '/')
|
|
||||||
{
|
|
||||||
dd = rootDevice;
|
|
||||||
fileStartPosition = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (strlen(fileName) < 5) //not a long enough file name
|
|
||||||
return 0;
|
|
||||||
if (!((fileName[3] == ':') && (fileName[4] == '/'))) //if we aren't using the root directory, then there must be a 3 character device explicitly specified
|
|
||||||
return 0; // followed by a colon and then a slash
|
|
||||||
char device[4];
|
|
||||||
memcpy(device, fileName, 3); //copy the 3 digit device id to device
|
|
||||||
device[3] = 0; //null-terminating character for device string
|
|
||||||
dd = vfs_getDiskDeviceByID(device);
|
|
||||||
if (!dd) //the specified device was not found
|
|
||||||
return 0;
|
|
||||||
fileStartPosition = 5;
|
|
||||||
}
|
|
||||||
switch (dd->fileSystem)
|
|
||||||
{
|
|
||||||
case VFS_FS_FAT12:
|
|
||||||
return fat12_readFile(fileName+fileStartPosition, dd);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
byte *vfs_readSector(DiskDevice *dd, dword sector, byte *dest, dword sectors)
|
|
||||||
{
|
|
||||||
byte *origDest = dest;
|
|
||||||
switch (dd->type)
|
|
||||||
{
|
|
||||||
case VFS_DISK_RD:
|
|
||||||
for (; sectors > 0; sectors--, dest += 512, sector++)
|
|
||||||
rd_readSector(dd, sector, dest);
|
|
||||||
return origDest;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
DiskDevice *vfs_getDiskDeviceByID(char *id)
|
|
||||||
{
|
|
||||||
DiskDevice *dd = firstDiskDevice;
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
if (strcmp(dd->id, id))
|
|
||||||
return dd;
|
|
||||||
dd = (DiskDevice *)dd->link;
|
|
||||||
if (!dd)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
33
vfs.h
33
vfs.h
@ -1,33 +0,0 @@
|
|||||||
// vfs.h
|
|
||||||
// Author: Josh Holtrop
|
|
||||||
// Created: 12/31/03
|
|
||||||
// Modified: 01/04/04
|
|
||||||
|
|
||||||
|
|
||||||
#define VFS_DISK_RD 1
|
|
||||||
#define VFS_DISK_FD 2
|
|
||||||
#define VFS_DISK_HD 3
|
|
||||||
|
|
||||||
#define VFS_FS_FAT12 1
|
|
||||||
|
|
||||||
#define VFS_LOC_FD0 1
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
dword type;
|
|
||||||
dword fileSystem;
|
|
||||||
dword location;
|
|
||||||
dword link;
|
|
||||||
char id[4];
|
|
||||||
} __attribute__((packed)) DiskDevice;
|
|
||||||
|
|
||||||
|
|
||||||
void vfs_init();
|
|
||||||
byte *vfs_readFile(char *fileName);
|
|
||||||
byte *vfs_readSector(DiskDevice *dd, dword sector, byte *dest, dword sectors);
|
|
||||||
DiskDevice *vfs_getDiskDeviceByID(char *id);
|
|
||||||
|
|
||||||
DiskDevice *rootDevice = 0;
|
|
||||||
DiskDevice *firstDiskDevice = 0;
|
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user