Import backup from 2005-06-02
This commit is contained in:
parent
b0132c866e
commit
692cf2fc08
@ -22,7 +22,7 @@ all: Asm_Kernel C_Kernel
|
|||||||
@$(LD) $(LD_FLAGS) -Map kernel.map \
|
@$(LD) $(LD_FLAGS) -Map kernel.map \
|
||||||
boot.o kernel.o lang_a.o mm.o vmm.o conv.o kout.o \
|
boot.o kernel.o lang_a.o mm.o vmm.o conv.o kout.o \
|
||||||
vconsole.o display.o devices.o pic.o keyboard.o \
|
vconsole.o display.o devices.o pic.o keyboard.o \
|
||||||
ramdisk.o vfs.o lang_c.o vesafb.o \
|
ramdisk.o vfs.o lang_c.o \
|
||||||
string.o new.o ext2.o misc_char.o -o kernel.bin
|
string.o new.o ext2.o misc_char.o -o kernel.bin
|
||||||
@echo ' Kernel built: ' `ls -sk kernel.bin | cut -d' ' -f1`kb
|
@echo ' Kernel built: ' `ls -sk kernel.bin | cut -d' ' -f1`kb
|
||||||
|
|
||||||
@ -51,8 +51,6 @@ C_Kernel:
|
|||||||
@$(CC) $(CC_FLAGS) -c char/keyboard.c -o keyboard.o
|
@$(CC) $(CC_FLAGS) -c char/keyboard.c -o keyboard.o
|
||||||
@echo ' CC lang_c.o'
|
@echo ' CC lang_c.o'
|
||||||
@$(CC) $(CC_FLAGS) -c lang/lang.c -o lang_c.o
|
@$(CC) $(CC_FLAGS) -c lang/lang.c -o lang_c.o
|
||||||
@echo ' CC vesafb.o'
|
|
||||||
@$(CC) $(CC_FLAGS) -c display/vesafb.c -o vesafb.o
|
|
||||||
|
|
||||||
@echo ' CPP string.o'
|
@echo ' CPP string.o'
|
||||||
@$(CPP) $(CPP_FLAGS) -c lang/string.cpp -o string.o
|
@$(CPP) $(CPP_FLAGS) -c lang/string.cpp -o string.o
|
||||||
|
@ -1,28 +1,21 @@
|
|||||||
// keyboard.c
|
// keyboard.c
|
||||||
// Author: Josh Holtrop
|
// Author: Josh Holtrop
|
||||||
// Created: 04/17/03
|
// Created: 04/17/03
|
||||||
// Modified: 08/16/04
|
// Modified: 05/19/05
|
||||||
|
|
||||||
#include "hos_defines.h"
|
#include "hos_defines.h"
|
||||||
#include "char/keyboard.h"
|
#include "char/keyboard.h"
|
||||||
#include "sys/io.h" // inportb, outportb
|
#include "sys/io.h" // inportb, outportb
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
#include "lang/conv.h" // asciiSwitchCase()
|
#include "lang/conv.h" // asciiSwitchCase()
|
||||||
|
#include "display/kout.h" // kprintf()
|
||||||
#include "display/kout.h"
|
|
||||||
#include "display/display.h" // display_activate()
|
#include "display/display.h" // display_activate()
|
||||||
|
|
||||||
#define KBD_BUFFER_LENGTH 64
|
|
||||||
|
|
||||||
u8_t kbdFlags = 0; // holds current keyboard flags - caps/num/scroll/shift/ctrl/alt
|
u8_t kbdFlags = 0; // holds current keyboard flags - caps/num/scroll/shift/ctrl/alt
|
||||||
u8_t lastWasE0 = 0; // was the last byte 0x0E ?
|
u8_t lastWasE0 = 0; // was the last byte 0x0E ?
|
||||||
u32_t kbdBuffer[KBD_BUFFER_LENGTH]; // a buffer for all keypresses
|
|
||||||
int kbdBufferStart = 0; // position of next key in buffer
|
|
||||||
int kbdBufferLen = 0; // number of keys left in the buffer
|
|
||||||
u8_t rawIgnore = 0; // how many signals to blatantly ignore
|
u8_t rawIgnore = 0; // how many signals to blatantly ignore
|
||||||
u8_t ackReason = 0; // used to record the reason why we would get an acknowledge byte (0xFA)
|
u8_t ackReason = 0; // used to record the reason why we would get an acknowledge byte (0xFA)
|
||||||
|
|
||||||
|
|
||||||
//these arrays convert a keyboard scan code to an ASCII character value
|
//these arrays convert a keyboard scan code to an ASCII character value
|
||||||
const u8_t SCAN2ASCII[129] = // for normal keys
|
const u8_t SCAN2ASCII[129] = // for normal keys
|
||||||
"\000\0331234567890-=\010\011" // null,esc,1234567890-=,bksp,tab
|
"\000\0331234567890-=\010\011" // null,esc,1234567890-=,bksp,tab
|
||||||
@ -83,7 +76,6 @@ void isr_keyboard()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
switch (kbdScan) // handle control keys
|
switch (kbdScan) // handle control keys
|
||||||
{
|
{
|
||||||
case KBD_SCAN_LSHIFT:
|
case KBD_SCAN_LSHIFT:
|
||||||
@ -111,6 +103,7 @@ void isr_keyboard()
|
|||||||
case KBD_SCAN_ALT + KBD_SCAN_RELEASED:
|
case KBD_SCAN_ALT + KBD_SCAN_RELEASED:
|
||||||
kbdFlags &= (KBDF_ALT ^ 0xFF);
|
kbdFlags &= (KBDF_ALT ^ 0xFF);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KBD_SCAN_CAPS+KBD_SCAN_RELEASED:
|
case KBD_SCAN_CAPS+KBD_SCAN_RELEASED:
|
||||||
kbdFlags ^= KBDF_CAPS;
|
kbdFlags ^= KBDF_CAPS;
|
||||||
kbd_resetLEDs(); // update LEDs
|
kbd_resetLEDs(); // update LEDs
|
||||||
@ -142,48 +135,9 @@ void isr_keyboard()
|
|||||||
}
|
}
|
||||||
if (kbdScan & KBD_SCAN_RELEASED)
|
if (kbdScan & KBD_SCAN_RELEASED)
|
||||||
kbdAscii = 0;
|
kbdAscii = 0;
|
||||||
if (kbdBufferLen < KBD_BUFFER_LENGTH) //no key slots available
|
|
||||||
kbdBuffer[(kbdBufferStart+kbdBufferLen++)%KBD_BUFFER_LENGTH] = (u32_t) ((kbdFlags << 16) | (kbdScan << 8) | kbdAscii);
|
|
||||||
|
|
||||||
|
// send a key event to the display subsystem
|
||||||
if (kbdAscii)
|
display_key_event((kbdFlags << 16) | (kbdScan << 8) | kbdAscii);
|
||||||
kprintf("%c", kbdAscii);
|
|
||||||
// if (kbdFlags & KBDF_ALT)
|
|
||||||
// {
|
|
||||||
if (kbdScan >= 0x3B && kbdScan <= 0x44)
|
|
||||||
display_activate(kbdScan - 0x3B);
|
|
||||||
if (kbdScan >= 0x57 && kbdScan <= 0x58)
|
|
||||||
display_activate(kbdScan - 0x4D);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
//Gets a key from the buffer, returns 0 if no keys available, returns immediately
|
|
||||||
u32_t kbdGetKey()
|
|
||||||
{
|
|
||||||
if (kbdBufferLen == 0) // buffer empty
|
|
||||||
return 0;
|
|
||||||
u32_t retVal = kbdBuffer[kbdBufferStart];
|
|
||||||
kbdBufferStart++;
|
|
||||||
kbdBufferLen--;
|
|
||||||
if (kbdBufferStart >= KBD_BUFFER_LENGTH)
|
|
||||||
kbdBufferStart = 0;
|
|
||||||
return retVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Gets a key from the buffer, if no keys available, waits for one to be entered
|
|
||||||
u32_t kbdWaitKey()
|
|
||||||
{
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
if (kbdBufferLen != 0) // buffer empty
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
u32_t retVal = kbdBuffer[kbdBufferStart];
|
|
||||||
kbdBufferStart++;
|
|
||||||
kbdBufferLen--;
|
|
||||||
if (kbdBufferStart >= KBD_BUFFER_LENGTH)
|
|
||||||
kbdBufferStart = 0;
|
|
||||||
return retVal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Resets the keyboard LEDs to reflect the current state of the num lock, caps lock, and scroll lock bits
|
//Resets the keyboard LEDs to reflect the current state of the num lock, caps lock, and scroll lock bits
|
||||||
@ -195,4 +149,3 @@ void kbd_resetLEDs()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,35 +1,36 @@
|
|||||||
// keyboard.h
|
// keyboard.h
|
||||||
// Author: Josh Holtrop
|
// Author: Josh Holtrop
|
||||||
// Created: 04/17/03
|
// Created: 04/17/03
|
||||||
// Modified: 08/20/04
|
// Modified: 05/19/05
|
||||||
|
|
||||||
#include "hos_defines.h"
|
#include "hos_defines.h"
|
||||||
|
|
||||||
#ifndef __HOS_KEYBOARD__
|
#ifndef __HOS_KEYBOARD__
|
||||||
#define __HOS_KEYBOARD__ __HOS_KEYBOARD__
|
#define __HOS_KEYBOARD__ __HOS_KEYBOARD__
|
||||||
|
|
||||||
#define KBDF_SCROLL 0x01
|
#define KBDF_SCROLL 0x01
|
||||||
#define KBDF_NUM 0x02
|
#define KBDF_NUM 0x02
|
||||||
#define KBDF_CAPS 0x04
|
#define KBDF_CAPS 0x04
|
||||||
#define KBDF_SHIFT 0x10
|
#define KBDF_SHIFT 0x10
|
||||||
#define KBDF_CTRL 0x20
|
#define KBDF_CTRL 0x20
|
||||||
#define KBDF_ALT 0x40
|
#define KBDF_ALT 0x40
|
||||||
|
|
||||||
#define KBD_SCAN_RELEASED 0x80
|
#define KBD_SCAN_RELEASED 0x80
|
||||||
|
|
||||||
#define KBD_SCAN_CTRL 29
|
#define KBD_SCAN_CTRL 29
|
||||||
#define KBD_SCAN_LSHIFT 42
|
#define KBD_SCAN_LSHIFT 42
|
||||||
#define KBD_SCAN_RSHIFT 54
|
#define KBD_SCAN_RSHIFT 54
|
||||||
#define KBD_SCAN_ALT 56
|
#define KBD_SCAN_ALT 56
|
||||||
#define KBD_SCAN_SCROLL 70
|
#define KBD_SCAN_SCROLL 70
|
||||||
#define KBD_SCAN_CAPS 58
|
#define KBD_SCAN_CAPS 58
|
||||||
#define KBD_SCAN_NUM 69
|
#define KBD_SCAN_NUM 69
|
||||||
|
|
||||||
|
#define KBD_ASCII(x) ((x) & 0xFF)
|
||||||
|
#define KBD_SCAN(x) (((x) >> 8) & 0xFF)
|
||||||
|
#define KBD_FLAGS(x) (((x) >> 16) &0xFF)
|
||||||
|
|
||||||
void isr_keyboard();
|
void isr_keyboard();
|
||||||
void kbd_resetLEDs();
|
void kbd_resetLEDs();
|
||||||
u32_t kbdGetKey();
|
|
||||||
u32_t kbdWaitKey();
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ extern "C"
|
|||||||
#include "char/vconsole.h"
|
#include "char/vconsole.h"
|
||||||
|
|
||||||
VConsole *vconsoles[VCONSOLE_MAX]; // pointer to virtual console structs
|
VConsole *vconsoles[VCONSOLE_MAX]; // pointer to virtual console structs
|
||||||
extern int display_activeConsole; // display subsystem active virtual console number
|
|
||||||
char ansi2vgaAttr[8] = {0, 4, 2, 6, 1, 5, 3, 7};
|
char ansi2vgaAttr[8] = {0, 4, 2, 6, 1, 5, 3, 7};
|
||||||
|
|
||||||
void vconsole_setup(int width, int height)
|
void vconsole_setup(int width, int height)
|
||||||
@ -27,6 +26,22 @@ void vconsole_setup(int width, int height)
|
|||||||
vconsoles[i] = new VConsole(width, height);
|
vconsoles[i] = new VConsole(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int vconsole_activate(u32_t id)
|
||||||
|
{
|
||||||
|
if (id >= VCONSOLE_MAX)
|
||||||
|
return -1;
|
||||||
|
vconsoles[id]->activate();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int vconsole_deactivate(u32_t id)
|
||||||
|
{
|
||||||
|
if (id >= VCONSOLE_MAX)
|
||||||
|
return -1;
|
||||||
|
vconsoles[id]->deactivate();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
VConsoleDriver::~VConsoleDriver()
|
VConsoleDriver::~VConsoleDriver()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < VCONSOLE_MAX; i++)
|
for (int i = 0; i < VCONSOLE_MAX; i++)
|
||||||
@ -46,6 +61,7 @@ int VConsoleDriver::char_write(minor_t minor, int c)
|
|||||||
VConsole::VConsole(int width, int height)
|
VConsole::VConsole(int width, int height)
|
||||||
{
|
{
|
||||||
myBuffer = new u16_t[width * height];
|
myBuffer = new u16_t[width * height];
|
||||||
|
myBuffer2 = NULL;
|
||||||
myWidth = width;
|
myWidth = width;
|
||||||
myHeight = height;
|
myHeight = height;
|
||||||
myAttribute = myForeground = 0x07;
|
myAttribute = myForeground = 0x07;
|
||||||
@ -63,12 +79,23 @@ VConsole::~VConsole()
|
|||||||
|
|
||||||
void VConsole::activate()
|
void VConsole::activate()
|
||||||
{
|
{
|
||||||
|
if (myActive) // don't activate if already active
|
||||||
|
return;
|
||||||
myActive = 1;
|
myActive = 1;
|
||||||
|
myBuffer2 = myBuffer;
|
||||||
|
myBuffer = (u16_t *)CONSOLE_MEMORY;
|
||||||
|
memcpyd(myBuffer, myBuffer2, (myWidth * myHeight) >> 1);
|
||||||
|
writeCursorPosition(myCursorPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VConsole::deactivate()
|
void VConsole::deactivate()
|
||||||
{
|
{
|
||||||
|
if (!myActive) // don't deactivate non-active console
|
||||||
|
return;
|
||||||
myActive = 0;
|
myActive = 0;
|
||||||
|
myBuffer = myBuffer2;
|
||||||
|
myBuffer2 = NULL;
|
||||||
|
memcpyd(myBuffer, (u16_t *)CONSOLE_MEMORY, (myWidth * myHeight) >> 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int VConsole::char_write(int c)
|
int VConsole::char_write(int c)
|
||||||
@ -110,12 +137,10 @@ int VConsole::char_write(int c)
|
|||||||
break;
|
break;
|
||||||
case 'J': // clear screen, home cursor
|
case 'J': // clear screen, home cursor
|
||||||
memsetw(myBuffer, 0x0720, myWidth * myHeight);
|
memsetw(myBuffer, 0x0720, myWidth * myHeight);
|
||||||
// vconsole_draw(id);
|
|
||||||
update_cursor_coord(0, 0);
|
update_cursor_coord(0, 0);
|
||||||
break;
|
break;
|
||||||
case 'K': // erase line from cursor position (including char. under cursor) to end of line
|
case 'K': // erase line from cursor position (including char. under cursor) to end of line
|
||||||
memsetw(myBuffer + myCursorPosition, 0x0720, myWidth - cursorX);
|
memsetw(myBuffer + myCursorPosition, 0x0720, myWidth - cursorX);
|
||||||
// vconsole_draw(id);
|
|
||||||
break;
|
break;
|
||||||
case 's': // push cursor position on an internal stack
|
case 's': // push cursor position on an internal stack
|
||||||
if (myCursorStackPosition < 16)
|
if (myCursorStackPosition < 16)
|
||||||
@ -202,8 +227,6 @@ void VConsole::put_char(int c)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
myBuffer[myCursorPosition] = c | (myAttribute << 8);
|
myBuffer[myCursorPosition] = c | (myAttribute << 8);
|
||||||
// if (myActive)
|
|
||||||
// display_console_put_char(c | (myAttribute << 8), myCursorPosition);
|
|
||||||
update_cursor(myCursorPosition + 1);
|
update_cursor(myCursorPosition + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -237,14 +260,9 @@ void VConsole::update_cursor(u16_t position)
|
|||||||
myCursorPosition -= myWidth;
|
myCursorPosition -= myWidth;
|
||||||
memcpyw(myBuffer, myBuffer + myWidth, myWidth * (myHeight - 1));
|
memcpyw(myBuffer, myBuffer + myWidth, myWidth * (myHeight - 1));
|
||||||
memsetw(myBuffer + (myWidth * (myHeight - 1)), 0x0720, myWidth);
|
memsetw(myBuffer + (myWidth * (myHeight - 1)), 0x0720, myWidth);
|
||||||
// if (myActive)
|
|
||||||
// {
|
|
||||||
// vconsole_draw(id);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
// if (myActive)
|
if (myActive)
|
||||||
// display_console_update_cursor(id, position);
|
writeCursorPosition(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VConsole::update_attribute()
|
void VConsole::update_attribute()
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#ifndef __HOS_VCONSOLE__
|
#ifndef __HOS_VCONSOLE__
|
||||||
#define __HOS_VCONSOLE__ __HOS_VCONSOLE__
|
#define __HOS_VCONSOLE__ __HOS_VCONSOLE__
|
||||||
|
|
||||||
#define VCONSOLE_MAX 7
|
#define VCONSOLE_MAX 12
|
||||||
|
|
||||||
#ifdef _HOS_CPP_
|
#ifdef _HOS_CPP_
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -15,6 +15,9 @@ extern "C" {
|
|||||||
#include "hos_defines.h"
|
#include "hos_defines.h"
|
||||||
|
|
||||||
void vconsole_setup(int width, int height);
|
void vconsole_setup(int width, int height);
|
||||||
|
int vconsole_activate(u32_t id);
|
||||||
|
int vconsole_deactivate(u32_t id);
|
||||||
|
|
||||||
|
|
||||||
#ifdef _HOS_CPP_
|
#ifdef _HOS_CPP_
|
||||||
}
|
}
|
||||||
@ -32,6 +35,7 @@ class VConsole
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
u16_t *myBuffer;
|
u16_t *myBuffer;
|
||||||
|
u16_t *myBuffer2;
|
||||||
u16_t myWidth;
|
u16_t myWidth;
|
||||||
u16_t myHeight;
|
u16_t myHeight;
|
||||||
u16_t myCursorPosition;
|
u16_t myCursorPosition;
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "devices.h"
|
#include "devices.h"
|
||||||
#include "char/misc_char.h"
|
#include "char/misc_char.h"
|
||||||
#include "char/vconsole.h"
|
#include "char/vconsole.h"
|
||||||
|
#include "block/ramdisk.h"
|
||||||
|
|
||||||
DeviceDriver *drivers[256];
|
DeviceDriver *drivers[256];
|
||||||
|
|
||||||
@ -17,6 +18,7 @@ int devices_init()
|
|||||||
{
|
{
|
||||||
drivers[MAJOR_MISC_CHAR] = new MiscChar();
|
drivers[MAJOR_MISC_CHAR] = new MiscChar();
|
||||||
drivers[MAJOR_VCONSOLE] = new VConsoleDriver();
|
drivers[MAJOR_VCONSOLE] = new VConsoleDriver();
|
||||||
|
drivers[MAJOR_RAMDISK] = new Ramdisk();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// Device subsystem for HOS
|
// Device subsystem for HOS
|
||||||
// Author: Josh Holtrop
|
// Author: Josh Holtrop
|
||||||
// Date: 05/11/05
|
// Date: 05/11/05
|
||||||
// Modified: 05/11/05
|
// Modified: 06/02/05
|
||||||
|
|
||||||
#ifndef __HOS_DEVICES_H__
|
#ifndef __HOS_DEVICES_H__
|
||||||
#define __HOS_DEVICES_H__ __HOS_DEVICES_H__
|
#define __HOS_DEVICES_H__ __HOS_DEVICES_H__
|
||||||
@ -20,6 +20,9 @@
|
|||||||
#define BLOCK_SIZE 512
|
#define BLOCK_SIZE 512
|
||||||
#define BLOCK_SIZE_LOG 9
|
#define BLOCK_SIZE_LOG 9
|
||||||
|
|
||||||
|
#define DEV_MAJOR (x) (((x) >> 8) & 0xFF)
|
||||||
|
#define DEV_MINOR (x) ((x) & 0xFF)
|
||||||
|
|
||||||
typedef short major_t;
|
typedef short major_t;
|
||||||
typedef short minor_t;
|
typedef short minor_t;
|
||||||
typedef u32_t device_t;
|
typedef u32_t device_t;
|
||||||
|
@ -9,27 +9,24 @@
|
|||||||
#include "lang/lang.h"
|
#include "lang/lang.h"
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
#include "display/vesafb.h"
|
#include "display/vesafb.h"
|
||||||
|
#include "char/keyboard.h"
|
||||||
|
#include "display/kout.h"
|
||||||
|
|
||||||
extern real_mode_param_t rm_params; // check if a video mode is activated
|
extern real_mode_param_t rm_params; // check if a video mode is activated
|
||||||
|
int display_type;
|
||||||
int display_activeConsole = -1; // start with no active console
|
int display_activeConsole = -1; // start with no active console
|
||||||
display_t myDisplays[12]; // f1-f12 change displays
|
|
||||||
|
|
||||||
// initialization routine for display subsystem
|
// initialization routine for display subsystem
|
||||||
int display_init()
|
int display_init()
|
||||||
{
|
{
|
||||||
int width = 80;
|
if (!rm_params.vid_addr) // framebuffer mode
|
||||||
int height = 25;
|
|
||||||
int displayType = DISPLAY_CONSOLE;
|
|
||||||
if (rm_params.vid_addr) // framebuffer mode
|
|
||||||
{
|
{
|
||||||
vesafb_init(rm_params.width, rm_params.height, rm_params.bpp);
|
vconsole_setup(80, 25);
|
||||||
width = vesafb_getWidth();
|
display_activate(KERNEL_MSG_CONSOLE);
|
||||||
height = vesafb_getHeight();
|
|
||||||
displayType = DISPLAY_FB;
|
|
||||||
}
|
}
|
||||||
vconsole_setup(width, height);
|
else
|
||||||
// vconsole_activate(0);
|
display_type = DISPLAY_GRAPHICAL;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,73 +34,40 @@ int display_init()
|
|||||||
// activate the given display
|
// activate the given display
|
||||||
int display_activate(u32_t id)
|
int display_activate(u32_t id)
|
||||||
{
|
{
|
||||||
if (id > 11)
|
if (id == display_activeConsole)
|
||||||
|
return 0;
|
||||||
|
if (display_type != DISPLAY_CONSOLE)
|
||||||
return -1;
|
return -1;
|
||||||
switch (myDisplays[id].type)
|
if (id >= VCONSOLE_MAX)
|
||||||
|
return -2;
|
||||||
|
if (display_activeConsole >= 0)
|
||||||
|
vconsole_deactivate(display_activeConsole);
|
||||||
|
if (vconsole_activate(id)) // if true, didn't work to activate console
|
||||||
{
|
{
|
||||||
case DISPLAY_CONSOLE:
|
vconsole_activate(display_activeConsole); // restore old one
|
||||||
case DISPLAY_FB:
|
return -3;
|
||||||
display_activeConsole = myDisplays[id].id;
|
|
||||||
// return vconsole_draw(display_activeConsole);
|
|
||||||
case DISPLAY_GRAPHICAL:
|
|
||||||
default:
|
|
||||||
return -2;
|
|
||||||
}
|
}
|
||||||
|
display_activeConsole = id;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// routine to refresh a console window
|
void display_key_event(u32_t keyCode)
|
||||||
int display_console_draw(minor_t id, int cursorPosition, u16_t *buffer, int buff_len)
|
|
||||||
{
|
{
|
||||||
if (id == display_activeConsole)
|
if (display_type == DISPLAY_CONSOLE)
|
||||||
{
|
{
|
||||||
int i;
|
u32_t kbdScan = KBD_SCAN(keyCode);
|
||||||
for (i = 0; i < 12; i++)
|
if ( /* kbdFlags & KBDF_ALT && */ kbdScan >= 0x3B && kbdScan <= 0x44) // switch displays F1-F10
|
||||||
{
|
{
|
||||||
if (myDisplays[i].id == id)
|
display_activate(kbdScan - 0x3B);
|
||||||
{
|
return;
|
||||||
if (myDisplays[i].type == DISPLAY_CONSOLE)
|
}
|
||||||
{
|
if ( /* kbdFlags & KBDF_ALT && */ kbdScan >= 0x57 && kbdScan <= 0x58) // F11-F12
|
||||||
memcpyw((void *)CONSOLE_MEMORY, buffer, buff_len);
|
{
|
||||||
writeCursorPosition(cursorPosition);
|
display_activate(kbdScan - 0x4D);
|
||||||
return 0;
|
return;
|
||||||
}
|
|
||||||
else if (myDisplays[i].type == DISPLAY_FB)
|
|
||||||
return vesafb_draw(buffer, buff_len, cursorPosition);
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
if (KBD_ASCII(keyCode))
|
||||||
|
putc(KBD_ASCII(keyCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// write a character to the screen
|
|
||||||
int display_console_put_char(minor_t id, u16_t c, int position)
|
|
||||||
{
|
|
||||||
if (id == display_activeConsole)
|
|
||||||
{
|
|
||||||
if (myDisplays[id].type == DISPLAY_CONSOLE)
|
|
||||||
*(u16_t *)(CONSOLE_MEMORY + (position << 1)) = c;
|
|
||||||
else if (myDisplays[id].type == DISPLAY_FB)
|
|
||||||
vesafb_draw_char(position, c);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// move the cursor on the screen
|
|
||||||
int display_console_update_cursor(minor_t id, int cursorPosition)
|
|
||||||
{
|
|
||||||
if (id == display_activeConsole)
|
|
||||||
{
|
|
||||||
if (myDisplays[id].type == DISPLAY_CONSOLE)
|
|
||||||
writeCursorPosition(cursorPosition);
|
|
||||||
else if (myDisplays[id].type == DISPLAY_FB)
|
|
||||||
vesafb_update_cursor(cursorPosition);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,10 +9,8 @@
|
|||||||
#include "hos_defines.h"
|
#include "hos_defines.h"
|
||||||
#include "devices.h"
|
#include "devices.h"
|
||||||
|
|
||||||
#define DISPLAY_NULL 0
|
#define DISPLAY_CONSOLE 0
|
||||||
#define DISPLAY_CONSOLE 1
|
#define DISPLAY_GRAPHICAL 1
|
||||||
#define DISPLAY_FB 2
|
|
||||||
#define DISPLAY_GRAPHICAL 3
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@ -22,9 +20,8 @@ typedef struct
|
|||||||
|
|
||||||
int display_init();
|
int display_init();
|
||||||
int display_activate(u32_t id);
|
int display_activate(u32_t id);
|
||||||
int display_console_draw(minor_t id, int cursorPosition, u16_t *buffer, int buff_len);
|
|
||||||
int display_console_put_char(minor_t id, u16_t c, int position);
|
void display_key_event(u32_t keyCode);
|
||||||
int display_console_update_cursor(minor_t id, int cursorPosition);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ void putc(int c)
|
|||||||
#ifdef PARALLEL_DEBUG
|
#ifdef PARALLEL_DEBUG
|
||||||
char_write(MAJOR_MISC_CHAR, MISC_CHAR_LP0, c);
|
char_write(MAJOR_MISC_CHAR, MISC_CHAR_LP0, c);
|
||||||
#endif
|
#endif
|
||||||
char_write(MAJOR_VCONSOLE, 1, c); // write to vconsole with minor 1, first allocated
|
char_write(MAJOR_VCONSOLE, KERNEL_MSG_CONSOLE, c); // write to vconsole with minor 1, first allocated
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
136
kernel/fs/ext2.h
136
kernel/fs/ext2.h
@ -2,17 +2,151 @@
|
|||||||
// ext2 filesystem driver for HOS
|
// ext2 filesystem driver for HOS
|
||||||
// Author: Josh Holtrop
|
// Author: Josh Holtrop
|
||||||
// Date: 05/10/05
|
// Date: 05/10/05
|
||||||
// Modified: 05/10/05
|
// Modified: 05/23/05
|
||||||
|
|
||||||
#ifndef __HOS_EXT2_H__
|
#ifndef __HOS_EXT2_H__
|
||||||
#define __HOS_EXT2_H__ __HOS_EXT2_H__
|
#define __HOS_EXT2_H__ __HOS_EXT2_H__
|
||||||
|
|
||||||
|
#define EXT2_MAGIC 0xEF53
|
||||||
|
#define EXT2_NAME_LEN 255
|
||||||
|
|
||||||
|
#define EXT2_I_MODE_ATTR_MASK 0x0FFF
|
||||||
|
#define EXT2_I_MODE_OX 0x0001
|
||||||
|
#define EXT2_I_MODE_OW 0x0002
|
||||||
|
#define EXT2_I_MODE_OR 0x0004
|
||||||
|
#define EXT2_I_MODE_GX 0x0008
|
||||||
|
#define EXT2_I_MODE_GW 0x0010
|
||||||
|
#define EXT2_I_MODE_GR 0x0020
|
||||||
|
#define EXT2_I_MODE_UX 0x0040
|
||||||
|
#define EXT2_I_MODE_UW 0x0080
|
||||||
|
#define EXT2_I_MODE_UR 0x0100
|
||||||
|
#define EXT2_I_MODE_STICKY 0x0200
|
||||||
|
#define EXT2_I_MODE_SGID 0x0400
|
||||||
|
#define EXT2_I_MODE_SUID 0x0800
|
||||||
|
|
||||||
|
#define EXT2_I_MODE_TYPE_MASK 0xF000
|
||||||
|
#define EXT2_I_MODE_FIFO 0x1000
|
||||||
|
#define EXT2_I_MODE_CHAR 0x2000
|
||||||
|
#define EXT2_I_MODE_DIR 0x4000
|
||||||
|
#define EXT2_I_MODE_BLOCK 0x6000
|
||||||
|
#define EXT2_I_MODE_FILE 0x8000
|
||||||
|
#define EXT2_I_MODE_SYM 0xA000
|
||||||
|
#define EXT2_I_MODE_SOCK 0xC000
|
||||||
|
|
||||||
|
#define EXT2_I_FLAGS_SEC_DEL 0x01
|
||||||
|
#define EXT2_I_FLAGS_UNDELETE 0x02
|
||||||
|
#define EXT2_I_FLAGS_COMPRESS 0x04
|
||||||
|
#define EXT2_I_FLAGS_SYNC 0x08
|
||||||
|
#define EXT2_I_FLAGS_IMMUTABLE 0x10
|
||||||
|
#define EXT2_I_FLAGS_APPEND 0x20
|
||||||
|
#define EXT2_I_FLAGS_NODUMP 0x40
|
||||||
|
|
||||||
|
#define EXT2_INODE_BAD_BLOCKS 1
|
||||||
|
#define EXT2_INODE_ROOT 2
|
||||||
|
#define EXT2_INODE_ACL_INDEX 3
|
||||||
|
#define EXT2_INODE_ACL_DATA 4
|
||||||
|
#define EXT2_INODE_BOOT_LOADER 5
|
||||||
|
#define EXT2_INODE_UNDELETE_DIR 6
|
||||||
|
#define EXT2_INODE_AVAIL 11
|
||||||
|
|
||||||
|
#define EXT2_FT_UNKNOWN 0
|
||||||
|
#define EXT2_FT_FILE 1
|
||||||
|
#define EXT2_FT_DIR 2
|
||||||
|
#define EXT2_FT_CHAR 3
|
||||||
|
#define EXT2_FT_BLOCK 4
|
||||||
|
#define EXT2_FT_FIFO 5
|
||||||
|
#define EXT2_FT_SOCK 6
|
||||||
|
#define EXT2_FT_SYMLINK 7
|
||||||
|
#define EXT2_FT_MAX 8
|
||||||
|
|
||||||
#include "vfs.h"
|
#include "vfs.h"
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
u32_t s_inodes_count; /* Inodes count */
|
||||||
|
u32_t s_blocks_count; /* Blocks count */
|
||||||
|
u32_t s_r_blocks_count; /* Reserved blocks count */
|
||||||
|
u32_t s_free_blocks_count; /* Free blocks count */
|
||||||
|
u32_t s_free_inodes_count; /* Free inodes count */
|
||||||
|
u32_t s_first_data_block; /* First Data Block */
|
||||||
|
u32_t s_log_block_size; /* Block size: 0->1024, 1->2048, 2->4096 */
|
||||||
|
int s_log_frag_size; /* Fragment size */
|
||||||
|
u32_t s_blocks_per_group; /* # Blocks per group */
|
||||||
|
u32_t s_frags_per_group; /* # Fragments per group */
|
||||||
|
u32_t s_inodes_per_group; /* # Inodes per group */
|
||||||
|
u32_t s_mtime; /* Mount time */
|
||||||
|
u32_t s_wtime; /* Write time */
|
||||||
|
u16_t s_mnt_count; /* Mount count */
|
||||||
|
short s_max_mnt_count; /* Maximal mount count */
|
||||||
|
u16_t s_magic; /* Magic signature */
|
||||||
|
u16_t s_state; /* File system state */
|
||||||
|
u16_t s_errors; /* Behaviour when detecting errors */
|
||||||
|
u16_t s_minor_rev_level; /* minor revision level */
|
||||||
|
u32_t s_lastcheck; /* time of last check */
|
||||||
|
u32_t s_checkinterval; /* max. time between checks */
|
||||||
|
u32_t s_creator_os; /* OS */
|
||||||
|
u32_t s_rev_level; /* Revision level */
|
||||||
|
u16_t s_def_resuid; /* Default uid for reserved blocks */
|
||||||
|
u16_t s_def_resgid; /* Default gid for reserved blocks */
|
||||||
|
|
||||||
|
u32_t s_reserved[235];
|
||||||
|
} ext2_super_block_t;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
u32_t bg_block_bitmap; // Blocks bitmap block
|
||||||
|
u32_t bg_inode_bitmap; // Inode bitmap block
|
||||||
|
u32_t bg_inode_table; // Inode table block
|
||||||
|
u16_t bg_free_blocks_count; // Free blocks count
|
||||||
|
u16_t bg_free_inodes_count; // Free Inodes count
|
||||||
|
u16_t bg_used_dirs_count; // Directories count
|
||||||
|
u16_t bg_pad1;
|
||||||
|
u32_t bg_reserved[3];
|
||||||
|
} ext2_group_desc_t;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
u16_t i_mode; // File mode
|
||||||
|
u16_t i_uid; // Owner UID
|
||||||
|
u32_t i_size; // Size in bytes
|
||||||
|
u32_t i_atime; // Access time
|
||||||
|
u32_t i_ctime; // Creation time
|
||||||
|
u32_t i_mtime; // Modification time
|
||||||
|
u32_t i_dtime; // Deletion time
|
||||||
|
u16_t i_gid; // Group ID
|
||||||
|
u16_t i_links_count; // Links count
|
||||||
|
u32_t i_blocks; // Blocks count
|
||||||
|
u32_t i_flags; // File flags
|
||||||
|
u32_t i_reserved1;
|
||||||
|
u32_t i_block[15]; // Pointers to blocks (12 direct, single, double, triple indirect)
|
||||||
|
u32_t i_version; // File version (for NFS)
|
||||||
|
u32_t i_file_acl; // File ACL
|
||||||
|
u32_t i_dir_acl; // Directory ACL
|
||||||
|
u32_t i_faddr; // Fragment address
|
||||||
|
u8_t i_frag; // Fragment number
|
||||||
|
u8_t i_fsize; // Fragment size
|
||||||
|
u16_t i_pad1;
|
||||||
|
u32_t i_reserved2[2];
|
||||||
|
} ext2_inode_t;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
u32_t inode; // inode number
|
||||||
|
u16_t length; // directory entry length
|
||||||
|
u8_t name_length; // name length
|
||||||
|
u8_t file_type; // File type
|
||||||
|
char name[EXT2_NAME_LEN];
|
||||||
|
} ext2_dir_entry_t;
|
||||||
|
|
||||||
|
|
||||||
#ifdef _HOS_CPP_
|
#ifdef _HOS_CPP_
|
||||||
|
|
||||||
class Ext2 : public FileSystem
|
class Ext2 : public FileSystem
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -75,11 +75,11 @@ typedef struct
|
|||||||
u32_t s_blocks_per_group; /* # Blocks per group */
|
u32_t s_blocks_per_group; /* # Blocks per group */
|
||||||
u32_t s_frags_per_group; /* # Fragments per group */
|
u32_t s_frags_per_group; /* # Fragments per group */
|
||||||
u32_t s_inodes_per_group; /* # Inodes per group */
|
u32_t s_inodes_per_group; /* # Inodes per group */
|
||||||
u32_t s_mtime; /* Mount time */
|
u32_t s_mtime; /* Mount time */
|
||||||
u32_t s_wtime; /* Write time */
|
u32_t s_wtime; /* Write time */
|
||||||
u16_t s_mnt_count; /* Mount count */
|
u16_t s_mnt_count; /* Mount count */
|
||||||
short s_max_mnt_count; /* Maximal mount count */
|
short s_max_mnt_count; /* Maximal mount count */
|
||||||
u16_t s_magic; /* Magic signature */
|
u16_t s_magic; /* Magic signature */
|
||||||
u16_t s_state; /* File system state */
|
u16_t s_state; /* File system state */
|
||||||
u16_t s_errors; /* Behaviour when detecting errors */
|
u16_t s_errors; /* Behaviour when detecting errors */
|
||||||
u16_t s_minor_rev_level; /* minor revision level */
|
u16_t s_minor_rev_level; /* minor revision level */
|
||||||
|
@ -6,11 +6,48 @@
|
|||||||
|
|
||||||
#define _HOS_CPP_ _HOS_CPP_
|
#define _HOS_CPP_ _HOS_CPP_
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
#include "hos_defines.h"
|
#include "hos_defines.h"
|
||||||
|
#include "display/kout.h"
|
||||||
|
}
|
||||||
|
|
||||||
#include "vfs.h"
|
#include "vfs.h"
|
||||||
|
#include "lang/vector.h"
|
||||||
|
#include "lang/string.h"
|
||||||
|
#include "devices.h"
|
||||||
|
|
||||||
|
inode_num_t rootInode;
|
||||||
|
vector<VFSMount> *mountPoints;
|
||||||
|
|
||||||
int vfs_init()
|
int vfs_init()
|
||||||
{
|
{
|
||||||
|
mountPoints = new vector<VFSMount>;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int vfs_mount(device_t device, int fsType, char *mountPoint)
|
||||||
|
{
|
||||||
|
string mountPt(mountPoint);
|
||||||
|
if (mountPt == "/")
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
VFSMount::VFSMount(device_t dev, FileSystem *fs, string mountPoint, inode_num_t mountInode)
|
||||||
|
{
|
||||||
|
myDev = dev;
|
||||||
|
myFS = fs;
|
||||||
|
myRefs = 0;
|
||||||
|
myMountPoint = mountPoint;
|
||||||
|
myMountInode = mountInode;
|
||||||
|
}
|
||||||
|
|
||||||
|
VFSMount::~VFSMount()
|
||||||
|
{
|
||||||
|
if (myFS)
|
||||||
|
delete myFS;
|
||||||
|
if (myRefs)
|
||||||
|
kprintf("Filesystem uncleanly mounted from %s\n", myMountPoint.data());
|
||||||
|
}
|
||||||
|
@ -7,20 +7,78 @@
|
|||||||
#ifndef __HOS_VFS_H__
|
#ifndef __HOS_VFS_H__
|
||||||
#define __HOS_VFS_H__ __HOS_VFS_H__
|
#define __HOS_VFS_H__ __HOS_VFS_H__
|
||||||
|
|
||||||
|
#define FS_EXT2 1
|
||||||
|
|
||||||
|
#define VFS_FT_UNKNOWN 0
|
||||||
|
#define VFS_FT_FILE 1
|
||||||
|
#define VFS_FT_DIR 2
|
||||||
|
#define VFS_FT_CHAR 3
|
||||||
|
#define VFS_FT_BLOCK 4
|
||||||
|
#define VFS_FT_FIFO 5
|
||||||
|
#define VFS_FT_SOCK 6
|
||||||
|
#define VFS_FT_SYMLINK 7
|
||||||
|
|
||||||
|
#define VFS_PERMS_OX 0x0001
|
||||||
|
#define VFS_PERMS_OW 0x0002
|
||||||
|
#define VFS_PERMS_OR 0x0004
|
||||||
|
#define VFS_PERMS_GX 0x0008
|
||||||
|
#define VFS_PERMS_GW 0x0010
|
||||||
|
#define VFS_PERMS_GR 0x0020
|
||||||
|
#define VFS_PERMS_UX 0x0040
|
||||||
|
#define VFS_PERMS_UW 0x0080
|
||||||
|
#define VFS_PERMS_UR 0x0100
|
||||||
|
#define VFS_PERMS_STICKY 0x0200
|
||||||
|
#define VFS_PERMS_SGID 0x0400
|
||||||
|
#define VFS_PERMS_SUID 0x0800
|
||||||
|
|
||||||
|
#define EOF 1000000
|
||||||
|
|
||||||
|
#include "hos_defines.h"
|
||||||
|
#include "devices.h"
|
||||||
|
|
||||||
#ifdef _HOS_CPP_
|
#ifdef _HOS_CPP_
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef u64_t inode_num_t;
|
||||||
|
|
||||||
int vfs_init();
|
int vfs_init();
|
||||||
|
int vfs_mount(device_t device, int fsType, char *mountPoint);
|
||||||
|
|
||||||
#ifdef _HOS_CPP_
|
#ifdef _HOS_CPP_
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "lang/string.h"
|
||||||
|
|
||||||
class FileSystem
|
class FileSystem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FileSystem();
|
FileSystem(device_t dev);
|
||||||
~FileSystem();
|
virtual ~FileSystem();
|
||||||
|
|
||||||
|
virtual u32_t totalBlocks(); /* 512 byte blocks */
|
||||||
|
virtual u32_t usedBlocks();
|
||||||
|
virtual u32_t freeBlocks();
|
||||||
|
|
||||||
|
virtual u32_t totalInodes();
|
||||||
|
virtual u32_t usedInodes();
|
||||||
|
virtual u32_t freeInodes();
|
||||||
|
|
||||||
|
virtual u32_t getRootInodeNumber();
|
||||||
|
};
|
||||||
|
|
||||||
|
class VFSMount
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
device_t myDev;
|
||||||
|
FileSystem *myFS;
|
||||||
|
int myRefs;
|
||||||
|
string myMountPoint;
|
||||||
|
inode_num_t myMountInode;
|
||||||
|
VFSMount
|
||||||
|
public:
|
||||||
|
VFSMount(device_t dev, FileSystem *fs, string mountPoint, inode_num_t mountInode);
|
||||||
|
~VFSMount();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -162,57 +162,5 @@ int vfs_read_block_file(vfs_open_file_t *open_file, void *buffer);
|
|||||||
int vfs_block_file_seek(vfs_open_file_t *open_file, u32_t block_number);
|
int vfs_block_file_seek(vfs_open_file_t *open_file, u32_t block_number);
|
||||||
int vfs_close_block_file(vfs_open_file_t *open_file);
|
int vfs_close_block_file(vfs_open_file_t *open_file);
|
||||||
|
|
||||||
#ifdef _HOS_CPP_
|
|
||||||
|
|
||||||
class FileSystem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
FileSystem();
|
|
||||||
virtual void out();
|
|
||||||
};
|
|
||||||
|
|
||||||
FileSystem::FileSystem()
|
|
||||||
{
|
|
||||||
kprintf("FileSystem()\n");
|
|
||||||
}
|
|
||||||
void FileSystem::out()
|
|
||||||
{
|
|
||||||
kprintf("I am a FileSystem object.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
class Ext2 : public FileSystem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Ext2();
|
|
||||||
void out();
|
|
||||||
};
|
|
||||||
|
|
||||||
Ext2::Ext2()
|
|
||||||
{
|
|
||||||
kprintf("Ext2()\n");
|
|
||||||
}
|
|
||||||
void Ext2::out()
|
|
||||||
{
|
|
||||||
kprintf("I am an Ext2 object.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
class JoshsFS : public FileSystem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
JoshsFS();
|
|
||||||
void out();
|
|
||||||
};
|
|
||||||
|
|
||||||
JoshsFS::JoshsFS()
|
|
||||||
{
|
|
||||||
kprintf("JoshsFS()\n");
|
|
||||||
}
|
|
||||||
void JoshsFS::out()
|
|
||||||
{
|
|
||||||
kprintf("I am an JoshsFS object.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -8,21 +8,22 @@
|
|||||||
|
|
||||||
#define PARALLEL_DEBUG
|
#define PARALLEL_DEBUG
|
||||||
|
|
||||||
#define HOS_TIMER_FREQ 1000
|
#define HOS_TIMER_FREQ 1000
|
||||||
|
#define KERNEL_MSG_CONSOLE 11
|
||||||
|
|
||||||
#define VIRT_OFFSET 0xC0000000
|
#define VIRT_OFFSET 0xC0000000
|
||||||
#define PHYS_LOAD 0x00108000
|
#define PHYS_LOAD 0x00108000
|
||||||
#define HEAP_START 0xD0000000
|
#define HEAP_START 0xD0000000
|
||||||
#define HEAP_LENGTH 0x20000000
|
#define HEAP_LENGTH 0x20000000
|
||||||
|
|
||||||
#define CONSOLE_MEMORY 0xC00B8000
|
#define CONSOLE_MEMORY 0xC00B8000
|
||||||
#define BIOS_CHAR_MAP 0xC00FFA6E
|
#define BIOS_CHAR_MAP 0xC00FFA6E
|
||||||
|
#define LFB_MEMORY 0xF0000000
|
||||||
|
|
||||||
#define MAX_MODULES 16
|
#define MAX_MODULES 16
|
||||||
#define MAX_MMAP 16
|
#define MAX_MMAP 16
|
||||||
|
|
||||||
#define NULL 0
|
#define NULL 0
|
||||||
#define INT_MIN -42
|
|
||||||
|
|
||||||
#define New(x) kcalloc(1, sizeof(x))
|
#define New(x) kcalloc(1, sizeof(x))
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ void k_init()
|
|||||||
vid_mem <<= 2; break;
|
vid_mem <<= 2; break;
|
||||||
}
|
}
|
||||||
// map in video memory so we can access the video card's LFB
|
// map in video memory so we can access the video card's LFB
|
||||||
vmm_mapn(0xF0000000, (u32_t)rm_params.vid_addr, (vid_mem >> 12) + 1);
|
vmm_mapn(LFB_MEMORY, (u32_t)rm_params.vid_addr, (vid_mem >> 12) + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
display_init(); // initialize display subsystem
|
display_init(); // initialize display subsystem
|
||||||
@ -136,15 +136,15 @@ void k_init()
|
|||||||
for (i = 0; i < mb_info_block.mods_count; i++)
|
for (i = 0; i < mb_info_block.mods_count; i++)
|
||||||
{
|
{
|
||||||
kprintf("Loaded kernel module %d: 0x%x - 0x%x (%d bytes)\n", i, mb_modules[i].mod_start, mb_modules[i].mod_end, mb_modules[i].mod_end - mb_modules[i].mod_start);
|
kprintf("Loaded kernel module %d: 0x%x - 0x%x (%d bytes)\n", i, mb_modules[i].mod_start, mb_modules[i].mod_end, mb_modules[i].mod_end - mb_modules[i].mod_start);
|
||||||
/* if (((mb_modules[i].mod_end - mb_modules[i].mod_start) > 1024) &&
|
if (((mb_modules[i].mod_end - mb_modules[i].mod_start) > 1024) &&
|
||||||
((ext2_super_block_t *)(mb_modules[i].mod_start + 1024))->s_magic == EXT2_MAGIC)
|
((ext2_super_block_t *)(mb_modules[i].mod_start + 1024))->s_magic == EXT2_MAGIC)
|
||||||
{
|
{
|
||||||
// we found an initrd
|
// we found an initrd
|
||||||
minor_t initrd_minor = ramdisk_register((void *)mb_modules[i].mod_start, mb_modules[i].mod_end - mb_modules[i].mod_start);
|
minor_t initrd_minor = ramdisk_register((void *)mb_modules[i].mod_start, mb_modules[i].mod_end - mb_modules[i].mod_start);
|
||||||
kprintf("initrd (%dkb) loaded\n", (mb_modules[i].mod_end - mb_modules[i].mod_start) >> 10);
|
kprintf("initrd (%dkb) loaded\n", (mb_modules[i].mod_end - mb_modules[i].mod_start) >> 10);
|
||||||
k_check(vfs_mount(MAJORB_RAMDISK, initrd_minor, FS_EXT2, "/"), "Could not mount initrd to /!");
|
k_check(vfs_mount((MAJOR_RAMDISK << 8) | initrd_minor, FS_EXT2, "/"), "Could not mount initrd to /!");
|
||||||
}
|
}
|
||||||
*/ }
|
}
|
||||||
|
|
||||||
/* vfs_open_file_t *root = vfs_open_dir("////");
|
/* vfs_open_file_t *root = vfs_open_dir("////");
|
||||||
if (root)
|
if (root)
|
||||||
@ -185,6 +185,7 @@ void k_init()
|
|||||||
else
|
else
|
||||||
kprintf("Error: Could not open directory\n");
|
kprintf("Error: Could not open directory\n");
|
||||||
*/
|
*/
|
||||||
|
|
||||||
criticalCounter--;
|
criticalCounter--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,6 +102,9 @@ static inline bool operator<=(const char *cstring, const string & str)
|
|||||||
static inline bool operator>=(const char *cstring, const string & str)
|
static inline bool operator>=(const char *cstring, const string & str)
|
||||||
{ return str <= cstring; }
|
{ return str <= cstring; }
|
||||||
|
|
||||||
|
static inline string operator+(const char *cstring, const string & str)
|
||||||
|
{ return string(cstring, str); }
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
145
kernel/lang/vector.h
Normal file
145
kernel/lang/vector.h
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
|
||||||
|
// vector.h
|
||||||
|
// implements c++ vector object for HOS
|
||||||
|
// Author: Josh Holtrop
|
||||||
|
// Date: 05/30/05
|
||||||
|
// Modified: 05/30/05
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __HOS_VECTOR__
|
||||||
|
#define __HOS_VECTOR__ __HOS_VECTOR__
|
||||||
|
|
||||||
|
template<typename type>
|
||||||
|
class vector
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
/* Pointers to vector elements */
|
||||||
|
type **myData;
|
||||||
|
|
||||||
|
/* How many elements are present */
|
||||||
|
unsigned int mySize;
|
||||||
|
|
||||||
|
/* How many elements there are pointers for */
|
||||||
|
unsigned int myAllocated;
|
||||||
|
|
||||||
|
/* Causes the vector to double in its allocated size */
|
||||||
|
void grow();
|
||||||
|
|
||||||
|
public:
|
||||||
|
/* Constructors/Destructor */
|
||||||
|
vector<type>();
|
||||||
|
vector<type>(unsigned int size);
|
||||||
|
~vector<type>();
|
||||||
|
|
||||||
|
/* Returns the size of the vector */
|
||||||
|
unsigned int size() const;
|
||||||
|
|
||||||
|
/* Add an element to the end of the vector */
|
||||||
|
vector<type> & add(type elem);
|
||||||
|
|
||||||
|
/* Remove an element from the vector */
|
||||||
|
vector<type> & remove(unsigned int index);
|
||||||
|
|
||||||
|
/* Insert an element into a position in the vector */
|
||||||
|
vector<type> & insert(type elem, unsigned int position);
|
||||||
|
|
||||||
|
/* Direct access operators */
|
||||||
|
const type & operator[](unsigned int index) const;
|
||||||
|
type & operator[](unsigned int index);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename type>
|
||||||
|
vector<type>::vector<type>()
|
||||||
|
{
|
||||||
|
myData = NULL;
|
||||||
|
mySize = 0;
|
||||||
|
myAllocated = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename type>
|
||||||
|
vector<type>::vector<type>(unsigned int size)
|
||||||
|
{
|
||||||
|
myData = new (type *)[size];
|
||||||
|
mySize = 0;
|
||||||
|
myAllocated = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename type>
|
||||||
|
vector<type>::~vector<type>()
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < mySize; i++)
|
||||||
|
delete myData[i];
|
||||||
|
delete[] myData;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename type>
|
||||||
|
u32_t vector<type>::size() const
|
||||||
|
{
|
||||||
|
return mySize;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename type>
|
||||||
|
const type & vector<type>::operator[](unsigned int index) const
|
||||||
|
{
|
||||||
|
return *myData[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename type>
|
||||||
|
type & vector<type>::operator[](unsigned int index)
|
||||||
|
{
|
||||||
|
return *myData[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename type>
|
||||||
|
vector<type> & vector<type>::add(type elem)
|
||||||
|
{
|
||||||
|
while (mySize >= myAllocated)
|
||||||
|
grow();
|
||||||
|
myData[mySize++] = new type(elem);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename type>
|
||||||
|
void vector<type>::grow()
|
||||||
|
{
|
||||||
|
myAllocated <<= 1;
|
||||||
|
if (myAllocated == 0)
|
||||||
|
myAllocated = 1;
|
||||||
|
type **data_new = new (type *)[myAllocated];
|
||||||
|
for (unsigned int i = 0; i < mySize; i++)
|
||||||
|
data_new[i] = myData[i];
|
||||||
|
if (myData)
|
||||||
|
delete[] myData;
|
||||||
|
myData = data_new;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename type>
|
||||||
|
vector<type> & vector<type>::remove(unsigned int index)
|
||||||
|
{
|
||||||
|
if (index < mySize)
|
||||||
|
{
|
||||||
|
delete myData[index];
|
||||||
|
for (unsigned int i = index; i < (mySize - 1); i++)
|
||||||
|
myData[i] = myData[i+1];
|
||||||
|
mySize--;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename type>
|
||||||
|
vector<type> & vector<type>::insert(type elem, unsigned int position)
|
||||||
|
{
|
||||||
|
if (position <= mySize)
|
||||||
|
{
|
||||||
|
if (mySize == myAllocated)
|
||||||
|
grow();
|
||||||
|
for (unsigned int i = mySize; i > position; i--)
|
||||||
|
myData[i] = myData[i-1];
|
||||||
|
myData[position] = new type(elem);
|
||||||
|
mySize++;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -5,6 +5,10 @@ SECTIONS
|
|||||||
.text 0xC0108000 : {
|
.text 0xC0108000 : {
|
||||||
code = .; _code = .; __code = .;
|
code = .; _code = .; __code = .;
|
||||||
*(.text)
|
*(.text)
|
||||||
|
/* . = ALIGN(4096); */
|
||||||
|
}
|
||||||
|
.gnulinkonce : {
|
||||||
|
*(.gnu.linkonce*)
|
||||||
. = ALIGN(4096);
|
. = ALIGN(4096);
|
||||||
}
|
}
|
||||||
.data : {
|
.data : {
|
||||||
@ -15,8 +19,8 @@ SECTIONS
|
|||||||
.rodata : {
|
.rodata : {
|
||||||
rodata = .; _rodata = .; __rodata = .;
|
rodata = .; _rodata = .; __rodata = .;
|
||||||
*(.rodata)
|
*(.rodata)
|
||||||
. = ALIGN(4096);
|
|
||||||
}
|
}
|
||||||
|
. = ALIGN(4096);
|
||||||
.bss : {
|
.bss : {
|
||||||
bss = .; _bss = .; __bss = .;
|
bss = .; _bss = .; __bss = .;
|
||||||
*(.bss)
|
*(.bss)
|
||||||
|
@ -50,10 +50,7 @@ void mm_init()
|
|||||||
{
|
{
|
||||||
mm_preserven(mb_modules[i].mod_start - VIRT_OFFSET, (mb_modules[i].mod_end - mb_modules[i].mod_start) >> 12);
|
mm_preserven(mb_modules[i].mod_start - VIRT_OFFSET, (mb_modules[i].mod_end - mb_modules[i].mod_start) >> 12);
|
||||||
}
|
}
|
||||||
if (mm_totalmem % 0x100000)
|
mm_megabytes = (mm_totalmem >> 20) + ((mm_totalmem % 0x100000) ? 1 : 0);
|
||||||
mm_megabytes = (mm_totalmem >> 20) + 1;
|
|
||||||
else
|
|
||||||
mm_megabytes = mm_totalmem >> 20;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include "mm/mm.h"
|
#include "mm/mm.h"
|
||||||
|
|
||||||
int vmm_map_range(void *virt_start, void *virt_end, u32_t phys_start);
|
int vmm_map_range(void *virt_start, void *virt_end, u32_t phys_start);
|
||||||
void *vmm_getFreeChunk(u32_t size);
|
void *vmm_getFreeChunk(u32_t size);
|
||||||
void vmm_removeHeapEntry(u32_t queue, HeapEntry_t *he);
|
void vmm_removeHeapEntry(u32_t queue, HeapEntry_t *he);
|
||||||
int vmm_moreCore(u32_t size);
|
int vmm_moreCore(u32_t size);
|
||||||
int vmm_coalesceEntry(u32_t queue, HeapEntry_t *newHE);
|
int vmm_coalesceEntry(u32_t queue, HeapEntry_t *newHE);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user