Import backup from 2005-06-20
This commit is contained in:
parent
4689c11cc8
commit
da90bcc164
29
Makefile
29
Makefile
@ -16,7 +16,7 @@ UMOUNT=sudo umount
|
||||
# Do not print "Entering directory ..."
|
||||
MAKEFLAGS += --no-print-directory
|
||||
|
||||
.PHONY: all clean initrd apps grub_image install install_img
|
||||
.PHONY: all clean initrd apps grub_image install install_img depend copy_image
|
||||
|
||||
all:
|
||||
make -C kernel
|
||||
@ -47,22 +47,16 @@ grub_image:
|
||||
rm grub_commands.tmp
|
||||
rm grub_image_device.map.tmp
|
||||
|
||||
install:
|
||||
gzip -c $(INITRD) > $(INITRD).gz
|
||||
-mkdir $(FLOPPY_MOUNT)
|
||||
$(MOUNT) -t ext2 $(DEVICE) $(FLOPPY_MOUNT)
|
||||
-cp kernel/kernel.bin $(FLOPPY_MOUNT)
|
||||
-cp rmmod/rmmod.bin $(FLOPPY_MOUNT)
|
||||
-cp menu.lst $(FLOPPY_MOUNT)/boot/grub
|
||||
-cp $(INITRD).gz $(FLOPPY_MOUNT)/$(INITRD).gz
|
||||
$(UMOUNT) $(FLOPPY_MOUNT)
|
||||
-rmdir $(FLOPPY_MOUNT)
|
||||
|
||||
install_img:
|
||||
gzip -c $(INITRD) > $(INITRD).gz
|
||||
-mkdir $(FLOPPY_MOUNT)
|
||||
copy_image:
|
||||
cp $(GRUB_IMAGE) $(FLOPPY_IMAGE)
|
||||
$(MOUNT) -t ext2 -o loop $(FLOPPY_IMAGE) $(FLOPPY_MOUNT)
|
||||
|
||||
install: FDEV=$(FLOPPY)
|
||||
install_img: FDEV=$(FLOPPY_IMAGE)
|
||||
install_img: MOUNT_FLAGS=-o loop
|
||||
install_img: copy_image
|
||||
install install_img:
|
||||
-mkdir $(FLOPPY_MOUNT)
|
||||
$(MOUNT) -t ext2 $(MOUNT_FLAGS) $(FDEV) $(FLOPPY_MOUNT)
|
||||
-cp kernel/kernel.bin $(FLOPPY_MOUNT)
|
||||
-cp rmmod/rmmod.bin $(FLOPPY_MOUNT)
|
||||
-cp menu.lst $(FLOPPY_MOUNT)/boot/grub
|
||||
@ -78,7 +72,10 @@ initrd:
|
||||
cp -Pr $(INITRD_DIR)/* $(INITRD_MOUNT)
|
||||
$(UMOUNT) $(INITRD_MOUNT)
|
||||
rm -rf $(INITRD_MOUNT)
|
||||
gzip -c $(INITRD) > $(INITRD).gz
|
||||
|
||||
depend:
|
||||
make -C kernel depend
|
||||
|
||||
wordcount:
|
||||
find . -regex '\(.*\.[ch]\)\|\(.*\.asm\)\|\(.*\.inc\)\|\(.*\.cpp\)' | xargs cat | wc
|
||||
|
2
build.txt
Normal file
2
build.txt
Normal file
@ -0,0 +1,2 @@
|
||||
To build the HOS kernel, just run 'make'
|
||||
To build a HOS floppy image for bochs, run 'make initrd' and 'make install_img' as root (root permissions needed to mount floppy image)
|
@ -70,8 +70,9 @@ char/keyboard.o: lang/conv.h display/kout.h display/display.h devices.h
|
||||
lang/lang.o: lang/lang.h hos_defines.h
|
||||
lang/string.o: lang/string.h lang/lang.h hos_defines.h
|
||||
lang/new.o: hos_defines.h mm/vmm.h multiboot.h
|
||||
fs/vfs.o: hos_defines.h display/kout.h fs/vfs.h lang/vector.h lang/string.h
|
||||
fs/vfs.o: devices.h
|
||||
fs/vfs.o: hos_defines.h display/kout.h fs/vfs.h fs/ext2.h lang/vector.h
|
||||
fs/vfs.o: lang/string.h devices.h
|
||||
fs/ext2.o: fs/ext2.h fs/vfs.h
|
||||
char/misc_char.o: hos_defines.h devices.h char/misc_char.h sys/io.h
|
||||
block/ramdisk.o: functions.h hos_defines.h sys/io.h mm/vmm.h multiboot.h
|
||||
block/ramdisk.o: lang/lang.h block/ramdisk.h devices.h
|
||||
|
83
kernel/Makefile.bak
Normal file
83
kernel/Makefile.bak
Normal file
@ -0,0 +1,83 @@
|
||||
# Makefile for HOS
|
||||
# Josh Holtrop
|
||||
# Created: 07/08/04
|
||||
# Modified: 06/13/05
|
||||
|
||||
# Assembler Information:
|
||||
NASM=nasm
|
||||
NASM_FLAGS=-f aout
|
||||
|
||||
# C/C++ Information:
|
||||
CPPFLAGS=-fleading-underscore -fno-builtin -nostdlib -nostartfiles -nodefaultlibs -I. -Wall
|
||||
CC=gcc
|
||||
CXX=g++
|
||||
CXXFLAGS=-fno-rtti -fno-exceptions
|
||||
|
||||
# Linker Information:
|
||||
LD=ld
|
||||
LDFLAGS=-nodefaultlibs -nostdlib --no-demangle -T link.ld
|
||||
|
||||
# Files
|
||||
OBJS=boot.o kernel.o lang/lang_a.o mm/mm.o mm/vmm.o lang/conv.o \
|
||||
display/kout.o char/vconsole.o display/display.o devices.o \
|
||||
sys/pic.o char/keyboard.o block/ramdisk.o fs/vfs.o \
|
||||
lang/lang.o lang/string.o lang/new.o fs/ext2.o char/misc_char.o
|
||||
CSRC=kernel.c mm/mm.c mm/vmm.c lang/conv.c display/kout.c display/display.c sys/pic.c char/keyboard.c lang/lang.c
|
||||
CXXSRC=lang/string.cpp lang/new.cpp fs/vfs.cpp fs/ext2.cpp char/misc_char.cpp block/ramdisk.cpp char/vconsole.cpp devices.cpp
|
||||
|
||||
.PHONY: all depend clean html
|
||||
|
||||
all: $(OBJS)
|
||||
$(LD) $(LDFLAGS) -Map kernel.map $(OBJS) -o kernel.bin
|
||||
@echo ' Kernel built: ' `ls -sk kernel.bin | cut -d' ' -f1`kb
|
||||
|
||||
depend:
|
||||
makedepend -- $(CPPFLAGS) -- $(CSRC) $(CXXSRC)
|
||||
|
||||
boot.o: boot.asm
|
||||
$(NASM) $(NASM_FLAGS) -l boot.lst boot.asm -o boot.o
|
||||
|
||||
lang/lang_a.o: lang/lang.asm
|
||||
$(NASM) $(NASM_FLAGS) -l lang.lst lang/lang.asm -o lang/lang_a.o
|
||||
|
||||
clean:
|
||||
-rm -f $(OBJS) *.bin *.map *.lst *.out *~ fs/*~ sys/*~ block/*~ char/*~ lang/*~ mm/*~ display/*~
|
||||
|
||||
html:
|
||||
-rm -rf html
|
||||
-mkdir html
|
||||
source-highlight --output-dir=html -f xhtml -n $(CSRC) $(CXXSRC)
|
||||
|
||||
# The following is used by 'make' to automatically
|
||||
# generate dependency information
|
||||
# DO NOT DELETE
|
||||
|
||||
kernel.o: kernel.h hos_defines.h multiboot.h module.h lang/lang.h functions.h
|
||||
kernel.o: sys/io.h mm/mm.h mm/vmm.h lang/conv.h devices.h display/display.h
|
||||
kernel.o: display/kout.h sys/pic.h char/keyboard.h block/ramdisk.h fs/vfs.h
|
||||
kernel.o: fs/ext2.h fs/vfs.h
|
||||
mm/mm.o: kernel.h hos_defines.h multiboot.h mm/mm.h
|
||||
mm/vmm.o: hos_defines.h kernel.h multiboot.h mm/vmm.h lang/lang.h mm/mm.h
|
||||
lang/conv.o: lang/conv.h hos_defines.h
|
||||
display/kout.o: hos_defines.h display/kout.h lang/conv.h devices.h
|
||||
display/kout.o: char/misc_char.h char/misc_char.h
|
||||
display/display.o: devices.h hos_defines.h char/vconsole.h display/display.h
|
||||
display/display.o: lang/lang.h kernel.h multiboot.h display/vesafb.h
|
||||
display/display.o: char/keyboard.h display/kout.h
|
||||
sys/pic.o: hos_defines.h sys/pic.h sys/io.h
|
||||
char/keyboard.o: hos_defines.h char/keyboard.h sys/io.h functions.h
|
||||
char/keyboard.o: lang/conv.h display/kout.h display/display.h devices.h
|
||||
lang/lang.o: lang/lang.h hos_defines.h
|
||||
lang/string.o: lang/string.h lang/lang.h hos_defines.h
|
||||
lang/new.o: hos_defines.h mm/vmm.h multiboot.h
|
||||
fs/vfs.o: hos_defines.h display/kout.h fs/vfs.h fs/ext2.h lang/vector.h
|
||||
fs/vfs.o: lang/string.h devices.h
|
||||
fs/ext2.o: fs/ext2.h fs/vfs.h
|
||||
char/misc_char.o: hos_defines.h devices.h char/misc_char.h sys/io.h
|
||||
block/ramdisk.o: functions.h hos_defines.h sys/io.h mm/vmm.h multiboot.h
|
||||
block/ramdisk.o: lang/lang.h block/ramdisk.h devices.h
|
||||
char/vconsole.o: hos_defines.h mm/vmm.h multiboot.h lang/lang.h
|
||||
char/vconsole.o: display/display.h devices.h functions.h sys/io.h
|
||||
char/vconsole.o: char/vconsole.h
|
||||
devices.o: hos_defines.h devices.h char/misc_char.h char/misc_char.h
|
||||
devices.o: char/vconsole.h block/ramdisk.h
|
@ -22,6 +22,7 @@
|
||||
|
||||
#define DEV_MAJOR(x) (((x) >> 8) & 0xFF)
|
||||
#define DEV_MINOR(x) ((x) & 0xFF)
|
||||
#define DEV(x,y) ((x) << 8 | (y))
|
||||
|
||||
typedef short major_t;
|
||||
typedef short minor_t;
|
||||
|
@ -4,3 +4,34 @@
|
||||
// Date: 05/10/05
|
||||
// Modified: 05/10/05
|
||||
|
||||
#define _HOS_CPP_ _HOS_CPP_
|
||||
|
||||
extern "C" {
|
||||
#include "display/kout.h"
|
||||
}
|
||||
|
||||
#include "ext2.h"
|
||||
|
||||
Ext2fs::Ext2fs(device_t dev)
|
||||
{
|
||||
myDevice = dev;
|
||||
if (block_read(DEV_MAJOR(dev), DEV_MINOR(dev), 2, 2, &mySuper) < 1024)
|
||||
{
|
||||
myError = -1;
|
||||
return;
|
||||
}
|
||||
if (mySuper.s_magic != EXT2_MAGIC)
|
||||
{
|
||||
myError = -2;
|
||||
return;
|
||||
}
|
||||
myError = 0;
|
||||
mySuperDirty = 0;
|
||||
kprintf("Device: %d\n", myDevice);
|
||||
}
|
||||
|
||||
Ext2fs::~Ext2fs()
|
||||
{
|
||||
if (mySuperDirty)
|
||||
block_write(DEV_MAJOR(myDevice), DEV_MINOR(myDevice), 2, 2, &mySuper);
|
||||
}
|
||||
|
@ -138,15 +138,16 @@ typedef struct
|
||||
char name[EXT2_NAME_LEN];
|
||||
} ext2_dir_entry_t;
|
||||
|
||||
|
||||
#ifdef _HOS_CPP_
|
||||
|
||||
class Ext2 : public FileSystem
|
||||
class Ext2fs : public FileSystem
|
||||
{
|
||||
protected:
|
||||
|
||||
ext2_super_block_t mySuper;
|
||||
int mySuperDirty;
|
||||
public:
|
||||
|
||||
Ext2fs(device_t dev);
|
||||
~Ext2fs();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -12,6 +12,7 @@ extern "C" {
|
||||
}
|
||||
|
||||
#include "vfs.h"
|
||||
#include "ext2.h"
|
||||
#include "lang/vector.h"
|
||||
#include "lang/string.h"
|
||||
#include "devices.h"
|
||||
@ -29,10 +30,43 @@ int vfs_mount(device_t device, int fsType, char *mountPoint)
|
||||
{
|
||||
string mountPt(mountPoint);
|
||||
if (mountPt == "/")
|
||||
{
|
||||
if (mountPoints->size())
|
||||
{
|
||||
kprintf("/ must be the first filesystem mounted!\n");
|
||||
return -1;
|
||||
}
|
||||
FileSystem *fs = vfs_attempt_mount(device, fsType);
|
||||
if (fs == NULL)
|
||||
return -2;
|
||||
rootInode = fs->getRootInodeNumber();
|
||||
mountPoints->add(VFSMount(device, fs, mountPt, 0));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
return 0;
|
||||
return 500;
|
||||
}
|
||||
|
||||
FileSystem *vfs_attempt_mount(device_t device, int fsType)
|
||||
{
|
||||
FileSystem *fs;
|
||||
switch (fsType)
|
||||
{
|
||||
case FS_EXT2:
|
||||
fs = new Ext2fs(device);
|
||||
break;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
if (fs->check())
|
||||
{
|
||||
delete fs;
|
||||
return NULL;
|
||||
}
|
||||
return fs;
|
||||
}
|
||||
|
||||
VFSMount::VFSMount(device_t dev, FileSystem *fs, string mountPoint, inode_num_t mountInode)
|
||||
@ -47,7 +81,21 @@ VFSMount::VFSMount(device_t dev, FileSystem *fs, string mountPoint, inode_num_t
|
||||
VFSMount::~VFSMount()
|
||||
{
|
||||
if (myFS)
|
||||
{
|
||||
delete myFS;
|
||||
if (myRefs)
|
||||
kprintf("Filesystem uncleanly mounted from %s\n", myMountPoint.data());
|
||||
}
|
||||
}
|
||||
|
||||
FileSystem::FileSystem() {myError = -10278;}
|
||||
FileSystem::~FileSystem() {}
|
||||
u32_t FileSystem::totalBlocks(){return 0;}
|
||||
u32_t FileSystem::usedBlocks(){return 0;};
|
||||
u32_t FileSystem::freeBlocks(){return 0;};
|
||||
u32_t FileSystem::totalInodes(){return 0;};
|
||||
u32_t FileSystem::usedInodes(){return 0;};
|
||||
u32_t FileSystem::freeInodes(){return 0;};
|
||||
u32_t FileSystem::getRootInodeNumber(){return 0;};
|
||||
int FileSystem::check(){return myError;};
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#define __HOS_VFS_H__ __HOS_VFS_H__
|
||||
|
||||
#define FS_EXT2 1
|
||||
#define FS_MAX 5
|
||||
|
||||
#define VFS_FT_UNKNOWN 0
|
||||
#define VFS_FT_FILE 1
|
||||
@ -52,7 +53,11 @@ int vfs_mount(device_t device, int fsType, char *mountPoint);
|
||||
|
||||
class FileSystem
|
||||
{
|
||||
protected:
|
||||
int myError;
|
||||
device_t myDevice;
|
||||
public:
|
||||
FileSystem();
|
||||
FileSystem(device_t dev);
|
||||
virtual ~FileSystem();
|
||||
|
||||
@ -65,6 +70,8 @@ public:
|
||||
virtual u32_t freeInodes();
|
||||
|
||||
virtual u32_t getRootInodeNumber();
|
||||
|
||||
virtual int check();
|
||||
};
|
||||
|
||||
class VFSMount
|
||||
@ -81,6 +88,8 @@ public:
|
||||
~VFSMount();
|
||||
};
|
||||
|
||||
FileSystem *vfs_attempt_mount(device_t device, int fsType);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "mm/mm.h"
|
||||
#include "mm/vmm.h"
|
||||
#include "lang/conv.h"
|
||||
//#include "char/vconsole.h"
|
||||
#include "devices.h"
|
||||
#include "display/display.h"
|
||||
#include "display/kout.h"
|
||||
@ -142,7 +141,7 @@ void k_init()
|
||||
// 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);
|
||||
kprintf("initrd (%dkb) loaded\n", (mb_modules[i].mod_end - mb_modules[i].mod_start) >> 10);
|
||||
k_check(vfs_mount((MAJOR_RAMDISK << 8) | initrd_minor, FS_EXT2, "/"), "Could not mount initrd to /!");
|
||||
k_check(vfs_mount(DEV(MAJOR_RAMDISK, initrd_minor), FS_EXT2, "/"), "Could not mount initrd to /!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@ SECTIONS
|
||||
.text 0xC0108000 : {
|
||||
code = .; _code = .; __code = .;
|
||||
*(.text)
|
||||
/* . = ALIGN(4096); */
|
||||
}
|
||||
.gnulinkonce : {
|
||||
*(.gnu.linkonce*)
|
||||
@ -14,13 +13,9 @@ SECTIONS
|
||||
.data : {
|
||||
data = .; _data = .; __data = .;
|
||||
*(.data)
|
||||
/* . = ALIGN(4096); */
|
||||
}
|
||||
.rodata : {
|
||||
rodata = .; _rodata = .; __rodata = .;
|
||||
*(.rodata)
|
||||
}
|
||||
. = ALIGN(4096);
|
||||
}
|
||||
.bss : {
|
||||
bss = .; _bss = .; __bss = .;
|
||||
*(.bss)
|
||||
|
Loading…
x
Reference in New Issue
Block a user