Import backup from 2003-12-31
This commit is contained in:
parent
76398df125
commit
c613002307
14
Functions.c
14
Functions.c
@ -38,6 +38,13 @@ inline void disable_ints()
|
|||||||
asm("cli");
|
asm("cli");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
char *strcat(char *dest, char *src)
|
||||||
|
{
|
||||||
|
strcpy(dest+strlen(dest), src);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//Re-maps the Programmable Interrupr Controllers so IRQ0->pic1 base address, IRG8->pic2 base address
|
//Re-maps the Programmable Interrupr Controllers so IRQ0->pic1 base address, IRG8->pic2 base address
|
||||||
void remap_pics(int pic1, int pic2)
|
void remap_pics(int pic1, int pic2)
|
||||||
{
|
{
|
||||||
@ -108,13 +115,6 @@ inline void init_timer()
|
|||||||
outportb(0x40, 0x2e); //msb
|
outportb(0x40, 0x2e); //msb
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Invalidates the page tables to re-cache the Translation Lookaside Buffer
|
|
||||||
/*inline void invlpg()
|
|
||||||
{
|
|
||||||
asm("invlpg");
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//Signals an End Of Interrupt signal to the first PIC
|
//Signals an End Of Interrupt signal to the first PIC
|
||||||
inline void eoi()
|
inline void eoi()
|
||||||
{
|
{
|
||||||
|
64
asmfuncs.asm
64
asmfuncs.asm
@ -52,6 +52,70 @@ _read_cr3:
|
|||||||
mov eax, cr3;
|
mov eax, cr3;
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
;copies a string from the source to the destination parameter
|
||||||
|
;extern void strcpy(char *dest, char *src);
|
||||||
|
[global _strcpy]
|
||||||
|
_strcpy:
|
||||||
|
push ebp
|
||||||
|
mov ebp, esp
|
||||||
|
push esi
|
||||||
|
push edi
|
||||||
|
mov edi, [ebp+8]
|
||||||
|
mov esi, [ebp+12]
|
||||||
|
strcpyloop:
|
||||||
|
lodsb
|
||||||
|
stosb
|
||||||
|
or al, al
|
||||||
|
jnz strcpyloop
|
||||||
|
pop edi
|
||||||
|
pop esi
|
||||||
|
pop ebp
|
||||||
|
ret
|
||||||
|
|
||||||
|
;copies memory of n bytes from src to destination
|
||||||
|
;extern void memcpy(dword dest, dword src, dword n);
|
||||||
|
[global _memcpy]
|
||||||
|
_memcpy:
|
||||||
|
push ebp
|
||||||
|
mov ebp, esp
|
||||||
|
push esi
|
||||||
|
push edi
|
||||||
|
push ecx
|
||||||
|
mov edi, [ebp+8]
|
||||||
|
mov esi, [ebp+12]
|
||||||
|
mov ecx, [ebp+16]
|
||||||
|
|
||||||
|
rep movsb
|
||||||
|
|
||||||
|
pop ecx
|
||||||
|
pop edi
|
||||||
|
pop esi
|
||||||
|
pop ebp
|
||||||
|
ret
|
||||||
|
|
||||||
|
;returns the number of characters in a string
|
||||||
|
;extern dword strlen(char *str);
|
||||||
|
[global _strlen]
|
||||||
|
_strlen:
|
||||||
|
push ebp
|
||||||
|
mov ebp, esp
|
||||||
|
push esi
|
||||||
|
push ebx
|
||||||
|
mov esi, [ebp+8]
|
||||||
|
xor ebx, ebx
|
||||||
|
strlenloop:
|
||||||
|
lodsb
|
||||||
|
or al, al
|
||||||
|
jz strlendone
|
||||||
|
inc ebx
|
||||||
|
jmp strlenloop
|
||||||
|
strlendone:
|
||||||
|
mov eax, ebx
|
||||||
|
pop ebx
|
||||||
|
pop esi
|
||||||
|
pop ebp
|
||||||
|
ret
|
||||||
|
|
||||||
;this function invalidates the page directory/table entry that
|
;this function invalidates the page directory/table entry that
|
||||||
; would be used to access the memory address given in the parameter
|
; would be used to access the memory address given in the parameter
|
||||||
;extern void invlpg(dword addr);
|
;extern void invlpg(dword addr);
|
||||||
|
@ -21,8 +21,7 @@ inline void eoi();
|
|||||||
inline void eoi2();
|
inline void eoi2();
|
||||||
inline dword kernel_size();
|
inline dword kernel_size();
|
||||||
inline void init_timer();
|
inline void init_timer();
|
||||||
//inline void invlpg();
|
char *strcat(char *dest, char *src);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
1
gccasm.bat
Executable file
1
gccasm.bat
Executable file
@ -0,0 +1 @@
|
|||||||
|
gcc -S kernel.c -masm=intel -fno-builtin
|
9
kernel.c
9
kernel.c
@ -16,6 +16,8 @@
|
|||||||
#include "fdc.h" //Floppy Disk Controller functions
|
#include "fdc.h" //Floppy Disk Controller functions
|
||||||
#include "stdfont.h" //Standard font bitmask array
|
#include "stdfont.h" //Standard font bitmask array
|
||||||
#include "kio.h"
|
#include "kio.h"
|
||||||
|
#include "vfs.h"
|
||||||
|
#include "rd.h"
|
||||||
|
|
||||||
void isr(dword num);
|
void isr(dword num);
|
||||||
void k_init();
|
void k_init();
|
||||||
@ -32,7 +34,12 @@ extern void console_cls();
|
|||||||
extern int puts(char *str);
|
extern int puts(char *str);
|
||||||
extern int putDec(int number);
|
extern int putDec(int number);
|
||||||
extern int putDecu(dword number);
|
extern int putDecu(dword number);
|
||||||
|
extern void strcpy(char *dest, char *src);
|
||||||
|
extern void memcpy(dword dest, dword src, dword n);
|
||||||
|
extern dword strlen(char *str);
|
||||||
|
|
||||||
|
#include "rd.c"
|
||||||
|
#include "vfs.c"
|
||||||
#include "kio.c"
|
#include "kio.c"
|
||||||
#include "fdc.c"
|
#include "fdc.c"
|
||||||
#include "mouse.c"
|
#include "mouse.c"
|
||||||
@ -58,6 +65,7 @@ void k_init()
|
|||||||
mouse_init();
|
mouse_init();
|
||||||
pic1_mask(0); //unmask IRQ's 0-7
|
pic1_mask(0); //unmask IRQ's 0-7
|
||||||
pic2_mask(0); //unmask IRQ's 8-15
|
pic2_mask(0); //unmask IRQ's 8-15
|
||||||
|
vfs_init();
|
||||||
enable_ints();
|
enable_ints();
|
||||||
kbd_resetLEDs(); //after enabling interrupts!!
|
kbd_resetLEDs(); //after enabling interrupts!!
|
||||||
if (videoMode)
|
if (videoMode)
|
||||||
@ -71,6 +79,7 @@ void k_init()
|
|||||||
printf("HOS 0.13 - Kernel File Size: %u kb\tData Size: %u bytes\n", kernel_size()>>10, (dword)(&_end)-(dword)(&_code));
|
printf("HOS 0.13 - Kernel File Size: %u kb\tData Size: %u bytes\n", kernel_size()>>10, (dword)(&_end)-(dword)(&_code));
|
||||||
printf("Memory available to OS: %u MB (%u bytes)\n", mm_megabytes, mm_totalmem);
|
printf("Memory available to OS: %u MB (%u bytes)\n", mm_megabytes, mm_totalmem);
|
||||||
printf("Free memory: %u bytes (%u pages)\n", mm_freemem(), mm_freemem()>>12);
|
printf("Free memory: %u bytes (%u pages)\n", mm_freemem(), mm_freemem()>>12);
|
||||||
|
printf("Root Directory: %s/\n", rootDirectory);
|
||||||
|
|
||||||
dword key = 0;
|
dword key = 0;
|
||||||
for (;;)
|
for (;;)
|
||||||
|
13
rd.c
Normal file
13
rd.c
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// rd.c
|
||||||
|
// Author: Josh Holtrop
|
||||||
|
// Created: 12/31/03
|
||||||
|
|
||||||
|
|
||||||
|
byte *rd_readSector(DiskDevice *rd, dword sector)
|
||||||
|
{
|
||||||
|
dword dest = (dword)malloc(512);
|
||||||
|
memcpy(dest, rd->location + (sector * 512), 512);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
8
rd.h
Normal file
8
rd.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// rd.h
|
||||||
|
// Author: Josh Holtrop
|
||||||
|
// Created: 12/31/03
|
||||||
|
|
||||||
|
|
||||||
|
byte *rd_readSector(DiskDevice *rd, dword sector);
|
||||||
|
|
||||||
|
|
71
vfs.c
71
vfs.c
@ -0,0 +1,71 @@
|
|||||||
|
// vfs.c
|
||||||
|
// Author: Josh Holtrop
|
||||||
|
// Created: 12/31/03
|
||||||
|
|
||||||
|
|
||||||
|
void vfs_init()
|
||||||
|
{
|
||||||
|
byte ramDiskPresent = *(byte *)0xC0090000;
|
||||||
|
if (ramDiskPresent)
|
||||||
|
{
|
||||||
|
strcpy(rootDirectory, "rd0");
|
||||||
|
firstDevice = malloc(sizeof(DeviceEntry));
|
||||||
|
firstDevice->link = 0;
|
||||||
|
firstDevice->diskDevice = malloc(sizeof(DiskDevice));
|
||||||
|
firstDevice->diskDevice->type = VFS_DISK_RD;
|
||||||
|
firstDevice->diskDevice->fileSystem = VFS_FS_FAT12;
|
||||||
|
strcpy(firstDevice->diskDevice->id, "rd0");
|
||||||
|
firstDevice->diskDevice->location = 0xC0200000;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rootDirectory[0] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
byte *vfs_readFile(char *fileName)
|
||||||
|
{
|
||||||
|
char *newFileName = fileName;
|
||||||
|
char device[4];
|
||||||
|
if (fileName[0] == '/')
|
||||||
|
{
|
||||||
|
newFileName = malloc(strlen(fileName)+4);
|
||||||
|
strcpy(newFileName, rootDirectory);
|
||||||
|
strcat(newFileName, fileName);
|
||||||
|
}
|
||||||
|
strcpy(device, newFileName);
|
||||||
|
DiskDevice *dd = vfs_getDiskDeviceByID(device);
|
||||||
|
|
||||||
|
if (newFileName != fileName)
|
||||||
|
free(newFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
byte *vfs_readSector(DiskDevice *dd, dword sector)
|
||||||
|
{
|
||||||
|
switch(dd->type)
|
||||||
|
{
|
||||||
|
case VFS_DISK_RD:
|
||||||
|
return rd_readSector(dd, sector);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DiskDevice *vfs_getDiskDeviceByID(char *id)
|
||||||
|
{
|
||||||
|
DeviceEntry *de = firstDevice;
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
if (strcmp(de->diskDevice->id, id))
|
||||||
|
return de->diskDevice;
|
||||||
|
de = (DeviceEntry *)de->link;
|
||||||
|
if (!de)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
34
vfs.h
34
vfs.h
@ -0,0 +1,34 @@
|
|||||||
|
// vfs.h
|
||||||
|
// Author: Josh Holtrop
|
||||||
|
// Created: 12/31/03
|
||||||
|
|
||||||
|
|
||||||
|
#define VFS_DISK_RD 1
|
||||||
|
#define VFS_DISK_FD 2
|
||||||
|
#define VFS_DISK_HD 3
|
||||||
|
|
||||||
|
#define VFS_FS_FAT12 1
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
dword type;
|
||||||
|
dword fileSystem;
|
||||||
|
char id[4];
|
||||||
|
dword location;
|
||||||
|
} __attribute__((packed)) DiskDevice;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
DiskDevice *diskDevice;
|
||||||
|
dword link;
|
||||||
|
} __attribute__((packed)) DeviceEntry;
|
||||||
|
|
||||||
|
|
||||||
|
void vfs_init();
|
||||||
|
byte *vfs_readFile(char *fileName);
|
||||||
|
byte *vfs_readSector(DiskDevice *dd, dword sector);
|
||||||
|
DiskDevice *vfs_getDiskDeviceByID(char *id);
|
||||||
|
|
||||||
|
char rootDirectory[4];
|
||||||
|
DeviceEntry *firstDevice = 0;
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user