diff --git a/SConstruct b/SConstruct index ed7b765..4d862dd 100644 --- a/SConstruct +++ b/SConstruct @@ -1,5 +1,6 @@ import sys import os +import shutil import multiprocessing import SCons.Util @@ -103,6 +104,21 @@ def GetNumCPUs(env): env.SetOption('num_jobs', GetNumCPUs(env)) +def CopyTree(dst, src, env): + def DirCopyHelper(src, dst): + for f in os.listdir(src): + srcPath = os.path.join(src, f) + dstPath = os.path.join(dst, f) + if os.path.isdir(srcPath): + if not os.path.exists(dstPath): + os.makedirs(dstPath) + DirCopyHelper(srcPath, dstPath) + else: + env.Command(dstPath, srcPath, Copy("$TARGET", "$SOURCE")) + if (not os.path.exists(dst)): + os.makedirs(dst) + DirCopyHelper(src, dst) + # XXX: Hack to support clang static analyzer def CheckFailed(): if os.getenv('CCC_ANALYZER_OUTPUT_FORMAT') != None: @@ -126,6 +142,11 @@ Export('env') # Debugging Tools +# Create include tree +CopyTree('build/include', 'include', env) +CopyTree('build/include/sys', 'sys/include', env) +CopyTree('build/include/machine', 'sys/' + env['ARCH'] + '/include', env) + # Build Targets SConscript('sys/SConscript', variant_dir='build/sys') diff --git a/sys/SConscript b/sys/SConscript index 48409b7..59e6d30 100644 --- a/sys/SConscript +++ b/sys/SConscript @@ -51,7 +51,7 @@ kern_env.Append(CPPFLAGS = ['-ffreestanding', '-fno-builtin', '-nostdinc', '-mno-red-zone', '-mno-mmx', '-mno-sse', '-mcmodel=large']) # '-target', 'amd64-orion-eabi' -kern_env.Append(CPPPATH = ['#include', '#sys/include']) +kern_env.Append(CPPPATH = ['#build/include']) kernel = kern_env.Program("castor", src) Depends(kernel, ldscript) diff --git a/sys/amd64/critical.c b/sys/amd64/critical.c index 5f757ad..2cf1f30 100644 --- a/sys/amd64/critical.c +++ b/sys/amd64/critical.c @@ -1,13 +1,13 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include -#include "amd64.h" -#include "amd64op.h" +#include +#include uint32_t lockLevel[MAX_CPUS]; diff --git a/sys/amd64/debug.c b/sys/amd64/debug.c index 645fc74..034ff16 100644 --- a/sys/amd64/debug.c +++ b/sys/amd64/debug.c @@ -2,14 +2,14 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include -#include "amd64.h" -#include "amd64op.h" -#include "trap.h" +#include +#include +#include TrapFrame *frames[MAX_CPUS]; diff --git a/sys/amd64/disasm.c b/sys/amd64/disasm.c index a7a98c2..b79482b 100644 --- a/sys/amd64/disasm.c +++ b/sys/amd64/disasm.c @@ -32,8 +32,8 @@ #include #include -#include -#include +#include +#include /* * Missing from headers diff --git a/sys/amd64/amd64.h b/sys/amd64/include/amd64.h similarity index 100% rename from sys/amd64/amd64.h rename to sys/amd64/include/amd64.h diff --git a/sys/amd64/amd64op.h b/sys/amd64/include/amd64op.h similarity index 100% rename from sys/amd64/amd64op.h rename to sys/amd64/include/amd64op.h diff --git a/sys/amd64/asm.h b/sys/amd64/include/asm.h similarity index 100% rename from sys/amd64/asm.h rename to sys/amd64/include/asm.h diff --git a/sys/amd64/atomic.h b/sys/amd64/include/atomic.h similarity index 100% rename from sys/amd64/atomic.h rename to sys/amd64/include/atomic.h diff --git a/sys/amd64/ioapic.h b/sys/amd64/include/ioapic.h similarity index 100% rename from sys/amd64/ioapic.h rename to sys/amd64/include/ioapic.h diff --git a/sys/amd64/lapic.h b/sys/amd64/include/lapic.h similarity index 100% rename from sys/amd64/lapic.h rename to sys/amd64/include/lapic.h diff --git a/sys/amd64/mp.h b/sys/amd64/include/mp.h similarity index 100% rename from sys/amd64/mp.h rename to sys/amd64/include/mp.h diff --git a/sys/amd64/multiboot.h b/sys/amd64/include/multiboot.h similarity index 100% rename from sys/amd64/multiboot.h rename to sys/amd64/include/multiboot.h diff --git a/sys/amd64/pmap.h b/sys/amd64/include/pmap.h similarity index 100% rename from sys/amd64/pmap.h rename to sys/amd64/include/pmap.h diff --git a/sys/amd64/trap.h b/sys/amd64/include/trap.h similarity index 100% rename from sys/amd64/trap.h rename to sys/amd64/include/trap.h diff --git a/sys/amd64/ioapic.c b/sys/amd64/ioapic.c index 29617cb..62873a3 100644 --- a/sys/amd64/ioapic.c +++ b/sys/amd64/ioapic.c @@ -4,13 +4,13 @@ #include #include -#include -#include +#include +#include -#include "amd64.h" -#include "pmap.h" -#include "trap.h" +#include +#include +#include #define IOAPICBASE 0xFEC00000 diff --git a/sys/amd64/irq.c b/sys/amd64/irq.c index 7d0f89e..5ac8f1a 100644 --- a/sys/amd64/irq.c +++ b/sys/amd64/irq.c @@ -1,11 +1,11 @@ #include -#include +#include +#include -#include "trap.h" -#include "ioapic.h" -#include +#include +#include LIST_HEAD(IRQHandlerList, IRQHandler); struct IRQHandlerList handlers[T_IRQ_LEN]; diff --git a/sys/amd64/lapic.c b/sys/amd64/lapic.c index 9bcee7b..997f436 100644 --- a/sys/amd64/lapic.c +++ b/sys/amd64/lapic.c @@ -5,13 +5,13 @@ #include #include -#include -#include +#include +#include -#include "amd64.h" -#include "amd64op.h" -#include "pmap.h" -#include "trap.h" +#include +#include +#include +#include #define CPUID_FLAG_APIC 0x100 diff --git a/sys/amd64/machine.c b/sys/amd64/machine.c index 1224378..5d1ff07 100644 --- a/sys/amd64/machine.c +++ b/sys/amd64/machine.c @@ -1,18 +1,18 @@ #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -#include "amd64.h" -#include "ioapic.h" -#include "lapic.h" -#include "trap.h" -#include "pmap.h" +#include +#include +#include +#include +#include #include "../dev/console.h" diff --git a/sys/amd64/mbentry.c b/sys/amd64/mbentry.c index 3998a6f..5cc008f 100644 --- a/sys/amd64/mbentry.c +++ b/sys/amd64/mbentry.c @@ -5,14 +5,14 @@ #include #include -#include -#include +#include +#include #include "../dev/console.h" -#include "amd64.h" -#include "pmap.h" -#include "multiboot.h" +#include +#include +#include void MachineBoot_Entry(unsigned long magic, unsigned long addr); diff --git a/sys/amd64/pci.c b/sys/amd64/pci.c index b6ac32c..f6b1ff9 100644 --- a/sys/amd64/pci.c +++ b/sys/amd64/pci.c @@ -1,11 +1,11 @@ #include -#include -#include +#include +#include -#include "amd64.h" -#include "amd64op.h" +#include +#include #define PCI_PORT_ADDR 0xCF8 #define PCI_PORT_DATABASE 0xCFC diff --git a/sys/amd64/pmap.c b/sys/amd64/pmap.c index 4d8cd13..5479284 100644 --- a/sys/amd64/pmap.c +++ b/sys/amd64/pmap.c @@ -2,15 +2,15 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include -#include "amd64.h" -#include "amd64op.h" -#include "mp.h" -#include "pmap.h" +#include +#include +#include +#include typedef struct AS { diff --git a/sys/amd64/trap.c b/sys/amd64/trap.c index 22d96b8..d4898f1 100644 --- a/sys/amd64/trap.c +++ b/sys/amd64/trap.c @@ -2,15 +2,15 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include "amd64.h" -#include "lapic.h" -#include "trap.h" +#include +#include +#include extern uint64_t trap_table[T_MAX]; extern void trap_pop(TrapFrame *tf); diff --git a/sys/amd64/xmem.c b/sys/amd64/xmem.c index 542e7ba..1241099 100644 --- a/sys/amd64/xmem.c +++ b/sys/amd64/xmem.c @@ -2,14 +2,14 @@ #include #include -#include -#include -#include +#include +#include +#include -#include "amd64.h" -#include "amd64op.h" -#include "pmap.h" -#include "mp.h" +#include +#include +#include +#include #define MAX_XMEM_REGIONS 1024 diff --git a/sys/dev/ahci.c b/sys/dev/ahci.c index aa851b0..b1a29db 100644 --- a/sys/dev/ahci.c +++ b/sys/dev/ahci.c @@ -3,10 +3,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include "ata.h" #include "sata.h" diff --git a/sys/dev/console.c b/sys/dev/console.c index 92edc47..0c6b371 100644 --- a/sys/dev/console.c +++ b/sys/dev/console.c @@ -1,7 +1,7 @@ #include -#include +#include #include "console.h" #include "x86/vgacons.h" diff --git a/sys/dev/pci.c b/sys/dev/pci.c index ee5a314..024ad4a 100644 --- a/sys/dev/pci.c +++ b/sys/dev/pci.c @@ -2,9 +2,9 @@ #include #include -#include -#include -#include +#include +#include +#include void PCI_ScanBus(); diff --git a/sys/dev/x86/debugcons.c b/sys/dev/x86/debugcons.c index 40a4847..45cf030 100644 --- a/sys/dev/x86/debugcons.c +++ b/sys/dev/x86/debugcons.c @@ -5,10 +5,10 @@ #include -#include +#include -#include "../../amd64/amd64.h" -#include "../../amd64/amd64op.h" +#include +#include void DebugConsole_Init() { diff --git a/sys/dev/x86/ide.c b/sys/dev/x86/ide.c index 0907da7..c398a11 100644 --- a/sys/dev/x86/ide.c +++ b/sys/dev/x86/ide.c @@ -3,8 +3,8 @@ #include #include -#include -#include +#include +#include #include "ioport.h" #include "../ata.h" diff --git a/sys/dev/x86/sercons.c b/sys/dev/x86/sercons.c index b6bf95d..e2745df 100644 --- a/sys/dev/x86/sercons.c +++ b/sys/dev/x86/sercons.c @@ -1,8 +1,8 @@ #include -#include -#include +#include +#include #include "ioport.h" #include "sercons.h" diff --git a/sys/dev/x86/vgacons.c b/sys/dev/x86/vgacons.c index f9e37dd..8957a46 100644 --- a/sys/dev/x86/vgacons.c +++ b/sys/dev/x86/vgacons.c @@ -5,11 +5,11 @@ #include #include -#include -#include +#include +#include -#include "../../amd64/amd64.h" -#include "../../amd64/pmap.h" +#include +#include #include "vgacons.h" diff --git a/sys/fs/o2fs/o2fs.h b/sys/fs/o2fs/o2fs.h new file mode 100644 index 0000000..de56455 --- /dev/null +++ b/sys/fs/o2fs/o2fs.h @@ -0,0 +1,36 @@ + +/* + * *** Disk Layout *** + * + * +---------------------+ + * | Super Blocks (4MBs) | + * +---------------------+ + * | | + * . + * . + * . + * | | + * +---------------------+ + * | Super Blocks (4MBs) | + * +---------------------+ + * + */ + +typedef struct ObjID { + uint8_t hash[32]; + uint64_t device; + uint64_t offset; +} ObjID; + +typedef struct SuperBlock +{ + uint8_t magic[8]; + uint16_t versionMajor; + uint16_t versionMinor; + uint32_t _rsvd0; + uint64_t features; + + ObjID root; /* Root Tree */ + + uint8_t hash[32]; +} SuperBlock; diff --git a/sys/include/irq.h b/sys/include/irq.h index d94cfcf..ac24f66 100644 --- a/sys/include/irq.h +++ b/sys/include/irq.h @@ -2,7 +2,7 @@ #ifndef __IRQ_H__ #define __IRQ_H__ -#include +#include typedef struct IRQHandler { int irq; diff --git a/sys/include/kassert.h b/sys/include/kassert.h index f00b0ca..661c735 100644 --- a/sys/include/kassert.h +++ b/sys/include/kassert.h @@ -2,7 +2,7 @@ #ifndef __KASSERT_H__ #define __KASSERT_H__ -#include +#include #define ASSERT(x) if (!(x)) { Panic("ASSERT:"); } #define NOT_IMPLEMENTED() Panic("NOT_IMPLEMENTED:") diff --git a/sys/include/queue.h b/sys/include/queue.h index 6ce9f88..55bd494 100644 --- a/sys/include/queue.h +++ b/sys/include/queue.h @@ -33,7 +33,7 @@ #ifndef _SYS_QUEUE_H_ #define _SYS_QUEUE_H_ -#include +#include /* * This file defines four types of data structures: singly-linked lists, diff --git a/sys/kern/debug.c b/sys/kern/debug.c index cddb4ae..3bb3384 100644 --- a/sys/kern/debug.c +++ b/sys/kern/debug.c @@ -18,8 +18,8 @@ #include #include -#include -#include +#include +#include #include "../dev/console.h" diff --git a/sys/kern/palloc.c b/sys/kern/palloc.c index e03540a..8e53169 100644 --- a/sys/kern/palloc.c +++ b/sys/kern/palloc.c @@ -7,14 +7,15 @@ #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -#include "../amd64/amd64.h" +// PGSIZE +#include /* 'FREEPAGE' */ #define FREEPAGE_MAGIC_FREE 0x4652454550414745ULL diff --git a/sys/kern/printf.c b/sys/kern/printf.c index 0e79626..9de0317 100644 --- a/sys/kern/printf.c +++ b/sys/kern/printf.c @@ -8,7 +8,7 @@ #include #include -#include +#include #include "../dev/console.h" diff --git a/sys/kern/spinlock.c b/sys/kern/spinlock.c index fa75f82..0ac3b04 100644 --- a/sys/kern/spinlock.c +++ b/sys/kern/spinlock.c @@ -2,14 +2,12 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include -#include "../amd64/amd64.h" -#include "../amd64/amd64op.h" -#include "../amd64/atomic.h" +#include void Spinlock_Init(Spinlock *lock, const char *name)