├── .gdbinit
├── .gitattributes
├── .gitignore
├── CMakeLists.txt
├── CONTRIBUTING.md
├── COPYING
├── LICENSE
├── OVMFbin
├── OVMF_CODE-pure-efi.fd
├── OVMF_VARS-pure-efi.fd
└── README.md
├── README.md
├── TODO.org
├── base
├── inc
│ └── .gitignore
└── lib
│ ├── crt0.o
│ ├── crti.o
│ ├── crtn.o
│ └── libc.a
├── gnu-efi
├── .gitignore
├── ChangeLog
├── Make.defaults
├── Make.rules
├── Makefile
├── README.efilib
├── README.elilo
├── README.git
├── README.gnuefi
├── apps
│ ├── AllocPages.c
│ ├── FreePages.c
│ ├── Makefile
│ ├── bltgrid.c
│ ├── debughook.c
│ ├── drv0.c
│ ├── drv0.h
│ ├── drv0_use.c
│ ├── exit.c
│ ├── lfbgrid.c
│ ├── modelist.c
│ ├── printenv.c
│ ├── route80h.c
│ ├── setdbg.c
│ ├── setjmp.c
│ ├── t.c
│ ├── t2.c
│ ├── t3.c
│ ├── t4.c
│ ├── t5.c
│ ├── t6.c
│ ├── t7.c
│ ├── t8.c
│ ├── tcc.c
│ ├── tpause.c
│ ├── trivial.S
│ └── unsetdbg.c
├── bootloader
│ ├── Makefile
│ └── main.c
├── gnuefi
│ ├── Makefile
│ ├── crt0-efi-aarch64.S
│ ├── crt0-efi-arm.S
│ ├── crt0-efi-ia32.S
│ ├── crt0-efi-ia64.S
│ ├── crt0-efi-mips64el.S
│ ├── crt0-efi-x86_64.S
│ ├── elf_aarch64_efi.lds
│ ├── elf_arm_efi.lds
│ ├── elf_ia32_efi.lds
│ ├── elf_ia32_fbsd_efi.lds
│ ├── elf_ia64_efi.lds
│ ├── elf_mips64el_efi.lds
│ ├── elf_x86_64_efi.lds
│ ├── elf_x86_64_fbsd_efi.lds
│ ├── reloc_aarch64.c
│ ├── reloc_arm.c
│ ├── reloc_ia32.c
│ ├── reloc_ia64.S
│ ├── reloc_mips64el.c
│ └── reloc_x86_64.c
├── inc
│ ├── Makefile
│ ├── aarch64
│ │ ├── efibind.h
│ │ ├── efilibplat.h
│ │ └── efisetjmp_arch.h
│ ├── arm
│ │ ├── efibind.h
│ │ ├── efilibplat.h
│ │ └── efisetjmp_arch.h
│ ├── efi.h
│ ├── efi_nii.h
│ ├── efi_pxe.h
│ ├── efiapi.h
│ ├── eficompiler.h
│ ├── eficon.h
│ ├── efidebug.h
│ ├── efidef.h
│ ├── efidevp.h
│ ├── efierr.h
│ ├── efifs.h
│ ├── efigpt.h
│ ├── efiip.h
│ ├── efilib.h
│ ├── efilink.h
│ ├── efinet.h
│ ├── efipart.h
│ ├── efipciio.h
│ ├── efipoint.h
│ ├── efiprot.h
│ ├── efipxebc.h
│ ├── efirtlib.h
│ ├── efiser.h
│ ├── efisetjmp.h
│ ├── efishellintf.h
│ ├── efishellparm.h
│ ├── efistdarg.h
│ ├── efitcp.h
│ ├── efiudp.h
│ ├── efiui.h
│ ├── ia32
│ │ ├── efibind.h
│ │ ├── efilibplat.h
│ │ ├── efisetjmp_arch.h
│ │ └── pe.h
│ ├── ia64
│ │ ├── efibind.h
│ │ ├── efilibplat.h
│ │ ├── efisetjmp_arch.h
│ │ ├── pe.h
│ │ └── salproc.h
│ ├── inc.mak
│ ├── libsmbios.h
│ ├── make.inf
│ ├── makefile.hdr
│ ├── mips64el
│ │ ├── efibind.h
│ │ ├── efilibplat.h
│ │ └── efisetjmp_arch.h
│ ├── pci22.h
│ ├── protocol
│ │ ├── adapterdebug.h
│ │ ├── eficonsplit.h
│ │ ├── efidbg.h
│ │ ├── efivar.h
│ │ ├── ia64
│ │ │ └── eficontext.h
│ │ ├── intload.h
│ │ ├── legacyboot.h
│ │ ├── make.inf
│ │ ├── makefile.hdr
│ │ ├── piflash64.h
│ │ ├── readme.txt
│ │ └── vgaclass.h
│ ├── romload.h
│ └── x86_64
│ │ ├── efibind.h
│ │ ├── efilibplat.h
│ │ ├── efisetjmp_arch.h
│ │ └── pe.h
└── lib
│ ├── Makefile
│ ├── Makefile.orig
│ ├── aarch64
│ ├── efi_stub.S
│ ├── initplat.c
│ ├── math.c
│ └── setjmp.S
│ ├── arm
│ ├── div.S
│ ├── edk2asm.h
│ ├── efi_stub.S
│ ├── initplat.c
│ ├── ldivmod.S
│ ├── llsl.S
│ ├── llsr.S
│ ├── math.c
│ ├── mullu.S
│ ├── setjmp.S
│ └── uldiv.S
│ ├── boxdraw.c
│ ├── cmdline.c
│ ├── console.c
│ ├── crc.c
│ ├── data.c
│ ├── debug.c
│ ├── dpath.c
│ ├── error.c
│ ├── event.c
│ ├── exit.c
│ ├── guid.c
│ ├── hand.c
│ ├── hw.c
│ ├── ia32
│ ├── efi_stub.S
│ ├── initplat.c
│ ├── math.c
│ └── setjmp.S
│ ├── ia64
│ ├── initplat.c
│ ├── math.c
│ ├── palproc.S
│ ├── palproc.h
│ ├── salpal.c
│ └── setjmp.S
│ ├── init.c
│ ├── lib.h
│ ├── lock.c
│ ├── mips64el
│ ├── efi_stub.S
│ ├── initplat.c
│ ├── math.c
│ └── setjmp.S
│ ├── misc.c
│ ├── print.c
│ ├── runtime
│ ├── efirtlib.c
│ ├── rtdata.c
│ ├── rtlock.c
│ ├── rtstr.c
│ └── vm.c
│ ├── smbios.c
│ ├── sread.c
│ ├── str.c
│ └── x86_64
│ ├── callwrap.c
│ ├── efi_stub.S
│ ├── initplat.c
│ ├── math.c
│ └── setjmp.S
├── hello.txt
├── kernel
├── CMakeLists.txt
├── kernel.ld
├── res
│ └── dfltfont.psf
└── src
│ ├── acpi.cpp
│ ├── acpi.h
│ ├── ahci.cpp
│ ├── ahci.h
│ ├── basic_renderer.cpp
│ ├── basic_renderer.h
│ ├── bitmap.cpp
│ ├── bitmap.h
│ ├── boot.h
│ ├── cpu.h
│ ├── cpuid.asm
│ ├── cpuid.cpp
│ ├── cpuid.h
│ ├── cstr.cpp
│ ├── cstr.h
│ ├── debug.cpp
│ ├── debug.h
│ ├── devices
│ ├── devices.cpp
│ └── devices.h
│ ├── e1000.cpp
│ ├── e1000.h
│ ├── efi_memory.cpp
│ ├── efi_memory.h
│ ├── elf.h
│ ├── elf_loader.h
│ ├── event.cpp
│ ├── event.h
│ ├── fat_definitions.h
│ ├── file.h
│ ├── gdt.asm
│ ├── gdt.cpp
│ ├── gdt.h
│ ├── gpt.cpp
│ ├── gpt.h
│ ├── gpt_partition_type_guids.h
│ ├── guid.h
│ ├── hpet.cpp
│ ├── hpet.h
│ ├── inode.h
│ ├── integers.h
│ ├── interrupts
│ ├── idt.cpp
│ ├── idt.h
│ ├── interrupts.cpp
│ ├── interrupts.h
│ ├── syscalls.asm
│ ├── syscalls.cpp
│ └── syscalls.h
│ ├── io.cpp
│ ├── io.h
│ ├── kernel.cpp
│ ├── kernel.h
│ ├── keyboard.cpp
│ ├── keyboard.h
│ ├── keyboard_scancode_translation.cpp
│ ├── keyboard_scancode_translation.h
│ ├── kstage1.cpp
│ ├── kstage1.h
│ ├── large_integers.h
│ ├── link_definitions.h
│ ├── linked_list.h
│ ├── math.h
│ ├── memory.cpp
│ ├── memory.h
│ ├── memory
│ ├── common.h
│ ├── heap.cpp
│ ├── heap.h
│ ├── paging.h
│ ├── physical_memory_manager.cpp
│ ├── physical_memory_manager.h
│ ├── region.h
│ ├── virtual_memory_manager.cpp
│ └── virtual_memory_manager.h
│ ├── mouse.cpp
│ ├── mouse.h
│ ├── panic.cpp
│ ├── panic.h
│ ├── pci.cpp
│ ├── pci.h
│ ├── pci_descriptors.cpp
│ ├── pit.cpp
│ ├── pit.h
│ ├── prekernel.asm
│ ├── pure_virtuals.cpp
│ ├── pure_virtuals.h
│ ├── random_lcg.cpp
│ ├── random_lcg.h
│ ├── random_lfsr.cpp
│ ├── random_lfsr.h
│ ├── rtc.cpp
│ ├── rtc.h
│ ├── scheduler.asm
│ ├── scheduler.cpp
│ ├── scheduler.h
│ ├── spinlock.cpp
│ ├── spinlock.h
│ ├── storage
│ ├── device_drivers
│ │ ├── gpt_partition.h
│ │ ├── port_controller.cpp
│ │ └── port_controller.h
│ ├── file_metadata.h
│ ├── filesystem_driver.h
│ ├── filesystem_drivers
│ │ ├── dbgout.h
│ │ ├── file_allocation_table.cpp
│ │ ├── file_allocation_table.h
│ │ ├── input.cpp
│ │ ├── input.h
│ │ ├── pipe.cpp
│ │ ├── pipe.h
│ │ ├── socket.cpp
│ │ └── socket.h
│ └── storage_device_driver.h
│ ├── system.cpp
│ ├── system.h
│ ├── tests.cpp
│ ├── tests.h
│ ├── time.h
│ ├── tss.cpp
│ ├── tss.h
│ ├── uart.cpp
│ ├── uart.h
│ ├── userswitch.asm
│ ├── utf.cpp
│ ├── utf.h
│ ├── va_list.h
│ ├── vfs_forward.h
│ ├── virtual_filesystem.cpp
│ ├── virtual_filesystem.h
│ └── x86_64
│ └── cpu.h
├── known_bugs.org
├── oldTODO.org
├── scripts
├── README.md
├── buildrun.bat
├── buildrun.sh
├── cinclude2dot.sh
├── install_mkgpt.sh
├── mkbootdir.sh
├── mkfat32efibootimage.cmake
├── mkfat32images.cmake
├── mkfat32lensorosdata.cmake
├── mkgpt.sh
├── mkimg.bat
├── mkimg.ps1
├── mkimg.sh
├── mkiso.bat
├── mkiso.ps1
├── mkiso.sh
├── run.bat
├── run.ps1
├── run.sh
├── rundbg.bat
├── rundbg.sh
├── runhda.bat
├── runhda.ps1
├── runhda.sh
├── runhdadbg.bat
├── runhdadbg.sh
├── runiso.bat
├── runiso.ps1
├── runiso.sh
├── startup.nsh
└── sysroot.sh
├── std
└── include
│ ├── .gitattributes
│ ├── algorithm
│ ├── array
│ ├── atomic
│ ├── bit
│ ├── bits
│ ├── colours.h
│ ├── decls.h
│ └── terminate.h
│ ├── cmath
│ ├── concepts
│ ├── cstring
│ ├── ctype.h
│ ├── extensions
│ ├── extensions_double_ended_queue
│ ├── extensions_ring_buffer
│ ├── extensions_sparse_vector
│ ├── filesystem
│ ├── format
│ ├── functional
│ ├── iterator
│ ├── locale
│ ├── memory
│ ├── mutex
│ ├── new
│ ├── stddef.h
│ ├── stdint.h
│ ├── string
│ ├── string_view
│ ├── type_traits
│ ├── unordered_map
│ ├── utility
│ └── vector
├── structure.dot
├── toolchain
├── .gitignore
├── README.md
├── binutils-2.38-lensor.patch
├── config.cmake
├── gcc-11.2.0-lensor.patch
├── gcc-12.1.0-lensor.patch
├── lensor.h
├── lensor_gnu_toolchain.cmake
├── toolchain.sh
└── win_toolchain.sh
└── user
├── CMakeLists.txt
├── blazeit
├── CMakeLists.txt
└── main.c
├── cat
├── CMakeLists.txt
└── main.cpp
├── clienttest
├── CMakeLists.txt
└── main.c
├── echo
├── CMakeLists.txt
└── main.cpp
├── libc
├── CMakeLists.txt
├── README.md
├── abi.cpp
├── assert.h
├── bits
│ ├── abi.h
│ ├── cdtors.h
│ ├── file_struct.h
│ ├── io_defs.h
│ ├── string_intrinsics.h
│ └── stub.h
├── crt0.s
├── crti.s
├── crtn.s
├── errno.h
├── float.h
├── install-headers.cmake
├── install.sh
├── limits.h
├── stdalign.h
├── stdarg.h
├── stdbool.h
├── stdio.cpp
├── stdio.h
├── stdlib.cpp
├── stdlib.h
├── stdnoreturn.h
├── string.cpp
├── string.h
├── sys
│ ├── intrin.h
│ ├── syscalls.h
│ └── types.h
├── template.h
├── test
│ ├── CMakeLists.txt
│ └── test.cc
├── tests
│ ├── CMakeLists.txt
│ ├── add-test.sh
│ ├── test
│ │ └── string
│ │ │ ├── base.cpp
│ │ │ ├── cat.cpp
│ │ │ ├── compare-lex.cpp
│ │ │ ├── compare.cpp
│ │ │ ├── erase.cpp
│ │ │ ├── misc.cpp
│ │ │ ├── starts-ends.cpp
│ │ │ ├── substr.cpp
│ │ │ └── view.cpp
│ └── testing.hh
├── time.h
├── unistd.cpp
└── unistd.h
├── libm
├── CMakeLists.txt
└── src
│ └── stub.cpp
├── libstdc++
├── CMakeLists.txt
└── src
│ ├── filesystem.cpp
│ └── stub.cpp
├── ls
├── CMakeLists.txt
└── main.cpp
├── pwd
├── CMakeLists.txt
└── main.c
├── servertest
├── CMakeLists.txt
└── main.c
├── stdout
├── CMakeLists.txt
├── framebuffer.c
├── framebuffer.h
├── ints.h
├── main.c
├── psf.c
└── psf.h
└── xish
├── CMakeLists.txt
└── src
└── main.cpp
/.gdbinit:
--------------------------------------------------------------------------------
1 | target remote localhost:1234
2 | symbol-file ./boot/LensorOS/kernel.elf
3 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # If you are confused about this file, see the documentation at:
2 | # https://git-scm.com/docs/gitattributes
3 |
4 | # Auto detect text files and perform LF normalization
5 | * text=auto
6 |
7 | # Linux bash files should always have LF line endings.
8 | *.sh text eol=lf
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Prerequisites
2 | *.d
3 |
4 | # Compiled Object files
5 | *.slo
6 | *.lo
7 | *.o
8 | *.obj
9 |
10 | # Precompiled Headers
11 | *.gch
12 | *.pch
13 |
14 | # Compiled Dynamic libraries
15 | *.so
16 | *.dylib
17 | *.dll
18 |
19 | # Fortran module files
20 | *.mod
21 | *.smod
22 |
23 | # Compiled Static libraries
24 | *.lai
25 | *.la
26 | *.a
27 | *.lib
28 |
29 | # Executables
30 | *.exe
31 | *.out
32 | *.app
33 |
34 | # Builds
35 | **/bld/
36 | **/build/
37 | **/builds/
38 | **/win/
39 | **/winja/
40 | **/windows/
41 | **/winbld/
42 | **/winbuild/
43 | **/lnx/
44 | **/linux/
45 | **/lnxbuild/
46 | **/linuxbuild/
47 | **/make/
48 | **/ninja/
49 | **/debug/
50 | **/dbg/
51 | **/rls/
52 | **/release/
53 | **/tst/
54 | **/testing/
55 | **/cmake-build-*/
56 |
57 | # Scripts at the top level
58 | *.cmake
59 | *.sh
60 | *.bat
61 | *.ps1
62 | *.py
63 |
64 | # Build stuff
65 | bin/
66 |
67 | # LibC Tests
68 | user/libc/test/test
69 |
70 | # Userspace build install directory
71 | user/bin
72 |
73 | # Backups
74 | **/*.tmp*
75 | **/*.temp*
76 | **/*~
77 | **/#*#
78 | **/.#*
79 | **/*.backup*
80 | **/.swp
81 |
82 | # Boot Directory
83 | /boot/
84 |
85 | # System Root
86 | /root/
87 |
88 | # clangd
89 | **/compile_commands.json*
90 | .cache/
91 |
92 | # OVMF
93 | OVMFbin/OVMF_VARS_LensorOS.fd
94 |
95 | # cinclude2dot
96 | **/include_visualization/
97 |
98 | # CLion
99 | .idea/
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2022, Contributors To LensorOS.
2 | All rights reserved.
3 |
4 | This file is part of LensorOS.
5 |
6 | LensorOS is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | LensorOS is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with LensorOS. If not, see .
--------------------------------------------------------------------------------
/OVMFbin/OVMF_CODE-pure-efi.fd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LensPlaysGames/LensorOS/02a4aa87c2daf6a575cf0811361e4fb5f3a0935b/OVMFbin/OVMF_CODE-pure-efi.fd
--------------------------------------------------------------------------------
/OVMFbin/OVMF_VARS-pure-efi.fd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LensPlaysGames/LensorOS/02a4aa87c2daf6a575cf0811361e4fb5f3a0935b/OVMFbin/OVMF_VARS-pure-efi.fd
--------------------------------------------------------------------------------
/TODO.org:
--------------------------------------------------------------------------------
1 | #+title: LensorOS TODO 2024
2 | #+author: Lens
3 | #+description: What the fuck we should be doing for LensorOS in 2024
4 | #+created: [2024-06-21 Fri 11:37]
5 |
6 | * Fucking Printing From Userspace Barely Fucking Works
7 | Began [2024-06-21 Fri 11:37]
8 | Ended ?
9 |
10 | I'm pretty sure the whole buffering of libc is just fairly broken. A
11 | certain someone built it, so I'm not that surprised that it's
12 | overcomplicated and doesn't work.
13 |
--------------------------------------------------------------------------------
/base/inc/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LensPlaysGames/LensorOS/02a4aa87c2daf6a575cf0811361e4fb5f3a0935b/base/inc/.gitignore
--------------------------------------------------------------------------------
/base/lib/crt0.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LensPlaysGames/LensorOS/02a4aa87c2daf6a575cf0811361e4fb5f3a0935b/base/lib/crt0.o
--------------------------------------------------------------------------------
/base/lib/crti.o:
--------------------------------------------------------------------------------
1 | ELF > h @ @ .shstrtab .text .data .bss .init .fini @ @ @ @ " @ @ (
--------------------------------------------------------------------------------
/base/lib/crtn.o:
--------------------------------------------------------------------------------
1 | ELF > h @ @ .shstrtab .text .data .bss .init .fini @ @ @ @ " @ @ (
--------------------------------------------------------------------------------
/base/lib/libc.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LensPlaysGames/LensorOS/02a4aa87c2daf6a575cf0811361e4fb5f3a0935b/base/lib/libc.a
--------------------------------------------------------------------------------
/gnu-efi/.gitignore:
--------------------------------------------------------------------------------
1 | # Generated folder + files from `make bootloader`
2 | /x86_64/
--------------------------------------------------------------------------------
/gnu-efi/README.efilib:
--------------------------------------------------------------------------------
1 |
2 | The files in the "lib" and "inc" subdirectories are using the EFI Application
3 | Toolkit distributed by Intel at http://developer.intel.com/technology/efi
4 |
5 | This code is covered by the following agreement:
6 |
7 | Copyright (c) 1998-2000 Intel Corporation
8 |
9 | Redistribution and use in source and binary forms, with or without modification, are permitted
10 | provided that the following conditions are met:
11 |
12 | Redistributions of source code must retain the above copyright notice, this list of conditions and
13 | the following disclaimer.
14 |
15 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions
16 | and the following disclaimer in the documentation and/or other materials provided with the
17 | distribution.
18 |
19 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL BE
22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 | POSSIBILITY OF SUCH DAMAGE. THE EFI SPECIFICATION AND ALL OTHER INFORMATION
29 | ON THIS WEB SITE ARE PROVIDED "AS IS" WITH NO WARRANTIES, AND ARE SUBJECT
30 | TO CHANGE WITHOUT NOTICE.
31 |
--------------------------------------------------------------------------------
/gnu-efi/README.elilo:
--------------------------------------------------------------------------------
1 |
2 | IMPORTANT information related to the gnu-efi package
3 | ----------------------------------------------------
4 | June 2001
5 |
6 | As of version 3.0, the gnu-efi package is now split in two different packages:
7 |
8 | -> gnu-efi-X.y: contains the EFI library, include files and crt0.
9 |
10 | -> elilo-X.y : contains the ELILO bootloader.
11 |
12 | Note that X.y don't need to match for both packages. However elilo-3.x
13 | requires at least gnu-efi-3.0. EFI support for x86_64 is provided in
14 | gnu-efi-3.0d.
15 |
16 | Both packages can be downloaded from:
17 |
18 | http://www.sf.net/projects/gnu-efi
19 | http://www.sf.net/projects/elilo
20 |
--------------------------------------------------------------------------------
/gnu-efi/README.git:
--------------------------------------------------------------------------------
1 | README.git
2 |
3 | Generating releases from git a very simple process;
4 |
5 | 1) Edit the file "Makefile". Changing the "VERSION" line to the new version.
6 | 2) Do a "git commit" just for the version number change.
7 | 3) Then do a "make test-archive".
8 | That will make a file in the current directory gnu-efi-$VERSION.tar.bz2 ,
9 | with its top level directory gnu-efi-$VERSION/ and the source tree under that.
10 |
11 | Once you've tested that and you're sure it's what you want to release,
12 | 4) Do "make archive", which will tag a release in git and generate a
13 | final tarball from it.
14 |
15 | You then push to the archive, being sure to include the tag:
16 | 5) "git push origin master:master --tags"
17 |
18 | And upload the archive wherever it's supposed to go.
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/gnu-efi/apps/drv0.h:
--------------------------------------------------------------------------------
1 | #ifndef _GNU_EFI_APPS_DRV0_H_
2 | #define _GNU_EFI_APPS_DRV0_H_
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | /* UEFI naming conventions */
9 | #define GNU_EFI_APPS_DRV0_PROTOCOL_GUID \
10 | { 0xe4dcafd0, 0x586c, 0x4b3d, {0x86, 0xe7, 0x28, 0xde, 0x7f, 0xcc, 0x04, 0xb9} }
11 |
12 | INTERFACE_DECL(_GNU_EFI_APPS_DRV0_PROTOCOL);
13 |
14 | typedef
15 | EFI_STATUS
16 | (EFIAPI *GNU_EFI_APPS_DRV0_SAY_HELLO) (
17 | IN const CHAR16 *HelloWho
18 | );
19 |
20 | typedef
21 | EFI_STATUS
22 | (EFIAPI *GNU_EFI_APPS_DRV0_GET_NUMBER_OF_HELLO) (
23 | OUT UINTN *NumberOfHello
24 | );
25 |
26 | typedef struct _GNU_EFI_APPS_DRV0_PROTOCOL {
27 | GNU_EFI_APPS_DRV0_SAY_HELLO SayHello;
28 | GNU_EFI_APPS_DRV0_GET_NUMBER_OF_HELLO GetNumberOfHello;
29 | } GNU_EFI_APPS_DRV0_PROTOCOL;
30 |
31 | #ifdef __cplusplus
32 | }
33 | #endif
34 |
35 | #endif
36 |
--------------------------------------------------------------------------------
/gnu-efi/apps/exit.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | EFI_STATUS
5 | efi_main (EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab)
6 | {
7 | InitializeLib(image_handle, systab);
8 |
9 | Exit(EFI_SUCCESS, 0, NULL);
10 |
11 | return EFI_UNSUPPORTED;
12 | }
13 |
--------------------------------------------------------------------------------
/gnu-efi/apps/printenv.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | EFI_STATUS
5 | efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
6 | {
7 | EFI_STATUS status;
8 | CHAR16 name[256], *val, fmt[20];
9 | EFI_GUID vendor;
10 | UINTN size;
11 |
12 | InitializeLib(image, systab);
13 |
14 | name[0] = 0;
15 | vendor = NullGuid;
16 |
17 | Print(L"GUID Variable Name Value\n");
18 | Print(L"=================================== ==================== ========\n");
19 |
20 | StrCpy(fmt, L"%.-35g %.-20s %s\n");
21 | while (1) {
22 | size = sizeof(name);
23 | status = uefi_call_wrapper(RT->GetNextVariableName, 3, &size, name, &vendor);
24 | if (status != EFI_SUCCESS)
25 | break;
26 |
27 | val = LibGetVariable(name, &vendor);
28 | Print(fmt, &vendor, name, val);
29 | FreePool(val);
30 | }
31 | return EFI_SUCCESS;
32 | }
33 |
--------------------------------------------------------------------------------
/gnu-efi/apps/setjmp.c:
--------------------------------------------------------------------------------
1 |
2 | #include
3 | #include
4 | #include
5 |
6 | EFI_STATUS
7 | efi_main(
8 | EFI_HANDLE image_handle,
9 | EFI_SYSTEM_TABLE *systab
10 | )
11 | {
12 | jmp_buf env;
13 | int rc;
14 |
15 | InitializeLib(image_handle, systab);
16 | rc = setjmp(env);
17 | Print(L"setjmp() = %d\n", rc);
18 |
19 | if (rc == 3) {
20 | Print(L"3 worked\n");
21 | longjmp(env, 0);
22 | return 0;
23 | }
24 |
25 | if (rc == 1) {
26 | Print(L"0 got to be one yay\n");
27 | return 0;
28 | }
29 |
30 | longjmp(env, 3);
31 | return 0;
32 | }
33 |
--------------------------------------------------------------------------------
/gnu-efi/apps/t.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | static CHAR16 *
5 | a2u (char *str)
6 | {
7 | static CHAR16 mem[2048];
8 | int i;
9 |
10 | for (i = 0; str[i]; ++i)
11 | mem[i] = (CHAR16) str[i];
12 | mem[i] = 0;
13 | return mem;
14 | }
15 |
16 | EFI_STATUS
17 | efi_main (EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab)
18 | {
19 | SIMPLE_TEXT_OUTPUT_INTERFACE *conout;
20 |
21 | InitializeLib(image_handle, systab);
22 | conout = systab->ConOut;
23 | uefi_call_wrapper(conout->OutputString, 2, conout, (CHAR16 *)L"Hello World!\n\r");
24 | uefi_call_wrapper(conout->OutputString, 2, conout, a2u("Hello World!\n\r"));
25 |
26 | return EFI_SUCCESS;
27 | }
28 |
--------------------------------------------------------------------------------
/gnu-efi/apps/t2.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | EFI_STATUS
5 | efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
6 | {
7 | SIMPLE_TEXT_OUTPUT_INTERFACE *conout;
8 |
9 | InitializeLib(image, systab);
10 | conout = systab->ConOut;
11 | uefi_call_wrapper(conout->OutputString, 2, conout, L"Hello World!\n\r");
12 |
13 | return EFI_SUCCESS;
14 | }
15 |
--------------------------------------------------------------------------------
/gnu-efi/apps/t4.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | EFI_STATUS
5 | efi_main (EFI_HANDLE *image, EFI_SYSTEM_TABLE *systab)
6 | {
7 | UINTN index;
8 |
9 | InitializeLib(image, systab);
10 | uefi_call_wrapper(systab->ConOut->OutputString, 2, systab->ConOut, L"Hello application started\r\n");
11 | uefi_call_wrapper(systab->ConOut->OutputString, 2, systab->ConOut, L"\r\n\r\n\r\nHit any key to exit\r\n");
12 | uefi_call_wrapper(systab->BootServices->WaitForEvent, 3, 1, &systab->ConIn->WaitForKey, &index);
13 | return EFI_SUCCESS;
14 | }
15 |
--------------------------------------------------------------------------------
/gnu-efi/apps/t5.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | EFI_STATUS
5 | efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
6 | {
7 | InitializeLib(image, systab);
8 | Print(L"HelloLib application started\n");
9 | Print(L"\n\n\nHit any key to exit this image\n");
10 | WaitForSingleEvent(ST->ConIn->WaitForKey, 0);
11 | uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, L"\n\n");
12 | return EFI_SUCCESS;
13 | }
14 |
--------------------------------------------------------------------------------
/gnu-efi/apps/t6.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | typedef EFI_STATUS (*foo_t)(EFI_HANDLE, EFI_GUID *, VOID **);
5 | typedef struct {
6 | unsigned long addr;
7 | unsigned long gp;
8 | } fdesc_t;
9 |
10 | EFI_LOADED_IMAGE my_loaded;
11 |
12 | EFI_STATUS
13 | efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
14 | {
15 | EFI_LOADED_IMAGE *loaded_image = NULL;
16 | #if 0
17 | EFI_DEVICE_PATH *dev_path;
18 | #endif
19 | EFI_STATUS status;
20 |
21 | InitializeLib(image, systab);
22 | status = uefi_call_wrapper(systab->BootServices->HandleProtocol,
23 | 3,
24 | image,
25 | &LoadedImageProtocol,
26 | (void **) &loaded_image);
27 | if (EFI_ERROR(status)) {
28 | Print(L"handleprotocol: %r\n", status);
29 | }
30 |
31 | #if 0
32 | BS->HandleProtocol(loaded_image->DeviceHandle, &DevicePathProtocol, (void **) &dev_path);
33 |
34 | Print(L"Image device : %s\n", DevicePathToStr(dev_path));
35 | Print(L"Image file : %s\n", DevicePathToStr(loaded_image->FilePath));
36 | #endif
37 | Print(L"Image base : %lx\n", loaded_image->ImageBase);
38 | Print(L"Image size : %lx\n", loaded_image->ImageSize);
39 | Print(L"Load options size : %lx\n", loaded_image->LoadOptionsSize);
40 | Print(L"Load options : %s\n", loaded_image->LoadOptions);
41 |
42 | return EFI_SUCCESS;
43 | }
44 |
--------------------------------------------------------------------------------
/gnu-efi/apps/t7.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | EFI_STATUS
5 | efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
6 | {
7 | EFI_INPUT_KEY efi_input_key;
8 | EFI_STATUS efi_status;
9 |
10 | InitializeLib(image, systab);
11 |
12 | Print(L"HelloLib application started\n");
13 |
14 | Print(L"\n\n\nHit any key to exit this image\n");
15 | WaitForSingleEvent(ST->ConIn->WaitForKey, 0);
16 |
17 | uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, L"\n\n");
18 |
19 | efi_status = uefi_call_wrapper(ST->ConIn->ReadKeyStroke, 2, ST->ConIn, &efi_input_key);
20 |
21 | Print(L"ScanCode: %xh UnicodeChar: %xh CallRtStatus: %x\n",
22 | efi_input_key.ScanCode, efi_input_key.UnicodeChar, efi_status);
23 |
24 | return EFI_SUCCESS;
25 | }
26 |
--------------------------------------------------------------------------------
/gnu-efi/apps/t8.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | EFI_STATUS
5 | efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
6 | {
7 | INTN Argc, i;
8 | CHAR16 **Argv;
9 |
10 | InitializeLib(ImageHandle, SystemTable);
11 | Argc = GetShellArgcArgv(ImageHandle, &Argv);
12 |
13 | Print(L"Hello World, started with Argc=%d\n", Argc);
14 | for (i = 0 ; i < Argc ; ++i)
15 | Print(L" Argv[%d] = '%s'\n", i, Argv[i]);
16 |
17 | Print(L"Bye.\n");
18 | return EFI_SUCCESS;
19 | }
20 |
--------------------------------------------------------------------------------
/gnu-efi/apps/tpause.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | EFI_STATUS
5 | efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
6 | {
7 | Print(L"Press `q' to quit, any other key to continue:\n");
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/gnu-efi/apps/trivial.S:
--------------------------------------------------------------------------------
1 | .text
2 | .align 4
3 |
4 | .globl _start
5 | _start:
6 | #if 0
7 | pushl %ebp
8 | movl %esp,%ebp
9 | pushl %ebx # save ebx
10 | movl 12(%ebp),%eax # eax <- systab
11 | movl 24(%eax),%ebx # ebx <- systab->FirmwareVendor
12 | pushl %ebx
13 | movl 44(%eax),%ebx # ebx <- systab->ConOut
14 | pushl %ebx
15 | movl 4(%ebx),%eax # eax <- conout->OutputString
16 | call *%eax
17 | movl -4(%ebp),%ebx # restore ebx
18 | leave
19 | ret
20 |
21 | #else
22 |
23 | pushl %ebp
24 | movl %esp,%ebp
25 | pushl %ebx
26 | call 0f
27 | 0: popl %eax
28 | addl $hello-0b,%eax
29 | pushl %eax
30 | movl 12(%ebp),%eax # eax <- systab
31 | movl 44(%eax),%ebx # ebx <- systab->ConOut
32 | pushl %ebx
33 | movl 4(%ebx),%eax # eax <- conout->OutputString
34 | call *%eax
35 | movl -4(%ebp),%ebx
36 | leave
37 | ret
38 |
39 | .section .rodata
40 | .align 2
41 | hello: .byte 'h',0,'e',0,'l',0,'l',0,'o',0,'\n',0,'\r',0,0,0
42 |
43 | #endif
44 |
--------------------------------------------------------------------------------
/gnu-efi/gnuefi/elf_aarch64_efi.lds:
--------------------------------------------------------------------------------
1 | OUTPUT_FORMAT("elf64-littleaarch64", "elf64-littleaarch64", "elf64-littleaarch64")
2 | OUTPUT_ARCH(aarch64)
3 | ENTRY(_start)
4 | SECTIONS
5 | {
6 | .text 0x0 : {
7 | _text = .;
8 | *(.text.head)
9 | *(.text)
10 | *(.text.*)
11 | *(.gnu.linkonce.t.*)
12 | *(.srodata)
13 | *(.rodata*)
14 | . = ALIGN(16);
15 | }
16 | _etext = .;
17 | _text_size = . - _text;
18 | .dynamic : { *(.dynamic) }
19 | .data : ALIGN(4096)
20 | {
21 | _data = .;
22 | *(.sdata)
23 | *(.data)
24 | *(.data1)
25 | *(.data.*)
26 | *(.got.plt)
27 | *(.got)
28 |
29 | /* the EFI loader doesn't seem to like a .bss section, so we stick
30 | it all into .data: */
31 | . = ALIGN(16);
32 | _bss = .;
33 | *(.sbss)
34 | *(.scommon)
35 | *(.dynbss)
36 | *(.bss)
37 | *(COMMON)
38 | . = ALIGN(16);
39 | _bss_end = .;
40 | }
41 |
42 | .rela.dyn : { *(.rela.dyn) }
43 | .rela.plt : { *(.rela.plt) }
44 | .rela.got : { *(.rela.got) }
45 | .rela.data : { *(.rela.data) *(.rela.data*) }
46 | . = ALIGN(512);
47 | _edata = .;
48 | _data_size = . - _data;
49 |
50 | . = ALIGN(4096);
51 | .dynsym : { *(.dynsym) }
52 | . = ALIGN(4096);
53 | .dynstr : { *(.dynstr) }
54 | . = ALIGN(4096);
55 | .note.gnu.build-id : { *(.note.gnu.build-id) }
56 | /DISCARD/ :
57 | {
58 | *(.rel.reloc)
59 | *(.eh_frame)
60 | *(.note.GNU-stack)
61 | }
62 | .comment 0 : { *(.comment) }
63 | }
64 |
--------------------------------------------------------------------------------
/gnu-efi/gnuefi/elf_arm_efi.lds:
--------------------------------------------------------------------------------
1 | OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
2 | OUTPUT_ARCH(arm)
3 | ENTRY(_start)
4 | SECTIONS
5 | {
6 | .text 0x0 : {
7 | _text = .;
8 | *(.text.head)
9 | *(.text)
10 | *(.text.*)
11 | *(.gnu.linkonce.t.*)
12 | *(.srodata)
13 | *(.rodata*)
14 | . = ALIGN(16);
15 | }
16 | _etext = .;
17 | _text_size = . - _text;
18 | .dynamic : { *(.dynamic) }
19 | .data :
20 | {
21 | _data = .;
22 | *(.sdata)
23 | *(.data)
24 | *(.data1)
25 | *(.data.*)
26 | *(.got.plt)
27 | *(.got)
28 |
29 | /* the EFI loader doesn't seem to like a .bss section, so we stick
30 | it all into .data: */
31 | . = ALIGN(16);
32 | _bss = .;
33 | *(.sbss)
34 | *(.scommon)
35 | *(.dynbss)
36 | *(.bss)
37 | *(.bss.*)
38 | *(COMMON)
39 | . = ALIGN(16);
40 | _bss_end = .;
41 | }
42 |
43 | .rel.dyn : { *(.rel.dyn) }
44 | .rel.plt : { *(.rel.plt) }
45 | .rel.got : { *(.rel.got) }
46 | .rel.data : { *(.rel.data) *(.rel.data*) }
47 | _edata = .;
48 | _data_size = . - _etext;
49 |
50 | . = ALIGN(4096);
51 | .dynsym : { *(.dynsym) }
52 | . = ALIGN(4096);
53 | .dynstr : { *(.dynstr) }
54 | . = ALIGN(4096);
55 | .note.gnu.build-id : { *(.note.gnu.build-id) }
56 | /DISCARD/ :
57 | {
58 | *(.rel.reloc)
59 | *(.eh_frame)
60 | *(.note.GNU-stack)
61 | }
62 | .comment 0 : { *(.comment) }
63 | }
64 |
--------------------------------------------------------------------------------
/gnu-efi/gnuefi/elf_ia64_efi.lds:
--------------------------------------------------------------------------------
1 | OUTPUT_FORMAT("elf64-ia64-little")
2 | OUTPUT_ARCH(ia64)
3 | ENTRY(_start_plabel)
4 | SECTIONS
5 | {
6 | . = 0;
7 | ImageBase = .;
8 | /* .hash and/or .gnu.hash MUST come first! */
9 | .hash : { *(.hash) }
10 | .gnu.hash : { *(.gnu.hash) }
11 | . = ALIGN(4096);
12 | .text :
13 | {
14 | _text = .;
15 | *(.text)
16 | *(.text.*)
17 | *(.gnu.linkonce.t.*)
18 | . = ALIGN(16);
19 | }
20 | _etext = .;
21 | _text_size = . - _text;
22 | . = ALIGN(4096);
23 | __gp = ALIGN (8) + 0x200000;
24 | .sdata :
25 | {
26 | _data = .;
27 | *(.got.plt)
28 | *(.got)
29 | *(.srodata)
30 | *(.sdata)
31 | *(.sbss)
32 | *(.scommon)
33 | }
34 | . = ALIGN(4096);
35 | .data :
36 | {
37 | *(.rodata*)
38 | *(.ctors)
39 | *(.data*)
40 | *(.gnu.linkonce.d*)
41 | *(.plabel) /* data whose relocs we want to ignore */
42 | /* the EFI loader doesn't seem to like a .bss section, so we stick
43 | it all into .data: */
44 | *(.dynbss)
45 | *(.bss)
46 | *(COMMON)
47 | }
48 | .note.gnu.build-id : { *(.note.gnu.build-id) }
49 |
50 | . = ALIGN(4096);
51 | .dynamic : { *(.dynamic) }
52 | . = ALIGN(4096);
53 | .rela :
54 | {
55 | *(.rela.text)
56 | *(.rela.data*)
57 | *(.rela.sdata)
58 | *(.rela.got)
59 | *(.rela.gnu.linkonce.d*)
60 | *(.rela.stab)
61 | *(.rela.ctors)
62 | }
63 | _edata = .;
64 | _data_size = . - _etext;
65 | . = ALIGN(4096);
66 | .reloc : /* This is the PECOFF .reloc section! */
67 | {
68 | *(.reloc)
69 | }
70 | . = ALIGN(4096);
71 | .dynsym : { *(.dynsym) }
72 | . = ALIGN(4096);
73 | .dynstr : { *(.dynstr) }
74 | /DISCARD/ :
75 | {
76 | *(.rela.plabel)
77 | *(.rela.reloc)
78 | *(.IA_64.unwind*)
79 | *(.IA64.unwind*)
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/gnu-efi/gnuefi/elf_mips64el_efi.lds:
--------------------------------------------------------------------------------
1 | OUTPUT_FORMAT("elf64-tradlittlemips", "elf64-tradbigmips", "elf64-tradlittlemips")
2 | OUTPUT_ARCH(mips)
3 | ENTRY(_start)
4 | SECTIONS
5 | {
6 | .text 0x0 : {
7 | _text = .;
8 | *(.text.head)
9 | *(.text)
10 | *(.text.*)
11 | *(.gnu.linkonce.t.*)
12 | *(.srodata)
13 | *(.rodata*)
14 | . = ALIGN(16);
15 | }
16 | _etext = .;
17 | _text_size = . - _text;
18 | .dynamic : { *(.dynamic) }
19 | .data :
20 | {
21 | _data = .;
22 | *(.sdata)
23 | *(.data)
24 | *(.data1)
25 | *(.data.*)
26 | *(.got.plt)
27 | HIDDEN (_gp = ALIGN (16) + 0x7ff0);
28 | *(.got)
29 |
30 | /* the EFI loader doesn't seem to like a .bss section, so we stick
31 | it all into .data: */
32 | . = ALIGN(16);
33 | _bss = .;
34 | *(.sbss)
35 | *(.scommon)
36 | *(.dynbss)
37 | *(.bss)
38 | *(COMMON)
39 | . = ALIGN(16);
40 | _bss_end = .;
41 | }
42 |
43 | .rel.dyn : { *(.rel.dyn) }
44 | .rel.plt : { *(.rel.plt) }
45 | .rel.got : { *(.rel.got) }
46 | .rel.data : { *(.rel.data) *(.rel.data*) }
47 | _edata = .;
48 | _data_size = . - _etext;
49 |
50 | . = ALIGN(4096);
51 | .dynsym : { *(.dynsym) }
52 | . = ALIGN(4096);
53 | .dynstr : { *(.dynstr) }
54 | . = ALIGN(4096);
55 | .note.gnu.build-id : { *(.note.gnu.build-id) }
56 | /DISCARD/ :
57 | {
58 | *(.rel.reloc)
59 | *(.eh_frame)
60 | *(.MIPS.abiflags)
61 | *(.note.GNU-stack)
62 | }
63 | .comment 0 : { *(.comment) }
64 | }
65 |
--------------------------------------------------------------------------------
/gnu-efi/gnuefi/elf_x86_64_efi.lds:
--------------------------------------------------------------------------------
1 | /* Same as elf_x86_64_fbsd_efi.lds, except for OUTPUT_FORMAT below - KEEP IN SYNC */
2 | OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
3 | OUTPUT_ARCH(i386:x86-64)
4 | ENTRY(_start)
5 | SECTIONS
6 | {
7 | . = 0;
8 | ImageBase = .;
9 | /* .hash and/or .gnu.hash MUST come first! */
10 | .hash : { *(.hash) }
11 | .gnu.hash : { *(.gnu.hash) }
12 | . = ALIGN(4096);
13 | .eh_frame :
14 | {
15 | *(.eh_frame)
16 | }
17 | . = ALIGN(4096);
18 | .text :
19 | {
20 | _text = .;
21 | *(.text)
22 | *(.text.*)
23 | *(.gnu.linkonce.t.*)
24 | . = ALIGN(16);
25 | }
26 | _etext = .;
27 | _text_size = . - _text;
28 | . = ALIGN(4096);
29 | .reloc :
30 | {
31 | *(.reloc)
32 | }
33 | . = ALIGN(4096);
34 | .data :
35 | {
36 | _data = .;
37 | *(.rodata*)
38 | *(.got.plt)
39 | *(.got)
40 | *(.data*)
41 | *(.sdata)
42 | /* the EFI loader doesn't seem to like a .bss section, so we stick
43 | it all into .data: */
44 | *(.sbss)
45 | *(.scommon)
46 | *(.dynbss)
47 | *(.bss)
48 | *(COMMON)
49 | *(.rel.local)
50 | }
51 | .note.gnu.build-id : { *(.note.gnu.build-id) }
52 |
53 | _edata = .;
54 | _data_size = . - _etext;
55 | . = ALIGN(4096);
56 | .dynamic : { *(.dynamic) }
57 | . = ALIGN(4096);
58 | .rela :
59 | {
60 | *(.rela.data*)
61 | *(.rela.got)
62 | *(.rela.stab)
63 | }
64 | . = ALIGN(4096);
65 | .dynsym : { *(.dynsym) }
66 | . = ALIGN(4096);
67 | .dynstr : { *(.dynstr) }
68 | . = ALIGN(4096);
69 | .ignored.reloc :
70 | {
71 | *(.rela.reloc)
72 | *(.eh_frame)
73 | *(.note.GNU-stack)
74 | }
75 | .comment 0 : { *(.comment) }
76 | }
77 |
--------------------------------------------------------------------------------
/gnu-efi/gnuefi/elf_x86_64_fbsd_efi.lds:
--------------------------------------------------------------------------------
1 | /* Same as elf_x86_64_efi.lds, except for OUTPUT_FORMAT below - KEEP IN SYNC */
2 | OUTPUT_FORMAT("elf64-x86-64-freebsd", "elf64-x86-64-freebsd", "elf64-x86-64-freebsd")
3 | OUTPUT_ARCH(i386:x86-64)
4 | ENTRY(_start)
5 | SECTIONS
6 | {
7 | . = 0;
8 | ImageBase = .;
9 | /* .hash and/or .gnu.hash MUST come first! */
10 | .hash : { *(.hash) }
11 | .gnu.hash : { *(.gnu.hash) }
12 | . = ALIGN(4096);
13 | .eh_frame :
14 | {
15 | *(.eh_frame)
16 | }
17 | . = ALIGN(4096);
18 | .text :
19 | {
20 | _text = .;
21 | *(.text)
22 | . = ALIGN(16);
23 | }
24 | _etext = .;
25 | _text_size = . - _text;
26 | .reloc :
27 | {
28 | *(.reloc)
29 | }
30 | . = ALIGN(4096);
31 | .data :
32 | {
33 | _data = .;
34 | *(.rodata*)
35 | *(.got.plt)
36 | *(.got)
37 | *(.data*)
38 | *(.sdata)
39 | /* the EFI loader doesn't seem to like a .bss section, so we stick
40 | it all into .data: */
41 | *(.sbss)
42 | *(.scommon)
43 | *(.dynbss)
44 | *(.bss)
45 | *(COMMON)
46 | *(.rel.local)
47 | }
48 | .note.gnu.build-id : { *(.note.gnu.build-id) }
49 |
50 | . = ALIGN(4096);
51 | .dynamic : { *(.dynamic) }
52 | . = ALIGN(4096);
53 | .rela :
54 | {
55 | *(.rela.data*)
56 | *(.rela.got)
57 | *(.rela.stab)
58 | }
59 | _edata = .;
60 | _data_size = . - _etext;
61 | . = ALIGN(4096);
62 | .dynsym : { *(.dynsym) }
63 | . = ALIGN(4096);
64 | .dynstr : { *(.dynstr) }
65 | . = ALIGN(4096);
66 | .ignored.reloc :
67 | {
68 | *(.rela.reloc)
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/gnu-efi/inc/Makefile:
--------------------------------------------------------------------------------
1 | SRCDIR = .
2 |
3 | VPATH = $(SRCDIR)
4 |
5 | include $(SRCDIR)/../Make.defaults
6 |
7 | TOPDIR = $(SRCDIR)/..
8 |
9 | CDIR=$(TOPDIR)/..
10 |
11 | all:
12 |
13 | clean:
14 |
15 | install:
16 | mkdir -p $(INSTALLROOT)$(PREFIX)/include/efi
17 | mkdir -p $(INSTALLROOT)$(PREFIX)/include/efi/protocol
18 | mkdir -p $(INSTALLROOT)$(PREFIX)/include/efi/$(ARCH)
19 | $(INSTALL) -m 644 $(SRCDIR)/*.h $(INSTALLROOT)$(PREFIX)/include/efi
20 | $(INSTALL) -m 644 $(SRCDIR)/protocol/*.h $(INSTALLROOT)$(PREFIX)/include/efi/protocol
21 | $(INSTALL) -m 644 $(SRCDIR)/$(ARCH)/*.h $(INSTALLROOT)$(PREFIX)/include/efi/$(ARCH)
22 | ifeq ($(ARCH),ia64)
23 | mkdir -p $(INSTALLROOT)$(PREFIX)/include/efi/protocol/ia64
24 | $(INSTALL) -m 644 $(SRCDIR)/protocol/ia64/*.h $(INSTALLROOT)$(PREFIX)/include/efi/protocol/ia64
25 | endif
26 |
27 | include $(SRCDIR)/../Make.rules
28 |
--------------------------------------------------------------------------------
/gnu-efi/inc/aarch64/efilibplat.h:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1998 Intel Corporation
4 |
5 | Module Name:
6 |
7 | efilibplat.h
8 |
9 | Abstract:
10 |
11 | EFI to compile bindings
12 |
13 |
14 |
15 |
16 | Revision History
17 |
18 | --*/
19 |
20 | VOID
21 | InitializeLibPlatform (
22 | IN EFI_HANDLE ImageHandle,
23 | IN EFI_SYSTEM_TABLE *SystemTable
24 | );
25 |
26 |
--------------------------------------------------------------------------------
/gnu-efi/inc/aarch64/efisetjmp_arch.h:
--------------------------------------------------------------------------------
1 | #ifndef GNU_EFI_AARCH64_SETJMP_H
2 | #define GNU_EFI_AARCH64_SETJMP_H
3 |
4 | #define JMPBUF_ALIGN 8
5 |
6 | typedef struct {
7 | /* GP regs */
8 | UINT64 X19;
9 | UINT64 X20;
10 | UINT64 X21;
11 | UINT64 X22;
12 | UINT64 X23;
13 | UINT64 X24;
14 | UINT64 X25;
15 | UINT64 X26;
16 | UINT64 X27;
17 | UINT64 X28;
18 | UINT64 FP;
19 | UINT64 LR;
20 | UINT64 IP0;
21 |
22 | /* FP regs */
23 | UINT64 D8;
24 | UINT64 D9;
25 | UINT64 D10;
26 | UINT64 D11;
27 | UINT64 D12;
28 | UINT64 D13;
29 | UINT64 D14;
30 | UINT64 D15;
31 | } ALIGN(JMPBUF_ALIGN) jmp_buf[1];
32 |
33 | #endif /* GNU_EFI_AARCH64_SETJMP_H */
34 |
--------------------------------------------------------------------------------
/gnu-efi/inc/arm/efilibplat.h:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1998 Intel Corporation
4 |
5 | Module Name:
6 |
7 | efilibplat.h
8 |
9 | Abstract:
10 |
11 | EFI to compile bindings
12 |
13 |
14 |
15 |
16 | Revision History
17 |
18 | --*/
19 |
20 | VOID
21 | InitializeLibPlatform (
22 | IN EFI_HANDLE ImageHandle,
23 | IN EFI_SYSTEM_TABLE *SystemTable
24 | );
25 |
26 |
--------------------------------------------------------------------------------
/gnu-efi/inc/arm/efisetjmp_arch.h:
--------------------------------------------------------------------------------
1 | #ifndef GNU_EFI_ARM_SETJMP_H
2 | #define GNU_EFI_ARM_SETJMP_H
3 |
4 | #define JMPBUF_ALIGN 4
5 |
6 | typedef struct {
7 | UINT32 R3; // A copy of R13
8 | UINT32 R4;
9 | UINT32 R5;
10 | UINT32 R6;
11 | UINT32 R7;
12 | UINT32 R8;
13 | UINT32 R9;
14 | UINT32 R10;
15 | UINT32 R11;
16 | UINT32 R12;
17 | UINT32 R13;
18 | UINT32 R14;
19 | } ALIGN(JMPBUF_ALIGN) jmp_buf[1];
20 |
21 | #endif /* GNU_EFI_ARM_SETJMP_H */
22 |
--------------------------------------------------------------------------------
/gnu-efi/inc/efi.h:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1998 Intel Corporation
4 |
5 | Module Name:
6 |
7 | efi.h
8 |
9 | Abstract:
10 |
11 | Public EFI header files
12 |
13 |
14 |
15 | Revision History
16 |
17 | --*/
18 |
19 |
20 | // Add a predefined macro to detect usage of the library
21 | #ifndef _GNU_EFI
22 | #define _GNU_EFI
23 | #endif
24 |
25 | //
26 | // Build flags on input
27 | // EFI32
28 | // EFI_DEBUG - Enable debugging code
29 | // EFI_NT_EMULATOR - Building for running under NT
30 | //
31 |
32 |
33 | #ifndef _EFI_INCLUDE_
34 | #define _EFI_INCLUDE_
35 |
36 | #define EFI_FIRMWARE_VENDOR L"INTEL"
37 | #define EFI_FIRMWARE_MAJOR_REVISION 12
38 | #define EFI_FIRMWARE_MINOR_REVISION 33
39 | #define EFI_FIRMWARE_REVISION ((EFI_FIRMWARE_MAJOR_REVISION <<16) | (EFI_FIRMWARE_MINOR_REVISION))
40 |
41 | #include "efibind.h"
42 | #include "eficompiler.h"
43 | #include "efidef.h"
44 | #include "efidevp.h"
45 | #include "efipciio.h"
46 | #include "efiprot.h"
47 | #include "eficon.h"
48 | #include "efiser.h"
49 | #include "efi_nii.h"
50 | #include "efipxebc.h"
51 | #include "efinet.h"
52 | #include "efiapi.h"
53 | #include "efifs.h"
54 | #include "efierr.h"
55 | #include "efiui.h"
56 | #include "efiip.h"
57 | #include "efiudp.h"
58 | #include "efitcp.h"
59 | #include "efipoint.h"
60 |
61 | #endif
62 |
--------------------------------------------------------------------------------
/gnu-efi/inc/eficompiler.h:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 2016 Pete Batard
4 |
5 | Module Name:
6 |
7 | eficompiler.h
8 |
9 | Abstract:
10 |
11 | Compiler specific adjustments
12 |
13 | --*/
14 |
15 | #ifdef _MSC_EXTENSIONS
16 | #define EFI_UNUSED
17 | #else
18 | #define EFI_UNUSED __attribute__((__unused__))
19 | #endif
20 |
21 | #ifdef _MSC_EXTENSIONS
22 | #define ALIGN(x) __declspec(align(x))
23 | #else
24 | #define ALIGN(x) __attribute__((__aligned__(x)))
25 | #endif
26 |
27 | /* Also add a catch-all on __attribute__() for MS compilers */
28 | #ifdef _MSC_EXTENSIONS
29 | #define __attribute__(x)
30 | #endif
31 |
--------------------------------------------------------------------------------
/gnu-efi/inc/efipart.h:
--------------------------------------------------------------------------------
1 | #ifndef _EFI_PART_H
2 | #define _EFI_PART_H
3 |
4 | /*++
5 |
6 | Copyright (c) 1998 Intel Corporation
7 |
8 | Module Name:
9 |
10 | efipart.h
11 |
12 | Abstract:
13 | Info about disk partitions and Master Boot Records
14 |
15 |
16 |
17 |
18 | Revision History
19 |
20 | --*/
21 |
22 | //
23 | //
24 | //
25 |
26 | #define EFI_PARTITION 0xef
27 | #define MBR_SIZE 512
28 |
29 | #pragma pack(1)
30 |
31 | typedef struct {
32 | UINT8 BootIndicator;
33 | UINT8 StartHead;
34 | UINT8 StartSector;
35 | UINT8 StartTrack;
36 | UINT8 OSIndicator;
37 | UINT8 EndHead;
38 | UINT8 EndSector;
39 | UINT8 EndTrack;
40 | UINT8 StartingLBA[4];
41 | UINT8 SizeInLBA[4];
42 | } MBR_PARTITION_RECORD;
43 |
44 | #define EXTRACT_UINT32(D) (UINT32)(D[0] | (D[1] << 8) | (D[2] << 16) | (D[3] << 24))
45 |
46 | #define MBR_SIGNATURE 0xaa55
47 | #define MIN_MBR_DEVICE_SIZE 0x80000
48 | #define MBR_ERRATA_PAD 0x40000 // 128 MB
49 |
50 | #define MAX_MBR_PARTITIONS 4
51 | typedef struct {
52 | UINT8 BootStrapCode[440];
53 | UINT8 UniqueMbrSignature[4];
54 | UINT8 Unknown[2];
55 | MBR_PARTITION_RECORD Partition[MAX_MBR_PARTITIONS];
56 | UINT16 Signature;
57 | } MASTER_BOOT_RECORD;
58 | #pragma pack()
59 |
60 |
61 | #endif
62 |
--------------------------------------------------------------------------------
/gnu-efi/inc/efisetjmp.h:
--------------------------------------------------------------------------------
1 | #ifndef GNU_EFI_SETJMP_H
2 | #define GNU_EFI_SETJMP_H
3 |
4 | #include "eficompiler.h"
5 | #include "efisetjmp_arch.h"
6 |
7 | extern UINTN setjmp(jmp_buf env) __attribute__((returns_twice));
8 | extern VOID longjmp(jmp_buf env, UINTN value) __attribute__((noreturn));
9 |
10 | #endif /* GNU_EFI_SETJMP_H */
11 |
--------------------------------------------------------------------------------
/gnu-efi/inc/efistdarg.h:
--------------------------------------------------------------------------------
1 | #ifndef _EFISTDARG_H_
2 | #define _EFISTDARG_H_
3 |
4 | /*++
5 |
6 | Copyright (c) 1998 Intel Corporation
7 |
8 | Module Name:
9 |
10 | devpath.h
11 |
12 | Abstract:
13 |
14 | Defines for parsing the EFI Device Path structures
15 |
16 |
17 |
18 | Revision History
19 |
20 | --*/
21 |
22 | #ifndef GNU_EFI_USE_EXTERNAL_STDARG
23 | typedef __builtin_va_list va_list;
24 |
25 | # define va_start(v,l) __builtin_va_start(v,l)
26 | # define va_end(v) __builtin_va_end(v)
27 | # define va_arg(v,l) __builtin_va_arg(v,l)
28 | # define va_copy(d,s) __builtin_va_copy(d,s)
29 | #else
30 | # include
31 | #endif
32 |
33 | #endif
34 |
--------------------------------------------------------------------------------
/gnu-efi/inc/efiui.h:
--------------------------------------------------------------------------------
1 | #ifndef _EFI_UI_H
2 | #define _EFI_UI_H
3 |
4 | /*++
5 |
6 | Copyright (c) 200 Intel Corporation
7 |
8 | Module Name:
9 |
10 | EfiUi.h
11 |
12 | Abstract:
13 | Protocol used to build User Interface (UI) stuff.
14 |
15 | This protocol is just data. It is a multi dimentional array.
16 | For each string there is an array of UI_STRING_ENTRY. Each string
17 | is for a different language translation of the same string. The list
18 | is terminated by a NULL UiString. There can be any number of
19 | UI_STRING_ENTRY arrays. A NULL array terminates the list. A NULL array
20 | entry contains all zeros.
21 |
22 | Thus the shortest possible EFI_UI_PROTOCOL has three UI_STRING_ENTRY.
23 | The String, it's NULL terminator, and the NULL terminator for the entire
24 | thing.
25 |
26 |
27 | Revision History
28 |
29 | --*/
30 |
31 | #define EFI_UI_INTERFACE_PROTOCOL_GUID \
32 | { 0x32dd7981, 0x2d27, 0x11d4, {0xbc, 0x8b, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81} }
33 | #define EFI_UI_PROTOCOL EFI_UI_INTERFACE_PROTOCOL_GUID
34 |
35 |
36 | typedef enum {
37 | UiDeviceString,
38 | UiVendorString,
39 | UiMaxString
40 | } UI_STRING_TYPE;
41 |
42 | typedef struct {
43 | ISO_639_2 *LangCode;
44 | CHAR16 *UiString;
45 | } UI_STRING_ENTRY;
46 |
47 | #define EFI_UI_INTERFACE_PROTOCOL_VERSION 0x00010000
48 | #define EFI_UI_VERSION EFI_UI_INTERFACE_PROTOCOL_VERSION
49 |
50 | typedef struct _EFI_UI_INTERFACE_PROTOCOL {
51 | UINT32 Version;
52 | UI_STRING_ENTRY *Entry;
53 | } EFI_UI_INTERFACE_PROTOCOL;
54 |
55 | typedef struct _EFI_UI_INTERFACE_PROTOCOL _UI_INTERFACE;
56 | typedef EFI_UI_INTERFACE_PROTOCOL UI_INTERFACE;
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------
/gnu-efi/inc/ia32/efilibplat.h:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1998 Intel Corporation
4 |
5 | Module Name:
6 |
7 | efilibplat.h
8 |
9 | Abstract:
10 |
11 | EFI to compile bindings
12 |
13 |
14 |
15 |
16 | Revision History
17 |
18 | --*/
19 |
20 | VOID
21 | InitializeLibPlatform (
22 | IN EFI_HANDLE ImageHandle,
23 | IN EFI_SYSTEM_TABLE *SystemTable
24 | );
25 |
26 |
27 |
--------------------------------------------------------------------------------
/gnu-efi/inc/ia32/efisetjmp_arch.h:
--------------------------------------------------------------------------------
1 | #ifndef GNU_EFI_IA32_SETJMP_H
2 | #define GNU_EFI_IA32_SETJMP_H
3 |
4 | #define JMPBUF_ALIGN 4
5 |
6 | typedef struct {
7 | UINT32 Ebx;
8 | UINT32 Esi;
9 | UINT32 Edi;
10 | UINT32 Ebp;
11 | UINT32 Esp;
12 | UINT32 Eip;
13 | } ALIGN(JMPBUF_ALIGN) jmp_buf[1];
14 |
15 | #endif /* GNU_EFI_IA32_SETJMP_H */
16 |
--------------------------------------------------------------------------------
/gnu-efi/inc/ia64/efilibplat.h:
--------------------------------------------------------------------------------
1 | #ifndef _EFI_LIB_PLAT_H
2 | #define _EFI_LIB_PLAT_H
3 | /*++
4 |
5 | Copyright (c) 1998 Intel Corporation
6 |
7 | Module Name:
8 |
9 | efilibplat.h
10 |
11 | Abstract:
12 |
13 | EFI to compile bindings
14 |
15 |
16 |
17 | Revision History
18 |
19 | --*/
20 |
21 | #include "salproc.h"
22 |
23 |
24 | VOID
25 | InitializeLibPlatform (
26 | IN EFI_HANDLE ImageHandle,
27 | IN EFI_SYSTEM_TABLE *SystemTable
28 | );
29 |
30 | VOID
31 | LibInitSalAndPalProc(
32 | OUT PLABEL *SalPlabel,
33 | OUT UINT64 *PalEntry
34 | );
35 |
36 | EFI_STATUS
37 | LibGetSalIoPortMapping (
38 | OUT UINT64 *IoPortMapping
39 | );
40 |
41 | EFI_STATUS
42 | LibGetSalIpiBlock (
43 | OUT UINT64 *IpiBlock
44 | );
45 |
46 | EFI_STATUS
47 | LibGetSalWakeupVector (
48 | OUT UINT64 *WakeVector
49 | );
50 |
51 | VOID *
52 | LibSearchSalSystemTable (
53 | IN UINT8 EntryType
54 | );
55 |
56 |
57 | VOID
58 | LibSalProc (
59 | IN UINT64 Arg1,
60 | IN UINT64 Arg2,
61 | IN UINT64 Arg3,
62 | IN UINT64 Arg4,
63 | IN UINT64 Arg5,
64 | IN UINT64 Arg6,
65 | IN UINT64 Arg7,
66 | IN UINT64 Arg8,
67 | OUT rArg *Results OPTIONAL
68 | );
69 |
70 | VOID
71 | LibPalProc (
72 | IN UINT64 Arg1,
73 | IN UINT64 Arg2,
74 | IN UINT64 Arg3,
75 | IN UINT64 Arg4,
76 | OUT rArg *Results OPTIONAL
77 | );
78 |
79 | #endif
80 |
81 |
--------------------------------------------------------------------------------
/gnu-efi/inc/ia64/efisetjmp_arch.h:
--------------------------------------------------------------------------------
1 | #ifndef GNU_EFI_IA64_SETJMP_H
2 | #define GNU_EFI_IA64_SETJMP_H
3 |
4 | #define JMPBUF_ALIGN 0x10
5 |
6 | typedef struct {
7 | UINT64 F2[2];
8 | UINT64 F3[2];
9 | UINT64 F4[2];
10 | UINT64 F5[2];
11 | UINT64 F16[2];
12 | UINT64 F17[2];
13 | UINT64 F18[2];
14 | UINT64 F19[2];
15 | UINT64 F20[2];
16 | UINT64 F21[2];
17 | UINT64 F22[2];
18 | UINT64 F23[2];
19 | UINT64 F24[2];
20 | UINT64 F25[2];
21 | UINT64 F26[2];
22 | UINT64 F27[2];
23 | UINT64 F28[2];
24 | UINT64 F29[2];
25 | UINT64 F30[2];
26 | UINT64 F31[2];
27 | UINT64 R4;
28 | UINT64 R5;
29 | UINT64 R6;
30 | UINT64 R7;
31 | UINT64 SP;
32 | UINT64 BR0;
33 | UINT64 BR1;
34 | UINT64 BR2;
35 | UINT64 BR3;
36 | UINT64 BR4;
37 | UINT64 BR5;
38 | UINT64 InitialUNAT;
39 | UINT64 AfterSpillUNAT;
40 | UINT64 PFS;
41 | UINT64 BSP;
42 | UINT64 Predicates;
43 | UINT64 LoopCount;
44 | UINT64 FPSR;
45 | } ALIGN(JMPBUF_ALIGN) jmp_buf[1];
46 |
47 | #endif /* GNU_EFI_IA64_SETJMP_H */
48 |
--------------------------------------------------------------------------------
/gnu-efi/inc/inc.mak:
--------------------------------------------------------------------------------
1 |
2 |
3 | INC_DEPS = $(INC_DEPS) \
4 | efi.h \
5 | efiapi.h \
6 | efibind.h \
7 | eficon.h \
8 | efidebug.h \
9 | efidef.h \
10 | efidevp.h \
11 | efierr.h \
12 | efifs.h \
13 | efilib.h \
14 | efipart.h \
15 | efipciio.h \
16 | efiprot.h \
17 | efipxe.h \
18 | efivar.h \
19 | pe.h \
20 | efiip.h \
21 | efiudp.h \
22 | efitcp.h \
23 | stdarg.h
24 |
--------------------------------------------------------------------------------
/gnu-efi/inc/make.inf:
--------------------------------------------------------------------------------
1 | #
2 | #
3 | #
4 |
5 | [sources]
6 | efi.h
7 | efiapi.h
8 | eficon.h
9 | efidebug.h
10 | efidef.h
11 | efidevp.h
12 | efierr.h
13 | efifs.h
14 | efilib.h
15 | efipart.h
16 | efipciio.h
17 | efiprot.h
18 | efipxebc.h
19 | efistdarg.h
20 | efinet.h
21 | efiip.h
22 | efiudp.h
23 | efitcp.h
24 |
25 | [ia32sources]
26 | efibind.h
27 | pe.h
28 | efilibplat.h
29 |
30 | [ia64sources]
31 | efibind.h
32 | pe.h
33 | efilibplat.h
34 |
--------------------------------------------------------------------------------
/gnu-efi/inc/makefile.hdr:
--------------------------------------------------------------------------------
1 |
2 | #
3 | # This is a machine generated file - DO NOT EDIT
4 | # Generated by genmake.exe
5 | # Generated from make.inf
6 | # Copyright (c) 1998 Intel Corporation
7 | #
8 |
9 | INC_DEPS = $(INC_DEPS) \
10 | $(SDK_INSTALL_DIR)\include\efi\efi.h \
11 | $(SDK_INSTALL_DIR)\include\efi\efiapi.h \
12 | $(SDK_INSTALL_DIR)\include\efi\eficon.h \
13 | $(SDK_INSTALL_DIR)\include\efi\efidebug.h \
14 | $(SDK_INSTALL_DIR)\include\efi\efidef.h \
15 | $(SDK_INSTALL_DIR)\include\efi\efidevp.h \
16 | $(SDK_INSTALL_DIR)\include\efi\efierr.h \
17 | $(SDK_INSTALL_DIR)\include\efi\efifs.h \
18 | $(SDK_INSTALL_DIR)\include\efi\efilib.h \
19 | $(SDK_INSTALL_DIR)\include\efi\efipart.h \
20 | $(SDK_INSTALL_DIR)\include\efi\efipciio.h \
21 | $(SDK_INSTALL_DIR)\include\efi\efiprot.h \
22 | $(SDK_INSTALL_DIR)\include\efi\efipxebc.h \
23 | $(SDK_INSTALL_DIR)\include\efi\efistdarg.h \
24 | $(SDK_INSTALL_DIR)\include\efi\efinet.h \
25 | $(SDK_INSTALL_DIR)\include\efi\efiip.h \
26 | $(SDK_INSTALL_DIR)\include\efi\efiudp.h \
27 | $(SDK_INSTALL_DIR)\include\efi\efitcp.h \
28 |
29 |
30 | !IF "$(PROCESSOR)" == "Ia32"
31 | INC_DEPS = $(INC_DEPS) \
32 | $(SDK_INSTALL_DIR)\include\efi\Ia32\efibind.h \
33 | $(SDK_INSTALL_DIR)\include\efi\Ia32\pe.h \
34 | $(SDK_INSTALL_DIR)\include\efi\Ia32\efilibplat.h \
35 |
36 |
37 | !ENDIF
38 |
39 |
40 | !IF "$(PROCESSOR)" == "Ia64"
41 | INC_DEPS = $(INC_DEPS) \
42 | $(SDK_INSTALL_DIR)\include\efi\Ia64\efibind.h \
43 | $(SDK_INSTALL_DIR)\include\efi\Ia64\pe.h \
44 | $(SDK_INSTALL_DIR)\include\efi\Ia64\efilibplat.h \
45 |
46 |
47 | !ENDIF
48 |
49 |
--------------------------------------------------------------------------------
/gnu-efi/inc/mips64el/efilibplat.h:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1998 Intel Corporation
4 |
5 | Module Name:
6 |
7 | efilibplat.h
8 |
9 | Abstract:
10 |
11 | EFI to compile bindings
12 |
13 |
14 |
15 |
16 | Revision History
17 |
18 | --*/
19 |
20 | VOID
21 | InitializeLibPlatform (
22 | IN EFI_HANDLE ImageHandle,
23 | IN EFI_SYSTEM_TABLE *SystemTable
24 | );
25 |
26 |
--------------------------------------------------------------------------------
/gnu-efi/inc/mips64el/efisetjmp_arch.h:
--------------------------------------------------------------------------------
1 | #ifndef GNU_EFI_MIPS64EL_SETJMP_H
2 | #define GNU_EFI_MIPS64EL_SETJMP_H
3 |
4 | #define JMPBUF_ALIGN 8
5 |
6 | typedef struct {
7 | /* GP regs */
8 | UINT64 RA;
9 | UINT64 SP;
10 | UINT64 FP;
11 | UINT64 GP;
12 | UINT64 S0;
13 | UINT64 S1;
14 | UINT64 S2;
15 | UINT64 S3;
16 | UINT64 S4;
17 | UINT64 S5;
18 | UINT64 S6;
19 | UINT64 S7;
20 |
21 | #ifdef __mips_hard_float
22 | /* FP regs */
23 | UINT64 F24;
24 | UINT64 F25;
25 | UINT64 F26;
26 | UINT64 F27;
27 | UINT64 F28;
28 | UINT64 F29;
29 | UINT64 F30;
30 | UINT64 F31;
31 | #endif
32 | } ALIGN(JMPBUF_ALIGN) jmp_buf[1];
33 |
34 | #endif /* GNU_EFI_MIPS64EL_SETJMP_H */
35 |
--------------------------------------------------------------------------------
/gnu-efi/inc/protocol/adapterdebug.h:
--------------------------------------------------------------------------------
1 | #ifndef _ADAPTER_DEBUG_H
2 | #define _ADAPTER_DEBUG_H
3 |
4 | /*++
5 |
6 | Copyright (c) 1999 Intel Corporation
7 |
8 | Module Name:
9 |
10 | AdapterDebug.h
11 |
12 | Abstract:
13 |
14 | Protocol to debug the EDD 3.0 enablement of BIOS option ROMs
15 |
16 |
17 |
18 | Revision History
19 |
20 | --*/
21 |
22 | // {82F86881-282B-11d4-BC7D-0080C73C8881}
23 | #define ADAPTER_DEBUG_PROTOCOL \
24 | { 0x82f86881, 0x282b, 0x11d4, {0xbc, 0x7d, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81} }
25 |
26 | //
27 | // This protocol points to the BIOS_LEGACY_DRIVE data structure
28 | // see edd.h for more details
29 | //
30 |
31 | #endif
32 |
33 |
--------------------------------------------------------------------------------
/gnu-efi/inc/protocol/eficonsplit.h:
--------------------------------------------------------------------------------
1 | #ifndef _EFI_CONFORK_H
2 | #define _EFI_CONFORK_H
3 | /*++
4 |
5 | Copyright (c) 1999 Intel Corporation
6 |
7 | Module Name:
8 |
9 | Abstract:
10 |
11 |
12 |
13 | Revision History
14 |
15 | --*/
16 |
17 |
18 |
19 | //
20 | // ConOut Forker Protocol
21 | //
22 |
23 | #define TEXT_OUT_SPLITER_PROTOCOL \
24 | { 0x56d830a0, 0x7e7a, 0x11d3, {0xbb, 0xa0, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
25 |
26 | #define ERROR_OUT_SPLITER_PROTOCOL \
27 | { 0xf0ba9039, 0x68f1, 0x425e, {0xaa, 0x7f, 0xd9, 0xaa, 0xf9, 0x1b, 0x82, 0xa1}}
28 |
29 | #define TEXT_IN_SPLITER_PROTOCOL \
30 | { 0xf9a3c550, 0x7fb5, 0x11d3, {0xbb, 0xa0, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
31 |
32 | #endif
33 |
--------------------------------------------------------------------------------
/gnu-efi/inc/protocol/intload.h:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1999 Intel Corporation
4 |
5 | Module Name:
6 |
7 | intload
8 |
9 | Abstract:
10 |
11 | EFI support for loading internally linked in apps
12 |
13 |
14 |
15 | Revision History
16 |
17 | --*/
18 |
19 | #ifndef _INTERNAL_LOAD_INCLUDE_
20 | #define _INTERNAL_LOAD_INCLUDE_
21 |
22 | // {D65A6B8C-71E5-4df0-A909-F0D2992B5AA9}
23 | #define INTERNAL_SHELL_GUID \
24 | { 0xd65a6b8c, 0x71e5, 0x4df0, {0xa9, 0x09, 0xf0, 0xd2, 0x99, 0x2b, 0x5a, 0xa9} }
25 |
26 |
27 | #endif
28 |
--------------------------------------------------------------------------------
/gnu-efi/inc/protocol/make.inf:
--------------------------------------------------------------------------------
1 | #
2 | #
3 | #
4 |
5 | [sources]
6 | efivar.h
7 | legacyboot.h
8 | VgaClass.h
9 | intload.h
10 |
11 | [ia32sources]
12 |
13 | [ia64sources]
14 |
--------------------------------------------------------------------------------
/gnu-efi/inc/protocol/makefile.hdr:
--------------------------------------------------------------------------------
1 |
2 | #
3 | # This is a machine generated file - DO NOT EDIT
4 | # Generated by genmake.exe
5 | # Generated from make.inf
6 | # Copyright (c) 1998 Intel Corporation
7 | #
8 |
9 | INC_DEPS = $(INC_DEPS) \
10 | $(SDK_INSTALL_DIR)\include\efi\protocol\efivar.h \
11 | $(SDK_INSTALL_DIR)\include\efi\protocol\legacyboot.h \
12 | $(SDK_INSTALL_DIR)\include\efi\protocol\vgaclass.h \
13 | $(SDK_INSTALL_DIR)\include\efi\protocol\efidbg.h \
14 |
15 |
16 | !IF "$(PROCESSOR)" == "Ia32"
17 | INC_DEPS = $(INC_DEPS) \
18 |
19 |
20 | !ENDIF
21 |
22 |
23 | !IF "$(PROCESSOR)" == "Ia64"
24 | INC_DEPS = $(INC_DEPS) \
25 | $(SDK_INSTALL_DIR)\include\efi\protocol\$(PROCESSOR)\eficontext.h \
26 |
27 |
28 | !ENDIF
29 |
30 |
--------------------------------------------------------------------------------
/gnu-efi/inc/protocol/readme.txt:
--------------------------------------------------------------------------------
1 | The protocol directory contains non Architectural
2 | Protocols that span the FW, Platform, or application
3 | space.
--------------------------------------------------------------------------------
/gnu-efi/inc/romload.h:
--------------------------------------------------------------------------------
1 | #ifndef _EFI_ROMLOAD_H
2 | #define _EFI_ROMLOAD_H
3 |
4 | #define ROM_SIGNATURE 0xaa55
5 | #define PCIDS_SIGNATURE "PCIR"
6 | #pragma pack(push)
7 | #pragma pack(1)
8 | typedef struct
9 | {
10 | UINT8 Pcids_Sig[4];
11 | UINT16 VendId;
12 | UINT16 DevId;
13 | UINT16 Vpd_Off;
14 | UINT16 Size;
15 | UINT8 Rev;
16 | UINT8 Class_Code[3];
17 | UINT16 Image_Len;
18 | UINT16 Rev_Lvl;
19 | UINT8 Code_Type;
20 | UINT8 Indi;
21 | UINT16 Rsvd;
22 | }PciDataStructure;
23 | typedef struct
24 | {
25 | UINT16 Size;
26 | UINT32 Header_Sig;
27 | UINT16 SubSystem;
28 | UINT16 MachineType;
29 | UINT8 Resvd[10];
30 | UINT16 EfiOffset;
31 | }ArchData;
32 | typedef struct
33 | {
34 | UINT16 Rom_Sig;
35 | ArchData Arch_Data;
36 | UINT16 Pcids_Off;
37 | UINT8 resvd[38];
38 | }RomHeader;
39 | #pragma pack(pop)
40 |
41 | #endif
42 |
--------------------------------------------------------------------------------
/gnu-efi/inc/x86_64/efilibplat.h:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1998 Intel Corporation
4 |
5 | Module Name:
6 |
7 | efilibplat.h
8 |
9 | Abstract:
10 |
11 | EFI to compile bindings
12 |
13 |
14 |
15 |
16 | Revision History
17 |
18 | --*/
19 |
20 | VOID
21 | InitializeLibPlatform (
22 | IN EFI_HANDLE ImageHandle,
23 | IN EFI_SYSTEM_TABLE *SystemTable
24 | );
25 |
26 |
27 |
--------------------------------------------------------------------------------
/gnu-efi/inc/x86_64/efisetjmp_arch.h:
--------------------------------------------------------------------------------
1 | #ifndef GNU_EFI_X86_64_SETJMP_H
2 | #define GNU_EFI_X86_64_SETJMP_H
3 |
4 | #define JMPBUF_ALIGN 8
5 |
6 | typedef struct {
7 | UINT64 Rbx;
8 | UINT64 Rsp;
9 | UINT64 Rbp;
10 |
11 | UINT64 Rdi;
12 | UINT64 Rsi;
13 | UINT64 R12;
14 | UINT64 R13;
15 | UINT64 R14;
16 | UINT64 R15;
17 | UINT64 Rip;
18 | UINT64 MxCsr;
19 | UINT8 XmmBuffer[160]; // XMM6 - XMM15
20 | } ALIGN(JMPBUF_ALIGN) jmp_buf[1];
21 |
22 | #endif /* GNU_EFI_X86_64_SETJMP_H */
23 |
--------------------------------------------------------------------------------
/gnu-efi/lib/aarch64/efi_stub.S:
--------------------------------------------------------------------------------
1 | /* This stub is a stub to make the build happy */
2 |
--------------------------------------------------------------------------------
/gnu-efi/lib/aarch64/initplat.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copright (C) 2014 Linaro Ltd.
3 | * Author: Ard Biesheuvel
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | * 1. Redistributions of source code must retain the above copyright
9 | * notice and this list of conditions, without modification.
10 | * 2. The name of the author may not be used to endorse or promote products
11 | * derived from this software without specific prior written permission.
12 | *
13 | * Alternatively, this software may be distributed under the terms of the
14 | * GNU General Public License as published by the Free Software Foundation;
15 | * either version 2 of the License, or (at your option) any later version.
16 | */
17 |
18 | #include "lib.h"
19 |
20 | VOID
21 | InitializeLibPlatform (
22 | IN EFI_HANDLE ImageHandle EFI_UNUSED,
23 | IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED
24 | )
25 | {
26 | }
27 |
--------------------------------------------------------------------------------
/gnu-efi/lib/aarch64/setjmp.S:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
3 | * This program and the accompanying materials are licensed and made
4 | available
5 | * under the terms and conditions of the BSD License which accompanies
6 | this
7 | * distribution. The full text of the license may be found at
8 | * http://opensource.org/licenses/bsd-license.php.
9 | *
10 | * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
11 | BASIS,
12 | * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
13 | * IMPLIED.
14 | */
15 | .text
16 | .p2align 3
17 |
18 | #define GPR_LAYOUT \
19 | REG_PAIR (x19, x20, 0); \
20 | REG_PAIR (x21, x22, 16); \
21 | REG_PAIR (x23, x24, 32); \
22 | REG_PAIR (x25, x26, 48); \
23 | REG_PAIR (x27, x28, 64); \
24 | REG_PAIR (x29, x30, 80); \
25 | REG_ONE (x16, 96)
26 |
27 | #define FPR_LAYOUT \
28 | REG_PAIR(d8, d9, 112); \
29 | REG_PAIR(d10, d11, 128); \
30 | REG_PAIR(d12, d13, 144); \
31 | REG_PAIR(d14, d15, 160);
32 |
33 | #define REG_PAIR(REG1, REG2, OFFS) stp REG1, REG2, [x0, OFFS]
34 | #define REG_ONE(REG1, OFFS) str REG1, [x0, OFFS]
35 |
36 | .globl setjmp
37 | .type setjmp, @function
38 | setjmp:
39 | mov x16, sp
40 | GPR_LAYOUT
41 | FPR_LAYOUT
42 | mov w0, #0
43 | ret
44 |
45 | #undef REG_PAIR
46 | #undef REG_ONE
47 |
48 | #define REG_PAIR(REG1, REG2, OFFS) ldp REG1, REG2, [x0, OFFS]
49 | #define REG_ONE(REG1, OFFS) ldr REG1, [x0, OFFS]
50 |
51 | .globl longjmp
52 | .type longjmp, @function
53 | longjmp:
54 | GPR_LAYOUT
55 | FPR_LAYOUT
56 | mov sp, x16
57 | cmp w1, #0
58 | mov w0, #1
59 | csel w0, w1, w0, ne
60 | br x30
61 |
--------------------------------------------------------------------------------
/gnu-efi/lib/arm/edk2asm.h:
--------------------------------------------------------------------------------
1 |
2 | #define ASM_PFX(x) x
3 | #define GCC_ASM_EXPORT(x) \
4 | .globl x ; \
5 | .type x, %function
6 |
7 |
--------------------------------------------------------------------------------
/gnu-efi/lib/arm/efi_stub.S:
--------------------------------------------------------------------------------
1 | /* This stub is a stub to make the build happy */
2 |
--------------------------------------------------------------------------------
/gnu-efi/lib/arm/initplat.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copright (C) 2014 Linaro Ltd.
3 | * Author: Ard Biesheuvel
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | * 1. Redistributions of source code must retain the above copyright
9 | * notice and this list of conditions, without modification.
10 | * 2. The name of the author may not be used to endorse or promote products
11 | * derived from this software without specific prior written permission.
12 | *
13 | * Alternatively, this software may be distributed under the terms of the
14 | * GNU General Public License as published by the Free Software Foundation;
15 | * either version 2 of the License, or (at your option) any later version.
16 | */
17 |
18 | #include "lib.h"
19 |
20 | VOID
21 | InitializeLibPlatform (
22 | IN EFI_HANDLE ImageHandle EFI_UNUSED,
23 | IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED
24 | )
25 | {
26 | }
27 |
28 | #ifdef __GNUC__
29 | void __div0(void)
30 | {
31 | // TODO handle divide by zero fault
32 | while (1);
33 | }
34 | #endif
35 |
--------------------------------------------------------------------------------
/gnu-efi/lib/arm/ldivmod.S:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
4 | //
5 | // This program and the accompanying materials
6 | // are licensed and made available under the terms and conditions of the BSD License
7 | // which accompanies this distribution. The full text of the license may be found at
8 | // http://opensource.org/licenses/bsd-license.php
9 | //
10 | // THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 | //
13 | //------------------------------------------------------------------------------
14 |
15 |
16 | #include "edk2asm.h"
17 |
18 | .text
19 | .align 2
20 | GCC_ASM_EXPORT(__aeabi_ldivmod)
21 |
22 | //
23 | // A pair of (unsigned) long longs is returned in {{r0, r1}, {r2, r3}},
24 | // the quotient in {r0, r1}, and the remainder in {r2, r3}.
25 | //
26 | //__value_in_regs lldiv_t
27 | //EFIAPI
28 | //__aeabi_ldivmod (
29 | // IN UINT64 Dividen
30 | // IN UINT64 Divisor
31 | // )//
32 | //
33 |
34 | ASM_PFX(__aeabi_ldivmod):
35 | push {r4,lr}
36 | asrs r4,r1,#1
37 | eor r4,r4,r3,LSR #1
38 | bpl L_Test1
39 | rsbs r0,r0,#0
40 | rsc r1,r1,#0
41 | L_Test1:
42 | tst r3,r3
43 | bpl L_Test2
44 | rsbs r2,r2,#0
45 | rsc r3,r3,#0
46 | L_Test2:
47 | bl ASM_PFX(__aeabi_uldivmod)
48 | tst r4,#0x40000000
49 | beq L_Test3
50 | rsbs r0,r0,#0
51 | rsc r1,r1,#0
52 | L_Test3:
53 | tst r4,#0x80000000
54 | beq L_Exit
55 | rsbs r2,r2,#0
56 | rsc r3,r3,#0
57 | L_Exit:
58 | pop {r4,pc}
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/gnu-efi/lib/arm/llsl.S:
--------------------------------------------------------------------------------
1 | #------------------------------------------------------------------------------
2 | #
3 | # Copyright (c) 2013, ARM. All rights reserved.
4 | #
5 | # This program and the accompanying materials
6 | # are licensed and made available under the terms and conditions of the BSD License
7 | # which accompanies this distribution. The full text of the license may be found at
8 | # http://opensource.org/licenses/bsd-license.php
9 | #
10 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 | #
13 | #------------------------------------------------------------------------------
14 |
15 | #include "edk2asm.h"
16 |
17 | .text
18 | .align 2
19 | GCC_ASM_EXPORT(__aeabi_llsl)
20 |
21 | #
22 | #VOID
23 | #EFIAPI
24 | #__aeabi_llsl (
25 | # IN VOID *Destination,
26 | # IN VOID *Source,
27 | # IN UINT32 Size
28 | # );
29 | #
30 | ASM_PFX(__aeabi_llsl):
31 | subs r3,r2,#0x20
32 | bpl 1f
33 | rsb r3,r2,#0x20
34 | lsl r1,r1,r2
35 | orr r1,r1,r0,lsr r3
36 | lsl r0,r0,r2
37 | bx lr
38 | 1:
39 | lsl r1,r0,r3
40 | mov r0,#0
41 | bx lr
42 |
--------------------------------------------------------------------------------
/gnu-efi/lib/arm/llsr.S:
--------------------------------------------------------------------------------
1 | #------------------------------------------------------------------------------
2 | #
3 | # Copyright (c) 2013, ARM. All rights reserved.
4 | #
5 | # This program and the accompanying materials
6 | # are licensed and made available under the terms and conditions of the BSD License
7 | # which accompanies this distribution. The full text of the license may be found at
8 | # http://opensource.org/licenses/bsd-license.php
9 | #
10 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 | #
13 | #------------------------------------------------------------------------------
14 |
15 | #include "edk2asm.h"
16 |
17 | .text
18 | .align 2
19 | GCC_ASM_EXPORT(__aeabi_llsr)
20 |
21 | #
22 | #VOID
23 | #EFIAPI
24 | #__aeabi_llsr (
25 | # IN VOID *Destination,
26 | # IN VOID *Source,
27 | # IN UINT32 Size
28 | # );
29 | #
30 | ASM_PFX(__aeabi_llsr):
31 | subs r3,r2,#0x20
32 | bpl 1f
33 | rsb r3,r2,#0x20
34 | lsr r0,r0,r2
35 | orr r0,r0,r1,lsl r3
36 | lsr r1,r1,r2
37 | bx lr
38 | 1:
39 | lsr r0,r1,r3
40 | mov r1,#0
41 | bx lr
42 |
--------------------------------------------------------------------------------
/gnu-efi/lib/arm/mullu.S:
--------------------------------------------------------------------------------
1 | #------------------------------------------------------------------------------
2 | #
3 | # Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
4 | #
5 | # This program and the accompanying materials
6 | # are licensed and made available under the terms and conditions of the BSD License
7 | # which accompanies this distribution. The full text of the license may be found at
8 | # http://opensource.org/licenses/bsd-license.php
9 | #
10 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 | #
13 | #------------------------------------------------------------------------------
14 |
15 | #include "edk2asm.h"
16 |
17 | .text
18 | GCC_ASM_EXPORT(__aeabi_lmul)
19 | #
20 | #INT64
21 | #EFIAPI
22 | #__aeabi_lmul (
23 | # IN INT64 Multiplicand
24 | # IN INT64 Multiplier
25 | # );
26 | #
27 | ASM_PFX(__aeabi_lmul):
28 | stmdb sp!, {lr}
29 | mov lr, r0
30 | umull r0, ip, r2, lr
31 | mla r1, r2, r1, ip
32 | mla r1, r3, lr, r1
33 | ldmia sp!, {pc}
34 |
--------------------------------------------------------------------------------
/gnu-efi/lib/arm/setjmp.S:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
3 | * This program and the accompanying materials are licensed and made
4 | * available under the terms and conditions of the BSD License which
5 | * accompanies this distribution. The full text of the license may
6 | * be found at http://opensource.org/licenses/bsd-license.php.
7 | *
8 | * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
9 | * BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
10 | * EXPRESS OR IMPLIED.
11 | */
12 | .text
13 | .arm
14 | .globl setjmp
15 | .type setjmp, %function
16 | setjmp:
17 | mov r3, r13
18 | stmia r0, {r3-r12,r14}
19 | eor r0, r0, r0
20 | bx lr
21 |
22 | .globl longjmp
23 | .type longjmp, %function
24 | longjmp:
25 | ldmia r0, {r3-r12,r14}
26 |
--------------------------------------------------------------------------------
/gnu-efi/lib/debug.c:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1998 Intel Corporation
4 |
5 | Module Name:
6 |
7 | debug.c
8 |
9 | Abstract:
10 |
11 | Debug library functions
12 |
13 |
14 |
15 | Revision History
16 |
17 | --*/
18 |
19 | #include "lib.h"
20 |
21 |
22 |
23 | //
24 | // Declare runtime functions
25 | //
26 |
27 | //
28 | //
29 | //
30 |
31 | INTN
32 | DbgAssert (
33 | IN CONST CHAR8 *FileName,
34 | IN INTN LineNo,
35 | IN CONST CHAR8 *Description
36 | )
37 | {
38 | DbgPrint (D_ERROR, (CHAR8 *)"%EASSERT FAILED: %a(%d): %a%N\n", FileName, LineNo, Description);
39 |
40 | BREAKPOINT();
41 | return 0;
42 | }
43 |
44 |
--------------------------------------------------------------------------------
/gnu-efi/lib/exit.c:
--------------------------------------------------------------------------------
1 | #include "lib.h"
2 |
3 | VOID
4 | Exit(
5 | IN EFI_STATUS ExitStatus,
6 | IN UINTN ExitDataSize,
7 | IN CHAR16 *ExitData OPTIONAL
8 | )
9 | {
10 | uefi_call_wrapper(BS->Exit,
11 | 4,
12 | LibImageHandle,
13 | ExitStatus,
14 | ExitDataSize,
15 | ExitData);
16 |
17 | // Uh oh, Exit() returned?!
18 | for (;;) { }
19 | }
20 |
--------------------------------------------------------------------------------
/gnu-efi/lib/ia32/efi_stub.S:
--------------------------------------------------------------------------------
1 | /* This stub is a stub to make the build happy */
2 |
--------------------------------------------------------------------------------
/gnu-efi/lib/ia32/initplat.c:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1998 Intel Corporation
4 |
5 | Module Name:
6 |
7 | initplat.c
8 |
9 | Abstract:
10 |
11 |
12 |
13 |
14 | Revision History
15 |
16 | --*/
17 |
18 | #include "lib.h"
19 |
20 | VOID
21 | InitializeLibPlatform (
22 | IN EFI_HANDLE ImageHandle EFI_UNUSED,
23 | IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED
24 | )
25 | {
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/gnu-efi/lib/ia32/setjmp.S:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
3 | * This program and the accompanying materials are licensed and made
4 | available
5 | * under the terms and conditions of the BSD License which accompanies
6 | this
7 | * distribution. The full text of the license may be found at
8 | * http://opensource.org/licenses/bsd-license.php.
9 | *
10 | * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
11 | BASIS,
12 | * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
13 | * IMPLIED.
14 | */
15 | .text
16 | .globl setjmp
17 | #ifndef __MINGW32__
18 | .type setjmp, @function
19 | #else
20 | .def setjmp; .scl 2; .type 32; .endef
21 | #endif
22 | setjmp:
23 | pop %ecx
24 | movl (%esp), %edx
25 | movl %ebx, (%edx)
26 | movl %esi, 4(%edx)
27 | movl %edi, 8(%edx)
28 | movl %ebp, 12(%edx)
29 | movl %esp, 16(%edx)
30 | xorl %eax, %eax
31 | jmp *%ecx
32 |
33 | .globl longjmp
34 | #ifndef __MINGW32__
35 | .type longjmp, @function
36 | #else
37 | .def longjmp; .scl 2; .type 32; .endef
38 | #endif
39 | longjmp:
40 | pop %eax
41 | pop %edx
42 | pop %eax
43 | movl (%edx), %ebx
44 | movl 4(%edx), %esi
45 | movl 8(%edx), %edi
46 |
--------------------------------------------------------------------------------
/gnu-efi/lib/ia64/initplat.c:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1999 Intel Corporation
4 |
5 | Module Name:
6 |
7 | initplat.c
8 |
9 | Abstract:
10 |
11 | Functions to make SAL and PAL proc calls
12 |
13 | Revision History
14 |
15 | --*/
16 | #include "lib.h"
17 |
18 | //#include "palproc.h"
19 |
20 | VOID
21 | InitializeLibPlatform (
22 | IN EFI_HANDLE ImageHandle EFI_UNUSED,
23 | IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED
24 | )
25 | {
26 | PLABEL SalPlabel;
27 | UINT64 PalEntry;
28 |
29 | LibInitSalAndPalProc (&SalPlabel, &PalEntry);
30 | }
31 |
--------------------------------------------------------------------------------
/gnu-efi/lib/ia64/math.c:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1998 Intel Corporation
4 |
5 | Module Name:
6 |
7 | math.c
8 |
9 | Abstract:
10 |
11 |
12 |
13 |
14 | Revision History
15 |
16 | --*/
17 |
18 | #include "lib.h"
19 |
20 |
21 | //
22 | // Declare runtime functions
23 | //
24 |
25 | #ifdef RUNTIME_CODE
26 | #ifndef __GNUC__
27 | #pragma RUNTIME_CODE(LShiftU64)
28 | #pragma RUNTIME_CODE(RShiftU64)
29 | #pragma RUNTIME_CODE(MultU64x32)
30 | #pragma RUNTIME_CODE(DivU64x32)
31 | #endif
32 | #endif
33 |
34 | //
35 | //
36 | //
37 |
38 |
39 |
40 |
41 | UINT64
42 | LShiftU64 (
43 | IN UINT64 Operand,
44 | IN UINTN Count
45 | )
46 | // Left shift 64bit by 32bit and get a 64bit result
47 | {
48 | return Operand << Count;
49 | }
50 |
51 | UINT64
52 | RShiftU64 (
53 | IN UINT64 Operand,
54 | IN UINTN Count
55 | )
56 | // Right shift 64bit by 32bit and get a 64bit result
57 | {
58 | return Operand >> Count;
59 | }
60 |
61 |
62 | UINT64
63 | MultU64x32 (
64 | IN UINT64 Multiplicand,
65 | IN UINTN Multiplier
66 | )
67 | // Multiple 64bit by 32bit and get a 64bit result
68 | {
69 | return Multiplicand * Multiplier;
70 | }
71 |
72 | UINT64
73 | DivU64x32 (
74 | IN UINT64 Dividend,
75 | IN UINTN Divisor,
76 | OUT UINTN *Remainder OPTIONAL
77 | )
78 | // divide 64bit by 32bit and get a 64bit result
79 | // N.B. only works for 31bit divisors!!
80 | {
81 | ASSERT (Divisor != 0);
82 |
83 | if (Remainder) {
84 | *Remainder = Dividend % Divisor;
85 | }
86 |
87 | return Dividend / Divisor;
88 | }
89 |
--------------------------------------------------------------------------------
/gnu-efi/lib/ia64/palproc.h:
--------------------------------------------------------------------------------
1 | //
2 | //
3 | // Copyright (c) 1996-99 Intel Corp.
4 | //
5 | //
6 | //Module Name:
7 | //
8 | // palproc.h
9 | //
10 | //Abstract:
11 | //
12 | // This module contains generic macros for an IA64 assembly writer.
13 | //
14 | //
15 | //Revision History
16 | //
17 |
18 | #ifndef _PALPROC_H
19 | #define _PALPROC_H
20 |
21 | #define PROCEDURE_ENTRY(name) .##text; \
22 | .##type name, @function; \
23 | .##global name; \
24 | .##proc name; \
25 | name:
26 |
27 | #define PROCEDURE_EXIT(name) .##endp name
28 |
29 | // Note: use of NESTED_SETUP requires number of locals (l) >= 3
30 |
31 | #define NESTED_SETUP(i,l,o,r) \
32 | alloc loc1=ar##.##pfs,i,l,o,r ;\
33 | mov loc0=b0
34 |
35 | #define NESTED_RETURN \
36 | mov b0=loc0 ;\
37 | mov ar##.##pfs=loc1 ;;\
38 | br##.##ret##.##dpnt b0;;
39 |
40 |
41 | // defines needed in palproc.s
42 |
43 | #define PAL_MC_CLEAR_LOG 0x0015
44 | #define PAL_MC_DRAIN 0x0016
45 | #define PAL_MC_EXPECTED 0x0017
46 | #define PAL_MC_DYNAMIC_STATE 0x0018
47 | #define PAL_MC_ERROR_INFO 0x0019
48 | #define PAL_MC_RESUME 0x001a
49 | #define PAL_MC_REGISTER_MEM 0x001b
50 |
51 | #endif // _PALPROC_H
52 |
--------------------------------------------------------------------------------
/gnu-efi/lib/mips64el/efi_stub.S:
--------------------------------------------------------------------------------
1 | /* This stub is a stub to make the build happy */
2 |
--------------------------------------------------------------------------------
/gnu-efi/lib/mips64el/initplat.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copright (C) 2014 Linaro Ltd.
3 | * Author: Ard Biesheuvel
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | * 1. Redistributions of source code must retain the above copyright
9 | * notice and this list of conditions, without modification.
10 | * 2. The name of the author may not be used to endorse or promote products
11 | * derived from this software without specific prior written permission.
12 | *
13 | * Alternatively, this software may be distributed under the terms of the
14 | * GNU General Public License as published by the Free Software Foundation;
15 | * either version 2 of the License, or (at your option) any later version.
16 | */
17 |
18 | #include "lib.h"
19 |
20 | VOID
21 | InitializeLibPlatform (
22 | IN EFI_HANDLE ImageHandle EFI_UNUSED,
23 | IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED
24 | )
25 | {
26 | }
27 |
--------------------------------------------------------------------------------
/gnu-efi/lib/runtime/rtdata.c:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1998 Intel Corporation
4 |
5 | Module Name:
6 |
7 | data.c
8 |
9 | Abstract:
10 |
11 | EFI library global data
12 |
13 |
14 |
15 | Revision History
16 |
17 | --*/
18 |
19 | #include "lib.h"
20 |
21 |
22 | //
23 | // These globals are runtime globals
24 | //
25 | // N.B. The Microsoft C compiler will only put the data in the
26 | // right data section if it is explicitly initialized..
27 | //
28 |
29 | #ifndef __GNUC__
30 | #pragma BEGIN_RUNTIME_DATA()
31 | #endif
32 |
33 | //
34 | // RT - pointer to the runtime table
35 | //
36 |
37 | EFI_RUNTIME_SERVICES *RT;
38 |
39 | //
40 | // LibStandalone - TRUE if lib is linked in as part of the firmware.
41 | // N.B. The EFI fw sets this value directly
42 | //
43 |
44 | BOOLEAN LibFwInstance;
45 |
46 | //
47 | // EFIDebug - Debug mask
48 | //
49 |
50 | UINTN EFIDebug = EFI_DBUG_MASK;
51 |
52 | //
53 | // LibRuntimeDebugOut - Runtime Debug Output device
54 | //
55 |
56 | SIMPLE_TEXT_OUTPUT_INTERFACE *LibRuntimeDebugOut;
57 |
58 | //
59 | // LibRuntimeRaiseTPL, LibRuntimeRestoreTPL - pointers to Runtime functions from the
60 | // Boot Services Table
61 | //
62 |
63 | EFI_RAISE_TPL LibRuntimeRaiseTPL = NULL;
64 | EFI_RESTORE_TPL LibRuntimeRestoreTPL = NULL;
65 |
66 |
--------------------------------------------------------------------------------
/gnu-efi/lib/x86_64/initplat.c:
--------------------------------------------------------------------------------
1 | /*++
2 |
3 | Copyright (c) 1998 Intel Corporation
4 |
5 | Module Name:
6 |
7 | initplat.c
8 |
9 | Abstract:
10 |
11 |
12 |
13 |
14 | Revision History
15 |
16 | --*/
17 |
18 | #include "lib.h"
19 |
20 | VOID
21 | InitializeLibPlatform (
22 | IN EFI_HANDLE ImageHandle EFI_UNUSED,
23 | IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED
24 | )
25 | {
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/gnu-efi/lib/x86_64/setjmp.S:
--------------------------------------------------------------------------------
1 | .text
2 | .globl setjmp
3 | #ifndef __MINGW32__
4 | .type setjmp, @function
5 | #else
6 | .def setjmp; .scl 2; .type 32; .endef
7 | #endif
8 | setjmp:
9 | pop %rsi
10 | movq %rbx,0x00(%rdi)
11 | movq %rsp,0x08(%rdi)
12 | push %rsi
13 | movq %rbp,0x10(%rdi)
14 | movq %r12,0x18(%rdi)
15 | movq %r13,0x20(%rdi)
16 | movq %r14,0x28(%rdi)
17 | movq %r15,0x30(%rdi)
18 | movq %rsi,0x38(%rdi)
19 | xor %rax,%rax
20 | ret
21 |
22 | .globl longjmp
23 | #ifndef __MINGW32__
24 | .type longjmp, @function
25 | #else
26 | .def longjmp; .scl 2; .type 32; .endef
27 | #endif
28 | longjmp:
29 | movl %esi, %eax
30 | movq 0x00(%rdi), %rbx
31 | movq 0x08(%rdi), %rsp
32 | movq 0x10(%rdi), %rbp
33 | movq 0x18(%rdi), %r12
34 | movq 0x20(%rdi), %r13
35 | movq 0x28(%rdi), %r14
36 | movq 0x30(%rdi), %r15
37 | xor %rdx,%rdx
38 | mov $1,%rcx
39 | cmp %rax,%rdx
40 | cmove %rcx,%rax
41 | jmp *0x38(%rdi)
42 |
--------------------------------------------------------------------------------
/hello.txt:
--------------------------------------------------------------------------------
1 | Hello from Emacs! <3
2 |
--------------------------------------------------------------------------------
/kernel/res/dfltfont.psf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LensPlaysGames/LensorOS/02a4aa87c2daf6a575cf0811361e4fb5f3a0935b/kernel/res/dfltfont.psf
--------------------------------------------------------------------------------
/kernel/src/bitmap.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see
24 |
25 | class Bitmap {
26 | public:
27 | Bitmap() {}
28 |
29 | Bitmap(u64 size, u8* bufferAddress);
30 |
31 | void init(u64 size, u8* bufferAddress);
32 | u64 length() { return Size; }
33 | void* base() { return (void*)Buffer; };
34 |
35 | bool get(u64 index);
36 | bool set(u64 index, bool value);
37 |
38 | bool operator [] (u64 index);
39 |
40 | private:
41 | /* Number of bits within the bitmap. */
42 | u64 Size;
43 | /* Buffer to store bitmap within. */
44 | u8* Buffer;
45 | };
46 |
47 | #endif
48 |
--------------------------------------------------------------------------------
/kernel/src/boot.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see
24 | #include
25 | #include
26 | #include
27 |
28 | struct BootInfo {
29 | Framebuffer* framebuffer;
30 | PSF1_FONT* font;
31 | EFI_MEMORY_DESCRIPTOR* map;
32 | u64 mapSize;
33 | u64 mapDescSize;
34 | ACPI::RSDP2* rsdp;
35 | };
36 |
37 | #endif /* LENSOR_OS_BOOT_H */
38 |
--------------------------------------------------------------------------------
/kernel/src/cpuid.asm:
--------------------------------------------------------------------------------
1 | ;; Copyright 2022, Contributors To LensorOS.
2 | ;; All rights reserved.
3 | ;;
4 | ;; This file is part of LensorOS.
5 | ;;
6 | ;; LensorOS is free software: you can redistribute it and/or modify
7 | ;; it under the terms of the GNU General Public License as published by
8 | ;; the Free Software Foundation, either version 3 of the License, or
9 | ;; (at your option) any later version.
10 | ;;
11 | ;; LensorOS is distributed in the hope that it will be useful,
12 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | ;; GNU General Public License for more details.
15 | ;;
16 | ;; You should have received a copy of the GNU General Public License
17 | ;; along with LensorOS. If not, see
21 |
22 | const char to_hex_not_supported[] = "TYPE_NOT_SUPPORTED";
23 |
24 | extern "C" size_t strlen(const char* a) {
25 | size_t out = 0;
26 | while (true) {
27 | if (*a == '\0')
28 | return out + 1;
29 |
30 | ++a;
31 | ++out;
32 | }
33 | }
34 |
35 | bool strcmp(const char* a, const char* b, u64 length) {
36 | for (u64 i = 0; i < length; ++i) {
37 | if (*a != *b)
38 | return false;
39 |
40 | ++a;
41 | ++b;
42 | }
43 | return true;
44 | }
45 |
--------------------------------------------------------------------------------
/kernel/src/cstr.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see
24 | #include
25 |
26 | #ifndef LENSOR_OS_UART_HIDE_COLOR_CODES
27 | constexpr const char* trueString = "\033[32mTrue\033[0m";
28 | constexpr const char* falseString = "\033[31mFalse\033[0m";
29 | #else
30 | constexpr const char* trueString = "True";
31 | constexpr const char* falseString = "False";
32 | #endif /* #ifndef LENSOR_OS_UART_HIDE_COLOR_CODES */
33 |
34 | /* String Length
35 | * Returns the number of characters including null terminator.
36 | */
37 | extern "C" size_t strlen(const char* a);
38 |
39 | /* String Compare
40 | * Returns `true` only if all characters within
41 | * both strings up to length are exactly equal.
42 | */
43 | bool strcmp(const char* a, const char* b, u64 length);
44 |
45 | #endif
46 |
--------------------------------------------------------------------------------
/kernel/src/debug.cpp:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see
21 | #include
22 | #include
23 | #include
24 |
25 | void dbgmsg_buf(const u8* buffer, u64 byteCount) {
26 | UART::out(buffer, byteCount);
27 | }
28 |
29 | void dbgrainbow(std::string_view str, ShouldNewline nl) {
30 | for (u64 i = 0; i < str.size(); ++i) {
31 | std::print("\033[1;3{}m{}", i % 6 + 1, char(str[i]));
32 | }
33 | std::print("\033[0m");
34 | if (nl == ShouldNewline::Yes)
35 | std::print("\n");
36 | }
37 |
38 | void dbgrainbow(const char* str, ShouldNewline nl) {
39 | dbgrainbow(std::string_view{str}, nl);
40 | }
41 |
--------------------------------------------------------------------------------
/kernel/src/debug.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see
24 | #include
25 | #include
26 |
27 | enum class ShouldNewline {
28 | Yes = 0,
29 | No = 1
30 | };
31 |
32 | /// Print a number of bytes from a given buffer as characters.
33 | void dbgmsg_buf(const u8* buffer, u64 byteCount);
34 |
35 | /// Print a string with lots of colors (and no formatting)! Nyan debug :^)
36 | void dbgrainbow(std::string_view, ShouldNewline nl = ShouldNewline::No);
37 |
38 | /// Print a C-style null-terminated string in lots
39 | /// of colors (and no formatting)! Nyan debug :^)
40 | void dbgrainbow(const char* str, ShouldNewline nl = ShouldNewline::No);
41 |
42 | #endif /* LENSOR_OS_DEBUG_H */
43 |
--------------------------------------------------------------------------------
/kernel/src/efi_memory.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see
24 |
25 | // TODO: Move this struct into Memory namespace.
26 | struct EFI_MEMORY_DESCRIPTOR {
27 | u32 type;
28 | u32 pad;
29 | void* physicalAddress;
30 | void* virtualAddress;
31 | u64 numPages;
32 | u64 attributes;
33 | };
34 |
35 | namespace Memory {
36 | extern const char* EFI_MEMORY_TYPE_STRINGS[];
37 |
38 | void print_efi_memory_map(EFI_MEMORY_DESCRIPTOR* map, u64 mapSize, u64 entrySize);
39 | void print_efi_memory_map_summed(EFI_MEMORY_DESCRIPTOR* map, u64 mapSize, u64 entrySize);
40 | }
41 |
42 | #endif
43 |
--------------------------------------------------------------------------------
/kernel/src/gdt.asm:
--------------------------------------------------------------------------------
1 | ;; Copyright 2022, Contributors To LensorOS.
2 | ;; All rights reserved.
3 | ;;
4 | ;; This file is part of LensorOS.
5 | ;;
6 | ;; LensorOS is free software: you can redistribute it and/or modify
7 | ;; it under the terms of the GNU General Public License as published by
8 | ;; the Free Software Foundation, either version 3 of the License, or
9 | ;; (at your option) any later version.
10 | ;;
11 | ;; LensorOS is distributed in the hope that it will be useful,
12 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | ;; GNU General Public License for more details.
15 | ;;
16 | ;; You should have received a copy of the GNU General Public License
17 | ;; along with LensorOS. If not, see
21 |
22 | GDT gGDT;
23 | GDTDescriptor gGDTD;
24 |
25 | void setup_gdt() {
26 | // BASE LIMIT ACCESS FLAGS:LIMIT1
27 | gGDT.Null = { 0, 0, 0x00, 0x00 };
28 | gGDT.Ring0Code = { 0, 0xffffffff, 0b10011010, 0b10110000 };
29 | gGDT.Ring0Data = { 0, 0xffffffff, 0b10010010, 0b10110000 };
30 | gGDT.Ring3Code = { 0, 0xffffffff, 0b11111010, 0b10110000 };
31 | gGDT.Ring3Data = { 0, 0xffffffff, 0b11110010, 0b10110000 };
32 | gGDT.TSS = {{ 0, 0xffffffff, 0b10001001, 0b00100000 }};
33 | }
34 |
--------------------------------------------------------------------------------
/kernel/src/integers.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see
24 | #include
25 |
26 | /// Unsigned Integer Alias Declaration
27 | using uint = unsigned int;
28 |
29 | /// Fixed-Width Unsigned Integer Alias Declarations
30 | using u8 = uint8_t;
31 | using u16 = uint16_t;
32 | using u32 = uint32_t;
33 | using u64 = uint64_t;
34 | using usz = uintptr_t;
35 |
36 | /// Fixed-Width Signed Integer Alias Declarations
37 | using s8 = int8_t;
38 | using s16 = int16_t;
39 | using s32 = int32_t;
40 | using s64 = int64_t;
41 | using ssz = intptr_t;
42 |
43 | #endif
44 |
--------------------------------------------------------------------------------
/kernel/src/interrupts/syscalls.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see
24 |
25 | constexpr usz LENSOR_OS_NUM_SYSCALLS = 26;
26 | extern void* syscalls[LENSOR_OS_NUM_SYSCALLS];
27 |
28 | // Defined in `syscalls.cpp`
29 | // Used by `syscalls.asm`
30 | extern usz num_syscalls;
31 |
32 | // Defined in `syscalls.asm`
33 | extern "C" void system_call_handler_asm();
34 |
35 | #endif
36 |
--------------------------------------------------------------------------------
/kernel/src/io.cpp:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see
21 | #include
22 |
23 | void out8(u16 port, u8 value) {
24 | asm volatile ("outb %0, %1" : : "a"(value), "Nd"(port));
25 | }
26 |
27 | void out16(u16 port, u16 value) {
28 | asm volatile ("outw %0, %1" : : "a"(value), "Nd"(port));
29 | }
30 |
31 | void out32(u16 port, u32 value) {
32 | asm volatile ("outl %0, %1" : : "a"(value), "Nd"(port));
33 | }
34 |
35 | u8 in8(u16 port) {
36 | u8 retValue;
37 | asm volatile ("inb %1, %0" : "=a"(retValue) : "Nd"(port));
38 | return retValue;
39 | }
40 |
41 | u16 in16(u16 port) {
42 | u16 retValue;
43 | asm volatile ("inw %1, %0" : "=a"(retValue) : "Nd"(port));
44 | return retValue;
45 | }
46 |
47 | u32 in32(u16 port) {
48 | u32 retValue;
49 | asm volatile ("inl %1, %0" : "=a"(retValue) : "Nd"(port));
50 | return retValue;
51 | }
52 |
53 | void io_wait() {
54 | // Port 0x80 -- Unused port that is safe to read/write
55 | asm volatile ("outb %%al, $0x80" : : "a"(0));
56 | }
57 |
--------------------------------------------------------------------------------
/kernel/src/io.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see
24 |
25 | void out8 (u16 port, u8 value);
26 | u8 in8 (u16 port);
27 | void out16 (u16 port, u16 value);
28 | u16 in16 (u16 port);
29 | void out32 (u16 port, u32 value);
30 | u32 in32 (u16 port);
31 |
32 | /* By writing to a port that is known to be unused,
33 | * it is possible to 'delay' the CPU by a microsecond or two.
34 | * This is useful for 'slow' hardware (ie. RTC) that needs some
35 | * time for the serial operation to take effect.
36 | * Port 0x80 is used by BIOS for POST codes, and reading from/writing to
37 | * it is effectively guaranteed to not adversely affect the hardware.
38 | */
39 | void io_wait();
40 |
41 | #endif
42 |
--------------------------------------------------------------------------------
/kernel/src/kernel.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see
24 |
25 | extern "C" void kmain(BootInfo*);
26 |
27 | #endif /* LENSOR_OS_KERNEL_H */
28 |
--------------------------------------------------------------------------------
/kernel/src/keyboard_scancode_translation.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see
24 |
25 | namespace Keyboard {
26 | namespace QWERTY {
27 | /// For release counter-part, add 0x80.
28 | #define ESCAPE 0x01
29 | #define BACKSPACE 0x0e
30 | #define TAB 0x0f
31 | #define ENTER 0x1c
32 | #define LCONTROL 0x1d
33 | #define LSHIFT 0x2a
34 | #define RSHIFT 0x36
35 | #define LALT 0x38
36 | #define SPACE 0x39
37 | #define CAPSLOCK 0x3a
38 | #define NUMLOCK 0x45
39 | #define SCROLLLOCK 0x46
40 |
41 | /// Preceded by 'e0' byte.
42 | #define ARROW_UP 0x48
43 | #define ARROW_DOWN 0x50
44 | #define ARROW_LEFT 0x4b
45 | #define ARROW_RIGHT 0x4d
46 |
47 | extern const char ASCII[];
48 | char Translate(u8 scancode, bool capital);
49 | }
50 | }
51 | #endif
52 |
--------------------------------------------------------------------------------
/kernel/src/kstage1.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see
24 |
25 | void kstage1(BootInfo*);
26 |
27 | #endif /* LENSOR_OS_KSTAGE1_H */
28 |
--------------------------------------------------------------------------------
/kernel/src/link_definitions.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see
24 |
25 | extern u64 KERNEL_PHYSICAL;
26 | extern u64 KERNEL_VIRTUAL;
27 | extern u64 KERNEL_START;
28 | extern u64 KERNEL_END;
29 | extern u64 TEXT_START;
30 | extern u64 TEXT_END;
31 | extern u64 DATA_START;
32 | extern u64 DATA_END;
33 | extern u64 READ_ONLY_DATA_START;
34 | extern u64 READ_ONLY_DATA_END;
35 | extern u64 BLOCK_STARTING_SYMBOLS_START;
36 | extern u64 BLOCK_STARTING_SYMBOLS_END;
37 |
38 | #define V2P(addr) ((u64)(addr) - (u64)&KERNEL_VIRTUAL)
39 | #define P2V(addr) ((u64)(addr) + (u64)&KERNEL_VIRTUAL)
40 |
41 | #endif /* LENSOR_OS_LINK_DEFINITIONS_H */
42 |
--------------------------------------------------------------------------------
/kernel/src/memory.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see
25 |
26 | extern "C" void memset(void* src, u8 value , u64 numBytes);
27 | extern "C" int memcmp(const void* src, const void* dest, size_t numBytes);
28 | extern "C" void* memcpy(void* __restrict__ dest, const void* __restrict__ src, size_t numBytes);
29 | extern "C" void* memmove(void* destination, const void* source, size_t num);
30 |
31 | template
32 | T volatile_read(const volatile T* ptr) {
33 | return *ptr;
34 | }
35 |
36 | template
37 | void volatile_write(volatile T* dest, const T& value) {
38 | *dest = value;
39 | }
40 |
41 | #endif
42 |
--------------------------------------------------------------------------------
/kernel/src/memory/common.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see
24 |
25 | /// Get the compiler to shut up about the missing `_` somehow.
26 | /// Might just be clangd tho.
27 | /*
28 | size_t operator "" KiB(unsigned long long sz) {
29 | return sz << 10;
30 | }
31 | */
32 |
33 | #define KiB(x) ((u64)(x) << 10)
34 | #define MiB(x) ((u64)(x) << 20)
35 | #define GiB(x) ((u64)(x) << 30)
36 |
37 | #define TO_KiB(x) ((u64)(x) >> 10)
38 | #define TO_MiB(x) ((u64)(x) >> 20)
39 | #define TO_GiB(x) ((u64)(x) >> 30)
40 |
41 | constexpr usz PAGE_SIZE = 4096;
42 |
43 | #endif /* LENSOR_OS_MEMORY_COMMON_H */
44 |
--------------------------------------------------------------------------------
/kernel/src/memory/region.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see
24 | #include
25 |
26 | namespace Memory {
27 | struct Region {
28 | void* vaddr = 0;
29 | void* paddr = 0;
30 | usz length = 0;
31 | usz pages = 0;
32 | u64 flags = 0;
33 |
34 | Region(void* vaddress, void* paddress, usz bytes, u64 flag) {
35 | vaddr = vaddress;
36 | paddr = paddress;
37 | length = bytes;
38 | if ((bytes % PAGE_SIZE) == 0) {
39 | pages = bytes / PAGE_SIZE;
40 | } else {
41 | pages = 1 + (bytes / PAGE_SIZE);
42 | }
43 | flags = flag;
44 | }
45 | };
46 | }
47 |
48 | #endif
49 |
--------------------------------------------------------------------------------
/kernel/src/mouse.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see
32 | #include
33 |
34 | void init_ps2_mouse();
35 | void handle_ps2_mouse_interrupt(u8 data);
36 | void process_mouse_packet();
37 | // DRAW MOUSE CURSOR AT MOUSE POSITION USING GLOBAL RENDERER.
38 | void draw_mouse_cursor();
39 |
40 | // The mouse ID determines what features the mouse supports.
41 | // 0 = x, y, left, right, middle (3 bytes)
42 | // 3 = 0 + scroll data (4th byte)
43 | // 4 = 3 + 4th button, 5th button
44 | extern u8 gMouseID;
45 | extern Vector2 gMousePosition;
46 | extern Vector2 gOldMousePosition;
47 |
48 | #endif
49 |
--------------------------------------------------------------------------------
/kernel/src/panic.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see
21 |
22 | #include
23 |
24 | extern "C" void __cxa_pure_virtual() {
25 | panic("Pure virtual function called!");
26 | hang();
27 | }
28 |
--------------------------------------------------------------------------------
/kernel/src/pure_virtuals.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see
21 |
22 | #include
23 |
24 | LCG gRandomLCG;
25 |
26 | u64 LCG::get() {
27 | next();
28 | return state;
29 | }
30 |
31 | u64 LCG::get(u64 max) {
32 | if (max == 0)
33 | return 0;
34 | next();
35 | return state % max;
36 | }
37 |
38 | u64 LCG::get(u64 min, u64 max) {
39 | if (min == 0 || max == 0)
40 | return get(max);
41 | if (min >= max)
42 | min = max - 1;
43 | next();
44 | return (state % (max - min)) + min;
45 | }
46 |
--------------------------------------------------------------------------------
/kernel/src/random_lcg.h:
--------------------------------------------------------------------------------
1 | #ifndef LENSOR_OS_RANDOM_LINEAR_CONGRUENTIAL_GENERATOR_H
2 | #define LENSOR_OS_RANDOM_LINEAR_CONGRUENTIAL_GENERATOR_H
3 |
4 | #include
5 |
6 | class LCG {
7 | u64 state {0};
8 | public:
9 | inline void seed(u64 s) {
10 | state = s;
11 | }
12 |
13 | inline void next() {
14 | state = 1103515245 * state + 12345;
15 | }
16 |
17 | /// Get a random 64-bit number.
18 | u64 get();
19 | /// Get a random number between zero and given `max` (inclusive/exclusive).
20 | u64 get(u64 max);
21 | /// Get a random number between a given `min` and `max` (inclusive/exclusive).
22 | u64 get(u64 min, u64 max);
23 | };
24 |
25 | extern LCG gRandomLCG;
26 |
27 | #endif
28 |
--------------------------------------------------------------------------------
/kernel/src/system.cpp:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see
21 |
22 | System* SYSTEM { nullptr };
23 |
--------------------------------------------------------------------------------
/kernel/src/tests.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see
24 |
25 | void append_codepoint_as_utf8(std::string &appendee, u32 codepoint);
26 |
27 | // utf16 -> utf8
28 | // Fairly lax, will ignore most invalid utf16 in a best effort approach.
29 | auto utf16_to_utf8(std::string_view utf16) -> std::string;
30 |
31 | #endif /* LENSOR_OS_UTF_H */
32 |
--------------------------------------------------------------------------------
/kernel/src/va_list.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see
24 |
25 | enum struct ProcessFileDescriptor : FileDescriptor { Invalid = static_cast(-1) };
26 | enum struct GlobalFileDescriptor : FileDescriptor { Invalid = static_cast(-1) };
27 |
28 | using ProcFD = ProcessFileDescriptor;
29 | using SysFD = GlobalFileDescriptor;
30 |
31 | #endif // LENSOROS_VFS_FORWARD_H
32 |
--------------------------------------------------------------------------------
/kernel/src/x86_64/cpu.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see
24 | #include
25 |
26 | struct CPUState {
27 | u64 RSP;
28 | u64 RBX;
29 | u64 RCX;
30 | u64 RDX;
31 | u64 RSI;
32 | u64 RDI;
33 | u64 RBP;
34 | u64 R8;
35 | u64 R9;
36 | u64 R10;
37 | u64 R11;
38 | u64 R12;
39 | u64 R13;
40 | u64 R14;
41 | u64 R15;
42 | u64 FS;
43 | u64 GS;
44 | u64 RAX;
45 | InterruptFrame Frame;
46 | } __attribute__((packed));
47 |
48 | #endif // LENSOR_OS_X86_64_CPU_H
49 |
--------------------------------------------------------------------------------
/known_bugs.org:
--------------------------------------------------------------------------------
1 | * =ls /fs0/bin/= doesn't work
2 | Posted [2024-07-02 Tue 13:44]
3 | Bested [2024-07-02 Tue 16:10]
4 |
5 | Running =/fs0/bin/ls /fs0/bin/= doesn't work, I think because of the trailing slash. So, either =ls= user program or =directory_data= syscall has an issue handling the trailing slash. Maybe even just the FAT driver implementation.
6 |
7 | Update [2024-07-02 Tue 14:09]: It's definitely within the FAT implementation.
8 |
9 | - The Fix :: special case trailing separator in =pop_filename_from_front_of_path()=
10 |
11 | * =bg servertest=, =clienttest= on startup triple faults
12 | Posted [2024-06-24 Mon 16:22]
13 |
14 | Running `bg servertest` and then `clienttest` as the first and second commands upon boot, respectively, triple faults after the client? exits.
15 |
16 | Now, this wouldn't be so weird if all of the following didn't work just fine:
17 | - Calling any other program(s) (like `ls`) as the first or several first command(s) and then calling `bg servertest` then `clienttest`.
18 | - Calling `bg servertest` as the first command, then calling one or more other programs (like `ls`), then calling `clienttest`.
19 | - The mixture of the above two cases, calling another program, then `bg servertest`, then another program, then `clienttest`.
20 |
21 | Since all of those work, it's quite confusing as to what the nature of the bug actually is. I suspect that this will just magically go away one day as bugs get fixed, code gets rewritten, etc.
22 |
23 | What's for certain is it's all an absolute mess right now, and I'm surprised it functions at all.
24 |
--------------------------------------------------------------------------------
/scripts/buildrun.bat:
--------------------------------------------------------------------------------
1 | :: ASSUMES NINJA BUILD SYSTEM AND WORKING DIRECTORY OF ROOT OF REPOSITORY
2 |
3 | set PROC=
4 | for /f "delims=" %%a in ('echo %NUMBER_OF_PROCESSORS%') do @set PROC=%%a
5 |
6 | :: SYSTEM LIBRARIES
7 | cmake -G Ninja -S user/libc -B user/libc/winja
8 | if %errorlevel% neq 0 exit /b %errorlevel%
9 | cmake --build user/libc/winja --clean-first -- -j %PROC%
10 | if %errorlevel% neq 0 exit /b %errorlevel%
11 | :: USERSPACE PROGRAMS
12 | cmake -G Ninja -S user/blazeit -B user/blazeit/winja
13 | if %errorlevel% neq 0 exit /b %errorlevel%
14 | cmake --build user/blazeit/winja --clean-first -- -j %PROC%
15 | if %errorlevel% neq 0 exit /b %errorlevel%
16 | xcopy /y user\blazeit\winja\blazeit user\blazeit\blazeit
17 | if %errorlevel% neq 0 exit /b %errorlevel%
18 | cmake -G Ninja -S user/stdout -B user/stdout/winja
19 | if %errorlevel% neq 0 exit /b %errorlevel%
20 | cmake --build user/stdout/winja --clean-first -- -j %PROC%
21 | if %errorlevel% neq 0 exit /b %errorlevel%
22 | xcopy /y user\stdout\winja\stdout user\stdout\stdout
23 | if %errorlevel% neq 0 exit /b %errorlevel%
24 | cmake -G Ninja -S user/pwd -B user/pwd/winja
25 | if %errorlevel% neq 0 exit /b %errorlevel%
26 | cmake --build user/pwd/winja --clean-first -- -j %PROC%
27 | if %errorlevel% neq 0 exit /b %errorlevel%
28 | xcopy /y user\pwd\winja\pwd user\pwd\pwd
29 | if %errorlevel% neq 0 exit /b %errorlevel%
30 | :: KERNEL
31 | cmake -G Ninja -S kernel -B kernel/winja -DHIDE_UART_COLOR_CODES=OFF
32 | if %errorlevel% neq 0 exit /b %errorlevel%
33 | cmake --build kernel/winja --target runhda_qemu --clean-first -- -j %PROC%
34 | if %errorlevel% neq 0 exit /b %errorlevel%
35 |
--------------------------------------------------------------------------------
/scripts/buildrun.sh:
--------------------------------------------------------------------------------
1 | # ASSUMES NINJA BUILD SYSTEM AND WORKING DIRECTORY OF ROOT OF REPOSITORY
2 |
3 | PROC=$(nproc)
4 |
5 | # SYSTEM LIBRARIES
6 | cmake -G Ninja -S user/libc -B user/libc/winja && cmake --build user/libc/winja --clean-first -- -j $PROC
7 | # USERSPACE PROGRAMS
8 | cmake -G Ninja -S user/blazeit -B user/blazeit/winja \
9 | && cmake --build user/blazeit/winja --clean-first -- -j $PROC \
10 | && xcopy /y user\blazeit\winja\blazeit user\blazeit\blazeit
11 |
12 | cmake -G Ninja -S user/stdout -B user/stdout/winja \
13 | && cmake --build user/stdout/winja --clean-first -- -j $PROC \
14 | && xcopy /y user\stdout\winja\stdout user\stdout\stdout
15 |
16 | cmake -G Ninja -S user/pwd -B user/pwd/winja \
17 | && cmake --build user/pwd/winja --clean-first -- -j $PROC \
18 | && xcopy /y user\pwd\winja\pwd user\pwd\pwd
19 |
20 | # KERNEL
21 | cmake -G Ninja -S kernel -B kernel/winja -DHIDE_UART_COLOR_CODES=OFF \
22 | && cmake --build kernel/winja --target runhda_qemu --clean-first -- -j $PROC
23 |
--------------------------------------------------------------------------------
/scripts/install_mkgpt.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2022, Contributors To LensorOS.
4 | # All rights reserved.
5 | #
6 | # This file is part of LensorOS.
7 | #
8 | # LensorOS is free software: you can redistribute it and/or modify
9 | # it under the terms of the GNU General Public License as published by
10 | # the Free Software Foundation, either version 3 of the License, or
11 | # (at your option) any later version.
12 | #
13 | # LensorOS is distributed in the hope that it will be useful,
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | # GNU General Public License for more details.
17 | #
18 | # You should have received a copy of the GNU General Public License
19 | # along with LensorOS. If not, see .
20 |
21 |
22 | # Dependencies:
23 | # |-- autoconf
24 | # `-- automake
25 |
26 | run(){
27 | set -x
28 | "$@"
29 | { set +x; } 2>/dev/null
30 | }
31 |
32 | run sudo apt install autoconf automake
33 | run git clone https://github.com/jncronin/mkgpt.git
34 | run cd mkgpt
35 | run automake --add-missing
36 | run autoreconf
37 | run ./configure
38 | run make
39 | run sudo make install
40 |
--------------------------------------------------------------------------------
/scripts/mkfat32efibootimage.cmake:
--------------------------------------------------------------------------------
1 | # Run like `cmake -P mkfat32efibootimage.cmake`
2 |
3 | set(REPO_DIR ${CMAKE_CURRENT_LIST_DIR}/..)
4 | set(BOOT_DIR ${REPO_DIR}/boot)
5 | set(IMAGE_DIR ${REPO_DIR}/bin)
6 | set(SCRIPTS_DIR ${REPO_DIR}/scripts)
7 |
8 | # Boot media generation: raw FAT32 images.
9 | # TODO: Can also use truncate in place of dd
10 | find_program( DD_PROGRAM dd )
11 | find_program( MTOOLS_PROGRAM mtools )
12 | if(NOT DD_PROGRAM OR NOT MTOOLS_PROGRAM)
13 | message(NOTICE "[31;5mWARN: MISSING PROGRAM! Could not find `dd` and `mtools`, cannot generate FAT32 UEFI boot media. See dependencies in README.[m")
14 | endif()
15 |
16 | function(mcopy_file filename_to_copy directory)
17 | if (NOT EXISTS ${filename_to_copy})
18 | message(FATAL_ERROR "File at " ${filename_to_copy} " MUST exist to generate UEFI boot media")
19 | endif()
20 | execute_process(COMMAND mcopy -i ${IMAGE_DIR}/LensorOS.img ${filename_to_copy} ::${directory})
21 | endfunction()
22 |
23 | message(STATUS "Generating FAT32 UEFI boot media...")
24 | file(MAKE_DIRECTORY ${IMAGE_DIR})
25 | execute_process(COMMAND ${DD_PROGRAM} if=/dev/zero of=${IMAGE_DIR}/LensorOS.img count=93750)
26 | execute_process(COMMAND mformat -i ${IMAGE_DIR}/LensorOS.img -F -v "EFI System" ::)
27 | execute_process(COMMAND mmd -i ${IMAGE_DIR}/LensorOS.img ::/EFI)
28 | execute_process(COMMAND mmd -i ${IMAGE_DIR}/LensorOS.img ::/EFI/BOOT)
29 | execute_process(COMMAND mmd -i ${IMAGE_DIR}/LensorOS.img ::/LensorOS)
30 | mcopy_file(${SCRIPTS_DIR}/startup.nsh "")
31 | mcopy_file(${BOOT_DIR}/EFI/BOOT/main.efi /EFI/BOOT)
32 | mcopy_file(${BOOT_DIR}/LensorOS/kernel.elf /LensorOS)
33 | mcopy_file(${BOOT_DIR}/LensorOS/dfltfont.psf /LensorOS)
34 |
35 |
--------------------------------------------------------------------------------
/scripts/mkfat32images.cmake:
--------------------------------------------------------------------------------
1 | execute_process(COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_LIST_DIR}/mkfat32efibootimage.cmake)
2 | execute_process(COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_LIST_DIR}/mkfat32lensorosdata.cmake)
3 |
--------------------------------------------------------------------------------
/scripts/mkgpt.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2022, Contributors To LensorOS.
4 | # All rights reserved.
5 | #
6 | # This file is part of LensorOS.
7 | #
8 | # LensorOS is free software: you can redistribute it and/or modify
9 | # it under the terms of the GNU General Public License as published by
10 | # the Free Software Foundation, either version 3 of the License, or
11 | # (at your option) any later version.
12 | #
13 | # LensorOS is distributed in the hope that it will be useful,
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | # GNU General Public License for more details.
17 | #
18 | # You should have received a copy of the GNU General Public License
19 | # along with LensorOS. If not, see .
20 |
21 |
22 | ScriptDirectory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
23 | KernelDirectory="$ScriptDirectory/../kernel"
24 |
25 | run(){
26 | set -x
27 | "$@"
28 | { set +x; } 2>/dev/null
29 | }
30 |
31 | run $ScriptDirectory/mkimg.sh
32 | run mkgpt -o $KernelDirectory/bin/LensorOS.bin --part $KernelDirectory/bin/LensorOS.img --type system --part $KernelDirectory/bin/LensorOSData.img --type 00000000-0000-0000-0000-000000000069
33 |
--------------------------------------------------------------------------------
/scripts/mkiso.bat:
--------------------------------------------------------------------------------
1 | :: Copyright 2022, Contributors To LensorOS.
2 | :: All rights reserved.
3 | ::
4 | :: This file is part of LensorOS.
5 | ::
6 | :: LensorOS is free software: you can redistribute it and/or modify
7 | :: it under the terms of the GNU General Public License as published by
8 | :: the Free Software Foundation, either version 3 of the License, or
9 | :: (at your option) any later version.
10 | ::
11 | :: LensorOS is distributed in the hope that it will be useful,
12 | :: but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | :: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | :: GNU General Public License for more details.
15 | ::
16 | :: You should have received a copy of the GNU General Public License
17 | :: along with LensorOS. If not, see .
18 | SET ScriptDirectory=%0/..
19 | SET BuildDirectory=%ScriptDirectory%/../kernel/bin
20 | SET ScriptDirectory=%ScriptDirectory:"=%
21 | SET BuildDirectory=%BuildDirectory:"=%
22 | cmd /c %ScriptDirectory%/mkimg.bat
23 | cd %BuildDirectory%
24 | md iso
25 | cp LensorOS.img iso/
26 | xorriso -as mkisofs -R -f -e LensorOS.img -no-emul-boot -o LensorOS.iso iso
27 | @echo " -> Created El-Torito ISO-9660 boot media image"
28 | rm -r iso
29 |
--------------------------------------------------------------------------------
/scripts/mkiso.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2022, Contributors To LensorOS.
4 | # All rights reserved.
5 | #
6 | # This file is part of LensorOS.
7 | #
8 | # LensorOS is free software: you can redistribute it and/or modify
9 | # it under the terms of the GNU General Public License as published by
10 | # the Free Software Foundation, either version 3 of the License, or
11 | # (at your option) any later version.
12 | #
13 | # LensorOS is distributed in the hope that it will be useful,
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | # GNU General Public License for more details.
17 | #
18 | # You should have received a copy of the GNU General Public License
19 | # along with LensorOS. If not, see .
20 |
21 |
22 | ScriptDirectory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
23 | BuildDirectory="$ScriptDirectory/../kernel/bin"
24 |
25 | run() {
26 | set -x
27 | "$@"
28 | { set +x; } 2>/dev/null
29 | }
30 |
31 | # TODO: Think about how to run LensorOS from a bootable ISO image while
32 | # also having the data partition loaded on there.
33 |
34 | run $ScriptDirectory/mkimg.sh
35 | run mkdir -p $BuildDirectory/iso
36 | run cp \
37 | $BuildDirectory/LensorOS.img \
38 | $BuildDirectory/iso
39 | run xorriso \
40 | -as mkisofs \
41 | -R -f \
42 | -e LensorOS.img \
43 | -no-emul-boot \
44 | -o $BuildDirectory/LensorOS.iso \
45 | $BuildDirectory/iso
46 | run rm -r $BuildDirectory/iso
47 |
--------------------------------------------------------------------------------
/scripts/run.bat:
--------------------------------------------------------------------------------
1 | :: Copyright 2022, Contributors To LensorOS.
2 | :: All rights reserved.
3 | ::
4 | :: This file is part of LensorOS.
5 | ::
6 | :: LensorOS is free software: you can redistribute it and/or modify
7 | :: it under the terms of the GNU General Public License as published by
8 | :: the Free Software Foundation, either version 3 of the License, or
9 | :: (at your option) any later version.
10 | ::
11 | :: LensorOS is distributed in the hope that it will be useful,
12 | :: but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | :: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | :: GNU General Public License for more details.
15 | ::
16 | :: You should have received a copy of the GNU General Public License
17 | :: along with LensorOS. If not, see .
18 | SET OVMFbin=%0/../../OVMFbin
19 | SET BuildDirectory=%0/../../kernel/bin
20 | SET OVMFbin=%OVMFbin:"=%
21 | SET BuildDirectory=%BuildDirectory:"=%
22 | IF NOT EXIST %BuildDirectory%/LensorOS.img echo " -> ERROR: Could not find %BuildDirectory%/LensorOS.img" & EXIT
23 | IF NOT EXIST %OVMFbin%/OVMF_CODE-pure-efi.fd echo " -> ERROR: Could not find %OVMFbin%/OVMF_CODE-pure-efi.fd" & EXIT
24 | IF NOT EXIST %OVMFbin%/OVMF_VARS_LensorOS.fd cp %OVMFbin%/OVMF_VARS-pure-efi.fd %OVMFbin%/OVMF_VARS_LensorOS.fd
25 | qemu-system-x86_64 ^
26 | -d cpu_reset ^
27 | -machine q35 ^
28 | -cpu qemu64 ^
29 | -m 100M ^
30 | -serial stdio ^
31 | -soundhw pcspk ^
32 | -rtc base=localtime,clock=host,driftfix=none ^
33 | -net none ^
34 | -drive format=raw,file=%BuildDirectory%/LensorOS.img ^
35 | -drive if=pflash,format=raw,unit=0,file=%OVMFbin%/OVMF_CODE-pure-efi.fd,readonly=on ^
36 | -drive if=pflash,format=raw,unit=1,file=%OVMFbin%/OVMF_VARS_LensorOS.fd
37 |
--------------------------------------------------------------------------------
/scripts/rundbg.bat:
--------------------------------------------------------------------------------
1 | :: Copyright 2022, Contributors To LensorOS.
2 | :: All rights reserved.
3 | ::
4 | :: This file is part of LensorOS.
5 | ::
6 | :: LensorOS is free software: you can redistribute it and/or modify
7 | :: it under the terms of the GNU General Public License as published by
8 | :: the Free Software Foundation, either version 3 of the License, or
9 | :: (at your option) any later version.
10 | ::
11 | :: LensorOS is distributed in the hope that it will be useful,
12 | :: but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | :: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | :: GNU General Public License for more details.
15 | ::
16 | :: You should have received a copy of the GNU General Public License
17 | :: along with LensorOS. If not, see .
18 | SET OVMFbin=%0/../../OVMFbin
19 | SET BuildDirectory=%0/../../kernel/bin
20 | SET OVMFbin=%OVMFbin:"=%
21 | SET BuildDirectory=%BuildDirectory:"=%
22 | IF NOT EXIST %BuildDirectory%/LensorOS.img echo " -> ERROR: Could not find %BuildDirectory%/LensorOS.img" & EXIT
23 | IF NOT EXIST %OVMFbin%/OVMF_CODE-pure-efi.fd echo " -> ERROR: Could not find %OVMFbin%/OVMF_CODE-pure-efi.fd" & EXIT
24 | IF NOT EXIST %OVMFbin%/OVMF_VARS_LensorOS.fd cp %OVMFbin%/OVMF_VARS-pure-efi.fd %OVMFbin%/OVMF_VARS_LensorOS.fd
25 | qemu-system-x86_64.exe ^
26 | -s -S ^
27 | -d cpu_reset ^
28 | -machine q35 ^
29 | -cpu qemu64 ^
30 | -m 100M ^
31 | -serial stdio ^
32 | -soundhw pcspk ^
33 | -net none ^
34 | -rtc base=localtime,clock=host,driftfix=none ^
35 | -drive format=raw,file=%BuildDirectory%/LensorOS.img ^
36 | -drive if=pflash,format=raw,unit=0,file=%OVMFbin%/OVMF_CODE-pure-efi.fd,readonly=on ^
37 | -drive if=pflash,format=raw,unit=1,file=%OVMFbin%/OVMF_VARS_LensorOS.fd
38 |
--------------------------------------------------------------------------------
/scripts/rundbg.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2022, Contributors To LensorOS.
4 | # All rights reserved.
5 | #
6 | # This file is part of LensorOS.
7 | #
8 | # LensorOS is free software: you can redistribute it and/or modify
9 | # it under the terms of the GNU General Public License as published by
10 | # the Free Software Foundation, either version 3 of the License, or
11 | # (at your option) any later version.
12 | #
13 | # LensorOS is distributed in the hope that it will be useful,
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | # GNU General Public License for more details.
17 | #
18 | # You should have received a copy of the GNU General Public License
19 | # along with LensorOS. If not, see .
20 |
21 |
22 | ScriptDirectory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
23 | BuildDirectory="$ScriptDirectory/../kernel/bin"
24 | OVMFDirectory="$ScriptDirectory/../OVMFbin"
25 | qemu-system-x86_64 \
26 | -s -S \
27 | -d cpu_reset \
28 | -machine q35 \
29 | -cpu qemu64 \
30 | -m 100M \
31 | -serial stdio \
32 | -soundhw pcspk \
33 | -net none \
34 | -rtc base=localtime,clock=host,driftfix=none \
35 | -drive format=raw,file=$BuildDirectory/LensorOS.img \
36 | -drive if=pflash,format=raw,unit=0,file=$OVMFDirectory/OVMF_CODE-pure-efi.fd,readonly=on \
37 | -drive if=pflash,format=raw,unit=1,file=$OVMFDirectory/OVMF_VARS-pure-efi.fd
38 |
--------------------------------------------------------------------------------
/scripts/runhda.bat:
--------------------------------------------------------------------------------
1 | :: Copyright 2022, Contributors To LensorOS.
2 | :: All rights reserved.
3 | ::
4 | :: This file is part of LensorOS.
5 | ::
6 | :: LensorOS is free software: you can redistribute it and/or modify
7 | :: it under the terms of the GNU General Public License as published by
8 | :: the Free Software Foundation, either version 3 of the License, or
9 | :: (at your option) any later version.
10 | ::
11 | :: LensorOS is distributed in the hope that it will be useful,
12 | :: but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | :: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | :: GNU General Public License for more details.
15 | ::
16 | :: You should have received a copy of the GNU General Public License
17 | :: along with LensorOS. If not, see .
18 | SET OVMFbin=%0/../../OVMFbin
19 | SET BuildDirectory=%0/../../bin
20 | SET OVMFbin=%OVMFbin:"=%
21 | SET BuildDirectory=%BuildDirectory:"=%
22 | IF NOT EXIST %BuildDirectory%/LensorOS.bin echo " -> ERROR: Could not find %BuildDirectory%/LensorOS.bin" & EXIT
23 | IF NOT EXIST %OVMFbin%/OVMF_CODE-pure-efi.fd echo " -> ERROR: Could not find %OVMFbin%/OVMF_CODE-pure-efi.fd" & EXIT
24 | IF NOT EXIST %OVMFbin%/OVMF_VARS_LensorOS.fd cp %OVMFbin%/OVMF_VARS-pure-efi.fd %OVMFbin%/OVMF_VARS_LensorOS.fd
25 | qemu-system-x86_64.exe ^
26 | -cpu qemu64 ^
27 | -machine q35 ^
28 | -m 100M ^
29 | -rtc base=localtime,clock=host,driftfix=none ^
30 | -serial stdio ^
31 | -audiodev dsound,id=audio_device ^
32 | -machine pcspk-audiodev=audio_device ^
33 | -d cpu_reset ^
34 | -hda %BuildDirectory%\LensorOS.bin ^
35 | -drive if=pflash,format=raw,unit=0,file=%OVMFbin%\OVMF_CODE-pure-efi.fd,readonly=on ^
36 | -drive if=pflash,format=raw,unit=1,file=%OVMFbin%\OVMF_VARS_LensorOS.fd ^
37 | -nic user,ipv6=off,model=e1000,mac=52:54:98:76:54:32
38 |
--------------------------------------------------------------------------------
/scripts/runhdadbg.bat:
--------------------------------------------------------------------------------
1 | :: Copyright 2022, Contributors To LensorOS.
2 | :: All rights reserved.
3 | ::
4 | :: This file is part of LensorOS.
5 | ::
6 | :: LensorOS is free software: you can redistribute it and/or modify
7 | :: it under the terms of the GNU General Public License as published by
8 | :: the Free Software Foundation, either version 3 of the License, or
9 | :: (at your option) any later version.
10 | ::
11 | :: LensorOS is distributed in the hope that it will be useful,
12 | :: but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | :: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | :: GNU General Public License for more details.
15 | ::
16 | :: You should have received a copy of the GNU General Public License
17 | :: along with LensorOS. If not, see .
18 | SET OVMFbin=%0/../../OVMFbin
19 | SET BuildDirectory=%0/../../kernel/bin
20 | SET OVMFbin=%OVMFbin:"=%
21 | SET BuildDirectory=%BuildDirectory:"=%
22 | IF NOT EXIST %BuildDirectory%/LensorOS.img echo " -> ERROR: Could not find %BuildDirectory%/LensorOS.img" & EXIT
23 | IF NOT EXIST %OVMFbin%/OVMF_CODE-pure-efi.fd echo " -> ERROR: Could not find %OVMFbin%/OVMF_CODE-pure-efi.fd" & EXIT
24 | IF NOT EXIST %OVMFbin%/OVMF_VARS_LensorOS.fd cp %OVMFbin%/OVMF_VARS-pure-efi.fd %OVMFbin%/OVMF_VARS_LensorOS.fd
25 | qemu-system-x86_64.exe ^
26 | -s -S ^
27 | -cpu qemu64 ^
28 | -machine q35 ^
29 | -m 100M ^
30 | -rtc base=localtime,clock=host,driftfix=none ^
31 | -serial stdio ^
32 | -soundhw pcspk ^
33 | -d cpu_reset ^
34 | -hda %BuildDirectory%\LensorOS.bin ^
35 | -drive if=pflash,format=raw,unit=0,file=%OVMFbin%\OVMF_CODE-pure-efi.fd,readonly=on ^
36 | -drive if=pflash,format=raw,unit=1,file=%OVMFbin%\OVMF_VARS_LensorOS.fd ^
37 | -net none
38 |
--------------------------------------------------------------------------------
/scripts/runiso.bat:
--------------------------------------------------------------------------------
1 | :: Copyright 2022, Contributors To LensorOS.
2 | :: All rights reserved.
3 | ::
4 | :: This file is part of LensorOS.
5 | ::
6 | :: LensorOS is free software: you can redistribute it and/or modify
7 | :: it under the terms of the GNU General Public License as published by
8 | :: the Free Software Foundation, either version 3 of the License, or
9 | :: (at your option) any later version.
10 | ::
11 | :: LensorOS is distributed in the hope that it will be useful,
12 | :: but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | :: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | :: GNU General Public License for more details.
15 | ::
16 | :: You should have received a copy of the GNU General Public License
17 | :: along with LensorOS. If not, see .
18 | SET OVMFbin=%0/../../OVMFbin
19 | SET BuildDirectory=%0/../../kernel/bin
20 | SET OVMFbin=%OVMFbin:"=%
21 | SET BuildDirectory=%BuildDirectory:"=%
22 | IF NOT EXIST %BuildDirectory%/LensorOS.img echo " -> ERROR: Could not find %BuildDirectory%/LensorOS.img" & EXIT
23 | IF NOT EXIST %OVMFbin%/OVMF_CODE-pure-efi.fd echo " -> ERROR: Could not find %OVMFbin%/OVMF_CODE-pure-efi.fd" & EXIT
24 | IF NOT EXIST %OVMFbin%/OVMF_VARS_LensorOS.fd cp %OVMFbin%/OVMF_VARS-pure-efi.fd %OVMFbin%/OVMF_VARS_LensorOS.fd
25 | qemu-system-x86_64 ^
26 | -d cpu_reset ^
27 | -machine q35 ^
28 | -cpu qemu64 ^
29 | -m 100M ^
30 | -serial stdio ^
31 | -soundhw pcspk ^
32 | -rtc base=localtime,clock=host,driftfix=none ^
33 | -net none ^
34 | -drive format=raw,file=%BuildDirectory%/LensorOS.iso,media=cdrom ^
35 | -drive if=pflash,format=raw,unit=0,file=%OVMFbin%/OVMF_CODE-pure-efi.fd,readonly=on ^
36 | -drive if=pflash,format=raw,unit=1,file=%OVMFbin%/OVMF_VARS_LensorOS.fd
37 |
--------------------------------------------------------------------------------
/scripts/sysroot.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2022, Contributors To LensorOS.
4 | # All rights reserved.
5 | #
6 | # This file is part of LensorOS.
7 | #
8 | # LensorOS is free software: you can redistribute it and/or modify
9 | # it under the terms of the GNU General Public License as published by
10 | # the Free Software Foundation, either version 3 of the License, or
11 | # (at your option) any later version.
12 | #
13 | # LensorOS is distributed in the hope that it will be useful,
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | # GNU General Public License for more details.
17 | #
18 | # You should have received a copy of the GNU General Public License
19 | # along with LensorOS. If not, see .
20 | set -u
21 |
22 | ScriptDirectory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
23 | ProjectRoot="$ScriptDirectory/.."
24 | SystemRoot="$ProjectRoot/root"
25 |
26 | run(){
27 | set -x
28 | "$@"
29 | { set +x; } 2>/dev/null
30 | }
31 |
32 | echo -e "\n\n -> Bootstrapping System Root at $SystemRoot\n\n"
33 | run mkdir -p "$SystemRoot"
34 | # Copy base filesystem with pre-built libc
35 | # binaries into newly-created sysroot.
36 | # This solves the issue of having to build a
37 | # bootstrap version of the compiler first.
38 | cd "$ScriptDirectory"
39 | run cp -r ../base/* "$SystemRoot/"
40 | # Copy header files from libc to sysroot.
41 | run cd ../user/libc/
42 | run find ./ -name '*.h' -exec cp --parents '{}' -t "$SystemRoot/inc" ';'
43 | run cp "$ProjectRoot"/std/include/* "$SystemRoot/inc/"
44 | run cp "$ProjectRoot"/std/include/bits/* "$SystemRoot/inc/bits/"
45 | run cd "$ScriptDirectory"
46 |
--------------------------------------------------------------------------------
/std/include/.gitattributes:
--------------------------------------------------------------------------------
1 | * linguist-language=C++
2 |
--------------------------------------------------------------------------------
/std/include/bit:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see
25 | #include
26 | #include
27 | #include
28 | #include
29 |
30 | __BEGIN_DECLS__
31 | void* memcpy(void* __restrict__ __dest, const void* __restrict__ __src, size_t __n);
32 | __END_DECLS__
33 |
34 | namespace std {
35 |
36 | template
37 | requires (sizeof(_To) == sizeof(_From))
38 | constexpr _To bit_cast(const _From& __from) {
39 | return __builtin_bit_cast(_To, __from);
40 | }
41 |
42 | template
43 | constexpr _T byteswap(_T n) noexcept {
44 | //static_assert(std::has_unique_object_representations_v<_T>, "T may not have padding bits");
45 | auto repr = std::bit_cast>(n);
46 | std::reverse(repr.begin(), repr.end());
47 | return std::bit_cast<_T>(repr);
48 | }
49 |
50 | } // namespace std
51 |
52 | #endif /* _LENSOR_OS_BIT_H */
53 |
--------------------------------------------------------------------------------
/std/include/bits/colours.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see .
18 | */
19 |
20 | #ifndef _LIBC_COLOURS_H
21 | #define _LIBC_COLOURS_H
22 |
23 | #define _RR "\033[1;31m"
24 | #define _R "\033[31m"
25 | #define _G "\033[32m"
26 | #define _Y "\033[33m"
27 | #define _B "\033[34m"
28 | #define _M "\033[35m"
29 | #define _C "\033[36m"
30 | #define _W "\033[37m"
31 | #define _N "\033[m"
32 |
33 | #endif // _LIBC_COLOURS_H
34 |
--------------------------------------------------------------------------------
/std/include/bits/terminate.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see
25 | [[noreturn]] inline void terminate() noexcept {
26 | __libc_assert(false, "terminate() called");
27 | }
28 |
29 | [[noreturn]] inline void __terminate_with_message(const char* __msg) noexcept {
30 | __libc_assert(false, __msg ?: "terminate() called");
31 | }
32 | #else
33 | # include
34 | [[noreturn]] inline void terminate() noexcept {
35 | panic("terminate() called");
36 | for (;;) __asm__ __volatile__("hlt");
37 | }
38 |
39 | [[noreturn]] inline void __terminate_with_message(const char* __msg) noexcept {
40 | panic(__msg ?: "terminate() called");
41 | for (;;) __asm__ __volatile__("hlt");
42 | }
43 | #endif
44 |
45 | #endif // _LENSOROS_LIBC_TERMINATE_H
46 |
--------------------------------------------------------------------------------
/std/include/cmath:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see .
18 | */
19 |
20 | #ifndef _LENSOROS_CMATH
21 | #define _LENSOROS_CMATH
22 |
23 | #define INFINITY (1. / 0.)
24 | #define NAN (0. / 0.)
25 |
26 | namespace std {
27 |
28 | template
29 | constexpr bool isnan(_Ty value) noexcept { return value != value; }
30 |
31 | template
32 | constexpr bool isinf(_Ty value) noexcept { return value == INFINITY || value == -INFINITY; }
33 |
34 | }
35 |
36 | #endif // _LENSOROS_CMATH
37 |
--------------------------------------------------------------------------------
/std/include/cstring:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see
24 | #else
25 | #include
26 | #endif
27 |
28 | #endif // _LENSOROS_CSTRING
29 |
--------------------------------------------------------------------------------
/std/include/ctype.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see .
18 | */
19 |
20 | #ifndef _LENSOROS_LIBC_CTYPE_H
21 | #define _LENSOROS_LIBC_CTYPE_H
22 |
23 | #include
24 |
25 | __BEGIN_DECLS__
26 |
27 | __constexpr inline int isdigit(int c) { return c >= '0' && c <= '9'; }
28 | __constexpr inline int isalpha(int c) { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); }
29 | __constexpr inline int isalnum(int c) { return isalpha(c) || isdigit(c); }
30 | __constexpr inline int isxdigit(int c) { return isdigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); }
31 | __constexpr inline int islower(int c) { return c >= 'a' && c <= 'z'; }
32 | __constexpr inline int isupper(int c) { return c >= 'A' && c <= 'Z'; }
33 |
34 | __END_DECLS__
35 |
36 | #endif // _LENSOROS_LIBC_CTYPE_H
37 |
--------------------------------------------------------------------------------
/std/include/extensions:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see
28 | #include
29 | #include
30 |
31 | #include
32 | #include
33 | #include
34 |
35 | namespace std {
36 | template
37 | constexpr auto find_if(_Container&& c, _Predicate pred) {
38 | return find_if(c.begin(), c.end(), pred);
39 | }
40 |
41 | template
42 | constexpr auto find(_Container&& container, _El&& el) {
43 | return find(container.begin(), container.end(), std::forward<_El>(el));
44 | }
45 |
46 | } // namespace std
47 |
48 | #endif // _LENSOROS_EXTENSIONS
49 |
--------------------------------------------------------------------------------
/std/include/locale:
--------------------------------------------------------------------------------
1 | #ifndef _LENSOROS_LOCALE_H
2 | #define _LENSOROS_LOCALE_H
3 |
4 | namespace std {
5 |
6 | // FIXME: STUB
7 | class locale{};
8 |
9 | } /* namespace std */
10 |
11 | #endif /* _LENSOROS_LOCALE_H */
12 |
--------------------------------------------------------------------------------
/std/include/mutex:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see .
18 | */
19 |
20 | #ifndef _LENSOR_OS_MUTEX
21 | #define _LENSOR_OS_MUTEX
22 |
23 | namespace std {
24 |
25 | struct mutex {
26 | void lock() {}
27 | bool try_lock() { return true; }
28 | void unlock() {}
29 |
30 | explicit mutex() {}
31 | };
32 |
33 | struct recursive_mutex {
34 | void lock() {}
35 | bool try_lock() { return true; }
36 | void unlock() {}
37 |
38 | explicit recursive_mutex() {}
39 | };
40 |
41 | template
42 | class unique_lock {
43 | _Lock& __lock;
44 | public:
45 | explicit unique_lock(_Lock& lock) : __lock(lock) { __lock.lock(); }
46 | ~unique_lock() { __lock.unlock(); }
47 | };
48 |
49 | } // namespace std
50 |
51 |
52 | #endif // _LENSOR_OS_MUTEX
53 |
--------------------------------------------------------------------------------
/std/include/stddef.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see .
18 | */
19 |
20 |
21 | #ifndef _STDDEF_H
22 | #define _STDDEF_H
23 |
24 | #include
25 |
26 | #define offsetof(type, member) __builtin_offsetof(type, member)
27 |
28 | __BEGIN_DECLS__
29 |
30 | typedef __PTRDIFF_TYPE__ ptrdiff_t;
31 | typedef __SIZE_TYPE__ size_t;
32 | typedef __WINT_TYPE__ wint_t;
33 |
34 | typedef struct {
35 | long long __ll __attribute__((__aligned__(__alignof__(long long))));
36 | long double __ld __attribute__((__aligned__(__alignof__(long double))));
37 | } max_align_t;
38 |
39 | #ifdef __cplusplus
40 | # define NULL nullptr
41 | namespace std {
42 | typedef decltype(nullptr) nullptr_t;
43 | using size_t = size_t;
44 | using ptrdiff_t = ptrdiff_t;
45 | } // namespace std
46 | #else
47 | # define NULL ((void*)0)
48 | typedef __WCHAR_TYPE__ wchar_t;
49 | #endif
50 |
51 | __END_DECLS__
52 |
53 | #endif /* _STDDEF_H */
54 |
--------------------------------------------------------------------------------
/std/include/string_view:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see
24 |
25 | #endif // _LENSOROS_STRING_VIEW_
26 |
--------------------------------------------------------------------------------
/toolchain/.gitignore:
--------------------------------------------------------------------------------
1 | #Copyright 2022, Contributors To LensorOS.
2 | # All rights reserved.
3 |
4 | # This file is part of LensorOS.
5 |
6 | # LensorOS is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the License, or
9 | # (at your option) any later version.
10 |
11 | # LensorOS is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 |
16 | # You should have received a copy of the GNU General Public License
17 | # along with LensorOS. If not, see .
18 |
19 |
20 | # Generated directories
21 | /cross/
22 | /wincross/
23 | /binutils*/
24 | /gcc*/
25 |
26 | # Downloaded archives
27 | *.tar*
28 |
29 | # Untouched (for generating patches)
30 | /untouched/
31 |
--------------------------------------------------------------------------------
/toolchain/config.cmake:
--------------------------------------------------------------------------------
1 | # Copyright 2022, Contributors To LensorOS.
2 | # All rights reserved.
3 | #
4 | # This file is part of LensorOS.
5 | #
6 | # LensorOS is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # LensorOS is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with LensorOS. If not, see -S -B -DMACHINE="QEMU"
24 |
25 | set(
26 | ARCH "x86_64"
27 | CACHE STRING
28 | "The CPU architecture that LensorOS will be run on"
29 | )
30 | set_property(
31 | CACHE ARCH
32 | PROPERTY STRINGS
33 | "x86_64"
34 | )
35 | set(
36 | MACHINE "VBOX"
37 | CACHE STRING
38 | "The machine type that LensorOS will run on"
39 | )
40 | set_property(
41 | CACHE MACHINE
42 | PROPERTY STRINGS
43 | "PC"
44 | "QEMU"
45 | "VBOX"
46 | "VMWARE"
47 | )
48 | option(
49 | HIDE_UART_COLOR_CODES
50 | "Do not print ANSI terminal color codes to serial output.
51 | Particularly useful if the terminal you are using does not support it.
52 | On by default for compatibility reasons."
53 | ON
54 | )
55 | option(
56 | QEMU_DEBUG
57 | "Start QEMU with `-S -s` flags, halting startup until a debugger has been attached."
58 | OFF
59 | )
60 |
--------------------------------------------------------------------------------
/toolchain/lensor.h:
--------------------------------------------------------------------------------
1 | #undef TARGET_LENSOR
2 | #define TARGET_LENSOR 1
3 |
4 | /* This file is meant to end up as gcc-VERSION/gcc/config/lensor.h.
5 | * This file is included in the relavant GCC patch; it is only for
6 | * developmental use.
7 | */
8 |
9 | /* Default arguments
10 | * `-- `-lc`
11 | * Link to C Standard Library
12 | */
13 | #undef LIB_SPEC
14 | #define LIB_SPEC "-lc"
15 |
16 | /* Default linker arguments
17 | * `-- `-z max-page-size=4096`
18 | * Use 4KiB pages by default, even on 64-bit systems.
19 | */
20 | #undef LINK_SPEC
21 | #define LINK_SPEC "-z max-page-size=4096"
22 |
23 | /* Files that are linked before user code.
24 | * The prefix is to match one of Binutils'
25 | * /ld/configure.tgt `NATIVE_LIB_DIRS`.
26 | * The %s tells GCC to look for these files in the library directory.
27 | */
28 | #undef STANDARD_STARTFILE_PREFIX
29 | #define STANDARD_STARTFILE_PREFIX "/lib/"
30 | #undef STARTFILE_SPEC
31 | #define STARTFILE_SPEC "crt0.o%s crti.o%s crtbegin.o%s"
32 |
33 | /* Files that are linked after user code. */
34 | #undef ENDFILE_SPEC
35 | #define ENDFILE_SPEC "crtend.o%s crtn.o%s"
36 |
37 | /* Additional predefined macros. */
38 | #undef TARGET_OS_CPP_BUILTINS
39 | #define TARGET_OS_CPP_BUILTINS() \
40 | do { \
41 | builtin_define ("__lensor__"); \
42 | builtin_define ("__lensoros__"); \
43 | builtin_define ("__unix__"); \
44 | builtin_assert ("system=lensor"); \
45 | builtin_assert ("system=lensoros"); \
46 | builtin_assert ("system=unix"); \
47 | builtin_assert ("system=posix"); \
48 | } while(0);
49 |
--------------------------------------------------------------------------------
/user/blazeit/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright 2022, Contributors To LensorOS.
2 | # All rights reserved.
3 | #
4 | # This file is part of LensorOS.
5 | #
6 | # LensorOS is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # LensorOS is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with LensorOS. If not, see .
18 |
19 |
20 | cmake_minimum_required( VERSION 3.20 )
21 | set( blazeit_VERSION 0.0.3 )
22 | set( blazeit_LANGUAGES C )
23 |
24 | # Get the directory of the repository.
25 | cmake_path(
26 | GET
27 | CMAKE_CURRENT_LIST_DIR
28 | PARENT_PATH
29 | REPO_DIR
30 | )
31 | cmake_path(
32 | GET
33 | REPO_DIR
34 | PARENT_PATH
35 | REPO_DIR
36 | )
37 |
38 | project( LensorOS VERSION ${blazeit_VERSION} LANGUAGES ${blazeit_LANGUAGES} )
39 |
40 | add_executable( blazeit main.c )
41 |
--------------------------------------------------------------------------------
/user/blazeit/main.c:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see .
18 | */
19 |
20 | #include
21 |
22 | int main(void) {
23 | puts(" >== blaze it, mafk ==>");
24 | return 420;
25 | }
26 |
--------------------------------------------------------------------------------
/user/cat/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright 2022, Contributors To LensorOS.
2 | # All rights reserved.
3 | #
4 | # This file is part of LensorOS.
5 | #
6 | # LensorOS is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # LensorOS is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with LensorOS. If not, see
2 | #include
3 |
4 | int main(int argc, char** argv) {
5 | if (argc != 2) {
6 | printf("Please provide exactly one filepath\n");
7 | return 1;
8 | }
9 |
10 | FILE* f = fopen(argv[1], "rb");
11 | if (not f) {
12 | printf("Could not open file at %s\n", argv[1]);
13 | return 1;
14 | }
15 |
16 | constexpr int bytes_to_read = 1;
17 | char c[bytes_to_read];
18 | size_t bytes_read;
19 | while ((bytes_read = fread(&c[0], 1, bytes_to_read, f)) > 0) {
20 | if (feof(f) or ferror(f) || bytes_read != bytes_to_read) break;
21 | fwrite(&c[0], 1, bytes_read, stdout);
22 | }
23 |
24 | return 0;
25 | }
26 |
--------------------------------------------------------------------------------
/user/clienttest/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright 2022, Contributors To LensorOS.
2 | # All rights reserved.
3 | #
4 | # This file is part of LensorOS.
5 | #
6 | # LensorOS is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # LensorOS is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with LensorOS. If not, see
2 |
3 | #include
4 | #include
5 | #include
6 |
7 | int main(int argc, char **argv) {
8 | printf("[CLIENT]: starting... opening socket\n");
9 | fflush(stdout);
10 |
11 | int sockFD = sys_socket(0, 0, 0);
12 |
13 | printf("[CLIENT]: socket opened\n");
14 | fflush(stdout);
15 |
16 | sockaddr addr;
17 | addr.type = LENSOR16;
18 | const char socket_path[] = "!Test";
19 | memset(addr.data, 0, SOCK_ADDR_MAX_SIZE);
20 | memcpy(addr.data, &socket_path, sizeof(socket_path) - 1);
21 | int rc = sys_connect(sockFD, &addr, sizeof(sockaddr));
22 | if (rc) {
23 | close(sockFD);
24 | printf("[CLIENT]: Couldn't connect to address: %s\n", socket_path);
25 | fflush(stdout);
26 | return rc;
27 | }
28 | printf("[CLIENT]: Connected to address: \"%s\"\n", socket_path);
29 | fflush(stdout);
30 |
31 | printf("[CLIENT]: Reading from socket...\n");
32 | fflush(stdout);
33 |
34 | unsigned char data[512];
35 | int bytes_read = 0;
36 | bytes_read += read(sockFD, data, 16);
37 |
38 | printf("[CLIENT]: Read %d bytes from socket\n", bytes_read);
39 | fflush(stdout);
40 |
41 | uint64_t* data_it = (uint64_t*)data;
42 | uint64_t leading = *data_it++;
43 | uint64_t trailing = *data_it;
44 |
45 | printf("[CLIENT]: got %u and %u\n", leading, trailing);
46 | fflush(stdout);
47 |
48 | write(sockFD, data, 16);
49 |
50 | printf("[CLIENT]: client written\n");
51 | fflush(stdout);
52 |
53 | printf("[CLIENT]: closing client socket\n");
54 | fflush(stdout);
55 |
56 | close(sockFD);
57 |
58 | printf("[CLIENT]: closed client socket\n");
59 | fflush(stdout);
60 |
61 | return 0;
62 | }
63 |
--------------------------------------------------------------------------------
/user/echo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright 2022, Contributors To LensorOS.
2 | # All rights reserved.
3 | #
4 | # This file is part of LensorOS.
5 | #
6 | # LensorOS is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # LensorOS is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with LensorOS. If not, see
2 | #include
3 |
4 | int main(int argc, const char **argv) {
5 | for (int i = 1; i < argc; ++i) {
6 | std::print("{}", argv[i]);
7 | if (i + 1 < argc) std::print(" ");
8 | }
9 | std::print("\n");
10 | }
11 |
--------------------------------------------------------------------------------
/user/libc/bits/abi.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see .
18 | */
19 |
20 | #ifndef LENSOROS_ABI_H
21 | #define LENSOROS_ABI_H
22 |
23 | #include
24 |
25 | __BEGIN_DECLS__
26 | using __dso_cb = void (*)(void*);
27 | using __dso_cb_arg = void*;
28 | using __dso_handle_t = void*;
29 |
30 | extern __bool __in_quick_exit;
31 |
32 | void __cxa_atexit(__dso_cb func, __dso_cb_arg arg, __dso_handle_t dso);
33 | __END_DECLS__
34 |
35 | #endif // LENSOROS_ABI_H
36 |
--------------------------------------------------------------------------------
/user/libc/bits/cdtors.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see .
18 | */
19 |
20 | #ifndef _LENSOROS_LIBC_CDTORS_H
21 | #define _LENSOROS_LIBC_CDTORS_H
22 |
23 | #define _CDTOR_MALLOC 0
24 | #define _CDTOR_STDIO 1
25 |
26 | #endif // _LENSOROS_LIBC_CDTORS_H
27 |
--------------------------------------------------------------------------------
/user/libc/bits/io_defs.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by ae on 02/11/22.
3 | //
4 |
5 | #ifndef LENSOROS_IO_DEFS_H
6 | #define LENSOROS_IO_DEFS_H
7 |
8 | #include
9 | #include
10 | #include
11 |
12 | __BEGIN_DECLS__
13 |
14 | /// These MUST be 0, 1, 2 because of how we handle them internally.
15 | #define _IOFBF 0
16 | #define _IOLBF 1
17 | #define _IONBF 2
18 |
19 | typedef int _IO_fd_t;
20 | typedef size_t _IO_size_t;
21 | typedef uint16_t _IO_flags_t;
22 | typedef long _IO_off_t;
23 |
24 | __END_DECLS__
25 |
26 | #ifdef __cplusplus
27 | #include
28 |
29 | /// Recursive mutex because flockfile() is a thing.
30 | typedef std::recursive_mutex _IO_lock_t;
31 |
32 | /// Buffering mode.
33 | enum Buffering : _IO_flags_t {
34 | /// No buffering. Write the character(s) immediately.
35 | Unbuffered = _IONBF,
36 |
37 | /// Line buffering. Write the character(s) immediately if a newline is
38 | /// encountered. Otherwise, write to a buffer and only flush when the
39 | /// buffer is full or a newline is encountered.
40 | LineBuffered = _IOLBF,
41 |
42 | /// Full buffering. Write the character(s) to a buffer and only flush when
43 | /// the buffer is full.
44 | FullyBuffered = _IOFBF,
45 | };
46 |
47 | #endif
48 |
49 |
50 | #endif // LENSOROS_IO_DEFS_H
51 |
--------------------------------------------------------------------------------
/user/libc/bits/stub.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see .
18 | */
19 |
20 | #ifndef _LENSOR_OS_STUB_H
21 | #define _LENSOR_OS_STUB_H
22 |
23 | #include "../assert.h"
24 |
25 | #define _LIBC_STUB() \
26 | do { \
27 | __libc_assert(false, "Not implemented"); \
28 | } while (0)
29 |
30 | #endif // _LENSOR_OS_STUB_H
31 |
--------------------------------------------------------------------------------
/user/libc/crt0.s:
--------------------------------------------------------------------------------
1 | ;;;# Copyright 2022, Contributors To LensorOS.
2 | ;;;# All rights reserved.
3 | ;;;#
4 | ;;;# This file is part of LensorOS.
5 | ;;;#
6 | ;;;# LensorOS is free software: you can redistribute it and/or modify
7 | ;;;# it under the terms of the GNU General Public License as published by
8 | ;;;# the Free Software Foundation, either version 3 of the License, or
9 | ;;;# (at your option) any later version.
10 | ;;;#
11 | ;;;# LensorOS is distributed in the hope that it will be useful,
12 | ;;;# but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | ;;;# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | ;;;# GNU General Public License for more details.
15 | ;;;#
16 | ;;;# You should have received a copy of the GNU General Public License
17 | ;;;# along with LensorOS. If not, see .
20 |
21 | if [ -z $1 ]; then
22 | echo "No target directory given. Please specify the sysroot directory as an argument on the command line."
23 | exit 1
24 | fi
25 | echo "Copying headers to $1/usr/include"
26 | find ./ -name '*.h' -exec cp --parents {} $1/usr/include ';'
27 | if [ -d "bld" ]; then
28 | echo "Copying libc to $1/usr/lib"
29 | cp bld/libc.a $1/usr/lib/
30 | fi
31 |
--------------------------------------------------------------------------------
/user/libc/limits.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see .
18 | */
19 |
20 | #ifndef _LIMITS_H
21 | #define _LIMITS_H
22 |
23 | #if defined (__cplusplus)
24 | extern "C" {
25 | #endif
26 |
27 | #define INT_MAX INT32_MAX
28 | #define INT_MIN INT32_MIN
29 |
30 | #define UINT_MAX UINT32_MAX
31 |
32 | #define CHAR_BIT 8
33 | #define SCHAR_MIN (-128)
34 | #define SCHAR_MAX 127
35 | #define UCHAR_MAX 255
36 |
37 | #define SHRT_MAX 32768
38 | #define SHRT_MIN (-SHRT_MAX - 1)
39 |
40 | #define USHRT_MAX 65535
41 |
42 | #define LONG_MAX 2147483647L
43 | #define LONG_MIN (-LONG_MAX - 1L)
44 |
45 | #define ULONG_MAX 4294967295UL
46 |
47 | #define LONG_LONG_MAX 9223372036854775807LL
48 | #define LONG_LONG_MIN (-LONG_LONG_MAX - 1LL)
49 |
50 | #define LLONG_MAX LONG_LONG_MAX
51 | #define LLONG_MIN LONG_LONG_MIN
52 |
53 | #define ULONG_LONG_MAX 18446744073709551615ULL
54 | #define ULLONG_MAX ULONG_LONG_MAX
55 |
56 | #define CHAR_MIN SCHAR_MIN
57 | #define CHAR_MAX SCHAR_MAX
58 |
59 | #if defined (__cplusplus)
60 | } /* extern "C" */
61 | #endif
62 |
63 | #endif /* _LIMITS_H */
64 |
--------------------------------------------------------------------------------
/user/libc/stdalign.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see .
18 | */
19 |
20 |
21 | #ifndef _STDALIGN_H
22 | #define _STDALIGN_H
23 |
24 | #if defined (__cplusplus)
25 | extern "C" {
26 | #endif
27 |
28 | #ifndef __cplusplus
29 |
30 | #if __STDC_VERSION__ < 201112L && defined(__GNUC__)
31 | #define _Alignas(t) __attribute__((__aligned__(t)))
32 | #define _Alignof(t) __alignof__(t)
33 | #endif /* C11 or compiler extensions */
34 |
35 | #define alignas _Alignas
36 | #define alignof _Alignof
37 |
38 | #endif /* __cplusplus */
39 |
40 | #define __alignas_is_defined 1
41 | #define __alignof_is_defined 1
42 |
43 | #if defined (__cplusplus)
44 | } /* extern "C" */
45 | #endif
46 |
47 | #endif /* _STDALIGN_H */
48 |
--------------------------------------------------------------------------------
/user/libc/stdarg.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see .
18 | */
19 |
20 |
21 | #ifndef _STDARG_H
22 | #define _STDARG_H
23 |
24 | #include "bits/decls.h"
25 |
26 | __BEGIN_DECLS__
27 |
28 | typedef __builtin_va_list va_list;
29 |
30 | #define va_start(__ap,__last) __builtin_va_start(__ap, __last)
31 | #define va_end(__ap) __builtin_va_end(__ap)
32 | #define va_arg(__ap,__type) __builtin_va_arg(__ap,__type)
33 | #define va_copy(__dest, __src) __builtin_va_copy(__dest,__src)
34 |
35 | __END_DECLS__
36 |
37 | #endif /* _STDARG_H */
38 |
--------------------------------------------------------------------------------
/user/libc/stdbool.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see .
18 | */
19 |
20 |
21 | #ifndef _STDBOOL_H
22 | #define _STDBOOL_H
23 |
24 | #ifndef __cplusplus
25 |
26 | #define true 1
27 | #define false 0
28 | #define bool _Bool
29 |
30 | #endif /* __cplusplus */
31 |
32 | #define __bool_true_false_are_defined 1
33 |
34 | #endif /* _STDBOOL_H */
35 |
--------------------------------------------------------------------------------
/user/libc/stdnoreturn.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see .
18 | */
19 |
20 |
21 | #ifndef _STDNORETURN_H
22 | #define _STDNORETURN_H
23 |
24 | #ifndef __cplusplus
25 | #define noreturn _Noreturn
26 | #endif
27 |
28 | #endif /* _STDNORETURN_H */
29 |
--------------------------------------------------------------------------------
/user/libc/sys/types.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see .
18 | */
19 |
20 |
21 | #ifndef _TYPES_H
22 | #define _TYPES_H
23 |
24 | #include
25 | #include
26 |
27 | __BEGIN_DECLS__
28 |
29 | #define unsigned signed
30 | typedef __SIZE_TYPE__ ssize_t;
31 | #undef unsigned
32 |
33 | #ifndef __kernel__
34 | typedef int64_t pid_t;
35 | #endif
36 |
37 | typedef int64_t blkcnt_t;
38 | typedef int64_t blksize_t;
39 | typedef uint64_t clock_t;
40 | typedef uint64_t clockid_t;
41 | typedef uint64_t dev_t;
42 | typedef uint64_t fsblkcnt_t;
43 | typedef uint64_t fsfilcnt_t;
44 | typedef uint64_t fpos_t;
45 | typedef uint64_t gid_t;
46 | typedef uint64_t id_t;
47 | typedef uint64_t ino_t;
48 | typedef uint64_t mode_t;
49 | typedef uint64_t nlink_t;
50 | typedef int64_t off_t;
51 | typedef uint64_t size_t;
52 | typedef int64_t ssize_t;
53 | typedef uint64_t time_t;
54 | typedef uint64_t timer_t;
55 | typedef uint64_t uid_t;
56 |
57 | __END_DECLS__
58 |
59 | #endif /* _TYPES_H */
60 |
--------------------------------------------------------------------------------
/user/libc/template.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see .
18 | */
19 |
20 |
21 | #ifndef _STDDEF_H
22 | #define _STDDEF_H
23 |
24 | #if defined (__cplusplus)
25 | extern "C" {
26 | #endif
27 |
28 |
29 |
30 | #if defined (__cplusplus)
31 | } /* extern "C" */
32 | #endif
33 |
34 | #endif
35 |
--------------------------------------------------------------------------------
/user/libc/test/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright 2022, Contributors To LensorOS.
2 | # All rights reserved.
3 | #
4 | # This file is part of LensorOS.
5 | #
6 | # LensorOS is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # LensorOS is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with LensorOS. If not, see .
18 |
19 | cmake_minimum_required(VERSION 3.14)
20 | project(libc-tests C CXX ASM)
21 |
22 | # Don't build LibC for LensorOS.
23 | set(LENSOR_OS_LIBC_BUILD_HOST 1)
24 | set(CMAKE_CXX_STANDARD 20)
25 |
26 | # Build libc.
27 | add_subdirectory(.. libc)
28 |
29 | # Build the tests.
30 | add_executable(test test.cc)
31 | target_compile_options(
32 | test
33 | PRIVATE
34 | -Wall -Wextra -Werror=return-type
35 | -Wno-unused-parameter -Wno-unused-variable
36 | -O0 -g
37 | )
38 | target_link_libraries(test PRIVATE c)
39 |
40 |
--------------------------------------------------------------------------------
/user/libc/test/test.cc:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | int main(int argc, char** argv) {
5 | std::print("argc: {}\n", argc);
6 | for (int i = 0; i < argc; i++) {
7 | std::print("argv[{}]: {}\n", i, (const char*) argv[i]);
8 | }
9 | }
--------------------------------------------------------------------------------
/user/libc/tests/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.20)
2 | project(tests C CXX ASM)
3 | enable_testing()
4 |
5 | # Don't build LibC for LensorOS.
6 | set(LENSOR_OS_LIBC_BUILD_HOST 1)
7 | set(CMAKE_CXX_STANDARD 20)
8 |
9 | add_subdirectory(.. libc)
10 |
11 | add_library(options INTERFACE)
12 | target_compile_options(options INTERFACE
13 | -Wall -Wextra -Wconversion -Wundef
14 | -Werror=return-type
15 | -O0 -g
16 | )
17 | target_include_directories(options INTERFACE
18 | "${PROJECT_SOURCE_DIR}"
19 | )
20 | target_link_libraries(options INTERFACE c)
21 |
22 | set(global_test_counter 0)
23 |
24 | function(test name file)
25 | set(counter "${global_test_counter}")
26 | set(target_name "target${counter}")
27 | math(EXPR newcounter "${counter} + 1")
28 | set(global_test_counter "${newcounter}" PARENT_SCOPE)
29 |
30 | add_executable("${target_name}" "${file}")
31 | target_link_libraries("${target_name}" options)
32 | add_test("${name}" "${target_name}")
33 | endfunction()
34 |
35 | test("string/base" "${PROJECT_SOURCE_DIR}/test/string/base.cpp")
36 | test("string/cat" "${PROJECT_SOURCE_DIR}/test/string/cat.cpp")
37 | test("string/compare" "${PROJECT_SOURCE_DIR}/test/string/compare.cpp")
38 | test("string/starts-ends" "${PROJECT_SOURCE_DIR}/test/string/starts-ends.cpp")
39 | test("string/misc" "${PROJECT_SOURCE_DIR}/test/string/misc.cpp")
40 | test("string/compare-lex" "${PROJECT_SOURCE_DIR}/test/string/compare-lex.cpp")
41 | test("string/erase" "${PROJECT_SOURCE_DIR}/test/string/erase.cpp")
42 | test("string/view" "${PROJECT_SOURCE_DIR}/test/string/view.cpp")
43 | test("string/substr" "${PROJECT_SOURCE_DIR}/test/string/substr.cpp")
44 |
--------------------------------------------------------------------------------
/user/libc/tests/add-test.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -eu
3 |
4 | die() {
5 | echo "$1"
6 | exit 1
7 | }
8 |
9 | ## Need at least one argument.
10 | test $# -lt 2 || die "Usage: ./add-test.sh "
11 |
12 | project_path=$(dirname "$0")
13 | test_path=$project_path/test
14 | test_file=$test_path/$1.cpp
15 | test_name=$1
16 |
17 |
18 | ## Make sure the file doesn’t already exist.
19 | test -e "$test_file" && die "Error: File \"$1\" already exists"
20 |
21 | ## Make sure the parent directory of the file exists.
22 | mkdir -p "$(dirname "$test_file")"
23 |
24 | ## Generate a test stub.
25 | cat > "$test_file" << END
26 | #include
27 |
28 | int main() {
29 |
30 | }
31 | END
32 |
33 | ## Add the test to the CMakeLists.txt.
34 | echo -e "test(\"$test_name\" \"\${PROJECT_SOURCE_DIR}/test/$test_name.cpp\")" >> "$project_path/CMakeLists.txt"
35 |
--------------------------------------------------------------------------------
/user/libc/tests/test/string/base.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | int main() {
5 | std::string a;
6 | std::string b = "123456";
7 | std::string c = "23456789012345678923456789234567823456782345678345678";
8 |
9 | ensure a.size() == 0;
10 | ensure b.size() == 6;
11 | ensure c.size() == 53;
12 | ensure eq(b.data(), "123456", 6);
13 | ensure eq(c.data(), "23456789012345678923456789234567823456782345678345678", 53);
14 | }
--------------------------------------------------------------------------------
/user/libc/tests/test/string/cat.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | int main() {
5 | std::string a = "1234";
6 | std::string b = "abcd";
7 |
8 | /// Short string concatenation.
9 | a += b;
10 | ensure a.size() == 8;
11 | ensure eq(a.data(), "1234abcd", 8);
12 |
13 | const char in1[] = "2-439t2-49tj234-9tj2-49tj2w4-tj249tj24-tj24t-jk24t-92wj4t9j";
14 | std::string c = in1;
15 |
16 | /// Long string concatenation.
17 | a += c;
18 | ensure a.size() == 8 + sizeof in1 - 1;
19 | ensure eq(a.data(), "1234abcd2-439t2-49tj234-9tj2-49tj2w4-tj249tj24-tj24t-jk24t-92wj4t9j", 8 + sizeof in1 - 1);
20 |
21 | /// Operator +
22 | std::string d = a + b;
23 | std::string e = c + c;
24 |
25 | ensure d.size() == a.size() + b.size();
26 | ensure eq(d.data(), "1234abcd2-439t2-49tj234-9tj2-49tj2w4-tj249tj24-tj24t-jk24t-92wj4t9jabcd", d.size());
27 | ensure e.size() == c.size() + c.size();
28 | ensure eq(e.data(), "2-439t2-49tj234-9tj2-49tj2w4-tj249tj24-tj24t-jk24t-92wj4t9j2-439t2-49tj234-9tj2-49tj2w4-tj249tj24-tj24t-jk24t-92wj4t9j", e.size());
29 | }
30 |
--------------------------------------------------------------------------------
/user/libc/tests/test/string/compare-lex.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | int main() {
5 | std::string a = "foobar";
6 | std::string b = "foobbr";
7 | std::string c = "barfoo";
8 | std::string d = "foob";
9 |
10 | ensure a < b;
11 | ensure c < a;
12 | ensure c < b;
13 | ensure d < a;
14 | ensure d < b;
15 | ensure a <= a;
16 | ensure a >= a;
17 | ensure a != b;
18 | ensure a != d;
19 | }
20 |
--------------------------------------------------------------------------------
/user/libc/tests/test/string/compare.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | int main() {
5 | std::string a = "1234";
6 | std::string b = "1234";
7 |
8 | ensure a == "1234";
9 | ensure a == b;
10 |
11 | const char in[] = "2-439t2-49tj234-9tj2-49tj2w4-tj249tj24-tj24t-jk24t-92wj4t9j";
12 | std::string c = in;
13 | std::string d = in;
14 |
15 | ensure c == in;
16 | ensure c == d;
17 | }
18 |
--------------------------------------------------------------------------------
/user/libc/tests/test/string/erase.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | int main() {
5 | std::string s = "1234567890";
6 |
7 | s.erase(2, 1);
8 | ensure s == "124567890";
9 |
10 | s.erase(2, 3);
11 | ensure s == "127890";
12 |
13 | s.erase(4);
14 | ensure s == "1278";
15 |
16 | s.erase();
17 | ensure s.empty();
18 |
19 | s = "1234567890";
20 |
21 | s.erase(s.begin() + 2, s.begin() + 3);
22 | ensure s == "124567890";
23 |
24 | s.erase(s.begin() + 2, s.begin() + 5);
25 | ensure s == "127890";
26 |
27 | s.erase(s.begin() + 4, s.end());
28 | ensure s == "1278";
29 |
30 | s.erase(s.begin());
31 | ensure s == "278";
32 |
33 | s.erase(s.begin(), s.end());
34 | ensure s.empty();
35 | }
36 |
--------------------------------------------------------------------------------
/user/libc/tests/test/string/misc.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | int main() {
5 | const char in[] = "2-439t2-49tj234-9tj2-49tj2w4-tj249tj24-tj24t-jk24t-92wj4t9j";
6 | std::string a = "1234";
7 | std::string b = in;
8 | std::string c;
9 |
10 | ensure a.size() == 4;
11 | ensure b.size() == sizeof in - 1;
12 | ensure c.size() == 0;
13 | ensure a.capacity() >= 4;
14 | ensure b.capacity() >= sizeof in - 1;
15 | ensure a[a.size()] == 0;
16 | ensure b[b.size()] == 0;
17 | ensure c[0] == 0;
18 | ensure a.data() == a.c_str();
19 | ensure b.data() == b.c_str();
20 | ensure (a.begin() + ssize_t(a.size())) == a.end();
21 | ensure (b.begin() + ssize_t(b.size())) == b.end();
22 | ensure c.begin() == c.end();
23 | ensure not a.empty();
24 | ensure not b.empty();
25 | ensure c.empty();
26 | ensure a.front() == '1';
27 | ensure b.front() == '2';
28 | ensure a.back() == '4';
29 | ensure b.back() == 'j';
30 | }
31 |
--------------------------------------------------------------------------------
/user/libc/tests/test/string/starts-ends.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | int main() {
5 | std::string a = "123456";
6 |
7 | ensure a.starts_with("123456");
8 | ensure a.starts_with("123");
9 | ensure not a.starts_with("1234567");
10 | ensure not a.starts_with("123457");
11 | ensure not a.starts_with("234");
12 |
13 | ensure a.ends_with("123456");
14 | ensure a.ends_with("456");
15 | ensure not a.ends_with("1234567");
16 | ensure not a.ends_with("123457");
17 | ensure not a.ends_with("345");
18 | }
19 |
--------------------------------------------------------------------------------
/user/libc/tests/test/string/substr.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | int main() {
5 | std::string a = "1234567890";
6 | std::string_view av = a;
7 |
8 | ensure a.substr(4) == "567890";
9 | ensure a.substr() == a;
10 | ensure a.substr(1) == "234567890";
11 | ensure a.substr(2, 5) == "34567";
12 |
13 | /*ensure av.substr(4) == "567890";
14 | ensure av.substr() == av;
15 | ensure av.substr(1) == "234567890";
16 | ensure av.substr(2, 5) == "34567";*/
17 | }
18 |
--------------------------------------------------------------------------------
/user/libc/tests/test/string/view.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | int main() {
5 | const char in[] = "2-439t2-49tj234-9tj2-49tj2w4-tj249tj24-tj24t-jk24t-92wj4t9j";
6 | std::string a = "1234";
7 | std::string b = in;
8 |
9 | std::string_view av = a;
10 | std::string_view bv = b;
11 |
12 | ensure av.data() == a.data();
13 | ensure bv.data() == b.data();
14 |
15 | ensure av.size() == a.size();
16 | ensure bv.size() == b.size();
17 | /*
18 | ensure av == a;
19 | ensure bv == b;
20 |
21 | ensure av == "1234";
22 | ensure bv == in;*/
23 | }
24 |
--------------------------------------------------------------------------------
/user/libc/time.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2022, Contributors To LensorOS.
2 | * All rights reserved.
3 | *
4 | * This file is part of LensorOS.
5 | *
6 | * LensorOS is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * LensorOS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with LensorOS. If not, see .
18 | */
19 |
20 |
21 | #ifndef _TIME_H
22 | #define _TIME_H
23 |
24 | #if defined (__cplusplus)
25 | extern "C" {
26 | #endif
27 |
28 |
29 |
30 | #if defined (__cplusplus)
31 | } /* extern "C" */
32 | #endif
33 |
34 | #endif /* _TIME_H */
35 |
--------------------------------------------------------------------------------
/user/libm/src/stub.cpp:
--------------------------------------------------------------------------------
1 | // It's a stub!
2 | // TODO: Implement libm, ya know?
3 | // Or port another libm to LensorOS.
4 |
--------------------------------------------------------------------------------
/user/libstdc++/src/filesystem.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | namespace std {
5 | namespace filesystem {
6 | bool exists (path path) {
7 | FILE* f = fopen(path.string().data(), "r");
8 | if (!f) return false;
9 | fclose(f);
10 | return true;
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/user/ls/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright 2022, Contributors To LensorOS.
2 | # All rights reserved.
3 | #
4 | # This file is part of LensorOS.
5 | #
6 | # LensorOS is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # LensorOS is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with LensorOS. If not, see
2 | #include
3 |
4 | int main(int argc, char** argv) {
5 | if (argc != 2) {
6 | printf("Please provide exactly one filepath\n");
7 | return 1;
8 | }
9 |
10 | struct DirectoryEntry {
11 | uint32_t type;
12 | char name[248];
13 | };
14 | DirectoryEntry entries[8] = {0};
15 |
16 | int entry_count = syscall(SYS_directory_data, argv[1], &entries[0], 8);
17 | if (entry_count == -1) return 1;
18 |
19 | printf("%s:\n", argv[1]);
20 | for (int i = 0; i < entry_count; ++i) {
21 | const bool last_entry = i + 1 == entry_count;
22 | const bool directory = entries[i].type == 1;
23 |
24 | const char* indent = last_entry ? "`-- " : "|-- ";
25 | const char* dir_mark = directory ? "(D) " : "";
26 |
27 | printf("%s%s%s\n", indent, dir_mark, entries[i].name);
28 | }
29 |
30 | return 0;
31 | }
32 |
--------------------------------------------------------------------------------
/user/pwd/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright 2022, Contributors To LensorOS.
2 | # All rights reserved.
3 | #
4 | # This file is part of LensorOS.
5 | #
6 | # LensorOS is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # LensorOS is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with LensorOS. If not, see
2 | #include
3 | #include
4 |
5 | #define PWD_MAX 4096
6 | static char pwdbuf[PWD_MAX];
7 |
8 | int main(void) {
9 | // TODO: Handle -L and -P arguments.
10 | pwdbuf[0] = '\0';
11 | if (!syscall(SYS_pwd, pwdbuf, PWD_MAX)) return 1;
12 | printf("%s\n", pwdbuf);
13 | return 0;
14 | }
15 |
--------------------------------------------------------------------------------
/user/servertest/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright 2022, Contributors To LensorOS.
2 | # All rights reserved.
3 | #
4 | # This file is part of LensorOS.
5 | #
6 | # LensorOS is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # LensorOS is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with LensorOS. If not, see
5 | #include
6 |
7 | /// 4 bytes per pixel, one byte per color, unless otherwise specified.
8 | typedef enum FramebufferFormat {
9 | FB_FORMAT_INVALID = 0,
10 | FB_FORMAT_ARGB,
11 | FB_FORMAT_BGRA,
12 | FB_FORMAT_ABGR,
13 | FB_FORMAT_MAX,
14 | FB_FORMAT_DEFAULT = FB_FORMAT_ARGB,
15 | } FramebufferFormat;
16 |
17 | typedef struct Framebuffer {
18 | void* base_address;
19 | uint64_t buffer_size;
20 | uint32_t pixel_width;
21 | uint32_t pixel_height;
22 | uint32_t pixels_per_scanline;
23 | FramebufferFormat format;
24 | } Framebuffer;
25 |
26 | /// Get a pixel given a framebuffer format
27 | uint32_t mkpixel(const FramebufferFormat format, const unsigned char r, const unsigned char g, const unsigned char b, const unsigned char a);
28 |
29 | /// Ensure given x and y pixel coordinates are within bounds.
30 | void clamp_draw_position(const Framebuffer fb, size_t *x, size_t *y);
31 |
32 | /// Write a single pixel to the framebuffer (slow).
33 | void write_pixel(const Framebuffer fb, const uint32_t pixel, size_t x, size_t y);
34 |
35 | /// Set each pixel within a rectangle of pixels to the given pixel value.
36 | void fill_rect(const Framebuffer fb, const uint32_t pixel, size_t x, size_t y, size_t w, size_t h);
37 |
38 | /// Set each pixel to given value.
39 | void fill_color(const Framebuffer fb, const uint32_t pixel);
40 |
41 | // TODO: read_*
42 |
43 | #endif /* FRAMEBUFFER_H */
44 |
--------------------------------------------------------------------------------
/user/stdout/ints.h:
--------------------------------------------------------------------------------
1 | #ifndef INTS_H
2 | #define INTS_H
3 |
4 | #include
5 |
6 | /// Unsigned Integer Alias Declaration
7 | typedef unsigned int uint;
8 |
9 | /// Fixed-Width Unsigned Integer Alias Declarations
10 | typedef uint8_t u8;
11 | typedef uint16_t u16;
12 | typedef uint32_t u32;
13 | typedef uint64_t u64;
14 | typedef uintptr_t usz;
15 |
16 | /// Fixed-Width Signed Integer Alias Declarations
17 | typedef int8_t s8;
18 | typedef int16_t s16;
19 | typedef int32_t s32;
20 | typedef int64_t s64;
21 | typedef intptr_t ssz;
22 |
23 | #endif /* INTS_H */
24 |
--------------------------------------------------------------------------------
/user/stdout/psf.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include
4 |
5 | void psf1_delete(const PSF1_FONT font) {
6 | free(font.glyph_buffer);
7 | }
8 | u8 psf1_width(const PSF1_FONT font) {
9 | return 8;
10 | }
11 | u8 psf1_height(const PSF1_FONT font) {
12 | return font.header.character_size;
13 | }
14 | /// bitmap size is as follows: (8, font.header->character_size)
15 | /// @return address of beginning of bitmap pertaining to given character.
16 | u8* psf1_char_bitmap(const PSF1_FONT font, const u8 c) {
17 | return (u8*)font.glyph_buffer + (c * psf1_height(font));
18 | }
19 |
--------------------------------------------------------------------------------
/user/stdout/psf.h:
--------------------------------------------------------------------------------
1 | #ifndef PSF_H
2 | #define PSF_H
3 |
4 | #include
5 |
6 | #define PSF1_MAGIC0 0x36
7 | #define PSF1_MAGIC1 0x04
8 | typedef struct PSF1_HEADER {
9 | // Magic bytes to indicate PSF1 font type
10 | u8 magic[2];
11 | u8 mode;
12 | u8 character_size;
13 | } PSF1_HEADER;
14 | typedef struct PSF1_FONT {
15 | PSF1_HEADER header;
16 | void* glyph_buffer;
17 | } PSF1_FONT;
18 |
19 | void psf1_delete(const PSF1_FONT font);
20 | u8 psf1_width(const PSF1_FONT font);
21 | u8 psf1_height(const PSF1_FONT font);
22 | u8* psf1_char_bitmap(const PSF1_FONT font, const u8 c);
23 |
24 | #endif /* PSF_H */
25 |
--------------------------------------------------------------------------------
/user/xish/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright 2022, Contributors To LensorOS.
2 | # All rights reserved.
3 | #
4 | # This file is part of LensorOS.
5 | #
6 | # LensorOS is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # LensorOS is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with LensorOS. If not, see