Import backup from 2004-05-22
This commit is contained in:
parent
6b6e19effd
commit
a982312d2c
@ -30,7 +30,7 @@ LD_FLAGS=-nodefaultlibs -nostdlib --no-demangle -T link.ld
|
|||||||
# Linking the kernel together #
|
# Linking the kernel together #
|
||||||
###############################
|
###############################
|
||||||
all: Asm_Kernel Asm_Functions C_Kernel
|
all: Asm_Kernel Asm_Functions C_Kernel
|
||||||
$(LD) $(LD_FLAGS) -o kernel.bin -Map ./lst/LDout.doc ks.o kernel.o asmfuncs.o fdc.o keyboard.o kio.o mm.o mouse.o stdfont.o video.o vmm.o rtc.o pic.o io.o string.o cmos.o hos_defines.o
|
$(LD) $(LD_FLAGS) -o kernel.bin -Map ./lst/LDout.doc ks.o kernel.o asmfuncs.o fdc.o keyboard.o kio.o mm.o mouse.o stdfont.o video.o vmm.o rtc.o pic.o io.o string.o cmos.o hos_defines.o vfs.o
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
# Assembly Kernel Loader #
|
# Assembly Kernel Loader #
|
||||||
@ -54,7 +54,7 @@ C_Kernel:
|
|||||||
$(CPP) $(CPP_FLAGS) -c sys/pic.cpp -o pic.o
|
$(CPP) $(CPP_FLAGS) -c sys/pic.cpp -o pic.o
|
||||||
$(CPP) $(CPP_FLAGS) -c sys/io.cpp -o io.o
|
$(CPP) $(CPP_FLAGS) -c sys/io.cpp -o io.o
|
||||||
$(CPP) $(CPP_FLAGS) -c sys/cmos.cpp -o cmos.o
|
$(CPP) $(CPP_FLAGS) -c sys/cmos.cpp -o cmos.o
|
||||||
$(CPP) $(CPP_FLAGS) -c string/string.cpp -o string.o
|
$(CPP) $(CPP_FLAGS) -c lang/string.cpp -o string.o
|
||||||
$(CPP) $(CPP_FLAGS) -c video/stdfont.cpp -o stdfont.o
|
$(CPP) $(CPP_FLAGS) -c video/stdfont.cpp -o stdfont.o
|
||||||
$(CPP) $(CPP_FLAGS) -c video/video.cpp -o video.o
|
$(CPP) $(CPP_FLAGS) -c video/video.cpp -o video.o
|
||||||
$(CPP) $(CPP_FLAGS) -c block/fdc.cpp -o fdc.o
|
$(CPP) $(CPP_FLAGS) -c block/fdc.cpp -o fdc.o
|
||||||
@ -63,6 +63,7 @@ C_Kernel:
|
|||||||
$(CPP) $(CPP_FLAGS) -c mm/mm.cpp -o mm.o
|
$(CPP) $(CPP_FLAGS) -c mm/mm.cpp -o mm.o
|
||||||
$(CPP) $(CPP_FLAGS) -c mm/vmm.cpp -o vmm.o
|
$(CPP) $(CPP_FLAGS) -c mm/vmm.cpp -o vmm.o
|
||||||
$(CPP) $(CPP_FLAGS) -c hos_defines.cpp -o hos_defines.o
|
$(CPP) $(CPP_FLAGS) -c hos_defines.cpp -o hos_defines.o
|
||||||
|
$(CPP) $(CPP_FLAGS) -c fs/vfs.cpp -o vfs.o
|
||||||
|
|
||||||
#################################################
|
#################################################
|
||||||
# Clean up the source directory of any binaries #
|
# Clean up the source directory of any binaries #
|
||||||
|
@ -3,112 +3,17 @@
|
|||||||
// Date: 03/11/04
|
// Date: 03/11/04
|
||||||
// Modified: 03/16/04
|
// Modified: 03/16/04
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
#include "fs/vfat.h"
|
|
||||||
#include "hos_defines.h"
|
#include "hos_defines.h"
|
||||||
#include "block/rd.h"
|
#include "vfs.h"
|
||||||
#include "block/loop.h"
|
//#include "fs/vfat.h"
|
||||||
|
//#include "block/rd.h"
|
||||||
|
//#include "block/loop.h"
|
||||||
|
#include "lang/LinkedList.h"
|
||||||
|
#include "kio.h"
|
||||||
|
|
||||||
Volume *firstVolume = 0;
|
void vfs_init()
|
||||||
Volume *rootVolume = 0;
|
|
||||||
MountPoint *firstMountPoint = 0;
|
|
||||||
|
|
||||||
void vfs_init()
|
|
||||||
{
|
{
|
||||||
if(*(byte *)BOOT_HASRD) //bootloader loaded an initial ram disk
|
|
||||||
{
|
|
||||||
Volume *initrd = vfs_newVolume();
|
|
||||||
RamDisk *rd = rd_newDisk(0xC0200000, 1440*1024);
|
|
||||||
initrd->diskDevice = rd;
|
|
||||||
initrd->deviceType = VFS_RD;
|
|
||||||
strcpy(initrd->label, "rd0");
|
|
||||||
initrd->link = 0;
|
|
||||||
rootVolume = initrd;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Volume *vfs_newVolume()
|
|
||||||
{
|
|
||||||
Volume *vol = malloc(sizeof(Volume));
|
|
||||||
vfs_getLastVolume()->link = vol;
|
|
||||||
return vol;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Volume *vfs_getLastVolume()
|
|
||||||
{
|
|
||||||
Volume *vol = firstVolume;
|
|
||||||
while (vol)
|
|
||||||
vol = vol->link;
|
|
||||||
return vol;
|
|
||||||
}
|
|
||||||
|
|
||||||
int vfs_readSector(Volume *vol, dword sector, byte *buffer)
|
|
||||||
{
|
|
||||||
switch(vol->deviceType)
|
|
||||||
{
|
|
||||||
case VFS_RD:
|
|
||||||
return rd_readSector(vol->diskDevice, sector, buffer);
|
|
||||||
case VFS_LOOP:
|
|
||||||
return loop_readSector(vol->diskDevice, sector, buffer);
|
|
||||||
default:
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int vfs_writeSector(Volume *vol, dword sector, byte *buffer)
|
|
||||||
{
|
|
||||||
switch(vol->deviceType)
|
|
||||||
{
|
|
||||||
case VFS_RD:
|
|
||||||
return rd_writeSector(vol->diskDevice, sector, buffer);
|
|
||||||
case VFS_LOOP:
|
|
||||||
return loop_writeSector(vol->diskDevice, sector, buffer);
|
|
||||||
default:
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int vfs_readSectorn(Volume *vol, dword sector, byte *buffer, int n)
|
|
||||||
{
|
|
||||||
int r;
|
|
||||||
for (; n > 0; --n, ++sector, buffer += 512)
|
|
||||||
{
|
|
||||||
r = vfs_readSector(vol, sector, buffer);
|
|
||||||
if (r) return r;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int vfs_writeSectorn(Volume *vol, dword sector, byte *buffer, int n)
|
|
||||||
{
|
|
||||||
int r;
|
|
||||||
for (; n > 0; --n, ++sector, buffer += 512)
|
|
||||||
{
|
|
||||||
r = vfs_writeSector(vol, sector, buffer);
|
|
||||||
if (r) return r;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int vfs_readFileBlock(Volume *vol, char *file, dword start, byte *buffer, dword blockSize)
|
|
||||||
{
|
|
||||||
switch(vol->fsType)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int vfs_writeFileBlock(Volume *vol, char *file, dword start, byte *buffer, dword blockSize)
|
|
||||||
{
|
|
||||||
switch(vol->fsType)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,58 +1,14 @@
|
|||||||
// vfs.h
|
// vfs.h
|
||||||
// Author: Josh Holtrop
|
// Author: Josh Holtrop
|
||||||
// Date: 03/11/04
|
// Date: 03/11/04
|
||||||
// Modified: 03/16/04
|
// Modified: 05/21/04
|
||||||
|
|
||||||
#ifndef __HOS_VFS__
|
#ifndef __HOS_VFS__
|
||||||
#define __HOS_VFS__ __HOS_VFS__
|
#define __HOS_VFS__ __HOS_VFS__
|
||||||
|
|
||||||
#include "hos_defines.h"
|
#include "hos_defines.h"
|
||||||
|
|
||||||
#define VFS_LABEL_LENGTH 8
|
void vfs_init();
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
void *diskDevice; //pointer to device-dependent structure
|
|
||||||
int length; //size of the volume in bytes
|
|
||||||
int deviceType; //one of VFS_DISK_TYPES
|
|
||||||
int fsType; //one of VFS_FS_TYPES
|
|
||||||
char label[VFS_LABEL_LENGTH]; //descriptive volume label
|
|
||||||
void *link; //link to next volume in linked list
|
|
||||||
} Volume;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
dword location; //location used by disk driver
|
|
||||||
dword dataLocation; //location used by disk driver
|
|
||||||
dword position; //read/write position in file
|
|
||||||
dword attributes; //read/write
|
|
||||||
dword fileSize; //number of bytes the file takes
|
|
||||||
Volume *vol; //what volume this file is on
|
|
||||||
} FILE;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
char *device;
|
|
||||||
char *mount;
|
|
||||||
void *mp;
|
|
||||||
} MountPoint;
|
|
||||||
|
|
||||||
#define FILE_READ 1
|
|
||||||
#define FILE_WRITE 2
|
|
||||||
#define FILE_READ_WRITE 3
|
|
||||||
|
|
||||||
enum VFS_DISK_TYPES {VFS_NODISK, VFS_RD, VFS_FD, VFS_HD, VFS_LOOP, VFS_NUM_DISK_TYPES};
|
|
||||||
enum VFS_FS_TYPES {VFS_NOFS, VFS_VFAT, VFS_EXT2, VFS_NUM_FS_TYPES};
|
|
||||||
|
|
||||||
void vfs_init();
|
|
||||||
Volume *vfs_newVolume();
|
|
||||||
Volume *vfs_getLastVolume();
|
|
||||||
int vfs_readSector(Volume *vol, dword sector, byte *buffer);
|
|
||||||
int vfs_writeSector(Volume *vol, dword sector, byte *buffer);
|
|
||||||
int vfs_readSectorn(Volume *vol, dword sector, byte *buffer, int n);
|
|
||||||
int vfs_writeSectorn(Volume *vol, dword sector, byte *buffer, int n);
|
|
||||||
int vfs_readFileBlock(Volume *vol, char *file, dword start, byte *buffer, dword blockSize);
|
|
||||||
int vfs_writeFileBlock(Volume *vol, char *file, dword start, byte *buffer, dword blockSize);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -14,13 +14,12 @@
|
|||||||
#include "char/keyboard.h" //generic keyboard driver & functions
|
#include "char/keyboard.h" //generic keyboard driver & functions
|
||||||
#include "char/mouse.h" //generic ps/2 mouse driver & functions
|
#include "char/mouse.h" //generic ps/2 mouse driver & functions
|
||||||
#include "block/fdc.h" //Floppy Disk Controller functions
|
#include "block/fdc.h" //Floppy Disk Controller functions
|
||||||
#include "string/string.h" //string functions
|
|
||||||
#include "sys/cmos.h" //CMOS interface functions
|
#include "sys/cmos.h" //CMOS interface functions
|
||||||
#include "sys/io.h" //port i/o functions
|
#include "sys/io.h" //port i/o functions
|
||||||
#include "sys/pic.h" //Programmable Interrupt Controller functions
|
#include "sys/pic.h" //Programmable Interrupt Controller functions
|
||||||
#include "sys/rtc.h" //Real Time Clock functions
|
#include "sys/rtc.h" //Real Time Clock functions
|
||||||
#include "video/stdfont.h" //Standard font bitmask array
|
|
||||||
#include "video/video.h" //video functions
|
#include "video/video.h" //video functions
|
||||||
|
#include "fs/vfs.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
@ -34,10 +33,11 @@ void k_init()
|
|||||||
{
|
{
|
||||||
// ===== Initialization
|
// ===== Initialization
|
||||||
fdc_sendDOR(0x0C); //turn off floppy motor!!
|
fdc_sendDOR(0x0C); //turn off floppy motor!!
|
||||||
kio_console_cls();
|
|
||||||
video_init();
|
|
||||||
mm_init();
|
mm_init();
|
||||||
vmm_init();
|
vmm_init();
|
||||||
|
video_init();
|
||||||
|
kio_init();
|
||||||
|
kio_console_cls();
|
||||||
pic_remap(0x20, 0x28);
|
pic_remap(0x20, 0x28);
|
||||||
timer_init();
|
timer_init();
|
||||||
mouse_init();
|
mouse_init();
|
||||||
@ -68,6 +68,8 @@ void k_init()
|
|||||||
printf("Built on %s at %s\n", __DATE__, __TIME__);
|
printf("Built on %s at %s\n", __DATE__, __TIME__);
|
||||||
printf("%b/%b/%b %b:%b:%b\n", rtc_readMonth(), rtc_readDay(), rtc_readYear(), rtc_readHour(), rtc_readMinute(), rtc_readSecond());
|
printf("%b/%b/%b %b:%b:%b\n", rtc_readMonth(), rtc_readDay(), rtc_readYear(), rtc_readHour(), rtc_readMinute(), rtc_readSecond());
|
||||||
|
|
||||||
|
vfs_init();
|
||||||
|
|
||||||
dword key = 0;
|
dword key = 0;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
@ -8,12 +8,21 @@
|
|||||||
#include "asmfuncs.h"
|
#include "asmfuncs.h"
|
||||||
#include "video/video.h"
|
#include "video/video.h"
|
||||||
|
|
||||||
dword cursorPosition = 0; //Caches the current cursor position
|
dword graphical;
|
||||||
|
dword cursorPosition; //Caches the current cursor position
|
||||||
word console_memory[2000]; //holds a copy of the console's memory
|
word console_memory[2000]; //holds a copy of the console's memory
|
||||||
|
|
||||||
// This is the main output routine, it uses a format string and a variable
|
// This is the main output routine, it uses a format string and a variable
|
||||||
// number of arguments to print formatted text
|
// number of arguments to print formatted text
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
|
void kio_init()
|
||||||
|
{
|
||||||
|
graphical = video_Mode();
|
||||||
|
cursorPosition = 0;
|
||||||
|
writeCursorPosition(0);
|
||||||
|
}
|
||||||
|
|
||||||
void printf(char *fmt, ...)
|
void printf(char *fmt, ...)
|
||||||
{
|
{
|
||||||
dword *params = ((dword *)(&fmt)) + 1; //points to the first paramater
|
dword *params = ((dword *)(&fmt)) + 1; //points to the first paramater
|
||||||
@ -95,7 +104,7 @@ void putc(dword chr)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (video_Mode())
|
if (graphical)
|
||||||
{
|
{
|
||||||
console_memory[cursorPosition] = charac | 0x0700;
|
console_memory[cursorPosition] = charac | 0x0700;
|
||||||
kio_drawConsoleChar(cursorPosition);
|
kio_drawConsoleChar(cursorPosition);
|
||||||
@ -112,7 +121,7 @@ void putc(dword chr)
|
|||||||
kio_console_scroll();
|
kio_console_scroll();
|
||||||
cursorPosition = 2000-80;
|
cursorPosition = 2000-80;
|
||||||
}
|
}
|
||||||
if (!video_Mode())
|
if (!graphical)
|
||||||
writeCursorPosition(cursorPosition);
|
writeCursorPosition(cursorPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,7 +158,7 @@ void kio_console_scroll()
|
|||||||
{
|
{
|
||||||
memcpyd(console_memory, console_memory + 80, 960);
|
memcpyd(console_memory, console_memory + 80, 960);
|
||||||
memsetw(console_memory + 1920, 0x0720, 80);
|
memsetw(console_memory + 1920, 0x0720, 80);
|
||||||
if (video_Mode())
|
if (graphical)
|
||||||
kio_drawConsole();
|
kio_drawConsole();
|
||||||
else
|
else
|
||||||
memcpyd((void *)0xC00B8000, console_memory, 1000);
|
memcpyd((void *)0xC00B8000, console_memory, 1000);
|
||||||
@ -159,7 +168,7 @@ void kio_console_scroll()
|
|||||||
void kio_console_cls()
|
void kio_console_cls()
|
||||||
{
|
{
|
||||||
memsetw(console_memory, 0x0720, 2000);
|
memsetw(console_memory, 0x0720, 2000);
|
||||||
if (video_Mode())
|
if (graphical)
|
||||||
kio_drawConsole();
|
kio_drawConsole();
|
||||||
else
|
else
|
||||||
memcpyd((void *)0xC00B8000, console_memory, 1000);
|
memcpyd((void *)0xC00B8000, console_memory, 1000);
|
||||||
@ -210,6 +219,8 @@ dword kio_getCursorPosition()
|
|||||||
void kio_writeCursorPosition(dword position)
|
void kio_writeCursorPosition(dword position)
|
||||||
{
|
{
|
||||||
cursorPosition = position;
|
cursorPosition = position;
|
||||||
|
if (!graphical)
|
||||||
|
writeCursorPosition(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
|
void kio_init();
|
||||||
void printf(char *fmt, ...);
|
void printf(char *fmt, ...);
|
||||||
void putc(dword chr);
|
void putc(dword chr);
|
||||||
void putHex(dword number);
|
void putHex(dword number);
|
||||||
|
180
kernel/lang/LinkedList.h
Normal file
180
kernel/lang/LinkedList.h
Normal file
@ -0,0 +1,180 @@
|
|||||||
|
|
||||||
|
template <typename Element>
|
||||||
|
class LinkedList
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
class LinkedNode
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LinkedNode()
|
||||||
|
{
|
||||||
|
prev = next = 0;
|
||||||
|
}
|
||||||
|
LinkedNode(Element dataElement)
|
||||||
|
{
|
||||||
|
data = dataElement;
|
||||||
|
prev = next = 0;
|
||||||
|
}
|
||||||
|
Element data;
|
||||||
|
LinkedNode *next;
|
||||||
|
LinkedNode *prev;
|
||||||
|
};
|
||||||
|
|
||||||
|
LinkedNode *firstNode;
|
||||||
|
LinkedNode *lastNode;
|
||||||
|
int count;
|
||||||
|
|
||||||
|
public:
|
||||||
|
class iterator
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
LinkedNode *theNode;
|
||||||
|
public:
|
||||||
|
iterator(LinkedNode & node)
|
||||||
|
{
|
||||||
|
theNode = &node;
|
||||||
|
}
|
||||||
|
iterator(LinkedNode *node)
|
||||||
|
{
|
||||||
|
theNode = node;
|
||||||
|
}
|
||||||
|
Element & operator*()
|
||||||
|
{
|
||||||
|
return theNode->data;
|
||||||
|
}
|
||||||
|
Element & operator++()
|
||||||
|
{
|
||||||
|
theNode = theNode->next;
|
||||||
|
return theNode->data;
|
||||||
|
}
|
||||||
|
Element & operator++(int dum)
|
||||||
|
{
|
||||||
|
theNode = theNode->next;
|
||||||
|
return theNode->prev->data;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class reverse_iterator
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
LinkedNode *theNode;
|
||||||
|
public:
|
||||||
|
reverse_iterator(LinkedNode & node)
|
||||||
|
{
|
||||||
|
theNode = &node;
|
||||||
|
}
|
||||||
|
reverse_iterator(LinkedNode *node)
|
||||||
|
{
|
||||||
|
theNode = node;
|
||||||
|
}
|
||||||
|
Element & operator*()
|
||||||
|
{
|
||||||
|
return theNode->data;
|
||||||
|
}
|
||||||
|
Element & operator++()
|
||||||
|
{
|
||||||
|
theNode = theNode->prev;
|
||||||
|
return theNode->data;
|
||||||
|
}
|
||||||
|
Element & operator++(int dum)
|
||||||
|
{
|
||||||
|
theNode = theNode->prev;
|
||||||
|
return theNode->next->data;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
LinkedList();
|
||||||
|
int numElements() { return count; }
|
||||||
|
iterator begin() { return new iterator(firstNode); }
|
||||||
|
iterator end() { return new iterator(lastNode->next); }
|
||||||
|
reverse_iterator rbegin() { return new reverse_iterator(lastNode); }
|
||||||
|
reverse_iterator rend() { return new reverse_iterator(firstNode->prev); }
|
||||||
|
LinkedList & insert(int index, Element e);
|
||||||
|
LinkedList & push_back(Element e);
|
||||||
|
LinkedList & remove(int index);
|
||||||
|
LinkedList & pop_back();
|
||||||
|
Element & operator[](int index);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
LinkedList<T>::LinkedList()
|
||||||
|
{
|
||||||
|
firstNode = lastNode = new LinkedNode();
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Element>
|
||||||
|
LinkedList<Element> & LinkedList<Element>::insert(int index, Element e)
|
||||||
|
{
|
||||||
|
if (index == count)
|
||||||
|
push_back(e);
|
||||||
|
else if (index >= 0 && index < count)
|
||||||
|
{
|
||||||
|
LinkedNode *nptr = firstNode;
|
||||||
|
for (int i = 0; i <= index; i++)
|
||||||
|
nptr = nptr->next;
|
||||||
|
LinkedNode *newptr = new LinkedNode(e);
|
||||||
|
newptr->next = nptr;
|
||||||
|
newptr->prev = nptr->prev;
|
||||||
|
newptr->prev->next = newptr;
|
||||||
|
nptr->prev = newptr;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Element>
|
||||||
|
LinkedList<Element> & LinkedList<Element>::push_back(Element e)
|
||||||
|
{
|
||||||
|
lastNode->next = new LinkedNode(e);
|
||||||
|
lastNode->next->prev = lastNode;
|
||||||
|
lastNode = lastNode->next;
|
||||||
|
count++;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Element>
|
||||||
|
LinkedList<Element> & LinkedList<Element>::remove(int index)
|
||||||
|
{
|
||||||
|
if (index == count-1)
|
||||||
|
pop_back();
|
||||||
|
else if (index >= 0 && index < count)
|
||||||
|
{
|
||||||
|
LinkedNode *nptr = firstNode;
|
||||||
|
for (int i = 0; i <= index; i++)
|
||||||
|
nptr = nptr->next;
|
||||||
|
nptr->prev->next = nptr->next;
|
||||||
|
nptr->next->prev = nptr->prev;
|
||||||
|
delete nptr;
|
||||||
|
count--;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Element>
|
||||||
|
LinkedList<Element> & LinkedList<Element>::pop_back()
|
||||||
|
{
|
||||||
|
if (count)
|
||||||
|
{
|
||||||
|
lastNode = lastNode->prev;
|
||||||
|
delete lastNode->next;
|
||||||
|
lastNode->next = 0;
|
||||||
|
count--;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Element>
|
||||||
|
Element & LinkedList<Element>::operator[](int index)
|
||||||
|
{
|
||||||
|
if (index >= 0 && index < count)
|
||||||
|
{
|
||||||
|
LinkedNode *nptr = firstNode;
|
||||||
|
for (int i = 0; i <= index; i++)
|
||||||
|
nptr = nptr->next;
|
||||||
|
return nptr->data;
|
||||||
|
}
|
||||||
|
return firstNode->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -6,10 +6,8 @@
|
|||||||
|
|
||||||
#include "hos_defines.h"
|
#include "hos_defines.h"
|
||||||
#include "vmm.h"
|
#include "vmm.h"
|
||||||
#include "video/video.h"
|
|
||||||
#include "asmfuncs.h"
|
#include "asmfuncs.h"
|
||||||
#include "mm/mm.h"
|
#include "mm/mm.h"
|
||||||
#include "video/stdfont.h"
|
|
||||||
|
|
||||||
HeapEntry *firstHeapEntry = (HeapEntry *)0xD0000000; //this is where heap memory starts
|
HeapEntry *firstHeapEntry = (HeapEntry *)0xD0000000; //this is where heap memory starts
|
||||||
|
|
||||||
@ -21,15 +19,7 @@ void vmm_init()
|
|||||||
pageTables[0x3FF] = 0x104000|0x03; //the last page directory entry points to the page directory itself
|
pageTables[0x3FF] = 0x104000|0x03; //the last page directory entry points to the page directory itself
|
||||||
pageTables[0] = 0;
|
pageTables[0] = 0;
|
||||||
invlpg_(0);
|
invlpg_(0);
|
||||||
if (video_Mode()) //we are in a graphical mode
|
|
||||||
{
|
|
||||||
unsigned int vidPages = video_getWidth() * video_getHeight() * (video_getBitsPerPixel() >> 3);
|
|
||||||
if (vidPages % 4096)
|
|
||||||
vidPages = (vidPages >> 12) + 1;
|
|
||||||
else
|
|
||||||
vidPages = (vidPages >> 12);
|
|
||||||
vmm_mapn(0xF0000000, video_getPhysBasePtr(), vidPages);
|
|
||||||
}
|
|
||||||
unsigned int firstHeapEntryBlock = (unsigned int)mm_palloc();
|
unsigned int firstHeapEntryBlock = (unsigned int)mm_palloc();
|
||||||
vmm_map1((unsigned int)firstHeapEntry, firstHeapEntryBlock);
|
vmm_map1((unsigned int)firstHeapEntry, firstHeapEntryBlock);
|
||||||
HeapEntryBlock *heb = (HeapEntryBlock *)firstHeapEntry;
|
HeapEntryBlock *heb = (HeapEntryBlock *)firstHeapEntry;
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "hos_defines.h"
|
#include "hos_defines.h"
|
||||||
#include "video.h"
|
#include "video.h"
|
||||||
#include "video/stdfont.h"
|
#include "video/stdfont.h"
|
||||||
|
#include "mm/vmm.h"
|
||||||
|
|
||||||
ModeInfoBlock video_mode;
|
ModeInfoBlock video_mode;
|
||||||
dword videoMode = 0; //what video mode # we are in, 0 for console mode
|
dword videoMode = 0; //what video mode # we are in, 0 for console mode
|
||||||
@ -34,6 +35,14 @@ void video_init()
|
|||||||
case 32:
|
case 32:
|
||||||
video_psetp = &video_psetp32;
|
video_psetp = &video_psetp32;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int vidPages = video_mode.XResolution * video_mode.YResolution * (video_mode.BitsPerPixel >> 3);
|
||||||
|
if (vidPages % 4096)
|
||||||
|
vidPages = (vidPages >> 12) + 1;
|
||||||
|
else
|
||||||
|
vidPages = (vidPages >> 12);
|
||||||
|
vmm_mapn(0xF0000000, video_mode.PhysBasePtr, vidPages);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Renders a character using stdfont[] as a bitmask
|
//Renders a character using stdfont[] as a bitmask
|
||||||
|
Loading…
x
Reference in New Issue
Block a user