├── .gitignore ├── .vscode ├── c_cpp_properties.json └── settings.json ├── LICENSE ├── README.md ├── makefile ├── meta ├── binutils_patches │ ├── Makefile.am.patch │ ├── config.bfd.patch │ ├── config.sub.patch │ ├── configure.tgt.patch │ ├── elf_i386_saturn.sh │ ├── elf_x86_64_saturn.sh │ └── gas_configure.tgt.patch ├── bochs-runner.sh ├── bochsrc ├── build_ld.sh ├── build_libcxx.sh ├── cache.cmake ├── debug.sh ├── download_llvm.sh ├── saturn-layout ├── toolchain-saturn.cmake └── vbox-runner.sh ├── saturn.org ├── saturn_logo.png ├── saturn_logo_cropped.png ├── screenshots ├── Advanced grid and databinding.PNG ├── Capcom.PNG ├── Dsky.PNG ├── Grid and Labels.PNG ├── Transcript.PNG ├── aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.PNG ├── apollo tiles.PNG ├── dsky and capcom.PNG ├── first actual graphics driver.PNG ├── improved text layout.PNG ├── libwindows first drawText implementation.PNG ├── multi-size text.PNG ├── multicolour text.PNG ├── parrot.PNG └── saturn-logo-small.png ├── src ├── applications │ ├── capcom │ │ ├── capcom.h │ │ ├── commands.cpp │ │ ├── commands.h │ │ ├── layout.h │ │ └── main.cpp │ ├── dsky │ │ ├── dsky.h │ │ ├── layout.h │ │ └── main.cpp │ ├── makefile │ ├── taskbar │ │ ├── layout.h │ │ ├── main.cpp │ │ └── taskbar.h │ ├── test │ │ └── main.cpp │ └── transcript │ │ ├── layout.h │ │ ├── main.cpp │ │ └── transcript.h ├── grub.cfg ├── kernel │ ├── arch │ │ ├── i386 │ │ │ ├── boot.s │ │ │ ├── cpu │ │ │ │ ├── acpi.cpp │ │ │ │ ├── acpi.h │ │ │ │ ├── ap_trampoline.s │ │ │ │ ├── apic.cpp │ │ │ │ ├── apic.h │ │ │ │ ├── change_process.s │ │ │ │ ├── cpu.cpp │ │ │ │ ├── cpu.h │ │ │ │ ├── initialize.cpp │ │ │ │ ├── initialize.h │ │ │ │ ├── initialize_sse.s │ │ │ │ ├── msr.cpp │ │ │ │ ├── msr.h │ │ │ │ ├── pic.cpp │ │ │ │ ├── pic.h │ │ │ │ ├── rtc.cpp │ │ │ │ ├── rtc.h │ │ │ │ ├── sse.h │ │ │ │ ├── stack_frames.h │ │ │ │ ├── tsc.cpp │ │ │ │ ├── tsc.h │ │ │ │ ├── tss.cpp │ │ │ │ └── tss.h │ │ │ ├── crti.s │ │ │ ├── crtn.s │ │ │ ├── gdt │ │ │ │ ├── gdt.cpp │ │ │ │ ├── gdt.h │ │ │ │ └── gdt_flush.s │ │ │ ├── idt │ │ │ │ ├── idt.cpp │ │ │ │ ├── idt.h │ │ │ │ ├── isr_stubs.s │ │ │ │ └── loadIDT.s │ │ │ ├── linker.ld │ │ │ ├── memory │ │ │ │ ├── block_allocator.h │ │ │ │ ├── guard.cpp │ │ │ │ ├── guard.h │ │ │ │ ├── physical_memory_manager.cpp │ │ │ │ ├── physical_memory_manager.h │ │ │ │ ├── virtual_memory_manager.cpp │ │ │ │ └── virtual_memory_manager.h │ │ │ └── task_context.h │ │ └── x86_64 │ │ │ ├── cpu │ │ │ ├── acpi.cpp │ │ │ ├── acpi.h │ │ │ ├── apic.cpp │ │ │ ├── apic.h │ │ │ ├── create_trampoline.cpp │ │ │ ├── halt.cpp │ │ │ ├── halt.h │ │ │ ├── initialise_sse.s │ │ │ ├── initialize.cpp │ │ │ ├── initialize.h │ │ │ ├── metablocks.cpp │ │ │ ├── metablocks.h │ │ │ ├── msr.cpp │ │ │ ├── msr.h │ │ │ ├── pic.cpp │ │ │ ├── pic.h │ │ │ ├── timers │ │ │ │ ├── pit.cpp │ │ │ │ ├── pit.h │ │ │ │ ├── rtc.cpp │ │ │ │ ├── rtc.h │ │ │ │ ├── tsc.cpp │ │ │ │ └── tsc.h │ │ │ ├── trampoline.h │ │ │ ├── trampoline.s │ │ │ ├── tss.cpp │ │ │ └── tss.h │ │ │ ├── crti.s │ │ │ ├── crtn.s │ │ │ ├── gdt.cpp │ │ │ ├── gdt.h │ │ │ ├── idt │ │ │ ├── descriptor.cpp │ │ │ ├── descriptor.h │ │ │ ├── exception_stubs.s │ │ │ ├── exceptions.cpp │ │ │ ├── exceptions.h │ │ │ ├── irq_stubs.s │ │ │ ├── irqs.cpp │ │ │ └── irqs.h │ │ │ ├── linker.ld │ │ │ ├── memory │ │ │ ├── address_space.cpp │ │ │ ├── address_space.h │ │ │ ├── addresses.h │ │ │ ├── block_allocator.h │ │ │ ├── physical_memory_manager.cpp │ │ │ ├── physical_memory_manager.h │ │ │ ├── virtual_memory_manager.cpp │ │ │ └── virtual_memory_manager.h │ │ │ └── misc │ │ │ ├── avl_tree.h │ │ │ ├── kernel_initial_arguments.h │ │ │ ├── linked_list.h │ │ │ └── testing.h │ ├── director.cpp │ ├── director.h │ ├── elf.h │ ├── ipc.cpp │ ├── ipc.h │ ├── kernel.cpp │ ├── list.h │ ├── lock_impl.s │ ├── locks.h │ ├── log.cpp │ ├── log.h │ ├── make.config │ ├── permissions.cpp │ ├── permissions.h │ ├── pre_kernel.cpp │ ├── saturn.cpp │ ├── saturn_startup.s │ ├── scheduler.cpp │ ├── scheduler.h │ ├── services.cpp │ ├── services.h │ ├── task.cpp │ └── task.h ├── libc │ ├── freestanding │ │ ├── ctype.cpp │ │ ├── cxa_guards.cpp │ │ ├── errno.cpp │ │ ├── initialize_libc.cpp │ │ ├── setjmp.s │ │ ├── stack_check.cpp │ │ ├── stdio │ │ │ ├── fclose.cpp │ │ │ ├── file.h │ │ │ ├── fopen.cpp │ │ │ ├── fread.cpp │ │ │ ├── fseek.cpp │ │ │ ├── ftell.cpp │ │ │ ├── fwrite.cpp │ │ │ ├── printf.cpp │ │ │ └── standard_streams.cpp │ │ ├── stdlib │ │ │ ├── abort.cpp │ │ │ ├── aligned_alloc.cpp │ │ │ ├── free.cpp │ │ │ ├── malloc.cpp │ │ │ ├── qsort.cpp │ │ │ ├── realloc.cpp │ │ │ ├── strtof.cpp │ │ │ ├── strtol.cpp │ │ │ └── strtoul.cpp │ │ ├── string │ │ │ ├── memchr.cpp │ │ │ ├── memcmp.cpp │ │ │ ├── memcpy.s │ │ │ ├── memmove.cpp │ │ │ ├── memset.s │ │ │ ├── strcat.cpp │ │ │ ├── strcmp.cpp │ │ │ ├── strcpy.cpp │ │ │ ├── strlen.cpp │ │ │ ├── strncpy.cpp │ │ │ ├── strrchr.cpp │ │ │ └── strstr.cpp │ │ ├── system_calls │ │ │ ├── close.cpp │ │ │ ├── create.cpp │ │ │ ├── map.cpp │ │ │ ├── open.cpp │ │ │ ├── read.cpp │ │ │ ├── receive.cpp │ │ │ ├── run.cpp │ │ │ ├── seek.cpp │ │ │ ├── send.cpp │ │ │ ├── sendImplementation.s │ │ │ ├── sleep.cpp │ │ │ ├── waitForServiceRegistered.cpp │ │ │ └── write.cpp │ │ └── wchar │ │ │ ├── wcslen.cpp │ │ │ ├── wcstof.cpp │ │ │ ├── wcstol.cpp │ │ │ ├── wcstoul.cpp │ │ │ ├── wmemchr.cpp │ │ │ ├── wmemcmp.cpp │ │ │ ├── wmemcpy.cpp │ │ │ ├── wmemmove.cpp │ │ │ ├── wmemset.cpp │ │ │ └── wprintf.cpp │ ├── hosted │ │ ├── crt1.s │ │ ├── libc_startup.cpp │ │ └── stdio │ │ │ └── printf.cpp │ ├── include │ │ ├── assert.h │ │ ├── ctype.h │ │ ├── errno.h │ │ ├── fcntl.h │ │ ├── initialize_libc.h │ │ ├── inttypes.h │ │ ├── langinfo.h │ │ ├── locale.h │ │ ├── math.h │ │ ├── setjmp.h │ │ ├── stdio.h │ │ ├── stdlib.h │ │ ├── string.h │ │ ├── sys │ │ │ └── types.h │ │ ├── system_calls.h │ │ ├── time.h │ │ ├── unistd.h │ │ ├── wchar.h │ │ └── wctype.h │ └── make.config ├── loader │ ├── boot.s │ ├── elf.cpp │ ├── elf.h │ ├── gdt.cpp │ ├── gdt.h │ ├── idt_32.cpp │ ├── idt_32.h │ ├── isr_stubs.s │ ├── linker.ld │ ├── make.config │ ├── multiboot.h │ ├── panic.cpp │ ├── panic.h │ ├── print.cpp │ ├── print.h │ └── startup.cpp ├── saturn │ ├── crc.cpp │ ├── crc.h │ ├── gemini │ │ ├── environment.cpp │ │ ├── environment.h │ │ ├── interpreter.cpp │ │ └── interpreter.h │ ├── heap.cpp │ ├── heap.h │ ├── logging.cpp │ ├── logging.h │ ├── make.config │ ├── parsing.cpp │ ├── parsing.h │ ├── time.cpp │ ├── time.h │ ├── wait.cpp │ └── wait.h ├── services │ ├── apollo │ │ ├── alphablend.cpp │ │ ├── alphablend.h │ │ ├── container.cpp │ │ ├── container.h │ │ ├── display.cpp │ │ ├── display.h │ │ ├── fastcpy.s │ │ ├── lib │ │ │ ├── application.h │ │ │ ├── databinding.h │ │ │ ├── debug.cpp │ │ │ ├── debug.h │ │ │ ├── element_layout.h │ │ │ ├── elements │ │ │ │ ├── container.h │ │ │ │ ├── control.h │ │ │ │ ├── element.cpp │ │ │ │ ├── element.h │ │ │ │ ├── grid.cpp │ │ │ │ ├── grid.h │ │ │ │ ├── label.cpp │ │ │ │ ├── label.h │ │ │ │ ├── listview.cpp │ │ │ │ └── listview.h │ │ │ ├── layout.cpp │ │ │ ├── layout.h │ │ │ ├── make.config │ │ │ ├── renderer.cpp │ │ │ ├── renderer.h │ │ │ ├── text.cpp │ │ │ ├── text.h │ │ │ ├── visual.tst │ │ │ ├── window.cpp │ │ │ └── window.h │ │ ├── manager.cpp │ │ ├── manager.h │ │ ├── messages.h │ │ ├── tile.cpp │ │ └── tile.h │ ├── discovery │ │ ├── loader.cpp │ │ ├── loader.h │ │ ├── pci.cpp │ │ └── pci.h │ ├── drivers │ │ ├── ata │ │ │ ├── driver.cpp │ │ │ └── driver.h │ │ ├── bochsGraphicsAdaptor │ │ │ ├── driver.cpp │ │ │ └── driver.h │ │ └── serial │ │ │ ├── driver.cpp │ │ │ └── driver.h │ ├── events │ │ ├── system.cpp │ │ └── system.h │ ├── fakeFileSystem │ │ ├── fakeFileSystem.cpp │ │ └── fakeFileSystem.h │ ├── hardwareFileSystem │ │ ├── cpu │ │ │ ├── cpu.cpp │ │ │ ├── cpu.h │ │ │ ├── extensions.cpp │ │ │ ├── extensions.h │ │ │ ├── features.cpp │ │ │ ├── features.h │ │ │ ├── id.cpp │ │ │ ├── id.h │ │ │ ├── instructions.cpp │ │ │ ├── instructions.h │ │ │ ├── instructionsets.cpp │ │ │ ├── instructionsets.h │ │ │ ├── support.cpp │ │ │ ├── support.h │ │ │ ├── technology.cpp │ │ │ └── technology.h │ │ ├── object.cpp │ │ ├── object.h │ │ ├── pci │ │ │ ├── device.cpp │ │ │ ├── device.h │ │ │ ├── function.cpp │ │ │ ├── function.h │ │ │ ├── host.cpp │ │ │ ├── host.h │ │ │ ├── pci.cpp │ │ │ └── pci.h │ │ ├── ps2 │ │ │ ├── mouse.cpp │ │ │ └── mouse.h │ │ ├── system.cpp │ │ ├── system.h │ │ └── timer │ │ │ ├── timer.cpp │ │ │ ├── timer.h │ │ │ ├── tsc.cpp │ │ │ └── tsc.h │ ├── keyboard │ │ ├── keyboard.cpp │ │ ├── keyboard.h │ │ ├── messages.h │ │ └── virtualKeys.h │ ├── make.config │ ├── massStorageFileSystem │ │ ├── ext2 │ │ │ ├── filesystem.cpp │ │ │ └── filesystem.h │ │ ├── filesystem.h │ │ ├── system.cpp │ │ └── system.h │ ├── mouse │ │ ├── messages.h │ │ ├── service.cpp │ │ └── service.h │ ├── processFileSystem │ │ ├── object.cpp │ │ ├── object.h │ │ ├── processFileSystem.cpp │ │ └── processFileSystem.h │ ├── ps2 │ │ ├── mouse.cpp │ │ ├── mouse.h │ │ ├── ps2.cpp │ │ └── ps2.h │ ├── startup │ │ ├── startup.cpp │ │ └── startup.h │ ├── terminal │ │ ├── terminal.cpp │ │ ├── terminal.h │ │ ├── vga.cpp │ │ └── vga.h │ └── virtualFileSystem │ │ ├── cache.h │ │ ├── messages.h │ │ ├── virtualFileSystem.cpp │ │ ├── virtualFileSystem.h │ │ ├── vostok.cpp │ │ └── vostok.h └── userland │ ├── make.config │ └── shell │ ├── shell.cpp │ └── shell.h └── test └── kernel ├── arch └── x86_64 │ ├── memory │ ├── blockAllocator.cpp │ ├── blockAllocator.h │ ├── memory.cpp │ └── memory.h │ └── misc │ ├── avl.cpp │ ├── avl.h │ ├── linked_list.cpp │ ├── linked_list.h │ ├── misc.cpp │ └── misc.h ├── kernel.cpp └── kernel.h /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | *.o 3 | .#* 4 | *.bin 5 | *.a 6 | sysroot/ 7 | .d/ 8 | warnings.log 9 | saturn.log 10 | notes.org 11 | toolchain/ 12 | .vscode/ipch -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "**/libc++/**/*": "cpp", 4 | "*.tst": "clojure", 5 | "**/libc++/include/*": "cpp", 6 | "string": "cpp", 7 | "string_view": "cpp", 8 | "vector": "cpp", 9 | "type_traits": "cpp", 10 | "list": "cpp", 11 | "iterator": "cpp", 12 | "algorithm": "cpp", 13 | "cstddef": "cpp", 14 | "cwchar": "cpp", 15 | "ios": "cpp", 16 | "iosfwd": "cpp", 17 | "new": "cpp", 18 | "queue": "cpp", 19 | "stack": "cpp", 20 | "utility": "cpp", 21 | "__split_buffer": "cpp", 22 | "array": "cpp", 23 | "initializer_list": "cpp", 24 | "atomic": "cpp", 25 | "deque": "cpp", 26 | "memory": "cpp", 27 | "__config": "cpp", 28 | "__nullptr": "cpp", 29 | "exception": "cpp", 30 | "optional": "cpp", 31 | "stdexcept": "cpp", 32 | "typeinfo": "cpp", 33 | "variant": "cpp", 34 | "__bit_reference": "cpp", 35 | "__functional_base": "cpp", 36 | "functional": "cpp", 37 | "limits": "cpp", 38 | "tuple": "cpp", 39 | "__hash_table": "cpp", 40 | "__tree": "cpp", 41 | "map": "cpp", 42 | "unordered_map": "cpp", 43 | "__string": "cpp", 44 | "mutex": "cpp" 45 | } 46 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ -------------------------------------------------------------------------------- /meta/binutils_patches/Makefile.am.patch: -------------------------------------------------------------------------------- 1 | --- Makefile.am 2018-10-14 16:42:44.437436191 -0400 2 | +++ Makefile.saturn.am 2018-10-14 16:45:06.664594876 -0400 3 | @@ -286,6 +286,7 @@ 4 | eelf_i386_fbsd.c \ 5 | eelf_i386_ldso.c \ 6 | eelf_i386_nacl.c \ 7 | + eelf_i386_saturn.c \ 8 | eelf_i386_sol2.c \ 9 | eelf_i386_vxworks.c \ 10 | eelf_iamcu.c \ 11 | @@ -455,6 +456,7 @@ 12 | eelf_x86_64_cloudabi.c \ 13 | eelf_x86_64_fbsd.c \ 14 | eelf_x86_64_nacl.c \ 15 | + eelf_x86_64_saturn.c \ 16 | eelf_x86_64_sol2.c \ 17 | ehppa64linux.c \ 18 | ei386pep.c \ 19 | @@ -1295,6 +1297,10 @@ 20 | $(srcdir)/emulparams/elf_nacl.sh \ 21 | $(ELF_X86_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} 22 | 23 | +eelf_i386_saturn.c: $(srcdir)/emulparams/elf_i386_saturn.sh \ 24 | + $(srcdir)/emulparams/elf_i386.sh \ 25 | + $(ELF_X86_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} 26 | + 27 | eelf_i386_sol2.c: $(srcdir)/emulparams/elf_i386_sol2.sh \ 28 | $(srcdir)/emulparams/solaris2.sh \ 29 | $(srcdir)/emultempl/solaris2.em \ 30 | @@ -1846,6 +1852,10 @@ 31 | $(srcdir)/emulparams/elf_nacl.sh \ 32 | $(ELF_X86_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} 33 | 34 | +eelf_x86_64_saturn.c: $(srcdir)/emulparams/elf_x86_64_saturn.sh \ 35 | + $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} 36 | + ${GENSCRIPTS} elf_x86_64_saturn "$ (tdir_elf_x86_64_saturn)" 37 | + 38 | eelf_x86_64_sol2.c: $(srcdir)/emulparams/elf_x86_64_sol2.sh \ 39 | $(srcdir)/emulparams/elf_x86_64.sh \ 40 | $(srcdir)/emulparams/solaris2.sh \ 41 | -------------------------------------------------------------------------------- /meta/binutils_patches/config.bfd.patch: -------------------------------------------------------------------------------- 1 | --- config.bfd 2018-10-14 17:02:17.227471245 -0400 2 | +++ config.bfd.saturn 2018-10-14 17:01:42.763938370 -0400 3 | @@ -761,6 +761,12 @@ 4 | targ_selfvecs="iamcu_elf32_vec i386chaos_vec" 5 | ;; 6 | 7 | + i[3-7]86-*-saturn*) 8 | + targ_defvec=i386_elf32_vec 9 | + targ_selvecs= 10 | + targ64_selvecs=x86_64_elf64_vec 11 | + ;; 12 | + 13 | ia16-*-elf) 14 | targ_defvec=i386_elf32_vec 15 | targ_selvecs="i386_msdos_vec i386_aout_vec" 16 | @@ -1203,6 +1209,12 @@ 17 | want64=true 18 | ;; 19 | #ifdef BFD64 20 | + x86_64-*-saturn*) 21 | + targ_defvec=x86_64_elf64_vec 22 | + targ_selvecs=i386_elf32_vec 23 | + want64=true 24 | + ;; 25 | + 26 | s390x-*-linux*) 27 | targ_defvec=s390_elf64_vec 28 | targ_selvecs=s390_elf32_vec 29 | -------------------------------------------------------------------------------- /meta/binutils_patches/config.sub.patch: -------------------------------------------------------------------------------- 1 | --- config.sub 2018-07-06 03:13:31.000000000 -0400 2 | +++ config.saturn.sub 2018-10-13 21:46:02.743522322 -0400 3 | @@ -1374,7 +1374,7 @@ 4 | | os2* | vos* | palmos* | uclinux* | nucleus* \ 5 | | morphos* | superux* | rtmk* | windiss* \ 6 | | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ 7 | - | skyos* | haiku* | rdos* | toppers* | drops* | es* \ 8 | + | saturn* | skyos* | haiku* | rdos* | toppers* | drops* | es* \ 9 | | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ 10 | | midnightbsd*) 11 | # Remember, each alternative MUST END IN *, to match a version number. 12 | -------------------------------------------------------------------------------- /meta/binutils_patches/configure.tgt.patch: -------------------------------------------------------------------------------- 1 | --- configure.tgt.original 2018-10-14 16:45:20.851810206 -0400 2 | +++ configure.tgt 2018-10-14 16:55:37.952297703 -0400 3 | @@ -262,6 +262,15 @@ 4 | targ_extra_emuls=elf_i386 ;; 5 | i[3-7]86-*-sysv[45]*) targ_emul=elf_i386 6 | targ_extra_emuls=elf_iamcu ;; 7 | +i[3-7]86-*-saturn*) 8 | + targ_emul=elf_i386_saturn 9 | + targ_extra_emuls=elf_i386 10 | + targ64_extra_emuls="elf_x86_64_saturn elf_x86_64" 11 | + ;; 12 | +x86_64-*-saturn*) 13 | + targ_emul=elf_x86_64_saturn 14 | + targ_extra_emuls="elf_x86_64 elf_i386_saturn elf_i386" 15 | + ;; 16 | i[3-7]86-*-solaris2*) targ_emul=elf_i386_sol2 17 | targ_extra_emuls="elf_i386_ldso elf_i386 elf_iamcu elf_x86_64_sol2 elf_x86_64 elf_l1om elf_k1om" 18 | targ_extra_libpath=$targ_extra_emuls 19 | @@ -794,6 +803,14 @@ 20 | NATIVE_LIB_DIRS='/usr/local/lib /usr/ccs/lib /lib /usr/lib' 21 | ;; 22 | 23 | +i[3-7]86-*-saturn*) 24 | + NATIVE_LIB_DIRS='/libraries /system/libraries' 25 | + ;; 26 | + 27 | +x86_64-*-saturn*) 28 | + NATIVE_LIB_DIRS='/libraries /system/libraries' 29 | + ;; 30 | + 31 | i[3-7]86-*-solaris*) 32 | NATIVE_LIB_DIRS='/usr/local/lib /usr/ccs/lib /lib /usr/lib' 33 | ;; 34 | -------------------------------------------------------------------------------- /meta/binutils_patches/elf_i386_saturn.sh: -------------------------------------------------------------------------------- 1 | . ${srcdir}/emulparams/elf_i386.sh 2 | GENERATE_SHLIB_SCRIPT=yes 3 | GENERATE_PIE_SCRIPT=yes 4 | TEXT_START_ADDR=0x10000 -------------------------------------------------------------------------------- /meta/binutils_patches/elf_x86_64_saturn.sh: -------------------------------------------------------------------------------- 1 | . ${srcdir}/emulparams/elf_x86_64.sh 2 | -------------------------------------------------------------------------------- /meta/binutils_patches/gas_configure.tgt.patch: -------------------------------------------------------------------------------- 1 | --- gas/configure.tgt 2018-06-24 14:38:57.000000000 -0400 2 | +++ gas_configure.saturn.tgt 2018-10-13 22:09:08.651598110 -0400 3 | @@ -254,6 +254,7 @@ 4 | i386-*-*nt*) fmt=coff em=pe ;; 5 | i386-*-chaos) fmt=elf ;; 6 | i386-*-rdos*) fmt=elf ;; 7 | + i386-*-saturn*) fmt=elf ;; 8 | i386-*-darwin*) fmt=macho ;; 9 | 10 | ia16-*-elf*) fmt=elf ;; 11 | -------------------------------------------------------------------------------- /meta/bochs-runner.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | kernel=$(uname -r) 4 | 5 | if [[ $kernel = *"Microsoft"* ]]; 6 | then 7 | bochs="$bochs.exe" 8 | where=$(which $bochs) 9 | bochsDir=$(dirname $(which $bochs)) 10 | bochsDirName=$(basename $bochsDir) 11 | 12 | if [[ $bochsDirName = *"bochs"* ]]; 13 | then 14 | biosPath=$bochsDir/bios 15 | else 16 | biosPath=$(dirname $bochsDir)/bios 17 | fi 18 | 19 | BXSHARE=$biosPath 20 | export BXSHARE 21 | export WSLENV=$WSLENV:BXSHARE/p 22 | 23 | $bochs -f meta/bochsrc -q 24 | 25 | else 26 | #expect bochs to be built and stored adjacent to saturn dir 27 | BXSHARE=../bochs/bios ../bochs/bochs -f meta/bochsrc -q 28 | fi 29 | -------------------------------------------------------------------------------- /meta/bochsrc: -------------------------------------------------------------------------------- 1 | romimage: file=$BXSHARE/BIOS-bochs-latest 2 | vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest 3 | 4 | display_library: x #, options="gui_debug" 5 | 6 | ata0-master: type=cdrom, path=sysroot/system/boot/saturn.iso, status=inserted 7 | 8 | boot: cdrom 9 | 10 | cpu: model=corei7_sandy_bridge_2600k , count=2, ips=50000000 11 | memory: guest=256, host=256 12 | 13 | info: action=report 14 | debug: action=report, PIT=ignore, harddrv=ignore, XGUI=ignore, pit82c54=ignore, PIC=ignore, ioapic=ignore, siminterface=ignore, memory=ignore, floppy=ignore 15 | 16 | #log: bochs_log.txt 17 | 18 | #debug_symbols: file="saturn.sym" 19 | 20 | magic_break: enabled=1 21 | 22 | vga: extension=vbe, update_freq=5, realtime=1 23 | clock: sync=none, time0=local, rtc_sync=0 24 | -------------------------------------------------------------------------------- /meta/build_ld.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | mkdir -p toolchain 4 | cd toolchain 5 | 6 | saturn="$(dirname $(pwd))" 7 | 8 | if [ -d "$saturn/toolchain/binutils/bin" ]; then 9 | exit 0; 10 | fi 11 | 12 | wget -nc https://ftp.gnu.org/gnu/binutils/binutils-2.31.tar.xz 13 | 14 | tar xf binutils-2.31.tar.xz 15 | 16 | cd binutils-2.31 17 | 18 | patch < "$saturn/meta/binutils_patches/config.sub.patch" 19 | cd bfd && patch < "$saturn/meta/binutils_patches/config.bfd.patch" && cd .. 20 | cd ld && patch < "$saturn/meta/binutils_patches/configure.tgt.patch" 21 | patch < "$saturn/meta/binutils_patches/Makefile.am.patch" && cd .. 22 | cd gas && patch < "$saturn/meta/binutils_patches/gas_configure.tgt.patch" && cd .. 23 | 24 | cp "$saturn/meta/binutils_patches/elf_i386_saturn.sh" ld/emulparams 25 | cp "$saturn/meta/binutils_patches/elf_x86_64_saturn.sh" ld/emulparams 26 | 27 | cd ld 28 | automake 29 | cd ../.. 30 | 31 | mkdir binutils_build 32 | cd binutils_build 33 | 34 | ../binutils-2.31/configure --target=x86_64-saturn --prefix="$saturn/toolchain/binutils" --with-sysroot --disable-nls --disable-werror 35 | make 36 | make install -------------------------------------------------------------------------------- /meta/build_libcxx.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | mkdir -p toolchain 4 | cd toolchain 5 | 6 | saturn="$(dirname $(pwd))" 7 | 8 | if [ -d "$saturn/toolchain/libc++" ]; then 9 | exit 0; 10 | fi 11 | 12 | export SATURN_SYSROOT="$saturn/sysroot" 13 | export SATURN_LIBCXX="$saturn/toolchain/llvm/projects/libcxx/include" 14 | export SATURN_TOOLCHAIN_BIN="$saturn/toolchain/binutils/bin" 15 | 16 | mkdir build_llvm -p 17 | cd build_llvm 18 | 19 | cmake -DCMAKE_TOOLCHAIN_FILE=../../meta/toolchain-saturn.cmake -C ../../meta/cache.cmake -G "Unix Makefiles" --debug-output --debug-trycompile ../llvm/ --trace 20 | make cxx 21 | 22 | cd .. 23 | rm libc++ -rf 24 | mkdir libc++/lib -p 25 | cp build_llvm/lib/*.a libc++/lib 26 | cp build_llvm/include/c++/v1 libc++/include -a 27 | 28 | unset SATURN_SYSROOT 29 | unset SATURN_LIBCXX 30 | unset SATURN_TOOLCHAIN_BIN 31 | -------------------------------------------------------------------------------- /meta/cache.cmake: -------------------------------------------------------------------------------- 1 | SET(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "") 2 | SET(LLVM_ENABLE_LTO OFF CACHE BOOL "") 3 | SET(LLVM_BUILD_TOOLS OFF CACHE BOOL "") 4 | SET(LLVM_INCLUDE_TOOLS OFF CACHE BOOL "") 5 | SET(LLVM_BUILD_EXAMPLES OFF CACHE BOOL "") 6 | SET(LLVM_BUILD_TESTS OFF CACHE BOOL "") 7 | SET(LLVM_INCLUDE_BENCHMARKS OFF CACHE BOOL "") 8 | SET(LLVM_BUILD_BENCHMARKS OFF CACHE BOOL "") 9 | SET(LLVM_BUILD_DOCS OFF CACHE BOOL "") 10 | SET(LLVM_INCLUDE_UTILS OFF CACHE BOOL "") 11 | SET(LLVM_ENABLE_EH OFF CACHE BOOL "") 12 | SET(LIBCXX_INCLUDE_DOCS OFF CACHE BOOL "") 13 | SET(LIBCXX_ENABLE_SHARED NO CACHE BOOL "") 14 | SET(LIBCXX_ENABLE_EXCEPTIONS NO CACHE BOOL "") 15 | SET(LIBCXX_ENABLE_RTTI NO CACHE BOOL "") 16 | SET(LIBCXX_INCLUDE_BENCHMARKS NO CACHE BOOL "") 17 | SET(LLVM_INCLUDE_EXAMPLES NO CACHE BOOL "") 18 | SET(LLVM_INCLUDE_TESTS NO CACHE BOOL "") 19 | SET(LLVM_TARGET_ARCH x86_64 CACHE STRING "") 20 | SET(LLVM_TARGETS_TO_BUILD "X86" CACHE STRING "") 21 | SET(LIBCXX_INSTALL_LIBRARY OFF CACHE BOOL "") 22 | SET(LIBCXX_INSTALL_HEADERS OFF CACHE BOOL "") 23 | SET(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "") 24 | SET(LLVM_ENABLE_PIC OFF CACHE BOOL "") 25 | SET(LLVM_ENABLE_LIBCXX ON CACHE BOOL "") 26 | SET(UNIX ON CACHE BOOL "") 27 | SET(LLVM_ENABLE_CXX1Y ON CACHE BOOL "") -------------------------------------------------------------------------------- /meta/debug.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | lines="$(tput lines)" 4 | columns="$(tput cols)" 5 | 6 | tmux -2 new-session -d -s saturn -x "$columns" -y "$lines" 7 | tmux new-window -a -n saturn 8 | 9 | # super advanced hacker layout 10 | tmux split-window -h -p 30 11 | 12 | # right side 13 | tmux split-window -v -p 90 #memory 14 | tmux split-window -v -p 60 #stack 15 | tmux split-window -v -p 80 #threads 16 | 17 | # left side 18 | tmux select-pane -t 0 19 | tmux split-window -v -p 66 #source 20 | tmux split-window -v -p 40 #variables 21 | tmux select-pane -t 1 22 | tmux split-window -h -p 35 #assembly and registers 23 | 24 | tmux select-pane -t 7 25 | tmux attach -t saturn -------------------------------------------------------------------------------- /meta/download_llvm.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | mkdir -p toolchain 4 | cd toolchain 5 | 6 | saturn="$(dirname $(pwd))" 7 | 8 | if [ -d "$saturn/toolchain/llvm" ]; then 9 | exit 0; 10 | fi 11 | 12 | svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm 13 | cd llvm/projects 14 | svn co http://llvm.org/svn/llvm-project/libcxx/trunk libcxx 15 | svn co http://llvm.org/svn/llvm-project/libcxxabi/trunk libcxxabi 16 | 17 | cd .. -------------------------------------------------------------------------------- /meta/saturn-layout: -------------------------------------------------------------------------------- 1 | dashboard source -output /dev/pts/3 2 | dashboard assembly -output /dev/pts/8 3 | dashboard registers -output /dev/pts/10 4 | dashboard variables -output /dev/pts/9 5 | dashboard memory -output /dev/pts/4 6 | dashboard stack -output /dev/pts/5 7 | dashboard threads -output /dev/pts/6 8 | 9 | dashboard -layout source assembly registers variables memory stack threads !expressions !history !breakpoints 10 | 11 | dash source -style height 17 12 | 13 | dash registers -style list 'rax rbc rcx rdx rsi rdi rbp rsp r8 r9 r10 r11 r12 r13 r14 r15 rip eflags cs ss ds es fs gs fs_base gs_base cr0 cr2 cr3 efer' 14 | 15 | dash assembly -style function False 16 | dash assembly -style height 18 17 | 18 | dash variabes -style compact False 19 | dash variables -style align True -------------------------------------------------------------------------------- /meta/toolchain-saturn.cmake: -------------------------------------------------------------------------------- 1 | SET(CMAKE_BUILD_TYPE Debug) 2 | 3 | SET(CMAKE_SYSTEM_NAME Generic) 4 | SET(CMAKE_SYSTEM_VERSION 1) 5 | SET(triple x86_64-saturn-pc) 6 | 7 | SET(CMAKE_C_COMPILER clang) 8 | SET(CMAKE_CXX_COMPILER clang++) 9 | SET(CMAKE_ASM_COMPILER yasm) 10 | SET(CMAKE_SYSROOT $ENV{SATURN_SYSROOT}) 11 | SET(CMAKE_FIND_ROOT_PATH $ENV{SATURN_SYSROOT}) 12 | 13 | SET(ONLY_CMAKE_FIND_ROOT_PATH TRUE) 14 | SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 15 | SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 16 | 17 | SET(CMAKE_LINKER "$ENV{SATURN_TOOLCHAIN_BIN}/x86_64-saturn-ld") 18 | SET(CMAKE_C_LINK_EXECUTABLE "$ENV{SATURN_TOOLCHAIN_BIN}/x86_64-saturn-ld -o ") 19 | SET(CMAKE_CXX_LINK_EXECUTABLE "$ENV{SATURN_TOOLCHAIN_BIN}/x86_64-saturn-ld -o ") 20 | 21 | SET(CMAKE_C_FLAGS "-isysroot $ENV{SATURN_SYSROOT} -iwithsysroot /system/include -U__linux__ -U__GLIBC__ -U__unix_") 22 | SET(CMAKE_CXX_FLAGS "-isysroot $ENV{SATURN_SYSROOT} -DBYTE_ORDER=LITTLE_ENDIAN -nostdinc++ -std=c++2a -iwithsysroot /system/include -D_LIBCPP_HAS_THREAD_API_EXTERNAL -U__linux__ -U__GLIBC__ -U__unix__ -I$ENV{SATURN_LIBCXX}") 23 | SET(CMAKE_C_LINK_FLAGS " --sysroot=$ENV{SATURN_SYSROOT} -L=/system/libraries") 24 | SET(CMAKE_CXX_LINK_FLAGS " -nostdlib -nodefaultlibs --sysroot=$ENV{SATURN_SYSROOT} -L=/system/libraries") 25 | 26 | set(CMAKE_CXX_STANDARD 17) 27 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 28 | set(CMAKE_CXX_EXTENSIONS OFF) -------------------------------------------------------------------------------- /meta/vbox-runner.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | vbox="VBoxManage" 4 | kernel=$(uname -r) 5 | 6 | if [[ $kernel = *"Microsoft"* ]]; 7 | then 8 | vbox="$vbox.exe" 9 | fi 10 | 11 | vms=$($vbox list vms) 12 | 13 | declare -a vms 14 | mapfile -t vms < <($vbox list vms) 15 | 16 | foundVM=false 17 | 18 | for vm in "${vms[@]}"; do 19 | 20 | if [[ $vm == \"Saturn\"* ]]; 21 | then 22 | foundVM=true 23 | fi 24 | 25 | done 26 | 27 | if [ "$foundVM" = false ]; 28 | then 29 | echo "Creating new Saturn VM for VirtualBox" 30 | $vbox createvm --name Saturn --ostype "Other_64" --register 31 | $vbox modifyvm Saturn --memory 256 --cpus 2 32 | $vbox storagectl Saturn --name "IDE" --add ide --bootable on 33 | $vbox storageattach Saturn --storagectl "IDE" --medium sysroot/system/boot/saturn.iso --type dvddrive --port 0 --device 0 34 | fi 35 | 36 | $vbox startvm Saturn -------------------------------------------------------------------------------- /saturn_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patrick-lafferty/saturn/6dc36adb42ad9b647704dd19247423a522eeb551/saturn_logo.png -------------------------------------------------------------------------------- /saturn_logo_cropped.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patrick-lafferty/saturn/6dc36adb42ad9b647704dd19247423a522eeb551/saturn_logo_cropped.png -------------------------------------------------------------------------------- /screenshots/Advanced grid and databinding.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patrick-lafferty/saturn/6dc36adb42ad9b647704dd19247423a522eeb551/screenshots/Advanced grid and databinding.PNG -------------------------------------------------------------------------------- /screenshots/Capcom.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patrick-lafferty/saturn/6dc36adb42ad9b647704dd19247423a522eeb551/screenshots/Capcom.PNG -------------------------------------------------------------------------------- /screenshots/Dsky.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patrick-lafferty/saturn/6dc36adb42ad9b647704dd19247423a522eeb551/screenshots/Dsky.PNG -------------------------------------------------------------------------------- /screenshots/Grid and Labels.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patrick-lafferty/saturn/6dc36adb42ad9b647704dd19247423a522eeb551/screenshots/Grid and Labels.PNG -------------------------------------------------------------------------------- /screenshots/Transcript.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patrick-lafferty/saturn/6dc36adb42ad9b647704dd19247423a522eeb551/screenshots/Transcript.PNG -------------------------------------------------------------------------------- /screenshots/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patrick-lafferty/saturn/6dc36adb42ad9b647704dd19247423a522eeb551/screenshots/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.PNG -------------------------------------------------------------------------------- /screenshots/apollo tiles.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patrick-lafferty/saturn/6dc36adb42ad9b647704dd19247423a522eeb551/screenshots/apollo tiles.PNG -------------------------------------------------------------------------------- /screenshots/dsky and capcom.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patrick-lafferty/saturn/6dc36adb42ad9b647704dd19247423a522eeb551/screenshots/dsky and capcom.PNG -------------------------------------------------------------------------------- /screenshots/first actual graphics driver.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patrick-lafferty/saturn/6dc36adb42ad9b647704dd19247423a522eeb551/screenshots/first actual graphics driver.PNG -------------------------------------------------------------------------------- /screenshots/improved text layout.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patrick-lafferty/saturn/6dc36adb42ad9b647704dd19247423a522eeb551/screenshots/improved text layout.PNG -------------------------------------------------------------------------------- /screenshots/libwindows first drawText implementation.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patrick-lafferty/saturn/6dc36adb42ad9b647704dd19247423a522eeb551/screenshots/libwindows first drawText implementation.PNG -------------------------------------------------------------------------------- /screenshots/multi-size text.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patrick-lafferty/saturn/6dc36adb42ad9b647704dd19247423a522eeb551/screenshots/multi-size text.PNG -------------------------------------------------------------------------------- /screenshots/multicolour text.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patrick-lafferty/saturn/6dc36adb42ad9b647704dd19247423a522eeb551/screenshots/multicolour text.PNG -------------------------------------------------------------------------------- /screenshots/parrot.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patrick-lafferty/saturn/6dc36adb42ad9b647704dd19247423a522eeb551/screenshots/parrot.PNG -------------------------------------------------------------------------------- /screenshots/saturn-logo-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patrick-lafferty/saturn/6dc36adb42ad9b647704dd19247423a522eeb551/screenshots/saturn-logo-small.png -------------------------------------------------------------------------------- /src/applications/capcom/capcom.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #pragma once 30 | 31 | int capcom_main(); -------------------------------------------------------------------------------- /src/applications/dsky/dsky.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #pragma once 30 | 31 | int dsky_main(); -------------------------------------------------------------------------------- /src/applications/makefile: -------------------------------------------------------------------------------- 1 | CROSS_COMPILER_PATH = ~/projects/saturn-cross-compiler/bin/i686-saturn/bin 2 | 3 | AR = $(CROSS_COMPILER_PATH)/ar 4 | 5 | CXX = clang++-5.0 6 | MARCH = "--target=i686-saturn -march=i686" 7 | WARNINGS = -Wall -Wextra 8 | CXXPATHS = -isysroot ../../sysroot/ -iwithsysroot /system/include -iwithsysroot 9 | 10 | FLAGS = -fno-omit-frame-pointer -fno-exceptions -fno-rtti -fno-builtin -nostdinc 11 | CXXFLAGS = -O0 $(FLAGS) -g $(MARCH) $(DEPENDENCYFLAGS) $(WARNINGS) -std=c++1z $(CXXPATHS) -masm=intel -Drestrict=__restrict 12 | 13 | LD = $(CROSS_COMPILER_PATH)/ld 14 | LDFLAGS = --sysroot=../../sysroot/ -L=system/libraries -L=libraries/lib -g 15 | 16 | OBJS = \ 17 | ../../sysroot/system/libraries/crt1.o \ 18 | ../kernel/arch/i386/crti.o \ 19 | $(shell $(CC) $(CFLAGS) -m32 -print-file-name=crtbegin.o) \ 20 | test/main.o \ 21 | $(shell $(CC) $(CFLAGS) -m32 -print-file-name=crtend.o) \ 22 | ../kernel/arch/i386/crtn.o \ 23 | 24 | LIBS = -lc 25 | 26 | LINK_LIST = \ 27 | $(OBJS) \ 28 | $(LIBS) 29 | 30 | all: test.bin 31 | 32 | test.bin: $(OBJS) 33 | $(LD) -o test/$@ $(LDFLAGS) $(LINK_LIST) 34 | 35 | %.o: %.cpp 36 | $(CXX) -c $< -o $@ $(CXXFLAGS) 37 | -------------------------------------------------------------------------------- /src/applications/taskbar/taskbar.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #pragma once 30 | 31 | int taskbar_main(); -------------------------------------------------------------------------------- /src/applications/test/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | 30 | int main() { 31 | printf("hello, world\n"); 32 | return 0; 33 | } -------------------------------------------------------------------------------- /src/applications/transcript/transcript.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #pragma once 30 | 31 | int transcript_main(); -------------------------------------------------------------------------------- /src/grub.cfg: -------------------------------------------------------------------------------- 1 | set default=0 2 | set timeout=0 3 | 4 | menuentry "Saturn" { 5 | multiboot2 /boot/loader.bin 6 | module2 /boot/saturn.bin "SATURN_KERNEL" 7 | } -------------------------------------------------------------------------------- /src/kernel/arch/i386/cpu/initialize_sse.s: -------------------------------------------------------------------------------- 1 | %if 0 2 | 3 | Copyright (c) 2017, Patrick Lafferty 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the copyright holder nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | %endif 30 | 31 | section .text 32 | global initializeSSE 33 | initializeSSE: 34 | mov eax, CR4 35 | or eax, 1 << 9 ;set OSFXR bit 36 | or eax, 1 << 10 ;set OSXMMEXCPT bit 37 | mov CR4, eax 38 | mov eax, CR0 39 | mov eax, 0x80000003 40 | mov CR0, eax 41 | ret 42 | 43 | -------------------------------------------------------------------------------- /src/kernel/arch/i386/cpu/msr.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #include 30 | 31 | namespace CPU { 32 | 33 | enum class ModelSpecificRegister : uint32_t { 34 | IA32_TSC_AUX = 0xC000'0103 //Saturn stores the current CPU's id in this msr 35 | }; 36 | 37 | void writeModelSpecificRegister(ModelSpecificRegister msr, uint32_t low, uint32_t high); 38 | uint32_t readModelSpecificRegister_Low(ModelSpecificRegister msr); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/kernel/arch/i386/cpu/pic.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | #include 30 | 31 | namespace PIC { 32 | 33 | void disable(); 34 | void remapIRQs(); 35 | void maskAllInterrupts(); 36 | 37 | /* 38 | Values taken from http://wiki.osdev.org/8259_PIC 39 | */ 40 | const uint8_t MasterCommandRegister = 0x20; 41 | const uint8_t MasterDataRegister = 0x21; 42 | const uint8_t SlaveCommandRegister = 0xA0; 43 | const uint8_t SlaveDataRegister = 0xA1; 44 | } -------------------------------------------------------------------------------- /src/kernel/arch/i386/cpu/rtc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | #include 31 | 32 | namespace RTC { 33 | 34 | void enable(uint8_t rate); 35 | void disable(); 36 | void reset(); 37 | } -------------------------------------------------------------------------------- /src/kernel/arch/i386/cpu/sse.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | extern "C" void initializeSSE(); -------------------------------------------------------------------------------- /src/kernel/arch/i386/cpu/stack_frames.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | #include 31 | 32 | namespace CPU { 33 | struct InterruptStackFrame { 34 | uint32_t gs, fs, es, ds; 35 | uint32_t edi, esi, ebp, esp; 36 | uint32_t ebx, edx, ecx, eax; 37 | uint32_t interruptNumber; 38 | uint32_t errorCode; 39 | uint32_t eip, cs, eflags, resp, ss; 40 | }; 41 | } -------------------------------------------------------------------------------- /src/kernel/arch/i386/cpu/tsc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | 30 | namespace TSC { 31 | 32 | void startCalibration(); 33 | void stopCalibration(); 34 | uint64_t getTicksPerSecond(); 35 | } -------------------------------------------------------------------------------- /src/kernel/arch/i386/cpu/tss.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include "tss.h" 29 | 30 | namespace CPU { 31 | TSS* setupTSS(uint32_t address) { 32 | TSS* tss = static_cast(reinterpret_cast(address)); 33 | fillTSS(tss); 34 | 35 | auto offset = sizeof(TSS) - sizeof(TSS::ioPermissionBitmap); 36 | tss->ioMapBaseAddress = offset; 37 | tss->ss0 = 0x10; 38 | 39 | return tss; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/kernel/arch/i386/crti.s: -------------------------------------------------------------------------------- 1 | ;/*FROM http://wiki.osdev.org/Calling_Global_Constructors*/ 2 | 3 | section .init 4 | global _init 5 | _init: 6 | push ebp 7 | mov ebp, esp 8 | ; 9 | 10 | section .fini 11 | global _fini 12 | _fini: 13 | push ebp 14 | mov ebp, esp 15 | ; 16 | -------------------------------------------------------------------------------- /src/kernel/arch/i386/crtn.s: -------------------------------------------------------------------------------- 1 | ;/*FROM http://wiki.osdev.org/Calling_Global_Constructors*/ 2 | 3 | ;/* x86 crtn.s */ 4 | section .init 5 | ;/* gcc will nicely put the contents of crtend.o's .init section here. */ 6 | pop ebp 7 | ret 8 | 9 | section .fini 10 | ; /* gcc will nicely put the contents of crtend.o's .fini section here. */ 11 | pop ebp 12 | ret 13 | -------------------------------------------------------------------------------- /src/kernel/arch/i386/gdt/gdt_flush.s: -------------------------------------------------------------------------------- 1 | %if 0 2 | 3 | Copyright (c) 2017, Patrick Lafferty 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the copyright holder nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | %endif 30 | section .text 31 | global gdt_flush 32 | extern gp 33 | 34 | gdt_flush: 35 | lgdt [gp] 36 | 37 | call reloadSegments 38 | ret 39 | 40 | reloadSegments: 41 | jmp 0x08:flush 42 | 43 | flush: 44 | mov eax, 0x10 45 | mov ds, eax 46 | mov es, eax 47 | mov fs, eax 48 | mov gs, eax 49 | mov ss, eax 50 | 51 | 52 | ret 53 | -------------------------------------------------------------------------------- /src/kernel/arch/i386/idt/loadIDT.s: -------------------------------------------------------------------------------- 1 | %if 0 2 | 3 | Copyright (c) 2017, Patrick Lafferty 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the copyright holder nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | %endif 30 | global loadIDT 31 | extern idtPointer 32 | loadIDT: 33 | lidt [idtPointer] 34 | ret 35 | -------------------------------------------------------------------------------- /src/kernel/arch/i386/memory/guard.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include "guard.h" 29 | #include 30 | 31 | namespace Kernel { 32 | 33 | MemoryGuard::MemoryGuard(Memory::VirtualMemoryManager* kernelVMM) { 34 | 35 | oldVMM = Memory::getCurrentVMM(); 36 | kernelVMM->activate(); 37 | } 38 | 39 | MemoryGuard::~MemoryGuard() { 40 | if (oldVMM != nullptr) { 41 | oldVMM->activate(); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/kernel/arch/i386/memory/guard.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | namespace Memory { 31 | class VirtualMemoryManager; 32 | } 33 | 34 | namespace Kernel { 35 | 36 | class MemoryGuard { 37 | public: 38 | 39 | MemoryGuard(Memory::VirtualMemoryManager* kernelVMM); 40 | ~MemoryGuard(); 41 | 42 | private: 43 | 44 | Memory::VirtualMemoryManager* oldVMM; 45 | }; 46 | } -------------------------------------------------------------------------------- /src/kernel/arch/i386/task_context.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | #include 31 | 32 | namespace Kernel { 33 | struct TaskContext { 34 | uint32_t esp; 35 | uint32_t kernelESP; 36 | }; 37 | } -------------------------------------------------------------------------------- /src/kernel/arch/x86_64/cpu/halt.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2019, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include "halt.h" 29 | #include "log.h" 30 | 31 | void halt(const char* message) { 32 | 33 | log(message); 34 | 35 | while (true) { 36 | asm("cli \n" 37 | "hlt"); 38 | } 39 | } -------------------------------------------------------------------------------- /src/kernel/arch/x86_64/cpu/halt.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2019, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | [[noreturn]] 31 | void halt(const char* message); -------------------------------------------------------------------------------- /src/kernel/arch/x86_64/cpu/initialise_sse.s: -------------------------------------------------------------------------------- 1 | %if 0 2 | 3 | Copyright (c) 2018, Patrick Lafferty 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the copyright holder nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | %endif 30 | 31 | section .text 32 | global initializeSSE 33 | initializeSSE: 34 | mov rax, CR4 35 | or rax, (1 << 9) + (1 << 10) ;set OSFXSR and OSXMMEXCPT bits 36 | mov CR4, rax 37 | mov rax, CR0 38 | and rax, ~(1 << 1) ;clear CR0.EM - Emulation 39 | mov CR0, rax 40 | ret 41 | 42 | global gdt_flush 43 | extern GdtPointer 44 | gdt_flush: 45 | mov rax, qword GdtPointer 46 | lgdt [rax] 47 | ret -------------------------------------------------------------------------------- /src/kernel/arch/x86_64/cpu/initialize.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | #include 30 | 31 | struct KernelConfig; 32 | 33 | namespace CPU { 34 | 35 | void initialize(KernelConfig* config); 36 | } 37 | -------------------------------------------------------------------------------- /src/kernel/arch/x86_64/cpu/msr.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #include 30 | 31 | namespace CPU { 32 | 33 | enum class ModelSpecificRegister : uint32_t { 34 | GSBase = 0xC000'0101, 35 | KernelGSBase = 0xC000'0102 36 | }; 37 | 38 | void writeModelSpecificRegister(ModelSpecificRegister msr, uint32_t low, uint32_t high); 39 | uint32_t readModelSpecificRegister_Low(ModelSpecificRegister msr); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/kernel/arch/x86_64/cpu/pic.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | #include 30 | 31 | namespace PIC { 32 | 33 | void disable(); 34 | void remapIRQs(); 35 | void maskAllInterrupts(); 36 | 37 | /* 38 | Values taken from http://wiki.osdev.org/8259_PIC 39 | */ 40 | const uint8_t MasterCommandRegister = 0x20; 41 | const uint8_t MasterDataRegister = 0x21; 42 | const uint8_t SlaveCommandRegister = 0xA0; 43 | const uint8_t SlaveDataRegister = 0xA1; 44 | } -------------------------------------------------------------------------------- /src/kernel/arch/x86_64/cpu/timers/pit.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2019, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | namespace PIT { 31 | 32 | void disable(); 33 | 34 | } -------------------------------------------------------------------------------- /src/kernel/arch/x86_64/cpu/timers/rtc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | #include 31 | 32 | namespace RTC { 33 | 34 | void enable(uint8_t rate); 35 | void disable(); 36 | void reset(); 37 | } -------------------------------------------------------------------------------- /src/kernel/arch/x86_64/cpu/timers/tsc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | 30 | namespace TSC { 31 | 32 | void startCalibration(); 33 | void stopCalibration(); 34 | uint64_t getTicksPerSecond(); 35 | } -------------------------------------------------------------------------------- /src/kernel/arch/x86_64/cpu/tss.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include "tss.h" 29 | #include 30 | #include 31 | 32 | namespace CPU { 33 | 34 | bool setupTSS(Memory::BlockAllocator& allocator) { 35 | 36 | auto tss = allocator.allocate(); 37 | return GDT::addTSSEntry(reinterpret_cast(tss), sizeof(TSS) - 1); 38 | } 39 | 40 | void loadTSSRegister(int id) { 41 | auto offset = 0x18 + id * 0x10; 42 | asm("ltr %%ax" : : "a"(offset)); 43 | } 44 | } -------------------------------------------------------------------------------- /src/kernel/arch/x86_64/crti.s: -------------------------------------------------------------------------------- 1 | ;/*FROM http://wiki.osdev.org/Calling_Global_Constructors*/ 2 | 3 | section .init 4 | global _init 5 | _init: 6 | push rbp 7 | mov rbp, rsp 8 | ; 9 | 10 | section .fini 11 | global _fini 12 | _fini: 13 | push rbp 14 | mov rbp, rsp 15 | ; 16 | -------------------------------------------------------------------------------- /src/kernel/arch/x86_64/crtn.s: -------------------------------------------------------------------------------- 1 | ;/*FROM http://wiki.osdev.org/Calling_Global_Constructors*/ 2 | 3 | section .init 4 | pop rbp 5 | ret 6 | 7 | section .fini 8 | pop rbp 9 | ret 10 | -------------------------------------------------------------------------------- /src/kernel/arch/x86_64/linker.ld: -------------------------------------------------------------------------------- 1 | ENTRY(_start) 2 | OUTPUT_FORMAT(elf64-x86-64) 3 | 4 | KERNEL_VMA = 0xFFFFFFFF80000000; 5 | 6 | SECTIONS 7 | { 8 | . = KERNEL_VMA; 9 | 10 | .text ALIGN(4K) : 11 | { 12 | *(.text) 13 | } 14 | 15 | .rodata ALIGN(4K) : 16 | { 17 | *(.rodata) 18 | } 19 | 20 | .data ALIGN(4K): 21 | { 22 | *(.data) 23 | *(COMMON) 24 | } 25 | 26 | .bss ALIGN(4K) : 27 | { 28 | _bss_start = .; 29 | *(.bss) 30 | _bss_end = .; 31 | } 32 | 33 | _bss_length = _bss_end - _bss_start; 34 | 35 | .ctors : 36 | { 37 | _constructors_start = .; 38 | *(SORT(.ctors*)) 39 | _constructors_end = .; 40 | } 41 | 42 | .dtors : 43 | { 44 | _destructors_start = .; 45 | *(SORT(.dtors*)) 46 | _destructors_end = .; 47 | } 48 | 49 | } -------------------------------------------------------------------------------- /src/kernel/arch/x86_64/memory/addresses.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2019, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | #include 31 | 32 | namespace Memory { 33 | 34 | /* 35 | These simple structs will help to prevent any physical/virtual address 36 | type mismatches (using physical where virtual is expected or verse visa). 37 | */ 38 | struct PhysicalAddress { 39 | uintptr_t address; 40 | }; 41 | 42 | struct VirtualAddress { 43 | uintptr_t address; 44 | }; 45 | } -------------------------------------------------------------------------------- /src/kernel/arch/x86_64/misc/kernel_initial_arguments.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | #include 31 | 32 | struct KernelConfig { 33 | uint64_t nextFreeAddress; 34 | uint64_t totalFreePages; 35 | uint64_t rsdpAddress; 36 | uint64_t acpiLocation; 37 | uint64_t acpiLength; 38 | }; -------------------------------------------------------------------------------- /src/kernel/log.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | void log(const char* restrict format, ...); -------------------------------------------------------------------------------- /src/kernel/make.config: -------------------------------------------------------------------------------- 1 | kernel_CXX_FLAGS = -mno-red-zone -mcmodel=kernel -Drestrict=__restrict 2 | kernel_OBJECTS = \ 3 | src/kernel/saturn.o \ 4 | src/kernel/log.o \ 5 | src/kernel/saturn_startup.o \ 6 | src/kernel/arch/x86_64/gdt.o \ 7 | src/kernel/arch/x86_64/memory/physical_memory_manager.o \ 8 | src/kernel/arch/x86_64/memory/virtual_memory_manager.o \ 9 | src/kernel/arch/x86_64/memory/address_space.o \ 10 | src/kernel/arch/x86_64/cpu/initialise_sse.o \ 11 | src/kernel/arch/x86_64/cpu/msr.o \ 12 | src/kernel/arch/x86_64/cpu/pic.o \ 13 | src/kernel/arch/x86_64/cpu/initialize.o \ 14 | src/kernel/arch/x86_64/cpu/acpi.o \ 15 | src/kernel/arch/x86_64/cpu/apic.o \ 16 | src/kernel/arch/x86_64/cpu/tss.o \ 17 | src/kernel/arch/x86_64/cpu/halt.o \ 18 | src/kernel/arch/x86_64/cpu/trampoline.o \ 19 | src/kernel/arch/x86_64/cpu/create_trampoline.o \ 20 | src/kernel/arch/x86_64/cpu/timers/rtc.o \ 21 | src/kernel/arch/x86_64/cpu/timers/tsc.o \ 22 | src/kernel/arch/x86_64/cpu/timers/pit.o \ 23 | src/kernel/arch/x86_64/idt/descriptor.o \ 24 | src/kernel/arch/x86_64/idt/exceptions.o \ 25 | src/kernel/arch/x86_64/idt/exception_stubs.o \ 26 | src/kernel/arch/x86_64/idt/irqs.o \ 27 | src/kernel/arch/x86_64/idt/irq_stubs.o \ 28 | src/kernel/arch/x86_64/cpu/metablocks.o \ 29 | test/kernel/kernel.o \ 30 | test/kernel/arch/x86_64/misc/avl.o \ 31 | test/kernel/arch/x86_64/misc/linked_list.o \ 32 | test/kernel/arch/x86_64/misc/misc.o \ 33 | test/kernel/arch/x86_64/memory/memory.o \ 34 | test/kernel/arch/x86_64/memory/blockAllocator.o 35 | 36 | TARGETS += kernel 37 | BINARIES += saturn.bin 38 | OBJECTS += $(kernel_OBJECTS) 39 | LINK_LIST = \ 40 | sysroot/system/libraries/libc_startup.o \ 41 | $(kernel_OBJECTS) 42 | 43 | kernel_LIBS = -lc_kernel 44 | 45 | saturn.bin: dependency_directories $(kernel_OBJECTS) $(ARCHDIR)/linker.ld libc_kernel.a 46 | $(LD) -T $(ARCHDIR)/linker.ld -o sysroot/system/boot/$@ $(GLOBAL_LD_FLAGS) $(LINK_LIST) $(kernel_LIBS) -------------------------------------------------------------------------------- /src/libc/freestanding/errno.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | //TODO 30 | //obviously wrong implementation, the goal was just to get libcxx to build 31 | int* getErrno() { 32 | //TODO: implement stub 33 | static int todo {0}; 34 | return &todo; 35 | } 36 | 37 | -------------------------------------------------------------------------------- /src/libc/freestanding/initialize_libc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | #include 30 | 31 | void initializeLibC() { 32 | loadLookupTable(); 33 | } -------------------------------------------------------------------------------- /src/libc/freestanding/stack_check.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | #include 30 | 31 | uintptr_t __stack_chk_guard = 0xe1a2c3d9; 32 | 33 | extern "C" __attribute__((noreturn)) 34 | void __stack_chk_fail(void) { 35 | printf("Stack smashing detected!\n"); 36 | 37 | while(true){} 38 | } -------------------------------------------------------------------------------- /src/libc/freestanding/stdio/fclose.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | #include "file.h" 30 | #include 31 | 32 | int fclose(FILE* stream) { 33 | close(stream->descriptor); 34 | delete stream; 35 | return 0; 36 | } -------------------------------------------------------------------------------- /src/libc/freestanding/stdio/file.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | #include 31 | 32 | struct _file { 33 | uint32_t descriptor; 34 | uint32_t position; 35 | int error; 36 | uint32_t length; 37 | }; -------------------------------------------------------------------------------- /src/libc/freestanding/stdio/ftell.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | #include "file.h" 30 | 31 | long int ftell(FILE* stream) { 32 | return stream->position; 33 | } -------------------------------------------------------------------------------- /src/libc/freestanding/stdio/standard_streams.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | 30 | FILE* stdin = nullptr; 31 | FILE* stdout = nullptr; 32 | FILE* stderr = nullptr; -------------------------------------------------------------------------------- /src/libc/freestanding/stdlib/abort.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | 30 | void abort(void) { 31 | //TODO 32 | while (true) {} 33 | } -------------------------------------------------------------------------------- /src/libc/freestanding/stdlib/aligned_alloc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | #include 30 | 31 | /* 32 | Note: not thread-safe! Just want to get a simple version running 33 | */ 34 | 35 | void* aligned_alloc(size_t alignment, size_t size) { 36 | 37 | auto heap = reinterpret_cast(0xa000'0000 + 0x100000); 38 | return heap->aligned_allocate(alignment, size); 39 | } -------------------------------------------------------------------------------- /src/libc/freestanding/stdlib/free.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | #include 30 | 31 | /* 32 | Note: not thread-safe! Just want to get a simple version running 33 | */ 34 | 35 | void free(void* ptr) { 36 | auto heap = reinterpret_cast(0xa000'0000 + 0x100000); 37 | return heap->free(ptr); 38 | } -------------------------------------------------------------------------------- /src/libc/freestanding/stdlib/malloc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | #include 30 | 31 | /* 32 | Note: not thread-safe! Just want to get a simple version running 33 | */ 34 | 35 | void* malloc(size_t size) { 36 | 37 | /* 38 | TODO: this is a temporary hack until elf loading and the 64bit port 39 | allows us to have a proper isolated default heap 40 | */ 41 | auto heap = reinterpret_cast(0xa000'0000 + 0x100000); 42 | return heap->allocate(size); 43 | } -------------------------------------------------------------------------------- /src/libc/freestanding/stdlib/strtof.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | 30 | float strtof(const char* restrict /*nptr*/, char** restrict /*endptr*/) { 31 | //TODO: implement stub 32 | return 0; 33 | } 34 | 35 | long double strtold(const char* restrict /*nptr*/, char** restrict /*endptr*/) { 36 | //TODO: implement stub 37 | return 0; 38 | } 39 | 40 | double strtod(const char* restrict /*nptr*/, char** restrict /*endptr*/) { 41 | //TODO: implement stub 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /src/libc/freestanding/stdlib/strtoul.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | 30 | unsigned long int strtoul(const char* restrict /*nptr*/, char** restrict /*endptr*/, int /*base*/) { 31 | //TODO: implement stub 32 | return 0; 33 | } 34 | 35 | unsigned long long int strtoull(const char* restrict /*nptr*/, char** restrict /*endptr*/, int /*base*/) { 36 | //TODO: implement stub 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /src/libc/freestanding/string/memchr.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | 30 | void* memchr(const void* s, int c, size_t n) { 31 | auto ptr = static_cast(s); 32 | auto ch = (unsigned char)c; 33 | 34 | for (auto i = 0u; i < n; i++) { 35 | if (ptr[i] == ch) { 36 | auto p = const_cast(ptr + i); 37 | return static_cast(p); 38 | } 39 | } 40 | 41 | return nullptr; 42 | } -------------------------------------------------------------------------------- /src/libc/freestanding/string/memcmp.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | 30 | int memcmp(const void* first, const void* second, size_t count) { 31 | 32 | auto lhs = static_cast(first); 33 | auto rhs = static_cast(second); 34 | 35 | for(size_t i = 0; i < count; i++) { 36 | if (lhs[i] > rhs[i]) { 37 | return 1; 38 | } 39 | else if (lhs[i] < rhs[i]) { 40 | return -1; 41 | } 42 | } 43 | 44 | return 0; 45 | } -------------------------------------------------------------------------------- /src/libc/freestanding/string/memcpy.s: -------------------------------------------------------------------------------- 1 | %if 0 2 | 3 | Copyright (c) 2018, Patrick Lafferty 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the copyright holder nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | %endif 30 | 31 | global memcpy 32 | memcpy: 33 | 34 | push rbp 35 | mov rbp, rsp 36 | 37 | mov rax, rdi 38 | mov rcx, rdx 39 | rep movsb 40 | 41 | mov rsp, rbp 42 | pop rbp 43 | 44 | ret -------------------------------------------------------------------------------- /src/libc/freestanding/string/memset.s: -------------------------------------------------------------------------------- 1 | %if 0 2 | 3 | Copyright (c) 2018, Patrick Lafferty 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the copyright holder nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | %endif 30 | 31 | section .text 32 | global memset 33 | memset: 34 | 35 | push rbp 36 | mov rbp, rsp 37 | 38 | mov rax, rsi 39 | mov rcx, rdx 40 | rep stosb 41 | mov rax, rdi 42 | 43 | mov rsp, rbp 44 | pop rbp 45 | 46 | ret -------------------------------------------------------------------------------- /src/libc/freestanding/string/strcat.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | 30 | char* strcat(char* restrict dest, const char* restrict src) { 31 | while (*dest != '\0') { 32 | dest++; 33 | } 34 | 35 | while (*src != '\0') { 36 | *dest++ = *src++; 37 | } 38 | 39 | return dest; 40 | } -------------------------------------------------------------------------------- /src/libc/freestanding/string/strcpy.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | 30 | char* strcpy(char* restrict dest, const char* restrict src) { 31 | while (*src != '\0') { 32 | *dest++ = *src++; 33 | } 34 | 35 | if (*src == '\0') { 36 | *dest = *src; 37 | } 38 | 39 | return dest; 40 | } -------------------------------------------------------------------------------- /src/libc/freestanding/string/strncpy.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | 30 | char* strncpy(char* restrict dest, const char* restrict src, size_t count) { 31 | while (*src != '\0' && count > 0) { 32 | *dest++ = *src++; 33 | count--; 34 | } 35 | 36 | if (*src == '\0') { 37 | *dest = *src; 38 | } 39 | 40 | if (count > 0) { 41 | *dest++ = '\0'; 42 | count--; 43 | } 44 | 45 | return dest; 46 | } -------------------------------------------------------------------------------- /src/libc/freestanding/string/strrchr.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | 30 | char* strrchr(const char* str, int ch) { 31 | const char* lastInstance = nullptr; 32 | 33 | while (*str != '\0') { 34 | if (static_cast(*str) == static_cast(ch)) { 35 | lastInstance = str; 36 | } 37 | 38 | str++; 39 | } 40 | 41 | return const_cast(lastInstance); 42 | } -------------------------------------------------------------------------------- /src/libc/freestanding/system_calls/close.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | #include 30 | #include 31 | 32 | using namespace VirtualFileSystem; 33 | 34 | void close(uint32_t fileDescriptor) { 35 | CloseRequest request; 36 | request.fileDescriptor = fileDescriptor; 37 | request.serviceType = Kernel::ServiceType::VFS; 38 | send(IPC::RecipientType::ServiceName, &request); 39 | } -------------------------------------------------------------------------------- /src/libc/freestanding/system_calls/send.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | #include 30 | 31 | extern "C" void sendImplementation(uint32_t recipient, uint64_t message); 32 | 33 | void send(IPC::RecipientType recipient, IPC::Message* message) { 34 | 35 | sendImplementation(static_cast(recipient), reinterpret_cast(message)); 36 | } -------------------------------------------------------------------------------- /src/libc/freestanding/system_calls/sendImplementation.s: -------------------------------------------------------------------------------- 1 | section .text 2 | global sendImplementation 3 | sendImplementation: 4 | push rbp 5 | mov rbp, rsp 6 | 7 | mov rax, 3 8 | mov rbx, rdi 9 | mov rcx, rsi 10 | int 0xFF 11 | 12 | mov rsp, rbp 13 | pop rbp 14 | ret -------------------------------------------------------------------------------- /src/libc/freestanding/wchar/wcslen.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | 30 | size_t wcslen(const wchar_t* /*s*/) { 31 | //TODO: implement stub 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /src/libc/freestanding/wchar/wcstof.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | 30 | float wcstof(const wchar_t* restrict /*nptr*/, wchar_t** restrict /*endptr*/) { 31 | //TODO: implement stub 32 | return 0; 33 | } 34 | 35 | double wcstod(const wchar_t* restrict /*nptr*/, wchar_t** restrict /*endptr*/) { 36 | //TODO: implement stub 37 | return 0; 38 | } 39 | 40 | long double wcstold(const wchar_t* restrict /*nptr*/, wchar_t** restrict /*endptr*/) { 41 | //TODO: implement stub 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /src/libc/freestanding/wchar/wcstol.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | 30 | long int wcstol(const wchar_t* restrict /*nptr*/, wchar_t** restrict /*endptr*/, int /*base*/) { 31 | //TODO: implement stub 32 | return 0; 33 | } 34 | 35 | long long int wcstoll(const wchar_t* restrict /*nptr*/, wchar_t** restrict /*endptr*/, int /*base*/) { 36 | //TODO: implement stub 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /src/libc/freestanding/wchar/wcstoul.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | 30 | unsigned long int wcstoul(const wchar_t* restrict /*nptr*/, wchar_t** restrict /*endptr*/, int /*base*/) { 31 | //TODO: implement stub 32 | return 0; 33 | } 34 | 35 | unsigned long long int wcstoull(const wchar_t* restrict /*nptr*/, 36 | wchar_t** restrict /*endptr*/, 37 | int /*base*/) { 38 | 39 | //TODO: implement stub 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /src/libc/freestanding/wchar/wmemchr.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | 30 | wchar_t* wmemchr(const wchar_t* /*s*/, wchar_t /*c*/, size_t /*n*/) { 31 | //TODO: implement stub 32 | return nullptr; 33 | } 34 | -------------------------------------------------------------------------------- /src/libc/freestanding/wchar/wmemcmp.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | 30 | int wmemcmp(const wchar_t* /*s1*/, const wchar_t* /*s2*/, size_t /*n*/) { 31 | //TODO: implement stub 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /src/libc/freestanding/wchar/wmemcpy.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | 30 | wchar_t* wmemcpy(wchar_t* restrict /*s1*/, const wchar_t* restrict /*s2*/, size_t /*n*/) { 31 | //TODO: implement stub 32 | return nullptr; 33 | } 34 | -------------------------------------------------------------------------------- /src/libc/freestanding/wchar/wmemmove.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | 30 | wchar_t* wmemmove(wchar_t* /*s1*/, const wchar_t* /*s2*/, size_t /*n*/) { 31 | //TODO: implement stub 32 | return nullptr; 33 | } 34 | -------------------------------------------------------------------------------- /src/libc/freestanding/wchar/wmemset.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | 30 | wchar_t* wmemset(wchar_t* /*s*/, wchar_t /*c*/, size_t /*n*/) { 31 | //TODO: implement stub 32 | return nullptr; 33 | } 34 | -------------------------------------------------------------------------------- /src/libc/freestanding/wchar/wprintf.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | 30 | int swprintf(wchar_t* restrict /*s*/, size_t /*n*/, const wchar_t* restrict /*format*/, ...) { 31 | //TODO: implement stub 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /src/libc/include/assert.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | #ifdef NDEBUG 35 | 36 | #define assert(ignore) ((void)0) 37 | 38 | #else 39 | 40 | #define assert(todo) ((void)0) 41 | 42 | #endif 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif -------------------------------------------------------------------------------- /src/libc/include/errno.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | //TODO 31 | //obviously wrong implementation, the goal was just to get libcxx to build 32 | int* getErrno(); 33 | 34 | #define errno (*getErrno()) 35 | 36 | typedef int errno_t; 37 | 38 | -------------------------------------------------------------------------------- /src/libc/include/fcntl.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | /* 31 | Libc++ wants to see this file when building itself. 32 | */ 33 | 34 | #include "sys/types.h" 35 | 36 | #define O_RDONLY 1 37 | 38 | int open(const char*, int); 39 | ssize_t read(int, void*, size_t); 40 | int close(int); -------------------------------------------------------------------------------- /src/libc/include/initialize_libc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | void initializeLibC(); -------------------------------------------------------------------------------- /src/libc/include/inttypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | #include -------------------------------------------------------------------------------- /src/libc/include/langinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | #include "locale.h" -------------------------------------------------------------------------------- /src/libc/include/setjmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | typedef int jmp_buf[6]; 31 | 32 | extern int setjmp(jmp_buf env); 33 | extern _Noreturn void longjmp(jmp_buf env, int val); -------------------------------------------------------------------------------- /src/libc/include/sys/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | /* 31 | Libc++ really wants this file to exist. Wont be adding anything else here. 32 | */ 33 | 34 | typedef int ssize_t; -------------------------------------------------------------------------------- /src/libc/include/unistd.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #pragma once 30 | 31 | /* 32 | Libc++ has its heart set on seeing this file when building itself, 33 | but doesn't need anything in here. 34 | */ 35 | 36 | -------------------------------------------------------------------------------- /src/loader/linker.ld: -------------------------------------------------------------------------------- 1 | ENTRY(boot) 2 | 3 | SECTIONS 4 | { 5 | . = 1M; 6 | 7 | .multiboot ALIGN(4K): 8 | { 9 | __loader_memory_start = .; 10 | *(.multiboot) 11 | } 12 | 13 | .text ALIGN(4K): 14 | { 15 | *(.text) 16 | } 17 | 18 | .rodata ALIGN(4K): 19 | { 20 | *(.rodata) 21 | } 22 | 23 | .data ALIGN(4K): 24 | { 25 | *(.data) 26 | } 27 | 28 | .bss ALIGN(4K): 29 | { 30 | *(.bss) 31 | __loader_memory_end = .; 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /src/loader/make.config: -------------------------------------------------------------------------------- 1 | loader_CXX_FLAGS = "--target=i686-saturn -march=i686" 2 | loader_CXX_FLAGS += -mno-mmx -mno-sse -mno-sse2 3 | loader_AS_FLAGS = -f elf32 4 | loader_OBJECTS = \ 5 | src/loader/boot.o \ 6 | src/loader/print.o \ 7 | src/loader/elf.o \ 8 | src/loader/panic.o \ 9 | src/loader/idt_32.o \ 10 | src/loader/isr_stubs.o \ 11 | src/loader/gdt.o \ 12 | src/loader/startup.o 13 | 14 | TARGETS += loader 15 | BINARIES += loader.bin 16 | OBJECTS += $(loader_OBJECTS) 17 | LINK_LIST = $(loader_OBJECTS) 18 | 19 | LDFLAGS = -g 20 | 21 | loader.bin: dependency_directories $(loader_OBJECTS) 22 | $(LD) -n -T src/loader/linker.ld -m elf_i386_saturn -o sysroot/system/boot/$@ $(GLOBAL_LD_FLAGS) $(loader_OBJECTS) -------------------------------------------------------------------------------- /src/loader/panic.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #include "panic.h" 30 | #include "print.h" 31 | 32 | /* 33 | Used when the Saturn loader encounters an unrecoverable error 34 | Prints a message and then halts 35 | */ 36 | void panic(const char* message) { 37 | asm volatile("cli"); 38 | 39 | printString(message); 40 | 41 | while (true) { 42 | asm volatile("hlt"); 43 | } 44 | } -------------------------------------------------------------------------------- /src/loader/panic.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | [[noreturn]] 31 | void panic(const char* message); -------------------------------------------------------------------------------- /src/loader/print.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | 30 | /* 31 | Helper funcs that write directly to video memory at the given line and column 32 | */ 33 | 34 | void printInteger(uint32_t i, int line = 0, int column = 0, bool isNegative = false, int base = 10, bool upper = false); 35 | void printString(const char* message, int line = 0, int column = 0); -------------------------------------------------------------------------------- /src/saturn/crc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | #include 31 | 32 | /* 33 | Implementation based off of RFC1952 34 | */ 35 | 36 | namespace Saturn::CRC { 37 | 38 | inline uint32_t lookup32[256]; 39 | inline bool needToComputeLookup {true}; 40 | 41 | void computeLookupTable(); 42 | bool check32(uint32_t originalCRC, uint8_t* buffer, uint32_t length); 43 | } -------------------------------------------------------------------------------- /src/saturn/gemini/interpreter.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | #include "../parsing.h" 31 | #include "environment.h" 32 | 33 | namespace Saturn::Gemini { 34 | 35 | CallResult interpret(Saturn::Parse::SExpression* s, Environment& environment); 36 | } 37 | -------------------------------------------------------------------------------- /src/saturn/make.config: -------------------------------------------------------------------------------- 1 | SATURNDIR = src/saturn 2 | 3 | LIB_SATURN_OBJS = \ 4 | $(SATURNDIR)/heap.o \ 5 | $(SATURNDIR)/time.o \ 6 | $(SATURNDIR)/wait.o \ 7 | $(SATURNDIR)/parsing.o \ 8 | $(SATURNDIR)/crc.o \ 9 | $(SATURNDIR)/logging.o \ 10 | $(SATURNDIR)/gemini/environment.o \ 11 | $(SATURNDIR)/gemini/interpreter.o 12 | -------------------------------------------------------------------------------- /src/saturn/time.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | namespace Saturn::Time { 29 | 30 | double getHighResolutionTimeSeconds(); 31 | } -------------------------------------------------------------------------------- /src/saturn/wait.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #include 30 | 31 | namespace Saturn::Event { 32 | 33 | void waitForMount(std::string_view path); 34 | } -------------------------------------------------------------------------------- /src/services/apollo/alphablend.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | 30 | namespace Apollo { 31 | 32 | uint32_t blend(uint32_t source, uint32_t destination, uint8_t alpha); 33 | } -------------------------------------------------------------------------------- /src/services/apollo/fastcpy.s: -------------------------------------------------------------------------------- 1 | 2 | global mems 3 | mems: 4 | 5 | mov edi, eax 6 | mov esi, ecx 7 | mov ecx, edx 8 | mov edx, esi 9 | add edx, ecx 10 | 11 | start: 12 | 13 | movntdqa xmm0, [esi] 14 | movntdqa xmm1, [esi + 16] 15 | movntdqa xmm2, [esi + 32] 16 | movntdqa xmm3, [esi + 48] 17 | 18 | movdqa [edi], xmm0 19 | movdqa [edi + 16], xmm1 20 | movdqa [edi + 32], xmm2 21 | movdqa [edi + 48], xmm3 22 | 23 | add esi, 040h 24 | add edi, 040h 25 | cmp esi, edx 26 | jne start 27 | ret -------------------------------------------------------------------------------- /src/services/apollo/lib/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | #include 31 | 32 | namespace Apollo::Debug { 33 | 34 | /* 35 | Renders a hollow box outline into the given buffer 36 | */ 37 | void drawBox(uint32_t* buffer, uint32_t x, uint32_t y, uint32_t width, uint32_t height); 38 | } -------------------------------------------------------------------------------- /src/services/apollo/lib/elements/control.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #pragma once 30 | 31 | #include "element.h" 32 | 33 | namespace Mouse { 34 | struct MouseMove; 35 | struct ButtonPress; 36 | struct Scroll; 37 | } 38 | 39 | namespace Apollo::Elements { 40 | 41 | /* 42 | A Control is a user interactive UI Element. It 43 | can receive mouse and keyboard events. 44 | */ 45 | class Control { 46 | public: 47 | 48 | virtual void handleMouseScroll(const Mouse::Scroll& message) = 0; 49 | }; 50 | } -------------------------------------------------------------------------------- /src/services/apollo/lib/make.config: -------------------------------------------------------------------------------- 1 | LIBDIR = src/services/apollo/lib 2 | 3 | LIB_APOLLO_OBJS = \ 4 | $(LIBDIR)/text.o \ 5 | $(LIBDIR)/debug.o \ 6 | $(LIBDIR)/layout.o \ 7 | $(LIBDIR)/window.o \ 8 | $(LIBDIR)/renderer.o \ 9 | $(LIBDIR)/elements/element.o \ 10 | $(LIBDIR)/elements/grid.o \ 11 | $(LIBDIR)/elements/listview.o \ 12 | $(LIBDIR)/elements/label.o -------------------------------------------------------------------------------- /src/services/discovery/loader.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include "loader.h" 29 | #include "pci.h" 30 | 31 | namespace Discovery { 32 | 33 | void discoverDevices() { 34 | PCI::discoverDevices(); 35 | } 36 | } -------------------------------------------------------------------------------- /src/services/discovery/loader.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | namespace Discovery { 31 | 32 | void discoverDevices(); 33 | } -------------------------------------------------------------------------------- /src/services/drivers/bochsGraphicsAdaptor/driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | namespace BGA { 31 | 32 | void service(); 33 | } -------------------------------------------------------------------------------- /src/services/drivers/serial/driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | #include 31 | 32 | namespace Serial { 33 | 34 | void service(); 35 | } -------------------------------------------------------------------------------- /src/services/fakeFileSystem/fakeFileSystem.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | /* 31 | The FakeFileSystem is just a hack until a real system like Ext2 32 | is supported. It allows you to "open" the service "binaries". 33 | Since the services are still statically linked to the kernel, 34 | this just returns their function address, while allowing me 35 | to test out the virtual file system and write a startup 36 | service (like systemd/init). 37 | */ 38 | namespace FakeFileSystem { 39 | 40 | void service(); 41 | } -------------------------------------------------------------------------------- /src/services/keyboard/keyboard.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | namespace Keyboard { 31 | void service(); 32 | } -------------------------------------------------------------------------------- /src/services/mouse/service.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | namespace Mouse { 31 | void service(); 32 | } -------------------------------------------------------------------------------- /src/services/startup/startup.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | namespace Startup { 31 | void service(); 32 | void runProgram(const char* path); 33 | } -------------------------------------------------------------------------------- /src/userland/make.config: -------------------------------------------------------------------------------- 1 | USERLAND_OBJS = \ 2 | src/userland/shell/shell.o \ 3 | src/applications/dsky/main.o \ 4 | src/applications/capcom/main.o \ 5 | src/applications/capcom/commands.o \ 6 | src/applications/transcript/main.o \ 7 | src/applications/taskbar/main.o -------------------------------------------------------------------------------- /src/userland/shell/shell.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | namespace Shell { 31 | extern "C" int main(); 32 | } -------------------------------------------------------------------------------- /test/kernel/arch/x86_64/memory/blockAllocator.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | namespace Test { 31 | 32 | class BlockAllocatorSuite { 33 | public: 34 | 35 | static constexpr const char* name = "BlockAllocator"; 36 | 37 | static bool allocate_HandlesSimpleAllocations(); 38 | static bool allocate_HandlesExcessiveAllocations(); 39 | static bool allocate_HandlesMultipleReservations(); 40 | static bool allocate_HandlesFreeList(); 41 | 42 | static bool run(); 43 | }; 44 | } -------------------------------------------------------------------------------- /test/kernel/arch/x86_64/memory/memory.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #include "memory.h" 30 | #include 31 | #include "blockAllocator.h" 32 | 33 | namespace Test { 34 | 35 | bool runMemoryTests() { 36 | return Preflight::runTestSuites(); 37 | } 38 | } -------------------------------------------------------------------------------- /test/kernel/arch/x86_64/memory/memory.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | namespace Test { 31 | 32 | bool runMemoryTests(); 33 | } -------------------------------------------------------------------------------- /test/kernel/arch/x86_64/misc/linked_list.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | namespace Test { 31 | 32 | class LinkedListSuite { 33 | public: 34 | 35 | static constexpr const char* name = "Linked List"; 36 | 37 | static bool add_HandlesEmptyList(); 38 | static bool add_HandlesNonEmptyList(); 39 | 40 | static bool reverse_Works(); 41 | 42 | static bool run(); 43 | }; 44 | } -------------------------------------------------------------------------------- /test/kernel/arch/x86_64/misc/misc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #include "misc.h" 30 | #include 31 | #include "avl.h" 32 | #include "linked_list.h" 33 | 34 | namespace Test { 35 | 36 | bool runMiscTests() { 37 | return Preflight::runTestSuites(); 38 | } 39 | } -------------------------------------------------------------------------------- /test/kernel/arch/x86_64/misc/misc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | namespace Test { 31 | 32 | bool runMiscTests(); 33 | } -------------------------------------------------------------------------------- /test/kernel/kernel.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #include "kernel.h" 30 | #include 31 | #include "arch/x86_64/misc/misc.h" 32 | #include "arch/x86_64/memory/memory.h" 33 | 34 | namespace Test { 35 | 36 | bool runKernelTests() { 37 | return runMiscTests() 38 | && runMemoryTests(); 39 | } 40 | } -------------------------------------------------------------------------------- /test/kernel/kernel.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, Patrick Lafferty 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #pragma once 29 | 30 | namespace Test { 31 | 32 | bool runKernelTests(); 33 | } --------------------------------------------------------------------------------