├── libraries ├── Makefile.am ├── libzbzcrt_prebuild │ ├── .gitignore │ └── Makefile └── libzbzcore │ ├── x8632 │ └── libzbzcore.S │ └── libzbzcore.S ├── __kcore ├── arch │ ├── Makefile.am │ └── i586 │ │ ├── idt.cpp │ │ ├── x8632_generalProtectionFault.cpp │ │ ├── schedTimer.cpp │ │ ├── __kexceptionTable.cpp │ │ ├── Makefile.am │ │ ├── wPRanger_accessors.cpp │ │ ├── msr.S │ │ ├── exceptions.h │ │ ├── wPRanger_getLevelRanges.cpp │ │ ├── gdt.c │ │ ├── x8632_debugException.cpp │ │ ├── x8632_breakpointException.cpp │ │ ├── cpuid.S │ │ ├── x86-debug-extensions.txt │ │ └── setjmp.S ├── firmware │ ├── Makefile.am │ └── ibmPcBios │ │ ├── Makefile.am │ │ ├── x86EmuAuxFuncs.h │ │ ├── debug-notes.txt │ │ ├── ibmPcBios_setRegs.cpp │ │ └── ibmPcBios_getRegs.cpp ├── __kstdlib │ ├── __klibc │ │ ├── i586 │ │ │ └── Makefile.am │ │ ├── Makefile.am │ │ └── malloc.cpp │ ├── __klibcxx │ │ └── Makefile.am │ ├── icxxabi │ │ └── Makefile.am │ ├── Makefile.am │ └── debug.cpp ├── include │ ├── arch │ │ ├── x8632 │ │ │ ├── mathEmulation.h │ │ │ ├── idt.png │ │ │ ├── eflags.png │ │ │ ├── pagefmt.png │ │ │ ├── debugregs.png │ │ │ ├── paepgfmt.png │ │ │ ├── pfErrcode.png │ │ │ ├── pagemodetrans.png │ │ │ ├── tlbContext.h │ │ │ ├── amd64-manual-modeswitch-flow-diagram.png │ │ │ ├── cpuFlags.h │ │ │ ├── differences-between-long-and-legacy-mode-overview.png │ │ │ ├── cpuid.h │ │ │ ├── cpuEnumeration.h │ │ │ ├── __kstdlib │ │ │ │ └── __kclib │ │ │ │ │ └── setjmp.h │ │ │ ├── gdt.h │ │ │ ├── arch.h │ │ │ ├── idt.h │ │ │ ├── memory.h │ │ │ ├── wPRanger_getLevelRanges.h │ │ │ ├── wPRanger_accessors.h │ │ │ ├── paePaging.semantics │ │ │ ├── debug.h │ │ │ ├── registerContext.h │ │ │ └── io.h │ │ ├── io.h │ │ ├── arch.h │ │ ├── paddr_t.h │ │ ├── atomic.h │ │ ├── memory.h │ │ ├── cpuControl.h │ │ ├── interrupts.h │ │ ├── tlbContext.h │ │ ├── mathEmulation.h │ │ ├── __kstdlib │ │ │ └── __kclib │ │ │ │ └── setjmp.h │ │ ├── registerContext.h │ │ ├── schedTimer.h │ │ ├── arch_include.h │ │ ├── paddr_t.txt │ │ ├── debug.h │ │ ├── memory.txt │ │ ├── paging.h │ │ └── mathEmulation.txt │ ├── in_asm.h │ ├── chipset │ │ ├── generic │ │ │ ├── regionMap.h │ │ │ ├── memory.h │ │ │ ├── chipset.h │ │ │ └── __kmemory.h │ │ ├── cpus.h │ │ ├── memory.h │ │ ├── ibmPc │ │ │ ├── cpus.h │ │ │ ├── memoryAreas.h │ │ │ ├── regionMap.h │ │ │ ├── memory.h │ │ │ └── chipset.h │ │ ├── terminalFwRiv.h │ │ ├── zkcm │ │ │ ├── memoryConfig.h │ │ │ ├── timerControl_filters.h │ │ │ ├── memoryDetection.h │ │ │ ├── zkcmIsr.h │ │ │ ├── cpuDetection.h │ │ │ ├── numaMap.h │ │ │ ├── debugDevice.h │ │ │ ├── zkcmCore.h │ │ │ ├── memoryMap.h │ │ │ ├── device.h │ │ │ ├── smpMap.h │ │ │ └── picDevice.h │ │ ├── pkg │ │ │ └── watchdogMod.h │ │ ├── memoryAreas.h │ │ ├── chipset_include.h │ │ └── chipset.h │ ├── platform │ │ ├── cpu.h │ │ ├── memory.h │ │ ├── pageTables.h │ │ ├── x8632-ibmPc │ │ │ ├── pageTables.h │ │ │ ├── memory.h │ │ │ └── cpu.h │ │ └── platform_include.h │ ├── kernel │ │ ├── common │ │ │ ├── rivulet.h │ │ │ ├── cpuTrib │ │ │ │ ├── archCpuFeatures.h │ │ │ │ ├── chipsetSmpMode.h │ │ │ │ ├── powerOperations.h │ │ │ │ └── cpuFeatures.h │ │ │ ├── execDomain.h │ │ │ ├── vfsTrib │ │ │ │ ├── vfsCache.h │ │ │ │ ├── commonOperations.h │ │ │ │ └── vfsTraverse.h │ │ │ ├── numaTypes.h │ │ │ ├── interruptTrib │ │ │ │ └── __kexceptionFn.h │ │ │ ├── __koptimizationHacks.h │ │ │ ├── cisternn │ │ │ │ └── cisternn.h │ │ │ ├── taskTrib │ │ │ │ ├── taskQNode.h │ │ │ │ └── load.h │ │ │ ├── floodplainn │ │ │ │ ├── tests.h │ │ │ │ ├── movableMemory.h │ │ │ │ └── region.h │ │ │ ├── kernel_include.h │ │ │ ├── panic.h │ │ │ ├── memoryTrib │ │ │ │ ├── allocFlags.h │ │ │ │ ├── rawMemAlloc.h │ │ │ │ ├── __kmemoryStream_methods.h │ │ │ │ └── pmmBridge.h │ │ │ ├── smpTypes.h │ │ │ ├── debugTrib │ │ │ │ └── debugTrib.h │ │ │ ├── sharedResourceGroup.h │ │ │ ├── execTrib │ │ │ │ └── executableFormat.h │ │ │ ├── tributary.h │ │ │ ├── waitLock.h │ │ │ ├── vaddrSpace.h │ │ │ ├── numaConfig.h │ │ │ ├── recursiveLock.h │ │ │ ├── deadlock.h │ │ │ └── smpConfig.h │ │ └── x8632 │ │ │ └── cpuTrib │ │ │ └── archCpuFeatures.h │ ├── __kclasses │ │ ├── allocClass.h │ │ ├── tests.h │ │ ├── waitQueue.h │ │ ├── heapCache.h │ │ ├── swampInfoNode.h │ │ ├── __kpageBlock.h │ │ ├── currentt.h │ │ ├── singleWaiterQueue.h │ │ ├── pageTableCache.h │ │ └── resizeableIdArray.h │ ├── commonlibs │ │ ├── libacpi │ │ │ ├── facp.h │ │ │ ├── libacpi.h │ │ │ ├── rsdp.h │ │ │ └── srat.h │ │ └── libx86mp │ │ │ ├── mpDefaultTables.h │ │ │ └── libx86mp.h │ ├── __kstdlib │ │ ├── tests.h │ │ ├── __kcxxCast.h │ │ ├── __kflagManipulation.h │ │ ├── __kcxxlib │ │ │ ├── mutex │ │ │ └── new │ │ ├── utf16.h │ │ ├── __kclib │ │ │ ├── string.h │ │ │ ├── stdlib.h │ │ │ ├── string8.h │ │ │ ├── string16.h │ │ │ └── assert.h │ │ ├── compiler │ │ │ └── cxxrtl.h │ │ ├── utf8.h │ │ ├── __ktypes.h │ │ └── callback.h │ ├── __kthreads │ │ ├── thread_include.h │ │ ├── __kcpuPowerOn.h │ │ └── main.h │ ├── firmware │ │ ├── ibmPcBios │ │ │ ├── ibmPcBios_coreFuncs.h │ │ │ └── ibmPcBios_regManip.h │ │ └── firmware_include.h │ └── multiboot2.h ├── kernel │ ├── Makefile.am │ ├── common │ │ ├── cisternn │ │ │ ├── Makefile.am │ │ │ └── descriptor.cpp │ │ ├── debugTrib │ │ │ ├── Makefile.am │ │ │ └── debugTrib.cpp │ │ ├── processTrib │ │ │ └── Makefile.am │ │ ├── taskTrib │ │ │ └── Makefile.am │ │ ├── interruptTrib │ │ │ └── Makefile.am │ │ ├── execTrib │ │ │ ├── Makefile.am │ │ │ ├── elfFuncs.h │ │ │ ├── elfParser.c │ │ │ └── execTrib.cpp │ │ ├── floodplainn │ │ │ ├── udi_buff.cpp │ │ │ ├── Makefile.am │ │ │ ├── udi_mei_call.cpp │ │ │ └── udiServiceCalls.cpp │ │ ├── timerTrib │ │ │ └── Makefile.am │ │ ├── cpuTrib │ │ │ ├── Makefile.am │ │ │ └── chipsetSmpMode.cpp │ │ ├── distributaryTrib │ │ │ ├── Makefile.am │ │ │ └── distributaries.cpp │ │ ├── memoryTrib │ │ │ ├── Makefile.am │ │ │ ├── rawMemAlloc.cpp │ │ │ └── recurse-map.txt │ │ ├── __koptimizationHacks.cpp │ │ ├── vfsTrib │ │ │ ├── Makefile.am │ │ │ ├── vfsTrib.cpp │ │ │ ├── hvfs_core.cpp │ │ │ ├── vfsTrib_file.cpp │ │ │ ├── vfsTrib_folder.cpp │ │ │ └── vfsTrib_fileDesc.cpp │ │ ├── Makefile.am │ │ ├── panic.cpp │ │ └── __kclassInstances.cpp │ └── i586 │ │ ├── Makefile.am │ │ ├── __kclassInstances.cpp │ │ ├── cpuTrib.cpp │ │ └── cpuFeatures.cpp ├── platform │ ├── Makefile.am │ └── i586-ibmPc │ │ ├── __kpagingLevel1Tables.S │ │ ├── Makefile.am │ │ └── placementAddresses.txt ├── .gitignore ├── chipset │ ├── ibmPc │ │ ├── ibm_pc.cpp │ │ ├── zkcmIbmPcState.cpp │ │ ├── Makefile.am │ │ ├── ibm_pc.udidprops │ │ ├── regionMap.cpp │ │ ├── rtcmos.h │ │ ├── busPinMappings.h │ │ ├── i8254_pit.cpp │ │ ├── zkcmIbmPcState.h │ │ ├── vgaTerminal.h │ │ ├── rs232.h │ │ ├── udi_init_info.cpp │ │ └── chipset_root_devices.cpp │ ├── generic │ │ ├── numaMap.cpp │ │ ├── memoryMap.cpp │ │ ├── memoryConfig.cpp │ │ ├── regionMap.cpp │ │ └── Makefile.am │ └── Makefile.am ├── commonlibs │ ├── libacpi │ │ └── Makefile.am │ ├── drivers │ │ ├── Makefile.am │ │ ├── zramdisk.udidprops │ │ └── zrootdev.udidprops │ ├── metalanguages │ │ ├── Makefile.am │ │ ├── udi_bridge.udimprops │ │ ├── floodplainn.udimprops │ │ ├── zbz_chipset.udimprops │ │ └── zbz_root.udimprops │ ├── libx86mp │ │ └── Makefile.am │ ├── Makefile.am │ └── libzbzcore │ │ ├── Makefile.am │ │ └── distributaryPath.cpp ├── __kthreads │ ├── Makefile.am │ ├── i586 │ │ ├── crtn.S │ │ ├── crti.S │ │ └── Makefile.am │ ├── main.cpp │ └── __kcpuPowerOn.cpp ├── __kclasses │ └── Makefile.am ├── udi_index.S └── Makefile.am ├── force_cpp_link.cpp ├── m4 ├── .gitignore ├── icxxabi-opts.m4 └── scaling-opts.m4 ├── programs └── zudi │ ├── .gitignore │ ├── zudiindex │ ├── .gitignore │ └── zudiindex-addall │ ├── INSTALL │ └── README.md ├── docs ├── riscv-m-csrs.png ├── riscv-s-csrs.png ├── riscv-u-csrs.png ├── riscv-m-csrs2.png ├── tss-call-gates.md ├── processes.txt └── freestanding-libstdcxx-libsupcxx.md ├── scripts ├── ifdefs.sh ├── git-resume-list.sh ├── nsource ├── loc └── configure-i586-ibmPc-ibmPcBios-numa.sh ├── packaging ├── grub2 │ ├── iso │ │ ├── cdboot.img │ │ ├── default.cfg │ │ └── grub2-i386-modules.img │ └── grub.cfg └── grub │ ├── menu.lst │ └── iso │ └── stage2_eltorito ├── include ├── lang.h ├── extern.h ├── scaling.h ├── debug.h ├── assembler.h └── __ksymbols.h ├── __kendoFs.S ├── .vscode ├── settings.json └── c_cpp_properties.json ├── .gitignore └── README /libraries/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS=libzbzcrt 2 | -------------------------------------------------------------------------------- /__kcore/arch/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS=@ZARCH@ 2 | -------------------------------------------------------------------------------- /__kcore/firmware/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS=@ZFIRMWARE@ -------------------------------------------------------------------------------- /force_cpp_link.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | -------------------------------------------------------------------------------- /libraries/libzbzcrt_prebuild/.gitignore: -------------------------------------------------------------------------------- 1 | *.S 2 | -------------------------------------------------------------------------------- /m4/.gitignore: -------------------------------------------------------------------------------- 1 | libtool.m4 2 | lt*.m4 3 | 4 | -------------------------------------------------------------------------------- /programs/zudi/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | .dirstamp 3 | -------------------------------------------------------------------------------- /__kcore/__kstdlib/__klibc/i586/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS= -------------------------------------------------------------------------------- /__kcore/include/arch/x8632/mathEmulation.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /__kcore/kernel/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS=common @ZARCH@ 2 | -------------------------------------------------------------------------------- /__kcore/platform/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS=@ZARCH@-@ZCHIPSET@ 2 | -------------------------------------------------------------------------------- /__kcore/.gitignore: -------------------------------------------------------------------------------- 1 | *.[oas] 2 | __klinkScript.ld 3 | tmp 4 | /Makefile 5 | 6 | -------------------------------------------------------------------------------- /__kcore/include/in_asm.h: -------------------------------------------------------------------------------- 1 | #ifndef __ASM__ 2 | #define __ASM__ 3 | #endif 4 | -------------------------------------------------------------------------------- /__kcore/include/chipset/generic/regionMap.h: -------------------------------------------------------------------------------- 1 | #define CHIPSET_MEMORY_NREGIONS 0 2 | 3 | -------------------------------------------------------------------------------- /__kcore/include/arch/io.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include ARCH_INCLUDE(io.h) 3 | 4 | -------------------------------------------------------------------------------- /docs/riscv-m-csrs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latentPrion/zambesii/HEAD/docs/riscv-m-csrs.png -------------------------------------------------------------------------------- /docs/riscv-s-csrs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latentPrion/zambesii/HEAD/docs/riscv-s-csrs.png -------------------------------------------------------------------------------- /docs/riscv-u-csrs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latentPrion/zambesii/HEAD/docs/riscv-u-csrs.png -------------------------------------------------------------------------------- /scripts/ifdefs.sh: -------------------------------------------------------------------------------- 1 | grep -n '#if' $(find $1 -type f | grep -v '\.git\|gcc') | grep -v '_H$' 2 | 3 | -------------------------------------------------------------------------------- /__kcore/include/arch/arch.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include ARCH_INCLUDE(arch.h) 3 | 4 | -------------------------------------------------------------------------------- /__kcore/include/arch/paddr_t.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include ARCH_INCLUDE(paddr_t.h) 3 | -------------------------------------------------------------------------------- /docs/riscv-m-csrs2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latentPrion/zambesii/HEAD/docs/riscv-m-csrs2.png -------------------------------------------------------------------------------- /__kcore/__kstdlib/__klibcxx/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES=lib__klibcxx.a 2 | lib__klibcxx_a_SOURCES=new.cpp -------------------------------------------------------------------------------- /__kcore/include/arch/atomic.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include ARCH_INCLUDE(atomic.h) 3 | 4 | -------------------------------------------------------------------------------- /__kcore/include/arch/memory.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include ARCH_INCLUDE(memory.h) 3 | 4 | -------------------------------------------------------------------------------- /__kcore/chipset/ibmPc/ibm_pc.cpp: -------------------------------------------------------------------------------- 1 | 2 | #define UDI_VERSION 0x101 3 | #include 4 | #endif 5 | 6 | 7 | -------------------------------------------------------------------------------- /__kcore/include/arch/cpuControl.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include ARCH_INCLUDE(cpuControl.h) 3 | 4 | -------------------------------------------------------------------------------- /__kcore/include/arch/interrupts.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include ARCH_INCLUDE(interrupts.h) 3 | 4 | -------------------------------------------------------------------------------- /__kcore/include/arch/tlbContext.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include ARCH_INCLUDE(tlbContext.h) 3 | 4 | -------------------------------------------------------------------------------- /__kcore/chipset/ibmPc/zkcmIbmPcState.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "zkcmIbmPcState.h" 3 | 4 | sIbmPcChipsetState ibmPcState; 5 | -------------------------------------------------------------------------------- /__kcore/include/chipset/cpus.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include CHIPSET_INCLUDE(cpus.h) 4 | 5 | -------------------------------------------------------------------------------- /__kcore/include/chipset/memory.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include CHIPSET_INCLUDE(memory.h) 3 | 4 | -------------------------------------------------------------------------------- /__kcore/include/platform/cpu.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include PLATFORM_INCLUDE(cpu.h) 3 | 4 | -------------------------------------------------------------------------------- /__kcore/kernel/common/cisternn/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES=libcisternn.a 2 | libcisternn_a_SOURCES=descriptor.cpp 3 | -------------------------------------------------------------------------------- /packaging/grub2/iso/cdboot.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latentPrion/zambesii/HEAD/packaging/grub2/iso/cdboot.img -------------------------------------------------------------------------------- /packaging/grub2/iso/default.cfg: -------------------------------------------------------------------------------- 1 | search --no-floppy --fs-uuid --set=root $root_uuid 2 | set prefix=($root)/boot/grub -------------------------------------------------------------------------------- /__kcore/chipset/generic/numaMap.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | sChipsetNumaMap *chipsetNumaMap = 0; 5 | -------------------------------------------------------------------------------- /__kcore/include/arch/mathEmulation.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include ARCH_INCLUDE(mathEmulation.h) 3 | 4 | -------------------------------------------------------------------------------- /__kcore/include/platform/memory.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include PLATFORM_INCLUDE(memory.h) 3 | 4 | -------------------------------------------------------------------------------- /__kcore/kernel/common/debugTrib/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES=libdebugTrib.a 2 | libdebugTrib_a_SOURCES=debugTrib.cpp 3 | -------------------------------------------------------------------------------- /packaging/grub/menu.lst: -------------------------------------------------------------------------------- 1 | timeout 2 2 | 3 | title Raw Zambesii v0.xx (Multiboot 1) 4 | kernel /zambesii/zambesii.zxe 5 | -------------------------------------------------------------------------------- /scripts/git-resume-list.sh: -------------------------------------------------------------------------------- 1 | git status | grep '^#[[:space:]]*modified:' | sed 's/#[[:space:]]modified:[[:space:]]*//' 2 | -------------------------------------------------------------------------------- /__kcore/__kstdlib/icxxabi/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES=libicxxabi.a 2 | libicxxabi_a_SOURCES=dso.cpp callConstructors.cpp 3 | -------------------------------------------------------------------------------- /__kcore/chipset/generic/memoryMap.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | chipsetMemMapS *chipsetMemMap = 0; 5 | 6 | -------------------------------------------------------------------------------- /__kcore/commonlibs/libacpi/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES=libacpi.a 2 | libacpi_a_SOURCES=rsdp.cpp rxsdt.cpp madt.cpp srat.cpp 3 | -------------------------------------------------------------------------------- /__kcore/include/arch/x8632/idt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latentPrion/zambesii/HEAD/__kcore/include/arch/x8632/idt.png -------------------------------------------------------------------------------- /__kcore/kernel/common/processTrib/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES=libprocessTrib.a 2 | libprocessTrib_a_SOURCES=processTrib.cpp 3 | -------------------------------------------------------------------------------- /packaging/grub/iso/stage2_eltorito: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latentPrion/zambesii/HEAD/packaging/grub/iso/stage2_eltorito -------------------------------------------------------------------------------- /__kcore/__kstdlib/__klibc/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS=@ZARCH@ 2 | 3 | noinst_LIBRARIES=lib__klibc.a 4 | lib__klibc_a_SOURCES=malloc.cpp 5 | -------------------------------------------------------------------------------- /__kcore/chipset/generic/memoryConfig.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | chipsetMemConfigS *chipsetMemConfig = 0; 5 | -------------------------------------------------------------------------------- /__kcore/chipset/generic/regionMap.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | sChipsetRegionMap *chipsetRegionMap = 0; 5 | 6 | -------------------------------------------------------------------------------- /__kcore/include/arch/x8632/eflags.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latentPrion/zambesii/HEAD/__kcore/include/arch/x8632/eflags.png -------------------------------------------------------------------------------- /__kcore/include/arch/x8632/pagefmt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latentPrion/zambesii/HEAD/__kcore/include/arch/x8632/pagefmt.png -------------------------------------------------------------------------------- /__kcore/include/platform/pageTables.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include PLATFORM_INCLUDE(pageTables.h) 3 | 4 | -------------------------------------------------------------------------------- /__kcore/kernel/common/taskTrib/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES=libtaskTrib.a 2 | libtaskTrib_a_SOURCES=taskTrib.cpp taskStream.cpp 3 | -------------------------------------------------------------------------------- /__kcore/include/arch/x8632/debugregs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latentPrion/zambesii/HEAD/__kcore/include/arch/x8632/debugregs.png -------------------------------------------------------------------------------- /__kcore/include/arch/x8632/paepgfmt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latentPrion/zambesii/HEAD/__kcore/include/arch/x8632/paepgfmt.png -------------------------------------------------------------------------------- /__kcore/include/arch/x8632/pfErrcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latentPrion/zambesii/HEAD/__kcore/include/arch/x8632/pfErrcode.png -------------------------------------------------------------------------------- /__kcore/kernel/common/interruptTrib/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES=libinterruptTrib.a 2 | libinterruptTrib_a_SOURCES=interruptTrib.cpp 3 | -------------------------------------------------------------------------------- /__kcore/commonlibs/drivers/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES=libdrivers.a 2 | libdrivers_a_SOURCES=zramdisk.cpp zrootdev.cpp zrootdev_init.cpp 3 | -------------------------------------------------------------------------------- /__kcore/include/arch/__kstdlib/__kclib/setjmp.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include ARCH_INCLUDE(__kstdlib/__kclib/setjmp.h) 3 | 4 | -------------------------------------------------------------------------------- /__kcore/kernel/common/execTrib/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES=libexecTrib.a 2 | libexecTrib_a_SOURCES=execTrib.cpp elf_base.c elfParser.c 3 | -------------------------------------------------------------------------------- /packaging/grub2/iso/grub2-i386-modules.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latentPrion/zambesii/HEAD/packaging/grub2/iso/grub2-i386-modules.img -------------------------------------------------------------------------------- /programs/zudi/zudiindex/.gitignore: -------------------------------------------------------------------------------- 1 | list 2 | *.udiprops 3 | zudiindex 4 | *.o 5 | *.zudid-index 6 | *.zudim-index 7 | *.zudi-index 8 | *.tmp 9 | -------------------------------------------------------------------------------- /__kcore/include/arch/x8632/pagemodetrans.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latentPrion/zambesii/HEAD/__kcore/include/arch/x8632/pagemodetrans.png -------------------------------------------------------------------------------- /__kcore/kernel/common/floodplainn/udi_buff.cpp: -------------------------------------------------------------------------------- 1 | 2 | #define UDI_VERSION 0x101 3 | #include 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | 7 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/rivulet.h: -------------------------------------------------------------------------------- 1 | #ifndef _RIVULET_H 2 | #define _RIVULET_H 3 | 4 | class Rivulet 5 | { 6 | }; 7 | 8 | #endif 9 | 10 | -------------------------------------------------------------------------------- /__kcore/kernel/common/timerTrib/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES=libtimerTrib.a 2 | libtimerTrib_a_SOURCES=timerTrib.cpp timerQueue.cpp timerStream.cpp 3 | -------------------------------------------------------------------------------- /__kcore/chipset/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS=@ZCHIPSET@ 2 | 3 | noinst_LIBRARIES=libchipset.a 4 | libchipset_a_SOURCES=timerControl_filters.cpp timerDevice.cpp 5 | -------------------------------------------------------------------------------- /__kcore/commonlibs/metalanguages/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES=libmetalanguages.a 2 | libmetalanguages_a_SOURCES=udi_gio.cpp udi_bridge.cpp udi_mgmt.cpp 3 | -------------------------------------------------------------------------------- /__kcore/include/chipset/ibmPc/cpus.h: -------------------------------------------------------------------------------- 1 | #ifndef _IBM_PC_CPU_CONFIG_H 2 | #define _IBM_PC_CPU_CONFIG_H 3 | 4 | #include 5 | 6 | #endif 7 | 8 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/cpuTrib/archCpuFeatures.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include KERNEL_INCLUDE(cpuTrib/archCpuFeatures.h) 3 | 4 | -------------------------------------------------------------------------------- /__kcore/chipset/generic/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES=libchipsetCore.a 2 | libchipsetCore_a_SOURCES=memoryConfig.cpp memoryMap.cpp regionMap.cpp numaMap.cpp 3 | 4 | -------------------------------------------------------------------------------- /__kcore/include/__kclasses/allocClass.h: -------------------------------------------------------------------------------- 1 | #ifndef _ALLOC_CLASS_H 2 | #define _ALLOC_CLASS_H 3 | 4 | class AllocatorBase 5 | { 6 | }; 7 | 8 | #endif 9 | 10 | -------------------------------------------------------------------------------- /__kcore/include/arch/x8632/tlbContext.h: -------------------------------------------------------------------------------- 1 | #ifndef _TLB_CONTEXT_H 2 | #define _TLB_CONTEXT_H 3 | 4 | struct sTlbContext 5 | { 6 | }; 7 | 8 | #endif 9 | 10 | -------------------------------------------------------------------------------- /__kcore/kernel/common/cpuTrib/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES=libcpuTrib.a 2 | libcpuTrib_a_SOURCES=cpuTrib.cpp cpuStream.cpp chipsetSmpMode.cpp \ 3 | interCpuMessager.cpp 4 | -------------------------------------------------------------------------------- /__kcore/include/commonlibs/libacpi/facp.h: -------------------------------------------------------------------------------- 1 | #ifndef _ZBZ_LIBACPI_FACP_H 2 | #define _ZBZ_LIBACPI_FACP_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | 7 | #endif 8 | 9 | -------------------------------------------------------------------------------- /programs/zudi/INSTALL: -------------------------------------------------------------------------------- 1 | Building is simple: 2 | make 3 | make install 4 | 5 | And that's it. If you need su -c or sudo, you should of course, be sure to 6 | prepend those. 7 | 8 | -------------------------------------------------------------------------------- /__kcore/include/arch/x8632/amd64-manual-modeswitch-flow-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latentPrion/zambesii/HEAD/__kcore/include/arch/x8632/amd64-manual-modeswitch-flow-diagram.png -------------------------------------------------------------------------------- /__kcore/include/kernel/common/cpuTrib/chipsetSmpMode.h: -------------------------------------------------------------------------------- 1 | #ifndef _USING_CHIPSET_SMP_MODE_H 2 | #define _USING_CHIPSET_SMP_MODE_H 3 | 4 | sarch_t usingChipsetSmpMode(void); 5 | 6 | #endif 7 | 8 | -------------------------------------------------------------------------------- /__kcore/kernel/common/cpuTrib/chipsetSmpMode.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | sarch_t usingChipsetSmpMode(void) 5 | { 6 | return cpuTrib.usingChipsetSmpMode(); 7 | } 8 | 9 | -------------------------------------------------------------------------------- /__kcore/kernel/common/distributaryTrib/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES=libdistributaryTrib.a 2 | libdistributaryTrib_a_SOURCES=distributaryTrib.cpp distributaries.cpp \ 3 | distributaryTrib_dvfs.cpp 4 | -------------------------------------------------------------------------------- /__kcore/__kthreads/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS=@ZARCH@ 2 | 3 | noinst_LIBRARIES=lib__kthreads.a 4 | lib__kthreads_a_SOURCES=main.cpp __kcpuPowerOn.cpp 5 | 6 | main.$(OBJEXT): AM_CXXFLAGS += -Wno-variadic-macros 7 | -------------------------------------------------------------------------------- /include/lang.h: -------------------------------------------------------------------------------- 1 | #ifndef _HLL_LANG_H 2 | #define _HLL_LANG_H 3 | 4 | #ifdef __cplusplus 5 | #define EXTERN extern "C" 6 | #else 7 | #define EXTERN extern 8 | #endif 9 | 10 | #endif 11 | 12 | -------------------------------------------------------------------------------- /__kcore/include/arch/x8632/cpuFlags.h: -------------------------------------------------------------------------------- 1 | #ifndef _CPU_FLAGS_H 2 | #define _CPU_FLAGS_H 3 | 4 | #define x8632_CPUFLAGS_IF (1<<9) 5 | 6 | #define x8632_CR4_DEBUG_ENABLED (1<<3) 7 | 8 | #endif 9 | 10 | -------------------------------------------------------------------------------- /__kcore/include/arch/x8632/differences-between-long-and-legacy-mode-overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latentPrion/zambesii/HEAD/__kcore/include/arch/x8632/differences-between-long-and-legacy-mode-overview.png -------------------------------------------------------------------------------- /__kcore/include/chipset/generic/memory.h: -------------------------------------------------------------------------------- 1 | #ifndef _CHIPSET_MEMORY_H 2 | #define _CHIPSET_MEMORY_H 3 | 4 | // Generic chipset: just load at 0x0. 5 | #define CHIPSET_MEMORY___KLOAD_PADDR_BASE 0x0 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/execDomain.h: -------------------------------------------------------------------------------- 1 | #ifndef _PROCESS_EXECDOMAIN_H 2 | #define _PROCESS_EXECDOMAIN_H 3 | 4 | #define PROCESS_EXECDOMAIN_KERNEL 0x1 5 | #define PROCESS_EXECDOMAIN_USER 0x2 6 | 7 | #endif 8 | 9 | -------------------------------------------------------------------------------- /__kcore/commonlibs/libx86mp/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES=libx86mp.a 2 | libx86mp_a_SOURCES=mpTables.cpp mpDefaultTables.cpp \ 3 | lapic_core.cpp lapic_ipi.cpp lapic_lint.cpp \ 4 | libIoApic.cpp ioApic_core.cpp ioApic_zkcm.cpp 5 | -------------------------------------------------------------------------------- /__kcore/kernel/common/memoryTrib/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES=libmemoryTrib.a 2 | libmemoryTrib_a_SOURCES=memoryStream.cpp memoryTrib.cpp vaddrSpaceStream.cpp \ 3 | rawMemAlloc.cpp memoryTrib_numa.cpp memoryTrib_pmemInit.cpp 4 | -------------------------------------------------------------------------------- /__kcore/kernel/i586/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES=libkernelCore.a 2 | libkernelCore_a_SOURCES=__kclassInstances.cpp cpuTrib.cpp interruptTrib.cpp cpuStream.cpp \ 3 | interCpuMessager.cpp cpuStream_powerManager.cpp vaddrSpace.cpp 4 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/vfsTrib/vfsCache.h: -------------------------------------------------------------------------------- 1 | #ifndef _VIRTUAL_FILE_SYSTEM_CACHE_H 2 | #define _VIRTUAL_FILE_SYSTEM_CACHE_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | class VfsCache 7 | { 8 | }; 9 | 10 | #endif 11 | 12 | -------------------------------------------------------------------------------- /__kendoFs.S: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | ASM_SECTION(.data) 6 | 7 | ASM_GLOBAL_DATA(__kendoFs) 8 | // .incbin "drivers.zudi-index" 9 | ASM_END_DATA(__kendoFs) 10 | ASM_GLOBAL_DATA(__kendoFsEnd) 11 | -------------------------------------------------------------------------------- /__kcore/__kthreads/i586/crtn.S: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | .section .init 4 | #if 1 5 | movl %ebp, %esp 6 | popl %ebp 7 | ret 8 | #endif 9 | 10 | .section .fini 11 | #if 1 12 | movl %ebp, %esp 13 | popl %ebp 14 | ret 15 | #endif 16 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/numaTypes.h: -------------------------------------------------------------------------------- 1 | #ifndef _NUMA_TYPES_H 2 | #define _NUMA_TYPES_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | #define NUMABANKID_INVALID (-1) 7 | 8 | typedef sarch_t numaBankId_t; 9 | 10 | #endif 11 | 12 | -------------------------------------------------------------------------------- /__kcore/platform/i586-ibmPc/__kpagingLevel1Tables.S: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | #ifdef CONFIG_ARCH_x86_32_PAE 6 | #include "paeLevel1Tables.S" 7 | #else 8 | #include "noPaeLevel1Tables.S" 9 | #endif 10 | 11 | -------------------------------------------------------------------------------- /__kcore/__kstdlib/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS=__klibc __klibcxx icxxabi 2 | 3 | noinst_LIBRARIES=lib__kstdlib.a 4 | lib__kstdlib_a_SOURCES=__kmath.cpp test___kbitManipulation.cpp debug.cpp 5 | 6 | test___kbitManipulation.$(OBJEXT): AM_CXXFLAGS+=-Wno-variadic-macros 7 | -------------------------------------------------------------------------------- /__kcore/firmware/ibmPcBios/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES=libfirmwareCore.a 2 | libfirmwareCore_a_SOURCES=debug.c decode.c fpu.c ops.c ops2.c prim_ops.c sys.c \ 3 | x86EmuAuxFuncs.cpp ibmPcBios_setRegs.cpp ibmPcBios_getRegs.cpp \ 4 | ibmPcBios_coreFuncs.cpp 5 | -------------------------------------------------------------------------------- /__kcore/include/chipset/ibmPc/memoryAreas.h: -------------------------------------------------------------------------------- 1 | #ifndef _CHIPSET_IBM_PC_MEMORY_AREAS_H 2 | #define _CHIPSET_IBM_PC_MEMORY_AREAS_H 3 | 4 | enum chipsetMemoryAreasE 5 | { 6 | CHIPSET_MEMAREA_LOWMEM = 0, 7 | CHIPSET_MEMAREA_NAREAS 8 | }; 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /__kcore/include/commonlibs/libacpi/libacpi.h: -------------------------------------------------------------------------------- 1 | #ifndef _ZBZ_LIBACPI_H 2 | #define _ZBZ_LIBACPI_H 3 | 4 | #include "baseTables.h" 5 | #include "rsdp.h" 6 | #include "rxsdt.h" 7 | 8 | #include "madt.h" 9 | #include "srat.h" 10 | 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /packaging/grub2/grub.cfg: -------------------------------------------------------------------------------- 1 | set timeout=2 2 | set default=0 3 | 4 | menuentry "Raw Zambesii v0.xx (Multiboot 1)" { 5 | multiboot /zambesii/zambesii.zxe 6 | } 7 | 8 | menuentry "Raw Zambesii v0.xx (Multiboot 2)" { 9 | multiboot2 /zambesii/zambesii.zxe 10 | } -------------------------------------------------------------------------------- /__kcore/arch/i586/idt.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | struct sX8632IdtEntry x8632Idt[256]; 6 | struct sX8632IdtPtr x8632IdtPtr = 7 | { 8 | (sizeof(struct sX8632IdtEntry) * 256) - 1, 9 | x8632Idt 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /__kcore/commonlibs/Makefile.am: -------------------------------------------------------------------------------- 1 | DIST_SUBDIRS=drivers metalanguages libzbzcore \ 2 | libx86mp libacpi 3 | SUBDIRS=drivers metalanguages libzbzcore @ZCHIPSET_COMMONLIBS_ENABLED_SUBDIRS@ 4 | 5 | noinst_LIBRARIES=libcommonlibs.a 6 | libcommonlibs_a_SOURCES=libzudiIndexParser.cpp 7 | -------------------------------------------------------------------------------- /__kcore/include/arch/registerContext.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include ARCH_INCLUDE(registerContext.h) 3 | 4 | extern "C" 5 | { 6 | void saveContextAndCallPull(void *cpuSleepStackBaseAddr); 7 | void loadContextAndJump(RegisterContext *tc); 8 | } 9 | 10 | -------------------------------------------------------------------------------- /__kcore/kernel/common/__koptimizationHacks.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | void __koptimizationHacks(void) 6 | { 7 | __kheadersInit(); 8 | #ifdef __x86_32__ 9 | __kcpuPowerOnInit(); 10 | #endif 11 | } 12 | 13 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/interruptTrib/__kexceptionFn.h: -------------------------------------------------------------------------------- 1 | #ifndef _ISR_FUNCTION_T_H 2 | #define _ISR_FUNCTION_T_H 3 | 4 | #include 5 | 6 | typedef status_t 7 | (__kexceptionFn)(class RegisterContext *regs, ubit8 postcall); 8 | 9 | #endif 10 | 11 | -------------------------------------------------------------------------------- /__kcore/kernel/i586/__kclassInstances.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | 7 | ProcessTrib processTrib( 8 | (void *)(ARCH_MEMORY___KLOAD_VADDR_BASE + 0x400000), 0x3FBFF000); 9 | 10 | -------------------------------------------------------------------------------- /__kcore/include/chipset/generic/chipset.h: -------------------------------------------------------------------------------- 1 | #ifndef _CHIPSET_H 2 | #define _CHIPSET_H 3 | // Generic chipset 4 | 5 | #define CHIPSET_SHORT_STRING "generic" 6 | #define CHIPSET_LONG_STRING "Generic/unknown, unconfigured chipset" 7 | #define CHIPSET_PATH generic 8 | 9 | #endif 10 | 11 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/__koptimizationHacks.h: -------------------------------------------------------------------------------- 1 | #ifndef ___KOPTIMIZATION_HACKS_H 2 | #define ___KOPTIMIZATION_HACKS_H 3 | 4 | extern void __koptimizationHacks(void); 5 | extern void __kheadersInit(void); 6 | extern void (*__kcpuPowerOnInit(void))(void); 7 | 8 | #endif 9 | 10 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/cisternn/cisternn.h: -------------------------------------------------------------------------------- 1 | #ifndef _DISTRIBUTARY_CISTERN_H_ 2 | #define _DISTRIBUTARY_CISTERN_H_ 3 | 4 | #include 5 | 6 | extern const dvfs::sDistributaryDescriptor cisternnDescriptor; 7 | 8 | #endif // _DISTRIBUTARY_CISTERN_H_ 9 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/taskTrib/taskQNode.h: -------------------------------------------------------------------------------- 1 | #ifndef _TASK_LIST_NODE_H 2 | #define _TASK_LIST_NODE_H 3 | 4 | #include 5 | 6 | struct sThreadQueueNode 7 | { 8 | Thread *thread; 9 | sThreadQueueNode *prev, *next; 10 | }; 11 | 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /__kcore/__kthreads/i586/crti.S: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | .section .init 4 | #if 1 5 | ASM_GLOBAL_FUNCTION(_init) 6 | pushl %ebp 7 | movl %esp, %ebp 8 | #endif 9 | 10 | .section .fini 11 | #if 1 12 | ASM_GLOBAL_FUNCTION(_fini) 13 | pushl %ebp 14 | movl %esp, %ebp 15 | #endif 16 | -------------------------------------------------------------------------------- /__kcore/include/platform/x8632-ibmPc/pageTables.h: -------------------------------------------------------------------------------- 1 | #ifndef _PLATFORM_PAGE_TABLES_H 2 | #define _PLATFORM_PAGE_TABLES_H 3 | 4 | #include 5 | 6 | extern "C" sPagingLevel0 __kpagingLevel0Tables; 7 | extern "C" sPagingLevel1 __kpagingLevel1Tables[]; 8 | 9 | #endif 10 | 11 | -------------------------------------------------------------------------------- /__kcore/include/commonlibs/libx86mp/mpDefaultTables.h: -------------------------------------------------------------------------------- 1 | #ifndef _x86_MP_DEFAULT_CONFIGURATION_TABLES_H 2 | #define _x86_MP_DEFAULT_CONFIGURATION_TABLES_H 3 | 4 | #include "mpTables.h" 5 | 6 | namespace x86Mp 7 | { 8 | extern struct sConfig *configDefaults[7]; 9 | } 10 | 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /__kcore/include/chipset/generic/__kmemory.h: -------------------------------------------------------------------------------- 1 | #ifndef _CHIPSET___KMEMORY_H 2 | #define _CHIPSET___KMEMORY_H 3 | 4 | // __kspace: spans from the 8MB mark, and is 2MB large. 5 | #define CHIPSET_MEMORY___KSPACE_BASE 0x00800000 6 | #define CHIPSET_MEMORY___KSPACE_SIZE 0x00200000 7 | 8 | #endif 9 | 10 | -------------------------------------------------------------------------------- /__kcore/kernel/common/floodplainn/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES=libfloodplainn.a 2 | libfloodplainn_a_SOURCES=device.cpp fvfs.cpp zuiFrontEnd.cpp zuiBackEnd.cpp floodplainn.cpp \ 3 | udiServiceCalls.cpp udi_channel.cpp floodplainnStream.cpp channel.cpp \ 4 | zumFrontEnd.cpp zumBackEnd.cpp udi_dma.cpp zudi.cpp 5 | -------------------------------------------------------------------------------- /__kcore/kernel/common/execTrib/elfFuncs.h: -------------------------------------------------------------------------------- 1 | #ifndef _ELF_FUNCTIONS_H 2 | #define _ELF_FUNCTIONS_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | error_t elf_initialize(const char *archString, ubit16 wordSize); 7 | sarch_t elf_identify(void *buff); 8 | sarch_t elf_isLocalArch(void *buff); 9 | 10 | #endif 11 | 12 | -------------------------------------------------------------------------------- /__kcore/__kstdlib/debug.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include <__kclasses/debugPipe.h> 5 | 6 | 7 | void PRINTFON(int cond, const utf8Char *str, ...) 8 | { 9 | va_list args; 10 | 11 | va_start(args, str); 12 | if (cond) 13 | return vprintf(str, args); 14 | 15 | va_end(args); 16 | } 17 | -------------------------------------------------------------------------------- /__kcore/kernel/common/vfsTrib/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES=libvfsTrib.a 2 | libvfsTrib_a_SOURCES=vfsTrib.cpp \ 3 | hvfs_core.cpp 4 | # vfsTrib_traverse.cpp vfsTrib_tree.cpp vfsTrib_folder.cpp 5 | # vfsTrib_fileDesc.cpp vfsTrib_fileInode.cpp vfsTrib_dirDesc.cpp 6 | # vfsTrib_dirInode.cpp vfsTrib_pathParse.cpp vfsTrib_file.cpp 7 | -------------------------------------------------------------------------------- /__kcore/include/__kstdlib/tests.h: -------------------------------------------------------------------------------- 1 | #ifndef __KSTDLIB_TESTS_H 2 | #define __KSTDLIB_TESTS_H 3 | 4 | namespace tests 5 | { 6 | 7 | namespace __kstdlib 8 | { 9 | 10 | extern testFn *tests[]; 11 | 12 | namespace __kclib 13 | { 14 | } 15 | 16 | namespace __kcxxlib 17 | { 18 | } 19 | 20 | } 21 | 22 | } 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /__kcore/include/arch/x8632/cpuid.h: -------------------------------------------------------------------------------- 1 | #ifndef _x86_32_CPUID_H 2 | #define _x86_32_CPUID_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | extern "C" void execCpuid( 7 | uarch_t num, uarch_t *eax, uarch_t *ebx, uarch_t *ecx, uarch_t *edx); 8 | 9 | extern "C" sarch_t x8632_verifyCpuIsI486OrHigher(void); 10 | 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /libraries/libzbzcore/x8632/libzbzcore.S: -------------------------------------------------------------------------------- 1 | 2 | /** x86-32 specific syscall library ASM functions. 3 | **/ 4 | 5 | syscall0: 6 | syscall1: 7 | syscall2: 8 | syscall3: 9 | syscall4: 10 | 11 | /* Below here we will place the actual preparative code to place the syscall 12 | * number into the right register, etc. 13 | **/ 14 | 15 | -------------------------------------------------------------------------------- /__kcore/include/arch/schedTimer.h: -------------------------------------------------------------------------------- 1 | #ifndef _CPU_TIMER_H 2 | #define _CPU_TIMER_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | class SchedTimer 7 | { 8 | public: 9 | error_t initialize(void); 10 | void setHz(uarch_t hz); 11 | 12 | public: 13 | uarch_t hz; 14 | continuousTimerDevS *timer; 15 | }; 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /__kcore/commonlibs/libzbzcore/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES=libzbzcore.a 2 | libzbzcore_a_SOURCES=main.cpp distributaryPath.cpp driverPath.cpp devicePath.cpp layout.cpp \ 3 | libzudi.cpp libzudi_buf.cpp libzudi_dma.cpp 4 | 5 | devicePath.$(OBJEXT) libzudi.$(OBJEXT) \ 6 | libzudi_buf.$(OBJEXT) libzudi_dma.$(OBJEXT): CXXFLAGS+=-Wno-variadic-macros 7 | -------------------------------------------------------------------------------- /__kcore/include/__kclasses/tests.h: -------------------------------------------------------------------------------- 1 | #ifndef ___KCLASSES_TESTS_H 2 | #define ___KCLASSES_TESTS_H 3 | 4 | #include 5 | 6 | namespace tests 7 | { 8 | 9 | namespace __kclasses 10 | { 11 | 12 | namespace memBmp 13 | { 14 | extern testFn *tests[]; 15 | } 16 | 17 | } 18 | 19 | extern testFn *all[]; 20 | } 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /__kcore/include/platform/platform_include.h: -------------------------------------------------------------------------------- 1 | #ifndef PLATFORM_INCLUDE 2 | 3 | #include 4 | #include 5 | 6 | #define PLATFORM_INCLUDE(__subpath) 7 | #define PLATFORM_SOURCE_INCLUDE(__subpath) 8 | 9 | #endif 10 | 11 | -------------------------------------------------------------------------------- /__kcore/commonlibs/metalanguages/udi_bridge.udimprops: -------------------------------------------------------------------------------- 1 | properties_version 0x101 2 | 3 | name 1 4 | supplier 2 5 | contact 3 6 | shortname udi_physio 7 | release 1 0x101 8 | 9 | requires udi 0x101 10 | 11 | provides udi_physio 0x101 12 | 13 | message 1 Zambesii UDI Bridge Metalanguage Implementation 14 | message 2 Zambesii 15 | message 3 N/A 16 | -------------------------------------------------------------------------------- /__kcore/include/__kclasses/waitQueue.h: -------------------------------------------------------------------------------- 1 | #ifndef _WAIT_QUEUE_H 2 | #define _WAIT_QUEUE_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | template 7 | class WaitQueue 8 | { 9 | public: 10 | WaitQueue(void); 11 | error_t initialize(void); 12 | 13 | uarch_t getNItems(void); 14 | uarch_t getNWaiters(void); 15 | }; 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /include/extern.h: -------------------------------------------------------------------------------- 1 | #ifndef _CPP_EXTERN_H 2 | #define _CPP_EXTERN_H 3 | 4 | #ifdef __cplusplus 5 | #define CPPEXTERN_START extern "C" { 6 | #define CPPEXTERN_END } 7 | #define CPPEXTERN_PROTO extern "C" 8 | #else 9 | #define CPPEXTERN_START 10 | #define CPPEXTERN_END 11 | #define CPPEXTERN_PROTO extern 12 | #endif 13 | 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /__kcore/kernel/common/execTrib/elfParser.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "elfFuncs.h" 5 | 6 | 7 | struct sElfModuleState elfModuleState; 8 | 9 | struct sExecutableParser elfParser = 10 | { 11 | &elf_initialize, 12 | &elf_identify, 13 | &elf_isLocalArch 14 | }; 15 | 16 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "new": "cpp", 4 | "type_traits": "cpp" 5 | }, 6 | // "C_Cpp.errorSquiggles": "disabled", 7 | "terminal.integrated.env.linux": { 8 | "GTK_PATH": null 9 | }, 10 | "editor.insertSpaces": false, 11 | "editor.tabSize": 8, 12 | "editor.rulers": [80] 13 | } 14 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/taskTrib/load.h: -------------------------------------------------------------------------------- 1 | #ifndef _SCHEDULING_LOAD_H 2 | #define _SCHEDULING_LOAD_H 3 | 4 | #define CAPACITY_UPDATE_ADD 0x1 5 | #define CAPACITY_UPDATE_SUBTRACT 0x2 6 | #define CAPACITY_UPDATE_SET 0x3 7 | 8 | #define LOAD_UPDATE_ADD 0x1 9 | #define LOAD_UPDATE_SUBTRACT 0x2 10 | #define LOAD_UPDATE_SET 0x3 11 | 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /__kcore/include/chipset/terminalFwRiv.h: -------------------------------------------------------------------------------- 1 | #ifndef _CHIPSET_TERMINAL_FIRMWARE_RIVULET_H 2 | #define _CHIPSET_TERMINAL_FIRMWARE_RIVULET_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | struct sIbmPc_TerminalBuff 7 | { 8 | ubit8 ch; 9 | ubit8 attr; 10 | }; 11 | 12 | struct sTerminalFwRiv 13 | { 14 | sIbmPc_TerminalBuff *buffPtr; 15 | }; 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /__kcore/__kthreads/i586/Makefile.am: -------------------------------------------------------------------------------- 1 | BUILT_SOURCES=crt1.S 2 | 3 | noinst_LIBRARIES=lib__kthreadsCore.a 4 | lib__kthreadsCore_a_SOURCES=main.cpp __kcpuPowerOnEntry.S __kcpuPowerOnMain.cpp \ 5 | crt0.S crt1.S crti.S crtn.S 6 | 7 | crt1.S: $(srcdir)/crt0.S 8 | $(LN_S) -f $< $@ 9 | 10 | main.$(OBJEXT): AM_CXXFLAGS += -Wno-variadic-macros 11 | 12 | CLEANFILES=crt1.S 13 | -------------------------------------------------------------------------------- /__kcore/commonlibs/metalanguages/floodplainn.udimprops: -------------------------------------------------------------------------------- 1 | properties_version 0x101 2 | 3 | name 1 4 | supplier 2 5 | contact 3 6 | shortname zbz_fplainn 7 | release 1 v0.00.000 8 | 9 | message 1 Zambesii Floodplainn metalanguage library 10 | message 2 Zambesii 11 | message 3 N/A 12 | 13 | requires udi 0x101 14 | provides zbz_fplainn 0x0 15 | 16 | rank 1 identifier 17 | -------------------------------------------------------------------------------- /__kcore/include/__kstdlib/__kcxxCast.h: -------------------------------------------------------------------------------- 1 | #ifndef ___KCXX_CAST_H 2 | #define ___KCXX_CAST_H 3 | 4 | #define R_CAST(__type,__var) reinterpret_cast<__type>( __var ) 5 | #define C_CAST(__type,__var) const_cast<__type>( __var ) 6 | #define S_CAST(__type,__var) static_cast<__type>( __var ) 7 | #define D_CAST(__type,__var) dynamic_cast<__type>( __var ) 8 | 9 | #endif 10 | 11 | -------------------------------------------------------------------------------- /__kcore/include/platform/x8632-ibmPc/memory.h: -------------------------------------------------------------------------------- 1 | #ifndef _PLATFORM_MEMORY_H 2 | #define _PLATFORM_MEMORY_H 3 | 4 | #include 5 | #include 6 | 7 | #define PLATFORM_MEMORY_GET___KSYMBOL_PADDR(__sym) \ 8 | ((((uarch_t)&__sym) - ARCH_MEMORY___KLOAD_VADDR_BASE) \ 9 | + CHIPSET_MEMORY___KLOAD_PADDR_BASE) 10 | 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /programs/zudi/README.md: -------------------------------------------------------------------------------- 1 | # Zambesii UDIProps Compiler and Parser: 2 | 3 | Currently it comprises: 4 | * A binary database compiler, which parses and compiles 5 | UDI udiprops driver configuration files into a machine readable 6 | format on behalf of the kernel. 7 | * A simple shell script which gathers all udiprops files within a target 8 | folder, and adds them to the binary index. 9 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/floodplainn/tests.h: -------------------------------------------------------------------------------- 1 | #ifndef _FPLAINN_TESTS_H 2 | #define _FPLAINN_TESTS_H 3 | 4 | #include 5 | 6 | namespace tests 7 | { 8 | namespace kernel 9 | { 10 | namespace floodplainn 11 | { 12 | namespace zudi 13 | { 14 | extern testFn tests[]; 15 | } 16 | namespace zum 17 | { 18 | extern testFn tests[]; 19 | } 20 | } 21 | } 22 | } 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /__kcore/kernel/common/floodplainn/udi_mei_call.cpp: -------------------------------------------------------------------------------- 1 | 2 | #define UDI_VERSION 0x101 3 | #include 4 | #include <__kstdlib/__kclib/stdarg.h> 5 | 6 | 7 | void udi_mei_call( 8 | udi_cb_t *gcb, 9 | udi_mei_init_t *meta_info, 10 | udi_index_t meta_ops_num, 11 | udi_index_t vec_idx, 12 | ... 13 | ) 14 | { 15 | va_list args; 16 | 17 | va_start(args, vec_idx); 18 | va_end(args); 19 | } 20 | -------------------------------------------------------------------------------- /__kcore/include/arch/arch_include.h: -------------------------------------------------------------------------------- 1 | #ifndef ARCH_INCLUDE 2 | 3 | #include 4 | 5 | #ifdef CONFIG_ARCH_x86_32 6 | #define ARCH_INCLUDE(__subpath) 7 | #define ARCH_SOURCE_INCLUDE(__subpath) 8 | #else 9 | #error "No recognizible architecture defined. Try --arch-MY_ARCH in the \ 10 | configure script." 11 | #endif 12 | 13 | #endif 14 | 15 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/kernel_include.h: -------------------------------------------------------------------------------- 1 | #ifndef KERNEL_INCLUDE 2 | 3 | #include 4 | 5 | #ifdef CONFIG_ARCH_x86_32 6 | #define KERNEL_INCLUDE(__subpath) 7 | #define KERNEL_SOURCE_INCLUDE(__subpath) 8 | #else 9 | #error "No recognized arch selected in config script. Try \ 10 | --arch=MY_ARCH." 11 | #endif 12 | 13 | #endif 14 | 15 | -------------------------------------------------------------------------------- /__kcore/__kclasses/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES=lib__kclasses.a 2 | lib__kclasses_a_SOURCES=memBmp.cpp bitmap.cpp allocTable.cpp pageTableCache.cpp slamCache.cpp \ 3 | debugPipe.cpp debugBuffer.cpp memReservoir.cpp heap.cpp cachePool.cpp \ 4 | hardwareIdList.cpp singleWaiterQueue.cpp \ 5 | test_memBmp.cpp 6 | 7 | memReservoir.$(OBJEXT): CXXFLAGS+=-Wno-frame-address 8 | test_memBmp.$(OBJEXT): CXXFLAGS+=-Wno-variadic-macros 9 | -------------------------------------------------------------------------------- /__kcore/chipset/ibmPc/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES=libchipsetCore.a 2 | libchipsetCore_a_SOURCES=regionMap.cpp i8259a.cpp findTables.cpp irqControl.cpp \ 3 | memoryDetection.cpp vgaTerminal.cpp zkcmCore.cpp \ 4 | cpuDetection.cpp memoryAreas.cpp zkcmIbmPcState.cpp timerControl.cpp \ 5 | rtcmos.cpp isa_busPinMappings.cpp busPinMappings.cpp i8254.cpp \ 6 | udi_init_info.cpp i8254_pit.cpp rs232.cpp chipset_root_devices.cpp 7 | -------------------------------------------------------------------------------- /__kcore/include/arch/x8632/cpuEnumeration.h: -------------------------------------------------------------------------------- 1 | #ifndef _x86_32_CPU_ENUMERATION_H 2 | #define _x86_32_CPU_ENUMERATION_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | #define CPUENUM_UNSUPPORTED_CPU 0x1 7 | #define CPUENUM_CPU_MODEL_UNCLEAR 0x2 8 | #define CPUENUM_CPU_MODEL_UNKNOWN 0x3 9 | 10 | namespace x86CpuEnumeration 11 | { 12 | status_t intel(void); 13 | status_t amd(void); 14 | } 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /__kcore/commonlibs/metalanguages/zbz_chipset.udimprops: -------------------------------------------------------------------------------- 1 | properties_version 0x101 2 | 3 | shortname zbz_cpst 4 | name 1 5 | supplier 2 6 | contact 3 7 | release 1 v0.00.000 8 | 9 | message 1 Zambesii chipset metalanguage 10 | message 2 Zambesii 11 | message 3 N/A 12 | 13 | requires udi 0x101 14 | provides zbz_chipset 0x0 15 | 16 | module main 17 | 18 | rank 1 bus_type zbz_chpst_bus_name 19 | rank 2 identifier 20 | 21 | -------------------------------------------------------------------------------- /__kcore/firmware/ibmPcBios/x86EmuAuxFuncs.h: -------------------------------------------------------------------------------- 1 | #ifndef _x86_EMU_MEMORY_AUXILIARY_FUNCTIONS_H 2 | #define _x86_EMU_MEMORY_AUXILIARY_FUNCTIONS_H 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | #define XEAEXTERN extern "C" 8 | #else 9 | #define XEAEXTERN extern 10 | #endif 11 | 12 | XEAEXTERN X86EMU_pioFuncs x86Emu_ioFuncs; 13 | XEAEXTERN X86EMU_memFuncs x86Emu_memFuncs; 14 | 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /__kcore/commonlibs/metalanguages/zbz_root.udimprops: -------------------------------------------------------------------------------- 1 | properties_version 0x101 2 | 3 | name 1 4 | supplier 2 5 | contact 3 6 | shortname zbz_root 7 | release 1 v0.00.000 8 | 9 | message 1 Zambesii root bus metalanguage library 10 | message 2 Zambesii 11 | message 3 N/A 12 | 13 | requires udi 0x101 14 | requires udi_physio 0x101 15 | provides zbz_root 0x0 16 | 17 | rank 1 bus_type zbz_root_device_type 18 | rank 3 identifier 19 | -------------------------------------------------------------------------------- /__kcore/include/__kstdlib/__kflagManipulation.h: -------------------------------------------------------------------------------- 1 | #ifndef _FLAG_MANIPULATION_H 2 | #define _FLAG_MANIPULATION_H 3 | 4 | #include 5 | 6 | #define FLAG_NBITS_IN(__field) \ 7 | (sizeof((__field)) * __BITS_PER_BYTE__) 8 | 9 | #define FLAG_SET(__var,__flag) ((__var) |= (__flag)) 10 | #define FLAG_UNSET(__var,__flag) ((__var) &= ~((__flag))) 11 | #define FLAG_TEST(__var,__flag) ((__var) & (__flag)) 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /__kcore/include/arch/paddr_t.txt: -------------------------------------------------------------------------------- 1 | paddr_t is an integral type used to represent a physical address on the 2 | relevant architecture. 3 | 4 | On the x86-32, for example, with the PAE, we need a 64 bit type to represent a 5 | physical address since the CPU supports a physical address space of > 2^32 in 6 | PAE mode. 7 | 8 | For an architecture without any sort of physical address space extension or 9 | quirk, just define it to the architecture's word size. 10 | 11 | -------------------------------------------------------------------------------- /__kcore/include/__kstdlib/__kcxxlib/mutex: -------------------------------------------------------------------------------- 1 | #ifndef __MUTEX_H 2 | #define __MUTEX_H 3 | 4 | namespace std 5 | { 6 | class spinlock; 7 | class recursive_spinlock; 8 | 9 | template class lock_guard; 10 | template class unique_lock; 11 | 12 | template 13 | void swap(unique_lock &x, unique_lock &y) throw(); 14 | 15 | void lock(void); 16 | } 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/vfsTrib/commonOperations.h: -------------------------------------------------------------------------------- 1 | #ifndef _VFS_COMMON_OPERATIONS_H 2 | #define _VFS_COMMON_OPERATIONS_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | namespace vfs 7 | { 8 | class DirectoryOperations 9 | { 10 | public: 11 | virtual error_t openDirectory(utf8Char *name, void **handle)=0; 12 | virtual error_t readDirectory(void *handle, void **tagInfo)=0; 13 | virtual void closeDirectory(void *handle)=0; 14 | }; 15 | } 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /__kcore/include/__kthreads/thread_include.h: -------------------------------------------------------------------------------- 1 | #ifndef THREAD_INCLUDE 2 | 3 | #include 4 | 5 | #ifdef CONFIG_ARCH_x86_32 6 | #define THREAD_INCLUDE(__subpath) <__kthreads/x8632/__subpath> 7 | #define THREAD_SOURCE_INCLUDE(__subpath) <__kthreads/x8632/__subpath> 8 | #else 9 | #error "No architecture was defined in the config file. Please either \ 10 | edit the config file, or use the configure script with option \ 11 | --arch=MY_ARCH." 12 | #endif 13 | 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /__kcore/include/chipset/zkcm/memoryConfig.h: -------------------------------------------------------------------------------- 1 | #ifndef _CHIPSET_MEMORY_CONFIG_H 2 | #define _CHIPSET_MEMORY_CONFIG_H 3 | 4 | #include 5 | 6 | /** EXPLANATION: 7 | * Interface used to allow a chipset porter to define the absolute size of RAM 8 | * at compile time. 9 | **/ 10 | 11 | struct sZkcmMemoryConfig 12 | { 13 | // Just in case some chipset doesn't have memory starting at paddr 0x0. 14 | paddr_t memBase; 15 | paddr_t memSize; 16 | }; 17 | 18 | #endif 19 | 20 | -------------------------------------------------------------------------------- /__kcore/include/chipset/pkg/watchdogMod.h: -------------------------------------------------------------------------------- 1 | #ifndef _WATCHDOG_CHIPSET_MODULE_H 2 | #define _WATCHDOG_CHIPSET_MODULE_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | class WatchdogMod 7 | { 8 | public: 9 | error_t initialize(void); 10 | error_t shutdown(void); 11 | error_t suspend(void); 12 | error_t restore(void); 13 | 14 | status_t setAction(ubit8 action); 15 | status_t setTimeoutMs(ubit32 ms); 16 | status_t enable(void); 17 | status_t disable(void); 18 | }; 19 | 20 | #endif 21 | 22 | -------------------------------------------------------------------------------- /__kcore/include/__kclasses/heapCache.h: -------------------------------------------------------------------------------- 1 | #ifndef _HEAP_CACHE_H 2 | #define _HEAP_CACHE_H 3 | 4 | class HeapCache 5 | { 6 | public: 7 | HeapCache(void) 8 | : 9 | sObjectize(0) 10 | {}; 11 | 12 | HeapCache(uarch_t sObjectize) 13 | : 14 | sObjectize(sObjectize) 15 | {}; 16 | 17 | virtual ~HeapCache(void) {} 18 | 19 | public: 20 | //virtual void *allocate(void) { return NULL; }; 21 | virtual void free(void *) {}; 22 | 23 | public: 24 | uarch_t sObjectize; 25 | }; 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /__kcore/include/arch/x8632/__kstdlib/__kclib/setjmp.h: -------------------------------------------------------------------------------- 1 | #ifndef _SET_JMP_H 2 | #define _SET_JMP_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | typedef struct c_jmp_buf 7 | { 8 | uarch_t eip; 9 | uarch_t esp, ebp; 10 | uarch_t ebx, ecx, edx; 11 | uarch_t esi, edi; 12 | } jmp_buf; 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | int setjmp(jmp_buf *state); 19 | void longjmp(jmp_buf *state, int ret); 20 | 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /__kcore/firmware/ibmPcBios/debug-notes.txt: -------------------------------------------------------------------------------- 1 | * 2013-05-23: 2 | prim_ops.c: 3 | In function div_long(), line 2427 4 | 5 | " 6 | ===============>if (h_dvd < (signed)(h_s + carry)) { <========================== 7 | h_s >>= 1;" 8 | 9 | Was receiving a warning about this comparison (signed and 10 | unsigned ints being compared). Did my best to choose the least 11 | harmful conversion, and chose to cast the right-hand operand to 12 | signed. May have been wrong, and this may be a bug. 13 | 14 | -------------------------------------------------------------------------------- /__kcore/include/firmware/ibmPcBios/ibmPcBios_coreFuncs.h: -------------------------------------------------------------------------------- 1 | #ifndef _IBM_PC_BIOS_CORE_FUNCTIONS_H 2 | #define _IBM_PC_BIOS_CORE_FUNCTIONS_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | #include "ibmPcBios_regManip.h" 6 | 7 | namespace ibmPcBios 8 | { 9 | error_t initialize(void); 10 | error_t shutdown(void); 11 | error_t suspend(void); 12 | error_t restore(void); 13 | 14 | void acquireLock(void); 15 | void releaseLock(void); 16 | void executeInterrupt(ubit8 intNo); 17 | } 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/panic.h: -------------------------------------------------------------------------------- 1 | #ifndef _PANIC_H 2 | #define _PANIC_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | // Handle a standard kernel error. 7 | void panic(error_t err, utf8Char *str=NULL) __attribute__((noreturn)); 8 | // Handle a generic error with a specific message. 9 | void panic(utf8Char *str, error_t err=ERROR_SUCCESS) __attribute__((noreturn)); 10 | // Panic without attempting to print any message at all. 11 | void panic(void) __attribute__((noreturn)); 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /__kcore/include/arch/x8632/gdt.h: -------------------------------------------------------------------------------- 1 | #ifndef _x86_32_GDT_H 2 | #define _x86_32_GDT_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | struct sX8632GdtEntry 7 | { 8 | ubit16 limitLow; 9 | ubit16 baseLow; 10 | ubit8 baseMid; 11 | ubit8 opts; 12 | ubit8 gran; 13 | ubit8 baseHigh; 14 | } __attribute__((packed)); 15 | 16 | struct sX8632GdtPtr 17 | { 18 | ubit16 limit; 19 | struct sX8632GdtEntry *baseAddr; 20 | } __attribute__((packed)); 21 | 22 | extern struct sX8632GdtPtr x8632GdtPtr; 23 | #endif 24 | 25 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/memoryTrib/allocFlags.h: -------------------------------------------------------------------------------- 1 | #ifndef _MEMORY_ALLOCATION_FLAGS_H 2 | #define _MEMORY_ALLOCATION_FLAGS_H 3 | 4 | #define MEMALLOC_NO_FAKEMAP (1<<0) 5 | #define MEMALLOC_PURE_VIRTUAL (1<<1) 6 | #define MEMALLOC_NO_SLEEP (1<<2) 7 | #define MEMALLOC_NO_FLUSH_ALL (1<<3) 8 | #define MEMALLOC_NO_FLUSH_RESERVOIR (1<<4) 9 | #define MEMALLOC_NO_FLUSH_PTCACHE (1<<5) 10 | #define MEMALLOC_NO_FLUSH_BANK_CACHE (1<<6) 11 | #define MEMALLOC_LOCAL_FLUSH_ONLY (1<<7) 12 | 13 | #endif 14 | 15 | -------------------------------------------------------------------------------- /__kcore/arch/i586/x8632_generalProtectionFault.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include <__kclasses/debugPipe.h> 5 | #include "exceptions.h" 6 | 7 | status_t x8632_gpf(RegisterContext *regs, ubit8) 8 | { 9 | printf(NOTICE OPTS(NOLOG) 10 | "#GPF: Culprit selector %x. Halting.\n", 11 | regs->errorCode); 12 | 13 | for (;FOREVER;) 14 | { 15 | cpuControl::disableInterrupts(); 16 | cpuControl::halt(); 17 | }; 18 | 19 | return ERROR_SUCCESS; 20 | } 21 | 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ldSearchDirs.ld 2 | .goutput* 3 | *.[oas] 4 | *.ekf 5 | *.ekfs 6 | *.zxe 7 | bochsrc* 8 | *.bz2 9 | tmp 10 | flp 11 | hdd 12 | fat 13 | foo 14 | *.tmp 15 | *.swp 16 | .bochsrc 17 | *.iso 18 | *~ 19 | *.zudi-index 20 | *.geany 21 | cscope.out 22 | /b 23 | /b-* 24 | /*-b 25 | 26 | # Autotools 27 | aclocal.m4 28 | autom4te.cache/ 29 | /autotools-aux/ 30 | configure 31 | config.log 32 | config.status 33 | Makefile.vars 34 | Makefile 35 | Makefile.in 36 | include/config.h* 37 | include/stamp-h* 38 | confdefs.h 39 | -------------------------------------------------------------------------------- /__kcore/include/arch/x8632/arch.h: -------------------------------------------------------------------------------- 1 | #ifndef _ARCH_H 2 | #define _ARCH_H 3 | 4 | #define __x86_32__ 5 | #define __32_BIT__ 6 | #define __ARCH_LITTLE_ENDIAN__ 7 | #define __BITS_PER_BYTE__ 8 8 | 9 | #define __VADDR_NBITS__ 32 10 | 11 | #ifdef CONFIG_ARCH_x86_32_PAE 12 | #define __PADDR_NBITS__ 64 13 | #else 14 | #define __PADDR_NBITS__ 32 15 | #endif 16 | 17 | #define ARCH_SHORT_STRING "x86-32" 18 | #define ARCH_LONG_STRING "Intel IA-32 architecture compatible" 19 | #define ARCH_PATH x8632 20 | 21 | #endif 22 | 23 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/smpTypes.h: -------------------------------------------------------------------------------- 1 | #ifndef _SMP_TYPES_H 2 | #define _SMP_TYPES_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | #define CPUID_INVALID ((cpu_t)~0) 7 | 8 | typedef uarch_t cpu_t; 9 | 10 | enum bspPlugTypeE 11 | { 12 | BSP_PLUGTYPE_NOTBSP=0, 13 | BSP_PLUGTYPE_FIRSTPLUG, 14 | BSP_PLUGTYPE_HOTPLUG 15 | }; 16 | 17 | #ifdef __cplusplus 18 | /* There are C files which include this file, so any C++ code in here 19 | * should be properly guarded. 20 | **/ 21 | #endif 22 | 23 | #endif 24 | 25 | -------------------------------------------------------------------------------- /__kcore/include/__kclasses/swampInfoNode.h: -------------------------------------------------------------------------------- 1 | #ifndef _SWAMP_INFO_NODE_H 2 | #define _SWAMP_INFO_NODE_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | class SwampInfoNode 7 | { 8 | public: 9 | SwampInfoNode( 10 | void *baseAddr=NULL, uarch_t nPages=0, 11 | SwampInfoNode *prev=NULL, SwampInfoNode *next=NULL) 12 | : 13 | baseAddr(baseAddr), nPages(nPages), 14 | prev(prev), next(next) 15 | {} 16 | 17 | public: 18 | void *baseAddr; 19 | uarch_t nPages; 20 | SwampInfoNode *prev, *next; 21 | }; 22 | 23 | #endif 24 | 25 | -------------------------------------------------------------------------------- /__kcore/include/arch/x8632/idt.h: -------------------------------------------------------------------------------- 1 | #ifndef _x86_32_IDT_H 2 | #define _x86_32_IDT_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | struct sX8632IdtEntry 7 | { 8 | ubit16 baseLow; 9 | ubit16 seg; 10 | ubit8 rsvd; 11 | ubit8 flags; 12 | ubit16 baseHigh; 13 | } __attribute__((packed)); 14 | 15 | struct sX8632IdtPtr 16 | { 17 | ubit16 limit; 18 | struct sX8632IdtEntry *idt; 19 | } __attribute__((packed)); 20 | 21 | extern struct sX8632IdtEntry x8632Idt[]; 22 | extern struct sX8632IdtPtr x8632IdtPtr; 23 | 24 | #endif 25 | 26 | -------------------------------------------------------------------------------- /__kcore/include/arch/debug.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include ARCH_INCLUDE(debug.h) 3 | 4 | #ifndef _ARCH_DEBUG_COMMON_H 5 | #define _ARCH_DEBUG_COMMON_H 6 | 7 | namespace debug 8 | { 9 | struct sStackDescriptor 10 | { 11 | void dump(void); 12 | 13 | void *start, *eof; 14 | uarch_t nBytes; 15 | }; 16 | 17 | void getCurrentStackInfo(sStackDescriptor *desc); 18 | void printStackTrace(void *startFrame, sStackDescriptor *desc); 19 | void printStackArguments(void *stackFrame, void *stackPointer); 20 | } 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /__kcore/include/arch/memory.txt: -------------------------------------------------------------------------------- 1 | memory.h: 2 | 3 | Must define the following macros for the architecture: 4 | 5 | #define ARCH_MEMORY___KLOAD_VADDR_BASE x 6 | This macro tells the kernel build where in the virtual address space of 7 | every process it resides. The kernel has been programmed to be able to 8 | stay within a fixed range of virtual memory in each address space and not 9 | cause any problems. 10 | 11 | You can even, for example, have a kernel build which takes up for example, 12 | the lower 1GB of a 4GB address space. 13 | 14 | -------------------------------------------------------------------------------- /__kcore/arch/i586/schedTimer.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | 6 | // If this doesn't return ERROR_SUCCESS, that's a lot of trouble. 7 | error_t SchedTimer::initialize(void) 8 | { 9 | /** EXPLANATION: 10 | * Detect LAPIC. If it exists, initialize it to a known state and 11 | * return. 12 | * 13 | * If no LAPIC, ask Chipset Support Package for a new timer source for 14 | * the scheduler. If it cannot provide that, then we return non-success 15 | * status. 16 | **/ 17 | 18 | -------------------------------------------------------------------------------- /__kcore/include/arch/x8632/memory.h: -------------------------------------------------------------------------------- 1 | #ifndef _MEMORY_H 2 | #define _MEMORY_H 3 | 4 | //Virtual load base for the kernel. 3GB mark on x86-32. 5 | #define ARCH_MEMORY___KLOAD_VADDR_BASE 0xC0000000 6 | #define ARCH_MEMORY_VADDR_IS_IN___KVADDRSPACE(vaddr) \ 7 | ((((uintptr_t)(vaddr)) >= ARCH_MEMORY___KLOAD_VADDR_BASE) \ 8 | && (((uintptr_t)(vaddr)) < (ARCH_MEMORY___KLOAD_VADDR_BASE + \ 9 | ARCH_MEMORY___KLOAD_VADDR_NBYTES))) 10 | #define ARCH_MEMORY___KLOAD_VADDR_NBYTES 0x40000000 11 | #define ARCH_MEMORY___KLOAD_VADDR_END 0xFFFFFFFF 12 | 13 | #endif 14 | 15 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/cpuTrib/powerOperations.h: -------------------------------------------------------------------------------- 1 | #ifndef _CPU_POWER_OPERATIONS_H 2 | #define _CPU_POWER_OPERATIONS_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | #define CPUSTREAM_POWEROPS_POWER_ON 0 7 | #define CPUSTREAM_POWEROPS_POWER_OFF 1 8 | #define CPUSTREAM_POWEROPS_LIGHT_SLEEP 2 9 | #define CPUSTREAM_POWEROPS_DEEP_SLEEP 3 10 | 11 | /* This is an array of architecture specific power operation preludes. 12 | * See kernel//cpuTrib/powerOperations.cpp. 13 | **/ 14 | extern status_t (*powerOperations[])(uarch_t); 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /__kcore/include/platform/x8632-ibmPc/cpu.h: -------------------------------------------------------------------------------- 1 | #ifndef _x86_32_IBMPC_CPU_H 2 | #define _x86_32_IBMPC_CPU_H 3 | 4 | /** EXPLANATION: 5 | * We use the memory space as follows: 6 | * CPU poweron static data (temporary GDT, etc) is placed within the 2 frames 7 | * beginning at 0xA000. The code for CPU poweron begins after it, at 0xC000. 8 | * 9 | * Remember that the x86 real mode emulator (x86Emu) uses the frame at 0x4000. 10 | **/ 11 | #define x8632_IBMPC_POWERON_PADDR_BASE 0x8000 12 | #define x8632_IBMPC_POWERON_GET_VECTOR(_paddr) (((_paddr) >> 12) & 0xFF) 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /__kcore/kernel/i586/cpuTrib.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include <__kstdlib/__ktypes.h> 5 | #include 6 | #include 7 | 8 | #if __SCALING__ >= SCALING_SMP 9 | CpuStream *CpuTrib::getCurrentCpuStream(void) 10 | { 11 | uarch_t dr0; 12 | // Read the current cpu's struct from the dr0 register. 13 | asm volatile ( 14 | "movl %%dr0, %0 \n\t" 15 | : "=r" (dr0) 16 | ); 17 | 18 | return reinterpret_cast( dr0 ); 19 | } 20 | #endif 21 | 22 | -------------------------------------------------------------------------------- /__kcore/include/__kclasses/__kpageBlock.h: -------------------------------------------------------------------------------- 1 | #ifndef ___KPAGE_BLOCK_H 2 | #define ___KPAGE_BLOCK_H 3 | 4 | #include 5 | 6 | #define PAGEBLOCK_NENTRIES(__type) \ 7 | ((PAGING_BASE_SIZE - sizeof(typename __kPageBlock::sHeader)) \ 8 | /sizeof(__type)) 9 | 10 | template 11 | class __kPageBlock 12 | { 13 | public: 14 | struct sHeader 15 | { 16 | __kPageBlock *next; 17 | // ubit32: We assume page sizes won't be reaching 4GB soon. 18 | ubit32 nFreeEntries; 19 | } header; 20 | T entries[PAGEBLOCK_NENTRIES(T)]; 21 | }; 22 | 23 | #endif 24 | 25 | -------------------------------------------------------------------------------- /__kcore/include/commonlibs/libx86mp/libx86mp.h: -------------------------------------------------------------------------------- 1 | #ifndef _x86_MP_LIBRARY_H 2 | #define _x86_MP_LIBRARY_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | #include "mpTables.h" 6 | #include "lapic.h" 7 | #include "ioApic.h" 8 | 9 | /** EXPLANATION: 10 | * Stateful library which scans and parses x86 MP tables. 11 | * 12 | * The library is stateful in that it caches information. That is, when it 13 | * finds an MP Floating Pointer, for example, it caches that pointer's location, 14 | * so subsequent calls to the library do not need to rescan for an MP FP. 15 | **/ 16 | 17 | 18 | #endif 19 | 20 | -------------------------------------------------------------------------------- /scripts/nsource: -------------------------------------------------------------------------------- 1 | hTotal=`find $1 | grep '.*\.h$' | wc -l` 2 | cTotal=`find $1 | grep '.*\.c$' | wc -l` 3 | sTotal=`find $1 | grep '.*\.s$' | wc -l` 4 | cppTotal=`find $1 | grep '.*\.cpp$' | wc -l` 5 | 6 | if [ "$2" == "" ]; then 7 | echo $((hTotal+cTotal+sTotal+cppTotal)) 8 | else 9 | if [ "$2" == "h" ]; then echo $hTotal; 10 | elif [ "$2" == "c" ]; then echo $cTotal; 11 | elif [ "$2" == "s" -o "$2" == "S" ]; then echo $sTotal; 12 | elif [ "$2" == "cpp" -o "$2" == "C" ]; then echo $cppTotal; 13 | else 14 | echo 'Usage: nsource [folder [h|c|s|C]]' 1>&2 15 | echo 0 16 | fi 17 | fi 18 | 19 | -------------------------------------------------------------------------------- /__kcore/include/firmware/firmware_include.h: -------------------------------------------------------------------------------- 1 | #ifndef FIRMWARE_INCLUDE 2 | 3 | #include 4 | 5 | #ifdef CONFIG_FIRMWARE_IBM_PC_BIOS 6 | #define FIRMWARE_INCLUDE(__subpath) 7 | #define FIRMWARE_SOURCE_INCLUDE(__subpath) 8 | #elif defined(CONFIG_FIRMWARE_UEFI) 9 | #define FIRMWARE_INCLUDE(__subpath) 10 | #define FIRMWARE_SOURCE_INCLUDE(__subpath) 11 | #else 12 | #error "No firmware chosen in configuration script. Try \ 13 | --firmware=MY_FIRMWARE." 14 | #endif 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /include/scaling.h: -------------------------------------------------------------------------------- 1 | #ifndef _SCALING_H 2 | #define _SCALING_H 3 | 4 | #include 5 | 6 | #define SCALING_UNI_PROCESSOR 0 7 | #define SCALING_SMP 1 8 | #define SCALING_CC_NUMA 2 9 | #define SCALING_NONCC_NUMA 3 10 | 11 | #ifdef CONFIG_CC_NUMA 12 | #define __SCALING__ SCALING_CC_NUMA 13 | #elif defined( CONFIG_SMP ) 14 | #define __SCALING__ SCALING_SMP 15 | #elif defined( CONFIG_UNI_PROCESSOR ) 16 | #define __SCALING__ SCALING_UNI_PROCESSOR 17 | #else 18 | #error "No scaling mode selected. Please re-run kernel configuration with --enable-scaling=" 19 | #endif 20 | 21 | #endif 22 | 23 | -------------------------------------------------------------------------------- /__kcore/chipset/ibmPc/ibm_pc.udidprops: -------------------------------------------------------------------------------- 1 | properties_version 0x101 2 | 3 | name 1 4 | supplier 2 5 | contact 3 6 | shortname pc_chpst 7 | release 1 v0.00.000 8 | 9 | message 1 IBM-PC compatible chipset driver 10 | message 2 Zambesii 11 | message 3 N/A 12 | 13 | requires udi 0x101 14 | requires zbz_root 0x0 15 | #requires zudi_bridge 0x101 16 | 17 | meta 1 zbz_root 18 | 19 | module main 20 | region 0 21 | 22 | message 100 IBM-PC compatible chipset 23 | device 100 1 \ 24 | bus_type string zbz_root \ 25 | zbz_root_chipset_short_name string IBM-PC \ 26 | zbz_root_chipset_long_name string IBM-PC-compatible-chipset 27 | 28 | -------------------------------------------------------------------------------- /__kcore/include/__kstdlib/utf16.h: -------------------------------------------------------------------------------- 1 | #ifndef _UTF_16_H 2 | #define _UTF_16_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | namespace utf16 7 | { 8 | inline unicodePoint toCodepoint(utf16Char *str) 9 | { 10 | unicodePoint c; 11 | 12 | c = (str[1] & 0x3FF); 13 | c |= (str[0] & ((1<<6) - 1)) << 10; 14 | c |= (((str[0] >> 6) & 0x1F) + 1) << 16; 15 | 16 | return c; 17 | } 18 | 19 | inline void toUtf16(unicodePoint c, utf16Char *h, utf16Char *l) 20 | { 21 | *l = (c & 0x3FF) | 0xDC00; 22 | *h = ((c & 0xFFFF) >> 10) 23 | | ((((c >> 16) & 0x1F) - 1) << 6) 24 | | 0xD800; 25 | } 26 | 27 | } 28 | 29 | #endif 30 | 31 | -------------------------------------------------------------------------------- /__kcore/include/chipset/memoryAreas.h: -------------------------------------------------------------------------------- 1 | #ifndef _CHIPSET_MEMORY_AREAS_H 2 | #define _CHIPSET_MEMORY_AREAS_H 3 | 4 | 5 | #include 6 | #include <__kstdlib/__ktypes.h> 7 | 8 | #include 9 | #include CHIPSET_INCLUDE(memoryAreas.h) 10 | 11 | 12 | namespace chipsetMemAreas 13 | { 14 | struct sArea 15 | { 16 | utf8Char *name; 17 | paddr_t basePaddr; 18 | paddr_t size; 19 | void *vaddr; 20 | }; 21 | 22 | error_t mapArea(ubit16 index); 23 | error_t unmapArea(ubit16 index); 24 | void *getArea(ubit16 index); 25 | struct sArea *getAreaInfo(ubit16 index); 26 | } 27 | 28 | #endif 29 | 30 | -------------------------------------------------------------------------------- /__kcore/kernel/common/vfsTrib/vfsTrib.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include <__kstdlib/__kclib/string.h> 3 | #include <__kstdlib/__kclib/string8.h> 4 | #include <__kstdlib/__kclib/stdlib.h> 5 | #include <__kstdlib/__kcxxlib/new> 6 | #include <__kclasses/debugPipe.h> 7 | #include 8 | 9 | 10 | status_t vfs::getIndexOfNext( 11 | utf8Char *path, utf8Char splitChar, uarch_t maxLength) 12 | { 13 | uarch_t i; 14 | 15 | for (i=0; path[i] != '\0' && i 5 | #include 6 | #include 7 | 8 | #define DEBUGTRIB "Debug Trib: " 9 | 10 | #define DEBUGTRIB_ENTER_DELAY 2000 11 | 12 | class DebugTrib 13 | { 14 | public: 15 | DebugTrib(void); 16 | 17 | public: 18 | void enterFromIrq(void); 19 | void enterNoIrq(void); 20 | void exit(void); 21 | 22 | private: 23 | // The number of CPUs currently inside of the debugger. 24 | SharedResourceGroup cpuCount; 25 | }; 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /__kcore/commonlibs/drivers/zramdisk.udidprops: -------------------------------------------------------------------------------- 1 | properties_version 0x101 2 | 3 | shortname zramdisk 4 | name 1 5 | supplier 2 6 | contact 3 7 | release 1 v0.00.012 8 | 9 | message 1 Zambesii RAM-disk driver 10 | message 2 Zambesii 11 | message 3 N/A 12 | 13 | requires udi 0x101 14 | requires zbz_root 0x0 15 | requires udi_gio 0x101 16 | 17 | meta 1 zbz_root 18 | meta 2 udi_gio 19 | 20 | module main 21 | region 0 22 | region 1 23 | 24 | internal_bind_ops 2 1 1 2 1 25 | parent_bind_ops 1 0 1 1 26 | parent_bind_ops 1 0 1 1 27 | child_bind_ops 1 0 1 28 | 29 | message 100 Zambesii kernel RAM-disk device 30 | 31 | device 100 1 identifier string __kramdisk 32 | -------------------------------------------------------------------------------- /__kcore/arch/i586/__kexceptionTable.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "exceptions.h" 4 | 5 | __kexceptionFn *__kexceptionTable[20] = 6 | { 7 | &x8632_div_zero, 8 | &x8632_debug, 9 | &x8632_nmi, 10 | &x8632_breakpoint, 11 | &x8632_int_overflow, 12 | &x8632_bound, 13 | &x8632_invalid_opcode, 14 | &x8632_no_fpu, 15 | &x8632_double_fault, 16 | &x8632_fpu_segfault, 17 | &x8632_tss_except, 18 | &x8632_seg_not_present, 19 | &x8632_stack_fault, 20 | &x8632_gpf, 21 | &x8632_page_fault, 22 | &x8632_unknown_interrupt, 23 | &x8632_fpu_fault, 24 | &x8632_alignment_check, 25 | &x8632_machine_check, 26 | &x8632_reserved_vector 27 | }; 28 | 29 | -------------------------------------------------------------------------------- /__kcore/include/chipset/zkcm/timerControl_filters.h: -------------------------------------------------------------------------------- 1 | #ifndef _TIMER_CONTROL_FILTERS_H 2 | #define _TIMER_CONTROL_FILTERS_H 3 | 4 | #include 5 | #include <__kstdlib/__ktypes.h> 6 | 7 | namespace timerFilters 8 | { 9 | sarch_t modes(ZkcmTimerDevice *dev, ubit32 criteria, ubit32 flags); 10 | sarch_t resolutions( 11 | ZkcmTimerDevice *dev, ubit32 criteria, ubit32 flags); 12 | 13 | sarch_t ioLatency( 14 | ZkcmTimerDevice *dev, ZkcmTimerDevice::ioLatencyE criteria, 15 | ubit32 flags); 16 | 17 | sarch_t precision( 18 | ZkcmTimerDevice *dev, ZkcmTimerDevice::precisionE criteria, 19 | ubit32 flags); 20 | } 21 | 22 | #endif 23 | 24 | -------------------------------------------------------------------------------- /__kcore/chipset/ibmPc/regionMap.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include <__kstdlib/__ktypes.h> 4 | 5 | 6 | static sChipsetRegionMapEntry chipsetRegions[] = 7 | { 8 | { 9 | // DMA region. We reserve 2MB. 10 | 0x1000, 0x80000, 11 | NULL, 12 | 0 13 | } 14 | #ifdef CONFIG_ARCH_x86_32_PAE 15 | ,{ 16 | // PAE x86-32 PDP table allocator region. 1MB. 17 | 0x700000, 0x100000, 18 | NULL, 19 | 0 20 | } 21 | #endif 22 | }; 23 | 24 | static sChipsetRegionMap _chipsetRegionMap = 25 | { 26 | chipsetRegions, 27 | CHIPSET_MEMORY_NREGIONS 28 | }; 29 | 30 | sChipsetRegionMap *chipsetRegionMap = &_chipsetRegionMap; 31 | 32 | -------------------------------------------------------------------------------- /libraries/libzbzcore/libzbzcore.S: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** EXPLANATION: 4 | * This is the switchboard file for the syscall lib which is embedded into 5 | * the Endo-Kernel FS. 6 | * 7 | * As is to be expected, it should contain different code for each architecture. 8 | * 9 | * This is achieved through means of simply including the config.h file, and 10 | * analysing it to see which arch the kernel core was compiled for, then 11 | * including the right code here to be assembled. 12 | **/ 13 | 14 | #ifdef CONFIG_ARCH_x86_32 15 | #include "x8632/libzbzcore.S" 16 | #else 17 | #error "No known architecture chosen in configure script. Try --arch=Myarch." 18 | #endif 19 | 20 | -------------------------------------------------------------------------------- /__kcore/include/chipset/zkcm/memoryDetection.h: -------------------------------------------------------------------------------- 1 | #ifndef _ZKCM_MEMORY_DETECTION_H 2 | #define _ZKCM_MEMORY_DETECTION_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include <__kstdlib/__ktypes.h> 8 | 9 | class ZkcmMemoryDetectionMod 10 | { 11 | public: 12 | error_t initialize(void); 13 | error_t shutdown(void); 14 | error_t suspend(void); 15 | error_t restore(void); 16 | 17 | sZkcmMemoryConfig *getMemoryConfig(void); 18 | sZkcmNumaMap *getNumaMap(void); 19 | sZkcmMemoryMapS *getMemoryMap(void); 20 | 21 | // Memory hotplug API design proposed for a later date. 22 | }; 23 | 24 | #endif 25 | 26 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/memoryTrib/rawMemAlloc.h: -------------------------------------------------------------------------------- 1 | #ifndef _MEMORY_TRIB_RAW_MEM_ALLOC_H 2 | #define _MEMORY_TRIB_RAW_MEM_ALLOC_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | /** EXPLANATION: 7 | * In order to lessen the number of circular dependencies in the kernel, these 8 | * wrapper functions around MemoryTrib::rawMemAlloc() and 9 | * MemoryTrib::rawMemFree() have been implemented. Their sole purpose is to 10 | * allow circumnavigation of the need to include memoryTrib.h where it causes 11 | * an #include circular chaotic hell. 12 | **/ 13 | 14 | void *rawMemAlloc(uarch_t nPages, uarch_t flags); 15 | void rawMemFree(void *vaddr, uarch_t nPages); 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /__kcore/arch/i586/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES=libarchCore.a 2 | libarchCore_a_SOURCES=wPRanger_mapInc.cpp wPRanger_mapNoInc.cpp wPRanger_remapInc.cpp \ 3 | wPRanger_remapNoInc.cpp wPRanger_setAttributes.cpp wPRanger_lookup.cpp \ 4 | wPRanger_unmap.cpp wPRanger_getLevelRanges.cpp wPRanger_accessors.cpp \ 5 | wPRanger_convertFlags.cpp \ 6 | tlbControl.cpp \ 7 | gdt.c idt.cpp vectorHandlers.S setjmp.S string.cpp __kexceptionTable.cpp \ 8 | exceptions.cpp x8632_pageFault.cpp x8632_generalProtectionFault.cpp \ 9 | string8.cpp string16.cpp \ 10 | taskContext.cpp cpuid.S msr.S cpuEnumerationIntel.cpp cpuEnumerationAmd.cpp \ 11 | debug.cpp x8632_debugException.cpp x8632_breakpointException.cpp 12 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/memoryTrib/__kmemoryStream_methods.h: -------------------------------------------------------------------------------- 1 | #ifndef ___K_MEMORY_STREAM_METHODS_H 2 | #define ___K_MEMORY_STREAM_METHODS_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | /** EXPLANATION: 7 | * In order to lessen the number of circular dependencies in the kernel, these 8 | * wrapper functions around the kernel's Memory Stream instance, have been 9 | * implemented. Their sole purpose is to allow circumnavigation of the need to 10 | * include memoryStream.h where it causes an #include circular chaotic hell. 11 | **/ 12 | 13 | void *__kmemoryStream_memRealloc( 14 | void *oldmem, uarch_t oldNBytes, uarch_t newNBytes, 15 | uarch_t flags=0); 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /include/debug.h: -------------------------------------------------------------------------------- 1 | #ifndef _DEBUG_HELPER_H 2 | #define _DEBUG_HELPER_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | #define DEBUG_ON(__con) \ 7 | if (__con) \ 8 | { \ 9 | asm volatile("" ::: "memory"); \ 10 | asm volatile ( \ 11 | "pushl %%ecx \n\t " \ 12 | "movl $0, %%ecx \n\t" \ 13 | "1: \n\t" \ 14 | "cmp $1, %%ecx \n\t" \ 15 | "jne 1b \n\t" \ 16 | "popl %%ecx \n\t" \ 17 | ::: "memory"); \ 18 | } 19 | 20 | extern int oo, pp, qq, rr; 21 | extern char *pp0, *pp1, *pp2, *pp3; 22 | int testFunction(...); 23 | 24 | // GCC likes to warn me about this, and it gets really irritating. 25 | void PRINTFON(int __cond, const utf8Char *__str, ...); 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /__kcore/kernel/common/floodplainn/udiServiceCalls.cpp: -------------------------------------------------------------------------------- 1 | 2 | #define UDI_VERSION 0x101 3 | #include 4 | #include 5 | #include <__kstdlib/__kclib/assert.h> 6 | #include <__kstdlib/__kcxxlib/memory> 7 | #include <__kclasses/debugPipe.h> 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | 15 | void __udi_assert(const char *expr, const char *file, int line) 16 | { 17 | printf(FATAL"udi_assert failure: line %d of %s; expr '%s'.\n", 18 | line, file, expr); 19 | 20 | assert_fatal(0); 21 | } 22 | -------------------------------------------------------------------------------- /__kcore/include/__kstdlib/__kclib/string.h: -------------------------------------------------------------------------------- 1 | #ifndef _STRING_H 2 | #define _STRING_H 3 | 4 | #include 5 | #include <__kstdlib/__ktypes.h> 6 | 7 | /** EXPLANATION: 8 | * Simple, C standard (mostly) compliant UCS-8 string manipulation library. Get 9 | * that solidly: NOT UTF-8: UCS-8. 10 | **/ 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | void *memset(void *ptr, int value, size_t count); 17 | void *memcpy(void *dest, const void *src, size_t count); 18 | //char *strcpy(char *dest, const char *src); 19 | int memcmp(const void *ptr1, const void *ptr2, size_t n); 20 | void *memmove(void *dest, const void *src, size_t n); 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | 26 | #endif 27 | 28 | -------------------------------------------------------------------------------- /__kcore/include/chipset/zkcm/zkcmIsr.h: -------------------------------------------------------------------------------- 1 | #ifndef _ZKCM_ISR_H 2 | #define _ZKCM_ISR_H 3 | 4 | #include 5 | #include <__kstdlib/__kerror.h> 6 | 7 | /* Return values for a ZKCM ISR function. */ 8 | #define ZKCM_ISR_NOT_MY_IRQ (1) 9 | #define ZKCM_ISR_SUCCESS (ERROR_SUCCESS) 10 | #define ZKCM_ISR_SUCCESS_AND_RETIRE_ME (8) 11 | 12 | #define ZKCM_ISR_NACK_UNRESPONSIVE (2) 13 | #define ZKCM_ISR_NACK_SHUTDOWN_POSSIBLE (3) 14 | #define ZKCM_ISR_NACK_RESET_POSSIBLE (4) 15 | 16 | #define ZKCM_ISR_ACK_UNRESPONSIVE (5) 17 | #define ZKCM_ISR_ACK_SHUTDOWN_POSSIBLE (6) 18 | #define ZKCM_ISR_ACK_RESET_POSSIBLE (7) 19 | 20 | typedef status_t (zkcmIsrFn)(ZkcmDeviceBase *self, ubit32 flags); 21 | 22 | #endif 23 | 24 | -------------------------------------------------------------------------------- /__kcore/platform/i586-ibmPc/Makefile.am: -------------------------------------------------------------------------------- 1 | BUILT_SOURCES=__klinkScript.ld __klinkScriptTmp.s 2 | noinst_LIBRARIES=libplatformCore.a 3 | libplatformCore_a_SOURCES=__kpagingLevel0Tables.S __kpagingLevel1Tables.S 4 | 5 | noinst_DATA=__klinkScript.ld 6 | 7 | __klinkScript.ld: __klinkScriptTmp.s 8 | @echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 9 | @echo Generating platform specific linker script. 10 | @echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 11 | grep -v '^[[:space:]]*#' $< >$@ 12 | 13 | __klinkScriptTmp.s: __klinkScript.S 14 | $(CPP) $(AM_CPPFLAGS) $(AM_ASFLAGS) $(AM_CPPASFLAGS) $(CPPFLAGS) $(ASFLAGS) $(CPPASFLAGS) -I$(abs_top_builddir)/include -E >$@ $< 15 | 16 | CLEANFILES=__klinkScript.ld __klinkScriptTmp.s 17 | -------------------------------------------------------------------------------- /include/assembler.h: -------------------------------------------------------------------------------- 1 | #ifndef _ASSEMBLER_H 2 | #define _ASSEMBLER_H 3 | 4 | #define ASM_GLOBAL_FUNCTION(__sym) \ 5 | .globl __sym; \ 6 | .type __sym, @function; \ 7 | __sym: \ 8 | 9 | #define ASM_LOCAL_FUNCTION(__sym) \ 10 | .type __sym, @function; \ 11 | __sym: \ 12 | 13 | #define ASM_END_FUNCTION(__sym) \ 14 | .size __sym, .-__sym; \ 15 | 16 | #define ASM_GLOBAL_DATA(__sym) \ 17 | .globl __sym; \ 18 | .type __sym, @object; \ 19 | __sym: \ 20 | 21 | #define ASM_LOCAL_DATA(__sym) \ 22 | .type __sym, @object; \ 23 | __sym: \ 24 | 25 | #define ASM_END_DATA(__sym) \ 26 | .size __sym, .-__sym; \ 27 | 28 | #define ASM_SECTION(__secname) \ 29 | .section __secname,"a"; \ 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /m4/icxxabi-opts.m4: -------------------------------------------------------------------------------- 1 | # Itanium C++ ABI options configuration 2 | 3 | # Maximum number of __cxa_atexit functions configuration 4 | AC_ARG_WITH([icxxabi-atexit-max-nfuncs], 5 | [AS_HELP_STRING([--with-icxxabi-atexit-max-nfuncs=@<:@integer@:>@], 6 | [Maximum number of atexit functions supported @<:@default=128@:>@])], 7 | [], [with_icxxabi_atexit_max_nfuncs="128"] 8 | ) 9 | # Validate with_icxxabi_atexit_max_nfuncs is a positive integer 10 | ZBZ_VALIDATE_POSITIVE_NONZERO_INTEGER([with_icxxabi_atexit_max_nfuncs]) 11 | AC_DEFINE_UNQUOTED([CONFIG_ICXXABI_ATEXIT_MAX_NFUNCS], 12 | [$with_icxxabi_atexit_max_nfuncs], 13 | [Maximum number of atexit functions supported]) 14 | AC_SUBST([with_icxxabi_atexit_max_nfuncs]) 15 | -------------------------------------------------------------------------------- /__kcore/include/arch/x8632/wPRanger_getLevelRanges.h: -------------------------------------------------------------------------------- 1 | #ifndef _WALKER_PAGE_RANGER_GET_LEVEL_RANGES_H 2 | #define _WALKER_PAGE_RANGER_GET_LEVEL_RANGES_H 3 | 4 | /** EXPLANATION: 5 | * This function is used to quickly set the ranges for each level of the paging 6 | * structure walk. Pass it the start virtual address and the number of pages to 7 | * be mapped, and it will calculate the and address, and the number of entries 8 | * in each table which must be walked. 9 | **/ 10 | 11 | void getLevelRanges( 12 | void *_vaddr, uarch_t nPages, 13 | uarch_t *l0Start, uarch_t *l0End, 14 | uarch_t *l1Start, uarch_t *l1End 15 | #ifdef CONFIG_ARCH_x86_32_PAE 16 | ,uarch_t *l2Start, uarch_t *l2End 17 | #endif 18 | ); 19 | 20 | #endif 21 | 22 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/sharedResourceGroup.h: -------------------------------------------------------------------------------- 1 | #ifndef _SHARED_RESOURCE_GROUP_H 2 | #define _SHARED_RESOURCE_GROUP_H 3 | 4 | /** EXPLANATION: 5 | * A resource group is a class which encapsulates the shared resource 6 | * locking for any set of parallel resources. In order to disambiguate 7 | * the locks for any set of resources, the resources and their lock are 8 | * grouped together. The template allows for strong type checking on 9 | * the lock. 10 | * 11 | * Use of this class within the kernel is *mandatory*. 12 | **/ 13 | 14 | template 15 | class SharedResourceGroup 16 | { 17 | public: 18 | lockType lock; 19 | resourceType rsrc; 20 | }; 21 | 22 | #endif 23 | 24 | -------------------------------------------------------------------------------- /__kcore/include/chipset/zkcm/cpuDetection.h: -------------------------------------------------------------------------------- 1 | #ifndef _ZKCM_CPU_DETECTION_MOD_H 2 | #define _ZKCM_CPU_DETECTION_MOD_H 3 | 4 | #include 5 | #include 6 | #include <__kstdlib/__ktypes.h> 7 | #include 8 | 9 | class ZkcmCpuDetectionMod 10 | { 11 | public: 12 | error_t initialize(void); 13 | error_t shutdown(void); 14 | error_t suspend(void); 15 | error_t restore(void); 16 | 17 | sarch_t checkSmpSanity(void); 18 | error_t setSmpMode(void); 19 | error_t loadBspId(cpu_t *ret, sbit8 requery); 20 | struct sZkcmSmpMap *getSmpMap(void); 21 | struct sZkcmNumaMap *getNumaMap(void); 22 | status_t powerControl(cpu_t cpuId, ubit8 command, uarch_t flags); 23 | }; 24 | 25 | #endif 26 | 27 | -------------------------------------------------------------------------------- /__kcore/chipset/ibmPc/rtcmos.h: -------------------------------------------------------------------------------- 1 | #ifndef _IBM_PC_RTC_CMOS_H 2 | #define _IBM_PC_RTC_CMOS_H 3 | 4 | #include 5 | #include <__kstdlib/__ktypes.h> 6 | #include 7 | 8 | CPPEXTERN_START 9 | 10 | error_t ibmPc_rtc_initialize(void); 11 | /*error_t ibmPc_rtc_shutdown(void); 12 | error_t ibmPc_rtc_suspend(void); 13 | error_t ibmPc_rtc_restore(void);*/ 14 | 15 | /*status_t ibmPc_rtc_getCurrentDate(sDate *date); 16 | status_t ibmPc_rtc_getCurrentTime(sTime *time);*/ 17 | status_t ibmPc_rtc_getHardwareDate(sDate *ret); 18 | status_t ibmPc_rtc_getHardwareTime(sTime *ret); 19 | /*void ibmPc_rtc_refreshCachedSystemTime(void); 20 | void ibmPc_rtc_flushCachedSystemTime(void); */ 21 | 22 | CPPEXTERN_END 23 | 24 | #endif 25 | 26 | -------------------------------------------------------------------------------- /__kcore/kernel/common/Makefile.am: -------------------------------------------------------------------------------- 1 | DIST_SUBDIRS=cpuTrib debugTrib distributaryTrib execTrib \ 2 | floodplainn interruptTrib memoryTrib processTrib taskTrib \ 3 | timerTrib vfsTrib \ 4 | cisternn # aqueductt levee reflectionn caurall watermarkk 5 | SUBDIRS=cpuTrib debugTrib distributaryTrib execTrib \ 6 | floodplainn interruptTrib memoryTrib processTrib taskTrib \ 7 | timerTrib vfsTrib @DISTRIBUTARIES_ENABLED_SUBDIRS@ 8 | 9 | noinst_LIBRARIES=libkernel.a 10 | libkernel_a_SOURCES=__kheaders.cpp __koptimizationHacks.cpp __kclassInstances.cpp \ 11 | lock.cpp multipleReaderLock.cpp waitLock.cpp recursiveLock.cpp vSwamp.cpp panic.cpp \ 12 | numaMemoryBank.cpp numaMemoryRange.cpp thread.cpp process.cpp numaCpuBank.cpp \ 13 | messageStream.cpp zasyncStream.cpp 14 | -------------------------------------------------------------------------------- /scripts/loc: -------------------------------------------------------------------------------- 1 | hTotal=`cat \`find $1 -type f | grep '.*\.h$'\` | wc -l \- | sed 's/[[:space:]]-//'` 2 | cTotal=`cat \`find $1 -type f | grep '.*\.c$'\` | wc -l \- | sed 's/[[:space:]]-//'` 3 | sTotal=`cat \`find $1 -type f | grep '.*\.S$'\` | wc -l \- | sed 's/[[:space:]]-//'` 4 | cppTotal=`cat \`find $1 -type f | grep '.*\.cpp$'\` | wc -l \- | sed 's/[[:space:]]-//'` 5 | 6 | if [ "$2" == "" ]; then 7 | echo $((hTotal+cTotal+sTotal+cppTotal)) 8 | else 9 | if [ "$2" == "h" ]; then echo $hTotal; 10 | elif [ "$2" == "c" ]; then echo $cTotal; 11 | elif [ "$2" == "s" -o "$2" == "S" ]; then echo $sTotal; 12 | elif [ "$2" == "cpp" -o "$2" == "C" ]; then echo $cppTotal; 13 | else 14 | echo 'Usage: loc [folder [h|c|s|C]]' 1>&2 15 | echo 0 16 | fi 17 | fi 18 | 19 | -------------------------------------------------------------------------------- /__kcore/include/arch/paging.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include ARCH_INCLUDE(paging.h) 3 | 4 | #ifndef _ARCH_PAGING_COMMON 5 | #define _ARCH_PAGING_COMMON 6 | 7 | #define PAGING_BYTES_TO_PAGES(__bytes) \ 8 | (((__bytes) / PAGING_BASE_SIZE) + ((!!((__bytes) % PAGING_BASE_SIZE))?1:0)) 9 | 10 | #define PAGING_PAGES_TO_BYTES(__pages) (PAGING_BASE_SIZE * (__pages)) 11 | 12 | #define PAGING_BASE_ALIGN_TRUNCATED(__addr) \ 13 | ((!!((__addr) & PAGING_BASE_MASK_LOW)) \ 14 | ? ((__addr) & PAGING_BASE_MASK_HIGH) \ 15 | : (__addr)) 16 | 17 | #define PAGING_BASE_ALIGN_FORWARD(__addr) \ 18 | ((!!((__addr) & PAGING_BASE_MASK_LOW)) ? \ 19 | ((((__addr)+PAGING_BASE_SIZE)) & PAGING_BASE_MASK_HIGH) :\ 20 | (__addr)) 21 | 22 | 23 | #endif 24 | 25 | -------------------------------------------------------------------------------- /__kcore/platform/i586-ibmPc/placementAddresses.txt: -------------------------------------------------------------------------------- 1 | 2 | IBM-PC CHIPSET RELATED: 3 | 4 | memoryDetection.cpp: 5 | The e820 memory map is stored at 0x1000-0x2FFF in low memory. 6 | 7 | __kcpuPowerOn[Text|Data]: 8 | These sections are copied to 0x8000-0x9FFF in low memory. 9 | ^ Can probably move these to 0x3000-0x4FFF. 10 | 11 | Text-mode VGA buffer: 12 | virt 0xB8000 - 0xB9000: Identity mapped for alphanumeric mode VGA. 13 | 14 | Kernel: 15 | Load address is at 0x100000-0x3FFFFF. 16 | 17 | __Kspace: 18 | Set to 0x400000 in order to give the kernel ample room (Max size 3 MiB). 19 | (0x400000 - 0x6FFFFF) 20 | 21 | Reserved Memory Region :: ISA-DMA 22 | 23 | x86-32 ARCHITECTURE RELATED: 24 | 25 | Reserved Memory Region :: PAE PDP table pool. 26 | 0x700000 - 0x7FFFFF. 27 | -------------------------------------------------------------------------------- /__kcore/arch/i586/wPRanger_accessors.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | // Accessors. 5 | sPagingLevel1 *const level1Accessor = 6 | reinterpret_cast( 0xFFFFF000 ); 7 | 8 | #ifdef CONFIG_ARCH_x86_32_PAE 9 | sPagingLevel2 *const level2Accessor = 10 | reinterpret_cast( 0xFFFFE000 ); 11 | #endif 12 | 13 | // Modifiers. 14 | #ifdef CONFIG_ARCH_x86_32_PAE 15 | paddr_t *const level1Modifier = reinterpret_cast( 16 | (0xFFFFD000 + (511 * sizeof(paddr_t))) ); 17 | 18 | paddr_t *const level2Modifier = reinterpret_cast( 19 | (0xFFFFD000 + (510 * sizeof(paddr_t))) ); 20 | #else 21 | paddr_t *const level1Modifier = reinterpret_cast( 22 | (0xFFFFE000 + (1023 * sizeof(paddr_t))) ); 23 | #endif 24 | 25 | -------------------------------------------------------------------------------- /__kcore/include/arch/x8632/wPRanger_accessors.h: -------------------------------------------------------------------------------- 1 | #ifndef _WALKER_PAGE_RANGER_ACCESSORS_H 2 | #define _WALKER_PAGE_RANGER_ACCESSORS_H 3 | 4 | #include 5 | #include 6 | 7 | /** EXPLANATION: 8 | * These global variables are used to hold a constant set of values across all 9 | * CPUs which will access the accessor or modifier page for the relevant level 10 | * of the paging hierarchy. 11 | **/ 12 | 13 | // Accessors. 14 | extern sPagingLevel1 *const level1Accessor; 15 | #ifdef CONFIG_ARCH_x86_32_PAE 16 | extern sPagingLevel2 *const level2Accessor; 17 | #endif 18 | 19 | // Modifiers. 20 | extern paddr_t *const level1Modifier; 21 | #ifdef CONFIG_ARCH_x86_32_PAE 22 | extern paddr_t *const level2Modifier; 23 | #endif 24 | 25 | #endif 26 | 27 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Please refer to the HTML documentation in the docs/ subdirectory. 2 | 3 | Cursory information: 4 | 5 | ABOUT THIS PROJECT: 6 | Zambesii is a portable kernel for 32-bit and above platforms which have 7 | a Memory Management Unit. It is still under very heavy development. 8 | 9 | ABOUT THE AUTHOR: 10 | I am a human being who lives in a country. If you wish to make contact 11 | with me, please email me at: latentprion gmail com. 12 | 13 | LICENSING: 14 | This project is licensed under the terms of the GPLv2. Please see 15 | "LICENSING" for more details. The kernel is currently "free" as in 16 | "free beer", but will soon no longer be so, and will eventually have a 17 | price attached at a future date, most likely after release, or sometime 18 | around then. 19 | 20 | -------------------------------------------------------------------------------- /__kcore/include/__kstdlib/compiler/cxxrtl.h: -------------------------------------------------------------------------------- 1 | #ifndef _CXX_RTL_H 2 | #define _CXX_RTL_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | namespace cxxrtl { 7 | 8 | class __kConstructorTester 9 | { 10 | public: 11 | // Magic num for success (0x5CCCE551 = "SUCCESS!") 12 | enum successResultE{ SUCCESS = 0x5CCCE551 }; 13 | 14 | __kConstructorTester(void) 15 | : value(SUCCESS) 16 | {} 17 | 18 | sbit8 wasSuccessful(void) const 19 | { return value == SUCCESS; } 20 | 21 | private: 22 | uarch_t value; 23 | }; 24 | 25 | extern __kConstructorTester __kconstructorTester; 26 | 27 | } // namespace cxxrtl 28 | 29 | extern "C" void *__dso_handle; 30 | extern "C" int __cxa_atexit(void (*func)(void *), void *arg, void *dsoHandle); 31 | extern "C" void __cxa_finalize(void *dsoHandle); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /__kcore/commonlibs/drivers/zrootdev.udidprops: -------------------------------------------------------------------------------- 1 | properties_version 0x101 2 | 3 | name 1 4 | supplier 2 5 | contact 3 6 | shortname zrootdev 7 | release 1 v0.00.000 8 | 9 | message 1 Zambesii root device 10 | message 2 Zambesii 11 | message 3 N/A 12 | 13 | requires udi 0x101 14 | requires udi_physio 0x101 15 | requires udi_gio 0x101 16 | 17 | meta 1 zbz_fplainn 18 | meta 2 zbz_root 19 | meta 3 udi_gio 20 | meta 4 udi_physio 21 | 22 | module main 23 | region 0 24 | region 1 25 | region 2 26 | region 3 27 | 28 | message 10 Zambesii root device 29 | 30 | device 10 1 \ 31 | identifier string zrootdev 32 | 33 | # For the parent we will never bind to because we are the kernel. 34 | child_bind_ops 2 0 1 35 | internal_bind_ops 3 1 1 1 1 36 | internal_bind_ops 3 2 1 1 1 37 | internal_bind_ops 3 3 1 1 1 38 | -------------------------------------------------------------------------------- /__kcore/include/chipset/chipset_include.h: -------------------------------------------------------------------------------- 1 | #ifndef CHIPSET_INCLUDE 2 | 3 | #include 4 | 5 | #ifdef CONFIG_CHIPSET_IBM_PC 6 | #define CHIPSET_INCLUDE(__subpath) 7 | #define CHIPSET_SOURCE_INCLUDE(__subpath) 8 | #elif defined(CONFIG_CHIPSET_GENERIC) 9 | #define CHIPSET_INCLUDE(__subpath) 10 | #define CHIPSET_INCLUDE(__subpath) 11 | 12 | #else 13 | #warning "No chipset selected in configure script. Defaulting to \ 14 | CONFIG_CHIPSET_GENERIC. Try --chipset=MY_CHIPSET." 15 | 16 | #define CONFIG_CHIPSET_GENERIC 17 | #define CHIPSET_INCLUDE(__subpath) 18 | #define CHIPSET_INCLUDE(__subpath) 19 | #endif 20 | 21 | #endif 22 | 23 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/vfsTrib/vfsTraverse.h: -------------------------------------------------------------------------------- 1 | #ifndef _VFS_TRAVERSE_AUX_FUNCTIONS_H 2 | #define _VFS_TRAVERSE_AUX_FUNCTIONS_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | namespace vfsTraverse 7 | { 8 | sarch_t isTree(utf8Char *path); 9 | sarch_t isUnixRoot(utf8Char *path); 10 | 11 | sbit32 getNextSegmentIndex(utf8Char *path); 12 | status_t valisDateegment(utf8Char *path); 13 | 14 | status_t getRelativePath( 15 | void *dir, utf8Char *path, ubit8 *type, void **ret); 16 | } 17 | 18 | 19 | /** Inline methods 20 | *****************************************************************************/ 21 | 22 | inline sarch_t vfsTraverse::isTree(utf8Char *path) 23 | { 24 | return (path[0] == ':'); 25 | } 26 | 27 | inline sarch_t vfsTraverse::isUnixRoot(utf8Char *path) 28 | { 29 | return (path[0] == '/'); 30 | } 31 | 32 | #endif 33 | 34 | -------------------------------------------------------------------------------- /__kcore/commonlibs/libzbzcore/distributaryPath.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include <__kclasses/debugPipe.h> 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | void __klzbzcore::distributary::main(Thread *self, mainCbFn *callback) 11 | { 12 | dvfs::Tag *tmpTag; 13 | error_t ret; 14 | void (*jumpAddress)(void); 15 | 16 | ret = vfsTrib.getDvfs()->getPath(self->parent->fullName, &tmpTag); 17 | if (ret != ERROR_SUCCESS) 18 | { 19 | printf(ERROR LZBZCORE"dtribPath: Failed to resolve dtrib name. " 20 | "\n\t(%s).\n", 21 | self->parent->fullName); 22 | }; 23 | 24 | callback(self, ret); 25 | 26 | jumpAddress = tmpTag->getDInode()->getEntryAddress(); 27 | (*jumpAddress)(); 28 | } 29 | -------------------------------------------------------------------------------- /__kcore/kernel/common/vfsTrib/hvfs_core.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | 6 | ubit32 Inodeounter; 7 | 8 | // VFS Inode allocation. 9 | error_t VfsTrib::getNewInode(ubit32 *inodeLow) 10 | { 11 | // Try to pop an inode number off the stack. 12 | if (inodeStack.pop(inodeLow) == ERROR_SUCCESS) { 13 | return ERROR_SUCCESS; 14 | }; 15 | 16 | // Else use the inode counter. 17 | if (Inodeounter == 0xFFFFFFFF) { 18 | return ERROR_CRITICAL; 19 | }; 20 | 21 | *inodeLow = Inodeounter++; 22 | return ERROR_SUCCESS; 23 | } 24 | 25 | void VfsTrib::releaseDirInode(ubit32 inodeLow) 26 | { 27 | inodeStack.push(inodeLow); 28 | } 29 | 30 | error_t VfsTrib::registerDirInode(ubit32 inodeLow, hvfs::DirInode *inode) 31 | { 32 | return dirInodeHash.insert(inodeLow, inode); 33 | } 34 | -------------------------------------------------------------------------------- /__kcore/include/chipset/ibmPc/regionMap.h: -------------------------------------------------------------------------------- 1 | #ifndef _CHIPSET_MEMORY_REGION_MAP_H 2 | #define _CHIPSET_MEMORY_REGION_MAP_H 3 | /** EXPLANATION: 4 | * Cater for the x86-32 PAE enabled kernel's need to allocate PDP tables from 5 | * within the first 4GB. We reserve a 512KB region for the kernel in that 6 | * case. 7 | * 8 | * This region will be used to allocate PDP tables. That gives us 256 frames to 9 | * use up before we have no room left for page directory pointers. In other 10 | * words, on x86-32 with PAE, we limit the kernel effectively to 256 allocatable 11 | * address spaces, and by extension, 256 processes max. Amusing. 12 | **/ 13 | enum chipsetMemoryRegionsE 14 | { 15 | CHIPSET_MEMORY_REGION_ISA_DMA = 0, 16 | #ifdef CONFIG_ARCH_x86_32_PAE 17 | CHIPSET_MEMORY_REGION_x86_32_PAE_PDP, 18 | #endif 19 | CHIPSET_MEMORY_NREGIONS 20 | }; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/execTrib/executableFormat.h: -------------------------------------------------------------------------------- 1 | #ifndef _EXECUTABLE_FORMAT_H 2 | #define _EXECUTABLE_FORMAT_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | /** EXPLANATION: 7 | * A struct of function pointers which are entry points into a loaded 8 | * relocatable ELF file which has been mapped into the kernel's own address 9 | * space. 10 | * 11 | * When initialize() is called for any module, the kernel will pass a buffer 12 | * with memory that the loaded module can use. The buffer is exactly 128B in 13 | * size. This should be enough for the module to use to 14 | **/ 15 | 16 | struct sExecutableParser 17 | { 18 | error_t (*initialize)(const char *archString, ubit16 wordSize); 19 | sarch_t (*identify)(void *buff); 20 | sarch_t (*isLocalArch)(void *buff); 21 | }; 22 | 23 | extern struct sExecutableParser elfParser; 24 | 25 | #endif 26 | 27 | -------------------------------------------------------------------------------- /__kcore/include/__kstdlib/utf8.h: -------------------------------------------------------------------------------- 1 | #ifndef ___KUTF_8_H 2 | #define ___KUTF_8_H 3 | 4 | #include 5 | #include <__kstdlib/__ktypes.h> 6 | 7 | namespace utf8 8 | { 9 | inline unicodePoint toCodepoint2(const utf8Char *str) 10 | { 11 | unicodePoint c; 12 | 13 | c = (str[0] & 0x1F) << 6; 14 | c |= (str[1] & 0x3F); 15 | 16 | return c; 17 | } 18 | 19 | inline unicodePoint toCodepoint3(const utf8Char *str) 20 | { 21 | unicodePoint c; 22 | 23 | c = (str[0] & 0xF) << 12; 24 | c |= (str[1] & 0x3F) << (12 - 6); 25 | c |= (str[2] & 0x3F); 26 | 27 | return c; 28 | } 29 | 30 | inline unicodePoint toCodepoint4(const utf8Char *str) 31 | { 32 | unicodePoint c; 33 | 34 | c = (str[0] & 0x7) << 18; 35 | c |= (str[1] & 0x3F) << (18 - 6); 36 | c |= (str[2] & 0x3F) << (18 - 12); 37 | c |= (str[3] & 0x3F); 38 | 39 | return c; 40 | } 41 | } 42 | 43 | #endif 44 | 45 | -------------------------------------------------------------------------------- /__kcore/__kthreads/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include <__kclasses/tests.h> 4 | #include <__kstdlib/tests.h> 5 | 6 | #define TESTS_CHECK_RETVAL_AND_UPDATE_RETVAL(retval, tmpretval) do \ 7 | { \ 8 | if ((tmpretval) != ERROR_SUCCESS) { \ 9 | (retval) = (tmpretval); \ 10 | } \ 11 | } while (0) 12 | 13 | TESTS_FN_MAKE_PROTOTYPE_DEFAULT_VARS(runTests) 14 | { 15 | uarch_t tot, succ, fail; 16 | status_t status=ERROR_SUCCESS, s; 17 | 18 | TESTS_VARS_INIT_DEFAULT_VARS(); 19 | 20 | s = runTestArray( 21 | tests::__kstdlib::tests, &tot, &succ, &fail); 22 | TESTS_CHECK_RETVAL_AND_UPDATE_RETVAL(status, s); 23 | TESTS_VARS_DEFAULT_VARS_INC_ALL_BY(tot, succ, fail); 24 | 25 | s = runTestArray( 26 | tests::__kclasses::memBmp::tests, 27 | &tot, &succ, &fail); 28 | TESTS_CHECK_RETVAL_AND_UPDATE_RETVAL(status, s); 29 | TESTS_VARS_DEFAULT_VARS_INC_ALL_BY(tot, succ, fail); 30 | 31 | return status; 32 | } 33 | -------------------------------------------------------------------------------- /__kcore/include/kernel/x8632/cpuTrib/archCpuFeatures.h: -------------------------------------------------------------------------------- 1 | #ifndef _ARCH_x86_32_CPU_FEATURES_H 2 | #define _ARCH_x86_32_CPU_FEATURES_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | #include <__kstdlib/__kclib/string.h> 6 | 7 | #define x8632_CPUFEAT_BASE_SYSENTER (1<<0) 8 | 9 | #define x8632_CPUFEAT_ADVANCED_VM (1<<0) 10 | 11 | #define x8632_CPUFEAT_SSE_NONE 0 12 | #define x8632_CPUFEAT_SSE1 1 13 | #define x8632_CPUFEAT_SSE2 2 14 | #define x8632_CPUFEAT_SSE3 3 15 | 16 | struct sArchCpuFeatures 17 | { 18 | sArchCpuFeatures(void) 19 | { 20 | memset(this, 0, sizeof(*this)); 21 | } 22 | 23 | utf8Char manufacturer[32]; 24 | ubit32 baseFlags; 25 | ubit32 advancedFlags; 26 | ubit8 sseLevel; 27 | ubit8 cpuNameNSpaces; 28 | 29 | struct 30 | { 31 | ubit8 f00fBug; 32 | } errataInfo; 33 | 34 | struct 35 | { 36 | ubit8 family, stepping, model, revision; 37 | } modelInfo; 38 | }; 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /__kcore/kernel/common/debugTrib/debugTrib.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include <__kclasses/debugPipe.h> 5 | #include <__kclasses/cachePool.h> 6 | #include 7 | 8 | 9 | DebugTrib::DebugTrib(void) 10 | { 11 | cpuCount.rsrc = 0; 12 | } 13 | 14 | void DebugTrib::enterFromIrq(void) 15 | { 16 | } 17 | 18 | void DebugTrib::enterNoIrq(void) 19 | { 20 | cpuCount.lock.acquire(); 21 | cpuCount.rsrc++; 22 | cpuCount.lock.release(); 23 | 24 | for (ubit16 i=0; i 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | void *malloc(uarch_t nBytes); 11 | // void *realloc(void *oldMem, uarch_t newSize); 12 | void *calloc(uarch_t objSize, uarch_t nObjs); 13 | void free(void *mem); 14 | 15 | #ifdef __cplusplus 16 | inline 17 | #else 18 | static 19 | #endif 20 | error_t crudeRealloc( 21 | void *oldMem, uarch_t oldMemSize, 22 | void **newMem, uarch_t newMemSize 23 | ) 24 | { 25 | void *_newMem; 26 | 27 | _newMem = new ubit8[newMemSize]; 28 | if (_newMem == NULL) { return ERROR_MEMORY_NOMEM; }; 29 | 30 | if (oldMem != NULL && oldMemSize > 0) { 31 | memcpy(_newMem, oldMem, oldMemSize); 32 | }; 33 | 34 | *newMem = _newMem; 35 | 36 | ::operator delete[](oldMem); 37 | return ERROR_SUCCESS; 38 | } 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /__kcore/chipset/ibmPc/busPinMappings.h: -------------------------------------------------------------------------------- 1 | #ifndef _IBM_PC_BUS_PIN_MAPPINGS_H 2 | #define _IBM_PC_BUS_PIN_MAPPINGS_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | #define IBMPCBPM "BusPinMapping: " 7 | 8 | namespace ibmPcBpm 9 | { 10 | namespace isa 11 | { 12 | status_t loadBusPinMappings(void); 13 | error_t get__kpinFor(ubit32 busIrqId, ubit16 *__kpin); 14 | status_t maskIrq(ubit32 busIrqId); 15 | status_t unmaskIrq(ubit32 busIrqId); 16 | } 17 | 18 | namespace pci 19 | { 20 | /*status_t loadBusPinMappings(void); 21 | error_t get__kpinFor(ubit32 busIrqId, ubit16 *__kpin); 22 | status_t maskIrq(ubit32 busIrqId); 23 | status_t unmaskIrq(ubit32 busIrqId);*/ 24 | } 25 | 26 | namespace acpi 27 | { 28 | /*status_t loadBusPinMappings(void); 29 | error_t get__kpinFor(ubit32 busIrqId, ubit16 *__kpin); 30 | status_t maskIrq(ubit32 busIrqId); 31 | status_t unmaskIrq(ubit32 busIrqId);*/ 32 | } 33 | } 34 | 35 | #endif 36 | 37 | -------------------------------------------------------------------------------- /__kcore/include/__kclasses/currentt.h: -------------------------------------------------------------------------------- 1 | #ifndef _CURRENTT_H 2 | #define _CURRENTT_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | #include <__kstdlib/__kclib/string8.h> 6 | 7 | namespace currentt 8 | { 9 | template 10 | class VfsTag 11 | { 12 | protected: 13 | VfsTag(utf8Char *name) 14 | : 15 | flags(0) 16 | { 17 | strncpy8(this->name, name, maxNameLength); 18 | this->name[maxNameLength-1] = '\0'; 19 | } 20 | 21 | error_t initialize(void) { return ERROR_SUCCESS; } 22 | 23 | ~VfsTag(void) {}; 24 | 25 | public: 26 | utf8Char *getName(void) { return name; } 27 | ubit16 getMaxNameLength(void) { return maxNameLength; } 28 | 29 | status_t rename(utf8Char *newName); 30 | 31 | private: 32 | utf8Char name[maxNameLength]; 33 | ubit32 flags; 34 | }; 35 | 36 | class vfsINode 37 | { 38 | protected: 39 | error_t initialize(void) { return ERROR_SUCCESS; } 40 | }; 41 | 42 | } 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /__kcore/arch/i586/msr.S: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | 6 | /* extern "C" void rdmsr(ubit32 idx, ubit32 *high, ubit32 *low) */ 7 | ASM_GLOBAL_FUNCTION(rdmsr) 8 | /* ESP+0 = ret, ESP+4 = idx, ESP+8=high */ 9 | pushl %ecx 10 | pushl %edx 11 | pushl %eax 12 | 13 | /* ESP+12 = ret, ESP+16 = idx, ESP+20 = *high */ 14 | movl 16(%esp), %ecx 15 | rdmsr 16 | movl 20(%esp), %ecx 17 | movl %edx, (%ecx) 18 | movl 24(%esp), %ecx 19 | movl %eax, (%ecx) 20 | 21 | popl %eax 22 | popl %edx 23 | popl %ecx 24 | ret 25 | ASM_END_FUNCTION(rdmsr) 26 | 27 | /* extern "C" void wrmsr(ubit32 idx, ubit32 high, ubit32 low) */ 28 | ASM_GLOBAL_FUNCTION(wrmsr) 29 | pushl %ecx 30 | pushl %edx 31 | pushl %eax 32 | 33 | /* ESP+12 = ret, ESP+16=idx, ESP+20=high, etc */ 34 | movl 16(%esp), %ecx 35 | movl 20(%esp), %edx 36 | movl 24(%esp), %eax 37 | wrmsr 38 | 39 | popl %eax 40 | popl %edx 41 | popl %ecx 42 | ret 43 | ASM_END_FUNCTION(wrmsr) 44 | -------------------------------------------------------------------------------- /__kcore/include/arch/mathEmulation.txt: -------------------------------------------------------------------------------- 1 | mathEmulation.h 2 | 3 | This file must have a relevant .cpp file in the root/arch/ARCH_HERE/ dir, 4 | on architectures which require runtime math emulation. 5 | 6 | Any file which uses any form of mathematical calculations which require 7 | emulation on any arch must include this file. 8 | 9 | The file defines global operators to work on signed and unsigned integral types. 10 | That is, in defining these operators globally, the compiler will insert a 11 | a reference to the emulated sequence wherever needed such that mathematics 12 | emultation is made implicit and transparent to the kernel source. 13 | 14 | So: in a file with: 15 | x = x / y; 16 | 17 | Which includes mathEmulation.h, where mathEmulation.h defines global operators 18 | for division emulation, the compiler will auto-insert a reference to the 19 | overloaded division sequence without us having to change the source. 20 | 21 | C++ operator overloading ftw. 22 | 23 | -------------------------------------------------------------------------------- /__kcore/include/chipset/ibmPc/memory.h: -------------------------------------------------------------------------------- 1 | #ifndef _CHIPSET_MEMORY_H 2 | #define _CHIPSET_MEMORY_H 3 | 4 | #include 5 | #include <__kstdlib/__ktypes.h> 6 | 7 | // __kspace size is 2MB, starting at the 4MiB mark. Do not exceed 3MiB. 8 | #define CHIPSET_MEMORY___KSPACE_BASE (0x400000) 9 | #define CHIPSET_MEMORY___KSPACE_SIZE (0x100000 * 2) 10 | 11 | // Implies the size of the global array of process pointers. 12 | #define CHIPSET_MEMORY_MAX_NPROCESSES (16384) 13 | // The maximum number of threads per process. 14 | #define CHIPSET_MEMORY_MAX_NTASKS (256) 15 | 16 | #ifdef CONFIG_ARCH_x86_32 17 | // x86-32 stack size for PC is 2 pages. 18 | #define CHIPSET_MEMORY___KSTACK_NPAGES 2 19 | #define CHIPSET_MEMORY_USERSTACK_NPAGES 8 20 | #endif 21 | 22 | // Absolute load address of the kernel in physical memory. 23 | #define CHIPSET_MEMORY___KLOAD_PADDR_BASE (0x100000) 24 | #define CHIPSET_MEMORY___KBOG_SIZE (0x200000) 25 | 26 | #endif 27 | 28 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/memoryTrib/pmmBridge.h: -------------------------------------------------------------------------------- 1 | #ifndef _PMM_BRIDGE_H 2 | #define _PMM_BRIDGE_H 3 | 4 | #include 5 | #include 6 | #include <__kstdlib/__ktypes.h> 7 | #include <__kclasses/bitmap.h> 8 | #include 9 | #include 10 | #include 11 | 12 | namespace fplainn 13 | { 14 | namespace dma 15 | { 16 | class Constraints; 17 | class ScatterGatherList; 18 | 19 | namespace constraints 20 | { 21 | class Compiler; 22 | } 23 | } 24 | } 25 | 26 | namespace memoryTribPmm 27 | { 28 | status_t fragmentedGetFrames(uarch_t nFrames, paddr_t *paddr); 29 | status_t constrainedGetFrames( 30 | fplainn::dma::constraints::Compiler *comCon, 31 | uarch_t nFrames, 32 | fplainn::dma::ScatterGatherList *retlist, 33 | uarch_t flags=0); 34 | 35 | void releaseFrames(paddr_t basePaddr, uarch_t nFrames); 36 | } 37 | 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/cpuTrib/cpuFeatures.h: -------------------------------------------------------------------------------- 1 | #ifndef _CPU_FEATURES_H 2 | #define _CPU_FEATURES_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | #include <__kstdlib/__kclib/string.h> 6 | #include 7 | 8 | #define CPUFEAT_FPULEVEL_NONE 0 9 | #define CPUFEAT_FPULEVEL_EXTERNAL 1 10 | #define CPUFEAT_FPULEVEL_INTEGRATED 2 11 | 12 | #define CPUFEAT_BITWIDTH_7 (1<<0) 13 | #define CPUFEAT_BITWIDTH_8 (1<<1) 14 | #define CPUFEAT_BITWIDTH_16 (1<<2) 15 | #define CPUFEAT_BITWIDTH_32 (1<<3) 16 | #define CPUFEAT_BITWIDTH_64 (1<<4) 17 | 18 | struct sCpuFeatures 19 | { 20 | sCpuFeatures(void) 21 | { 22 | memset(this, 0, sizeof(*this)); 23 | } 24 | 25 | utf8Char cpuFamily[32], cpuModel[64]; 26 | ubit16 clockMhz; 27 | ubit8 fpuLevel; 28 | ubit16 l1CacheSize, l2CacheSize, l3CacheSize; 29 | ubit8 cacheLineSize; 30 | ubit8 bitWidth; 31 | // Arch specific CPU features. 32 | sArchCpuFeatures archFeatures; 33 | }; 34 | 35 | #endif 36 | 37 | -------------------------------------------------------------------------------- /__kcore/kernel/common/vfsTrib/vfsTrib_file.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include <__kstdlib/__kcxxlib/new> 3 | #include 4 | 5 | 6 | status_t VfsTrib::createFile(vfsDirC *dir, utf8Char *name, uarch_t) 7 | { 8 | vfsFileC *newFile; 9 | status_t ret; 10 | 11 | // Allocate and initialize the new file descriptor. 12 | newFile = new vfsFileC; 13 | if (newFile == NULL) { 14 | return ERROR_MEMORY_NOMEM; 15 | }; 16 | 17 | ret = newFile->initialize(name); 18 | if (ret != ERROR_SUCCESS) { 19 | return ret; 20 | }; 21 | 22 | // Add the new file to the folder. 23 | dir->desc->addFileDesc(newFile); 24 | 25 | // Link the file descriptor to its parent folder. 26 | newFile->parent = dir; 27 | 28 | return ERROR_SUCCESS; 29 | } 30 | 31 | error_t VfsTrib::deleteFile(vfsDirINode *inode, utf8Char *name) 32 | { 33 | return inode->removeFileDesc(name); 34 | } 35 | 36 | status_t VfsTrib::renameFile(vfsDirINode *, utf8Char *, utf8Char *) 37 | { 38 | return ERROR_UNIMPLEMENTED; 39 | } 40 | 41 | -------------------------------------------------------------------------------- /__kcore/chipset/ibmPc/i8254_pit.cpp: -------------------------------------------------------------------------------- 1 | 2 | #define UDI_VERSION 0x101 3 | #include 4 | #undef UDI_VERSION 5 | 6 | /* Data type used to represent i8254-pit CLK cycles. CLK cycles are /not/ 1:1 7 | * related to actual microseconds. The i8254 PIT has an input frequency of 8 | * 1,193,180Hz. 9 | **/ 10 | typedef udi_ubit16_t timer_clk_t; 11 | 12 | struct sTimerRData 13 | { 14 | enum timerIrqStatusE { IRQ_DISABLED, IRQ_ENABLED }; 15 | enum timerApiStatusE { API_DISABLED, API_ENABLED }; 16 | enum timerModeE { ONESHOT, PERIODIC }; 17 | 18 | // Whether or not the channel 0 IRQ is active. 19 | timerIrqStatusE irqStatus; 20 | // Whether or not the device is logically enabled currently. 21 | timerApiStatusE apiStatus; 22 | timerModeE timerMode; 23 | // The current value programmed into the counter register. 24 | timer_clk_t CurrenttlkVal; 25 | // The current microsecond time requested by the bound child. 26 | udi_time_t currentTimeoutVal; 27 | }; 28 | 29 | struct sSpeakerRData 30 | { 31 | }; 32 | 33 | -------------------------------------------------------------------------------- /__kcore/include/commonlibs/libacpi/rsdp.h: -------------------------------------------------------------------------------- 1 | #ifndef _ZBZ_LIB_ACPI_RSDP_H 2 | #define _ZBZ_LIB_ACPI_RSDP_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | #include "baseTables.h" 6 | 7 | 8 | // "ACPI OK" 9 | #define ACPI "ACPI: " 10 | #define ACPI_CACHE_MAGIC 0xAC1D101C 11 | 12 | #ifdef __cplusplus 13 | 14 | namespace acpi 15 | { 16 | struct sSdtCache 17 | { 18 | ubit32 magic; 19 | acpi::sRsdp *rsdp; 20 | acpi::sRsdt *rsdt; 21 | acpi::sXsdt *xsdt; 22 | }; 23 | 24 | // Call before using, every time. 25 | void initializeCache(void); 26 | 27 | // TODO: Remember to remove. 28 | void debug(void); 29 | void *cacheVaddr(void); 30 | 31 | error_t findRsdp(void); 32 | sarch_t rsdpFound(void); 33 | acpi::sRsdp *getRsdp(void); 34 | 35 | sarch_t testForRsdt(void); 36 | sarch_t testForXsdt(void); 37 | 38 | error_t mapRsdt(void); 39 | acpi::sRsdt *getRsdt(void); 40 | error_t mapXsdt(void); 41 | acpi::sXsdt *getXsdt(void); 42 | 43 | void flushCache(void); 44 | } 45 | 46 | #endif 47 | 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /__kcore/include/__kstdlib/__kclib/string8.h: -------------------------------------------------------------------------------- 1 | #ifndef _UCS_8_STRING_H 2 | #define _UCS_8_STRING_H 3 | 4 | #include 5 | #include <__kstdlib/__ktypes.h> 6 | 7 | /** EXPLANATION: 8 | * Simple, C standard (mostly) compliant UCS-8 string manipulation library. Get 9 | * that solidly: NOT UTF-8: UCS-8. 10 | **/ 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | utf8Char *strstr8(const utf8Char *str1, const utf8Char *str2); 17 | utf8Char *strcpy8(utf8Char *dest, const utf8Char *src); 18 | utf8Char *strncpy8(utf8Char *dest, const utf8Char *src, size_t count); 19 | size_t strlen8(const utf8Char *str); 20 | int strcmp8(const utf8Char *str1, const utf8Char *str2); 21 | int strncmp8(const utf8Char *str1, const utf8Char *str2, int count); 22 | size_t strnlen8(const utf8Char *str1, size_t maxLen); 23 | utf8Char *strnchr8(const utf8Char *str, size_t n, const utf8Char chr); 24 | utf8Char *strcat8(utf8Char *dest, const utf8Char *src); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/tributary.h: -------------------------------------------------------------------------------- 1 | #ifndef _TRIBUTARY_C_H 2 | #define _TRIBUTARY_C_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | #include 6 | 7 | /** EXPLANATION: 8 | * TributaryC is a base class with singleton design used to instantiate 9 | * singleton kernel classes. The way the Zambesii singleton model works 10 | * is: 11 | * 12 | * There is a global instance of each class in an __kclassInstances.cpp 13 | * file. When you include a header for a kernel class 14 | * (e.g.: memoryTrib.h), you get a declaration of the following form: 15 | * extern kernelClassName kernelClassInstance; 16 | * 17 | * Every kernel class has a static 'getHandle()' method which can be 18 | * used to return the singleton kernel class instance. For the rest of 19 | * the class, you can use the extern declaration to reference the class 20 | * instance. This applies generally only for singleton kernel classes. 21 | **/ 22 | 23 | class Tributary 24 | { 25 | }; 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /__kcore/arch/i586/exceptions.h: -------------------------------------------------------------------------------- 1 | #ifndef x86_32_EXCEPTIONS_H 2 | #define x86_32_EXCEPTIONS_H 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | __kexceptionFn x8632_div_zero; 11 | __kexceptionFn x8632_debug; 12 | __kexceptionFn x8632_nmi; 13 | __kexceptionFn x8632_breakpoint; 14 | __kexceptionFn x8632_int_overflow; 15 | __kexceptionFn x8632_bound; 16 | __kexceptionFn x8632_invalid_opcode; 17 | __kexceptionFn x8632_no_fpu; 18 | __kexceptionFn x8632_double_fault; 19 | __kexceptionFn x8632_fpu_segfault; 20 | __kexceptionFn x8632_tss_except; 21 | __kexceptionFn x8632_seg_not_present; 22 | __kexceptionFn x8632_stack_fault; 23 | __kexceptionFn x8632_gpf; 24 | __kexceptionFn x8632_page_fault; 25 | __kexceptionFn x8632_unknown_interrupt; 26 | __kexceptionFn x8632_fpu_fault; 27 | __kexceptionFn x8632_alignment_check; 28 | __kexceptionFn x8632_machine_check; 29 | __kexceptionFn x8632_reserved_vector; 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif 36 | 37 | -------------------------------------------------------------------------------- /__kcore/arch/i586/wPRanger_getLevelRanges.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | void getLevelRanges( 7 | void *_vaddr, uarch_t nPages, 8 | uarch_t *l0Start, uarch_t *l0End, 9 | uarch_t *l1Start, uarch_t *l1End 10 | #ifdef CONFIG_ARCH_x86_32_PAE 11 | ,uarch_t *l2Start, uarch_t *l2End 12 | #endif 13 | ) 14 | { 15 | uarch_t vaddr, endAddr; 16 | 17 | vaddr = reinterpret_cast( _vaddr ); 18 | endAddr = vaddr + ((nPages - 1) * PAGING_BASE_SIZE); 19 | 20 | *l0Start = (vaddr & PAGING_L0_VADDR_MASK) >> PAGING_L0_VADDR_SHIFT; 21 | *l0End = (endAddr & PAGING_L0_VADDR_MASK) >> PAGING_L0_VADDR_SHIFT; 22 | 23 | *l1Start = (vaddr & PAGING_L1_VADDR_MASK) >> PAGING_L1_VADDR_SHIFT; 24 | *l1End = (endAddr & PAGING_L1_VADDR_MASK) >> PAGING_L1_VADDR_SHIFT; 25 | 26 | #ifdef CONFIG_ARCH_x86_32_PAE 27 | *l2Start = (vaddr & PAGING_L2_VADDR_MASK) >> PAGING_L2_VADDR_SHIFT; 28 | *l2End = (endAddr & PAGING_L2_VADDR_MASK) >> PAGING_L2_VADDR_SHIFT; 29 | #endif 30 | } 31 | -------------------------------------------------------------------------------- /__kcore/kernel/common/cisternn/descriptor.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | static void cisternnEntry(void) 9 | { 10 | Thread *self; 11 | 12 | self = static_cast( 13 | cpuTrib.getCurrentCpuStream()->taskStream.getCurrentThread() ); 14 | 15 | printf(NOTICE"Cisternn executing; process ID: %x. ESP: %p. " 16 | "Killing.\n", 17 | self->getFullId(), debug::getStackPointer()); 18 | 19 | taskTrib.kill(self->getFullId()); 20 | } 21 | 22 | const dvfs::sDistributaryDescriptor cisternnDescriptor= 23 | { 24 | CC"cisternn", CC"Zambesii", 25 | CC"Cisternn storage distributary for Zambesii", 26 | { 27 | { 28 | CC"storage", 29 | #ifdef CONFIG_DTRIB_CISTERNN 30 | 1 31 | #else 32 | 0 33 | #endif 34 | } 35 | }, 36 | 1, // Provides only one category. 37 | 0, 0, 0, // v0.00.000. 38 | &cisternnEntry, 39 | 0 40 | }; 41 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/waitLock.h: -------------------------------------------------------------------------------- 1 | #ifndef _WAIT_LOCK_H 2 | #define _WAIT_LOCK_H 3 | 4 | #include 5 | #include 6 | 7 | /** EXPLANATION: 8 | * Standard non-sleeping lock. Clears local logical CPU's IRQs and spins until 9 | * the lock is acquired. 10 | **/ 11 | 12 | class RecursiveLock; 13 | class MultipleReaderLock; 14 | 15 | class WaitLock 16 | : 17 | public Lock 18 | { 19 | friend class RecursiveLock; 20 | friend class MultipleReaderLock; 21 | 22 | public: 23 | enum flagShiftE { 24 | WL_FLAGS_ENUM_END = Lock::FLAGS_ENUM_END 25 | }; 26 | 27 | // Compile-time check that enum values fit within uarch_t 28 | typedef char __lock_flags_size_check2[(WL_FLAGS_ENUM_END <= __UARCH_T_NBITS__) ? 1 : -1]; 29 | 30 | void acquire(); 31 | void release(); 32 | // Release without re-enabling IRQs even if they were on before acquire. 33 | void releaseNoIrqs(); 34 | 35 | #ifdef ARCH_HAS_ATOMIC_WAITLOCK_PRIMITIVE 36 | }; 37 | #else 38 | } __attribute__(( section(".__katomicData") )); 39 | #endif 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /__kcore/include/__kstdlib/__kclib/string16.h: -------------------------------------------------------------------------------- 1 | #ifndef ___KCLIB_STRING_UCS16_H 2 | #define ___KCLIB_STRING_UCS16_H 3 | 4 | #include 5 | #include <__kstdlib/__ktypes.h> 6 | 7 | /** EXPLANATION: 8 | * This is not code to manipulate UTF-16 strings. It manipulates UCS-16. *NOT* 9 | * UTF-16. Get that VERY clearly through your head before you use these. 10 | **/ 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | void *memset16(void *ptr, int value, size_t count); 17 | void *memcpy16(void *dest, void *src, size_t count); 18 | utf16Char *strcpy16(utf16Char *dest, const utf16Char *src); 19 | size_t strlen16(const utf16Char *str); 20 | int strcmp16(const utf16Char *str1, const utf16Char *str2); 21 | int strncmp16(const utf16Char *str1, const utf16Char *str2, int count); 22 | size_t strnlen16(const utf16Char *str1, size_t maxLen); 23 | utf16Char *strnchr16(const utf16Char *str, size_t n, const utf16Char chr); 24 | utf16Char *strcat16(utf16Char *dest, const utf16Char *src); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /__kcore/include/chipset/zkcm/numaMap.h: -------------------------------------------------------------------------------- 1 | #ifndef _CHIPSET_NUMA_MAP_H 2 | #define _CHIPSET_NUMA_MAP_H 3 | 4 | #include 5 | #include <__kstdlib/__ktypes.h> 6 | #include 7 | #include 8 | 9 | /** EXPLANATION: 10 | * The format for a system NUMA map that gives details about the per-bank memory 11 | * ranges and CPUs in a NUMA setup. 12 | **/ 13 | 14 | #define NUMAMEMMAP_FLAGS_HOTPLUG (1<<0) 15 | #define NUMAMEMMAP_FLAGS_ONLINE (1<<1) 16 | 17 | #define NUMACPUMAP_FLAGS_HOTPLUG (1<<0) 18 | #define NUMACPUMAP_FLAGS_ONLINE (1<<1) 19 | 20 | struct sNumaCpuMapEntry 21 | { 22 | numaBankId_t bankId; 23 | cpu_t cpuId; 24 | ubit32 cpuAcpiId; 25 | uarch_t flags; 26 | }; 27 | 28 | struct sNumaMemoryMapEntry 29 | { 30 | paddr_t baseAddr, size; 31 | numaBankId_t bankId; 32 | uarch_t flags; 33 | }; 34 | 35 | struct sZkcmNumaMap 36 | { 37 | struct sNumaCpuMapEntry *cpuEntries; 38 | struct sNumaMemoryMapEntry *memEntries; 39 | ubit8 nMemEntries, nCpuEntries; 40 | }; 41 | 42 | #endif 43 | 44 | -------------------------------------------------------------------------------- /__kcore/kernel/common/execTrib/execTrib.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include <__kstdlib/__kflagManipulation.h> 5 | #include <__kclasses/cachePool.h> 6 | #include <__kstdlib/__kclib/string.h> 7 | #include 8 | 9 | 10 | ExecTrib::ExecTrib(void) 11 | { 12 | memset(parsers, 0, sizeof(*parsers) * EXECTRIB_MAX_NPARSERS); 13 | } 14 | 15 | error_t ExecTrib::initialize(void) 16 | { 17 | error_t ret; 18 | 19 | ret = (*elfParser.initialize)(ARCH_SHORT_STRING, __VADDR_NBITS__); 20 | if (ret != ERROR_SUCCESS) { 21 | return ret; 22 | }; 23 | 24 | parsers[0].desc = &elfParser; 25 | FLAG_SET(parsers[0].flags, EXECTRIB_PARSER_FLAGS_STATIC); 26 | return ERROR_SUCCESS; 27 | } 28 | 29 | sExecutableParser *ExecTrib::identify(void *buff) 30 | { 31 | for (uarch_t i=0; iidentify)(buff)) { 38 | return parsers[i].desc; 39 | }; 40 | }; 41 | 42 | return NULL; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /__kcore/include/__kthreads/__kcpuPowerOn.h: -------------------------------------------------------------------------------- 1 | #ifndef ___K_CPU_POWER_ON_H 2 | #define ___K_CPU_POWER_ON_H 3 | 4 | #include 5 | #include <__kstdlib/__ktypes.h> 6 | #include 7 | #include 8 | #include 9 | 10 | extern "C" void __kcpuPowerOnEntry(void); 11 | extern "C" void __kcpuPowerOnMain(CpuStream *self); 12 | 13 | extern "C" ubit8 *__kcpuPowerOnLapicVaddr; 14 | 15 | /** EXPLANTION: 16 | * We preallocate the __kcpuPowerStacks pointer array in the kernel image 17 | * based on CONFIG_MAX_NCPUS. NB: Notice my language. I said that we 18 | * preallocate the pointer array and not the power stacks themselves. The 19 | * power stack for each CPU is stored within its CpuStream structure. Hence 20 | * the stacks themselves are allocated dynamically at runtime. The __kcpuPowerStacks 21 | * array is a a preallocated array of pointers to the power stacks. 22 | **/ 23 | extern "C" void *__kcpuPowerStacks[CONFIG_MAX_NCPUS]; 24 | extern Thread __kcpuPowerOnThread; 25 | 26 | #endif 27 | 28 | -------------------------------------------------------------------------------- /__kcore/include/__kstdlib/__kclib/assert.h: -------------------------------------------------------------------------------- 1 | #ifndef _ASSERT_H 2 | #define _ASSERT_H 3 | 4 | #define ASSERT_QUOTE(x) #x 5 | #define ASSERT_DUAL_QUOTE(x) ASSERT_QUOTE(x) 6 | 7 | #define assert_warn(e) \ 8 | (((e) == 0) \ 9 | ? printf(WARNING"Assertion failed: " \ 10 | ASSERT_QUOTE(e) \ 11 | " on line " \ 12 | ASSERT_DUAL_QUOTE(__LINE__) \ 13 | " of " \ 14 | ASSERT_DUAL_QUOTE(__FILE__) \ 15 | ".\n") \ 16 | : \ 17 | ((void)0)) 18 | 19 | #define assert_error(e) \ 20 | (((e) == 0) \ 21 | ? printf(ERROR"Assertion failed: " \ 22 | ASSERT_QUOTE(e) \ 23 | " on line " \ 24 | ASSERT_DUAL_QUOTE(__LINE__) \ 25 | " of " \ 26 | ASSERT_DUAL_QUOTE(__FILE__) \ 27 | ".\n") \ 28 | : \ 29 | ((void)0)) 30 | 31 | #define assert_fatal(e) \ 32 | (((e) == 0) \ 33 | ? panic(FATAL"Assertion failed: " \ 34 | ASSERT_QUOTE(e) \ 35 | " on line " \ 36 | ASSERT_DUAL_QUOTE(__LINE__) \ 37 | " of " \ 38 | ASSERT_DUAL_QUOTE(__FILE__) \ 39 | ".\n") \ 40 | : \ 41 | ((void)0)) 42 | 43 | #define assert(e) assert_fatal((e)) 44 | 45 | #endif 46 | 47 | -------------------------------------------------------------------------------- /docs/tss-call-gates.md: -------------------------------------------------------------------------------- 1 | # TSS Selectors and Call Gates: 2 | 3 | ## Protection rings/priv levels: 4 | 5 | 0 - 3: 0 = highest, 3 = userspace. 6 | 7 | 8 | ## Call Gates: 9 | 10 | Sec 6.4.5: 11 | > Code modules in lower privilege segments can only access modules operating at higher privilege segments by means of a tightly controlled and protected interface called a gate. 12 | 13 | Calls to higher priv segments are handled "in a similar manner as a far call" with these differences: 14 | * The segment selector should denote a call gate descriptor and not a normal code segment descriptor. 15 | * The processor switches to a new stack to execute the called procedure. Each privilege level has its own stack. 16 | * The segment selector and stack pointer for the privilege level 3 stack are stored in the SS and ESP registers, 17 | * The segment selectors and stack pointers for the privilege level 2, 1, and 0 stacks are stored in a system segment called the task state segment (TSS) [unsure whether they're talking about the target segment's loadable stacks or the caller's yet-to-be-saved stacks]. 18 | -------------------------------------------------------------------------------- /__kcore/include/__kstdlib/__kcxxlib/new: -------------------------------------------------------------------------------- 1 | #ifndef _NEW_H 2 | #define _NEW_H 3 | 4 | #include 5 | #include <__kstdlib/__ktypes.h> 6 | #include <__kstdlib/__kclib/string.h> 7 | 8 | class MemReservoir; 9 | 10 | // Placement new and placement new[]. 11 | inline void *operator new(size_t, void *ptr) { return ptr; } 12 | inline void *operator new[](size_t, void *ptr) { return ptr; } 13 | 14 | void *operator new(size_t size, MemReservoir *heap); 15 | inline void *operator new[](size_t nBytes, MemReservoir *heap) 16 | { 17 | return ::operator new(nBytes, heap); 18 | } 19 | 20 | void *operator new(size_t size); 21 | void *operator new[](size_t nBytes); 22 | 23 | // Placement delete and placement delete[]. 24 | inline void operator delete(void *, void *) {} 25 | inline void operator delete[](void *, void *) {} 26 | 27 | void operator delete(void *ptr, MemReservoir *heap); 28 | inline void operator delete[](void *ptr, MemReservoir *heap) 29 | { 30 | ::operator delete(ptr, heap); 31 | } 32 | 33 | void operator delete(void *ptr); 34 | void operator delete[](void *mem); 35 | 36 | #endif 37 | 38 | -------------------------------------------------------------------------------- /__kcore/udi_index.S: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | ASM_SECTION(.rodata) 6 | 7 | ASM_GLOBAL_DATA(__kudi_index_drivers) 8 | .incbin "drivers.zudi-index" 9 | ASM_END_DATA(__kudi_index_drivers) 10 | ASM_GLOBAL_DATA(__kudi_index_drivers_end) 11 | 12 | ASM_GLOBAL_DATA(__kudi_index_data) 13 | .incbin "data.zudi-index" 14 | ASM_END_DATA(__kudi_index_data) 15 | ASM_GLOBAL_DATA(__kudi_index_data_end) 16 | 17 | ASM_GLOBAL_DATA(__kudi_index_provisions) 18 | .incbin "provisions.zudi-index" 19 | ASM_END_DATA(__kudi_index_provisions) 20 | ASM_GLOBAL_DATA(__kudi_index_provisions_end) 21 | 22 | ASM_GLOBAL_DATA(__kudi_index_devices) 23 | .incbin "devices.zudi-index" 24 | ASM_END_DATA(__kudi_index_devices) 25 | ASM_GLOBAL_DATA(__kudi_index_devices_end) 26 | 27 | ASM_GLOBAL_DATA(__kudi_index_ranks) 28 | .incbin "ranks.zudi-index" 29 | ASM_END_DATA(__kudi_index_ranks) 30 | ASM_GLOBAL_DATA(__kudi_index_ranks_end) 31 | 32 | ASM_GLOBAL_DATA(__kudi_index_strings) 33 | .incbin "strings.zudi-index" 34 | ASM_END_DATA(__kudi_index_strings) 35 | ASM_GLOBAL_DATA(__kudi_index_strings_end) 36 | 37 | -------------------------------------------------------------------------------- /.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Linux", 5 | "includePath": [ 6 | "${workspaceFolder}/**", 7 | "${workspaceFolder}/include", 8 | "${workspaceFolder}/__kcore/include", 9 | "${workspaceFolder}/programs/zudi/include", 10 | "${workspaceFolder}/b/include" 11 | ], 12 | "defines": [], 13 | "compilerPath": "/usr/local/bin/i586-elf/bin/i586-elf-g++", 14 | "cStandard": "c11", 15 | "cppStandard": "c++98", 16 | "intelliSenseMode": "gcc-x86", 17 | "browse": { 18 | "path": [ 19 | "${workspaceFolder}", 20 | "${workspaceFolder}/b" 21 | ], 22 | "limitSymbolsToIncludedHeaders": true, 23 | "databaseFilename": "" 24 | }, 25 | "forcedInclude": [ 26 | "${workspaceFolder}/b/include/config.h" 27 | ] 28 | } 29 | ], 30 | "version": 4 31 | } -------------------------------------------------------------------------------- /__kcore/kernel/common/memoryTrib/rawMemAlloc.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include <__kclasses/debugPipe.h> 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | void *rawMemAlloc(uarch_t nPages, uarch_t flags) 9 | { 10 | return memoryTrib.rawMemAlloc(nPages, flags); 11 | } 12 | 13 | void rawMemFree(void *vaddr, uarch_t nPages) 14 | { 15 | memoryTrib.rawMemFree(vaddr, nPages); 16 | } 17 | 18 | status_t memoryTribPmm::fragmentedGetFrames(uarch_t nFrames, paddr_t *paddr) 19 | { 20 | return memoryTrib.fragmentedGetFrames(nFrames, paddr); 21 | } 22 | 23 | status_t memoryTribPmm::constrainedGetFrames( 24 | fplainn::dma::constraints::Compiler *comCon, 25 | uarch_t nFrames, 26 | fplainn::dma::ScatterGatherList *retlist, 27 | uarch_t flags 28 | ) 29 | { 30 | return memoryTrib.constrainedGetFrames(comCon, nFrames, retlist, flags); 31 | } 32 | 33 | void memoryTribPmm::releaseFrames(paddr_t paddr, uarch_t nFrames) 34 | { 35 | memoryTrib.releaseFrames(paddr, nFrames); 36 | } 37 | 38 | -------------------------------------------------------------------------------- /__kcore/include/firmware/ibmPcBios/ibmPcBios_regManip.h: -------------------------------------------------------------------------------- 1 | #ifndef _IBM_PC_BIOS_REG_STATE_MANIP_H 2 | #define _IBM_PC_BIOS_REG_STATE_MANIP_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | #include "x86emu.h" 6 | 7 | namespace ibmPcBios_regs 8 | { 9 | uarch_t getEax(void); 10 | uarch_t getEbx(void); 11 | uarch_t getEcx(void); 12 | uarch_t getEdx(void); 13 | uarch_t getEsi(void); 14 | uarch_t getEdi(void); 15 | uarch_t getEsp(void); 16 | uarch_t getEbp(void); 17 | uarch_t getEflags(void); 18 | uarch_t getCs(void); 19 | uarch_t getDs(void); 20 | uarch_t getEs(void); 21 | uarch_t getFs(void); 22 | uarch_t getGs(void); 23 | uarch_t getSs(void); 24 | 25 | void setEax(uarch_t val); 26 | void setEbx(uarch_t val); 27 | void setEcx(uarch_t val); 28 | void setEdx(uarch_t val); 29 | void setEsi(uarch_t val); 30 | void setEdi(uarch_t val); 31 | void setEsp(uarch_t val); 32 | void setEbp(uarch_t val); 33 | void setCs(uarch_t val); 34 | void setDs(uarch_t val); 35 | void setEs(uarch_t val); 36 | void setFs(uarch_t val); 37 | void setGs(uarch_t val); 38 | void setSs(uarch_t val); 39 | } 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/vaddrSpace.h: -------------------------------------------------------------------------------- 1 | #ifndef _VADDR_SPACE_H 2 | #define _VADDR_SPACE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #define VADDRSPACE "vaddrSpace: " 11 | 12 | class VaddrSpace 13 | { 14 | public: 15 | VaddrSpace(void) 16 | : level0Paddr(paddr_t(0)) 17 | { 18 | VaddrSpace::level0Accessor.rsrc = NULL; 19 | } 20 | 21 | error_t initialize(numaBankId_t boundBankId); 22 | 23 | ~VaddrSpace(void); 24 | 25 | void dumpAllNonEmpty(void); 26 | void dumpAllPresent(void); 27 | status_t getTopLevelAddrState(void *vaddr) 28 | { 29 | return getTopLevelAddrState( 30 | (uintptr_t)vaddr >> PAGING_L0_VADDR_SHIFT); 31 | } 32 | 33 | status_t getTopLevelAddrState(uarch_t entry); 34 | 35 | public: 36 | // Uses a recursive lock, take note. 37 | SharedResourceGroup level0Accessor; 38 | #ifdef CONFIG_ARCH_x86_32_PAE 39 | sPagingLevel1 *extraPages; 40 | #endif 41 | paddr_t level0Paddr; 42 | }; 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/floodplainn/movableMemory.h: -------------------------------------------------------------------------------- 1 | #ifndef _ZUDI_MOVABLE_MEMORY_HEADER_H 2 | #define _ZUDI_MOVABLE_MEMORY_HEADER_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | #define UDI_MEM_MAGIC (0x11D1111E) 7 | #define UDI_MOVABLE_MEM_MAGIC (0x111011AB) 8 | 9 | namespace fplainn 10 | { 11 | struct sMovableMemory 12 | { 13 | void *operator new(size_t sz, uarch_t objectSize) 14 | { 15 | return ::operator new(sz + objectSize); 16 | } 17 | 18 | void operator delete(void *mem, uarch_t) 19 | { 20 | ::operator delete(mem); 21 | } 22 | 23 | void operator delete(void *mem) 24 | { 25 | operator delete(mem, 0); 26 | } 27 | 28 | sMovableMemory(uarch_t objectNBytes) 29 | : 30 | magic(0), objectNBytes(objectNBytes) 31 | {} 32 | 33 | sMovableMemory(void) 34 | : 35 | magic(0), objectNBytes(0) 36 | {} 37 | 38 | void setMagic(uarch_t _magic) { magic = _magic; } 39 | sbit8 magicIsValid(void) 40 | { 41 | if (magic == UDI_MEM_MAGIC 42 | || magic == UDI_MOVABLE_MEM_MAGIC) 43 | { return 1; }; 44 | 45 | return 0; 46 | } 47 | 48 | uarch_t magic; 49 | uarch_t objectNBytes; 50 | }; 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /__kcore/include/__kthreads/main.h: -------------------------------------------------------------------------------- 1 | #ifndef ___KORIENTATION_H 2 | #define ___KORIENTATION_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include <__kstdlib/__ktypes.h> 8 | #include 9 | 10 | #define ORIENT_QUOTE(x) #x 11 | 12 | #define DO_OR_DIE(__trib,__method,__ret) \ 13 | __ret = __trib.__method; \ 14 | if (__ret != ERROR_SUCCESS) \ 15 | { \ 16 | panic( \ 17 | __ret, \ 18 | FATAL"Kernel Orientation: Failure to initialize " \ 19 | ORIENT_QUOTE(__trib)" with method " \ 20 | ORIENT_QUOTE(__method)".\n"); \ 21 | } 22 | 23 | #define DIE_ON(__ret) \ 24 | do { \ 25 | if ((__ret) != ERROR_SUCCESS) \ 26 | { \ 27 | panic( \ 28 | __ret, \ 29 | FATAL"Orientation: " \ 30 | ORIENT_QUOTE(__func__) \ 31 | ": Asynch caller failed.\n"); \ 32 | }; \ 33 | } while(0); 34 | 35 | #define ORIENT "Orientation: " 36 | 37 | union uMultibootHeader 38 | { 39 | sMultibootHeader *mb1; 40 | sMultiboot2Header *mb2; 41 | }; 42 | 43 | extern "C" void main(ubit32 mbMagic, uMultibootHeader mbHeader); 44 | 45 | extern ubit8 __korientationPreallocatedBmpMem[][64]; 46 | 47 | #endif 48 | 49 | -------------------------------------------------------------------------------- /__kcore/chipset/ibmPc/zkcmIbmPcState.h: -------------------------------------------------------------------------------- 1 | #ifndef _ZKCM_IBM_PC_STATE_H 2 | #define _ZKCM_IBM_PC_STATE_H 3 | 4 | #include 5 | #include <__kstdlib/__ktypes.h> 6 | #include 7 | 8 | /** NOTE: 9 | * Try not to include this file in headers. Include it only in source files. 10 | **/ 11 | 12 | #define SMPSTATE_UNIPROCESSOR 0x0 13 | #define SMPSTATE_SMP 0x1 14 | 15 | struct sIbmPcChipsetState 16 | { 17 | sIbmPcChipsetState(void) 18 | : 19 | lapicPaddr(0) 20 | {} 21 | 22 | struct sBspInfo 23 | { 24 | sBspInfo(void) 25 | : 26 | bspIdRequestedAlready(0), bspId(CPUID_INVALID) 27 | {} 28 | 29 | sarch_t bspIdRequestedAlready; 30 | cpu_t bspId; 31 | } bspInfo; 32 | 33 | struct sSmpInfo 34 | { 35 | sSmpInfo(void) 36 | : 37 | chipsetState(SMPSTATE_UNIPROCESSOR), 38 | chipsetOriginalState(SMPSTATE_UNIPROCESSOR) 39 | {} 40 | 41 | // Whether SMP (Symmetric I/O) or non-SMP mode. 42 | ubit8 chipsetState; 43 | // Set the board back to Virt. wire or PIC mode at shutdown. 44 | ubit8 chipsetOriginalState; 45 | } smpInfo; 46 | 47 | paddr_t lapicPaddr; 48 | }; 49 | 50 | extern sIbmPcChipsetState ibmPcState; 51 | 52 | #endif 53 | 54 | -------------------------------------------------------------------------------- /__kcore/include/chipset/zkcm/debugDevice.h: -------------------------------------------------------------------------------- 1 | #ifndef _DEBUG_MODULE_H 2 | #define _DEBUG_MODULE_H 3 | 4 | #include 5 | #include <__kstdlib/__ktypes.h> 6 | 7 | class ZkcmDebugDevice 8 | : 9 | public ZkcmDeviceBase 10 | { 11 | public: 12 | enum deviceTypeE 13 | { 14 | TERMINAL=0, SERIAL, NETWORK, ROM, RAMBUFFER, OTHER 15 | } deviceType; 16 | 17 | ZkcmDebugDevice( 18 | deviceTypeE devType, 19 | ZkcmDevice *device 20 | ) 21 | : 22 | ZkcmDeviceBase(device), 23 | deviceType(devType) 24 | {} 25 | 26 | public: 27 | // Basic control. 28 | virtual error_t initialize(void); 29 | virtual error_t shutdown(void); 30 | virtual error_t suspend(void); 31 | virtual error_t restore(void); 32 | 33 | // Interface to take input from DebugPipe::printf(). 34 | virtual sarch_t isInitialized(void); 35 | virtual void syphon(const utf8Char *str, uarch_t len); 36 | virtual void clear(void); 37 | 38 | public: 39 | // deviceType=SERIAL || NETWORK. 40 | struct 41 | { 42 | ubit32 dataRate; 43 | // deviceType=ROM || RAMBUFFER || NETWORK 44 | uarch_t bufferSize; 45 | // deviceType=TERMINAL 46 | ubit16 lineWidth, nLines; 47 | } deviceDetails; 48 | }; 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /__kcore/__kthreads/__kcpuPowerOn.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include <__kthreads/__kcpuPowerOn.h> 6 | 7 | /** EXPLANATION: 8 | * Waking CPUs need to know the address of their sleep-stack within the kernel 9 | * vaddrspace in order to boot in parallel without centralized locking. 10 | * 11 | * We achieve this through the use of a global, resizeable array of pointers to 12 | * sleepstacks. When a CPU enters protected mode, it first looks up the address 13 | * that the kernel has mapped the local APICs to. Then it reads its CPU ID from 14 | * its local APIC, and uses that ID to index into the array of sleepstacks to 15 | * obtain the address of the stack it should use to enter the kernel. 16 | * 17 | * On this stack, pushed by the kernel before the CPU was powered on, is the 18 | * address of the CPU's CPU Stream. 19 | **/ 20 | void *__kcpuPowerStacks[CONFIG_MAX_NCPUS]; 21 | ubit8 *__kcpuPowerOnLapicVaddr=NULL; 22 | 23 | void __kcpuPowerOnMain(CpuStream *self); 24 | 25 | // Part of __koptimizationHacks.cpp. 26 | void (*__kcpuPowerOnInit(void))() 27 | { 28 | return &__kcpuPowerOnEntry; 29 | } 30 | -------------------------------------------------------------------------------- /__kcore/arch/i586/gdt.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | 5 | /** CAVEAT: 6 | * Do not try to rename this file to have the extension .cpp, or try to build 7 | * the kernel by running a compiler in "C++" parsing mode for this file. C++ 8 | * compilers have the habit of not hardcoding structs in the output objects, 9 | * and instead generating constructors to fill out hardcoded structs with their 10 | * values at runtime. 11 | * 12 | * However, the x86-32 GDT is used by the kernel long before we ever run 13 | * constructors; therefore, if some C++ compiler doesn't properly hardcode the 14 | * GDT entries as seen in here, your build will fail to run. 15 | **/ 16 | 17 | struct sX8632GdtEntry x8632Gdt[] = 18 | { 19 | {0, 0, 0, 0, 0, 0}, 20 | // Kernel descriptors. 21 | {0xFFFF, 0, 0, 0x9A, 0xCF, 0}, 22 | {0xFFFF, 0, 0, 0x92, 0xCF, 0}, 23 | // Userspace descriptors. 24 | {0xFFFF, 0, 0, 0xFA, 0xCF, 0}, 25 | {0xFFFF, 0, 0, 0xF2, 0xCF, 0}, 26 | // Space for 8 LDTs. Use the LDTs to hold TSSs. 27 | {0,0,0,0,0, 0}, 28 | {0,0,0,0,0, 0}, 29 | {0,0,0,0,0, 0}, 30 | {0,0,0,0,0, 0} 31 | }; 32 | 33 | struct sX8632GdtPtr x8632GdtPtr = 34 | { 35 | (sizeof(struct sX8632GdtEntry) * 9) - 1, 36 | x8632Gdt 37 | }; 38 | 39 | -------------------------------------------------------------------------------- /__kcore/kernel/common/vfsTrib/vfsTrib_folder.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include <__kstdlib/__kclib/string8.h> 3 | #include <__kstdlib/__kcxxlib/new> 4 | #include <__kclasses/debugPipe.h> 5 | #include 6 | #include 7 | 8 | 9 | status_t VfsTrib::createFolder(vfsDirC *dir, utf8Char *name, uarch_t) 10 | { 11 | status_t ret; 12 | vfsDirC *newDir; 13 | 14 | ret = vfsTraverse::valisDateegment(name); 15 | if (ret != ERROR_SUCCESS) { 16 | return ret; 17 | }; 18 | // Make sure folder/file with same name doesn't already exist. 19 | if (dir->desc->getDirDesc(name) != NULL 20 | || dir->desc->getFileDesc(name) != NULL) 21 | { 22 | return ERROR_INVALID_ARG_VAL; 23 | }; 24 | 25 | newDir = new (dirDescCache->allocate()) vfsDirC; 26 | if (newDir == NULL) { 27 | return ERROR_MEMORY_NOMEM; 28 | }; 29 | if ((ret = newDir->initialize(name)) != ERROR_SUCCESS) 30 | { 31 | newDir->~vfsDirC(); 32 | dirDescCache->free(newDir); 33 | return ret; 34 | }; 35 | 36 | newDir->parent = dir; 37 | dir->desc->addDirDesc(newDir); 38 | 39 | return ERROR_SUCCESS; 40 | } 41 | 42 | status_t VfsTrib::deleteFolder(vfsDirINode *inode, utf8Char *name) 43 | { 44 | return inode->removeDirDesc(name); 45 | } 46 | 47 | -------------------------------------------------------------------------------- /__kcore/include/arch/x8632/paePaging.semantics: -------------------------------------------------------------------------------- 1 | The processor while in PAE mode (PAE is enabled by setting CR4.PAE) holds 4 2 | internal non-architectural registers which point to the individual entries in 3 | the PDPT. 4 | 5 | In other words, there is no single CR3 in PAE. Software is made to think that 6 | this is so, but the processor internally uses 4 separate registers and maintains 7 | the address space as if there were 4 different PDs loaded. 8 | 9 | The 4 PDPTE registers are refreshed when: 10 | 1. Software executes a MOVL to CR0, or CR4 which enables PAE paging from 11 | the state of either no-paging enabled, or from 32-bit paging. 12 | 2. If a MOVL to CR3 is executed while PAE paging is enabled. In this case 13 | all 4 PDPTE registers are reloaded. 14 | 3. A hardware task switch which loads CR3 while PAE paging is enabled. 15 | 4. Certain VMX transitions. 16 | 17 | The manuals astate thet the processor will use Write-back (buffered) reading to 18 | load the PDPTE registers. 19 | 20 | The PAe does not support 1GB pages. The ACCESSED and DIRTY etc bits of the 21 | PDPT entries are reserved. However, a PDPTE register may be set to access all 22 | pages on that level to PCD or PWT. Note well that the R/W and U/S bits on PDPT 23 | entries are reserved. 24 | 25 | -------------------------------------------------------------------------------- /__kcore/include/multiboot2.h: -------------------------------------------------------------------------------- 1 | #ifndef _MULTIBOOT2_H 2 | #define _MULTIBOOT2_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | /* Multiboot2 header magic value */ 7 | #define MULTIBOOT2_HEADER_MAGIC 0xE85250D6 8 | 9 | /* Multiboot2 header architecture - i386 */ 10 | #define MULTIBOOT2_ARCHITECTURE_I386 0 11 | 12 | /* Multiboot2 header length - must include entire header */ 13 | #define MULTIBOOT2_HEADER_TAG_ALIGN 8 14 | 15 | /* Multiboot2 information structure magic value */ 16 | #define MULTIBOOT2_BOOTLOADER_MAGIC 0x36D76289 17 | 18 | /* Multiboot2 header tag types */ 19 | #define MULTIBOOT2_HEADER_TAG_END 0 20 | 21 | #ifndef __ASM__ 22 | 23 | /* Multiboot2 header structure */ 24 | struct sMultiboot2Header { 25 | ubit32 magic; 26 | ubit32 architecture; 27 | ubit32 header_length; 28 | ubit32 checksum; 29 | }; 30 | 31 | /* Multiboot2 header tag structure */ 32 | struct sMultiboot2HeaderTag { 33 | ubit16 type; 34 | ubit16 flags; 35 | ubit32 size; 36 | }; 37 | 38 | /* Multiboot2 information structure */ 39 | struct sMultiboot2Info { 40 | ubit32 total_size; 41 | ubit32 reserved; 42 | }; 43 | 44 | #endif /* !defined( __ASM__ ) */ 45 | 46 | #endif /* _MULTIBOOT2_H */ 47 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/floodplainn/region.h: -------------------------------------------------------------------------------- 1 | #ifndef _FLOODPLAINN_UDI_REGION_H 2 | #define _FLOODPLAINN_UDI_REGION_H 3 | 4 | #define UDI_VERSION 0x101 5 | #include 6 | #undef UDI_VERSION 7 | #include <__kstdlib/__ktypes.h> 8 | #include <__kclasses/heapList.h> 9 | 10 | class Thread; 11 | 12 | namespace fplainn 13 | { 14 | class RegionEndpoint; 15 | class DeviceInstance; 16 | 17 | class Region 18 | { 19 | public: 20 | error_t initialize(void) 21 | { return endpoints.initialize(); } 22 | 23 | void dumpChannelEndpoints(void); 24 | 25 | sbit8 findEndpoint(RegionEndpoint *endp) 26 | { 27 | HeapList::Iterator it; 28 | 29 | it = endpoints.begin(0); 30 | for (; it != endpoints.end(); ++it) 31 | { 32 | if (*it != endp) { continue; }; 33 | return 1; 34 | }; 35 | 36 | return 0; 37 | } 38 | 39 | private: 40 | friend class RegionEndpoint; 41 | 42 | error_t addEndpoint(RegionEndpoint *endp) 43 | { return endpoints.insert(endp); } 44 | 45 | sbit8 removeEndpoint(RegionEndpoint *endp) 46 | { return endpoints.remove(endp); } 47 | 48 | public: 49 | DeviceInstance *parent; 50 | ubit16 index; 51 | Thread *thread; 52 | HeapList endpoints; 53 | }; 54 | } 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /__kcore/include/chipset/zkcm/zkcmCore.h: -------------------------------------------------------------------------------- 1 | #ifndef _ZK_CHIPSET_MODULE_CORE_H 2 | #define _ZK_CHIPSET_MODULE_CORE_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #define ZKCMCORE "ZKCM Core: " 14 | 15 | class ZkcmCore 16 | { 17 | public: 18 | ZkcmCore(utf8Char *chipsetName, utf8Char *chipsetVendor); 19 | 20 | public: 21 | error_t initialize(void); 22 | error_t shutdown(void); 23 | error_t suspend(void); 24 | error_t restore(void); 25 | 26 | utf8Char chipsetName[96]; 27 | utf8Char chipsetVendor[96]; 28 | 29 | ZkcmMemoryDetectionMod memoryDetection; 30 | ZkcmCpuDetectionMod cpuDetection; 31 | 32 | // XXX: Still to be updated. 33 | WatchdogMod watchdog; 34 | ZkcmIrqControlMod irqControl; 35 | ZkcmTimerControlMod timerControl; 36 | 37 | ZkcmDebugDevice *debug[4]; 38 | 39 | void chipsetEventNotification(e__kPowerEvent event, uarch_t flags); 40 | void newCpuIdNotification(cpu_t highestCpuId); 41 | }; 42 | 43 | extern ZkcmCore zkcmCore; 44 | 45 | #endif 46 | 47 | -------------------------------------------------------------------------------- /__kcore/kernel/common/distributaryTrib/distributaries.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include <__kclasses/debugPipe.h> 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | const dvfs::sDistributaryDescriptor floodplainnIndexer= 13 | { 14 | CC"floodplainn-indexer", CC"Zambesii", 15 | CC"UDI Driver indexer and search service for Zambesii", 16 | { 17 | { CC"udi-driver-indexer", 1 }, 18 | }, 19 | 1, // Provides only one category. 20 | 0, 0, 0, // v0.00.000. 21 | (void(*)(void))&fplainn::Zui::main, 22 | 0 23 | }; 24 | 25 | const dvfs::sDistributaryDescriptor 26 | * const DistributaryTrib::distributaryDescriptors[] = 27 | { 28 | #ifdef CONFIG_DTRIB_CISTERNN 29 | &cisternnDescriptor, 30 | #endif 31 | #ifdef CONFIG_DTRIB_AQUEDUCTT 32 | #endif 33 | #ifdef CONFIG_DTRIB_REFLECTIONN 34 | #endif 35 | #ifdef CONFIG_DTRIB_CAURALL 36 | #endif 37 | #ifdef CONFIG_DTRIB_WATERMARKK 38 | #endif 39 | &floodplainnIndexer, 40 | // Null entry to terminate the array. Do not remove. 41 | NULL 42 | }; 43 | 44 | -------------------------------------------------------------------------------- /__kcore/arch/i586/x8632_debugException.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include "exceptions.h" 6 | 7 | 8 | status_t __attribute__((noreturn)) x8632_debug(RegisterContext *regs, ubit8) 9 | { 10 | Thread *currThread; 11 | 12 | currThread = cpuTrib.getCurrentCpuStream()->taskStream.getCurrentThread(); 13 | printf(NOTICE"Debug exception on CPU %d.\n" 14 | "\tContext: CS %x, EIP %x, EFLAGS %x\n" 15 | "\tESP %p, EBP %p, stack0 %p, stack1 %p\n" 16 | "\tESI %x, EDI %x\n" 17 | "\tEAX %x, EBX %x, ECX %x, EDX %x.\n", 18 | cpuTrib.getCurrentCpuStream()->cpuId, 19 | regs->cs, regs->eip, regs->eflags, 20 | regs->esp, regs->ebp, 21 | currThread->stack0, currThread->stack1, 22 | regs->esi, regs->edi, 23 | regs->eax, regs->ebx, regs->ecx, regs->edx); 24 | 25 | debug::sStackDescriptor currStackDesc; 26 | 27 | debug::getCurrentStackInfo(&currStackDesc); 28 | if (currThread != NULL) 29 | { printf(NOTICE"This is a normal thread.\n"); } 30 | else 31 | { printf(NOTICE"This is a per-cpu thread.\n"); }; 32 | 33 | debug::printStackTrace( 34 | (void *)regs->ebp, &currStackDesc); 35 | 36 | for (;FOREVER;) 37 | { 38 | cpuControl::disableInterrupts(); 39 | cpuControl::halt(); 40 | }; 41 | } 42 | 43 | -------------------------------------------------------------------------------- /__kcore/kernel/i586/cpuFeatures.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | 5 | sCpuFeatures x8632Cpus[] = 6 | { 7 | { 8 | "Pre-P6", "Intel 80486" /*, 9 | 0, 2, 0, 64, 10 | CPUFEAT_BITWIDTH_16 | CPUFEAT_BITWIDTH_32, 11 | { 12 | 0, 0, 13 | 0 14 | }*/ 15 | }, 16 | { 17 | "Pre-P6", "Intel 80586 (Pentium)" 18 | }, 19 | { 20 | "P6", "Intel Pentium Pro" 21 | }, 22 | { 23 | "P6", "Intel Pentium 2" 24 | }, 25 | { 26 | "P6", "Intel Pentium 2 Xeon" 27 | }, 28 | { 29 | "P6", "Intel Celeron" 30 | }, 31 | { 32 | "P6", "Intel Pentium 3" 33 | }, 34 | { 35 | "P6", "Intel Pentium 3 Xeon" 36 | }, 37 | { 38 | "Pentium 4", "Intel Xeon" 39 | }, 40 | { 41 | "Pentium 4", "Intel Pentium M" 42 | }, 43 | { 44 | "Pentium 4", "Intel Pentium Processor Extreme Edition" 45 | }, 46 | { 47 | "Core", "Intel Core Solo" 48 | }, 49 | { 50 | "Core", "Intel Core Duo" 51 | }, 52 | { 53 | "Core 2", "Intel Xeon 5100" 54 | }, 55 | { 56 | "Core 2", "Intel Xeon 5200" 57 | }, 58 | { 59 | "Core 2", "Intel Xeon 5300" 60 | }, 61 | { 62 | "Core 2", "Intel Xeon 5400" 63 | }, 64 | { 65 | "Core 2", "Intel Xeon 7400" 66 | }, 67 | { 68 | "Atom", "Intel Atom series" 69 | }, 70 | { 71 | "Core i7", "Intel Core i7 series" 72 | } 73 | }; 74 | 75 | -------------------------------------------------------------------------------- /scripts/configure-i586-ibmPc-ibmPcBios-numa.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Script to configure the kernel with specific options 4 | # Created: $(date) 5 | 6 | # Exit on error 7 | set -e 8 | 9 | echo "Running autoreconf..." 10 | autoreconf -i .. ../build/zudi 11 | 12 | HOST_TRIPLET="${HOST_TRIPLET:-i586-elf}" 13 | CPPFLAGS="${CPPFLAGS}" 14 | CFLAGS="${CFLAGS:--g}" 15 | CXXFLAGS="${CXXFLAGS:--g}" 16 | LDFLAGS="${LDFLAGS}" 17 | if [ -z "${REPLACE_ARGS}" ] 18 | then REPLACE_ARGS=$(cat <<'EOF' 19 | --disable-rt-kernel-irqs 20 | --enable-all-debug-opts 21 | --disable-kernel-vaddrspace-demand-paging 22 | --disable-heap-demand-paging 23 | --enable-debug-page-faults 24 | --disable-debug-interrupts 25 | --enable-debug-locked-interrupt-entry 26 | --enable-debug-locks 27 | --enable-dtrib-cisternn 28 | EOF 29 | ) 30 | fi 31 | APPEND_ARGS="${APPEND_ARGS:- }" 32 | 33 | echo "Running configure with custom options..." 34 | ../configure \ 35 | CPPFLAGS="${CPPFLAGS}" \ 36 | CFLAGS="${CFLAGS}" \ 37 | CXXFLAGS="${CXXFLAGS}" \ 38 | LDFLAGS="${LDFLAGS}" \ 39 | --host="${HOST_TRIPLET}" \ 40 | ZCHIPSET=pc \ 41 | ZFIRMWARE=bios \ 42 | --enable-scaling=ccnuma \ 43 | --with-max-ncpus=64 \ 44 | ${REPLACE_ARGS} ${APPEND_ARGS} 45 | 46 | echo "Configuration completed successfully!" 47 | -------------------------------------------------------------------------------- /__kcore/include/__kclasses/singleWaiterQueue.h: -------------------------------------------------------------------------------- 1 | #ifndef _SINGLE_WAITER_QUEUE_H 2 | #define _SINGLE_WAITER_QUEUE_H 3 | 4 | #include <__kstdlib/__kflagManipulation.h> 5 | #include <__kclasses/heapDoubleList.h> 6 | #include 7 | 8 | #define SWAITQ "Single-WaiterQ: " 9 | 10 | #define SINGLEWAITERQ_POP_FLAGS_DONTBLOCK (1<<0) 11 | 12 | class Thread; 13 | 14 | class SingleWaiterQueue 15 | : 16 | public HeapDoubleList 17 | { 18 | public: 19 | SingleWaiterQueue(void) 20 | : 21 | thread(NULL) 22 | {} 23 | 24 | error_t initialize(void) 25 | { 26 | return HeapDoubleList::initialize(); 27 | }; 28 | 29 | ~SingleWaiterQueue(void) {} 30 | 31 | void dump(void) 32 | { 33 | printf(NOTICE SWAITQ"%p: thread %p.\n", this, thread); 34 | HeapDoubleList::dump(); 35 | } 36 | 37 | public: 38 | error_t addItem(void *item); 39 | // HeapDoubleList::remove() is sufficient, needs no extending. 40 | // HeapDoubleList::getHead() is sufficient, needs no extending. 41 | // HeapDoubleList::getNItems() is sufficient, needs no extending. 42 | error_t pop(void **ret, uarch_t flags=0); 43 | error_t setWaitingThread(Thread *thread); 44 | 45 | Thread *getThread(void) { return thread; } 46 | 47 | private: 48 | Thread *thread; 49 | WaitLock lock; 50 | }; 51 | 52 | #endif 53 | 54 | -------------------------------------------------------------------------------- /__kcore/arch/i586/x8632_breakpointException.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include "exceptions.h" 6 | 7 | 8 | status_t __attribute__((noreturn)) x8632_breakpoint(RegisterContext *regs, ubit8) 9 | { 10 | Thread *currThread=NULL; 11 | 12 | currThread = cpuTrib.getCurrentCpuStream()->taskStream.getCurrentThread(); 13 | printf(NOTICE"Breakpoint exception on CPU %d.\n" 14 | "\tContext: CS %x, EIP %x, EFLAGS %x\n" 15 | "\tESP %p, EBP %p, stack0 %p, stack1 %p\n" 16 | "\tESI %x, EDI %x\n" 17 | "\tEAX %x, EBX %x, ECX %x, EDX %x.\n", 18 | cpuTrib.getCurrentCpuStream()->cpuId, 19 | regs->cs, regs->eip, regs->eflags, 20 | regs->esp, regs->ebp, 21 | currThread->stack0, currThread->stack1, 22 | regs->esi, regs->edi, 23 | regs->eax, regs->ebx, regs->ecx, regs->edx); 24 | 25 | debug::sStackDescriptor currStackDesc; 26 | 27 | debug::getCurrentStackInfo(&currStackDesc); 28 | if (currThread != NULL) 29 | { printf(NOTICE"This is a normal thread.\n"); } 30 | else 31 | { printf(NOTICE"This is a per-cpu thread.\n"); }; 32 | 33 | debug::printStackTrace( 34 | (void *)regs->ebp, &currStackDesc); 35 | 36 | for (;FOREVER;) 37 | { 38 | cpuControl::disableInterrupts(); 39 | cpuControl::halt(); 40 | }; 41 | } 42 | 43 | -------------------------------------------------------------------------------- /__kcore/arch/i586/cpuid.S: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | 6 | ASM_GLOBAL_FUNCTION(execCpuid) 7 | /* void execCpuid( 8 | * uarch_t num, 9 | * uarch_t *eax, uarch_t *ebx, uarch_t *ecx, uarch_t *edx); 10 | **/ 11 | pushl %eax 12 | pushl %ebx 13 | pushl %ecx 14 | pushl %edx 15 | movl 20(%esp), %eax 16 | cpuid 17 | 18 | pushl %ebx 19 | movl 28(%esp), %ebx 20 | movl %eax, (%ebx) 21 | popl %ebx 22 | movl 28(%esp), %eax 23 | movl %ebx, (%eax) 24 | movl 32(%esp), %eax 25 | movl %ecx, (%eax) 26 | movl 36(%esp), %eax 27 | movl %edx, (%eax) 28 | 29 | popl %edx 30 | popl %ecx 31 | popl %ebx 32 | popl %eax 33 | ret 34 | 35 | .loop: jmp . 36 | 37 | ASM_END_FUNCTION(execCpuid) 38 | 39 | ASM_GLOBAL_FUNCTION(x8632_verifyCpuIsI486OrHigher) 40 | pushl %ebx 41 | 42 | /* Try to change the ID flag in EFLAGS to see if CPUID is supported. */ 43 | pushfl 44 | popl %eax 45 | movl $1, %ebx 46 | shl $21, %ebx 47 | orl %ebx, %eax 48 | pushl %eax 49 | popfl 50 | 51 | /* Check to see if it got changed. */ 52 | pushfl 53 | popl %eax 54 | andl %ebx, %eax 55 | popl %ebx 56 | cmpl $0, %eax 57 | je .failed 58 | 59 | /* CPU is at least i486, since it has CPUID. */ 60 | ret 61 | 62 | .failed: 63 | movl $0, %eax 64 | ret 65 | ASM_END_FUNCTION(x8632_verifyCpuIsI486OrHigher) 66 | 67 | -------------------------------------------------------------------------------- /__kcore/include/arch/x8632/debug.h: -------------------------------------------------------------------------------- 1 | #ifndef _ARCH_x86_32_DEBUG_H 2 | #define _ARCH_x86_32_DEBUG_H 3 | 4 | #include 5 | #include <__kstdlib/__ktypes.h> 6 | 7 | #define DEBUG_BREAKPOINT_READ (1<<0) 8 | #define DEBUG_BREAKPOINT_WRITE (1<<1) 9 | #define DEBUG_BREAKPOINT_EXEC (1<<2) 10 | 11 | #define DEBUG_FLAGS_ENABLED (1<<4) 12 | #define DEBUG_FLAGS_BP0_ENABLED (1<<0) 13 | #define DEBUG_FLAGS_BP1_ENABLED (1<<1) 14 | #define DEBUG_FLAGS_BP2_ENABLED (1<<2) 15 | #define DEBUG_FLAGS_BP3_ENABLED (1<<3) 16 | 17 | namespace debug 18 | { 19 | ubit8 *getStackPointer(void); 20 | void getVaddrSpacePointer(paddr_t *p); 21 | 22 | void enableDebugExtensions(void); 23 | void disableDebugExtensions(void); 24 | sarch_t debugExtensionsEnabled(void); 25 | 26 | class Debugger 27 | { 28 | friend void debug::enableDebugExtensions(void); 29 | friend void debug::disableDebugExtensions(void); 30 | friend sarch_t debug::debugExtensionsEnabled(void); 31 | 32 | public: 33 | void setBreakpoint( 34 | ubit8 breakpoint, void *addr, ubit8 opSize, ubit8 rwx); 35 | 36 | void enableBreakpoint(ubit8 breakpoint); 37 | void disableBreakpoint(ubit8 breakpoint); 38 | sarch_t breakpointEnabled(ubit8 breakpoint); 39 | 40 | private: 41 | static uarch_t flags; 42 | }; 43 | } 44 | 45 | #endif 46 | 47 | 48 | -------------------------------------------------------------------------------- /__kcore/chipset/ibmPc/vgaTerminal.h: -------------------------------------------------------------------------------- 1 | #ifndef _IBM_PC_TERMINAL_MOD_H 2 | #define _IBM_PC_TERMINAL_MOD_H 3 | 4 | #include 5 | 6 | class IbmPcVgaTerminal 7 | : 8 | public ZkcmDebugDevice 9 | { 10 | public: 11 | IbmPcVgaTerminal() 12 | : 13 | ZkcmDebugDevice(ZkcmDebugDevice::TERMINAL, &baseDeviceInfo), 14 | buff(NULL), 15 | baseDeviceInfo( 16 | 0, 17 | CC"ibmpc-vga-term", CC"IBM PC compatible VGA card in text mode", 18 | CC"Unknown vendor", CC"N/A") 19 | {} 20 | 21 | public: 22 | virtual error_t initialize(void); 23 | virtual error_t shutdown(void); 24 | virtual error_t suspend(void); 25 | virtual error_t restore(void); 26 | 27 | // Interface to take input from DebugPipe::printf(). 28 | virtual sarch_t isInitialized(void); 29 | virtual void syphon(const utf8Char *str, uarch_t len); 30 | virtual void clear(void); 31 | 32 | void chipsetEventNotification(ubit8 event, uarch_t flags); 33 | 34 | private: 35 | void scrollDown(void); 36 | 37 | private: 38 | struct sIbmPc_TerminalMod_Fb 39 | { 40 | ubit8 ch; 41 | ubit8 attr; 42 | }; 43 | 44 | struct sIbmPc_TerminalMod_Fb *buff, *origBuff; 45 | uarch_t row, col, maxRow, maxCol; 46 | static ubit8 *bda; 47 | 48 | ZkcmDevice baseDeviceInfo; 49 | }; 50 | 51 | extern IbmPcVgaTerminal ibmPcVgaTerminal; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /libraries/libzbzcrt_prebuild/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # This Makefile is used to build the prebuilt version of the ZBZ C runtime library. 3 | # It doesn't support out-of-tree building. 4 | # Just type Make right in here. 5 | # 6 | $(warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) 7 | $(warning !!!Make sure to set ZARCH, and to set HOST to your host toolchain prefix!!!) 8 | $(warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) 9 | ifndef ZARCH 10 | $(error ZARCH is not set. Please set ZARCH to the target architecture. Check the top level configure.ac for architecture name options.) 11 | endif 12 | 13 | ORIG_CC := $(CC) 14 | 15 | ifdef HOST 16 | ifeq ($(ORIG_CC),cc) 17 | CC := $(HOST)-gcc 18 | else 19 | CC := $(HOST)-$(if $(ORIG_CC),$(ORIG_CC),gcc) 20 | endif 21 | CCAS := $(HOST)-as 22 | 23 | else 24 | CC := $(if $(ORIG_CC),$(ORIG_CC),gcc) 25 | CCAS := as 26 | endif 27 | 28 | AS := $(CCAS) 29 | RANLIB ?= ranlib 30 | 31 | CPPFLAGS = -DLIBZBZ_PREBUILD 32 | 33 | LIBZBZ_CRT_DIR := ../libzbzcrt/$(ZARCH) 34 | 35 | libc.a: crt1.o crt0.o crti.o crtn.o 36 | $(AR) $(ARFLAGS) $@ $^ 37 | $(RANLIB) $@ 38 | 39 | crt%.S: $(LIBZBZ_CRT_DIR)/crt%.S 40 | ln -sf $< $@ 41 | 42 | crt1.S: $(LIBZBZ_CRT_DIR)/crt0.S 43 | ln -sf $< $@ 44 | 45 | clean: 46 | rm -f *.o *.a *.S 47 | -------------------------------------------------------------------------------- /__kcore/firmware/ibmPcBios/ibmPcBios_setRegs.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | void ibmPcBios_regs::setEax(uarch_t val) 5 | { 6 | M.x86.R_EAX = val; 7 | } 8 | 9 | void ibmPcBios_regs::setEbx(uarch_t val) 10 | { 11 | M.x86.R_EBX = val; 12 | } 13 | 14 | void ibmPcBios_regs::setEcx(uarch_t val) 15 | { 16 | M.x86.R_ECX = val; 17 | } 18 | 19 | void ibmPcBios_regs::setEdx(uarch_t val) 20 | { 21 | M.x86.R_EDX = val; 22 | } 23 | 24 | void ibmPcBios_regs::setEsi(uarch_t val) 25 | { 26 | M.x86.R_ESI = val; 27 | } 28 | 29 | void ibmPcBios_regs::setEdi(uarch_t val) 30 | { 31 | M.x86.R_EDI = val; 32 | } 33 | 34 | void ibmPcBios_regs::setEsp(uarch_t val) 35 | { 36 | M.x86.R_ESP = val; 37 | } 38 | 39 | void ibmPcBios_regs::setEbp(uarch_t val) 40 | { 41 | M.x86.R_EBP = val; 42 | } 43 | 44 | void ibmPcBios_regs::setCs(uarch_t val) 45 | { 46 | M.x86.R_CS = val; 47 | } 48 | 49 | void ibmPcBios_regs::setDs(uarch_t val) 50 | { 51 | M.x86.R_DS = val; 52 | } 53 | 54 | void ibmPcBios_regs::setEs(uarch_t val) 55 | { 56 | M.x86.R_ES = val; 57 | } 58 | 59 | void ibmPcBios_regs::setFs(uarch_t val) 60 | { 61 | M.x86.R_FS = val; 62 | } 63 | 64 | void ibmPcBios_regs::setGs(uarch_t val) 65 | { 66 | M.x86.R_GS = val; 67 | } 68 | 69 | void ibmPcBios_regs::setSs(uarch_t val) 70 | { 71 | M.x86.R_SS = val; 72 | } 73 | 74 | 75 | -------------------------------------------------------------------------------- /__kcore/include/__kclasses/pageTableCache.h: -------------------------------------------------------------------------------- 1 | #ifndef _PAGE_TABLE_CACHE_H 2 | #define _PAGE_TABLE_CACHE_H 3 | 4 | #include 5 | #include 6 | #include <__kstdlib/__ktypes.h> 7 | #include <__kclasses/allocClass.h> 8 | #include 9 | #include 10 | 11 | /** EXPLANATION: 12 | * Page Table Cache is a fast one-frame allocator for on-the-fly allocation of 13 | * paging structures. Right now it can only hold as many frame addresses as can 14 | * be contained in one page. Soon, it will be a runtime-expanding class which 15 | * is dynamically grown and shrunk to cater for the kernel's page-structure 16 | * needs. 17 | **/ 18 | 19 | #define PTCACHE_NENTRIES (PAGING_BASE_SIZE / sizeof(paddr_t)) 20 | #define PTCACHE_STACK_EMPTY (-1) 21 | #define PTCACHE_STACK_FULL (PTCACHE_NENTRIES - 1) 22 | 23 | class PageTableCache 24 | : 25 | public AllocatorBase 26 | { 27 | public: 28 | PageTableCache(void); 29 | ~PageTableCache(void); 30 | 31 | public: 32 | error_t pop(paddr_t *paddr); 33 | void push(paddr_t paddr); 34 | 35 | // This will flush the cache when pmem is lacking. Pretty expensive. 36 | void flush(void); 37 | 38 | private: 39 | paddr_t stack[PTCACHE_NENTRIES]; 40 | SharedResourceGroup stackPtr; 41 | }; 42 | 43 | #endif 44 | 45 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/numaConfig.h: -------------------------------------------------------------------------------- 1 | #ifndef _NUMA_CONFIG_H 2 | #define _NUMA_CONFIG_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | #include <__kclasses/bitmap.h> 6 | #include 7 | #include 8 | #include 9 | 10 | /** EXPLANATION: 11 | * NUMA Configuration is done via this simple interface. The idea is to set a 12 | * default memory bank when allocating memory for the kernel. This way, when 13 | * allocating memory according to a thread's NUMA policy, we don't waste time 14 | * searching empty banks, etc. 15 | * 16 | * A thread sets its NUMA config via syscalls, and the kernel will set a default 17 | * bank for it. Memory allocation is done via the default bank. If an allocation 18 | * attempt on the default bank for a thread fails, all of its configured banks 19 | * are searched in sequence, and the first one which returns memory is deemed 20 | * the new default bank. 21 | * 22 | * This reduces the amount of lock contention on the bitmap of NUMA banks. 23 | **/ 24 | 25 | struct sNumaConfig 26 | { 27 | // Simple bitmap for bank config. 28 | Bitmap memBanks; 29 | // Last bank to which this task was scheduled. 30 | numaBankId_t last; 31 | SharedResourceGroup def; 32 | }; 33 | 34 | #endif 35 | 36 | -------------------------------------------------------------------------------- /__kcore/chipset/ibmPc/rs232.h: -------------------------------------------------------------------------------- 1 | #ifndef _IBM_PC_RS232_MOD_H 2 | #define _IBM_PC_RS232_MOD_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class IbmPcRs232 9 | : 10 | public ZkcmDebugDevice 11 | { 12 | public: 13 | IbmPcRs232(ubit32 childId) 14 | : 15 | ZkcmDebugDevice(ZkcmDebugDevice::TERMINAL, &baseDeviceInfo), 16 | baseDeviceInfo( 17 | childId, 18 | CC"ibmpc-rs232-serial", CC"IBM PC compatible RS232 serial", 19 | CC"Unknown vendor", CC"N/A") 20 | {} 21 | 22 | public: 23 | virtual error_t initialize(void); 24 | virtual error_t shutdown(void); 25 | virtual error_t suspend(void); 26 | virtual error_t restore(void); 27 | 28 | // Interface to take input from DebugPipe::printf(). 29 | virtual sarch_t isInitialized(void); 30 | virtual void syphon(const utf8Char *str, uarch_t len); 31 | virtual void clear(void); 32 | 33 | void chipsetEventNotification(ubit8 event, uarch_t flags); 34 | 35 | private: 36 | // Serial is a character stream, there's no surface to scroll 37 | void scrollDown(void) {} 38 | 39 | private: 40 | struct sState 41 | { 42 | sState(void) 43 | : 44 | port(0) 45 | {} 46 | 47 | ubit16 port; 48 | }s; 49 | 50 | ZkcmDevice baseDeviceInfo; 51 | }; 52 | 53 | extern IbmPcRs232 ibmPcRs2320, ibmPcRs2321; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/recursiveLock.h: -------------------------------------------------------------------------------- 1 | #ifndef _RECURSIVE_LOCK_H 2 | #define _RECURSIVE_LOCK_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | #include 6 | #include 7 | #include 8 | 9 | /** EXPLANATION: 10 | * Standard recursive non-sleeping lock. Uses atomic compareAndExchange 11 | * to efficiently manage lock ownership without requiring a separate WaitLock. 12 | * The lock member of the base Lock class is used to store the thread ID of 13 | * the owner, or PROCID_INVALID if the lock is free. 14 | * 15 | * Includes deadlock detection when CONFIG_DEBUG_LOCKS is defined. 16 | **/ 17 | 18 | class RecursiveLock 19 | : 20 | public Lock 21 | { 22 | public: 23 | enum flagShiftE { 24 | RL_FLAGS_ENUM_END = Lock::FLAGS_ENUM_END 25 | }; 26 | 27 | // Compile-time check that enum values fit within uarch_t 28 | typedef char __lock_flags_size_check2[(RL_FLAGS_ENUM_END <= __UARCH_T_NBITS__) ? 1 : -1]; 29 | 30 | RecursiveLock(void) 31 | : Lock() 32 | { 33 | // Initialize lock to PROCID_INVALID to indicate it's free 34 | lock = PROCID_INVALID; 35 | recursionCount = 0; 36 | } 37 | 38 | public: 39 | void acquire(void); 40 | void release(void); 41 | 42 | private: 43 | // Count of how many times the lock has been acquired recursively 44 | uarch_t recursionCount; 45 | }; 46 | 47 | #endif 48 | 49 | -------------------------------------------------------------------------------- /__kcore/include/__kstdlib/__ktypes.h: -------------------------------------------------------------------------------- 1 | #ifndef __KTYPES_H 2 | #define __KTYPES_H 3 | 4 | #ifndef __ASM__ 5 | #include 6 | #include 7 | #endif 8 | #include 9 | #include <__kstdlib/__kerror.h> 10 | #include <__kstdlib/__kcxxCast.h> 11 | 12 | // "CC" below stands for "kernel char cast". 13 | #define CC (utf8Char *) 14 | #define FOREVER (1) 15 | #define DECLARATION 16 | 17 | #ifndef __ASM__ 18 | 19 | typedef int8_t sbit8; 20 | typedef int16_t sbit16; 21 | typedef int32_t sbit32; 22 | typedef int64_t sbit64; 23 | 24 | typedef uint8_t ubit8; 25 | typedef uint16_t ubit16; 26 | typedef uint32_t ubit32; 27 | typedef uint64_t ubit64; 28 | 29 | // Define Zambesii's integral types. 30 | #ifdef __64_BIT__ 31 | typedef uint64_t uarch_t; 32 | typedef int64_t sarch_t; 33 | #elif defined (__32_BIT__) 34 | typedef uint32_t uarch_t; 35 | typedef int32_t sarch_t; 36 | #endif 37 | 38 | typedef sarch_t error_t; 39 | typedef sarch_t status_t; 40 | 41 | // Zambesii supports unicode in the form of UTF-8. 42 | typedef ubit8 utf8Char; 43 | typedef ubit16 utf16Char; 44 | typedef ubit32 unicodePoint; 45 | 46 | #define __UARCH_T_NBITS__ (sizeof(uarch_t) * __BITS_PER_BYTE__) 47 | #define __SARCH_T_NBITS__ (sizeof(sarch_t) * __BITS_PER_BYTE__) 48 | 49 | const utf8Char *strerror(error_t err); 50 | 51 | #endif /* !defined( __ASM__ ) */ 52 | 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/deadlock.h: -------------------------------------------------------------------------------- 1 | #ifndef __KERNEL_COMMON_DEADLOCK_DETECTION_H 2 | #define __KERNEL_COMMON_DEADLOCK_DETECTION_H 3 | 4 | #include 5 | 6 | #ifdef CONFIG_DEBUG_LOCKS 7 | 8 | #include <__kstdlib/__kclib/string.h> 9 | #include 10 | #include 11 | 12 | #define DEADLOCK_BUFF_MAX_NBYTES (1024) 13 | #define DEADLOCK_READ_BASE_MAX_NTRIES (10000) 14 | #define DEADLOCK_WRITE_BASE_MAX_NTRIES (10000) 15 | #define DEADLOCK_PER_CPU_EXTRA_READ_NTRIES (7500) 16 | #define DEADLOCK_PER_CPU_EXTRA_WRITE_NTRIES (7500) 17 | 18 | struct sDeadlockBuff 19 | { 20 | sDeadlockBuff(void) 21 | : 22 | inUse(0) 23 | { 24 | memset(buff, 0, sizeof(buff)); 25 | buffer.rsrc = buff; 26 | } 27 | 28 | sbit8 inUse; 29 | utf8Char buff[DEADLOCK_BUFF_MAX_NBYTES]; 30 | SharedResourceGroup buffer; 31 | } extern deadlockBuffers[CONFIG_MAX_NCPUS]; 32 | 33 | /** 34 | * Common function to handle deadlock detection for all lock types 35 | * 36 | * @param formatStr Format string for the deadlock message 37 | * @param ... Variable arguments for the format string, including lock object, CPU ID, and caller address 38 | */ 39 | void reportDeadlock(utf8Char *formatStr, ...); 40 | 41 | #endif 42 | 43 | #endif /* __KERNEL_COMMON_DEADLOCK_DETECTION_H */ 44 | -------------------------------------------------------------------------------- /__kcore/firmware/ibmPcBios/ibmPcBios_getRegs.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | uarch_t ibmPcBios_regs::getEax(void) 5 | { 6 | return M.x86.R_EAX; 7 | } 8 | 9 | uarch_t ibmPcBios_regs::getEbx(void) 10 | { 11 | return M.x86.R_EBX; 12 | } 13 | 14 | uarch_t ibmPcBios_regs::getEcx(void) 15 | { 16 | return M.x86.R_ECX; 17 | } 18 | 19 | uarch_t ibmPcBios_regs::getEdx(void) 20 | { 21 | return M.x86.R_EDX; 22 | } 23 | 24 | uarch_t ibmPcBios_regs::getEsi(void) 25 | { 26 | return M.x86.R_ESI; 27 | } 28 | 29 | uarch_t ibmPcBios_regs::getEdi(void) 30 | { 31 | return M.x86.R_EDI; 32 | } 33 | 34 | uarch_t ibmPcBios_regs::getEsp(void) 35 | { 36 | return M.x86.R_ESP; 37 | } 38 | 39 | uarch_t ibmPcBios_regs::getEbp(void) 40 | { 41 | return M.x86.R_EBP; 42 | } 43 | 44 | uarch_t ibmPcBios_regs::getCs(void) 45 | { 46 | return M.x86.R_CS; 47 | } 48 | 49 | uarch_t ibmPcBios_regs::getDs(void) 50 | { 51 | return M.x86.R_DS; 52 | } 53 | 54 | uarch_t ibmPcBios_regs::getEs(void) 55 | { 56 | return M.x86.R_ES; 57 | } 58 | 59 | uarch_t ibmPcBios_regs::getFs(void) 60 | { 61 | return M.x86.R_FS; 62 | } 63 | 64 | uarch_t ibmPcBios_regs::getGs(void) 65 | { 66 | return M.x86.R_GS; 67 | } 68 | 69 | uarch_t ibmPcBios_regs::getSs(void) 70 | { 71 | return M.x86.R_SS; 72 | } 73 | 74 | uarch_t ibmPcBios_regs::getEflags(void) 75 | { 76 | return M.x86.R_EFLG; 77 | } 78 | 79 | -------------------------------------------------------------------------------- /__kcore/include/arch/x8632/registerContext.h: -------------------------------------------------------------------------------- 1 | #ifndef _ARCH_x86_32_TASK_CONTEXT_H 2 | #define _ARCH_x86_32_TASK_CONTEXT_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | #include <__kstdlib/__kclib/string.h> 6 | #include 7 | #include 8 | 9 | class __attribute__((packed)) RegisterContext 10 | { 11 | public: 12 | RegisterContext(ubit8 execDomain); 13 | error_t initialize(void) { return ERROR_SUCCESS; }; 14 | 15 | /** EXPLANATION: 16 | * "initialStackIndex" specifies which of the stacks to set the new 17 | * thread's stack pointer register to. 18 | * 19 | * "0" for the kernel stack and "1" for the userspace stack. 20 | **/ 21 | void setStacks(void *stack0, void *stack1, ubit8 initialStackIndex); 22 | 23 | void setEntryPoint(void (*entryPoint)(void *)) 24 | { 25 | eip = (uintptr_t)entryPoint; 26 | } 27 | 28 | void dump(void); 29 | 30 | public: 31 | ubit16 es; // 2 32 | ubit16 ds; // 4 33 | ubit16 gs; // 6 34 | ubit16 fs; // 8 35 | ubit32 edi, esi; // 16 36 | ubit32 ebp, dummyEsp; // 24 37 | ubit32 ebx, edx; // 32 38 | ubit32 ecx, eax; // 40 39 | ubit32 vectorNo; // 44 40 | // Error code pushed by the CPU for certain exceptions. 41 | ubit32 errorCode; // 48 42 | ubit32 eip, cs; // 56 43 | ubit32 eflags; // 60 44 | ubit32 esp, ss; // 68 45 | }; 46 | 47 | #endif 48 | 49 | -------------------------------------------------------------------------------- /__kcore/arch/i586/x86-debug-extensions.txt: -------------------------------------------------------------------------------- 1 | ** Last branch recording facilities — Store branch records in the last branch 2 | record (LBR) stack MSRs for the most recent taken branches, interrupts, and/or 3 | exceptions in MSRs. A branch record consist of a branch-from and a branch-to 4 | instruction address. Send branch records out on the system bus as branch trace 5 | messages (BTMs). 6 | These facilities allow a debugger to be called as a separate task or as a procedure in 7 | the context of the current program or task. The following conditions can be used to 8 | invoke the debugger: 9 | 10 | * Task switch to a specific task. 11 | * Execution of the breakpoint instruction. 12 | * Execution of any instruction. 13 | * Execution of an instruction at a specified address. 14 | * Read or write to a specified memory address/range. 15 | * Write to a specified memory address/range. 16 | * Input from a specified I/O address/range. 17 | * Output to a specified I/O address/range. 18 | * Attempt to change the contents of a debug register. 19 | 20 | Debug registers DR4 and DR5 are reserved when debug extensions are enabled 21 | (when the DE flag in control register CR4 is set) and attempts to reference the DR4 22 | and DR5 registers cause invalid-opcode exceptions (#UD). When debug extensions 23 | are not enabled (when the DE flag is clear), these registers are aliased to debug 24 | registers DR6 and DR7. 25 | 26 | -------------------------------------------------------------------------------- /__kcore/include/chipset/zkcm/memoryMap.h: -------------------------------------------------------------------------------- 1 | #ifndef _CHIPSET_MEMORY_MAP_H 2 | #define _CHIPSET_MEMORY_MAP_H 3 | 4 | #include 5 | #include <__kstdlib/__ktypes.h> 6 | 7 | /** EXPLANATION: 8 | * This compile-time interface is used to allow a person porting a chipset to 9 | * compile-in a memory map of physical RAM on his/her particular chipset. 10 | * 11 | * If the pointer at the end of this file is not NULL, the kernel will assume 12 | * that the information given in this interface overrides anything the firmware 13 | * can provide; Technically the assumption is that the firmware is /unable/ to 14 | * provide a memory map, so the person porting the chipset, having knowledge of 15 | * the chipset's memory configuration, was nice prudent enough to provide his 16 | * /her own. 17 | * 18 | * The Firmware Trib must return a struct of this form as well, take note. 19 | **/ 20 | 21 | #define ZKCM_MMAP_TYPE_USABLE 0 22 | #define ZKCM_MMAP_TYPE_RECLAIMABLE 1 23 | #define ZKCM_MMAP_TYPE_RESERVED 2 24 | #define ZKCM_MMAP_TYPE_MMIO 3 25 | #define ZKCM_MMAP_TYPE_FIRMWARE 4 26 | 27 | struct sZkcmMemoryMapEntryS 28 | { 29 | paddr_t baseAddr, size; 30 | // Must be signed so it can hold the values defined above. 31 | sbit8 memType; 32 | }; 33 | 34 | struct sZkcmMemoryMapS 35 | { 36 | struct sZkcmMemoryMapEntryS *entries; 37 | ubit32 nEntries; 38 | }; 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /__kcore/chipset/ibmPc/udi_init_info.cpp: -------------------------------------------------------------------------------- 1 | 2 | #define UDI_VERSION 0x101 3 | #include 4 | #undef UDI_VERSION 5 | #include <__kstdlib/__ktypes.h> 6 | #include 7 | 8 | /** EXPLANATION: 9 | * In this file, every UDI driver and library provided by this chipset shall 10 | * be listed. Simply create an entry for it with its shortname, a pointer to 11 | * its udi_init_info or mei_init_info, and that is all that is required. 12 | * 13 | * The kernel is equipped with the intelligence to do all the rest of the work. 14 | **/ 15 | 16 | /** XXX: 17 | * Place your udi_init_info declaration here. 18 | **/ 19 | extern const udi_init_t zramdisk_init_info; 20 | extern const udi_init_t zrootdev_init_info; 21 | 22 | extern const udi_mei_init_t udi_mgmt_meta_info; 23 | extern const udi_mei_init_t udi_gio_meta_info; 24 | extern const udi_mei_init_t udi_bridge_meta_info; 25 | 26 | const sDriverInitEntry driverInitInfo[] = 27 | { 28 | { CC"zramdisk", &zramdisk_init_info }, 29 | { CC"zrootdev", &zrootdev_init_info }, 30 | // Shall always be terminated with the NULL entry. 31 | { NULL, NULL } 32 | }; 33 | 34 | const sMetaInitEntry metaInitInfo[] = 35 | { 36 | { CC"udi_gio", &udi_gio_meta_info }, 37 | { CC"udi_physio", &udi_bridge_meta_info }, 38 | { CC"udi_mgmt", &udi_mgmt_meta_info }, 39 | // Shall always be terminated with the NULL entry. 40 | { NULL, NULL } 41 | }; 42 | 43 | -------------------------------------------------------------------------------- /__kcore/include/chipset/ibmPc/chipset.h: -------------------------------------------------------------------------------- 1 | #ifndef _CHIPSET_H 2 | #define _CHIPSET_H 3 | //IBM-PC 4 | 5 | #include 6 | 7 | #define CHIPSET_SHORT_STRING "IBM-PC" 8 | #define CHIPSET_LONG_STRING "IBM-PC compatible chipset" 9 | #define CHIPSET_PATH ibmPc 10 | 11 | #define CHIPSET_HAS_ACPI 12 | 13 | // The mask which would tie/untie the debug pipe to/from all output devices. 14 | #define CHIPSET_DEBUG_DEVICE_TERMINAL_MASK 0x1 15 | 16 | /* Shared bank is always generated for IBM-PC. If you are building a custom 17 | * kernel for a NUMA supporting PC compatible, and you do not want a shared bank 18 | * you can comment this out though. 19 | * 20 | * Do not comment this out on a NON-NUMA build. Shared bank MUST be generated on 21 | * NON-NUMA builds. There are preprocessor checks to enforce this at compile 22 | * time. 23 | * 24 | * You can choose not to generate shared bank on a NUMA build. This would mean 25 | * that any CPUs for which the kernel cannot determine NUMA affinity will be 26 | * silently ignored. 27 | **/ 28 | #define CHIPSET_NUMA_GENERATE_SHBANK 29 | 30 | #if __SCALING__ >= SCALING_CC_NUMA 31 | #define CHIPSET_NUMA___KSPACE_BANKID 32 32 | #define CHIPSET_NUMA_SHBANKID 31 33 | #else 34 | // On non-NUMA there will only be __kspace & shbank. Set __kspace to 1. 35 | #define CHIPSET_NUMA___KSPACE_BANKID 1 36 | #define CHIPSET_NUMA_SHBANKID 0 37 | #endif 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /__kcore/chipset/ibmPc/chipset_root_devices.cpp: -------------------------------------------------------------------------------- 1 | 2 | #define UDI_VERSION 0x101 3 | #define UDI_PHYSIO_VERSION 0x101 4 | #include 5 | #include 6 | #include "../../commonlibs/drivers/zrootdev.h" 7 | 8 | struct child_dev chipset_devs[] = { 9 | { 10 | 3, // childId 11 | 0, // enum_released 12 | "chipset", // identifier 13 | "root-dev3", // address_locator 14 | "zbz_root", // bus_type 15 | "chipset" // zbz_root_device_type 16 | } 17 | }; 18 | 19 | udi_ubit8_t chipset_getNRootDevices(void) 20 | { 21 | return sizeof(chipset_devs) / sizeof(*chipset_devs); 22 | } 23 | 24 | udi_boolean_t chipset_root_dev_to_enum_attrs( 25 | udi_ubit32_t index, udi_instance_attr_list_t *outattrs, 26 | udi_ubit32_t *outChildId) 27 | { 28 | const unsigned N_BASE_DEVS = zrootdev_get_n_base_devs(); 29 | const unsigned N_CHIPSET_DEVS = chipset_getNRootDevices(); 30 | 31 | if (index < N_BASE_DEVS) { return false; } 32 | 33 | index -= N_BASE_DEVS; 34 | 35 | if (index >= N_CHIPSET_DEVS) { return false; } 36 | 37 | zrootdev_child_dev_to_enum_attrs( 38 | &chipset_devs[index], outattrs, outChildId); 39 | 40 | return true; 41 | } 42 | 43 | void chipset_root_dev_mark_released(udi_ubit32_t childId) 44 | { 45 | const int N_CHIPSET_DEVS = chipset_getNRootDevices(); 46 | 47 | for (int i = 0; i < N_CHIPSET_DEVS; i++) 48 | { 49 | if (chipset_devs[i].childId == childId) { 50 | chipset_devs[i].enum_released = 1; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /__kcore/include/commonlibs/libacpi/srat.h: -------------------------------------------------------------------------------- 1 | #ifndef _ZBZ_LIB_ACPI_R_X_SRAT_H 2 | #define _ZBZ_LIB_ACPI_R_X_SRAT_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | #include "rxsdt.h" 6 | 7 | #define ACPI_SRAT_GET_TYPE(_addr) (*(ubit8 *)(_addr)) 8 | #define ACPI_SRAT_TYPE_CPU 0 9 | #define ACPI_SRAT_TYPE_MEM 1 10 | 11 | namespace acpiR 12 | { 13 | namespace srat 14 | { 15 | #ifdef __cplusplus 16 | struct sCpu; 17 | struct sMem; 18 | sCpu *getNextCpuEntry(acpiR::sSrat *s, void **const handle); 19 | sMem *getNextMemEntry(acpiR::sSrat *s, void **const handle); 20 | #endif 21 | 22 | #define ACPI_SRAT_CPU_FLAGS_ENABLED (1<<0) 23 | 24 | struct sCpu 25 | { 26 | ubit8 type; 27 | ubit8 length; 28 | // Domain 0-7. 29 | ubit8 domain0; 30 | ubit8 lapicId; 31 | ubit32 flags; 32 | // Domain 8-31 + Local SAPIC EID. 33 | ubit8 domain1; 34 | ubit8 localSapicEid; 35 | ubit8 reserved[4]; 36 | }; 37 | 38 | #define ACPI_SRAT_MEM_FLAGS_ENABLED (1<<0) 39 | #define ACPI_SRAT_MEM_FLAGS_HOTPLUG (1<<1) 40 | #define ACPI_SRAT_MEM_FLAGS_NONVOLATILE (1<<2) 41 | 42 | struct sMem 43 | { 44 | ubit8 type; 45 | ubit8 length; 46 | ubit16 domain0; 47 | ubit16 domain1; 48 | ubit16 reserved0; 49 | ubit32 baseLow; 50 | ubit32 baseHigh; 51 | ubit32 lengthLow; 52 | ubit32 lengthHigh; 53 | ubit32 reserved1; 54 | ubit32 flags; 55 | ubit8 reserved2[8]; 56 | }; 57 | } 58 | } 59 | 60 | #endif 61 | 62 | -------------------------------------------------------------------------------- /docs/processes.txt: -------------------------------------------------------------------------------- 1 | What does process spawning entail? 2 | 3 | 1. A syscall specifying where the process image data should come from. 4 | * A check to see if the parent process is authorized to create the process. 5 | 2. A check to see if the kernel can handle the process' image data. 6 | 3. A check to see if the process image can be properly loaded (exec libs). 7 | 4. A memory allocation of the process' process Stream. 8 | a. If the process is contained, it must inherit its address space. 9 | b. If not, it must have its new address space allocated by the kernel. 10 | 5. The writing of the process' memory image into its address space. 11 | * The reading of the process' entry address. 12 | 6. Inheritance of attributes from its parent (environment, exec domain, 13 | affinity, privilege escalation, creator user, etc) 14 | 7. The creation of its first thread. 15 | 8. The scheduling of its first thread. 16 | 17 | Need to change thread switching to take difference in process address space 18 | into account. 19 | 20 | Need to change the way virtual address spaces are stored. 21 | 22 | Need to make virtual address spaces directly a member of container processes. 23 | 24 | Need to create the new class hierarchy for processes. 25 | 26 | Process hierarchy: 27 | 28 | driverProcess 29 | process 30 | |-containedProcess 31 | | +-containedDriverProcess (inherits driverProcess) 32 | +-containerProcess 33 | |-distributaryProcess 34 | +-containerDriverProcess (inherits driverProcess) 35 | 36 | -------------------------------------------------------------------------------- /__kcore/include/chipset/chipset.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include CHIPSET_INCLUDE(chipset.h) 4 | 5 | 6 | /** EXPLANATION: 7 | * Ensure that CHIPSET_NUMA___KSPACE_BANKID is defined. The kernel cannot work 8 | * unless CHIPSET_NUMA___KSPACE_BANKID is defined. 9 | **/ 10 | #if !defined(CHIPSET_NUMA___KSPACE_BANKID) || CHIPSET_NUMA___KSPACE_BANKID <= 0 11 | #error "CHIPSET_NUMA___KSPACE_BANKID must be defined, and greater than 0." 12 | #endif 13 | 14 | #if __SCALING__ < SCALING_CC_NUMA 15 | /* For a non-NUMA build of the kernel, CHIPSET_NUMA_GENERATE_SHBANK must 16 | * be defined, because the kernel must generate a shared bank on a 17 | * non-NUMA build. 18 | **/ 19 | #ifndef CHIPSET_NUMA_GENERATE_SHBANK 20 | #error "CHIPSET_NUMA_GENERATE_SHBANK must be defined for a non-NUMA build." 21 | #endif 22 | #endif 23 | 24 | #ifdef CHIPSET_NUMA_GENERATE_SHBANK 25 | /* Several things to check if SHBANK is to be generated: 26 | * 27 | * * CHIPSET_NUMA_SHBANKID must be defined if shbank is to be generated. 28 | * * CHIPSET_NUMA_SHBANKID absolutely must not be the same as 29 | * CHIPSET_NUMA___KSPACE_BANKID. 30 | **/ 31 | #ifndef CHIPSET_NUMA_SHBANKID 32 | #error "If CHIPSET_NUMA_GENERATE_SHBANK is defined, CHIPSET_NUMA_SHBANKID must also be defined." 33 | #endif 34 | 35 | #if CHIPSET_NUMA_SHBANKID == CHIPSET_NUMA___KSPACE_BANKID 36 | #error "Shared bank ID *CANNOT* be the same as __kspace bank ID." 37 | #endif 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /__kcore/arch/i586/setjmp.S: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | ASM_GLOBAL_FUNCTION(longjmp) 6 | /* esp[0]=retEip, esp[1]=addr(jump_buf), esp[2]=retval. */ 7 | movl 4(%esp), %eax 8 | movl 8(%esp), %ebx 9 | movl 4(%eax), %esp 10 | 11 | /* EBX on stack = retval. */ 12 | pushl %ebx 13 | 14 | movl 8(%eax), %ebp 15 | movl 12(%eax), %ebx 16 | movl 16(%eax), %ecx 17 | movl 20(%eax), %edx 18 | movl 24(%eax), %esi 19 | movl 28(%eax), %edi 20 | 21 | /* Restore the old return EIP value onto the stack since it magically 22 | * gets trampled (I don't know either). FreeBSD does the same, so 23 | * there's apparently some reason for this random crap. 24 | */ 25 | movl (%eax), %eax 26 | movl %eax, 4(%esp) 27 | /* Move the retval into EAX */ 28 | popl %eax 29 | ret 30 | ASM_END_FUNCTION(longjmp) 31 | 32 | ASM_GLOBAL_FUNCTION(setjmp) 33 | /* esp[0]=returnAddr, esp[1]=address of jmp_buf */ 34 | movl 4(%esp), %eax 35 | 36 | /* Begin moving reg state into the jump buff. */ 37 | movl %esp, 4(%eax) 38 | movl %ebp, 8(%eax) 39 | 40 | pushl %edx 41 | 42 | /* esp[0]=edx, esp[1]=returnAddr, esp[2]=addr of jmp_buf */ 43 | movl 4(%esp), %edx 44 | movl %edx, (%eax) /* first member of jmp_buf = retEIP */ 45 | 46 | popl %edx 47 | 48 | /* esp[0]=returnEip, esp[1]=addr of jmp_buf. */ 49 | movl %ebx, 12(%eax) 50 | movl %ecx, 16(%eax) 51 | movl %edx, 20(%eax) 52 | movl %esi, 24(%eax) 53 | movl %edi, 28(%eax) 54 | xorl %eax, %eax 55 | ret 56 | ASM_END_FUNCTION(setjmp) 57 | 58 | -------------------------------------------------------------------------------- /__kcore/include/arch/x8632/io.h: -------------------------------------------------------------------------------- 1 | #ifndef _x86_32_IO_H 2 | #define _x86_32_IO_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | namespace io 7 | { 8 | inline ubit8 read8(ubit16 port); 9 | inline ubit16 read16(ubit16 port); 10 | inline ubit32 read32(ubit16 port); 11 | 12 | inline void write8(ubit16 port, ubit8 val); 13 | inline void write16(ubit16 port, ubit16 val); 14 | inline void write32(ubit16 port, ubit32 val); 15 | } 16 | 17 | 18 | /** Inline methods 19 | ****************************************************************************/ 20 | 21 | inline ubit8 io::read8(ubit16 port) 22 | { 23 | ubit8 ret; 24 | asm volatile( 25 | "inb %1,%0" 26 | :"=a"(ret) 27 | :"Nd"(port)); 28 | return ret; 29 | } 30 | 31 | inline ubit16 io::read16(ubit16 port) 32 | { 33 | ubit16 ret; 34 | asm volatile( 35 | "inw %1,%0" 36 | :"=a"(ret) 37 | :"Nd"(port)); 38 | return ret; 39 | } 40 | 41 | inline ubit32 io::read32(ubit16 port) 42 | { 43 | ubit32 ret; 44 | asm volatile( 45 | "inl %1,%0" 46 | :"=a"(ret) 47 | :"Nd"(port)); 48 | return ret; 49 | } 50 | 51 | inline void io::write8(ubit16 port, ubit8 val) 52 | { 53 | asm volatile("outb %0,%1" 54 | : 55 | :"a"(val), "Nd" (port)); 56 | } 57 | 58 | inline void io::write16(ubit16 port, ubit16 val) 59 | { 60 | asm volatile("outw %0,%1" 61 | : 62 | :"a"(val), "Nd" (port)); 63 | } 64 | 65 | inline void io::write32(ubit16 port, ubit32 val) 66 | { 67 | asm volatile("outl %0,%1" 68 | : 69 | :"a"(val), "Nd" (port)); 70 | } 71 | 72 | #endif 73 | 74 | -------------------------------------------------------------------------------- /__kcore/include/kernel/common/smpConfig.h: -------------------------------------------------------------------------------- 1 | #ifndef _SMP_CONFIG_H 2 | #define _SMP_CONFIG_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | #include <__kclasses/bitmap.h> 6 | #include 7 | 8 | /** EXPLANATION: 9 | * Every thread inherently has SMP config. SMP config is the bitmap of all the 10 | * CPUs on which this thread may run. Every time a thread is migrated to a new 11 | * CPU, that CPU's bit is set in the process's bitmap of CPUs on which the 12 | * process has run. The reason this is important is that it greatly optimizes 13 | * TLB shootdown: if we can determine which CPUs a process has run on, we can 14 | * avoid unnecessary TLB shootdown on CPUs it hasn't touched yet. The purpose 15 | * of the 'last' member is to keep track of the last CPU on which the task was 16 | * run: using this, we can avoid having to acquire the lock on the process's 17 | * BMP to set the CPU's bit every time a task is scheduled. 18 | * 19 | * A thread which is NUMA bound to a bank for scheduling is implicitly SMP 20 | * bound to the CPUs on that bank. When a thread's NUMA CPU config changes, 21 | * its SMP config inherently changes as well. That is, the kernel will set/unset 22 | * bits in the SMP config for each CPU in the bank, unless the required changes 23 | * are much finer grained. 24 | **/ 25 | 26 | struct sSmpConfig 27 | { 28 | Bitmap cpus; 29 | // Id of the CPU to which this task was last scheduled. 30 | cpu_t last; 31 | uarch_t flags; 32 | }; 33 | 34 | #endif 35 | 36 | -------------------------------------------------------------------------------- /__kcore/kernel/common/memoryTrib/recurse-map.txt: -------------------------------------------------------------------------------- 1 | // Recursion trace for Kernel Vaddrspace's releasePages(). 2 | | 3 | |- __kprocess.vaddrSpaceStream.VSwamp[LOCKED]::releasePages() 4 | | |- [ENTRY] getNewSwampNode() 5 | | | |- __kprocess.vaddrSpaceStream.vswampC.swampNodeList[LOCKED]::addEntry() 6 | | | | |- memoryTrib[REENTRY-1]::rawMemAlloc() 7 | | | | | |- __kprocess.vaddrSpaceStream.VSwamp[RECURSE-1]::getPages() 8 | | | | | +- __kprocess.vaddrSpaceStream.VSwamp[DECURSE-1] 9 | | | | +- memoryTrib[LEAVE-1] 10 | | | +-__kprocess.vaddrSpaceStream.vswampC.swampNodeList[UNLOCKED] 11 | | +- [EXIT] 12 | +- __kprocess.vaddrSpaceStream.VSwamp[UNLOCKED]::releasePages() 13 | 14 | // Recursion trace for Memory Trib's rawMemFree(). 15 | | 16 | |- memoryTrib[ENTRY]::rawMemFree() 17 | | |- __kprocess.vaddrSpaceStream.VSwamp[LOCKED]::releasePages() 18 | | | |- [ENTRY] getNewSwampNode() 19 | | | | |- __kprocess.vaddrSpaceStream.vswampC.swampNodeList[LOCKED]::addEntry() 20 | | | | | |- memoryTrib[REENTRY-1]::rawMemAlloc() 21 | | | | | | |- __kprocess.vaddrSpaceStream.VSwamp[RECURSE-1]::getPages() 22 | | | | | | +- __kprocess.vaddrSpaceStream.VSwamp[DECURSE-1] 23 | | | | | +- memoryTrib[LEAVE-1] 24 | | | | +-__kprocess.vaddrSpaceStream.vswampC.swampNodeList[UNLOCKED] 25 | | | +- [EXIT] 26 | | +- __kprocess.vaddrSpaceStream.VSwamp[UNLOCKED]::releasePages() 27 | +- [EXIT] 28 | 29 | As long as rawMemAlloc() and rawMemFree() do not lock off the Memory Tributary 30 | object in a non-recursion friendly manner, this recursion domain is safe. 31 | 32 | -------------------------------------------------------------------------------- /__kcore/kernel/common/panic.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include <__kstdlib/__ktypes.h> 4 | #include <__kclasses/debugPipe.h> 5 | #include 6 | 7 | void panic(error_t err, utf8Char *str) 8 | { 9 | switch (err) 10 | { 11 | case ERROR_MEMORY_NOMEM_PHYSICAL: 12 | printf(FATAL"Kernel panic: ERROR_MEMORY_NOMEM_PHYSICAL.\n"); 13 | break; 14 | case ERROR_MEMORY_NOMEM_VIRTUAL: 15 | printf(FATAL"Kernel panic: ERROR_MEMORY_NOMEM_VIRTUAL.\n"); 16 | break; 17 | case ERROR_MEMORY_NOMEM: 18 | printf(FATAL"Kernel panic: ERROR_MEMORY_NOMEM.\n"); 19 | break; 20 | case ERROR_INVALID_ARG_VAL: 21 | printf(FATAL"Kernel panic: ERROR_INVALIC_ARG_VAL.\n"); 22 | break; 23 | case ERROR_INVALID_ARG: 24 | printf(FATAL"Kernel panic: ERROR_INVALID_ARG.\n"); 25 | break; 26 | case ERROR_MEMORY_NOMEM_IN_CONSTRUCTOR: 27 | printf(FATAL"Kernel panic: " 28 | "ERROR_MEMORY_NOMEM_IN_CONSTRUCTOR.\n"); 29 | 30 | break; 31 | case ERROR_SUCCESS: 32 | printf(FATAL"Kernel panic: ERROR_SUCCESS (...?).\n"); 33 | break; 34 | default: 35 | printf(FATAL"Kernel panic: error is %d\n", err); 36 | break; 37 | }; 38 | 39 | if (str != NULL) { 40 | printf(str); 41 | }; 42 | 43 | for (;FOREVER;) 44 | { 45 | cpuControl::disableInterrupts(); 46 | cpuControl::halt(); 47 | }; 48 | } 49 | 50 | void panic(utf8Char *str, error_t err) 51 | { 52 | panic(err, str); 53 | } 54 | 55 | void panic(void) 56 | { 57 | for (;FOREVER;) 58 | { 59 | cpuControl::disableInterrupts(); 60 | cpuControl::halt(); 61 | }; 62 | } 63 | -------------------------------------------------------------------------------- /__kcore/__kstdlib/__klibc/malloc.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include <__kstdlib/__kclib/string.h> 4 | #include <__kstdlib/__kclib/stdlib.h> 5 | #include <__kstdlib/__kcxxlib/memory> 6 | #include <__kclasses/memReservoir.h> 7 | #include <__kclasses/debugPipe.h> 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | void pointer::vmemUnmapAndFree( 14 | void *vaddr, uarch_t nPages, status_t nMapped, 15 | VaddrSpaceStream *vasStream 16 | ) 17 | { 18 | if (vasStream == NULL) 19 | { 20 | vasStream = cpuTrib.getCurrentCpuStream()->taskStream 21 | .getCurrentThread()->parent->getVaddrSpaceStream(); 22 | }; 23 | 24 | if (nMapped > 0) 25 | { 26 | paddr_t p; 27 | uarch_t f; 28 | 29 | walkerPageRanger::unmap( 30 | &vasStream->vaddrSpace, vaddr, &p, nMapped, &f); 31 | }; 32 | 33 | vasStream->releasePages(vaddr, nPages); 34 | } 35 | 36 | void pointer::streamFree(void *vaddr, MemoryStream *memStream) 37 | { 38 | if (memStream == NULL) 39 | { 40 | memStream = &cpuTrib.getCurrentCpuStream()->taskStream 41 | .getCurrentThread()->parent->memoryStream; 42 | }; 43 | 44 | memStream->memFree(vaddr); 45 | } 46 | 47 | void *malloc(uarch_t nBytes) 48 | { 49 | return memReservoir.allocate(nBytes); 50 | } 51 | 52 | void *calloc(uarch_t objSize, uarch_t nObjs) 53 | { 54 | return memReservoir.allocate(objSize * nObjs); 55 | } 56 | 57 | void free(void *mem) 58 | { 59 | if (mem == NULL) { return; }; 60 | memReservoir.free(mem); 61 | } 62 | 63 | -------------------------------------------------------------------------------- /__kcore/include/chipset/zkcm/device.h: -------------------------------------------------------------------------------- 1 | #ifndef _ZKCM_DEVICE_H 2 | #define _ZKCM_DEVICE_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | #include <__kstdlib/__kclib/string8.h> 6 | 7 | // Chipset device classes should instantiate one of these per device object. 8 | class ZkcmDevice 9 | { 10 | public: 11 | inline ZkcmDevice( 12 | ubit32 childId, 13 | utf8Char *shortName, utf8Char *longName, 14 | utf8Char *vendorName, utf8Char *vendorContact); 15 | 16 | public: 17 | // Uniquely identifies this child to its parent driver. 18 | ubit32 childId; 19 | ubit32 nChildren; 20 | 21 | utf8Char shortName[64]; 22 | utf8Char longName[256]; 23 | 24 | utf8Char vendorName[256]; 25 | utf8Char vendorContact[256]; 26 | }; 27 | 28 | // Inherited by all kernel device API classes. 29 | class ZkcmDeviceBase 30 | { 31 | public: 32 | ZkcmDevice *getBaseDevice(void) { return device; } 33 | 34 | protected: 35 | ZkcmDeviceBase(ZkcmDevice *device) 36 | : 37 | device(device) 38 | {} 39 | 40 | private: 41 | ZkcmDevice *device; 42 | }; 43 | 44 | /** Inline methods. 45 | ******************************************************************************/ 46 | 47 | ZkcmDevice::ZkcmDevice( 48 | ubit32 childId, 49 | utf8Char *shortName, utf8Char *longName, 50 | utf8Char *vendorName, utf8Char *vendorContact 51 | ) 52 | : 53 | childId(childId) 54 | { 55 | strcpy8(ZkcmDevice::shortName, shortName); 56 | strcpy8(ZkcmDevice::longName, longName); 57 | strcpy8(ZkcmDevice::vendorName, vendorName); 58 | strcpy8(ZkcmDevice::vendorContact, vendorContact); 59 | } 60 | 61 | #endif 62 | 63 | -------------------------------------------------------------------------------- /programs/zudi/zudiindex/zudiindex-addall: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | zudiindex_bin="zudiindex" 6 | wildcard="" 7 | propsDir="." 8 | indexDir="" 9 | usageMessage="`echo \"$0 - [search-directory] [index-path]\"`" 10 | 11 | if [ -n "${ZUDIINDEX_BIN}" ]; then 12 | zudiindex_bin=${ZUDIINDEX_BIN} 13 | fi 14 | 15 | case "$1" in 16 | "-drivers") wildcard='*.udidprops';; 17 | "-metas") wildcard='*.udimprops';; 18 | "--help") echo "$usageMessage"; exit 0;; 19 | *) echo "$usageMessage"; exit 1;; 20 | esac 21 | 22 | if [ -n "$2" ]; then propsDir="$2"; fi 23 | # We can leave $indexDir as an empty string because zudiindex uses a default 24 | # index path if none is specified, and this is desirable. 25 | if [ -n "$3" ]; then indexDir="$3"; fi 26 | 27 | # Expand the wildcard search into a result string. 28 | files="$(echo $propsDir/$wildcard)" 29 | 30 | # If there are no udiprops file matches in the propsDir, exit. 31 | if [ "$files" = "$propsDir/$wildcard" ]; 32 | then exit 0; 33 | fi 34 | 35 | if [ "$1" = "-drivers" ] 36 | then 37 | for i in $files; do 38 | if [ -n "$indexDir" ] 39 | then ${zudiindex_bin} -a "$i" -txt -b drivers --ignore-invalid-basepath -i "$indexDir" 40 | else ${zudiindex_bin} -a "$i" -txt -b drivers --ignore-invalid-basepath 41 | fi 42 | done 43 | else 44 | for i in $files; do 45 | if [ -n "$indexDir" ] 46 | then ${zudiindex_bin} -a "$i" -txt -meta -b metas --ignore-invalid-basepath -i "$indexDir" 47 | else ${zudiindex_bin} -a "$i" -txt -meta -b metas --ignore-invalid-basepath 48 | fi 49 | done 50 | fi 51 | 52 | exit 0; 53 | 54 | -------------------------------------------------------------------------------- /__kcore/include/__kclasses/resizeableIdArray.h: -------------------------------------------------------------------------------- 1 | #ifndef _RESIZEABLE_ID_ARRAY 2 | #define _RESIZEABLE_ID_ARRAY 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | #include <__kclasses/resizeableArray.h> 6 | #include <__kclasses/wrapAroundCounter.h> 7 | 8 | /** EXPLANATION: 9 | * This is a convenience class which enables you to maintain a resizeable array 10 | * of elements coupled with the ability to maintain unique IDs for each index 11 | * and not trample them. 12 | **/ 13 | template 14 | class ResizeableIdArray 15 | : public ResizeableArray 16 | { 17 | public: 18 | ResizeableIdArray(uarch_t maxVal) 19 | : ResizeableArray(), 20 | idCounter(maxVal) 21 | {} 22 | 23 | ~ResizeableIdArray(void) {} 24 | 25 | error_t initialize(void) 26 | { 27 | error_t ret; 28 | ret = ResizeableArray::initialize(); 29 | if (ret != ERROR_SUCCESS) { return ret; }; 30 | ret = idCounter.initialize(); 31 | if (ret != ERROR_SUCCESS) { return ret; }; 32 | return ERROR_SUCCESS; 33 | } 34 | 35 | sarch_t unlocked_getNextValue(ubit8 secondTry=0); 36 | 37 | private: 38 | sarch_t getNextValue(T *arr, ubit8 secondTry=0) 39 | { 40 | return ERROR_UNIMPLEMENTED; 41 | } 42 | 43 | public: 44 | WrapAroundCounter idCounter; 45 | }; 46 | 47 | 48 | /** Inline methods: 49 | ******************************************************************************/ 50 | 51 | template 52 | sarch_t ResizeableIdArray::unlocked_getNextValue(ubit8 secondTry) 53 | { 54 | return idCounter.getNextValue( 55 | ResizeableArray::s.rsrc.array, 56 | secondTry); 57 | } 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /__kcore/kernel/common/__kclassInstances.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include <__kclasses/debugPipe.h> 3 | #include <__kclasses/memReservoir.h> 4 | #include <__kclasses/cachePool.h> 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | /** EXPLANATION: 18 | * These are the instances of the kernel classes which don't require any 19 | * arch-specific information to be passed to their constructors. As a rule, 20 | * most of the kernel classes will be this way, with only one or two requiring 21 | * arch-specific construction information. 22 | * 23 | * The order in which they are placed here does not matter. Of course, 24 | * initializing in order is preferable. 25 | **/ 26 | TimerTrib timerTrib; 27 | InterruptTrib interruptTrib; 28 | MemoryTrib memoryTrib; 29 | DebugTrib debugTrib; 30 | MemReservoir memReservoir(&processTrib.__kgetStream()->memoryStream); 31 | CpuTrib cpuTrib; 32 | DebugPipe __kdebug; 33 | TaskTrib taskTrib; 34 | CachePool cachePool; 35 | ExecTrib execTrib; 36 | VfsTrib vfsTrib; 37 | DistributaryTrib distributaryTrib; 38 | Floodplainn floodplainn; 39 | -------------------------------------------------------------------------------- /m4/scaling-opts.m4: -------------------------------------------------------------------------------- 1 | AC_ARG_ENABLE([scaling], 2 | [AS_HELP_STRING([--enable-scaling=@<:@up|smp|numa@:>@], 3 | [Select processor scaling mode @<:@default=numa@:>@])], 4 | [AS_CASE(["$enableval"], 5 | [uniprocessor|up|no], 6 | [ZSCALING="up"], 7 | [multiprocessor|multiprocessing|smp|yes], 8 | [ZSCALING="smp"], 9 | [numa|ccnuma], 10 | [ZSCALING="numa"], 11 | [*], [AC_MSG_ERROR([Invalid scaling mode: $enableval])])], 12 | [ 13 | ZSCALING="numa" 14 | ] 15 | ) 16 | 17 | # Set the appropriate define based on ZSCALING 18 | AS_CASE(["$ZSCALING"], 19 | [up], 20 | [AC_DEFINE([CONFIG_UNI_PROCESSOR], [1], [Uniprocessor scaling mode])], 21 | [smp], 22 | [AC_DEFINE([CONFIG_SMP], [1], [SMP scaling mode])], 23 | [numa|*], 24 | [AC_DEFINE([CONFIG_CC_NUMA], [1], [CC-NUMA scaling mode])] 25 | ) 26 | AC_SUBST([ZSCALING]) 27 | 28 | # Maximum number of CPUs configuration 29 | AC_ARG_WITH([max-ncpus], 30 | [AS_HELP_STRING([--with-max-ncpus=@<:@integer@:>@], 31 | [Maximum number of CPUs supported @<:@default=256 or 1 for uniprocessor@:>@])], 32 | [ZMAX_NCPUS="$withval"], 33 | [ZMAX_NCPUS="256"] 34 | ) 35 | 36 | # Force ZMAX_NCPUS to 1 for uniprocessor builds 37 | AS_IF([test "$ZSCALING" = "up"], [ZMAX_NCPUS="1"]) 38 | # Validate ZMAX_NCPUS is a positive integer 39 | ZBZ_VALIDATE_POSITIVE_NONZERO_INTEGER([ZMAX_NCPUS]) 40 | # Define CONFIG_MAX_NCPUS 41 | AC_DEFINE_UNQUOTED([CONFIG_MAX_NCPUS], [$ZMAX_NCPUS], [Maximum number of CPUs supported]) 42 | AC_SUBST([ZMAX_NCPUS]) 43 | -------------------------------------------------------------------------------- /__kcore/include/chipset/zkcm/smpMap.h: -------------------------------------------------------------------------------- 1 | #ifndef _CHIPSET_CPU_MAP_H 2 | #define _CHIPSET_CPU_MAP_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | #include 6 | 7 | 8 | /** EXPLANATION: 9 | * Every chipset which has SMP or NUMA physical configuration SHALL provide a 10 | * CPU map. This map MUST contain an entry for every physical CPU present at 11 | * boot, regardless of whether or not it's a "bad" CPU (actually, especially if 12 | * it's a bad CPU), or if it's offline at boot. 13 | * 14 | * For CPU hotplug, there need not be an entry for an emplty slot which will 15 | * have a CPU plugged in at runtime. But as long as a CPU is expected to 16 | * plugged in when the kernel is booting, this CPU must be in the CPU map. 17 | * 18 | * In other words, this is a fully detailed map returned by the chipset code 19 | * which will tell the kernel how to handle any CPU at boot. 20 | * 21 | * At boot, the kernel will generate CPU Streams for all CPUs whose entries 22 | * mark them as "good" (i.e., not BADCPU) and "online". 23 | * 24 | * At runtime, if a new CPU is detected by some driver of sorts, the kernel will 25 | * use the information returned from the API that enumerated the hotplug CPU 26 | * to decide how to handle it. 27 | **/ 28 | 29 | #define ZKCM_SMPMAP_FLAGS_BADCPU (1<<0) 30 | #define ZKCM_SMPMAP_FLAGS_BSP (1<<1) 31 | 32 | struct sZkcmMemMapEntry 33 | { 34 | cpu_t cpuId; 35 | ubit32 cpuAcpiId; 36 | uarch_t flags; 37 | }; 38 | 39 | struct sZkcmSmpMap 40 | { 41 | uarch_t nEntries; 42 | struct sZkcmMemMapEntry *entries; 43 | }; 44 | 45 | #endif 46 | 47 | -------------------------------------------------------------------------------- /__kcore/include/__kstdlib/callback.h: -------------------------------------------------------------------------------- 1 | #ifndef _CALLBACK_H 2 | #define _CALLBACK_H 3 | 4 | #include 5 | 6 | /** EXPLANATION: 7 | * Simple callback continuation class framework. This enables us to create 8 | * polymorphic continuations. Each different sequence that requires a continuation 9 | * can create a custom derived class to suit its needs. 10 | * 11 | * The only disadvantage is that it requires dynamic memory allocation for 12 | * every continuation. But once we get past that, it's very clean. 13 | * 14 | * When the heap is in guardpaged mode however, this may end up exhausting 15 | * it very quickly. This problem can be alleviated a little by using a custom 16 | * slam cache for __kCallback objects specifically. 17 | **/ 18 | 19 | // Polymorphism is great. 20 | class Callback 21 | { 22 | public: 23 | virtual ~Callback(void) {}; 24 | virtual void operator()(MessageStream::sHeader *message)=0; 25 | }; 26 | 27 | template 28 | class _Callback 29 | : public Callback 30 | { 31 | protected: 32 | _Callback(T *fn) 33 | : 34 | function(fn) 35 | {} 36 | 37 | public: 38 | virtual void operator()(MessageStream::sHeader *message)=0; 39 | 40 | virtual ~_Callback(void) { function = NULL; } 41 | 42 | protected: 43 | T *function; 44 | }; 45 | 46 | typedef void (__kcbFn)(MessageStream::sHeader *msg); 47 | class __kCallback 48 | : public _Callback<__kcbFn> 49 | { 50 | public: 51 | __kCallback(__kcbFn *fn) : _Callback<__kcbFn>(fn) {} 52 | 53 | virtual void operator()(MessageStream::sHeader *message) 54 | { function(message); } 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /docs/freestanding-libstdcxx-libsupcxx.md: -------------------------------------------------------------------------------- 1 | # Freestanding libstdc++ and libsupc++: 2 | 3 | It's simple really. But still no freestanding crt*.o (technically mightn't be possible). Working on that now. 4 | 5 | ## Command summary: 6 | 7 | ```sh 8 | $ ../gcc-14.2.0/configure --target=i586-elf --disable-nls --enable-languages=c,c++ --prefix=$(HOME)/bin/i586-elf --without-headers --with-static-standard-libraries --disable-hosted-libstdcxx --enable-libstdcxx-static-eh-pool --with-libstdcxx-eh-pool-obj-count=64 9 | $ make -j8 all-gcc all-target-libgcc all-target-libstdc++-v3 10 | ``` 11 | 12 | ## Flag explanations: 13 | 14 | ### Definitely useful/important: 15 | 16 | * --with-static-standard-libraries: Tells GCC's configure to build libgcc and libstdc++ as static libs (*.a, *.la). 17 | * --disable-hosted-libstdcxx: This is the magic that tells GCC's build system to build for a freestanding target. 18 | * --enable-libstdcxx-static-eh-pool: This is useful because it makes libsupc++ manage a static pool of memory which it uses for holding exceptions if malloc() fails. I.e: it *should* enable your kernel to use exceptions early on in the boot process, before the memory manager has been initialized. 19 | * --with-libstdcxx-eh-pool-obj-count=64: This tells libsupc++ how much static memory to allocate for early exception handling. 20 | 21 | ### Other interesting and potentially useful flags: 22 | 23 | * --disable-tls 24 | * --disable-linux-futex 25 | * --disable-libstdcxx-threads 26 | * --disable-libstdcxx-filesystem-ts 27 | * --disable-libstdcxx-backtrace 28 | * --enable-libstdcxx-static-eh-pool 29 | * --enable-version-specific-runtime-libs 30 | -------------------------------------------------------------------------------- /include/__ksymbols.h: -------------------------------------------------------------------------------- 1 | #ifndef ___KSYMBOLS_H 2 | #define ___KSYMBOLS_H 3 | 4 | #include <__kstdlib/__ktypes.h> 5 | 6 | /* These are the symbols defined in the linker script which delineate the 7 | * kernel's ELF sections. 8 | **/ 9 | 10 | // Don't let C code see the 'extern "C"' used for C++. 11 | #ifdef __cplusplus 12 | #define EXTERN extern "C" 13 | #else 14 | #define EXTERN extern 15 | #endif 16 | 17 | EXTERN uarch_t __kstart, __kend, __kphysStart, __kphysEnd; 18 | EXTERN uarch_t __kvirtStart, __kvirtEnd; 19 | EXTERN uarch_t __korientationStart, __korientationEnd; 20 | EXTERN uarch_t __ksetupStart, __ksetupEnd; 21 | EXTERN uarch_t __kctorStart, __kctorEnd, __kdtorStart, __kdtorEnd, 22 | __kinitCtorStart, __kinitCtorEnd, 23 | __kfiniDtorStart, __kfiniDtorEnd; 24 | EXTERN uarch_t __kinitArrayCtorStart, __kinitArrayCtorEnd; 25 | EXTERN uarch_t __korientationStart, __korientationEnd; 26 | EXTERN uarch_t __kinitstart, __kinitEnd, __kfiniStart, __kfiniEnd; 27 | EXTERN uarch_t __ktextStart, __ktextEnd; 28 | EXTERN uarch_t __kdataStart, __kdataEnd; 29 | EXTERN uarch_t __kbssStart, __kbssEnd; 30 | EXTERN uarch_t __kcpuPowerOnTextStart, __kcpuPowerOnTextEnd; 31 | EXTERN uarch_t __kcpuPowerOnDataStart, __kcpuPowerOnDataEnd; 32 | EXTERN ubit8 __kudi_index_drivers, 33 | __kudi_index_data, 34 | __kudi_index_devices, 35 | __kudi_index_ranks, 36 | __kudi_index_provisions, 37 | __kudi_index_strings, 38 | __kudi_index_drivers_end, 39 | __kudi_index_data_end, 40 | __kudi_index_devices_end, 41 | __kudi_index_ranks_end, 42 | __kudi_index_provisions_end, 43 | __kudi_index_strings_end; 44 | 45 | #undef EXTERN 46 | 47 | #endif 48 | 49 | -------------------------------------------------------------------------------- /__kcore/Makefile.am: -------------------------------------------------------------------------------- 1 | # __kcxxabi will soon be transformed into a compiler specific directory which 2 | # will auto-build the appropriate C++ runtime for the current compiler. 3 | 4 | SUBDIRS = __kstdlib __kthreads platform chipset firmware arch \ 5 | kernel commonlibs __kclasses 6 | 7 | BUILT_SOURCES = $(ZUDI_INDEX_FILES) zudi_index_updated 8 | 9 | noinst_LIBRARIES=lib__kcore.a 10 | lib__kcore_a_DEPENDENCIES=zudi_index_updated 11 | lib__kcore_a_SOURCES=udi_index.S 12 | 13 | noinst_DATA=$(ZUDI_INDEX_FILES) 14 | ZUDI_INDEX_FILES = drivers.zudi-index data.zudi-index provisions.zudi-index \ 15 | devices.zudi-index ranks.zudi-index strings.zudi-index 16 | 17 | ZUDIINDEX_BUILD_DIR ::= $(top_builddir)/build/zudi/zudiindex 18 | ZUDIINDEX ::= $(ZUDIINDEX_BUILD_DIR)/zudiindex 19 | ZUDIINDEX_ADDALL ::= $(ZUDIINDEX_BUILD_DIR)/zudiindex-addall 20 | $(ZUDI_INDEX_FILES): $(ZUDIINDEX) $(ZUDIINDEX_ADDALL) 21 | zudi_index_updated: $(ZUDI_INDEX_FILES) 22 | @echo "Creating driver index." 23 | $(ZUDIINDEX) -c le -i . 24 | @echo "Adding chipset specific drivers to index." 25 | ZUDIINDEX_BIN=${ZUDIINDEX} $(ZUDIINDEX_ADDALL) -drivers $(srcdir)/chipset/$(ZCHIPSET) . 26 | @echo "Adding chipset specific metalanguages to index." 27 | ZUDIINDEX_BIN=${ZUDIINDEX} $(ZUDIINDEX_ADDALL) -metas $(srcdir)/chipset/$(ZCHIPSET) . 28 | @echo "Adding common metalanguages to index." 29 | ZUDIINDEX_BIN=${ZUDIINDEX} $(ZUDIINDEX_ADDALL) -metas $(srcdir)/commonlibs/metalanguages . 30 | @echo "Adding common drivers to index." 31 | ZUDIINDEX_BIN=${ZUDIINDEX} $(ZUDIINDEX_ADDALL) -drivers $(srcdir)/commonlibs/drivers . 32 | $(TOUCH) zudi_index_updated 33 | 34 | CLEANFILES = $(ZUDI_INDEX_FILES) zudi_index_updated 35 | -------------------------------------------------------------------------------- /__kcore/kernel/common/vfsTrib/vfsTrib_fileDesc.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include <__kstdlib/__kclib/string8.h> 3 | #include <__kstdlib/__kcxxlib/new> 4 | #include 5 | #include 6 | 7 | 8 | vfsFileC::vfsFileC(void) 9 | { 10 | name = NULL; 11 | parent = NULL; 12 | next = NULL; 13 | desc = NULL; 14 | 15 | type = VFSDESC_TYPE_FILE; 16 | flags = 0; 17 | refCount = 0; 18 | } 19 | 20 | vfsFileC::vfsFileC(vfsFileINode *inode) 21 | { 22 | name = NULL; 23 | parent = NULL; 24 | next = NULL; 25 | desc = inode; 26 | 27 | type = VFSDESC_TYPE_FILE; 28 | flags = 0; 29 | refCount = 0; 30 | } 31 | 32 | error_t vfsFileC::initialize( 33 | utf8Char *fileName, 34 | ubit32 inodeLow, ubit32 inodeHigh, uarch_t fileSize 35 | ) 36 | { 37 | ubit32 nameLen; 38 | error_t ret; 39 | 40 | // Allocate space for name. 41 | nameLen = strlen8(fileName); 42 | if (nameLen > VFSFILE_NAME_MAX_NCHARS) { 43 | nameLen = VFSFILE_NAME_MAX_NCHARS; 44 | }; 45 | 46 | name = new utf8Char[nameLen + 1]; 47 | if (name == NULL) { 48 | return ERROR_MEMORY_NOMEM; 49 | }; 50 | 51 | strncpy8(name, fileName, nameLen); 52 | name[nameLen] = '\0'; 53 | 54 | // Allocate inode. 55 | if (desc == NULL) 56 | { 57 | desc = new vfsFileINode(inodeHigh, inodeLow, fileSize); 58 | if (desc == NULL) { 59 | return ERROR_MEMORY_NOMEM; 60 | }; 61 | }; 62 | 63 | ret = desc->initialize(); 64 | if (ret == ERROR_SUCCESS) { 65 | return ERROR_SUCCESS; 66 | }; 67 | 68 | delete desc; 69 | desc = NULL; 70 | return ret; 71 | } 72 | 73 | vfsFileC::~vfsFileC(void) 74 | { 75 | delete name; 76 | if (desc != NULL && desc->refCount <= 0) { 77 | delete desc; 78 | }; 79 | } 80 | 81 | -------------------------------------------------------------------------------- /__kcore/include/chipset/zkcm/picDevice.h: -------------------------------------------------------------------------------- 1 | #ifndef _ZKCM_PIC_DEVICE_H 2 | #define _ZKCM_PIC_DEVICE_H 3 | 4 | #include 5 | #include 6 | #include <__kstdlib/__ktypes.h> 7 | 8 | class ZkcmPicDevice 9 | : 10 | public ZkcmDeviceBase 11 | { 12 | public: 13 | ZkcmPicDevice(ubit16 nPins, ZkcmDevice *device) 14 | : 15 | ZkcmDeviceBase(device), 16 | nPins(nPins), irqPinList(NULL), 17 | __kpinBase(0) 18 | {} 19 | 20 | virtual ~ZkcmPicDevice(void) {} 21 | 22 | public: 23 | virtual error_t initialize(void)=0; 24 | virtual error_t shutdown(void)=0; 25 | virtual error_t suspend(void)=0; 26 | virtual error_t restore(void)=0; 27 | 28 | virtual ubit16 get__kpinBase(void) 29 | { 30 | return __kpinBase; 31 | } 32 | 33 | virtual error_t identifyActiveIrq( 34 | cpu_t cpu, uarch_t vector, ubit16 *__kpin, ubit8 *triggerMode)=0; 35 | 36 | virtual status_t getIrqStatus( 37 | uarch_t __kpin, cpu_t *cpu, uarch_t *vector, 38 | ubit8 *triggerMode, ubit8 *polarity)=0; 39 | 40 | virtual status_t setIrqStatus( 41 | uarch_t __kpin, cpu_t cpu, uarch_t vector, ubit8 enabled)=0; 42 | 43 | virtual void maskIrq(ubit16 __kpin)=0; 44 | virtual void unmaskIrq(ubit16 __kpin)=0; 45 | virtual void maskAll(void)=0; 46 | virtual void unmaskAll(void)=0; 47 | virtual sarch_t irqIsEnabled(ubit16 __kpin)=0; 48 | 49 | virtual void maskIrqsByPriority( 50 | ubit16 __kpin, cpu_t cpuId, uarch_t *mask0)=0; 51 | 52 | virtual void unmaskIrqsByPriority( 53 | ubit16 __kpin, cpu_t cpuId, uarch_t mask0)=0; 54 | 55 | virtual void sendEoi(ubit16 __kpin)=0; 56 | 57 | public: 58 | ubit16 nPins; 59 | sZkcmIrqPin *irqPinList; 60 | ubit16 __kpinBase; 61 | }; 62 | 63 | #endif 64 | 65 | --------------------------------------------------------------------------------