Import backup from 2005-03-21
This commit is contained in:
parent
bb8ff09e3f
commit
14792ef954
17
Makefile
17
Makefile
@ -20,8 +20,10 @@ all:
|
|||||||
clean:
|
clean:
|
||||||
-make -C kernel clean
|
-make -C kernel clean
|
||||||
-make -C rmmod clean
|
-make -C rmmod clean
|
||||||
-rm -f *~ *.out hos.flp \#* hos_initrd hos_initrd.gz parallel.out
|
-rm -f *~ *.out hos.flp \#* hos_initrd hos_initrd.gz
|
||||||
|
|
||||||
|
apps:
|
||||||
|
make -C apps
|
||||||
|
|
||||||
grub:
|
grub:
|
||||||
-mkdir $(FLOPPY_MOUNT)
|
-mkdir $(FLOPPY_MOUNT)
|
||||||
@ -62,18 +64,13 @@ initrd:
|
|||||||
mke2fs -Fv -m0 -r0 -i1024 $(INITRD)
|
mke2fs -Fv -m0 -r0 -i1024 $(INITRD)
|
||||||
-mkdir $(INITRD_MOUNT)
|
-mkdir $(INITRD_MOUNT)
|
||||||
mount -t ext2 -o loop $(INITRD) $(INITRD_MOUNT)
|
mount -t ext2 -o loop $(INITRD) $(INITRD_MOUNT)
|
||||||
touch $(INITRD_MOUNT)/hi_there
|
mkdir $(INITRD_MOUNT)/bin
|
||||||
chmod 527 $(INITRD_MOUNT)/hi_there
|
cp apps/hash/hash $(INITRD_MOUNT)/bin
|
||||||
chown josh:users $(INITRD_MOUNT)/hi_there
|
ln -s /bin/hash $(INITRD_MOUNT)/bin/init
|
||||||
mknod $(INITRD_MOUNT)/rd0 b 5 2
|
|
||||||
mkdir $(INITRD_MOUNT)/txt
|
|
||||||
cp Makefile $(INITRD_MOUNT)/txt
|
|
||||||
ln -s txt/../txt/../txt/../txt/../txt/../txt/../txt/../txt/../txt/.. $(INITRD_MOUNT)/link
|
|
||||||
ln -s /txt/. $(INITRD_MOUNT)/yoda
|
|
||||||
umount $(INITRD_MOUNT)
|
umount $(INITRD_MOUNT)
|
||||||
rm -rf $(INITRD_MOUNT)
|
rm -rf $(INITRD_MOUNT)
|
||||||
|
|
||||||
|
|
||||||
wordcount:
|
wordcount:
|
||||||
find . -regex '\(.*\.[ch]\)\|\(.*\.asm\)\|\(.*\.inc\)\|\(.*\.cpp\)' | xargs cat | wc -l
|
find . -regex '\(.*\.[ch]\)\|\(.*\.asm\)\|\(.*\.inc\)\|\(.*\.cpp\)' | xargs cat | wc
|
||||||
|
|
||||||
|
3
apps/Makefile
Normal file
3
apps/Makefile
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
all:
|
||||||
|
make -C hash
|
||||||
|
|
3
apps/hash/Makefile
Normal file
3
apps/hash/Makefile
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
all:
|
||||||
|
nasm -f bin hash.asm -o hash
|
||||||
|
|
1
apps/hash/hash
Normal file
1
apps/hash/hash
Normal file
@ -0,0 +1 @@
|
|||||||
|
<EFBFBD>0<EFBFBD>
|
6
apps/hash/hash.asm
Normal file
6
apps/hash/hash.asm
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
[bits 32]
|
||||||
|
|
||||||
|
begin:
|
||||||
|
int 0x30
|
||||||
|
ret
|
@ -19,7 +19,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 parallel.o conv.o kout.o \
|
boot.o kernel.o lang_a.o mm.o vmm.o parallel.o conv.o kout.o \
|
||||||
vconsole.o display.o devices.o pic.o keyboard.o ramdisk.o vfs.o \
|
vconsole.o display.o devices.o pic.o keyboard.o ramdisk.o vfs.o \
|
||||||
devfs.o ext2.o lang_c.o -o kernel.bin
|
devfs.o ext2.o lang_c.o vesafb.o -o kernel.bin
|
||||||
|
|
||||||
Asm_Kernel:
|
Asm_Kernel:
|
||||||
$(NASM) $(NASM_FLAGS) -l boot.lst boot.asm -o boot.o
|
$(NASM) $(NASM_FLAGS) -l boot.lst boot.asm -o boot.o
|
||||||
@ -31,10 +31,10 @@ C_Kernel:
|
|||||||
$(CC) $(CC_FLAGS) -c mm/vmm.c -o vmm.o
|
$(CC) $(CC_FLAGS) -c mm/vmm.c -o vmm.o
|
||||||
$(CC) $(CC_FLAGS) -c char/parallel.c -o parallel.o
|
$(CC) $(CC_FLAGS) -c char/parallel.c -o parallel.o
|
||||||
$(CC) $(CC_FLAGS) -c lang/conv.c -o conv.o
|
$(CC) $(CC_FLAGS) -c lang/conv.c -o conv.o
|
||||||
$(CC) $(CC_FLAGS) -c kout.c -o kout.o
|
$(CC) $(CC_FLAGS) -c display/kout.c -o kout.o
|
||||||
$(CC) $(CC_FLAGS) -c char/vconsole.c -o vconsole.o
|
$(CC) $(CC_FLAGS) -c char/vconsole.c -o vconsole.o
|
||||||
$(CC) $(CC_FLAGS) -c fs/devices.c -o devices.o
|
$(CC) $(CC_FLAGS) -c fs/devices.c -o devices.o
|
||||||
$(CC) $(CC_FLAGS) -c display.c -o display.o
|
$(CC) $(CC_FLAGS) -c display/display.c -o display.o
|
||||||
$(CC) $(CC_FLAGS) -c sys/pic.c -o pic.o
|
$(CC) $(CC_FLAGS) -c sys/pic.c -o pic.o
|
||||||
$(CC) $(CC_FLAGS) -c char/keyboard.c -o keyboard.o
|
$(CC) $(CC_FLAGS) -c char/keyboard.c -o keyboard.o
|
||||||
$(CC) $(CC_FLAGS) -c block/ramdisk.c -o ramdisk.o
|
$(CC) $(CC_FLAGS) -c block/ramdisk.c -o ramdisk.o
|
||||||
@ -42,11 +42,12 @@ C_Kernel:
|
|||||||
$(CC) $(CC_FLAGS) -c fs/vfs.c -o vfs.o
|
$(CC) $(CC_FLAGS) -c fs/vfs.c -o vfs.o
|
||||||
$(CC) $(CC_FLAGS) -c fs/ext2.c -o ext2.o
|
$(CC) $(CC_FLAGS) -c fs/ext2.c -o ext2.o
|
||||||
$(CC) $(CC_FLAGS) -c lang/lang.c -o lang_c.o
|
$(CC) $(CC_FLAGS) -c lang/lang.c -o lang_c.o
|
||||||
|
$(CC) $(CC_FLAGS) -c display/vesafb.c -o vesafb.o
|
||||||
|
|
||||||
#################################################
|
#################################################
|
||||||
# Clean up the source directory of any binaries #
|
# Clean up the source directory of any binaries #
|
||||||
#################################################
|
#################################################
|
||||||
clean:
|
clean:
|
||||||
-rm -f *.o *.bin *.map *.lst *.out *~ fs/*~ sys/*~ block/*~ char/*~ lang/*~ mm/*~
|
-rm -f *.o *.bin *.map *.lst *.out *~ fs/*~ sys/*~ block/*~ char/*~ lang/*~ mm/*~ display/*~
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
#include "lang/conv.h" // asciiSwitchCase()
|
#include "lang/conv.h" // asciiSwitchCase()
|
||||||
|
|
||||||
#include "kout.h"
|
#include "display/kout.h"
|
||||||
#include "display.h" // display_activate()
|
#include "display/display.h" // display_activate()
|
||||||
|
|
||||||
#define KBD_BUFFER_LENGTH 64
|
#define KBD_BUFFER_LENGTH 64
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include "fs/devices.h"
|
#include "fs/devices.h"
|
||||||
#include "mm/vmm.h"
|
#include "mm/vmm.h"
|
||||||
#include "lang/lang.h"
|
#include "lang/lang.h"
|
||||||
#include "display.h"
|
#include "display/display.h"
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
|
|
||||||
vconsole_t *vconsoles[VCONSOLE_MAX]; // pointer to virtual console structs
|
vconsole_t *vconsoles[VCONSOLE_MAX]; // pointer to virtual console structs
|
||||||
@ -39,7 +39,7 @@ minor_t vconsole_new(int width, int height)
|
|||||||
int i;
|
int i;
|
||||||
for (i = 1; i < VCONSOLE_MAX; i++)
|
for (i = 1; i < VCONSOLE_MAX; i++)
|
||||||
{
|
{
|
||||||
if ( (!vconsoles[i]) && ( vconsoles[i] = kcalloc(1, sizeof(vconsole_t)))) //New(vconsole_t) ) )
|
if ( (!vconsoles[i]) && ( vconsoles[i] = New(vconsole_t) ) )
|
||||||
{
|
{
|
||||||
if (( vconsoles[i]->buffer = kmalloc(width * height * 2) ))
|
if (( vconsoles[i]->buffer = kmalloc(width * height * 2) ))
|
||||||
{
|
{
|
||||||
@ -47,7 +47,7 @@ minor_t vconsole_new(int width, int height)
|
|||||||
vconsoles[i]->height = height;
|
vconsoles[i]->height = height;
|
||||||
vconsoles[i]->attribute = vconsoles[i]->foreground = 0x07;
|
vconsoles[i]->attribute = vconsoles[i]->foreground = 0x07;
|
||||||
memsetw(vconsoles[i]->buffer, 0x0720, width * height);
|
memsetw(vconsoles[i]->buffer, 0x0720, width * height);
|
||||||
// register the device as /dev/console%d
|
// TODO: register the device as /dev/console%d
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -65,7 +65,8 @@ minor_t vconsole_new(int width, int height)
|
|||||||
int vconsole_draw(minor_t id)
|
int vconsole_draw(minor_t id)
|
||||||
{
|
{
|
||||||
if (vconsoles[id])
|
if (vconsoles[id])
|
||||||
return display_console_draw(id, vconsoles[id]->cursorPosition, vconsoles[id]->buffer);
|
return display_console_draw(id, vconsoles[id]->cursorPosition,
|
||||||
|
vconsoles[id]->buffer, vconsoles[id]->width * vconsoles[id]->height);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,14 +145,11 @@ int vconsole_char_write(minor_t id, int c)
|
|||||||
break;
|
break;
|
||||||
case 's': // push cursor position on an internal stack
|
case 's': // push cursor position on an internal stack
|
||||||
if (vconsoles[id]->cursorStackPosition < 16)
|
if (vconsoles[id]->cursorStackPosition < 16)
|
||||||
vconsoles[id]->cursorStack[vconsoles[id]->cursorStackPosition++] = vconsoles[id]->cursorPosition;
|
vconsoles[id]->cursorStack[vconsoles[id]->cursorStackPosition++] = vconsoles[id]->cursorPosition;
|
||||||
break;
|
break;
|
||||||
case 'u': // pop cursor position from stack
|
case 'u': // pop cursor position from stack
|
||||||
if (vconsoles[id]->cursorStackPosition > 0)
|
if (vconsoles[id]->cursorStackPosition > 0)
|
||||||
{
|
vconsole_update_cursor(id, vconsoles[id]->cursorStack[--vconsoles[id]->cursorStackPosition]);
|
||||||
vconsole_update_cursor(id, vconsoles[id]->cursorStack[--vconsoles[id]->cursorStackPosition]);
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'm': // set text attributes
|
case 'm': // set text attributes
|
||||||
for (evalEscapePosition = 0; evalEscapePosition <= vconsoles[id]->escapePosition; evalEscapePosition++)
|
for (evalEscapePosition = 0; evalEscapePosition <= vconsoles[id]->escapePosition; evalEscapePosition++)
|
||||||
@ -261,13 +259,13 @@ void vconsole_update_cursor(minor_t id, u16_t position)
|
|||||||
vconsoles[id]->cursorPosition = position;
|
vconsoles[id]->cursorPosition = position;
|
||||||
if (position >= (vconsoles[id]->width * vconsoles[id]->height)) // time to scroll console
|
if (position >= (vconsoles[id]->width * vconsoles[id]->height)) // time to scroll console
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < vconsoles[id]->cursorStackPosition; i++)
|
for (i = 0; i < vconsoles[id]->cursorStackPosition; i++)
|
||||||
{
|
{
|
||||||
vconsoles[id]->cursorStack[i] -= vconsoles[id]->width;
|
vconsoles[id]->cursorStack[i] -= vconsoles[id]->width;
|
||||||
if (vconsoles[id]->cursorStack[i] < 0)
|
if (vconsoles[id]->cursorStack[i] < 0)
|
||||||
vconsoles[id]->cursorStack[i] = 0;
|
vconsoles[id]->cursorStack[i] = 0;
|
||||||
}
|
}
|
||||||
vconsoles[id]->cursorPosition -= vconsoles[id]->width;
|
vconsoles[id]->cursorPosition -= vconsoles[id]->width;
|
||||||
memcpyw(vconsoles[id]->buffer, vconsoles[id]->buffer + vconsoles[id]->width, vconsoles[id]->width * (vconsoles[id]->height - 1));
|
memcpyw(vconsoles[id]->buffer, vconsoles[id]->buffer + vconsoles[id]->width, vconsoles[id]->width * (vconsoles[id]->height - 1));
|
||||||
memsetw(vconsoles[id]->buffer + (vconsoles[id]->width * (vconsoles[id]->height - 1)), 0x0720, vconsoles[id]->width);
|
memsetw(vconsoles[id]->buffer + (vconsoles[id]->width * (vconsoles[id]->height - 1)), 0x0720, vconsoles[id]->width);
|
||||||
|
@ -1,96 +0,0 @@
|
|||||||
// display.c
|
|
||||||
// Author: Josh Holtrop
|
|
||||||
// Date: 08/07/04
|
|
||||||
// Modified: 08/21/04
|
|
||||||
|
|
||||||
#include "fs/devices.h"
|
|
||||||
#include "char/vconsole.h"
|
|
||||||
#include "display.h"
|
|
||||||
#include "lang/lang.h"
|
|
||||||
|
|
||||||
int display_activeConsole = -1; // start with no active console
|
|
||||||
display_t myDisplays[12]; // f1-f12 change displays
|
|
||||||
|
|
||||||
// initialization routine for display subsystem
|
|
||||||
int display_init()
|
|
||||||
{
|
|
||||||
minor_t vc;
|
|
||||||
if ((vc = vconsole_new(80, 25)))
|
|
||||||
{
|
|
||||||
myDisplays[11].type = DISPLAY_CONSOLE;
|
|
||||||
myDisplays[11].id = vc;
|
|
||||||
display_activeConsole = vc;
|
|
||||||
}
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < 6; i++)
|
|
||||||
{
|
|
||||||
if ((vc = vconsole_new(80, 25)))
|
|
||||||
{
|
|
||||||
myDisplays[i].type = DISPLAY_CONSOLE;
|
|
||||||
myDisplays[i].id = vc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// activate the given display
|
|
||||||
int display_activate(u32_t id)
|
|
||||||
{
|
|
||||||
if (id > 11)
|
|
||||||
return -1;
|
|
||||||
switch (myDisplays[id].type)
|
|
||||||
{
|
|
||||||
case DISPLAY_CONSOLE:
|
|
||||||
display_activeConsole = myDisplays[id].id;
|
|
||||||
return vconsole_draw(display_activeConsole);
|
|
||||||
case DISPLAY_GRAPHICAL:
|
|
||||||
default:
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// routine to refresh a console window
|
|
||||||
int display_console_draw(minor_t id, int cursorPosition, u16_t *buffer)
|
|
||||||
{
|
|
||||||
if (id == display_activeConsole)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < 12; i++)
|
|
||||||
{
|
|
||||||
if (myDisplays[i].id == id)
|
|
||||||
{
|
|
||||||
memcpyw((void *)CONSOLE_MEMORY, buffer, 2000);
|
|
||||||
writeCursorPosition(cursorPosition);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// write a character to the screen
|
|
||||||
int display_console_put_char(minor_t id, u16_t c, int position)
|
|
||||||
{
|
|
||||||
if (id == display_activeConsole)
|
|
||||||
{
|
|
||||||
*(u16_t *)(CONSOLE_MEMORY + (position << 1)) = 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)
|
|
||||||
{
|
|
||||||
writeCursorPosition(cursorPosition);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
126
kernel/display/display.c
Normal file
126
kernel/display/display.c
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
// display.c
|
||||||
|
// Author: Josh Holtrop
|
||||||
|
// Date: 08/07/04
|
||||||
|
// Modified: 03/19/05
|
||||||
|
|
||||||
|
#include "fs/devices.h"
|
||||||
|
#include "char/vconsole.h"
|
||||||
|
#include "display.h"
|
||||||
|
#include "lang/lang.h"
|
||||||
|
#include "kernel.h"
|
||||||
|
#include "display/vesafb.h"
|
||||||
|
|
||||||
|
extern real_mode_param_t rm_params; // check if a video mode is activated
|
||||||
|
int display_activeConsole = -1; // start with no active console
|
||||||
|
display_t myDisplays[12]; // f1-f12 change displays
|
||||||
|
|
||||||
|
// initialization routine for display subsystem
|
||||||
|
int display_init()
|
||||||
|
{
|
||||||
|
minor_t vc;
|
||||||
|
int width = 80;
|
||||||
|
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);
|
||||||
|
width = vesafb_getWidth();
|
||||||
|
height = vesafb_getHeight();
|
||||||
|
displayType = DISPLAY_FB;
|
||||||
|
}
|
||||||
|
if (( vc = vconsole_new(width, height) ))
|
||||||
|
{
|
||||||
|
myDisplays[11].type = displayType;
|
||||||
|
myDisplays[11].id = vc;
|
||||||
|
display_activeConsole = vc;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < 6; i++)
|
||||||
|
{
|
||||||
|
if ((vc = vconsole_new(width, height)))
|
||||||
|
{
|
||||||
|
myDisplays[i].type = displayType;
|
||||||
|
myDisplays[i].id = vc;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return -2 - i;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// activate the given display
|
||||||
|
int display_activate(u32_t id)
|
||||||
|
{
|
||||||
|
if (id > 11)
|
||||||
|
return -1;
|
||||||
|
switch (myDisplays[id].type)
|
||||||
|
{
|
||||||
|
case DISPLAY_CONSOLE:
|
||||||
|
case DISPLAY_FB:
|
||||||
|
display_activeConsole = myDisplays[id].id;
|
||||||
|
return vconsole_draw(display_activeConsole);
|
||||||
|
case DISPLAY_GRAPHICAL:
|
||||||
|
default:
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// routine to refresh a console window
|
||||||
|
int display_console_draw(minor_t id, int cursorPosition, u16_t *buffer, int buff_len)
|
||||||
|
{
|
||||||
|
if (id == display_activeConsole)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < 12; i++)
|
||||||
|
{
|
||||||
|
if (myDisplays[i].id == id)
|
||||||
|
{
|
||||||
|
if (myDisplays[i].type == DISPLAY_CONSOLE)
|
||||||
|
{
|
||||||
|
memcpyw((void *)CONSOLE_MEMORY, buffer, buff_len);
|
||||||
|
writeCursorPosition(cursorPosition);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (myDisplays[i].type == DISPLAY_FB)
|
||||||
|
return vesafb_draw(buffer, buff_len, cursorPosition);
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
// display.h
|
// display.h
|
||||||
// Author: Josh Holtrop
|
// Author: Josh Holtrop
|
||||||
// Date: 08/07/04
|
// Date: 08/07/04
|
||||||
// Modified: 08/21/04
|
// Modified: 03/19/05
|
||||||
|
|
||||||
#ifndef __HOS_CONSOLE__
|
#ifndef __HOS_CONSOLE__
|
||||||
#define __HOS_CONSOLE__ __HOS_CONSOLE__
|
#define __HOS_CONSOLE__ __HOS_CONSOLE__
|
||||||
@ -9,18 +9,20 @@
|
|||||||
#include "hos_defines.h"
|
#include "hos_defines.h"
|
||||||
#include "fs/devices.h"
|
#include "fs/devices.h"
|
||||||
|
|
||||||
#define DISPLAY_NULL 0
|
#define DISPLAY_NULL 0
|
||||||
#define DISPLAY_CONSOLE 1
|
#define DISPLAY_CONSOLE 1
|
||||||
#define DISPLAY_GRAPHICAL 2
|
#define DISPLAY_FB 2
|
||||||
|
#define DISPLAY_GRAPHICAL 3
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
int type;
|
{
|
||||||
minor_t id;
|
int type;
|
||||||
|
minor_t id;
|
||||||
} display_t;
|
} display_t;
|
||||||
|
|
||||||
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 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);
|
int display_console_put_char(minor_t id, u16_t c, int position);
|
||||||
int display_console_update_cursor(minor_t id, int cursorPosition);
|
int display_console_update_cursor(minor_t id, int cursorPosition);
|
||||||
|
|
@ -1,17 +1,14 @@
|
|||||||
// kout.c
|
// kout.c
|
||||||
// Author: Josh Holtrop
|
// Author: Josh Holtrop
|
||||||
// Date: 08/02/04
|
// Date: 08/02/04
|
||||||
// Modified: 08/16/04
|
// Modified: 03/19/05
|
||||||
|
|
||||||
#include "hos_defines.h"
|
#include "hos_defines.h"
|
||||||
#include "char/parallel.h"
|
|
||||||
#include "kout.h"
|
#include "kout.h"
|
||||||
#include "lang/conv.h"
|
#include "lang/conv.h"
|
||||||
#include "fs/devices.h"
|
#include "fs/devices.h"
|
||||||
|
|
||||||
extern int display_activeConsole;
|
char buffer[64]; // for hex/oct/dec/ascii conversion
|
||||||
|
|
||||||
char buffer[64];
|
|
||||||
|
|
||||||
// print a character
|
// print a character
|
||||||
void putc(int c)
|
void putc(int c)
|
||||||
@ -19,14 +16,14 @@ void putc(int c)
|
|||||||
#ifdef PARALLEL_DEBUG
|
#ifdef PARALLEL_DEBUG
|
||||||
char_write(MAJORC_PARALLEL, 0, c);
|
char_write(MAJORC_PARALLEL, 0, c);
|
||||||
#endif
|
#endif
|
||||||
char_write(MAJORC_VCONSOLE, display_activeConsole, c);
|
char_write(MAJORC_VCONSOLE, 1, c); // write to vconsole with minor 1, first allocated
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// print a formatted string
|
// print a formatted string
|
||||||
void kprintf(char *fmt, ...)
|
void kprintf(char *fmt, ...)
|
||||||
{
|
{
|
||||||
u32_t *params = ((u32_t *)(&fmt)) + 1; //points to the first paramater
|
u32_t *params = ((u32_t *)(&fmt)) + 1; // points to the first paramater
|
||||||
int i;
|
int i;
|
||||||
int special = 0;
|
int special = 0;
|
||||||
for (i = 0; ; i++)
|
for (i = 0; ; i++)
|
111
kernel/display/vesafb.c
Normal file
111
kernel/display/vesafb.c
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
// vesafb.c
|
||||||
|
// Author: Josh Holtrop
|
||||||
|
// Date: 03/19/05
|
||||||
|
// Modified: 03/19/05
|
||||||
|
|
||||||
|
#include "display/display.h"
|
||||||
|
#include "display/vesafb.h"
|
||||||
|
#include "lang/lang.h"
|
||||||
|
#include "hos_defines.h" // BIOS_CHAR_MAP
|
||||||
|
|
||||||
|
u16_t *vmem16 = (u16_t *) VESAFB_VID_ADDR;
|
||||||
|
u32_t *vmem32 = (u32_t *) VESAFB_VID_ADDR;
|
||||||
|
int vesafb_bpp;
|
||||||
|
int vesafb_multiplier;
|
||||||
|
int vesafb_width; // pixels
|
||||||
|
int vesafb_height;
|
||||||
|
int vesafb_xres; // characters
|
||||||
|
int vesafb_yres;
|
||||||
|
int vesafb_cursor; // -1 to hide, 0+ for cursor position
|
||||||
|
|
||||||
|
int vesafb_init(int width, int height, int bpp)
|
||||||
|
{
|
||||||
|
switch(vesafb_bpp = bpp)
|
||||||
|
{
|
||||||
|
case 15: case 16:
|
||||||
|
vesafb_multiplier = 2;
|
||||||
|
break;
|
||||||
|
case 24:
|
||||||
|
vesafb_multiplier = 3;
|
||||||
|
break;
|
||||||
|
case 32:
|
||||||
|
vesafb_multiplier = 4;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
vesafb_width = width;
|
||||||
|
vesafb_height = height;
|
||||||
|
vesafb_xres = (width >> 3) & 0xFFF8; // columns divisible by 8
|
||||||
|
vesafb_yres = height >> 3;
|
||||||
|
return vesafb_cursor = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void vesafb_clear()
|
||||||
|
{
|
||||||
|
memset(vmem32, 0, vesafb_width * vesafb_height * vesafb_multiplier);
|
||||||
|
vesafb_update_cursor(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void vesafb_update_cursor(int position)
|
||||||
|
{
|
||||||
|
vesafb_draw_cursor(vesafb_cursor, 0);
|
||||||
|
vesafb_draw_cursor(vesafb_cursor = position, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void vesafb_draw_cursor(int position, int onoff)
|
||||||
|
{
|
||||||
|
int x = (position % vesafb_xres) << 3;
|
||||||
|
int y = ( (position / vesafb_xres) << 3 ) + 7;
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < 7; i++)
|
||||||
|
vesafb_pset(x + i, y, onoff);
|
||||||
|
}
|
||||||
|
|
||||||
|
void vesafb_pset(int x, int y, int onoff)
|
||||||
|
{
|
||||||
|
switch (vesafb_bpp)
|
||||||
|
{
|
||||||
|
case 15: case 16:
|
||||||
|
*(vmem16 + vesafb_width*y + x) = (onoff ? 0xFFFF : 0);
|
||||||
|
break;
|
||||||
|
case 24:
|
||||||
|
*((u32_t *)(((u32_t)vmem32) + 3*vesafb_width*y + 3*x)) = (onoff ? 0x00FFFFFF : 0);
|
||||||
|
break;
|
||||||
|
case 32:
|
||||||
|
*(vmem32 + vesafb_width*y + x) = (onoff ? 0x00FFFFFF : 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int vesafb_getWidth()
|
||||||
|
{
|
||||||
|
return vesafb_xres;
|
||||||
|
}
|
||||||
|
|
||||||
|
int vesafb_getHeight()
|
||||||
|
{
|
||||||
|
return vesafb_yres;
|
||||||
|
}
|
||||||
|
|
||||||
|
void vesafb_draw_char(int position, u16_t chr)
|
||||||
|
{
|
||||||
|
int x = (position % vesafb_xres) << 3;
|
||||||
|
int y = (position / vesafb_xres) << 3;
|
||||||
|
int xi, yi;
|
||||||
|
u8_t *charMap = (u8_t *) ( BIOS_CHAR_MAP + ((chr & 0xFF) << 3) );
|
||||||
|
for (yi = 0; yi < 7; yi++)
|
||||||
|
{
|
||||||
|
for (xi = 0; xi < 7; xi++)
|
||||||
|
vesafb_pset(x + xi, y + yi, (*charMap & (0x80 >> xi)));
|
||||||
|
charMap++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int vesafb_draw(u16_t *buffer, int buff_len, int cursor_position)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < buff_len; i++)
|
||||||
|
vesafb_draw_char(i, *buffer++);
|
||||||
|
vesafb_update_cursor(cursor_position);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
25
kernel/display/vesafb.h
Normal file
25
kernel/display/vesafb.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// vesafb.h
|
||||||
|
// Author: Josh Holtrop
|
||||||
|
// Date: 03/19/05
|
||||||
|
// Modified: 03/19/05
|
||||||
|
|
||||||
|
#ifndef __HOS_VESAFB__
|
||||||
|
#define __HOS_VESAFB__ __HOS_VESAFB__
|
||||||
|
|
||||||
|
#include "hos_defines.h"
|
||||||
|
|
||||||
|
#define VESAFB_VID_ADDR 0xF0000000
|
||||||
|
|
||||||
|
int vesafb_init(int width, int height, int bpp);
|
||||||
|
void vesafb_clear();
|
||||||
|
void vesafb_update_cursor(int position);
|
||||||
|
void vesafb_draw_cursor(int position, int onoff);
|
||||||
|
void vesafb_pset(int x, int y, int onoff);
|
||||||
|
int vesafb_getWidth();
|
||||||
|
int vesafb_getHeight();
|
||||||
|
void vesafb_draw_char(int position, u16_t chr);
|
||||||
|
int vesafb_draw(u16_t *buffer, int buff_len, int cursor_position);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include "hos_defines.h"
|
#include "hos_defines.h"
|
||||||
#include "fs/devices.h"
|
#include "fs/devices.h"
|
||||||
#include "kout.h"
|
#include "display/kout.h"
|
||||||
#include "ext2.h"
|
#include "ext2.h"
|
||||||
#include "mm/vmm.h"
|
#include "mm/vmm.h"
|
||||||
#include "fs/vfs.h"
|
#include "fs/vfs.h"
|
||||||
@ -416,6 +416,23 @@ int ext2_resize_inode(vfs_mount_t *mount, u32_t inode_number, u32_t new_size)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// TODO: resize
|
// TODO: resize
|
||||||
|
u32_t block_size = 1024 << super->s_log_block_size;
|
||||||
|
u32_t pointers_per_block = block_size >> 2;
|
||||||
|
u32_t *pointer_cache1 = kmalloc(3 * block_size);
|
||||||
|
u32_t *pointer_cache2 = pointer_cache1 + pointers_per_block;
|
||||||
|
u32_t *pointer_cache3 = pointer_cache2 + pointers_per_block;
|
||||||
|
u32_t c1_start, c2_start, c3_start;
|
||||||
|
c1_start = c2_start = c3_start = 0;
|
||||||
|
while (new_blocks < current_blocks) // delete, decrease current_blocks
|
||||||
|
{
|
||||||
|
current_blocks--;
|
||||||
|
// now delete block number current_blocks
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
while (current_blocks < new_blocks) // add, increase current_blocks
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// reserve a node of a inode or block bitmap and mark its entry allocated
|
// reserve a node of a inode or block bitmap and mark its entry allocated
|
||||||
@ -719,7 +736,7 @@ int ext2__read_block_file(vfs_mount_t *mount, vfs_open_file_t *open_file, void *
|
|||||||
kfree(block);
|
kfree(block);
|
||||||
return 0; // EOF
|
return 0; // EOF
|
||||||
}
|
}
|
||||||
memcpy(buffer, block + data_offset, 512);
|
memcpy(buffer, block + data_offset, min(512, bytes_read - data_offset));
|
||||||
kfree(block);
|
kfree(block);
|
||||||
open_block_file->block++;
|
open_block_file->block++;
|
||||||
return min(512, bytes_read - data_offset);
|
return min(512, bytes_read - data_offset);
|
||||||
|
@ -119,7 +119,7 @@ typedef struct
|
|||||||
u32_t i_blocks; // Blocks count
|
u32_t i_blocks; // Blocks count
|
||||||
u32_t i_flags; // File flags
|
u32_t i_flags; // File flags
|
||||||
u32_t i_reserved1;
|
u32_t i_reserved1;
|
||||||
u32_t i_block[15]; // Pointers to file blocks
|
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_version; // File version (for NFS)
|
||||||
u32_t i_file_acl; // File ACL
|
u32_t i_file_acl; // File ACL
|
||||||
u32_t i_dir_acl; // Directory ACL
|
u32_t i_dir_acl; // Directory ACL
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
// Modified: 12/21/04
|
// Modified: 12/21/04
|
||||||
|
|
||||||
#include "hos_defines.h"
|
#include "hos_defines.h"
|
||||||
#include "kout.h"
|
#include "display/kout.h"
|
||||||
#include "fs/vfs.h"
|
#include "fs/vfs.h"
|
||||||
#include "fs/ext2.h"
|
#include "fs/ext2.h"
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#define HEAP_LENGTH 0x20000000
|
#define HEAP_LENGTH 0x20000000
|
||||||
|
|
||||||
#define CONSOLE_MEMORY 0xC00B8000
|
#define CONSOLE_MEMORY 0xC00B8000
|
||||||
|
#define BIOS_CHAR_MAP 0xC00FFA6E
|
||||||
|
|
||||||
#define MAX_MODULES 16
|
#define MAX_MODULES 16
|
||||||
#define MAX_MMAP 16
|
#define MAX_MMAP 16
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// kernel.h
|
// kernel.h
|
||||||
// Author: Josh Holtrop
|
// Author: Josh Holtrop
|
||||||
// Date: 08/16/04
|
// Date: 08/16/04
|
||||||
// Modified: 08/28/04
|
// Modified: 03/19/05
|
||||||
// This is the main kernel initialization and boot-strapping file
|
// This is the main kernel initialization and boot-strapping file
|
||||||
|
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
@ -12,11 +12,11 @@
|
|||||||
#include "mm/mm.h"
|
#include "mm/mm.h"
|
||||||
#include "mm/vmm.h"
|
#include "mm/vmm.h"
|
||||||
#include "char/parallel.h"
|
#include "char/parallel.h"
|
||||||
#include "kout.h"
|
|
||||||
#include "lang/conv.h"
|
#include "lang/conv.h"
|
||||||
#include "char/vconsole.h"
|
#include "char/vconsole.h"
|
||||||
#include "fs/devices.h"
|
#include "fs/devices.h"
|
||||||
#include "display.h"
|
#include "display/display.h"
|
||||||
|
#include "display/kout.h"
|
||||||
#include "sys/io.h"
|
#include "sys/io.h"
|
||||||
#include "sys/pic.h"
|
#include "sys/pic.h"
|
||||||
#include "char/keyboard.h"
|
#include "char/keyboard.h"
|
||||||
@ -110,11 +110,23 @@ void k_init()
|
|||||||
devices_init();
|
devices_init();
|
||||||
if (real_mode_module)
|
if (real_mode_module)
|
||||||
{
|
{
|
||||||
if (rm_params.vid_mem) // there is video memory to map in
|
if (rm_params.vid_addr) // there is video memory to map in
|
||||||
vmm_mapn(0xF0000000, (u32_t)rm_params.vid_addr, (rm_params.vid_mem >> 12) + 1);
|
{
|
||||||
|
u32_t vid_mem = rm_params.width * rm_params.height;
|
||||||
|
switch (rm_params.bpp)
|
||||||
|
{
|
||||||
|
case 15: case 16:
|
||||||
|
vid_mem <<= 1; break;
|
||||||
|
case 24:
|
||||||
|
vid_mem *= 3; break;
|
||||||
|
case 32:
|
||||||
|
vid_mem <<= 2; break;
|
||||||
|
}
|
||||||
|
vmm_mapn(0xF0000000, (u32_t)rm_params.vid_addr, (vid_mem >> 12) + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
display_init(); //get us some virtual consoles to look at
|
display_init(); // get us some virtual consoles to look at
|
||||||
display_activate(11);
|
display_activate(11); // activate kernel dump vconsole
|
||||||
kprintf("HOS v0.16 initializing...\n");
|
kprintf("HOS v0.16 initializing...\n");
|
||||||
kprintf("Kernel load size: %d (0x%x) bytes (%d kb)\n", kernel_size(), kernel_size(), kernel_size() >> 10);
|
kprintf("Kernel load size: %d (0x%x) bytes (%d kb)\n", kernel_size(), kernel_size(), kernel_size() >> 10);
|
||||||
kprintf("Kernel memory size: %d (0x%x) bytes (%d kb)\n", kernel_size_used(), kernel_size_used(), kernel_size_used() >> 10);
|
kprintf("Kernel memory size: %d (0x%x) bytes (%d kb)\n", kernel_size_used(), kernel_size_used(), kernel_size_used() >> 10);
|
||||||
@ -174,19 +186,7 @@ void k_init()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
kprintf("Error: Could not open directory\n");
|
kprintf("Error: Could not open directory\n");
|
||||||
vfs_mount_t *rootm = vfs_get_mount(0);
|
|
||||||
kprintf("Total/Free inodes: %d/%d\tTotal/Free blocks: %d/%d\n",
|
|
||||||
vfs_total_inodes(rootm), vfs_free_inodes(rootm), vfs_total_blocks(rootm), vfs_free_blocks(rootm));
|
|
||||||
u32_t block = vfs_alloc_block(rootm);
|
|
||||||
kprintf("VFS got block %d\n", block);
|
|
||||||
kprintf("Total/Free inodes: %d/%d\tTotal/Free blocks: %d/%d\n",
|
|
||||||
vfs_total_inodes(rootm), vfs_free_inodes(rootm), vfs_total_blocks(rootm), vfs_free_blocks(rootm));
|
|
||||||
kprintf("Freeing block... %d\n", vfs_free_block(rootm, block));
|
|
||||||
kprintf("Total/Free inodes: %d/%d\tTotal/Free blocks: %d/%d\n",
|
|
||||||
vfs_total_inodes(rootm), vfs_free_inodes(rootm), vfs_total_blocks(rootm), vfs_free_blocks(rootm));
|
|
||||||
kprintf("Freeing block (again)... %d\n", vfs_free_block(rootm, block));
|
|
||||||
kprintf("Total/Free inodes: %d/%d\tTotal/Free blocks: %d/%d\n",
|
|
||||||
vfs_total_inodes(rootm), vfs_free_inodes(rootm), vfs_total_blocks(rootm), vfs_free_blocks(rootm));
|
|
||||||
criticalCounter--;
|
criticalCounter--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ typedef struct {
|
|||||||
void *vid_addr; // address of LFB, 0 if console mode
|
void *vid_addr; // address of LFB, 0 if console mode
|
||||||
u32_t width; // width in pixels or columns if vid_mem == 0
|
u32_t width; // width in pixels or columns if vid_mem == 0
|
||||||
u32_t height; // height in pixels or columns if vid_mem == 0
|
u32_t height; // height in pixels or columns if vid_mem == 0
|
||||||
u32_t vid_mem; // amount of memory for video buffer
|
|
||||||
u32_t bpp; // bits per pixel - 15/16/24/32
|
u32_t bpp; // bits per pixel - 15/16/24/32
|
||||||
} __attribute__ ((packed)) real_mode_param_t;
|
} __attribute__ ((packed)) real_mode_param_t;
|
||||||
|
|
||||||
|
@ -27,6 +27,8 @@ con_move_cursor: ;con_move_cursor(word location)
|
|||||||
|
|
||||||
con_clear:
|
con_clear:
|
||||||
pusha
|
pusha
|
||||||
|
push es
|
||||||
|
push ds
|
||||||
|
|
||||||
mov ax, 0xB800
|
mov ax, 0xB800
|
||||||
mov es, ax
|
mov es, ax
|
||||||
@ -37,6 +39,8 @@ con_clear:
|
|||||||
mov [cursor], word 0
|
mov [cursor], word 0
|
||||||
call con_write_cursor
|
call con_write_cursor
|
||||||
|
|
||||||
|
pop ds
|
||||||
|
pop es
|
||||||
popa
|
popa
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -52,9 +56,7 @@ putstring_loop:
|
|||||||
or al, al
|
or al, al
|
||||||
jz putstring_done
|
jz putstring_done
|
||||||
mov ah, 0x07
|
mov ah, 0x07
|
||||||
push ax
|
ccall con_putc, ax
|
||||||
call con_putc
|
|
||||||
add sp, 2
|
|
||||||
jmp putstring_loop
|
jmp putstring_loop
|
||||||
|
|
||||||
putstring_done:
|
putstring_done:
|
||||||
@ -63,10 +65,93 @@ putstring_done:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
con_putHex: ;con_putHex(word hexVal)
|
||||||
|
push bp
|
||||||
|
mov bp, sp
|
||||||
|
pusha
|
||||||
|
|
||||||
|
mov ax, [bp + 4]
|
||||||
|
mov cx, 12
|
||||||
|
mov dl, 0
|
||||||
|
con_putHex_loop:
|
||||||
|
push ax
|
||||||
|
shr ax, cl
|
||||||
|
and ax, 0xF
|
||||||
|
cmp ax, 0
|
||||||
|
jnz con_putHex_putc
|
||||||
|
cmp cx, 0
|
||||||
|
jz con_putHex_putc
|
||||||
|
cmp dl, 0
|
||||||
|
jz con_putHex_loop_done
|
||||||
|
con_putHex_putc:
|
||||||
|
add ax, '0'
|
||||||
|
cmp ax, '9'
|
||||||
|
jbe con_putHex_putc_goon
|
||||||
|
add ax, 'A'-'9'-1
|
||||||
|
con_putHex_putc_goon:
|
||||||
|
mov ah, 0x07
|
||||||
|
ccall con_putc, ax
|
||||||
|
mov dl, 1
|
||||||
|
con_putHex_loop_done:
|
||||||
|
pop ax
|
||||||
|
cmp cx, 0
|
||||||
|
jz con_putHex_done
|
||||||
|
sub cx, 4
|
||||||
|
jmp con_putHex_loop
|
||||||
|
|
||||||
|
con_putHex_done:
|
||||||
|
popa
|
||||||
|
pop bp
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
con_putDec: ;con_putDec(word dec)
|
||||||
|
push bp
|
||||||
|
mov bp, sp
|
||||||
|
pusha
|
||||||
|
|
||||||
|
mov ax, [bp + 4]
|
||||||
|
mov cx, 10000
|
||||||
|
mov di, 0
|
||||||
|
|
||||||
|
con_putDec_loop:
|
||||||
|
xor dx, dx
|
||||||
|
div cx ;remainder in dx, quotient in ax
|
||||||
|
mov bx, ax
|
||||||
|
mov ax, dx ;new value is ax % mod
|
||||||
|
push ax
|
||||||
|
mov ax, bx
|
||||||
|
cmp ax, 0
|
||||||
|
jnz con_putDec_putc
|
||||||
|
cmp cx, 1
|
||||||
|
jz con_putDec_putc
|
||||||
|
cmp di, 0
|
||||||
|
jz con_putDec_loop_done
|
||||||
|
con_putDec_putc:
|
||||||
|
add ax, 0x0730
|
||||||
|
ccall con_putc, ax
|
||||||
|
mov di, 1
|
||||||
|
|
||||||
|
con_putDec_loop_done:
|
||||||
|
mov ax, cx
|
||||||
|
xor dx, dx
|
||||||
|
mov bx, 10
|
||||||
|
div bx
|
||||||
|
mov cx, ax
|
||||||
|
pop ax
|
||||||
|
cmp cx, 0
|
||||||
|
jnz con_putDec_loop
|
||||||
|
|
||||||
|
popa
|
||||||
|
pop bp
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
con_putc: ;con_putc(char chr)
|
con_putc: ;con_putc(char chr)
|
||||||
push bp
|
push bp
|
||||||
mov bp, sp
|
mov bp, sp
|
||||||
pusha
|
pusha
|
||||||
|
push es
|
||||||
|
|
||||||
mov ax, 0xB800
|
mov ax, 0xB800
|
||||||
mov es, ax
|
mov es, ax
|
||||||
@ -79,13 +164,15 @@ con_putc: ;con_putc(char chr)
|
|||||||
putc_return:
|
putc_return:
|
||||||
mov ax, di
|
mov ax, di
|
||||||
mov bl, 160
|
mov bl, 160
|
||||||
div bl ; quotient in al, remainder in ah
|
div bl ; quotient in al, remainder in ah
|
||||||
shr ax, 8
|
shr ax, 8
|
||||||
sub di, ax
|
sub di, ax
|
||||||
add di, 160
|
add di, 160
|
||||||
putc_update:
|
putc_update:
|
||||||
mov [cursor], di
|
mov [cursor], di
|
||||||
call con_write_cursor
|
call con_write_cursor
|
||||||
|
|
||||||
|
pop es
|
||||||
popa
|
popa
|
||||||
pop bp
|
pop bp
|
||||||
ret
|
ret
|
||||||
|
172
rmmod/rmmod.asm
172
rmmod/rmmod.asm
@ -5,7 +5,7 @@
|
|||||||
; Modified: 01/04/05
|
; Modified: 01/04/05
|
||||||
|
|
||||||
%define VIRT_OFFSET 0xC0000000
|
%define VIRT_OFFSET 0xC0000000
|
||||||
|
%define SIZEOF_RMPARAMS 20
|
||||||
%include "rmmod.inc"
|
%include "rmmod.inc"
|
||||||
|
|
||||||
; the bootstrap process will jump us to 0x0:0x5010 so we'd better be ready for it
|
; the bootstrap process will jump us to 0x0:0x5010 so we'd better be ready for it
|
||||||
@ -21,6 +21,10 @@
|
|||||||
; ecx = where to store real mode parameter table
|
; ecx = where to store real mode parameter table
|
||||||
start:
|
start:
|
||||||
jmp 0:start_refreshed
|
jmp 0:start_refreshed
|
||||||
|
|
||||||
|
%include "conio.inc"
|
||||||
|
%include "vesa.inc"
|
||||||
|
|
||||||
start_refreshed:
|
start_refreshed:
|
||||||
mov ax, cs ; 0
|
mov ax, cs ; 0
|
||||||
mov ds, ax
|
mov ds, ax
|
||||||
@ -30,30 +34,144 @@ start_refreshed:
|
|||||||
mov [dat_rmadd], ecx
|
mov [dat_rmadd], ecx
|
||||||
mov [dat_retn], ebx
|
mov [dat_retn], ebx
|
||||||
|
|
||||||
|
mov ebx, ecx ; clear the rm_params
|
||||||
|
mov cx, SIZEOF_RMPARAMS
|
||||||
|
mov ax, 0
|
||||||
|
clear_rmparams_loop:
|
||||||
|
mov [ebx], al
|
||||||
|
inc ebx
|
||||||
|
loop clear_rmparams_loop
|
||||||
|
|
||||||
; begin real-mode code initialization, etc...
|
; begin real-mode code initialization, etc...
|
||||||
|
|
||||||
call con_clear
|
call con_clear
|
||||||
|
|
||||||
; ccall vesa_get_info, es, vbe_info_block
|
ccall vesa_get_info, es, vbe_info_block
|
||||||
jmp no_vesa
|
cmp ax, 0
|
||||||
|
jnzfar no_vesa
|
||||||
|
|
||||||
vesa_present:
|
vesa_present:
|
||||||
ccall con_putstring, txt_vesa
|
ccall con_putstring, txt_vesa
|
||||||
mov ax, [VideoModePtr]
|
xor ax, ax
|
||||||
mov es, ax
|
mov al, [VbeVersion + 1]
|
||||||
mov si, [VideoModePtr + 2]
|
ccall con_putHex, ax
|
||||||
|
ccall con_putc, '.' | 0x0700
|
||||||
|
xor ax, ax
|
||||||
|
mov al, [VbeVersion]
|
||||||
|
ccall con_putHex, ax
|
||||||
|
ccall con_putc, 10
|
||||||
|
|
||||||
|
xor ax, ax ; clear the scratch mem
|
||||||
|
mov cx, 129
|
||||||
|
mov di, scratch_mem
|
||||||
|
rep stosw
|
||||||
|
|
||||||
|
push ds
|
||||||
|
mov ax, [OemStringPtr + 2]
|
||||||
|
mov si, [OemStringPtr]
|
||||||
|
mov ds, ax
|
||||||
|
mov di, scratch_mem
|
||||||
|
mov cx, 128
|
||||||
|
rep movsw ; and copy the string there for display
|
||||||
|
pop ds
|
||||||
|
|
||||||
|
ccall con_putstring, scratch_mem ; write OEM string
|
||||||
|
ccall con_putc, 10
|
||||||
|
mov ax, [VideoModePtr + 2]
|
||||||
|
mov es, ax
|
||||||
|
mov si, [VideoModePtr]
|
||||||
|
xor dx, dx
|
||||||
|
vesa_mode_loop:
|
||||||
|
mov ax, [es:si] ; get next mode number
|
||||||
|
cmp ax, 0xFFFF
|
||||||
|
jzfar vesa_mode_loop_done
|
||||||
|
ccall vesa_get_mode_info, ds, vbe_mode_info_block, ax
|
||||||
|
cmp ax, 0
|
||||||
|
jnzfar vesa_mode_loop_next
|
||||||
|
|
||||||
|
mov ax, [ModeAttributes]
|
||||||
|
and ax, VESA_MODE_SUPPORTED | VESA_MODE_COLOR | VESA_MODE_GRAPHICS | VESA_MODE_LFB
|
||||||
|
cmp ax, VESA_MODE_SUPPORTED | VESA_MODE_COLOR | VESA_MODE_GRAPHICS | VESA_MODE_LFB
|
||||||
|
jnzfar vesa_mode_loop_next
|
||||||
|
mov al, [BitsPerPixel]
|
||||||
|
cmp al, 15
|
||||||
|
jz vesa_mode_good
|
||||||
|
cmp al, 16
|
||||||
|
jz vesa_mode_good
|
||||||
|
cmp al, 24
|
||||||
|
jz vesa_mode_good
|
||||||
|
cmp al, 32
|
||||||
|
jnzfar vesa_mode_loop_next
|
||||||
|
vesa_mode_good:
|
||||||
|
mov ax, dx
|
||||||
|
add ax, 0x0700 | 'a'
|
||||||
|
ccall con_putc, ax
|
||||||
|
ccall con_putstring, txt_vesa_mode1
|
||||||
|
ccall con_putDec, word [XResolution]
|
||||||
|
ccall con_putc, 'x' | 0x0700
|
||||||
|
ccall con_putDec, word [YResolution]
|
||||||
|
ccall con_putc, 'x' | 0x0700
|
||||||
|
xor ax, ax
|
||||||
|
mov al, [BitsPerPixel]
|
||||||
|
ccall con_putDec, ax
|
||||||
|
ccall con_putstring, txt_vesa_mode2
|
||||||
|
mov ax, [es:si] ; mode number
|
||||||
|
ccall con_putHex, ax
|
||||||
|
ccall con_putc, 10
|
||||||
|
|
||||||
|
mov bx, dx
|
||||||
|
shl bx, 1
|
||||||
|
mov [scratch_mem + bx], ax ; store modes in scratch_mem array
|
||||||
|
inc dx
|
||||||
|
|
||||||
|
vesa_mode_loop_next:
|
||||||
|
add si, 2
|
||||||
|
jmp vesa_mode_loop
|
||||||
|
|
||||||
|
vesa_mode_loop_done:
|
||||||
|
ccall con_putstring, txt_vesa_end
|
||||||
|
|
||||||
|
vesa_get_key_loop:
|
||||||
|
call con_getkey
|
||||||
|
mov ah, 0
|
||||||
|
cmp ax, '0'
|
||||||
|
jz vesa_the_end
|
||||||
|
cmp ax, 'a' ; first choice
|
||||||
|
jb vesa_get_key_loop
|
||||||
|
add dx, 'a'
|
||||||
|
cmp ax, dx ; one past last choice
|
||||||
|
jae vesa_get_key_loop
|
||||||
|
; ok, we have a valid video mode selection
|
||||||
|
sub ax, 'a'
|
||||||
|
shl ax, 1
|
||||||
|
mov bx, ax
|
||||||
|
mov cx, [scratch_mem + bx]
|
||||||
|
ccall vesa_get_mode_info, ds, vbe_mode_info_block, cx
|
||||||
|
or cx, 0x4000 ; enable LFB
|
||||||
|
ccall vesa_set_mode, cx ; turn on mode
|
||||||
|
|
||||||
|
mov ebx, [dat_rmadd] ; pass mode info to kernel
|
||||||
|
mov eax, [PhysBasePtr]
|
||||||
|
mov [ebx + 0], eax
|
||||||
|
xor eax, eax
|
||||||
|
mov al, [BitsPerPixel]
|
||||||
|
mov [ebx + 12], eax
|
||||||
|
mov ax, [XResolution]
|
||||||
|
mov [ebx + 4], eax
|
||||||
|
mov ax, [YResolution]
|
||||||
|
mov [ebx + 8], eax
|
||||||
|
|
||||||
|
jmp vesa_the_end
|
||||||
|
|
||||||
|
|
||||||
jmp end_rmmod
|
|
||||||
|
|
||||||
no_vesa:
|
no_vesa:
|
||||||
ccall con_putstring, txt_novesa
|
ccall con_putstring, txt_novesa
|
||||||
|
call con_getkey
|
||||||
|
|
||||||
|
vesa_the_end:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end_rmmod: ; get ready to go back to pmode and return to kernel initialization
|
end_rmmod: ; get ready to go back to pmode and return to kernel initialization
|
||||||
; call con_getkey
|
|
||||||
mov ebx, [dat_retn]
|
mov ebx, [dat_retn]
|
||||||
lgdt [gdtrlin32]
|
lgdt [gdtrlin32]
|
||||||
mov eax, cr0
|
mov eax, cr0
|
||||||
@ -77,8 +195,6 @@ offset_continue:
|
|||||||
|
|
||||||
[bits 16]
|
[bits 16]
|
||||||
|
|
||||||
%include "conio.inc"
|
|
||||||
|
|
||||||
;-------------------------------------------------------
|
;-------------------------------------------------------
|
||||||
gdtrlin32:
|
gdtrlin32:
|
||||||
dw gdt_endlin32-gdtlin32-1
|
dw gdt_endlin32-gdtlin32-1
|
||||||
@ -142,7 +258,10 @@ KERNEL_DATA_BS32 equ $-gdtbs32
|
|||||||
gdt_endbs32:
|
gdt_endbs32:
|
||||||
|
|
||||||
|
|
||||||
txt_vesa: db "VESA found. Please select:", 10, 0
|
txt_vesa: db "VESA found. VBE Version: ", 0
|
||||||
|
txt_vesa_mode1 db ". ", 0
|
||||||
|
txt_vesa_mode2 db ", mode 0x", 0
|
||||||
|
txt_vesa_end: db "Enter the letter of your selection or 0 for console mode:", 0
|
||||||
txt_novesa: db "VESA not found, using 80x25 console mode... press any key", 10, 0
|
txt_novesa: db "VESA not found, using 80x25 console mode... press any key", 10, 0
|
||||||
|
|
||||||
dat_rmadd: dd 0
|
dat_rmadd: dd 0
|
||||||
@ -162,4 +281,29 @@ OemProductName: dd 0
|
|||||||
OemProductRev: dd 0
|
OemProductRev: dd 0
|
||||||
Reserved: times 478 db 0
|
Reserved: times 478 db 0
|
||||||
|
|
||||||
|
vbe_mode_info_block:
|
||||||
|
ModeAttributes: dw 0
|
||||||
|
WinAAttributes: db 0
|
||||||
|
WinBAttributes: db 0
|
||||||
|
WinGranularity: dw 0
|
||||||
|
WinSize: dw 0
|
||||||
|
WinASegment: dw 0
|
||||||
|
WinBSegment: dw 0
|
||||||
|
WinFuncPtr: dd 0
|
||||||
|
BytesPerScanline: dw 0
|
||||||
|
|
||||||
|
XResolution: dw 0
|
||||||
|
YResolution: dw 0
|
||||||
|
XCharSize: db 0
|
||||||
|
YCharSize: db 0
|
||||||
|
NumberOfPlanes: db 0
|
||||||
|
BitsPerPixel: db 0
|
||||||
|
NumberOfBanks: db 0
|
||||||
|
MemoryModel: db 0
|
||||||
|
BankSize: db 0
|
||||||
|
NumberOfImagePages: db 0
|
||||||
|
Reserved2: times 10 db 0
|
||||||
|
PhysBasePtr: dd 0
|
||||||
|
Reserved3: times 212 db 0
|
||||||
|
|
||||||
|
scratch_mem:
|
||||||
|
@ -4,30 +4,82 @@
|
|||||||
; Modified: 01/04/05
|
; Modified: 01/04/05
|
||||||
; real mode vesa functions
|
; real mode vesa functions
|
||||||
|
|
||||||
|
; sample bochs VBE modes:
|
||||||
|
;0x000c6a86 <bogus+ 0>: 0x0100 0x0101 0x0102 0x0103 0x0105 0x0110 0x0111 0x0112
|
||||||
|
;0x000c6a96 <bogus+ 16>: 0x0113 0x0114 0x0115 0x0116 0x0117 0x0118 0x0142 0x0143
|
||||||
|
;0x000c6aa6 <bogus+ 32>: 0x0144 0x0146 0xffff
|
||||||
|
|
||||||
|
%define VESA_MODE_SUPPORTED 0x01
|
||||||
|
%define VESA_MODE_COLOR 0x08
|
||||||
|
%define VESA_MODE_GRAPHICS 0x10
|
||||||
|
%define VESA_MODE_LFB 0x80
|
||||||
|
|
||||||
|
vesa_return: dw 0
|
||||||
|
|
||||||
vesa_get_info: ;vesa_get_info(word seg, word offset)
|
vesa_get_info: ;vesa_get_info(word seg, word offset)
|
||||||
push bp
|
push bp
|
||||||
mov bp, sp
|
mov bp, sp
|
||||||
pusha
|
pusha
|
||||||
|
push es
|
||||||
|
push ds
|
||||||
|
|
||||||
mov ax, [bp + 4]
|
mov ax, [bp + 4]
|
||||||
mov es, ax
|
mov es, ax
|
||||||
mov di, [bp + 6]
|
mov di, [bp + 6]
|
||||||
mov ax, 0x4F00
|
mov ax, 0x4F00
|
||||||
int 0x10
|
int 0x10
|
||||||
cmp ax, 0x004F
|
sub ax, 0x004F
|
||||||
jz vesa_got_info
|
mov [vesa_return], ax
|
||||||
|
|
||||||
mov [vesa_return], word 1
|
pop ds
|
||||||
jmp vesa_get_info_done
|
pop es
|
||||||
|
|
||||||
vesa_got_info:
|
|
||||||
mov [vesa_return], word 0
|
|
||||||
|
|
||||||
vesa_got_info_done:
|
|
||||||
popa
|
popa
|
||||||
pop bp
|
pop bp
|
||||||
mov ax, [vesa_return]
|
mov ax, [vesa_return]
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
vesa_return: dw 0
|
vesa_get_mode_info: ;vesa_get_info(word seg, word offset, word mode)
|
||||||
|
push bp
|
||||||
|
mov bp, sp
|
||||||
|
pusha
|
||||||
|
push es
|
||||||
|
push ds
|
||||||
|
|
||||||
|
mov ax, [bp + 4]
|
||||||
|
mov es, ax
|
||||||
|
mov di, [bp + 6]
|
||||||
|
mov cx, [bp + 8]
|
||||||
|
mov ax, 0x4F01
|
||||||
|
int 0x10
|
||||||
|
sub ax, 0x004F
|
||||||
|
mov [vesa_return], ax
|
||||||
|
|
||||||
|
pop ds
|
||||||
|
pop es
|
||||||
|
popa
|
||||||
|
pop bp
|
||||||
|
mov ax, [vesa_return]
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
vesa_set_mode: ;vesa_set_mode(word mode)
|
||||||
|
push bp
|
||||||
|
mov bp, sp
|
||||||
|
pusha
|
||||||
|
push es
|
||||||
|
push ds
|
||||||
|
|
||||||
|
mov bx, [bp + 4]
|
||||||
|
mov ax, 0x4F02
|
||||||
|
int 0x10
|
||||||
|
sub ax, 0x004F
|
||||||
|
mov [vesa_return], ax
|
||||||
|
|
||||||
|
pop ds
|
||||||
|
pop es
|
||||||
|
popa
|
||||||
|
pop bp
|
||||||
|
mov ax, [vesa_return]
|
||||||
|
ret
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user