92 lines
1.7 KiB
C
92 lines
1.7 KiB
C
//kernel.c
|
|
//08/13/03 Josh Holtrop
|
|
//Holtrop's Operating System
|
|
|
|
#include "k_defines.h"
|
|
#include "functions.h"
|
|
|
|
void isr(int num);
|
|
void k_init();
|
|
|
|
#include "functions.c"
|
|
|
|
//9000:306
|
|
|
|
typedef struct{
|
|
USHORT ModeAttributes;
|
|
UCHAR WinAAttributes;
|
|
UCHAR WinBAttributes;
|
|
USHORT WinGranularity;
|
|
USHORT WinSize;
|
|
USHORT WinASegment;
|
|
USHORT WinBSegment;
|
|
UINT WinFuncPtr;
|
|
USHORT BytesPerScanLine;
|
|
|
|
USHORT XResolution;
|
|
USHORT YResolution;
|
|
UCHAR XCharSize;
|
|
UCHAR YCharSize;
|
|
UCHAR NumberOfPlanes;
|
|
UCHAR BitsPerPixel;
|
|
UCHAR NumberOfBanks;
|
|
UCHAR MemoryModel;
|
|
UCHAR BankSize;
|
|
UCHAR NumberOfImagePages;
|
|
UCHAR Reserved1;
|
|
|
|
UCHAR RedMaskSize;
|
|
UCHAR RedFieldPosition;
|
|
UCHAR GreenMaskSize;
|
|
UCHAR GreenFieldPosition;
|
|
UCHAR BlueMaskSize;
|
|
UCHAR BlueFieldPosition;
|
|
UCHAR RsvdMaskSize;
|
|
UCHAR RsvdFieldPosition;
|
|
UCHAR DirectColorModeInfo;
|
|
|
|
void *PhysBasePtr;
|
|
UINT OffScreenMemOffset;
|
|
USHORT OffScreenMemSize;
|
|
UCHAR Reserved[206];
|
|
} ModeInfoBlock;
|
|
|
|
|
|
|
|
|
|
void k_init()
|
|
{
|
|
remap_pics(0x20, 0x28);
|
|
//set timer : 2e9c = 100hz
|
|
outportb(0x43, 0x34);
|
|
outportb(0x40, 0x9c); //lsb
|
|
outportb(0x40, 0x2e); //msb
|
|
enable_ints();
|
|
ModeInfoBlock *mib = (ModeInfoBlock *) 0x90306;
|
|
UINT *vid = (UINT *) (mib->PhysBasePtr);
|
|
UINT a;
|
|
UINT tot = ((mib->XResolution) * (mib->YResolution));
|
|
for (a = 0; a < tot; a++)
|
|
{
|
|
if (a < (tot / 4))
|
|
vid[a] = 0x00FF0000;
|
|
else if (a < (tot / 2))
|
|
vid[a] = 0x0000FF00;
|
|
else if (a < ((tot * 3) / 4))
|
|
vid[a] = 0x000000FF;
|
|
else
|
|
vid[a] = 0x00FFFFFF;
|
|
}
|
|
}
|
|
|
|
void isr(int num)
|
|
{
|
|
if (num == 0x20)
|
|
{
|
|
(*(char*)0xB8000)++;
|
|
*(char*)0xB8001 = 7;
|
|
eoi();
|
|
}
|
|
}
|
|
|