From 04b709f3b3ba317afdfe0bcd992edf3a08bd683a Mon Sep 17 00:00:00 2001 From: Ali Mashtizadeh Date: Wed, 31 Jul 2019 17:30:50 -0400 Subject: [PATCH] Cleanup: Disable LWIP and address compiler warnings --- SConstruct | 8 ++++---- lib/libc/crt1.c | 17 +++++++++++------ lib/libc/file.c | 5 +++++ release/bootdisk.manifest | 1 - sbin/init/init.c | 4 ++-- sbin/sysctl/sysctl.c | 3 +-- sys/amd64/pmap.c | 5 +---- sys/dev/e1000.c | 14 ++++++++------ sys/include/types.h | 4 ++-- tests/SConscript | 26 +++++++++++++------------- 10 files changed, 47 insertions(+), 40 deletions(-) diff --git a/SConstruct b/SConstruct index fff0278..3beeb04 100644 --- a/SConstruct +++ b/SConstruct @@ -21,7 +21,7 @@ opts.AddVariables( ("WITH_GPROF", "Include gprof profiling (0 or 1).", "0"), ("PREFIX", "Installation target directory.", "#pxelinux"), ("ARCH", "Target Architecture", "amd64"), - ("BOOTDISK", "Build boot disk (0 or 1)", "0"), + ("BOOTDISK", "Build boot disk (0 or 1)", "1"), ("BOOTDISK_SIZE", "Boot disk size", "128") ) @@ -165,12 +165,12 @@ env["CRTEND"] = [ "#build/lib/libc/crtn.o" ] CopyTree('build/include', 'include', env) CopyTree('build/include/sys', 'sys/include', env) CopyTree('build/include/machine', 'sys/' + env['ARCH'] + '/include', env) -CopyTree('build/include/', 'lib/liblwip/src/include', env) +#CopyTree('build/include/', 'lib/liblwip/src/include', env) # Build Targets SConscript('sys/SConscript', variant_dir='build/sys') SConscript('lib/libc/SConscript', variant_dir='build/lib/libc') -SConscript('lib/liblwip/SConscript', variant_dir='build/lib/liblwip') +#SConscript('lib/liblwip/SConscript', variant_dir='build/lib/liblwip') SConscript('bin/ethdump/SConscript', variant_dir='build/bin/ethdump') SConscript('bin/ethinject/SConscript', variant_dir='build/bin/ethinject') SConscript('bin/shell/SConscript', variant_dir='build/bin/shell') @@ -203,7 +203,7 @@ if env["BOOTDISK"] == "1": Depends(bootdisk, "#build/sbin/init/init") Depends(bootdisk, "#build/sbin/sysctl/sysctl") Depends(bootdisk, "#build/sys/castor") - Depends(bootdisk, "#build/tests/lwiptest") + #Depends(bootdisk, "#build/tests/lwiptest") Depends(bootdisk, "#build/tests/pthreadtest") Depends(bootdisk, "#build/tests/threadtest") env.Alias('bootdisk', '#build/bootdisk.img') diff --git a/lib/libc/crt1.c b/lib/libc/crt1.c index 5d78693..86fbc21 100644 --- a/lib/libc/crt1.c +++ b/lib/libc/crt1.c @@ -100,17 +100,22 @@ handle_argv(int argc, char *argv[], char **env) void _start(char **ap) { - int argc; - char **argv; - char **env; + int status; + int argc = 0; + char **argv = NULL; + char **env = NULL; //argc = *(long *)(void *)ap; //argv = ap + 1; //env = ap + 2 + argc; - //handle_argv(argc, argv, env); + handle_argv(argc, argv, env); - //handle_static_init(argc, argv, env); + handle_static_init(argc, argv, env); - exit(main(argc, argv)); + status = main(argc, argv); + + finalizer(); + + exit(status); } diff --git a/lib/libc/file.c b/lib/libc/file.c index 614fc20..e728cf4 100644 --- a/lib/libc/file.c +++ b/lib/libc/file.c @@ -4,6 +4,7 @@ #include #include +#include #include @@ -94,11 +95,15 @@ fclose(FILE *fh) int feof(FILE *fh) { + errno = ENOSYS; + return -1; } int fflush(FILE *fh) { + errno = ENOSYS; + return -1; } size_t diff --git a/release/bootdisk.manifest b/release/bootdisk.manifest index 9031d01..d81cfa6 100644 --- a/release/bootdisk.manifest +++ b/release/bootdisk.manifest @@ -15,7 +15,6 @@ DIR / FILE sysctl build/sbin/sysctl/sysctl END DIR tests - FILE lwiptest build/tests/lwiptest FILE pthreadtest build/tests/pthreadtest FILE threadtest build/tests/threadtest END diff --git a/sbin/init/init.c b/sbin/init/init.c index 59d21fa..8fa6cd4 100644 --- a/sbin/init/init.c +++ b/sbin/init/init.c @@ -10,12 +10,12 @@ main(int argc, const char *argv[]) status = OSSpawn("/bin/shell"); if (status > 100) { - printf("init: Could not spawn shell %016llx\n", status); + printf("init: Could not spawn shell %016lx\n", status); } while (1) { status = OSWait(0); - printf("init: Zombie process exited (%016llx)\n", status); + printf("init: Zombie process exited (%016lx)\n", status); } } diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c index 818d233..e647939 100644 --- a/sbin/sysctl/sysctl.c +++ b/sbin/sysctl/sysctl.c @@ -30,7 +30,6 @@ int main(int argc, const char *argv[]) { int i; - uint64_t status; printf("%d\n", argc); if (true) { @@ -59,7 +58,7 @@ main(int argc, const char *argv[]) break; case SYSCTL_TYPE_INT: OSSysCtl(SYSCTLTable[i].path, &scInt, NULL); - printf("%s: %lld\n", SYSCTLTable[i].path, scInt.value); + printf("%s: %ld\n", SYSCTLTable[i].path, scInt.value); break; case SYSCTL_TYPE_BOOL: OSSysCtl(SYSCTLTable[i].path, &scBool, NULL); diff --git a/sys/amd64/pmap.c b/sys/amd64/pmap.c index ee095a3..37dc38d 100644 --- a/sys/amd64/pmap.c +++ b/sys/amd64/pmap.c @@ -412,7 +412,7 @@ PMap_Dump(AS *space) continue; kprintf("Level 3: %016llx:%016llx\n", - AddrFromIJKL(i, j, k, l), + AddrFromIJKL(i, j, k, 0), (uint64_t)pte3); if ((pte3 & PTE_PS) == 0) { @@ -423,12 +423,9 @@ PMap_Dump(AS *space) AddrFromIJKL(i, j, k, l), (uint64_t)pte4); } - l = 0; } } - k = 0; } - j = 0; } return; diff --git a/sys/dev/e1000.c b/sys/dev/e1000.c index 2c348f5..61b1c8d 100644 --- a/sys/dev/e1000.c +++ b/sys/dev/e1000.c @@ -62,6 +62,11 @@ void E1000_Configure(PCIDevice dev); #define E1000_REG_MTABASE 0x5200 +// EEPROM Offsets +#define NVM_MAC_ADDR 0x0000 +#define NVM_DEVICE_ID 0x000D +#define NVM_VENDOR_ID 0x000E + // Control Flags #define CTRL_SLU (1 << 6) @@ -184,12 +189,6 @@ E1000_Init(uint32_t bus, uint32_t slot, uint32_t func) } } -static inline uint16_t -MMIO_Read16(E1000Dev *dev, uint64_t addr) -{ - return *(uint16_t volatile *)(dev->mmiobase + addr); -} - static inline uint32_t MMIO_Read32(E1000Dev *dev, uint64_t addr) { @@ -479,6 +478,9 @@ E1000_Configure(PCIDevice dev) IRQ_Register(dev.irq, ðDev->irqHandle); kprintf("E1000: MAC XX:XX:XX:XX:XX:XX\n"); + for (int i = 0; i < 3; i++) { + E1000_EEPROM_Read(ethDev, NVM_MAC_ADDR + 2*i); + } // Device lock Spinlock_Init(ðDev->lock, "E1000 Spinlock", SPINLOCK_TYPE_NORMAL); diff --git a/sys/include/types.h b/sys/include/types.h index bd3c7f4..7c2fca0 100644 --- a/sys/include/types.h +++ b/sys/include/types.h @@ -5,12 +5,12 @@ typedef signed char int8_t; typedef signed short int16_t; typedef signed int int32_t; -typedef signed long long int64_t; +typedef signed long int64_t; typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; -typedef unsigned long long uint64_t; +typedef unsigned long uint64_t; typedef int64_t intptr_t; typedef uint64_t uintptr_t; diff --git a/tests/SConscript b/tests/SConscript index 38fc73e..37a6b27 100644 --- a/tests/SConscript +++ b/tests/SConscript @@ -21,17 +21,17 @@ pthreadtest_src.append(["pthreadtest.c"]) pthreadtest_src.append(env["CRTEND"]) test_env.Program("pthreadtest", pthreadtest_src) -test_netenv = env.Clone() - -test_netenv.Append(LINKFLAGS = ['-nostdlib']) -test_netenv.Append(CPPFLAGS = ['-fno-builtin', '-nostdinc']) -test_netenv.Append(CPPPATH = ['#build/include', '#build/include/ipv4']) -test_netenv.Append(LIBPATH = ['#build/lib/libc', '#build/lib/liblwip'], - LIBS = ['lwip', 'c']) - -lwiptest_src = [] -lwiptest_src.append(env["CRTBEGIN"]) -lwiptest_src.append(["lwiptest.c"]) -lwiptest_src.append(env["CRTEND"]) -test_netenv.Program("lwiptest", lwiptest_src) +#test_netenv = env.Clone() +# +#test_netenv.Append(LINKFLAGS = ['-nostdlib']) +#test_netenv.Append(CPPFLAGS = ['-fno-builtin', '-nostdinc']) +#test_netenv.Append(CPPPATH = ['#build/include', '#build/include/ipv4']) +#test_netenv.Append(LIBPATH = ['#build/lib/libc', '#build/lib/liblwip'], +# LIBS = ['lwip', 'c']) +# +#lwiptest_src = [] +#lwiptest_src.append(env["CRTBEGIN"]) +#lwiptest_src.append(["lwiptest.c"]) +#lwiptest_src.append(env["CRTEND"]) +#test_netenv.Program("lwiptest", lwiptest_src)