From: John Hodge Date: Tue, 24 Jul 2012 11:30:31 +0000 (+0800) Subject: Merge branch 'master' of github.com:thepowersgang/acess2 X-Git-Tag: rel0.15~706^2~70^2~1 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=e02f66c7125bf18f77c6c53587238cbd49da2c89;hp=d2159c0ab5d66e07308bc007ed4f4174d8d85668;p=tpg%2Facess2.git Merge branch 'master' of github.com:thepowersgang/acess2 --- diff --git a/BuildConf/x86/default.mk b/BuildConf/x86/default.mk index d9237ca4..759953cf 100644 --- a/BuildConf/x86/default.mk +++ b/BuildConf/x86/default.mk @@ -3,6 +3,7 @@ MODULES += Storage/ATA MODULES += Storage/FDDv2 MODULES += Network/NE2000 Network/RTL8139 MODULES += Network/VIARhineII +MODULES += Network/E1000 MODULES += Display/VESA MODULES += Display/BochsGA #MODULES += Display/VIAVideo diff --git a/KernelLand/Kernel/Makefile b/KernelLand/Kernel/Makefile index aecab40a..1c7cb637 100644 --- a/KernelLand/Kernel/Makefile +++ b/KernelLand/Kernel/Makefile @@ -25,7 +25,7 @@ ASFLAGS += -D ARCHDIR_IS_$(ARCHDIR)=1 -D PLATFORM_is_$(PLATFORM)=1 CPPFLAGS += -I./include -I./arch/$(ARCHDIR)/include -D_MODULE_NAME_=\"Kernel\" CPPFLAGS += -D ARCH=$(ARCH) -D ARCHDIR=$(ARCHDIR) -D PLATFORM=\"$(PLATFORM)\" -D ARCHDIR_IS_$(ARCHDIR)=1 -D PLATFORM_is_$(PLATFORM)=1 CPPFLAGS += -D KERNEL_VERSION=$(KERNEL_VERSION) -ffreestanding -CFLAGS += -Wall -fno-stack-protector -Wstrict-prototypes -g +CFLAGS += -Wall -fno-stack-protector -Wstrict-prototypes -std=gnu99 -g CFLAGS += -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wuninitialized CFLAGS += -O3 LDFLAGS += -T arch/$(ARCHDIR)/link.ld -g @@ -51,6 +51,7 @@ BUILDINFO_OBJ := $(OBJDIR)buildinfo.o$(OBJSUFFIX) BUILDINFO_SRC := $(OBJDIR)buildinfo.c$(OBJSUFFIX) OBJ := $(addprefix arch/$(ARCHDIR)/,$(A_OBJ)) +OBJ += pmemmap.o OBJ += heap.o logging.o debug.o lib.o libc.o adt.o time.o OBJ += drvutil_video.o drvutil_disk.o OBJ += messages.o modules.o syscalls.o system.o @@ -95,14 +96,12 @@ apidoc: # Output binary # - Links kernel # - Disassembles it -# - Gets a line count # - Increments the build count # - Does whatever architecture defined rules $(BIN): $(OBJ) $(MODS) arch/$(ARCHDIR)/link.ld Makefile ../../BuildConf/$(ARCH)/Makefile.cfg ../../BuildConf/$(ARCH)/$(PLATFORM).mk @echo --- LD -o $(BIN) @$(LD) $(LDFLAGS) -o $(BIN) $(OBJ) $(MODS) --defsym __buildnum=$$(( $(BUILD_NUM) + 1 )) -Map ../Map.$(ARCH).txt @$(DISASM) -S $(BIN) > $(BIN).dsm - @wc -l $(SRCFILES) include/*.h > LineCounts.$(ARCH).txt @echo BUILD_NUM = $$(( $(BUILD_NUM) + 1 )) > Makefile.BuildNum.$(ARCH) $(POSTBUILD) @cp $(BIN) $(BIN)_ @@ -116,7 +115,7 @@ $(OBJDIR)%.ao$(OBJSUFFIX): %.$(AS_SUFFIX) Makefile @mkdir -p $(dir $@) @$(AS) $(ASFLAGS) $< -o $@ ifeq ($(AS_SUFFIX),S) - @$(MAKEDEP) $(CPPFLAGS) -MT $@ -o $(OBJDIR)$*.ao.dep$(OBJSUFFIX) $< + @$(MAKEDEP) $(CPPFLAGS) -MT $@ -MP -o $(OBJDIR)$*.ao.dep$(OBJSUFFIX) $< endif # C Sources @@ -124,7 +123,7 @@ $(OBJDIR)%.o$(OBJSUFFIX): %.c Makefile @echo --- CC -o $@ @mkdir -p $(dir $@) @$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< - @$(MAKEDEP) $(CPPFLAGS) -MT $@ -o $(OBJDIR)$*.o.dep$(OBJSUFFIX) $< + @$(MAKEDEP) $(CPPFLAGS) -MT $@ -MP -o $(OBJDIR)$*.o.dep$(OBJSUFFIX) $< # Build-time linked modules %.xo.$(ARCH): @@ -134,14 +133,18 @@ $(OBJDIR)%.o$(OBJSUFFIX): %.c Makefile include/syscalls.h include/syscalls.inc.asm: syscalls.lst Makefile GenSyscalls.pl perl GenSyscalls.pl -# Rules based on the makefile -Makefile: ../../Makefile.cfg arch/$(ARCHDIR)/Makefile +# Differences for the makefile +Makefile: ../../Makefile.cfg ../../BuildConf/$(ARCH)/Makefile.cfg ../../BuildConf/$(ARCH)/$(PLATFORM).mk arch/$(ARCHDIR)/Makefile # Build-time information (git hash and build number) $(BUILDINFO_SRC): $(filter-out $(BUILDINFO_OBJ), $(OBJ)) $(MODS) arch/$(ARCHDIR)/link.ld Makefile + $(eval _GITHASH=$(shell git log -n 1 | head -n 1 | awk '{print $$2}')) + $(eval _GITCHANGED=$(shell git status --porcelain | grep -c '^ M ')) @echo "#include " > $@ - @echo "const char gsGitHash[] = \""`git log -n 1 | head -n 1 | awk '{print $$2}'`"\";" >> $@ + @echo "const char gsGitHash[] = \"$(_GITHASH)\";" >> $@ @echo "const int giBuildNumber = $(BUILD_NUM);" >> $@ + @echo "const char gsBuildInfo[] = \"Acess2 v$(KERNEL_VERSION) $(ARCH)-$(PLATFORM)\\\\r\\\\n\"" >> $@ + @echo " \"Build $(shell hostname --fqdn):$(BUILD_NUM) Git $(_GITHASH) - $(_GITCHANGED) modified\";" >> $@ # Compile rule for buildinfo (needs a special one because it's not a general source file) $(BUILDINFO_OBJ): $(BUILDINFO_SRC) @echo --- CC -o $@ @@ -149,3 +152,4 @@ $(BUILDINFO_OBJ): $(BUILDINFO_SRC) # Dependency Files -include $(DEPFILES) + diff --git a/KernelLand/Kernel/arch/x86/errors.c b/KernelLand/Kernel/arch/x86/errors.c index 9562c413..8dc90b01 100644 --- a/KernelLand/Kernel/arch/x86/errors.c +++ b/KernelLand/Kernel/arch/x86/errors.c @@ -228,14 +228,14 @@ void Error_Backtrace(Uint eip, Uint ebp) LogF("Backtrace: 0x%x", eip); // else // LogF("Backtrace: %s+0x%x", str, delta); - if(!MM_GetPhysAddr(ebp)) + if(!MM_GetPhysAddr((void*)ebp)) { LogF("\nBacktrace: Invalid EBP %p, stopping\n", ebp); return; } - while( MM_GetPhysAddr(ebp) && i < MAX_BACKTRACE ) + while( MM_GetPhysAddr((void*)ebp) && i < MAX_BACKTRACE ) { if( ebp >= MM_KERNEL_STACKS_END ) break; //str = Debug_GetSymbol(*(Uint*)(ebp+4), &delta); diff --git a/KernelLand/Kernel/arch/x86/main.c b/KernelLand/Kernel/arch/x86/main.c index 75db3740..b6ac974a 100644 --- a/KernelLand/Kernel/arch/x86/main.c +++ b/KernelLand/Kernel/arch/x86/main.c @@ -9,21 +9,21 @@ #include #include #include +#include #define VGA_ERRORS 0 +#define KERNEL_LOAD 0x100000 // 1MiB #define MAX_ARGSTR_POS (0x400000-0x2000) +#define MAX_PMEMMAP_ENTS 16 // === IMPORTS === +extern char gKernelEnd[]; extern void Heap_Install(void); -extern void Desctab_Install(void); extern void MM_PreinitVirtual(void); -extern void MM_Install(tMBoot_Info *MBoot); +extern void MM_Install(int NPMemRanges, tPMemMapEnt *PMemRanges); extern void MM_InstallVirtual(void); -extern void Threads_Init(void); extern int Time_Setup(void); -// --- Core --- -extern void System_Init(char *Commandline); // === PROTOTYPES === int kmain(Uint MbMagic, void *MbInfoPtr); @@ -41,29 +41,79 @@ struct { // === CODE === int kmain(Uint MbMagic, void *MbInfoPtr) { - int i; tMBoot_Module *mods; tMBoot_Info *mbInfo; + tPMemMapEnt pmemmap[MAX_PMEMMAP_ENTS]; + int nPMemMapEnts; - LogF("Acess2 x86-"PLATFORM" v"EXPAND_STR(KERNEL_VERSION)"\r\n"); - LogF(" Build %i, Git Hash %s\r\n", BUILD_NUM, gsGitHash); + LogF("%s\r\n", gsBuildInfo); - Log("MbMagic = %08x, MbInfoPtr = %p", MbMagic, MbInfoPtr); - - // Set up non-boot info dependent stuff - Desctab_Install(); // Set up GDT and IDT MM_PreinitVirtual(); // Initialise virtual mappings - + + mbInfo = MbInfoPtr; + switch(MbMagic) { // Multiboot 1 - case MULTIBOOT_MAGIC: + case MULTIBOOT_MAGIC: { + // TODO: Handle when this isn't in the mapped area + gsBootCmdLine = (char*)(mbInfo->CommandLine + KERNEL_BASE); + + tMBoot_MMapEnt *ent = (void*)mbInfo->MMapAddr; + tMBoot_MMapEnt *last = (void*)(mbInfo->MMapAddr + mbInfo->MMapLength); + + // Build up memory map + nPMemMapEnts = 0; + while( ent < last && nPMemMapEnts < MAX_PMEMMAP_ENTS ) + { + tPMemMapEnt *nent = &pmemmap[nPMemMapEnts]; + nent->Start = ent->Base; + nent->Length = ent->Length; + switch(ent->Type) + { + case 1: + nent->Type = PMEMTYPE_FREE; + break; + default: + nent->Type = PMEMTYPE_RESERVED; + break; + } + nent->NUMADomain = 0; + + nPMemMapEnts ++; + ent = (void*)( (tVAddr)ent + ent->Size + 4 ); + } + + // Ensure it's valid + nPMemMapEnts = PMemMap_ValidateMap(pmemmap, nPMemMapEnts, MAX_PMEMMAP_ENTS); + // TODO: Error handling + + // Replace kernel with PMEMTYPE_USED + nPMemMapEnts = PMemMap_MarkRangeUsed( + pmemmap, nPMemMapEnts, MAX_PMEMMAP_ENTS, + KERNEL_LOAD, (tVAddr)&gKernelEnd - KERNEL_LOAD - KERNEL_BASE + ); + + // Replace modules with PMEMTYPE_USED + nPMemMapEnts = PMemMap_MarkRangeUsed(pmemmap, nPMemMapEnts, MAX_PMEMMAP_ENTS, + mbInfo->Modules, mbInfo->ModuleCount*sizeof(*mods) + ); + mods = (void*)mbInfo->Modules; + for( int i = 0; i < mbInfo->ModuleCount; i ++ ) + { + nPMemMapEnts = PMemMap_MarkRangeUsed( + pmemmap, nPMemMapEnts, MAX_PMEMMAP_ENTS, + mods->Start, mods->End - mods->Start + ); + } + + // Debug - Output map + PMemMap_DumpBlocks(pmemmap, nPMemMapEnts); + // Adjust Multiboot structure address mbInfo = (void*)( (Uint)MbInfoPtr + KERNEL_BASE ); - gsBootCmdLine = (char*)(mbInfo->CommandLine + KERNEL_BASE); - MM_Install( mbInfo ); // Set up physical memory manager - break; + break; } // Multiboot 2 case MULTIBOOT2_MAGIC: @@ -78,6 +128,9 @@ int kmain(Uint MbMagic, void *MbInfoPtr) return 0; } + // Set up physical memory manager + MM_Install(nPMemMapEnts, pmemmap); + MM_InstallVirtual(); // Clean up virtual address space Heap_Install(); // Create initial heap @@ -95,7 +148,7 @@ int kmain(Uint MbMagic, void *MbInfoPtr) mods = (void*)( mbInfo->Modules + KERNEL_BASE ); giArch_NumBootModules = mbInfo->ModuleCount; gaArch_BootModules = malloc( giArch_NumBootModules * sizeof(*gaArch_BootModules) ); - for( i = 0; i < mbInfo->ModuleCount; i ++ ) + for( int i = 0; i < mbInfo->ModuleCount; i ++ ) { int ofs; diff --git a/KernelLand/Kernel/arch/x86/mm_phys.c b/KernelLand/Kernel/arch/x86/mm_phys.c index 49d7a1a7..b0f1c616 100644 --- a/KernelLand/Kernel/arch/x86/mm_phys.c +++ b/KernelLand/Kernel/arch/x86/mm_phys.c @@ -4,8 +4,9 @@ */ #define DEBUG 0 #include -#include #include +#include +#include //#define USE_STACK 1 #define TRACE_ALLOCS 0 // Print trace messages on AllocPhys/DerefPhys @@ -14,11 +15,10 @@ static const int addrClasses[] = {0,16,20,24,32,64}; static const int numAddrClasses = sizeof(addrClasses)/sizeof(addrClasses[0]); // === IMPORTS === -extern char gKernelEnd[]; extern void Proc_PrintBacktrace(void); // === PROTOTYPES === -void MM_Install(tMBoot_Info *MBoot); +void MM_Install(int NPMemRanges, tPMemMapEnt *PMemRanges); //tPAddr MM_AllocPhys(void); //tPAddr MM_AllocPhysRange(int Pages, int MaxBits); //void MM_RefPhys(tPAddr PAddr); @@ -39,86 +39,70 @@ void **gaPageNodes = (void*)MM_PAGENODE_BASE; #define REFENT_PER_PAGE (0x1000/sizeof(gaPageReferences[0])) // === CODE === -void MM_Install(tMBoot_Info *MBoot) +void MM_Install(int NPMemRanges, tPMemMapEnt *PMemRanges) { - Uint kernelPages, num; Uint i; Uint64 maxAddr = 0; - tMBoot_Module *mods; - tMBoot_MMapEnt *ent; // --- Find largest address - MBoot->MMapAddr |= KERNEL_BASE; - ent = (void *)( MBoot->MMapAddr ); - while( (Uint)ent < MBoot->MMapAddr + MBoot->MMapLength ) + for( i = 0; i < NPMemRanges; i ++ ) { - // Adjust for size - ent->Size += 4; - + tPMemMapEnt *ent = &PMemRanges[i]; // If entry is RAM and is above `maxAddr`, change `maxAddr` - if(ent->Type == 1) + if(ent->Type == PMEMTYPE_FREE || ent->Type == PMEMTYPE_USED) { - if(ent->Base + ent->Length > maxAddr) - maxAddr = ent->Base + ent->Length; + if(ent->Start + ent->Length > maxAddr) + maxAddr = ent->Start + ent->Length; giTotalMemorySize += ent->Length >> 12; } - // Go to next entry - ent = (tMBoot_MMapEnt *)( (Uint)ent + ent->Size ); } - if(maxAddr == 0) { - giPageCount = (MBoot->HighMem >> 2) + 256; // HighMem is a kByte value - } - else { - giPageCount = maxAddr >> 12; - } + giPageCount = maxAddr >> 12; giLastPossibleFree = giPageCount - 1; memsetd(gaPageBitmap, 0xFFFFFFFF, giPageCount/32); // Set up allocateable space - ent = (void *)( MBoot->MMapAddr ); - while( (Uint)ent < MBoot->MMapAddr + MBoot->MMapLength ) - { - memsetd( &gaPageBitmap[ent->Base/(4096*32)], 0, ent->Length/(4096*32) ); - ent = (tMBoot_MMapEnt *)( (Uint)ent + ent->Size ); + for( i = 0; i < NPMemRanges; i ++ ) + { + tPMemMapEnt *ent = &PMemRanges[i]; + if( ent->Type == PMEMTYPE_FREE ) + { + Uint64 startpg = ent->Start / PAGE_SIZE; + Uint64 pgcount = ent->Length / PAGE_SIZE; + while( startpg % 32 && pgcount ) { + gaPageBitmap[startpg/32] &= ~(1U << (startpg%32)); + startpg ++; + pgcount --; + } + memsetd( &gaPageBitmap[startpg/32], 0, pgcount/32 ); + startpg += pgcount - pgcount%32; + pgcount -= pgcount - pgcount%32; + while(pgcount) { + gaPageBitmap[startpg/32] &= ~(1U << (startpg%32)); + startpg ++; + pgcount --; + } + } + else if( ent->Type == PMEMTYPE_USED ) + { + giPhysAlloc += ent->Length / PAGE_SIZE; + } } - - // Get used page count (Kernel) - kernelPages = (Uint)&gKernelEnd - KERNEL_BASE - 0x100000; - kernelPages += 0xFFF; // Page Align - kernelPages >>= 12; - giPhysAlloc += kernelPages; // Add to used count - // Fill page bitmap - num = kernelPages/32; - memsetd( &gaPageBitmap[0x100000/(4096*32)], -1, num ); - gaPageBitmap[ 0x100000/(4096*32) + num ] = (1 << (kernelPages & 31)) - 1; - // Fill Superpage bitmap - num = kernelPages/(32*32); - memsetd( &gaSuperBitmap[0x100000/(4096*32*32)], -1, num ); - gaSuperBitmap[ 0x100000/(4096*32*32) + num ] = (1 << ((kernelPages / 32) & 31)) - 1; - - // Mark Multiboot's pages as taken - // - Structure - MM_RefPhys( (Uint)MBoot - KERNEL_BASE ); - // - Module List - for(i = (MBoot->ModuleCount*sizeof(tMBoot_Module)+0xFFF)>12; i--; ) - MM_RefPhys( MBoot->Modules + (i << 12) ); - // - Modules - mods = (void*)(MBoot->Modules + KERNEL_BASE); - for(i = 0; i < MBoot->ModuleCount; i++) + // - A set bit means that there are no free pages in this block of 32 + for( i = 0; i < (giPageCount+31)/32; i ++ ) { - num = (mods[i].End - mods[i].Start + 0xFFF) >> 12; - while(num--) - MM_RefPhys( (mods[i].Start & ~0xFFF) + (num<<12) ); + if( gaPageBitmap[i] + 1 == 0 ) { + gaSuperBitmap[i/32] |= (1 << i%32); + } } - + gaPageReferences = (void*)MM_REFCOUNT_BASE; Log_Log("PMem", "Physical memory set up (%lli pages of ~%lli MiB used)", - giPhysAlloc, (giTotalMemorySize*4)/1024 + giPhysAlloc, (giTotalMemorySize*PAGE_SIZE)/(1024*1024) ); } @@ -286,7 +270,7 @@ tPAddr MM_AllocPhys(void) } // Mark page used - if( MM_GetPhysAddr( (tVAddr)&gaPageReferences[indx] ) ) + if( MM_GetPhysAddr( &gaPageReferences[indx] ) ) gaPageReferences[indx] = 1; gaPageBitmap[ indx>>5 ] |= 1 << (indx&31); @@ -321,7 +305,6 @@ tPAddr MM_AllocPhys(void) */ tPAddr MM_AllocPhysRange(int Pages, int MaxBits) { - int a, b; int i, idx, sidx; tPAddr ret; @@ -346,8 +329,6 @@ tPAddr MM_AllocPhysRange(int Pages, int MaxBits) } idx = sidx / 32; sidx %= 32; - b = idx % 32; - a = idx / 32; #if 0 LOG("a=%i, b=%i, idx=%i, sidx=%i", a, b, idx, sidx); @@ -422,7 +403,7 @@ tPAddr MM_AllocPhysRange(int Pages, int MaxBits) // Mark pages used for( i = 0; i < Pages; i++ ) { - if( MM_GetPhysAddr( (tVAddr)&gaPageReferences[idx*32+sidx] ) ) + if( MM_GetPhysAddr( &gaPageReferences[idx*32+sidx] ) ) gaPageReferences[idx*32+sidx] = 1; gaPageBitmap[ idx ] |= 1 << sidx; sidx ++; @@ -464,7 +445,7 @@ void MM_RefPhys(tPAddr PAddr) // Reference the page if( gaPageReferences ) { - if( MM_GetPhysAddr( (tVAddr)&gaPageReferences[PAddr] ) == 0 ) + if( MM_GetPhysAddr( &gaPageReferences[PAddr] ) == 0 ) { int i, base; tVAddr addr = ((tVAddr)&gaPageReferences[PAddr]) & ~0xFFF; @@ -526,7 +507,7 @@ void MM_DerefPhys(tPAddr PAddr) giLastPossibleFree = PAddr; // Dereference - if( !MM_GetPhysAddr( (tVAddr)&gaPageReferences[PAddr] ) || (-- gaPageReferences[PAddr]) == 0 ) + if( !MM_GetPhysAddr( &gaPageReferences[PAddr] ) || (-- gaPageReferences[PAddr]) == 0 ) { #if TRACE_ALLOCS Log_Debug("PMem", "MM_DerefPhys: Free'd %P (%i free)", PAddr<<12, giPageCount-giPhysAlloc); @@ -538,7 +519,7 @@ void MM_DerefPhys(tPAddr PAddr) if(gaPageBitmap[ PAddr / 32 ] == 0) gaSuperBitmap[ PAddr >> 10 ] &= ~(1 << ((PAddr >> 5)&31)); - if( MM_GetPhysAddr( (tVAddr) &gaPageNodes[PAddr] ) ) + if( MM_GetPhysAddr( &gaPageNodes[PAddr] ) ) { gaPageNodes[PAddr] = NULL; // TODO: Free Node Page when fully unused @@ -560,7 +541,7 @@ int MM_GetRefCount(tPAddr PAddr) // We don't care about non-ram pages if(PAddr >= giPageCount) return -1; - if( MM_GetPhysAddr( (tVAddr)&gaPageReferences[PAddr] ) == 0 ) + if( MM_GetPhysAddr( &gaPageReferences[PAddr] ) == 0 ) return (gaPageBitmap[PAddr / 32] & (1 << PAddr%32)) ? 1 : 0; // Check if it is freed @@ -578,7 +559,7 @@ int MM_SetPageNode(tPAddr PAddr, void *Node) block_addr = (tVAddr) &gaPageNodes[PAddr]; block_addr &= ~(PAGE_SIZE-1); - if( !MM_GetPhysAddr( block_addr ) ) + if( !MM_GetPhysAddr( (void*)block_addr ) ) { if( !MM_Allocate( block_addr ) ) { Log_Warning("PMem", "Unable to allocate Node page"); @@ -597,7 +578,7 @@ int MM_GetPageNode(tPAddr PAddr, void **Node) if( MM_GetRefCount(PAddr) == 0 ) return 1; PAddr /= PAGE_SIZE; - if( !MM_GetPhysAddr( (tVAddr) &gaPageNodes[PAddr] ) ) { + if( !MM_GetPhysAddr( &gaPageNodes[PAddr] ) ) { *Node = NULL; return 0; } diff --git a/KernelLand/Kernel/arch/x86/mm_virt.c b/KernelLand/Kernel/arch/x86/mm_virt.c index d15c3d72..868fe86a 100644 --- a/KernelLand/Kernel/arch/x86/mm_virt.c +++ b/KernelLand/Kernel/arch/x86/mm_virt.c @@ -414,13 +414,14 @@ void MM_Deallocate(tVAddr VAddr) * \fn tPAddr MM_GetPhysAddr(tVAddr Addr) * \brief Checks if the passed address is accesable */ -tPAddr MM_GetPhysAddr(tVAddr Addr) +tPAddr MM_GetPhysAddr(const void *Addr) { - if( !(gaPageDir[Addr >> 22] & 1) ) + tVAddr addr = (tVAddr)Addr; + if( !(gaPageDir[addr >> 22] & 1) ) return 0; - if( !(gaPageTable[Addr >> 12] & 1) ) + if( !(gaPageTable[addr >> 12] & 1) ) return 0; - return (gaPageTable[Addr >> 12] & ~0xFFF) | (Addr & 0xFFF); + return (gaPageTable[addr >> 12] & ~0xFFF) | (addr & 0xFFF); } /** @@ -717,7 +718,8 @@ tVAddr MM_NewKStack(void) for(base = MM_KERNEL_STACKS; base < MM_KERNEL_STACKS_END; base += MM_KERNEL_STACK_SIZE) { // Check if space is free - if(MM_GetPhysAddr(base) != 0) continue; + if(MM_GetPhysAddr( (void*) base) != 0) + continue; // Allocate //for(i = MM_KERNEL_STACK_SIZE; i -= 0x1000 ; ) for(i = 0; i < MM_KERNEL_STACK_SIZE; i += 0x1000 ) @@ -1069,7 +1071,6 @@ tVAddr MM_MapHWPages(tPAddr PAddr, Uint Number) */ tVAddr MM_AllocDMA(int Pages, int MaxBits, tPAddr *PhysAddr) { - tPAddr maxCheck = (1 << MaxBits); tPAddr phys; tVAddr ret; @@ -1084,9 +1085,6 @@ tVAddr MM_AllocDMA(int Pages, int MaxBits, tPAddr *PhysAddr) return 0; } - // Bound - if(MaxBits >= PHYS_BITS) maxCheck = -1; - // Fast Allocate if(Pages == 1 && MaxBits >= PHYS_BITS) { diff --git a/KernelLand/Kernel/arch/x86/proc.c b/KernelLand/Kernel/arch/x86/proc.c index 281b6288..de0d5c3c 100644 --- a/KernelLand/Kernel/arch/x86/proc.c +++ b/KernelLand/Kernel/arch/x86/proc.c @@ -467,7 +467,6 @@ void Proc_IdleThread(void *Ptr) */ void Proc_Start(void) { - int tid; #if USE_MP int i; #endif @@ -479,7 +478,7 @@ void Proc_Start(void) if(i) gaCPUs[i].Current = NULL; // Create Idle Task - tid = Proc_NewKThread(Proc_IdleThread, &gaCPUs[i]); + Proc_NewKThread(Proc_IdleThread, &gaCPUs[i]); // Start the AP if( i != giProc_BootProcessorID ) { @@ -496,8 +495,7 @@ void Proc_Start(void) while( giNumInitingCPUs ) __asm__ __volatile__ ("hlt"); #else // Create Idle Task - tid = Proc_NewKThread(Proc_IdleThread, &gaCPUs[0]); -// gaCPUs[0].IdleThread = Threads_GetThread(tid); + Proc_NewKThread(Proc_IdleThread, &gaCPUs[0]); // Set current task gaCPUs[0].Current = &gThreadZero; @@ -588,9 +586,8 @@ void Proc_ClearThread(tThread *Thread) tTID Proc_NewKThread(void (*Fcn)(void*), void *Data) { Uint esp; - tThread *newThread, *cur; + tThread *newThread; - cur = Proc_GetCurThread(); newThread = Threads_CloneTCB(0); if(!newThread) return -1; @@ -711,7 +708,7 @@ Uint Proc_MakeUserStack(void) // Check Prospective Space for( i = USER_STACK_SZ >> 12; i--; ) - if( MM_GetPhysAddr( base + (i<<12) ) != 0 ) + if( MM_GetPhysAddr( (void*)(base + (i<<12)) ) != 0 ) break; if(i != -1) return 0; @@ -863,6 +860,10 @@ void Proc_DumpThreadCPUState(tThread *Thread) __asm__ __volatile__ ("mov %%ebp, %0" : "=r" (stack)); while( maxBacktraceDistance -- ) { + if( !CheckMem(stack, 8) ) { + regs = NULL; + break; + } // [ebp] = oldEbp // [ebp+4] = retaddr diff --git a/KernelLand/Kernel/arch/x86/start.asm b/KernelLand/Kernel/arch/x86/start.asm index b6026de6..1d4a35d8 100644 --- a/KernelLand/Kernel/arch/x86/start.asm +++ b/KernelLand/Kernel/arch/x86/start.asm @@ -57,6 +57,7 @@ mboot: [section .text] [extern kmain] +[extern Desctab_Install] [global start] start: ; Just show we're here @@ -87,11 +88,15 @@ start: .higher_half: mov WORD [0xB8006], 0x0773 ; 's' + + push ebx ; Multiboot Info + push eax ; Multiboot Magic Value + ; NOTE: These are actually for kmain + + call Desctab_Install mov WORD [0xB8008], 0x0773 ; 's' ; Call the kernel - push ebx ; Multiboot Info - push eax ; Multiboot Magic Value mov WORD [0xB800A], 0x0732 ; '2' call kmain diff --git a/KernelLand/Kernel/bin/elf.c b/KernelLand/Kernel/bin/elf.c index 83dfa8ac..b0d96cac 100644 --- a/KernelLand/Kernel/bin/elf.c +++ b/KernelLand/Kernel/bin/elf.c @@ -12,7 +12,7 @@ void *GetSymbol(const char *Name, size_t *Size); void *GetSymbol(const char *Name, size_t *Size) { Uint val; Binary_GetSymbol(Name, &val); if(Size)*Size=0; return (void*)val; }; #define AddLoaded(a,b) do{}while(0) -#define LoadLibrary(a,b,c) 0 +#define LoadLibrary(a,b,c) (Log_Debug("ELF", "Module requested lib '%s'",a),0) #include "../../../Usermode/Libraries/ld-acess.so_src/elf.c" #define DEBUG_WARN 1 diff --git a/KernelLand/Kernel/binary.c b/KernelLand/Kernel/binary.c index 8a8bc3eb..de94c6f6 100644 --- a/KernelLand/Kernel/binary.c +++ b/KernelLand/Kernel/binary.c @@ -881,12 +881,12 @@ int Binary_int_CheckMemFree( tVAddr _start, size_t _len ) _start &= ~(PAGE_SIZE-1); LOG("_start = %p, _len = 0x%x", _start, _len); for( ; _len > PAGE_SIZE; _len -= PAGE_SIZE, _start += PAGE_SIZE ) { - if( MM_GetPhysAddr(_start) != 0 ) { + if( MM_GetPhysAddr( (void*)_start ) != 0 ) { LEAVE('i', 1); return 1; } } - if( _len == PAGE_SIZE && MM_GetPhysAddr(_start) != 0 ) { + if( _len == PAGE_SIZE && MM_GetPhysAddr( (void*)_start ) != 0 ) { LEAVE('i', 1); return 1; } diff --git a/KernelLand/Kernel/drv/proc.c b/KernelLand/Kernel/drv/proc.c index 954cab62..b4483b04 100644 --- a/KernelLand/Kernel/drv/proc.c +++ b/KernelLand/Kernel/drv/proc.c @@ -109,12 +109,8 @@ tSysFS_Ent *gSysFS_FileList; */ int SysFS_Install(char **Options) { - { - const char *fmt = "Acess2 "EXPAND_STR(KERNEL_VERSION)" "EXPAND_STR(ARCHDIR)" build %i, hash %s"; - gSysFS_Version_Kernel.Node.Size = snprintf(NULL, 0, fmt, BUILD_NUM, gsGitHash); - gSysFS_Version_Kernel.Node.ImplPtr = malloc( gSysFS_Version_Kernel.Node.Size + 1 ); - sprintf(gSysFS_Version_Kernel.Node.ImplPtr, fmt, BUILD_NUM, gsGitHash); - } + gSysFS_Version_Kernel.Node.Size = strlen(gsBuildInfo); + gSysFS_Version_Kernel.Node.ImplPtr = (void*)gsBuildInfo; DevFS_AddDevice( &gSysFS_DriverInfo ); return MODULE_ERR_OK; diff --git a/KernelLand/Kernel/drv/vterm.c b/KernelLand/Kernel/drv/vterm.c index a6a1c66d..63db01e4 100644 --- a/KernelLand/Kernel/drv/vterm.c +++ b/KernelLand/Kernel/drv/vterm.c @@ -196,7 +196,6 @@ int VT_Install(char **Arguments) // Semaphore_Init(&gVT_Terminals[i].InputSemaphore, 0, MAX_INPUT_CHARS8, "VTerm", gVT_Terminals[i].Name); } - Log_Debug("VTerm", "Registering with DevFS"); // Add to DevFS DevFS_AddDevice( &gVT_DrvInfo ); diff --git a/KernelLand/Kernel/drv/vterm_termbuf.c b/KernelLand/Kernel/drv/vterm_termbuf.c index b6aff95c..7c296566 100644 --- a/KernelLand/Kernel/drv/vterm_termbuf.c +++ b/KernelLand/Kernel/drv/vterm_termbuf.c @@ -361,6 +361,7 @@ void VT_int_ChangeMode(tVTerm *Term, int NewMode, int NewWidth, int NewHeight) } // Debug + #if 0 switch(NewMode) { case TERM_MODE_TEXT: @@ -375,6 +376,7 @@ void VT_int_ChangeMode(tVTerm *Term, int NewMode, int NewWidth, int NewHeight) //case TERM_MODE_3DACCEL: // return; } + #endif } diff --git a/KernelLand/Kernel/drvutil_video.c b/KernelLand/Kernel/drvutil_video.c index 094f0b1a..05fa1026 100644 --- a/KernelLand/Kernel/drvutil_video.c +++ b/KernelLand/Kernel/drvutil_video.c @@ -137,12 +137,18 @@ int DrvUtil_Video_WriteLFB(tDrvUtil_Video_BufInfo *FBInfo, size_t Offset, size_t int csr_x, csr_y; int x, y; int bytes_per_px = (FBInfo->Depth + 7) / 8; + size_t ofs; ENTER("pFBInfo xOffset xLength pBuffer", FBInfo, Offset, Length, Buffer); csr_x = FBInfo->CursorX; csr_y = FBInfo->CursorY; + if( FBInfo->BackBuffer ) + dest = FBInfo->BackBuffer; + else + dest = FBInfo->Framebuffer; + DrvUtil_Video_RemoveCursor(FBInfo); switch( FBInfo->BufferFormat ) @@ -171,10 +177,9 @@ int DrvUtil_Video_WriteLFB(tDrvUtil_Video_BufInfo *FBInfo, size_t Offset, size_t Length = heightInChars*widthInChars - Offset; } - dest = FBInfo->Framebuffer; - LOG("dest = %p", dest); - dest += y * giVT_CharHeight * FBInfo->Pitch; LOG("dest = %p", dest); + ofs = y * giVT_CharHeight * FBInfo->Pitch; + dest += ofs; for( i = 0; i < Length; i++ ) { @@ -201,9 +206,11 @@ int DrvUtil_Video_WriteLFB(tDrvUtil_Video_BufInfo *FBInfo, size_t Offset, size_t LOG("dest = %p", dest); } } + if( x > 0 ) + dest += FBInfo->Pitch*giVT_CharHeight; Length = i * sizeof(tVT_Char); - } - break; + + break; } case VIDEO_BUFFMT_FRAMEBUFFER: if(FBInfo->Width*FBInfo->Height*4 < Offset+Length) @@ -217,11 +224,13 @@ int DrvUtil_Video_WriteLFB(tDrvUtil_Video_BufInfo *FBInfo, size_t Offset, size_t case 15: case 16: Log_Warning("DrvUtil", "TODO: Support 15/16 bpp modes in LFB write"); + dest = NULL; break; case 24: x = Offset % FBInfo->Width; y = Offset / FBInfo->Width; - dest = (Uint8*)FBInfo->Framebuffer + y*FBInfo->Pitch; + ofs = y*FBInfo->Pitch; + dest += ofs; for( ; Length >= 4; Length -= 4 ) { dest[x*3+0] = *src & 0xFF; @@ -243,25 +252,30 @@ int DrvUtil_Video_WriteLFB(tDrvUtil_Video_BufInfo *FBInfo, size_t Offset, size_t x = Offset % FBInfo->Width; y = Offset / FBInfo->Height; - px = (Uint32*)FBInfo->Framebuffer + y*FBInfo->Pitch/4; + ofs = y*FBInfo->Pitch; + dest += ofs; + px = (void*)dest; - for( ; Length >= 4; Length -= 4, x ) + for( ; Length >= 4; Length -= 4 ) { px[x++] = *src ++; if( x == FBInfo->Width ) { x = 0; - px += FBInfo->Pitch; + dest += FBInfo->Pitch; + px = (void*)dest; } } } else { - dest = (Uint8 *)FBInfo->Framebuffer + Offset; + ofs = Offset; + dest += ofs; memcpy(dest, Buffer, Length); } break; default: - Log_Warning("DrvUtil", "DrvUtil_Video_WriteLFB - Unknown bit depthn %i", FBInfo->Depth); + Log_Warning("DrvUtil", "DrvUtil_Video_WriteLFB - Unknown bit depth %i", FBInfo->Depth); + dest = NULL; break; } break; @@ -271,12 +285,18 @@ int DrvUtil_Video_WriteLFB(tDrvUtil_Video_BufInfo *FBInfo, size_t Offset, size_t FBInfo, Buffer, Length, &gDrvUtil_Stub_2DFunctions, sizeof(gDrvUtil_Stub_2DFunctions) ); + dest = NULL; break; default: LEAVE('i', -1); return -1; } + if( FBInfo->BackBuffer && dest ) { + memcpy((char*)FBInfo->Framebuffer + ofs, (char*)FBInfo->BackBuffer + ofs, + ((tVAddr)dest - (tVAddr)FBInfo->BackBuffer) - ofs + ); + } DrvUtil_Video_DrawCursor(FBInfo, csr_x, csr_y); @@ -520,18 +540,35 @@ void DrvUtil_Video_2D_Fill(void *Ent, Uint16 X, Uint16 Y, Uint16 W, Uint16 H, Ui { tDrvUtil_Video_BufInfo *FBInfo = Ent; - // TODO: Handle non-32bit modes - if( FBInfo->Depth != 32 ) return; - - // TODO: Be less hacky - int pitch = FBInfo->Pitch/4; - Uint32 *buf = (Uint32*)FBInfo->Framebuffer + Y*pitch + X; - while( H -- ) { - Uint32 *tmp; - int i; - tmp = buf; - for(i=W;i--;tmp++) *tmp = Colour; - buf += pitch; + switch( FBInfo->Depth ) + { + case 32: { + // TODO: Be less hacky + size_t pitch = FBInfo->Pitch/4; + size_t ofs = Y*pitch + X; + Uint32 *buf = (Uint32*)FBInfo->Framebuffer + ofs; + Uint32 *cbuf = NULL; + if( FBInfo->BackBuffer ) + cbuf = (Uint32*)FBInfo->BackBuffer + ofs; + while( H -- ) + { + Uint32 *line; + line = buf; + for(int i = W; i--; line++) + *line = Colour; + buf += pitch; + if( cbuf ) { + line = cbuf; + for(int i = W; i--; line++ ) + *line = Colour; + cbuf += pitch; + } + } + break; } + default: + // TODO: Handle non-32bit modes + Log_Warning("DrvUtil", "TODO: <32bpp _Fill"); + break; } } @@ -543,6 +580,9 @@ void DrvUtil_Video_2D_Blit(void *Ent, Uint16 DstX, Uint16 DstY, Uint16 SrcX, Uin int dst = DstY*scrnpitch + DstX; int src = SrcY*scrnpitch + SrcX; int tmp; + Uint8 *framebuffer = FBInfo->Framebuffer; + Uint8 *backbuffer = FBInfo->BackBuffer; + Uint8 *sourcebuffer = (FBInfo->BackBuffer ? FBInfo->BackBuffer : FBInfo->Framebuffer); //Log("Vesa_2D_Blit: (Ent=%p, DstX=%i, DstY=%i, SrcX=%i, SrcY=%i, W=%i, H=%i)", // Ent, DstX, DstY, SrcX, SrcY, W, H); @@ -554,26 +594,39 @@ void DrvUtil_Video_2D_Blit(void *Ent, Uint16 DstX, Uint16 DstY, Uint16 SrcX, Uin //Debug("W = %i, H = %i", W, H); - if( dst > src ) { + if(W == FBInfo->Width && FBInfo->Pitch == FBInfo->Width*bytes_per_px) + { + memmove(framebuffer + dst, sourcebuffer + src, H*FBInfo->Pitch); + if( backbuffer ) + memmove(backbuffer + dst, sourcebuffer + src, H*FBInfo->Pitch); + } + else if( dst > src ) + { // Reverse copy dst += H*scrnpitch; src += H*scrnpitch; - while( H -- ) { + while( H -- ) + { dst -= scrnpitch; src -= scrnpitch; tmp = W*bytes_per_px; - for( tmp = W; tmp --; ) { - *((Uint8*)FBInfo->Framebuffer + dst + tmp) = *((Uint8*)FBInfo->Framebuffer + src + tmp); + for( tmp = W; tmp --; ) + { + size_t src_o = src + tmp; + size_t dst_o = src + tmp; + framebuffer[dst_o] = sourcebuffer[src_o]; + if( backbuffer ) + backbuffer[dst_o] = sourcebuffer[src_o]; } } } - else if(W == FBInfo->Width && FBInfo->Pitch == FBInfo->Width*bytes_per_px) { - memmove((Uint8*)FBInfo->Framebuffer + dst, (Uint8*)FBInfo->Framebuffer + src, H*FBInfo->Pitch); - } else { // Normal copy is OK - while( H -- ) { - memcpy((Uint8*)FBInfo->Framebuffer + dst, (Uint8*)FBInfo->Framebuffer + src, W*bytes_per_px); + while( H -- ) + { + memcpy(framebuffer + dst, sourcebuffer + src, W*bytes_per_px); + if( backbuffer ) + memcpy(backbuffer + dst, sourcebuffer + src, W*bytes_per_px); dst += scrnpitch; src += scrnpitch; } diff --git a/KernelLand/Kernel/heap.c b/KernelLand/Kernel/heap.c index 9e291450..4c7ffd95 100644 --- a/KernelLand/Kernel/heap.c +++ b/KernelLand/Kernel/heap.c @@ -519,7 +519,7 @@ void Heap_Dump(void) foot = (void*)( (Uint)head + head->Size - sizeof(tHeapFoot) ); #if VERBOSE_DUMP Log_Log("Heap", "%p (0x%P): 0x%08x (%i) %4C", - head, MM_GetPhysAddr((tVAddr)head), head->Size, head->ValidSize, &head->Magic); + head, MM_GetPhysAddr(head), head->Size, head->ValidSize, &head->Magic); Log_Log("Heap", "%p %4C", foot->Head, &foot->Magic); if(head->File) { Log_Log("Heap", "%sowned by %s:%i", @@ -569,7 +569,7 @@ void Heap_Dump(void) #if !VERBOSE_DUMP Log_Log("Heap", "%p (%P): 0x%08lx %i %4C", - head, MM_GetPhysAddr((Uint)head), head->Size, head->ValidSize, &head->Magic); + head, MM_GetPhysAddr(head), head->Size, head->ValidSize, &head->Magic); if(foot) Log_Log("Heap", "Foot %p = {Head:%p,Magic:%4C}", foot, foot->Head, &foot->Magic); if(head->File) { @@ -589,7 +589,7 @@ void Heap_Dump(void) while( (tVAddr)head >= (tVAddr)badHead ) { Log_Log("Heap", "%p (%P): 0x%08lx %i %4C", - head, MM_GetPhysAddr((Uint)head), head->Size, head->ValidSize, &head->Magic); + head, MM_GetPhysAddr(head), head->Size, head->ValidSize, &head->Magic); Log_Log("Heap", "%p %4C", foot->Head, &foot->Magic); if(head->File) Log_Log("Heap", "%sowned by %s:%i", @@ -669,10 +669,10 @@ void Heap_Stats(void) #if 1 if( head->Magic == MAGIC_FREE ) Log_Debug("Heap", "%p (%P) - 0x%x free", - head->Data, MM_GetPhysAddr((tVAddr)&head->Data), head->Size); + head->Data, MM_GetPhysAddr(&head->Data), head->Size); else Log_Debug("Heap", "%p (%P) - 0x%x (%i) Owned by %s:%i (%lli ms old)", - head->Data, MM_GetPhysAddr((tVAddr)&head->Data), head->Size, head->ValidSize, head->File, head->Line, + head->Data, MM_GetPhysAddr(&head->Data), head->Size, head->ValidSize, head->File, head->Line, now() - head->AllocateTime ); #endif diff --git a/KernelLand/Kernel/include/acess.h b/KernelLand/Kernel/include/acess.h index 1a982fe5..51ae771b 100644 --- a/KernelLand/Kernel/include/acess.h +++ b/KernelLand/Kernel/include/acess.h @@ -60,7 +60,8 @@ typedef Uint64 off_t; //!< VFS Offset extern char __buildnum[]; #define BUILD_NUM ((int)(Uint)&__buildnum) -extern const char gsGitHash[]; +extern const char gsGitHash[]; +extern const char gsBuildInfo[]; #define VER2(major,minor) ((((major)&0xFF)<<8)|((minor)&0xFF)) /** @@ -252,7 +253,7 @@ extern int MM_Map(tVAddr VAddr, tPAddr PAddr); * \param Addr Address of the page to get the physical address of * \return Physical page mapped at \a Addr */ -extern tPAddr MM_GetPhysAddr(tVAddr Addr); +extern tPAddr MM_GetPhysAddr(const void *Addr); /** * \brief Set the access flags on a page * \param VAddr Virtual address of the page diff --git a/KernelLand/Kernel/include/api_drv_video.h b/KernelLand/Kernel/include/api_drv_video.h index ff9c395b..43d91d79 100644 --- a/KernelLand/Kernel/include/api_drv_video.h +++ b/KernelLand/Kernel/include/api_drv_video.h @@ -341,6 +341,10 @@ typedef struct sDrvUtil_Video_BufInfo * \brief Bit depth of the framebuffer */ short Depth; + /** + * \brief Cached copy of the screens state (only used if not NULL) + */ + void *BackBuffer; /* * \} */ diff --git a/KernelLand/Kernel/include/init.h b/KernelLand/Kernel/include/init.h index 9f2fc108..6af177dc 100644 --- a/KernelLand/Kernel/include/init.h +++ b/KernelLand/Kernel/include/init.h @@ -7,5 +7,7 @@ extern void Arch_LoadBootModules(void); extern void StartupPrint(const char *String); +extern void System_Init(char *Commandline); +extern void Threads_Init(void); #endif diff --git a/KernelLand/Kernel/include/pmemmap.h b/KernelLand/Kernel/include/pmemmap.h new file mode 100644 index 00000000..4b89e457 --- /dev/null +++ b/KernelLand/Kernel/include/pmemmap.h @@ -0,0 +1,37 @@ +/* + * Acess2 Kernel + * - By John Hodge (thePowersGang) + * + * pmemmap.h + * - Physical Memory Map definitions + */ +#ifndef _PMEMMAP_H_ +#define _PMEMMAP_H_ + +typedef struct sPMemMapEnt tPMemMapEnt; + +enum ePMemMapEntType +{ + PMEMTYPE_FREE, // Free RAM + PMEMTYPE_USED, // Used by Kernel / Modules + PMEMTYPE_RESERVED, // Unavaliable + PMEMTYPE_NVRAM, // Non-volatile + PMEMTYPE_UNMAPPED // Nothing on these lines +}; + +struct sPMemMapEnt +{ + Uint64 Start; + Uint64 Length; + enum ePMemMapEntType Type; + Uint16 NUMADomain; +}; + +extern void PMemMap_DumpBlocks(tPMemMapEnt *map, int NEnts); +extern int PMemMap_SplitBlock(tPMemMapEnt *map, int NEnts, int MaxEnts, int Block, Uint64 Offset); +extern int PMemMap_CompactMap(tPMemMapEnt *map, int NEnts, int MaxEnts); +extern int PMemMap_ValidateMap(tPMemMapEnt *map, int NEnts, int MaxEnts); +extern int PMemMap_MarkRangeUsed(tPMemMapEnt *map, int NEnts, int MaxEnts, Uint64 Base, Uint64 Size); + +#endif + diff --git a/KernelLand/Kernel/include/vfs.h b/KernelLand/Kernel/include/vfs.h index 9cb9e5de..98bc0275 100644 --- a/KernelLand/Kernel/include/vfs.h +++ b/KernelLand/Kernel/include/vfs.h @@ -20,6 +20,7 @@ #define _VFS_H #include +#include /** * \brief Thread list datatype for VFS_Select @@ -77,7 +78,15 @@ typedef struct sVFS_NodeType tVFS_NodeType; * is unmapped. Nice for read-only files and memory-only files (or * pseudo-readonly filesystems) */ -#define VFS_FFLAG_NOWRITEBACK +#define VFS_FFLAG_NOWRITEBACK 0x1000 + +/** + * \brief "Dirty Metadata" Flag + * + * Indicates that the node's metadata has been altered since the flag was last + * cleared. Tells the driver that it should update the inode at the next flush. + */ +#define VFS_FFLAG_DIRTY 0x8000 /** * \} */ diff --git a/KernelLand/Kernel/libc.c b/KernelLand/Kernel/libc.c index c6ada1e9..08ebc623 100644 --- a/KernelLand/Kernel/libc.c +++ b/KernelLand/Kernel/libc.c @@ -688,7 +688,6 @@ int rand(void) void *memmove(void *__dest, const void *__src, size_t len) { - size_t block_size; char *dest = __dest; const char *src = __src; void *ret = __dest; @@ -705,6 +704,8 @@ void *memmove(void *__dest, const void *__src, size_t len) if( (tVAddr)dest < (tVAddr)src ) return memcpy(dest, src, len); + #if 0 + size_t block_size; if( (tVAddr)dest < (tVAddr)src ) block_size = (tVAddr)src - (tVAddr)dest; else @@ -721,6 +722,13 @@ void *memmove(void *__dest, const void *__src, size_t len) } memcpy(dest, src, len); return ret; + #else + for( int i = len; i--; ) + { + dest[i] = src[i]; + } + return ret; + #endif } @@ -739,7 +747,7 @@ int CheckString(const char *String) addr = (tVAddr)String; - if( !MM_GetPhysAddr( addr ) ) + if( !MM_GetPhysAddr( (void*)addr ) ) return 0; // Check 1st page @@ -751,7 +759,7 @@ int CheckString(const char *String) { if(bUser && !MM_IsUser(addr) ) return 0; - if(!bUser && !MM_GetPhysAddr(addr) ) + if(!bUser && !MM_GetPhysAddr((void*)addr) ) return 0; } addr ++; diff --git a/KernelLand/Kernel/modules.c b/KernelLand/Kernel/modules.c index 8202b086..544e8661 100644 --- a/KernelLand/Kernel/modules.c +++ b/KernelLand/Kernel/modules.c @@ -8,6 +8,7 @@ #define USE_EDI 0 #define USE_UDI 0 +#define MODULE_FLAG_LOADERROR 0x1 // === PROTOTYPES === int Module_int_Initialise(tModule *Module, const char *ArgString); @@ -80,6 +81,15 @@ int Module_int_Initialise(tModule *Module, const char *ArgString) "Module %p (%s) is for another architecture (%i)", Module, Module->Name, Module->Arch ); + LEAVE('i', MODULE_ERR_BADMODULE); + return MODULE_ERR_BADMODULE; + } + + LOG("Module->Flags = %x", Module->Flags); + if(Module->Flags & MODULE_FLAG_LOADERROR ) { + Log_Warning("Module", "%s has already attempted to load and encountered errors", Module->Name); + LEAVE('i', MODULE_ERR_MISC); + return MODULE_ERR_MISC; } deps = Module->Dependencies; @@ -177,6 +187,7 @@ int Module_int_Initialise(tModule *Module, const char *ArgString) Log_Warning("Module", "Unable to load reason - Unknown code %i", ret); break; } + Module->Flags |= MODULE_FLAG_LOADERROR; LEAVE_RET('i', ret); return ret; } diff --git a/KernelLand/Kernel/pmemmap.c b/KernelLand/Kernel/pmemmap.c new file mode 100644 index 00000000..21ced24d --- /dev/null +++ b/KernelLand/Kernel/pmemmap.c @@ -0,0 +1,196 @@ +/* + * Acess2 Kernel + * - By John Hodge (thePowersGang) + * + * pmemmap.c + * - Physical memory map manipulation + */ +#define DEBUG 0 +#include +#include + +// === CODE === +void PMemMap_DumpBlocks(tPMemMapEnt *map, int NEnts) +{ + for( int i = 0; i < NEnts; i ++ ) + { + Log_Debug("PMemMap", "%i: %i 0x%02x %08llx+%llx", + i, map[i].Type, map[i].NUMADomain, + map[i].Start, map[i].Length + ); + } +} + +int PMemMap_SplitBlock(tPMemMapEnt *map, int NEnts, int MaxEnts, int Block, Uint64 Offset) +{ + LOG("Splitting %i (%llx+%llx) at %llx", Block, map[Block].Start, map[Block].Length, Offset); + + Uint64 _len = map[Block].Length; + map[Block].Length = Offset; + if( NEnts == MaxEnts ) { + // out of space + return NEnts; + } + if( Block < NEnts ) { + LOG("Moving %i entries from %i to %i", (NEnts - Block-1), Block+1, Block); + memmove(&map[Block+2], &map[Block+1], (NEnts - Block)*sizeof(map[0])); + } + Block ++; + NEnts ++; + + // New (free) block + map[Block].Start = map[Block-1].Start + Offset; + map[Block].Length = _len - Offset; + map[Block].Type = map[Block-1].Type; + map[Block].NUMADomain = map[Block-1].NUMADomain; + LOG("- New %i %02x %llx+%llx", map[Block].Type, map[Block].NUMADomain, map[Block].Start, map[Block].Length); + + return NEnts; +} + +int PMemMap_CompactMap(tPMemMapEnt *map, int NEnts, int MaxEnts) +{ + for( int i = 1; i < NEnts; i ++ ) + { + // Check if the ranges are contiguous + if( map[i-1].Start + map[i-1].Length < map[i].Start ) + continue ; + // Check if the type is the same + if( map[i-1].Type != map[i].Type ) + continue ; + // Check if the NUMA Domains are the same + if( map[i-1].NUMADomain != map[i].NUMADomain ) + continue ; + + // Ok, they should be together + map[i-1].Length += map[i].Length; + memmove(&map[i], &map[i+1], (NEnts - (i+1))*sizeof(map[0])); + LOG("Joined %i and %i into %llx+%llx", i-1, i, map[i-1].Start, map[i-1].Length); + + // Counteract the i++ in the loop iterator + i --; + NEnts --; + } + return NEnts; +} + +int PMemMap_ValidateMap(tPMemMapEnt *map, int NEnts, int MaxEnts) +{ + // Sort the pmem map + int bNeedsSort = 0; + for( int i = 1; i < NEnts; i ++ ) + { + if( map[i-1].Start > map[i].Start ) { + bNeedsSort = 1; + break; + } + } + if( bNeedsSort ) + { + // Use a selection/swap sort + for( int i = 0; i < NEnts; i ++ ) + { + int sel = i; + for( int j = i+1; j < NEnts; j ++ ) + { + if( map[j].Start < map[sel].Start ) + sel = j; + } + if( sel != i ) { + LOG("Swapping %i and %i", i, sel); + LOG(" - %llx+%llx", map[i].Start, map[i].Length); + LOG(" - %llx+%llx", map[sel].Start, map[sel].Length); + tPMemMapEnt tmp = map[i]; + map[i] = map[sel]; + map[sel] = tmp; + } + } + } + + // Ensure that the map has no overlaps + for( int i = 1; i < NEnts; i ++ ) + { + if( map[i-1].Start + map[i-1].Length <= map[i].Start ) + continue ; + // Oops, overlap! + Log_Notice("Arch", "Map ranges %llx+%llx and %llx+%llx overlap", + map[i-1].Start, map[i-1].Length, + map[i].Start, map[i].Length + ); + } + + NEnts = PMemMap_CompactMap(map, NEnts, MaxEnts); + return NEnts; +} + + +int PMemMap_MarkRangeUsed(tPMemMapEnt *map, int NEnts, int MaxEnts, Uint64 Base, Uint64 Size) +{ + int first; + + Size = (Size + 0xFFF) & ~0xFFF; + Base = Base & ~0xFFF; + + first = -1; + for( int i = 0; i < NEnts; i ++ ) + { + if( map[i].Start + map[i].Length > Base ) { + first = i; + break; + } + } + if( first == -1 ) { + // Not in map + LOG("%llx+%llx not in map (past end)", Base, Size); + return NEnts; + } + + if( map[first].Start > Base ) { + // Not in map + LOG("%llx+%llx not in map (in hole)", Base, Size); + return NEnts; + } + + // Detect single + if( map[first].Start <= Base && Base + Size <= map[first].Start + map[first].Length ) + { + // Split before + if( map[first].Start < Base ) + { + if( NEnts == MaxEnts ) { + // out of space... oops + return NEnts; + } + NEnts = PMemMap_SplitBlock(map, NEnts, MaxEnts, first, Base - map[first].Start); + first ++; + } + + // map[first].Start == Base + // Split after + if( map[first].Length > Size ) + { + if( NEnts == MaxEnts ) { + // out of space + return NEnts; + } + NEnts = PMemMap_SplitBlock(map, NEnts, MaxEnts, first, Size); + } + + // map[first] is now exactly the block + map[first].Type = PMEMTYPE_USED; + + return PMemMap_CompactMap(map, NEnts, MaxEnts); + } + else + { + // Wait... this should never happen, right? + Log_Notice("Arch", "Module %llx+%llx overlaps two or more ranges", + Base, Size); + PMemMap_DumpBlocks(map, NEnts); + // TODO: Error? + return NEnts; + } +} + + + diff --git a/KernelLand/Kernel/syscalls.c b/KernelLand/Kernel/syscalls.c index 5580187d..d629ae4e 100644 --- a/KernelLand/Kernel/syscalls.c +++ b/KernelLand/Kernel/syscalls.c @@ -102,7 +102,7 @@ void SyscallHandler(tSyscallRegs *Regs) // -- Get the physical address of a page case SYS_GETPHYS: - ret = MM_GetPhysAddr(Regs->Arg1); + ret = MM_GetPhysAddr( (void*)Regs->Arg1 ); break; // -- Map an address diff --git a/KernelLand/Kernel/system.c b/KernelLand/Kernel/system.c index db7da340..aa1cad82 100644 --- a/KernelLand/Kernel/system.c +++ b/KernelLand/Kernel/system.c @@ -162,7 +162,7 @@ void System_ParseVFS(char *Arg) // - Symbolic Link = if(value[0] == '/') { - Log_Log("Config", "Symbolic link '%s' pointing to '%s'", Arg, value); +// Log_Log("Config", "Symbolic link '%s' pointing to '%s'", Arg, value); VFS_Symlink(Arg, value); } // - Mount =: @@ -177,13 +177,13 @@ void System_ParseVFS(char *Arg) } // Create Mountpoint if( (fd = VFS_Open(Arg, 0)) == -1 ) { - Log_Log("Config", "Creating directory '%s'", Arg, value); +// Log_Log("Config", "Creating directory '%s'", Arg, value); VFS_MkDir( Arg ); } else { VFS_Close(fd); } // Mount - Log_Log("Config", "Mounting '%s' to '%s' ('%s')", dev, Arg, value); +// Log_Log("Config", "Mounting '%s' to '%s' ('%s')", dev, Arg, value); VFS_Mount(dev, Arg, value, ""); } } diff --git a/KernelLand/Kernel/vfs/handle.c b/KernelLand/Kernel/vfs/handle.c index 6d2b83fb..8cae8040 100644 --- a/KernelLand/Kernel/vfs/handle.c +++ b/KernelLand/Kernel/vfs/handle.c @@ -60,7 +60,7 @@ int VFS_AllocHandle(int bIsUser, tVFS_Node *Node, int Mode) { int max_handles = *Threads_GetMaxFD(); // Allocate Buffer - if( MM_GetPhysAddr( (tVAddr)gaUserHandles ) == 0 ) + if( MM_GetPhysAddr( gaUserHandles ) == 0 ) { Uint addr, size; size = max_handles * sizeof(tVFS_Handle); @@ -87,7 +87,7 @@ int VFS_AllocHandle(int bIsUser, tVFS_Node *Node, int Mode) else { // Allocate space if not already - if( MM_GetPhysAddr( (tVAddr)gaKernelHandles ) == 0 ) + if( MM_GetPhysAddr( gaKernelHandles ) == 0 ) { Uint addr, size; size = MAX_KERNEL_FILES * sizeof(tVFS_Handle); @@ -121,7 +121,7 @@ void VFS_ReferenceUserHandles(void) int max_handles = *Threads_GetMaxFD(); // Check if this process has any handles - if( MM_GetPhysAddr( (tVAddr)gaUserHandles ) == 0 ) + if( MM_GetPhysAddr( gaUserHandles ) == 0 ) return ; for( i = 0; i < max_handles; i ++ ) @@ -141,7 +141,7 @@ void VFS_CloseAllUserHandles(void) int max_handles = *Threads_GetMaxFD(); // Check if this process has any handles - if( MM_GetPhysAddr( (tVAddr)gaUserHandles ) == 0 ) + if( MM_GetPhysAddr( gaUserHandles ) == 0 ) return ; for( i = 0; i < max_handles; i ++ ) @@ -165,7 +165,7 @@ void *VFS_SaveHandles(int NumFDs, int *FDs) int max_handles = *Threads_GetMaxFD(); // Check if this process has any handles - if( MM_GetPhysAddr( (tVAddr)gaUserHandles ) == 0 ) + if( MM_GetPhysAddr( gaUserHandles ) == 0 ) return NULL; // Allocate @@ -214,7 +214,7 @@ void VFS_RestoreHandles(int NumFDs, void *Handles) return ; // Check if there is already a set of handles - if( MM_GetPhysAddr( (tVAddr)gaUserHandles ) != 0 ) + if( MM_GetPhysAddr( gaUserHandles ) != 0 ) return ; diff --git a/KernelLand/Kernel/vfs/mmap.c b/KernelLand/Kernel/vfs/mmap.c index 61288695..c5015e67 100644 --- a/KernelLand/Kernel/vfs/mmap.c +++ b/KernelLand/Kernel/vfs/mmap.c @@ -50,7 +50,7 @@ void *VFS_MMap(void *DestHint, size_t Length, int Protection, int Flags, int FD, LOG("%i pages anonymous to %p", npages, mapping_dest); for( ; npages --; mapping_dest += PAGE_SIZE, ofs += PAGE_SIZE ) { - if( MM_GetPhysAddr(mapping_dest) ) { + if( MM_GetPhysAddr((void*)mapping_dest) ) { // TODO: Set flags to COW if needed (well, if shared) MM_SetFlags(mapping_dest, MM_PFLAG_COW, MM_PFLAG_COW); LOG("clear from %p, %i bytes", (void*)(mapping_base + ofs), @@ -109,7 +109,7 @@ void *VFS_MMap(void *DestHint, size_t Length, int Protection, int Flags, int FD, // - Map (and allocate) pages while( npages -- ) { - if( MM_GetPhysAddr(mapping_dest) == 0 ) + if( MM_GetPhysAddr( (void*)mapping_dest ) == 0 ) { if( pb->PhysAddrs[pagenum - pb->BaseOffset] == 0 ) { @@ -132,11 +132,12 @@ void *VFS_MMap(void *DestHint, size_t Length, int Protection, int Flags, int FD, } // TODO: Clip read length read_len = nt->Read(h->Node, pagenum*PAGE_SIZE, PAGE_SIZE, (void*)mapping_dest); -// if( read_len != PAGE_SIZE ) { -// memset( (void*)(mapping_dest+read_len), 0, PAGE_SIZE-read_len ); -// } + // TODO: This was commented out, why? + if( read_len != PAGE_SIZE ) { + memset( (void*)(mapping_dest+read_len), 0, PAGE_SIZE-read_len ); + } } - pb->PhysAddrs[pagenum - pb->BaseOffset] = MM_GetPhysAddr( mapping_dest ); + pb->PhysAddrs[pagenum - pb->BaseOffset] = MM_GetPhysAddr( (void*)mapping_dest ); MM_SetPageNode( pb->PhysAddrs[pagenum - pb->BaseOffset], h->Node ); MM_RefPhys( pb->PhysAddrs[pagenum - pb->BaseOffset] ); LOG("Read and map %X to %p (%P)", pagenum*PAGE_SIZE, mapping_dest, diff --git a/KernelLand/Modules/Display/VESA/main.c b/KernelLand/Modules/Display/VESA/main.c index 71cd72bf..13fe798a 100644 --- a/KernelLand/Modules/Display/VESA/main.c +++ b/KernelLand/Modules/Display/VESA/main.c @@ -367,6 +367,8 @@ int Vesa_Int_SetMode(int mode) Mutex_Release( &glVesa_Lock ); + gVesa_BufInfo.BackBuffer = realloc(gVesa_BufInfo.BackBuffer, + gVesa_Modes[mode].height * gVesa_Modes[mode].pitch); gVesa_BufInfo.Framebuffer = gpVesa_Framebuffer; gVesa_BufInfo.Pitch = gVesa_Modes[mode].pitch; gVesa_BufInfo.Width = gVesa_Modes[mode].width; diff --git a/KernelLand/Modules/Filesystems/Ext2/dir.c b/KernelLand/Modules/Filesystems/Ext2/dir.c index 0887ed28..4039a7c0 100644 --- a/KernelLand/Modules/Filesystems/Ext2/dir.c +++ b/KernelLand/Modules/Filesystems/Ext2/dir.c @@ -61,14 +61,14 @@ char *Ext2_ReadDir(tVFS_Node *Node, int Pos) Ext2_int_ReadInode(disk, Node->Inode, &inode); size = inode.i_size; - LOG("inode.i_block[0] = 0x%x", inode.i_block[0]); + LOG("inode={.i_block[0]= 0x%x, .i_size=0x%x}", inode.i_block[0], inode.i_size); // Find Entry // Get First Block // - Do this ourselves as it is a simple operation Base = inode.i_block[0] * disk->BlockSize; // Scan directory - while(Pos -- && size > 0) + while(Pos -- && size > 0 && size <= inode.i_size) { VFS_ReadAt( disk->FD, Base+ofs, sizeof(tExt2_DirEnt), &dirent); ofs += dirent.rec_len; @@ -83,22 +83,29 @@ char *Ext2_ReadDir(tVFS_Node *Node, int Pos) } ofs = 0; Base = Ext2_int_GetBlockAddr( disk, inode.i_block, block ); + if( Base == 0 ) { + size = 0; + break; + } } } // Check for the end of the list - if(size <= 0) { + if(size <= 0 || size > inode.i_size) { LEAVE('n'); return NULL; } // Read Entry VFS_ReadAt( disk->FD, Base+ofs, sizeof(tExt2_DirEnt), &dirent ); - //LOG("dirent.inode = %i", dirent.inode); - //LOG("dirent.rec_len = %i", dirent.rec_len); - //LOG("dirent.name_len = %i", dirent.name_len); + LOG("dirent={.rec_len=%i,.inode=0x%x,.name_len=%i}", + dirent.rec_len, dirent.inode, dirent.name_len); dirent.name[ dirent.name_len ] = '\0'; // Cap off string + if( dirent.name_len == 0 ) { + LEAVE('p', VFS_SKIP); + return VFS_SKIP; + } // Ignore . and .. (these are done in the VFS) if( (dirent.name[0] == '.' && dirent.name[1] == '\0') @@ -172,34 +179,32 @@ tVFS_Node *Ext2_FindDir(tVFS_Node *Node, const char *Filename) */ int Ext2_MkNod(tVFS_Node *Parent, const char *Name, Uint Flags) { - #if 0 - tVFS_Node *child; - Uint64 inodeNum; - tExt2_Inode inode; - inodeNum = Ext2_int_AllocateInode(Parent->ImplPtr, Parent->Inode); + ENTER("pParent sName xFlags", Parent, Name, Flags); - memset(&inode, 0, sizeof(tExt2_Inode)); - - // File type - inode.i_mode = 0664; - if( Flags & VFS_FFLAG_READONLY ) - inode.i_mode &= ~0222; - if( Flags & VFS_FFLAG_SYMLINK ) - inode.i_mode |= EXT2_S_IFLNK; - else if( Flags & VFS_FFLAG_DIRECTORY ) - inode.i_mode |= EXT2_S_IFDIR | 0111; - - inode.i_uid = Threads_GetUID(); - inode.i_gid = Threads_GetGID(); - inode.i_ctime = - inode.i_mtime = - inode.i_atime = now() / 1000; - - child = Ext2_int_CreateNode(Parent->ImplPtr, inodeNum); - return Ext2_Link(Parent, child, Name); - #else - return 1; - #endif + Uint64 inodeNum = Ext2_int_AllocateInode(Parent->ImplPtr, Parent->Inode); + if( inodeNum == 0 ) { + return -1; + } + tVFS_Node *child = Ext2_int_CreateNode(Parent->ImplPtr, inodeNum); + if( !child ) { + Ext2_int_DereferenceInode(Parent->ImplPtr, inodeNum); + return -1; + } + + child->Flags = Flags & (VFS_FFLAG_DIRECTORY|VFS_FFLAG_SYMLINK|VFS_FFLAG_READONLY); + child->UID = Threads_GetUID(); + child->GID = Threads_GetGID(); + child->CTime = + child->MTime = + child->ATime = + now(); + child->ImplInt = 0; // ImplInt is the link count + // TODO: Set up ACLs + + int rv = Ext2_Link(Parent, Name, child); + child->Type->Close(child); + LEAVE('i', rv); + return rv; } /** @@ -344,7 +349,8 @@ tVFS_Node *Ext2_int_CreateNode(tExt2_Disk *Disk, Uint InodeID) if( (tmpNode = Inode_GetCache(Disk->CacheID, InodeID)) ) return tmpNode; - + + memset(&retNode, 0, sizeof(retNode)); // Set identifiers retNode.Inode = InodeID; @@ -352,7 +358,6 @@ tVFS_Node *Ext2_int_CreateNode(tExt2_Disk *Disk, Uint InodeID) // Set file length retNode.Size = inode.i_size; - retNode.Data = NULL; // Set Access Permissions retNode.UID = inode.i_uid; diff --git a/KernelLand/Modules/Filesystems/Ext2/ext2.c b/KernelLand/Modules/Filesystems/Ext2/ext2.c index 971ef28e..5c9f97a5 100644 --- a/KernelLand/Modules/Filesystems/Ext2/ext2.c +++ b/KernelLand/Modules/Filesystems/Ext2/ext2.c @@ -17,15 +17,16 @@ extern tVFS_NodeType gExt2_DirType; int Ext2_Install(char **Arguments); int Ext2_Cleanup(void); // - Interface Functions - int Ext2_Detect(int FD); + int Ext2_Detect(int FD); tVFS_Node *Ext2_InitDevice(const char *Device, const char **Options); -void Ext2_Unmount(tVFS_Node *Node); -void Ext2_CloseFile(tVFS_Node *Node); +void Ext2_Unmount(tVFS_Node *Node); +void Ext2_CloseFile(tVFS_Node *Node); // - Internal Helpers - int Ext2_int_GetInode(tVFS_Node *Node, tExt2_Inode *Inode); -Uint64 Ext2_int_GetBlockAddr(tExt2_Disk *Disk, Uint32 *Blocks, int BlockNum); -Uint32 Ext2_int_AllocateInode(tExt2_Disk *Disk, Uint32 Parent); -void Ext2_int_UpdateSuperblock(tExt2_Disk *Disk); + int Ext2_int_GetInode(tVFS_Node *Node, tExt2_Inode *Inode); +Uint64 Ext2_int_GetBlockAddr(tExt2_Disk *Disk, Uint32 *Blocks, int BlockNum); +Uint32 Ext2_int_AllocateInode(tExt2_Disk *Disk, Uint32 Parent); +void Ext2_int_DereferenceInode(tExt2_Disk *Disk, Uint32 Inode); +void Ext2_int_UpdateSuperblock(tExt2_Disk *Disk); // === SEMI-GLOBALS === MODULE_DEFINE(0, VERSION, FS_Ext2, Ext2_Install, Ext2_Cleanup); @@ -208,7 +209,29 @@ void Ext2_Unmount(tVFS_Node *Node) void Ext2_CloseFile(tVFS_Node *Node) { tExt2_Disk *disk = Node->ImplPtr; - Inode_UncacheNode(disk->CacheID, Node->Inode); + + if( Mutex_Acquire(&Node->Lock) != 0 ) + { + return ; + } + + if( Node->Flags & VFS_FFLAG_DIRTY ) + { + // Commit changes + } + + int was_not_referenced = (Node->ImplInt == 0); + tVFS_ACL *acls = Node->ACLs; + if( Inode_UncacheNode(disk->CacheID, Node->Inode) ) + { + if( was_not_referenced ) + { + // Remove inode + } + if( acls != &gVFS_ACL_EveryoneRW ) { + free(acls); + } + } return ; } @@ -337,6 +360,14 @@ Uint32 Ext2_int_AllocateInode(tExt2_Disk *Disk, Uint32 Parent) return 0; } +/** + * \brief Reduce the reference count on an inode + */ +void Ext2_int_DereferenceInode(tExt2_Disk *Disk, Uint32 Inode) +{ + +} + /** * \fn void Ext2_int_UpdateSuperblock(tExt2_Disk *Disk) * \brief Updates the superblock diff --git a/KernelLand/Modules/Filesystems/Ext2/ext2_common.h b/KernelLand/Modules/Filesystems/Ext2/ext2_common.h index 036cd59f..1d994ddb 100644 --- a/KernelLand/Modules/Filesystems/Ext2/ext2_common.h +++ b/KernelLand/Modules/Filesystems/Ext2/ext2_common.h @@ -32,6 +32,8 @@ typedef struct { extern void Ext2_CloseFile(tVFS_Node *Node); extern Uint64 Ext2_int_GetBlockAddr(tExt2_Disk *Disk, Uint32 *Blocks, int BlockNum); extern void Ext2_int_UpdateSuperblock(tExt2_Disk *Disk); +extern Uint32 Ext2_int_AllocateInode(tExt2_Disk *Disk, Uint32 Parent); +extern void Ext2_int_DereferenceInode(tExt2_Disk *Disk, Uint32 Inode); extern int Ext2_int_ReadInode(tExt2_Disk *Disk, Uint32 InodeId, tExt2_Inode *Inode); extern int Ext2_int_WriteInode(tExt2_Disk *Disk, Uint32 InodeId, tExt2_Inode *Inode); // --- Dir --- diff --git a/KernelLand/Modules/Filesystems/Ext2/write.c b/KernelLand/Modules/Filesystems/Ext2/write.c index 60b176ca..22e256bf 100644 --- a/KernelLand/Modules/Filesystems/Ext2/write.c +++ b/KernelLand/Modules/Filesystems/Ext2/write.c @@ -119,7 +119,12 @@ addBlocks: } base = block * disk->BlockSize; VFS_WriteAt(disk->FD, base, retLen, Buffer); + + // TODO: When should the size update be committed? inode.i_size += retLen; + Node->Size += retLen; + Node->Flags |= VFS_FFLAG_DIRTY; + retLen = 0; ret: // Makes sure the changes to the inode are committed diff --git a/KernelLand/Modules/Filesystems/InitRD/files.lst b/KernelLand/Modules/Filesystems/InitRD/files.lst index 6751147a..da00e999 100644 --- a/KernelLand/Modules/Filesystems/InitRD/files.lst +++ b/KernelLand/Modules/Filesystems/InitRD/files.lst @@ -1,6 +1,7 @@ Dir "SBin" { File "init" "__BIN__/SBin/init" File "login" "__BIN__/SBin/login" + File "telnetd" "__BIN__/SBin/telnetd" } Dir "Bin" { File "CLIShell" "__BIN__/Bin/CLIShell" diff --git a/KernelLand/Modules/Filesystems/InitRD/main.c b/KernelLand/Modules/Filesystems/InitRD/main.c index 02af0436..863a24a3 100644 --- a/KernelLand/Modules/Filesystems/InitRD/main.c +++ b/KernelLand/Modules/Filesystems/InitRD/main.c @@ -43,7 +43,6 @@ tVFS_NodeType gInitRD_FileType = { */ int InitRD_Install(char **Arguments) { - Log_Notice("InitRD", "Installed"); VFS_AddDriver( &gInitRD_FSInfo ); return MODULE_ERR_OK; @@ -57,7 +56,6 @@ tVFS_Node *InitRD_InitDevice(const char *Device, const char **Arguments) #if DUMP_ON_MOUNT InitRD_DumpDir( &gInitRD_RootNode, 0 ); #endif - Log_Notice("InitRD", "Mounted (%i files)", giInitRD_NumFiles); return &gInitRD_RootNode; } diff --git a/KernelLand/Modules/IPStack/include/adapters_api.h b/KernelLand/Modules/IPStack/include/adapters_api.h index 0ecd8473..78729986 100644 --- a/KernelLand/Modules/IPStack/include/adapters_api.h +++ b/KernelLand/Modules/IPStack/include/adapters_api.h @@ -10,6 +10,20 @@ #include "buffer.h" +enum eIPStack_AdapterTypes +{ + ADAPTERTYPE_ETHERNET_10M, + ADAPTERTYPE_ETHERNET_100M, + ADAPTERTYPE_ETHERNET_1G +}; + +// Checksum offloading +#define ADAPTERFLAG_OFFLOAD_MAC (1 << 0) +#define ADAPTERFLAG_OFFLOAD_IP4 (1 << 1) +#define ADAPTERFLAG_OFFLOAD_IP6 (1 << 2) +#define ADAPTERFLAG_OFFLOAD_TCP (1 << 3) +#define ADAPTERFLAG_OFFLOAD_UDP (1 << 4) + typedef struct sIPStack_AdapterType tIPStack_AdapterType; struct sIPStack_AdapterType diff --git a/KernelLand/Modules/Input/Keyboard/main.c b/KernelLand/Modules/Input/Keyboard/main.c index f49d8ea5..9c2e20e6 100644 --- a/KernelLand/Modules/Input/Keyboard/main.c +++ b/KernelLand/Modules/Input/Keyboard/main.c @@ -164,6 +164,15 @@ void Keyboard_HandleKey(tKeyboard *Source, Uint32 HIDKeySym) Uint32 flag; Uint8 layer; + if( !Source ) { + Log_Error("Keyboard", "Passed NULL handle"); + return ; + } + if( !Source->Node ) { + Log_Error("Keyboard", "Passed handle with NULL node"); + return ; + } + bPressed = !(HIDKeySym & (1 << 31)); HIDKeySym &= 0x7FFFFFFF; diff --git a/KernelLand/Modules/Input/PS2KbMouse/8042.c b/KernelLand/Modules/Input/PS2KbMouse/8042.c index e11bc74f..f71fff7f 100644 --- a/KernelLand/Modules/Input/PS2KbMouse/8042.c +++ b/KernelLand/Modules/Input/PS2KbMouse/8042.c @@ -36,11 +36,7 @@ void KBC8042_Init(void) void KBC8042_KeyboardHandler(int IRQ, void *Ptr) { - Uint8 scancode; - -// Log("KBC8042_KeyboardHandler: (IRQ=%i, Ptr=%p)", IRQ, Ptr); - - scancode = inb(0x60); + Uint8 scancode = inb(0x60); KB_HandleScancode( scancode ); } diff --git a/KernelLand/Modules/Network/E1000/Makefile b/KernelLand/Modules/Network/E1000/Makefile new file mode 100644 index 00000000..00a6e2ce --- /dev/null +++ b/KernelLand/Modules/Network/E1000/Makefile @@ -0,0 +1,9 @@ +# +# Acess2 Intel E1000 driver +# + +OBJ = e1000.o +NAME = E1000 + +-include ../Makefile.tpl + diff --git a/KernelLand/Modules/Network/E1000/e1000.c b/KernelLand/Modules/Network/E1000/e1000.c new file mode 100644 index 00000000..b225d3dd --- /dev/null +++ b/KernelLand/Modules/Network/E1000/e1000.c @@ -0,0 +1,60 @@ +/* + * Acess2 E1000 Network Driver + * - By John Hodge (thePowersGang) + * + * e1000.c + * - Intel E1000 Network Card Driver (core) + */ +#define DEBUG 1 +#define VERSION VER2(0,1) +#include +#include "e1000.h" +#include +#include +#include + +// === PROTOTYPES === + int E1000_Install(char **Arguments); + int E1000_Cleanup(void); +tIPStackBuffer *E1000_WaitForPacket(void *Ptr); + int E1000_SendPacket(void *Ptr, tIPStackBuffer *Buffer); +void E1000_IRQHandler(int Num, void *Ptr); + +// === GLOBALS === +MODULE_DEFINE(0, VERSION, E1000, E1000_Install, E1000_Cleanup, NULL); +tIPStack_AdapterType gE1000_AdapterType = { + .Name = "E1000", + .Type = 0, // TODO: Differentiate differnet wire protos and speeds + .Flags = 0, // TODO: IP checksum offloading, MAC checksum offloading etc + .SendPacket = E1000_SendPacket, + .WaitForPacket = E1000_WaitForPacket + }; + +// === CODE === +int E1000_Install(char **Arguments) +{ + for( int id = -1; (id = PCI_GetDevice(0x8086, 0x100E, id)) != -1; ) + { + + } + return MODULE_ERR_NOTNEEDED; +} + +int E1000_Cleanup(void) +{ + return 0; +} + +tIPStackBuffer *E1000_WaitForPacket(void *Ptr) +{ + return NULL; +} + +int E1000_SendPacket(void *Ptr, tIPStackBuffer *Buffer) +{ + return -1; +} + +void E1000_IRQHandler(int Num, void *Ptr) +{ +} diff --git a/KernelLand/Modules/Network/E1000/e1000.h b/KernelLand/Modules/Network/E1000/e1000.h new file mode 100644 index 00000000..d8b864ff --- /dev/null +++ b/KernelLand/Modules/Network/E1000/e1000.h @@ -0,0 +1,14 @@ +/* + * Acess2 E1000 Network Driver + * - By John Hodge (thePowersGang) + * + * e1000.h + * - Driver core header + */ +#ifndef _E1000_H_ +#define _E1000_H_ + + + +#endif + diff --git a/KernelLand/Modules/Network/VIARhineII/rhine2.c b/KernelLand/Modules/Network/VIARhineII/rhine2.c index a1686f7e..f9f4d254 100644 --- a/KernelLand/Modules/Network/VIARhineII/rhine2.c +++ b/KernelLand/Modules/Network/VIARhineII/rhine2.c @@ -330,7 +330,7 @@ int Rhine2_SendPacket(void *Ptr, tIPStackBuffer *Buffer) card->NextTX = (card->NextTX + nDescs) % N_TX_DESCS; desc = card->TXDescs + first_desc_id; - desc->TXBufferStart = MM_GetPhysAddr( (tVAddr)data ); + desc->TXBufferStart = MM_GetPhysAddr( data ); desc->BufferSize = len | (1 << 15); desc->TSR = 0; desc->TCR = 0; diff --git a/KernelLand/Modules/Storage/ATA/io.c b/KernelLand/Modules/Storage/ATA/io.c index 89f1a464..0ed5e374 100644 --- a/KernelLand/Modules/Storage/ATA/io.c +++ b/KernelLand/Modules/Storage/ATA/io.c @@ -148,16 +148,16 @@ int ATA_SetupIO(void) IRQ_AddHandler( gATA_IRQPri, ATA_IRQHandlerPri, NULL ); IRQ_AddHandler( gATA_IRQSec, ATA_IRQHandlerSec, NULL ); - gATA_PRDTs[0].PBufAddr = MM_GetPhysAddr( (tVAddr)&gATA_Buffers[0] ); - gATA_PRDTs[1].PBufAddr = MM_GetPhysAddr( (tVAddr)&gATA_Buffers[1] ); + gATA_PRDTs[0].PBufAddr = MM_GetPhysAddr( &gATA_Buffers[0] ); + gATA_PRDTs[1].PBufAddr = MM_GetPhysAddr( &gATA_Buffers[1] ); LOG("gATA_PRDTs = {PBufAddr: 0x%x, PBufAddr: 0x%x}", gATA_PRDTs[0].PBufAddr, gATA_PRDTs[1].PBufAddr); - gaATA_PRDT_PAddrs[0] = MM_GetPhysAddr( (tVAddr)&gATA_PRDTs[0] ); + gaATA_PRDT_PAddrs[0] = MM_GetPhysAddr( &gATA_PRDTs[0] ); LOG("gaATA_PRDT_PAddrs[0] = 0x%x", gaATA_PRDT_PAddrs[0]); ATA_int_BusMasterWriteDWord(4, gaATA_PRDT_PAddrs[0]); - gaATA_PRDT_PAddrs[1] = MM_GetPhysAddr( (tVAddr)&gATA_PRDTs[1] ); + gaATA_PRDT_PAddrs[1] = MM_GetPhysAddr( &gATA_PRDTs[1] ); LOG("gaATA_PRDT_PAddrs[1] = 0x%x", gaATA_PRDT_PAddrs[1]); ATA_int_BusMasterWriteDWord(12, gaATA_PRDT_PAddrs[1]); diff --git a/KernelLand/Modules/USB/Core/main.c b/KernelLand/Modules/USB/Core/main.c index 6ef7a2bb..94ec2531 100644 --- a/KernelLand/Modules/USB/Core/main.c +++ b/KernelLand/Modules/USB/Core/main.c @@ -43,8 +43,6 @@ tDevFS_Driver gUSB_DrvInfo = { */ int USB_Install(char **Arguments) { - Log_Warning("USB", "Not Complete - Devel Only"); - Proc_SpawnWorker(USB_PollThread, NULL); Proc_SpawnWorker(USB_AsyncThread, NULL); diff --git a/KernelLand/Modules/USB/UHCI/uhci.c b/KernelLand/Modules/USB/UHCI/uhci.c index e57a1c30..257171a8 100644 --- a/KernelLand/Modules/USB/UHCI/uhci.c +++ b/KernelLand/Modules/USB/UHCI/uhci.c @@ -191,7 +191,7 @@ int UHCI_int_InitHost(tUHCI_Controller *Host) 1,17,9,25,5,21,13,29,3,19,11,27,7,23,15,31 }; for( int i = 0; i < 1024; i ++ ) { - Uint32 addr = MM_GetPhysAddr( (tVAddr)&Host->TDQHPage->ControlQH ); + Uint32 addr = MM_GetPhysAddr( &Host->TDQHPage->ControlQH ); Host->FrameList[i] = addr | 2; } for( int i = 0; i < 64; i ++ ) { @@ -220,12 +220,12 @@ int UHCI_int_InitHost(tUHCI_Controller *Host) dest += _count; destphys += _count * sizeof(tUHCI_QH); } // Skip padding, and move to control QH - dest->Next = MM_GetPhysAddr( (tVAddr)&Host->TDQHPage->BulkQH ) | 2; + dest->Next = MM_GetPhysAddr( &Host->TDQHPage->BulkQH ) | 2; dest->Child = 1; } // Set up control and bulk queues - Host->TDQHPage->ControlQH.Next = MM_GetPhysAddr( (tVAddr)&Host->TDQHPage->BulkQH ) | 2; + Host->TDQHPage->ControlQH.Next = MM_GetPhysAddr( &Host->TDQHPage->BulkQH ) | 2; Host->TDQHPage->ControlQH.Child = 1; Host->TDQHPage->BulkQH.Next = 1; Host->TDQHPage->BulkQH.Child = 1; @@ -297,11 +297,11 @@ void UHCI_int_AppendTD(tUHCI_Controller *Cont, tUHCI_QH *QH, tUHCI_TD *TD) // Add TD->Link = 1; if( QH->Child & 1 ) { - QH->Child = MM_GetPhysAddr( (tVAddr)TD ); + QH->Child = MM_GetPhysAddr( TD ); } else { // Depth first - QH->_LastItem->Link = MM_GetPhysAddr( (tVAddr)TD ) | 4; + QH->_LastItem->Link = MM_GetPhysAddr( TD ) | 4; } QH->_LastItem = TD; @@ -360,7 +360,7 @@ tUHCI_TD *UHCI_int_CreateTD( if( ((tVAddr)Data & (PAGE_SIZE-1)) + Length > PAGE_SIZE #if PHYS_BITS > 32 - || MM_GetPhysAddr( (tVAddr)Data ) >> 32 + || MM_GetPhysAddr( Data ) >> 32 #endif ) { @@ -373,8 +373,8 @@ tUHCI_TD *UHCI_int_CreateTD( LOG("Relocated IN"); info = calloc( sizeof(tUHCI_ExtraTDInfo), 1 ); info->Offset = ((tVAddr)Data & (PAGE_SIZE-1)); - info->FirstPage = MM_GetPhysAddr( (tVAddr)Data ); - info->SecondPage = MM_GetPhysAddr( (tVAddr)Data + Length - 1 ); + info->FirstPage = MM_GetPhysAddr( Data ); + info->SecondPage = MM_GetPhysAddr( (const char *)Data + Length - 1 ); } else { @@ -388,7 +388,7 @@ tUHCI_TD *UHCI_int_CreateTD( } else { - td->BufferPointer = MM_GetPhysAddr( (tVAddr)Data ); + td->BufferPointer = MM_GetPhysAddr( Data ); td->_info.bFreePointer = 0; } @@ -661,7 +661,7 @@ tUHCI_TD *UHCI_int_GetTDFromPhys(tUHCI_Controller *Controller, Uint32 PAddr) } - tPAddr global_pool = MM_GetPhysAddr( (tVAddr)gaUHCI_TDPool ); + tPAddr global_pool = MM_GetPhysAddr( gaUHCI_TDPool ); if( PAddr < global_pool || PAddr >= global_pool + PAGE_SIZE ) return NULL; diff --git a/Makefile b/Makefile index 03295275..01b09064 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ USRLIBS += libimage_sif.so USRAPPS := init login CLIShell cat ls mount USRAPPS += bomb dhcpclient -USRAPPS += ip ping telnet irc wget +USRAPPS += ip ping telnet irc wget telnetd USRAPPS += axwin3 ALL_DYNMODS = $(addprefix all-,$(DYNMODS)) diff --git a/Tools/DiskTool/src/Makefile b/Tools/DiskTool/src/Makefile index a1282ac1..e91bc7f8 100644 --- a/Tools/DiskTool/src/Makefile +++ b/Tools/DiskTool/src/Makefile @@ -93,6 +93,7 @@ $(BUILDINFO_SRC): $(filter-out $(BUILDINFO_OBJ), $(OBJ)) Makefile @echo "const char gsKernelVersion[] = \"$(ACESS_VERSION)\";" >> $@ @echo "const char gsGitHash[] = \""`git log -n 1 | head -n 1 | awk '{print $$2}'`"\";" >> $@ @echo "const int giBuildNumber = $(BUILD_NUM);" >> $@ + @echo "const char gsBuildInfo[] = \"Acess2 DiskTool v$(ACESS_VERSION)\";" >> $@ $(BUILDINFO_OBJ): $(BUILDINFO_SRC) @echo [CC] -o $@ @$(CC) -o $@ -c $< $(CFLAGS) $(CPPFLAGS) diff --git a/Tools/DiskTool/src/actions.c b/Tools/DiskTool/src/actions.c index d1fb7034..e63ae612 100644 --- a/Tools/DiskTool/src/actions.c +++ b/Tools/DiskTool/src/actions.c @@ -95,6 +95,11 @@ int DiskTool_MountImage(const char *Identifier, const char *Path) return VFS_Mount(tpath, mountpoint, "", ""); } +int DiskTool_MkDir(const char *Directory) +{ + return -1; +} + int DiskTool_Copy(const char *Source, const char *Destination) { int src = DiskTool_int_TranslateOpen(Source, VFS_OPENFLAG_READ); diff --git a/Tools/DiskTool/src/helpers.c b/Tools/DiskTool/src/helpers.c index f3266775..f9e3bc4a 100644 --- a/Tools/DiskTool/src/helpers.c +++ b/Tools/DiskTool/src/helpers.c @@ -22,12 +22,21 @@ size_t DiskTool_int_TranslatePath(char *Buffer, const char *Path) if( Path[0] == '#' ) { - if(Buffer) + len = strlen(Path+1); + if(Buffer) { strcpy(Buffer, Path+1); - return strlen(Path) - 1; + } } - - if( colon ) + else if( Path[0] == ':' ) + { + len = strlen("/Devices/LVM/"); + len += strlen(Path+1); + if(Buffer) { + strcpy(Buffer, "/Devices/LVM/"); + strcat(Buffer, Path+1); + } + } + else if( colon ) { const char *pos; for(pos = Path; pos < colon; pos ++) @@ -43,23 +52,23 @@ size_t DiskTool_int_TranslatePath(char *Buffer, const char *Path) strncat(Buffer+strlen("/Mount/"), Path, colon - Path); strcat(Buffer, colon + 1); } - return len; } + else + { + native_path: + if( !gsWorkingDirectory[0] ) { + getcwd(gsWorkingDirectory, 1024); + } -native_path: - - if( !gsWorkingDirectory[0] ) { - getcwd(gsWorkingDirectory, 1024); - } - - len = strlen("/Native"); - len += strlen( gsWorkingDirectory ) + 1; - len += strlen(Path); - if( Buffer ) { - strcpy(Buffer, "/Native"); - strcat(Buffer, gsWorkingDirectory); - strcat(Buffer, "/"); - strcat(Buffer, Path); + len = strlen("/Native"); + len += strlen( gsWorkingDirectory ) + 1; + len += strlen(Path); + if( Buffer ) { + strcpy(Buffer, "/Native"); + strcat(Buffer, gsWorkingDirectory); + strcat(Buffer, "/"); + strcat(Buffer, Path); + } } return len; } diff --git a/Tools/DiskTool/src/include/acess.h b/Tools/DiskTool/src/include/acess.h index 16009a48..ff2347bd 100644 --- a/Tools/DiskTool/src/include/acess.h +++ b/Tools/DiskTool/src/include/acess.h @@ -18,6 +18,7 @@ extern char __buildnum[]; #define BUILD_NUM ((int)(Uint)&__buildnum) extern const char gsGitHash[]; +extern const char gsBuildInfo[]; #define BITS 32 #define NULL ((void*)0) @@ -48,7 +49,6 @@ typedef uint32_t tGID; typedef uint32_t tTID; // NOTE: Since this is single-threaded (for now) mutexes can be implimented as simple locks -typedef char tMutex; typedef char tShortSpinlock; typedef int64_t tTime; @@ -126,13 +126,6 @@ extern int WriteUTF8(Uint8 *str, Uint32 Val); extern int DivUp(int value, int divisor); extern uint64_t DivMod64U(uint64_t Num, uint64_t Den, uint64_t *Rem); -static inline int Mutex_Acquire(tMutex *m) { - if(*m) Log_KernelPanic("---", "Double mutex lock"); - *m = 1; - return 0; -} -static inline void Mutex_Release(tMutex *m) { *m = 0; } - static inline void SHORTLOCK(tShortSpinlock *Lock) { if(*Lock) Log_KernelPanic("---", "Double short lock"); *Lock = 1; diff --git a/Tools/DiskTool/src/include/mutex.h b/Tools/DiskTool/src/include/mutex.h new file mode 100644 index 00000000..9fe1c4f8 --- /dev/null +++ b/Tools/DiskTool/src/include/mutex.h @@ -0,0 +1,19 @@ + +#ifndef _MUTEX_H_ +#define _MUTEX_H_ + +typedef struct { + void *LockerReturnAddr; +} tMutex; + +static inline int Mutex_Acquire(tMutex *m) { + if(m->LockerReturnAddr) + Log_KernelPanic("---", "Double mutex lock of %p by %p (was locked by %p)", + m, __builtin_return_address(0), m->LockerReturnAddr); + m->LockerReturnAddr = __builtin_return_address(0);; + return 0; +} +static inline void Mutex_Release(tMutex *m) { m->LockerReturnAddr = 0; } + +#endif + diff --git a/Tools/DiskTool/src/logging.c b/Tools/DiskTool/src/logging.c index 2b03c6ff..07d7a522 100644 --- a/Tools/DiskTool/src/logging.c +++ b/Tools/DiskTool/src/logging.c @@ -190,6 +190,9 @@ void Debug_TraceLeave(const char *Function, char Type, ...) case 'p': fprintf(stderr, " %p", va_arg(args, const void *)); break; + case 'n': + fprintf(stderr, " NULL"); + break; default: fprintf(stderr, " ?"); break; diff --git a/Tools/DiskTool/src/main.c b/Tools/DiskTool/src/main.c index c3c4166d..0758fc29 100644 --- a/Tools/DiskTool/src/main.c +++ b/Tools/DiskTool/src/main.c @@ -16,12 +16,12 @@ int main(int argc, char *argv[]) if( strcmp("mount", argv[i]) == 0 || strcmp("-i", argv[i]) == 0 ) { // Mount an image if( argc - i < 3 ) { - fprintf(stderr, "--image/-i takes 2 arguments (ident and path)\n"); + fprintf(stderr, "mount takes 2 arguments (image and mountpoint)\n"); exit(-1); } - if( DiskTool_MountImage(argv[i+1], argv[i+2]) ) { - fprintf(stderr, "Unable to mount '%s' as '%s'\n", argv[i+2], argv[i+1]); + if( DiskTool_MountImage(argv[i+2], argv[i+1]) ) { + fprintf(stderr, "Unable to mount '%s' as '%s'\n", argv[i+1], argv[i+2]); break; } @@ -32,12 +32,12 @@ int main(int argc, char *argv[]) if( strcmp("mountlvm", argv[i]) == 0 ) { if( argc - i < 3 ) { - fprintf(stderr, "mountlvm takes 2 arguments (ident and path)\n"); + fprintf(stderr, "mountlvm takes 2 arguments (iamge and ident)\n"); exit(-1); } - if( DiskTool_RegisterLVM(argv[i+1], argv[i+2]) ) { - fprintf(stderr, "Unable to register '%s' as LVM '%s'\n", argv[i+2], argv[i+1]); + if( DiskTool_RegisterLVM(argv[i+2], argv[i+1]) ) { + fprintf(stderr, "Unable to register '%s' as LVM '%s'\n", argv[i+1], argv[i+2]); break; } diff --git a/Usermode/Applications/wget_src/main.c b/Usermode/Applications/wget_src/main.c index 69c9ab71..34108407 100644 --- a/Usermode/Applications/wget_src/main.c +++ b/Usermode/Applications/wget_src/main.c @@ -84,6 +84,12 @@ int main(int argc, char *argv[]) continue ; } + if( proto != PROTO_HTTP ) { + fprintf(stderr, "TODO: Support protocols other than HTTP\n"); + free(uri); + continue ; + } + rv = getaddrinfo(uri->Host, "http", NULL, &addrinfo); if( rv != 0 ) { fprintf(stderr, "Unable to resolve %s: %s\n", uri->Host, gai_strerror(rv));