diff --git a/src/sys/Makefile b/src/sys/Makefile index d6a114e..8d494d6 100755 --- a/src/sys/Makefile +++ b/src/sys/Makefile @@ -1,10 +1,13 @@ # $Id$ # Kernel Makefile (C) 2002 The UbixOS Project -all: boot-strap +all: boot-code init-code -boot-strap: boot +boot-code: boot (cd boot;make) +init-code: init + (cd init;make) + clean: - (cd boot;make clean) \ No newline at end of file + (cd boot;make clean) diff --git a/src/sys/boot/boot.s b/src/sys/boot/boot.s index 2fc5589..e69de29 100755 --- a/src/sys/boot/boot.s +++ b/src/sys/boot/boot.s @@ -1,24 +0,0 @@ -entry start -start: - xor %ax,%ax - mov bootMsg,%si - call print - nop - -print: - lodsb - or %al,%al - jz .DONE - mov $0x0E,%ah - mov $0x00,%bh - mov $0x07,%bl - int $0x10 - jmp print - .DONE: - ret - - -.ORG 508 -bootMsg: - .byte 13,10 - .ascii "Booting UbixOS" \ No newline at end of file diff --git a/src/sys/include/ubixos/gdt.h b/src/sys/include/ubixos/gdt.h new file mode 100755 index 0000000..5cb38e8 --- /dev/null +++ b/src/sys/include/ubixos/gdt.h @@ -0,0 +1,63 @@ +/************************************************************************************** + Copyright (c) 2002 + The UbixOS Project + + $Id$ +**************************************************************************************/ + +/* Descriptor Definitions */ +#define dCall 0x0C00 /* 386 Call Gate */ +#define dCode 0x1800 /* Code Segment */ +#define dData 0x1000 /* Data Segment */ +#define dInt 0x0E00 /* 386 Interrupt Gate */ +#define dLdt 0x200 /* Local Descriptor Table (LDT) */ +#define dTask 0x500 /* Task gate */ +#define dTrap 0x0F00 /* 386 Trap Gate */ +#define dTss 0x900 /* Task State Segment (TSS) */ + +/* Descriptor Options */ +#define dDpl3 0x6000 /* DPL3 or mask for DPL */ +#define dDpl2 0x4000 /* DPL2 or mask for DPL */ +#define dDpl1 0x2000 /* DPL1 or mask for DPL */ +#define dPresent 0x8000 /* Present */ +#define dNpresent 0x8000 /* Not Present */ +#define dAcc 0x100 /* Accessed (Data or Code) */ +#define dWrite 0x200 /* Writable (Data segments only) */ +#define dRead 0x200 /* Readable (Code segments only) */ +#define dBusy 0xB00 /* Busy (TSS only) was 200 */ +#define dEexdown 0x400 /* Expand down (Data segments only) */ +#define dConform 0x400 /* Conforming (Code segments only) */ +#define dBig 0x40 /* Default to 32 bit mode */ +#define dBiglim 0x80 /* Limit is in 4K units */ + +/* GDT Descriptor */ +struct gdtDescriptor { + unsigned short limitLow; /* Limit 0..15 */ + unsigned short baseLow; /* Base 0..15 */ + unsigned char baseMed; /* Base 16..23 */ + unsigned char access; /* Access Byte */ + unsigned int limitHigh:4; /* Limit 16..19 */ + unsigned int granularity:4; /* Granularity */ + unsigned char baseHigh; /* Base 24..31 */ + } __attribute__ ((packed)); + +struct gdtGate { + unsigned short offsetLow; /* Offset 0..15 */ + unsigned short selector; /* Selector */ + unsigned short access; /* Access Flags */ + unsigned short offsetHigh; /* Offset 16..31 */ + } __attribute__ ((packed)); + +union descriptorTableunion { + struct gdtDescriptor descriptor; /* Normal descriptor */ + struct gdtGate gate; /* Gate descriptor */ + unsigned long dummy; /* Any other info */ + }; + + +#define descriptorTable(name,length) union descriptorTableunion name[length] = +#define standardDescriptor(base, limit, control) {descriptor: {(limit & 0xffff), (base & 0xffff), ((base >> 16) & 0xff), \ + ((control+dPresent) >> 8), (limit >> 16), \ + ((control & 0xff) >> 4), (base >> 24)}} +#define gateDescriptor(offset, selector, control) {gate: {(offset & 0xffff), selector, \ + (control+dPresent), (offset >> 16) }} \ No newline at end of file diff --git a/src/sys/include/ubixos/scheduler.h b/src/sys/include/ubixos/scheduler.h new file mode 100755 index 0000000..3e19806 --- /dev/null +++ b/src/sys/include/ubixos/scheduler.h @@ -0,0 +1,44 @@ +/************************************************************************************** + Copyright (c) 2002 + The UbixOS Project + + $Id$ +**************************************************************************************/ + +/* Task State Segment Structure */ +struct tssStruct { + short backLink; + short backLink_reserved; + long esp0; + short ss0; + short ss0_reserved; + long esp1; + short ss1; + short ss1_reserved; + long esp2; + short ss2; + short ss2_reserved; + long cr3; + long eip; + long eflags; + long eax,ecx,edx,ebx; + long esp; + long ebp; + long esi; + long edi; + short es; + short es_reserved; + short cs; + short cs_reserved; + short ss; + short ss_reserved; + short ds; + short ds_reserved; + short fs; + short fs_reserved; + short gs; + short gs_reserved; + short ldt; + short ldt_reserved; + long traceBitmap; /* bits: trace 0, bitmap 16_31 */ + }; \ No newline at end of file diff --git a/src/sys/init/Makefile b/src/sys/init/Makefile new file mode 100755 index 0000000..e4f8f3e --- /dev/null +++ b/src/sys/init/Makefile @@ -0,0 +1,35 @@ +# (C) 2002 The UbixOS Project +# $Id$ + + +# Compiler +CC = gcc +CPP = g++ + + +# Linker +LINKER = ld + +# Remove +REMOVE = rm -fr + +# Objects +OBJS = main.o + +all: $(OBJS) + +# Compile Types +.cc.o: + $(CPP) -Wall -fomit-frame-pointer -O -I../include -c -o $@ $< +.cc.s: + $(CPP) -Wall -fomit-frame-pointer -O -I../include -S -o $@ $< +.c.o: + $(CC) -Wall -fomit-frame-pointer -O -I../include -c -o $@ $< +.c.s: + $(CC) -Wall -fomit-frame-pointer -O -I../include -S -o $@ $< +.S.o: + $(CC) -Wall -fomit-frame-pointer -c -o $@ $< + +# Clean up the junk +clean: + $(REMOVE) $(OBJS) diff --git a/src/sys/init/main.c b/src/sys/init/main.c new file mode 100755 index 0000000..f022292 --- /dev/null +++ b/src/sys/init/main.c @@ -0,0 +1,23 @@ +/************************************************************************************** + Copyright (c) 2002 + The UbixOS Project + + $Id$ +**************************************************************************************/ + +#include +#include + +descriptorTable(gdt,4) { + {dummy:0}, + standardDescriptor(0, 0xFFFFF, (dCode + dRead + dBig + dBiglim)), + standardDescriptor(0, 0xFFFFF, (dData + dWrite + dBig + dBiglim)), + standardDescriptor(1000, (sizeof(struct tssStruct)-1), (dTss)), + }; + +void _start() { + asm( + "lgdt (loadGdt) \n" + ); + while (1); + } \ No newline at end of file diff --git a/ubixos.kdevprj b/ubixos.kdevprj index adaeb7b..2275855 100755 --- a/ubixos.kdevprj +++ b/ubixos.kdevprj @@ -18,21 +18,27 @@ [Config for BinMakefileAm] addcxxflags= bin_program=ubixos -cxxflags= +cxxflags=\s-O1 ldadd= ldflags= +libtool_dir= +path_to_bin_program=. [General] AMChanged=false -author=reddawg -email=reddawg@Laptop.DomainAtlantic.Net +author=Christopher Olsen +dir_where_make_will_be_called=./ +email=Chris@DomainAtlantic.com kdevprj_version=1.3 lfv_open_groups=Others -makefiles=./Makefile.am,src/Makefile.am,src/sys/Makefile.am,src/sys/include/Makefile.am,src/lib/Makefile.am,src/lib/libc/Makefile.am,src/lib/libc/include/Makefile.am,src/bin/Makefile.am,src/bin/shell/Makefile.am,Makefile.am,src/sys/boot/Makefile.am -project_name=ubixos +make_options=\s-j1 clean all +makefiles=./Makefile.am,src/Makefile.am,src/sys/Makefile.am,src/sys/include/Makefile.am,src/lib/Makefile.am,src/lib/libc/Makefile.am,src/lib/libc/include/Makefile.am,src/bin/Makefile.am,src/bin/shell/Makefile.am,Makefile.am,src/sys/boot/Makefile.am,src/sys/init/Makefile.am,src/sys/include/ubixos/Makefile.am +modifyMakefiles=true +project_name=UbixOS project_type=normal_empty +short_info= sub_dir= -version= +version=0.01 version_control=CVS workspace=1 @@ -95,7 +101,7 @@ [src/sys/Makefile.am] files=src/sys/Makefile -sub_dirs=include,boot +sub_dirs=include,boot,init type=normal [src/sys/boot/Makefile] @@ -105,7 +111,7 @@ type=DATA [src/sys/boot/Makefile.am] -files=src/sys/boot/boot.s,src/sys/boot/Makefile +files=src/sys/boot/Makefile,src/sys/boot/boot.s sub_dirs= type=normal @@ -116,5 +122,41 @@ type=SOURCE [src/sys/include/Makefile.am] +sub_dirs=ubixos +type=normal + +[src/sys/include/ubixos/Makefile.am] +files=src/sys/include/ubixos/gdt.h,src/sys/include/ubixos/scheduler.h sub_dirs= type=normal + +[src/sys/include/ubixos/gdt.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/include/ubixos/scheduler.h] +dist=true +install=false +install_location= +type=HEADER + +[src/sys/init/Makefile] +dist=true +install=false +install_location= +type=DATA + +[src/sys/init/Makefile.am] +files=src/sys/init/main.c,src/sys/init/Makefile +sharedlib_LDFLAGS=-version-info 0:0:1 +sharedlib_rootname=init +sub_dirs= +type=static_library + +[src/sys/init/main.c] +dist=true +install=false +install_location= +type=SOURCE