Repository: thethumbler/Aquila Branch: master Commit: eb1d273218e5 Files: 453 Total size: 1.3 MB Directory structure: gitextract__96k71ly/ ├── .gitignore ├── .gitlab-ci.yml ├── .travis.yml ├── LICENSE ├── Makefile ├── README.md ├── configs/ │ ├── clang.mk │ ├── gcc.mk │ ├── i386-pc.mk │ ├── i386-quark.mk │ ├── none.mk │ ├── pcc.mk │ └── x86_64-pc.mk ├── initrd/ │ ├── Makefile │ ├── etc/ │ │ ├── font.tf │ │ ├── hostname │ │ ├── motd │ │ ├── passwd │ │ └── rc.init │ ├── init/ │ │ ├── Makefile │ │ └── init.c │ └── usr/ │ ├── bin/ │ │ ├── p++ │ │ ├── pcc │ │ └── pcpp │ ├── libexec/ │ │ ├── ccom │ │ ├── cpp │ │ └── cxxcom │ ├── share/ │ │ └── man/ │ │ └── man1/ │ │ ├── ccom.1 │ │ ├── cpp.1 │ │ ├── p++.1 │ │ ├── pcc.1 │ │ └── pcpp.1 │ └── test.c ├── iso/ │ └── boot/ │ └── grub/ │ └── grub.cfg ├── kernel/ │ ├── Makefile │ ├── README.md │ ├── arch/ │ │ ├── Build.mk │ │ ├── Makefile │ │ ├── arm/ │ │ │ ├── Build.mk │ │ │ ├── include/ │ │ │ │ ├── core/ │ │ │ │ │ └── types.h │ │ │ │ ├── cpu/ │ │ │ │ │ └── io.h │ │ │ │ └── mm/ │ │ │ │ └── mm.h │ │ │ ├── kernel.arm.ld │ │ │ └── none.c │ │ ├── i386/ │ │ │ ├── Build.mk │ │ │ ├── Makefile │ │ │ ├── boot/ │ │ │ │ ├── Build.mk │ │ │ │ ├── Makefile │ │ │ │ ├── init.c │ │ │ │ ├── multiboot.S │ │ │ │ ├── sys.S │ │ │ │ └── x86_64_bootstrap.S │ │ │ ├── cpu/ │ │ │ │ ├── Build.mk │ │ │ │ ├── Makefile │ │ │ │ ├── arith.c │ │ │ │ ├── cpu.S │ │ │ │ ├── cpu.h │ │ │ │ ├── fpu.c │ │ │ │ ├── gdt.c │ │ │ │ ├── idt.c │ │ │ │ ├── init.c │ │ │ │ ├── isr.c │ │ │ │ ├── smp.S │ │ │ │ └── trace.c │ │ │ ├── earlycon/ │ │ │ │ ├── Build.mk │ │ │ │ ├── Makefile │ │ │ │ ├── earlycon.c │ │ │ │ ├── fb.c │ │ │ │ ├── font.h │ │ │ │ ├── uart.c │ │ │ │ └── vga.c │ │ │ ├── include/ │ │ │ │ ├── boot/ │ │ │ │ │ ├── boot.h │ │ │ │ │ └── multiboot.h │ │ │ │ ├── config.h │ │ │ │ ├── core/ │ │ │ │ │ ├── _string.h │ │ │ │ │ ├── arch.h │ │ │ │ │ ├── panic.h │ │ │ │ │ ├── platform.h │ │ │ │ │ └── system.h │ │ │ │ ├── cpu/ │ │ │ │ │ ├── cpu.h │ │ │ │ │ ├── cpuid.h │ │ │ │ │ ├── io.h │ │ │ │ │ ├── msr.h │ │ │ │ │ ├── pit.h │ │ │ │ │ └── sdt.h │ │ │ │ ├── mm/ │ │ │ │ │ ├── mm.h │ │ │ │ │ └── pmap.h │ │ │ │ └── platform/ │ │ │ │ └── misc.h │ │ │ ├── kernel.i386.ld │ │ │ ├── kernel.x86_64.ld │ │ │ ├── mm/ │ │ │ │ ├── Build.mk │ │ │ │ ├── Makefile │ │ │ │ ├── frame_utils.h │ │ │ │ ├── i386.c │ │ │ │ ├── i386.h │ │ │ │ ├── mm.c │ │ │ │ ├── page_utils.h │ │ │ │ ├── x86_64.c │ │ │ │ └── x86_64.h │ │ │ ├── platform/ │ │ │ │ ├── Build.mk │ │ │ │ ├── Makefile │ │ │ │ ├── misc/ │ │ │ │ │ ├── Build.mk │ │ │ │ │ ├── Makefile │ │ │ │ │ ├── acpi.c │ │ │ │ │ ├── cmos.c │ │ │ │ │ ├── hpet.c │ │ │ │ │ ├── i8042.c │ │ │ │ │ ├── pic.c │ │ │ │ │ └── pit.c │ │ │ │ ├── pc/ │ │ │ │ │ ├── Build.mk │ │ │ │ │ ├── Makefile │ │ │ │ │ ├── init.c │ │ │ │ │ └── reboot.c │ │ │ │ └── quark/ │ │ │ │ ├── Build.mk │ │ │ │ ├── include/ │ │ │ │ │ └── chipset/ │ │ │ │ │ ├── legacy_bridge.h │ │ │ │ │ ├── root_complex.h │ │ │ │ │ └── system.h │ │ │ │ ├── init.c │ │ │ │ └── legacy/ │ │ │ │ ├── Build.mk │ │ │ │ ├── bridge.c │ │ │ │ ├── interrupt.c │ │ │ │ └── root_complex.c │ │ │ └── sys/ │ │ │ ├── Build.mk │ │ │ ├── Makefile │ │ │ ├── execve.c │ │ │ ├── fork.c │ │ │ ├── proc.c │ │ │ ├── sched.c │ │ │ ├── signal.c │ │ │ ├── sys.h │ │ │ ├── syscall.c │ │ │ └── thread.c │ │ └── none/ │ │ ├── Build.mk │ │ ├── include/ │ │ │ ├── core/ │ │ │ │ └── types.h │ │ │ ├── cpu/ │ │ │ │ └── io.h │ │ │ └── mm/ │ │ │ └── mm.h │ │ ├── kernel.none.ld │ │ └── none.c │ ├── core/ │ │ ├── Build.mk │ │ ├── Makefile │ │ ├── kargs.c │ │ ├── main.c │ │ ├── module.c │ │ ├── printk.c │ │ ├── snprintf.c │ │ └── time.c │ ├── dev/ │ │ ├── Build.mk │ │ ├── Makefile │ │ ├── ata/ │ │ │ ├── Build.mk │ │ │ ├── Makefile │ │ │ ├── ata.c │ │ │ ├── ata.h │ │ │ └── pio.c │ │ ├── fb/ │ │ │ ├── Build.mk │ │ │ ├── Makefile │ │ │ ├── fbdev/ │ │ │ │ ├── Build.mk │ │ │ │ ├── Makefile │ │ │ │ └── fbdev.c │ │ │ └── vesa/ │ │ │ ├── Build.mk │ │ │ ├── Makefile │ │ │ └── vesa.c │ │ ├── fdc/ │ │ │ ├── Build.mk │ │ │ ├── fdc.c │ │ │ ├── fdc_82077AA.c │ │ │ └── fdc_82077AA.h │ │ ├── kbd/ │ │ │ ├── Build.mk │ │ │ ├── Makefile │ │ │ ├── kbd.c │ │ │ └── ps2kbd.c │ │ ├── kdev.c │ │ ├── mem/ │ │ │ ├── Build.mk │ │ │ ├── Makefile │ │ │ ├── kmsg.c │ │ │ ├── memdev.c │ │ │ ├── memdev.h │ │ │ ├── null.c │ │ │ └── zero.c │ │ ├── mouse/ │ │ │ ├── Build.mk │ │ │ ├── Makefile │ │ │ └── ps2mouse.c │ │ ├── pci/ │ │ │ ├── Build.mk │ │ │ ├── Makefile │ │ │ └── pci.c │ │ ├── rd/ │ │ │ ├── Build.mk │ │ │ ├── Makefile │ │ │ └── ramdisk.c │ │ └── tty/ │ │ ├── Build.mk │ │ ├── Makefile │ │ ├── console/ │ │ │ ├── Build.mk │ │ │ ├── Makefile │ │ │ └── console.c │ │ ├── generic.c │ │ ├── pty/ │ │ │ ├── Build.mk │ │ │ ├── Makefile │ │ │ └── pty.c │ │ ├── tty.c │ │ └── uart/ │ │ ├── 8250/ │ │ │ ├── 8250.c │ │ │ ├── Build.mk │ │ │ └── Makefile │ │ ├── Build.mk │ │ ├── Makefile │ │ └── uart.c │ ├── fs/ │ │ ├── Build.mk │ │ ├── Makefile │ │ ├── bcache.c │ │ ├── close.c │ │ ├── devfs/ │ │ │ ├── Build.mk │ │ │ ├── Makefile │ │ │ └── devfs.c │ │ ├── devpts/ │ │ │ ├── Build.mk │ │ │ ├── Makefile │ │ │ └── devpts.c │ │ ├── ext2/ │ │ │ ├── Build.mk │ │ │ ├── Makefile │ │ │ ├── block.c │ │ │ ├── dentry.c │ │ │ ├── ext2.c │ │ │ ├── ext2.h │ │ │ ├── inode.c │ │ │ ├── super.c │ │ │ └── vops.c │ │ ├── fops.c │ │ ├── initramfs/ │ │ │ ├── Build.mk │ │ │ ├── Makefile │ │ │ ├── cpio/ │ │ │ │ ├── Build.mk │ │ │ │ ├── Makefile │ │ │ │ ├── cpio.c │ │ │ │ └── cpio.h │ │ │ └── initramfs.c │ │ ├── ioctl.c │ │ ├── lookup.c │ │ ├── minix/ │ │ │ ├── Build.mk │ │ │ ├── Makefile │ │ │ ├── block.c │ │ │ ├── dentry.c │ │ │ ├── inode.c │ │ │ ├── minix.c │ │ │ ├── minix.h │ │ │ ├── super.c │ │ │ └── vops.c │ │ ├── mknod.c │ │ ├── mount.c │ │ ├── pipe.c │ │ ├── posix/ │ │ │ ├── Build.mk │ │ │ ├── Makefile │ │ │ ├── close.c │ │ │ ├── helpers.c │ │ │ ├── ioctl.c │ │ │ ├── lseek.c │ │ │ ├── open.c │ │ │ ├── read.c │ │ │ ├── readdir.c │ │ │ ├── trunc.c │ │ │ └── write.c │ │ ├── procfs/ │ │ │ ├── Build.mk │ │ │ ├── Makefile │ │ │ └── procfs.c │ │ ├── pseudofs/ │ │ │ ├── Build.mk │ │ │ ├── Makefile │ │ │ └── pseudofs.c │ │ ├── read.c │ │ ├── readdir.c │ │ ├── rofs.c │ │ ├── stat.c │ │ ├── sync.c │ │ ├── tmpfs/ │ │ │ ├── Build.mk │ │ │ ├── Makefile │ │ │ └── tmpfs.c │ │ ├── trunc.c │ │ ├── unlink.c │ │ ├── vcache.c │ │ ├── vfs.c │ │ ├── vm_object.c │ │ ├── vops.c │ │ └── write.c │ ├── include/ │ │ ├── bits/ │ │ │ ├── dirent.h │ │ │ ├── errno.h │ │ │ ├── fcntl.h │ │ │ ├── mman.h │ │ │ └── utsname.h │ │ ├── boot/ │ │ │ └── boot.h │ │ ├── config.h │ │ ├── console/ │ │ │ └── earlycon.h │ │ ├── core/ │ │ │ ├── arch.h │ │ │ ├── assert.h │ │ │ ├── kargs.h │ │ │ ├── module.h │ │ │ ├── panic.h │ │ │ ├── printk.h │ │ │ ├── qsort.h │ │ │ ├── string.h │ │ │ ├── system.h │ │ │ ├── time.h │ │ │ └── types.h │ │ ├── cpu/ │ │ │ ├── cpu.h │ │ │ └── io.h │ │ ├── dev/ │ │ │ ├── console.h │ │ │ ├── dev.h │ │ │ ├── fbdev.h │ │ │ ├── kbd.h │ │ │ ├── pci.h │ │ │ ├── ramdev.h │ │ │ ├── tty.h │ │ │ ├── ttydev.h │ │ │ └── uart.h │ │ ├── ds/ │ │ │ ├── bitmap.h │ │ │ ├── buddy.h │ │ │ ├── ds.dox │ │ │ ├── hashmap.h │ │ │ ├── queue.h │ │ │ └── ringbuf.h │ │ ├── fs/ │ │ │ ├── bcache.h │ │ │ ├── devfs.h │ │ │ ├── devpts.h │ │ │ ├── initramfs.h │ │ │ ├── ioctl.h │ │ │ ├── mbr.h │ │ │ ├── pipe.h │ │ │ ├── posix.h │ │ │ ├── pseudofs.h │ │ │ ├── rofs.h │ │ │ ├── stat.h │ │ │ ├── termios.h │ │ │ ├── tmpfs.h │ │ │ ├── vcache.h │ │ │ └── vfs.h │ │ ├── mm/ │ │ │ ├── buddy.h │ │ │ ├── heap.h │ │ │ ├── kvmem.h │ │ │ ├── mm.h │ │ │ ├── pmap.h │ │ │ └── vm.h │ │ ├── net/ │ │ │ └── socket.h │ │ ├── stdarg.h │ │ ├── stddef.h │ │ ├── stdint.h │ │ ├── sys/ │ │ │ ├── binfmt.h │ │ │ ├── elf.h │ │ │ ├── proc.h │ │ │ ├── sched.h │ │ │ ├── signal.h │ │ │ ├── syscall.h │ │ │ └── thread.h │ │ └── video/ │ │ ├── vbe.h │ │ └── vesa.h │ ├── mm/ │ │ ├── Build.mk │ │ ├── Makefile │ │ ├── buddy.c │ │ ├── fault.c │ │ ├── kvmem.c │ │ ├── mm.c │ │ ├── vm_anon.c │ │ ├── vm_entry.c │ │ ├── vm_object.c │ │ ├── vm_space.c │ │ └── vmm.c │ ├── net/ │ │ ├── Build.mk │ │ ├── Makefile │ │ ├── socket.c │ │ └── unix/ │ │ ├── Build.mk │ │ ├── Makefile │ │ ├── unix.c │ │ └── unix.h │ └── sys/ │ ├── Build.mk │ ├── Makefile │ ├── binfmt/ │ │ ├── Build.mk │ │ ├── Makefile │ │ ├── binfmt.c │ │ └── elf.c │ ├── execve.c │ ├── fork.c │ ├── proc.c │ ├── sched.c │ ├── signal.c │ ├── syscall.c │ └── thread.c ├── loader/ │ ├── grub-legacy/ │ │ └── boot/ │ │ └── grub/ │ │ └── menu.lst │ └── grub2/ │ └── boot/ │ └── grub/ │ └── grub.cfg └── system/ ├── Makefile ├── aqbox/ │ ├── Build.mk │ ├── Makefile │ ├── aqbox.c │ ├── extra/ │ │ ├── Build.mk │ │ ├── Makefile │ │ ├── bim.c │ │ ├── clear.c │ │ ├── mknod.c │ │ ├── mktemp.c │ │ ├── readmbr.c │ │ ├── stat.c │ │ ├── truncate.c │ │ └── vmstat.c │ ├── include/ │ │ ├── aq_applets.h │ │ └── aqbox.h │ ├── posix/ │ │ ├── Build.mk │ │ ├── Makefile │ │ ├── cat.c │ │ ├── date.c │ │ ├── echo.c │ │ ├── env.c │ │ ├── kill.c │ │ ├── ls.c │ │ ├── mkdir.c │ │ ├── ps.c │ │ ├── pwd.c │ │ ├── sh.c │ │ ├── touch.c │ │ ├── uname.c │ │ └── unlink.c │ └── sys/ │ ├── Build.mk │ ├── Makefile │ ├── getty.c │ ├── login.c │ ├── mount.c │ └── reboot.c ├── fbterm/ │ ├── Build.mk │ ├── Makefile │ ├── aqkb.c │ ├── fb.c │ ├── fbterm.c │ ├── font.c │ ├── include/ │ │ ├── aqkb.h │ │ ├── config.h │ │ ├── fb.h │ │ ├── fbterm.h │ │ ├── tinyfont.h │ │ ├── vterm.h │ │ └── vterm_keycodes.h │ ├── libvterm/ │ │ ├── Build.mk │ │ ├── Makefile │ │ ├── encoding/ │ │ │ ├── DECdrawing.inc │ │ │ ├── DECdrawing.tbl │ │ │ ├── uk.inc │ │ │ └── uk.tbl │ │ ├── encoding.c │ │ ├── keyboard.c │ │ ├── mouse.c │ │ ├── parser.c │ │ ├── pen.c │ │ ├── rect.h │ │ ├── screen.c │ │ ├── state.c │ │ ├── unicode.c │ │ ├── utf8.h │ │ ├── vterm.c │ │ └── vterm_internal.h │ └── nanojpeg.c ├── kilo/ │ ├── Build.mk │ ├── LICENSE │ ├── Makefile │ ├── README.md │ └── kilo.c └── scripts/ └── gen.pl ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ *.o *.iso *.elf *.img tools/ graph.sh tags mnt/ build-tools/* !build-tools/build.sh !build-tools/aquila/ !build-tools/patches/ ramdisk/sysroot ramdisk/out system/usr system/nuklear/nuklear system/nuklear/libnk.a system/fbterm/fbterm system/aqbox/aqbox ================================================ FILE: .gitlab-ci.yml ================================================ image: manwar/aquila build: stage: build before_script: - apt update && apt -y install make cpio texinfo grub-pc-bin xorriso wget script: - export PATH=$PATH:/opt/aquila/bin - export TRAVIS_BUILD_DIR=$(pwd) - make aquila.iso -j$(nproc) artifacts: paths: - aquila.iso ================================================ FILE: .travis.yml ================================================ language: c before_install: - sudo apt-get update -qq - sudo apt-get install -qq texinfo grub-pc-bin xorriso install: - cd build-tools && bash build.sh && cd .. cache: directories: # Cache Packages - build-tools/pkgs # And unpacked directories - build-tools/binutils-2.28 - build-tools/gcc-7.3.0 - build-tools/autoconf-2.69 - build-tools/automake-1.12.1 # And gcc cross compiler - build-tools/sysroot script: - make aquila.iso deploy: provider: releases api_key: secure: aFJAuaPBhCn7R+4Ymeu12E0WapPSQFDljtCrqFOSsq/vCOJ7QeXuKp0P6XEXEPpZ2mv4V9GVnGHjWflWCH1frWHbCCSZsWkR36Rxlv0sY8ufoMjWeJqkcn1BNUVluGoZSjXyYp9jzFei6kbkk4jsoh3ipfFj8VK/i3qIZuUl7DAz70y8cg9z1Ue3FGgSq010+QI6iH/+hYssn1hJgtyOLmM8Fe4rRADBeAZQ8XFohqj1yTQRCAyVnL96OGes5mBGfYSikwU8n6errx78FI9ei7CkZEqZtqwoBxyX9XKbCo5TcdIITZ/7vXfiEf/3u/G6623M5pPPXRrxZfWcU+Oon20eQU9CKlGnzaMlGXTU6KtqeT53ullkCBC3X6dWwflcFXel/rpSXfyJY5ihllB4CpD/kXWSEZaFm/ip2II+MrkIK+qm469WArMNWvx7NqdC9BujEJ2phrT667qPzoUe+O7XCPxlWrcHJa8veo2GN1f2O8pH1PEvHPMWZfK0Z9N3ZKpLLn3P9BtMh0Chw0Cy+qMEa9Q3joRGBrQAzVUhGcCl9RsSWb89W7v1kvc6C9oiGO1Q+SRcdJtWkFRsjqGGowbzocjakPgJ8NaEztsiZvM0Om7CB0HeJR1fNA2i4NWfLx3GKt81v8/ld4zWjuukIkzxshuXkRqrcYB50cgHXGg= file: aquila.iso skip_cleanup: true on: repo: mohamed-anwar/Aquila tags: true ================================================ FILE: LICENSE ================================================ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. {one line to give the program's name and a brief idea of what it does.} Copyright (C) {year} {name of author} This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: {project} Copyright (C) {year} {fullname} This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . ================================================ FILE: Makefile ================================================ # This is the top leve Makefile of AquilaOS # # Targets: # # build-kernel - build kernel image in kernel/{ARCH}/kernel-{VERSION}.{ARCH} # install-kernel - install kernel image into {DESTDIR}/boot/kernel # clean-kernel - clean kernel source tree # # build-system - build system components # install-system - install system components into {DESTDIR}/ # clean-system - clean system source tree # # build-initrd - build ramdisk image in initrd/initrd.img # install-initrd - install ramdisk image into {DESTDIR}/boot/initrd.img # clean-initrd - clean ramdisk source tree # # build-all - build everything # install-all - install everything # clean-all - clean everything # export ifeq ($(SRCDIR),) SRCDIR := $(TRAVIS_BUILD_DIR) endif ifeq ($(SRCDIR),) SRCDIR != pwd endif ifeq ($(BUILDDIR),) BUILDDIR != pwd endif ifeq ($(CONFIG),) CONFIG := i386-pc endif include $(SRCDIR)/configs/$(CONFIG).mk ARCH=i386 VERSION=0.0.1 CP=cp BASH=bash MKDIR=mkdir -p ECHO=echo STRIP=/opt/aquila/bin/i686-aquila-strip LN=ln MAKEFLAGS += --no-print-directory GRUB_MKRESCUE = $(shell command -v grub2-mkrescue 2> /dev/null) ifeq ($(GRUB_MKRESCUE),) GRUB_MKRESCUE = grub-mkrescue endif DESTDIR = $(SRCDIR)/sysroot .PHONY: build-all install-all clean-all build-all: \ build-kernel \ build-system \ build-initrd install-all: \ install-kernel \ install-system \ install-initrd clean-all: \ clean-kernel \ clean-system \ clean-initrd # # kernel targets # .PHONY: build-kernel clean-kernel install-kernel build-kernel: $(MAKE) -C $(SRCDIR)/kernel/ install-kernel: $(MAKE) -C $(SRCDIR)/kernel/ install clean-kernel: $(MAKE) -C $(SRCDIR)/kernel/ clean # # initrd targets # .PHONY: build-initrd install-initrd clean-initrd build-initrd: build-system $(MAKE) -C $(SRCDIR)/initrd/ install-initrd: build-initrd $(MAKE) -C $(SRCDIR)/initrd/ install clean-initrd: $(MAKE) -C $(SRCDIR)/initrd/ clean # # system targets # .PHONY: build-system install-system clean-system build-system: $(MAKE) -C $(SRCDIR)/system/ install-system: build-system $(MAKE) -C $(SRCDIR)/system/ install clean-system: $(MAKE) -C $(SRCDIR)/system/ clean .PHONY: iso/kernel.elf.gz iso/kernel.elf.gz: build-kernel $(BASH) -c "if [[ ! -e iso ]]; then mkdir iso; fi" $(CP) kernel/arch/$(ARCH)/kernel-$(VERSION).$(ARCH) iso/kernel.elf gzip -f iso/kernel.elf .PHONY: iso/initrd.img.gz iso/initrd.img.gz: build-initrd $(BASH) -c "if [[ ! -e iso ]]; then mkdir iso; fi" cp initrd/initrd.img iso/initrd.img gzip -f iso/initrd.img .PHONY: try try: aquila.iso qemu-kvm -cdrom aquila.iso -hda hd.img -serial stdio -m 2G -d cpu_reset -no-reboot -boot d aquila.iso: iso/kernel.elf.gz iso/initrd.img.gz $(GRUB_MKRESCUE) -d /usr/lib/grub/i386-pc/ -o aquila.iso iso/ # #$(GRUB_MKRESCUE) -d /usr/lib/grub/i386-pc/ --install-modules="multiboot normal videoinfo videotest gzio" --locales="en@quot" --fonts=ascii -o aquila.iso iso/ ================================================ FILE: README.md ================================================ # Aquila OS ![https://travis-ci.org/mohamed-anwar/Aquila](https://api.travis-ci.org/mohamed-anwar/Aquila.svg?branch=master) [![Gitter chat](https://badges.gitter.im/mohamed-anwar/aquila.png)](https://gitter.im/_aquila) ![Image of Aquila](http://aquilaos.com/img/screenshot.png) UNIX-like Operating System, including the kernel and system tools. Intended to be fully **POSIX** compliant. Oh, and it compiles with -O3. #### Build Instructions Follow the instructions in this [wiki page.](https://github.com/mohamed-anwar/Aquila/wiki/Build-Instructions) #### CPU-based Features: ##### Supported Archetictures: > - [X] x86 > - [ ] x86-64 - [X] Multitasking - [X] Multithreading - [ ] SMP #### Kernel Features: - [X] Monolitihic kernel - [X] Virtual Filesystem - [ ] Supports loadable modules #### Supported Filesystems: - [X] initramfs (CPIO Archive filesystem, used for Ramdisk, read only) - [X] tmpfs (Generic temporary filesystem, read/write) - [X] devfs (Virtual filesystem, used for device handlers, statically populated, read/write) - [X] devpts (Virtual filesystem, used for psudo-terminals, dynamically populated, read/write) - [X] procfs (Processes information filesystem, read only) - [X] ext2 (Basic Extended 2 filesystem, read/write) - [ ] ext3 - [ ] ext4 - [ ] sysfs #### Supported Devices: - [X] i8042 (PS/2 Controller) - [X] ramdev (Memory mapped device, generic handler) - [X] ps2kbd (PS/2 Keyboard Controller) - [X] console (IBM TGA console) - [X] ata (ATA Harddisk handler, PIO mode) - [X] fbdev (Generic framebuffer device handler) - [X] 8250 (UART) #### Supported video interfaces: - [X] VESA 3.0 #### System Feautres: - [X] newlib-3.0.0 (latest) - [X] aqbox (Aquila Box, like busybox) - [X] fbterm (Framebuffer based terminal) - [X] tcc (Tiny C Compiler) - [X] lua (Lua programming language) - [X] kilo (Kilo text editor) ================================================ FILE: configs/clang.mk ================================================ CC := clang CFLAGS := $(INCLUDES) \ -nostdlib -ffreestanding -m32 \ -O3 -Wall -Wextra -Werror \ -Wno-unused -Wno-unused-parameter -march=i386 AS := $(CC) ASFLAGS := $(CFLAGS) #LD := ld.gold LD := ld.lld LDFLAGS := -nostdlib -melf_i386 ================================================ FILE: configs/gcc.mk ================================================ CC := i686-aquila-gcc CFLAGS += \ -nostdlib -ffreestanding -m32 \ -O3 -Wall -Wextra -Werror \ -Wno-unused -Wno-unused-parameter -march=i386 \ -funsigned-bitfields -fuse-ld=bfd AS := $(CC) ASFLAGS := $(CFLAGS) LD := i686-aquila-ld LDFLAGS := -nostdlib -melf_i386 SYSCC := i686-aquila-gcc SYSLD := i686-aquila-ld ================================================ FILE: configs/i386-pc.mk ================================================ include $(SRCDIR)/configs/gcc.mk # # Configurations # ARCH=i386 ARCH_DIR=i386 ARCH_I386=y ARCH_BITS=32 # # Boot Definitions # X86_MULTIBOOT=y # # Platform - PC # PLATFORM_X86_PC=y PLATFORM_DIR=pc # Support 8259 PIC PLATFORM_X86_MISC_PIC=y # Support 8253/8254 PIT PLATFORM_X86_MISC_PIT=y # Support i8042 PS/2 Controller PLATFORM_X86_MISC_I8042=y # Support HPET PLATFORM_X86_MISC_HPET=n # Support ACPI PLATFORM_X86_MISC_ACPI=y # Support CMOS PLATFORM_X86_MISC_CMOS=y # # Devices # # Generic framebuffer (fbdev) support DEV_FRAMEBUFFER=y # Generic console (condev) support DEV_CONSOLE=y DEV_KEYBOARD=y DEV_MOUSE=y DEV_KEYBOARD_PS2=y DEV_UART=y DEV_PTY=y DEV_MEMDEV=y DEV_ATA=y DEV_FDC=y # # Framebuffer # FBDEV_VESA=y # Filesystems FS_TMPFS=y FS_DEVFS=y FS_DEVPTS=y FS_EXT2=y FS_PROCFS=y FS_MINIX=y # Initramfs INITRAMFS_CPIO=y # Network NET_UNIX=y ================================================ FILE: configs/i386-quark.mk ================================================ # # Compilation flags # CC := $(PDIR)/../build-tools/sys/bin/i686-elf-gcc CFLAGS := -std=gnu99 -I. -I$(PDIR)/arch/$$(ARCH_DIR)/chipset/$$(CHIPSET_DIR)/include -I$(PDIR)/arch/$$(ARCH_DIR)/include -I $(PDIR) -I $(PDIR)/include/ -nostdlib -ffreestanding -m32 \ -O3 -Wall -Wextra -Werror -funsigned-bitfields -fuse-ld=bfd \ -Wno-unused -march=i586 AS := $(CC) ASFLAGS := $(CFLAGS) LD := $(PDIR)/../build-tools/sys/bin/i686-elf-ld.bfd LDFLAGS := -nostdlib -melf_i386 # # Configurations # ARCH=X86 ARCH_DIR=x86 ARCH_X86=y ARCH_BITS=32 # # Boot Definitions # X86_MULTIBOOT=y # # Chipset - generic # #CHIPSET_X86_GENERIC=y CHIPSET_X86_QUARK=y CHIPSET_DIR=quark # Support 8259 PIC CHIPSET_X86_MISC_PIC=y # Support 8253/8254 PIT CHIPSET_X86_MISC_PIT=y # Support i8042 PS/2 Controller #CHIPSET_X86_MISC_I8042=y # # Devices # # Generic framebuffer (fbdev) support #DEV_FRAMEBUFFER=y # Generic console (condev) support DEV_CONSOLE=y #DEV_KEYBOARD=y #DEV_MOUSE=y #DEV_KEYBOARD_PS2=y DEV_UART=y DEV_PTY=y # # Framebuffer # #FBDEV_VESA=y # Filesystems FS_TMPFS=y FS_DEVFS=y FS_DEVPTS=y #FS_EXT2=y FS_PROCFS=y ================================================ FILE: configs/none.mk ================================================ CC := $(PDIR)/../build-tools/sysroot/bin/i686-elf-gcc CFLAGS := -std=gnu99 -I. -I$(PDIR)/arch/$$(ARCH_DIR)/chipset/$$(CHIPSET_DIR)/include -I$(PDIR)/arch/$$(ARCH_DIR)/include -I $(PDIR) -I $(PDIR)/include/ -nostdlib -ffreestanding -m32 \ -O3 -Wall -Wextra -Werror -funsigned-bitfields -fuse-ld=bfd \ -Wno-unused -march=i386 AS := $(CC) ASFLAGS := $(CFLAGS) LD := ld.bfd LDFLAGS := -nostdlib -melf_i386 -L /opt/aquila/lib/gcc/i686-aquila/7.3.0/ ARCH=none ARCH_DIR=none ARCH_NONE=y ARCH_BITS=32 #DEV_FRAMEBUFFER=y #DEV_CONSOLE=y #DEV_KEYBOARD=y #DEV_MOUSE=y #DEV_KEYBOARD_PS2=y #DEV_UART=y #DEV_PTY=y #DEV_MEMDEV=y #DEV_ATA=y #DEV_FDC=y FBDEV_VESA=y # Filesystems FS_TMPFS=y FS_DEVFS=y FS_DEVPTS=y FS_EXT2=y FS_PROCFS=y FS_MINIX=y # Initramfs INITRAMFS_CPIO=y ================================================ FILE: configs/pcc.mk ================================================ CC := /opt/aquila/bin/i686-aquila-pcc CFLAGS += \ -nostdlib -ffreestanding -m32 \ -O3 -Wall -Wextra -Werror \ -Wno-unused -Wno-unused-parameter -march=i386 \ -funsigned-bitfields -fuse-ld=bfd AS := $(CC) ASFLAGS := $(CFLAGS) LD := /opt/aquila/bin/i686-aquila-ld LDFLAGS := -nostdlib -melf_i386 SYSCC := /opt/aquila/bin/i686-aquila-pcc SYSLD := /opt/aquila/bin/i686-aquila-ld ================================================ FILE: configs/x86_64-pc.mk ================================================ # # Compilation flags # CC := gcc CFLAGS := -std=gnu99 -I. -I$(PDIR)/arch/$$(ARCH_DIR)/chipset/$$(PLATFORM_DIR)/include -I$(PDIR)/arch/$$(ARCH_DIR)/include -I $(PDIR) -I $(PDIR)/include/ -nostdlib -ffreestanding \ -O3 -Wall -Wextra -Werror -funsigned-bitfields -fuse-ld=bfd \ -Wno-unused \ -mcmodel=large -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -z max-page-size=0x1000 AS := $(CC) ASFLAGS := $(CFLAGS) LD := ld.bfd LDFLAGS := -nostdlib -melf_x86_64 # # Configurations # ARCH=x86_64 ARCH_DIR=x86_64 ARCH_X86_64=y ARCH_BITS=64 # # Boot Definitions # X86_MULTIBOOT=y # # Chipset - generic # PLATFORM_X86_PC=y PLATFORM_DIR=pc # Support 8259 PIC PLATFORM_X86_MISC_PIC=y # Support 8253/8254 PIT PLATFORM_X86_MISC_PIT=y # Support i8042 PS/2 Controller PLATFORM_X86_MISC_I8042=y # # Devices # # Generic framebuffer (fbdev) support DEV_FRAMEBUFFER=y # Generic console (condev) support DEV_CONSOLE=y DEV_KEYBOARD=y DEV_MOUSE=y DEV_KEYBOARD_PS2=y DEV_UART=y DEV_PTY=y DEV_MEMDEV=y DEV_ATA=y # # Framebuffer # FBDEV_VESA=y # Filesystems FS_TMPFS=y FS_DEVFS=y FS_DEVPTS=y #FS_EXT2=y FS_PROCFS=y # Initramfs INITRAMFS_CPIO=y ================================================ FILE: initrd/Makefile ================================================ ROOT= initrd DIRS= bin sbin dev mnt proc tmp root COPY= etc usr AQBOX= aqbox AQBOX_BIN= cat clear echo env ls mkdir mknod ps pwd sh stat uname unlink touch kill bim date AQBOX_SBIN= login mount kbd getty readmbr reboot # Create initrd CPIO image initrd.img: all cd $(ROOT); find . | cpio -o > ../initrd.img; all: $(DIRS) $(COPY) $(ROOT)/init fbterm aqbox $(ROOT)/dev/kmsg #nuklear $(ROOT): $(MKDIR) -p $(ROOT) # Inflate initrd ROOT with required directories $(DIRS): $(ROOT) $(MKDIR) -p $(ROOT)/$@ # Copy some files and directories into initrd ROOT $(COPY): $(ROOT) $(CP) -r $@ $(ROOT)/ fbterm: $(ROOT)/bin/fbterm $(ROOT)/bin/fbterm: $(ROOT)/bin $(CP) $(SRCDIR)/system/fbterm/fbterm $(ROOT)/bin/ $(STRIP) $(ROOT)/bin/fbterm aqbox: $(ROOT)/bin/aqbox $(AQBOX_BIN) $(AQBOX_SBIN) $(ROOT)/bin/aqbox: $(ROOT)/bin $(CP) $(SRCDIR)/system/aqbox/aqbox $(ROOT)/bin/ $(STRIP) $(ROOT)/bin/aqbox $(AQBOX_BIN): $(ROOT)/bin/aqbox $(LN) -fs /bin/aqbox $(ROOT)/bin/$@ $(AQBOX_SBIN): $(ROOT)/bin/aqbox $(LN) -fs /bin/aqbox $(ROOT)/sbin/$@ $(ROOT)/init: $(MAKE) -C init/ $(CP) init/init $@ $(ROOT)/dev/kmsg: #sudo mknod $(ROOT)/dev/kmsg c 1 11 clean: $(MAKE) -C init/ clean $(RM) -rf $(ROOT) initrd.img .PHONY: all $(DIRS) clean $(COPY) fbterm aqbox $(AQBOX_BIN) $(AQBOX_SBIN) install install: all $(MKDIR) -p $(DESTDIR)/boot $(CP) initrd.img $(DESTDIR)/boot ================================================ FILE: initrd/etc/hostname ================================================ aquila ================================================ FILE: initrd/etc/motd ================================================ _...__..-' .' .' .' .' .------._ ; .-"""`-.<') `-._ .' (.--. _ `._ `'---.__.-' ` `;'-.-' '- ._ .--'`` '._ - ' . `""'-. `---' , ''--..__ `\ ``''---'`\ .' `'. ' `'. _____ .__.__ ________ _________ / _ \ ________ __|__| | _____ \_____ \ / _____/ / /_\ \ / ____/ | \ | | \__ \ / | \ \_____ \ / | < <_| | | / | |__/ __ \_/ | \/ \ \____|__ /\__ |____/|__|____(____ /\_______ /_______ / \/ |__| \/ \/ \/ Welcome to AquilaOS! ================================================ FILE: initrd/etc/passwd ================================================ root:x:0:0:root:/root:/bin/sh ================================================ FILE: initrd/etc/rc.init ================================================ #!/bin/sh set -x export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/libexec:/usr/local/bin:/usr/local/sbin # Mount devfs on /dev echo mounting devfs on /dev mount -t devfs /dev # Populate static devices echo populating static devices in /dev mknod /dev/console c 5 1 mknod /dev/ptmx c 5 2 mknod /dev/kbd c 11 0 mknod /dev/fb0 c 29 0 mknod /dev/hda b 3 0 mknod /dev/hda1 b 3 1 mknod /dev/ttyS0 c 4 64 mknod /dev/mouse c 10 1 mknod /dev/kmsg c 1 11 mknod /dev/fd0 b 2 0 # Mount devpts on /dev/pts echo mounting devpts on /dev/pts mkdir /dev/pts mount -t devpts /dev/pts ================================================ FILE: initrd/init/Makefile ================================================ #ARCH=i686 #SYSROOT= ../../build-tools/sysroot #CC= $(SYSROOT)/bin/$(ARCH)-aquila-gcc #CFLAGS= -I$(SYSROOT)/usr/$(ARCH)-aquila/include # #LD= $(CC) #LDFLAGS= -nostdlib -ffreestanding -Wl,-Ttext=0x1000 #LDLIBS= $(SYSROOT)/usr/$(ARCH)-aquila/lib/crt0.o -L$(SYSROOT)/usr/$(ARCH)-aquila/lib -lc -lpthread -lm -lgcc all: init init: init.c $(SYSCC) $< -o $@ clean: rm -rf init .PHONY: all clean ================================================ FILE: initrd/init/init.c ================================================ #include #include #include #include #include #include #include #include #include int log_fd = -1; int log_init() { log_fd = open("/dev/kmsg", O_WRONLY); } int _log(int level, const char *fmt, ...) { static char buf[512]; if (log_fd >= 0) { va_list ap; va_start(ap, fmt); int len = vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); write(log_fd, buf, len); } } int run(char **argv) { int child, status, pid; if (child = fork()) { do pid = waitpid(child, &status, 0); while (pid != child); } else { int x = execv(argv[0], argv); _log(1, "failed to execute %s: %s\n", argv[0], strerror(errno)); exit(x); } return status; } void signal_handler(int sig) { switch (sig) { case SIGTERM: _log(1, "init: reached target reboot\n"); exit(0); default: /* ignore */ return; } } int main(int argc, char **argv) { signal(SIGKILL, signal_handler); signal(SIGTERM, signal_handler); close(0); close(1); close(2); open("/dev/kmsg", O_RDONLY); log_init(); if (open("/dev/kmsg", O_WRONLY) != 2) { _log(1, "could not open stderr\n"); } _log(1, "init: started\n"); /* execute /etc/rc.init script */ _log(1, "init: executing /etc/rc.init script\n"); char *argp[] = {"/bin/sh", "/etc/rc.init", NULL}; run(argp); int use_fbterm = 0, use_serial = 0; if (argc > 0) { char *cmdline = argv[0], *token; while ((token = strtok(cmdline, " "))) { cmdline = NULL; if (!strcmp(token, "--serial")) use_serial = 1; else if (!strcmp(token, "--fbterm")) use_fbterm = 1; } } if (use_fbterm || !use_serial) { _log(1, "init: starting fbterm\n"); char *argp[] = {"/bin/fbterm", NULL}; if (!fork()) { for (int i = 0; i < 3; ++i) close(i); execv(argp[0], argp); } } if (use_serial) { if (!fork()) { for (int i = 0; i < 3; ++i) close(i); open("/dev/ttyS0", O_RDONLY); open("/dev/ttyS0", O_WRONLY); open("/dev/ttyS0", O_WRONLY); char *argp[] = {"/sbin/login", NULL}; while (1) run(argp); //execv(argp[0], argp); } } /* init can't die */ for (;;); } ================================================ FILE: initrd/usr/share/man/man1/ccom.1 ================================================ .\" $Id: ccom.1,v 1.33 2018/12/15 09:12:14 plunky Exp $ .\" .\" Copyright (c) 2007 Jeremy C. Reed .\" .\" Permission to use, copy, modify, and/or distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above .\" copyright notice and this permission notice appear in all copies. .\" .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR AND CONTRIBUTORS DISCLAIM .\" ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL AUTHOR AND .\" CONTRIBUTORS BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL .\" DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR .\" PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS .\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF .\" THIS SOFTWARE. .\" .Dd March 22, 2012 .Dt CCOM 1 .Os .Sh NAME .Nm ccom .Nd C compiler .Sh SYNOPSIS .Nm .Op Fl gkpsv .Op Fl f Ar features .Op Fl m Ar options .Op Fl W Ar warnings .Op Fl X Ar flags .Op Fl x Ar settings .Op Fl Z Ar flags .Op infile .Op outfile .Sh DESCRIPTION The .Nm utility provides a C compiler. The frontend is usually .Xr pcc 1 . It is .Em not intended to be run directly. .Nm reads the C source from .Ar infile or standard input and writes the assembler source to .Ar outfile or to standard output. .Pp The options are as follows: .Bl -tag -width Ds .It Fl f Ar feature Enable language features. Multiple .Fl f options can be given, the following features are supported: .Bl -tag -width Ds .It Sy stack-protector Enable stack smashing protection. Currently the same as .Sy stack-protector-all . .It Sy stack-protector-all Enable stack smashing protection for all functions. .It Sy pack-struct Ns Oo = Ns Ar n Oc Specify maximum alignment for structure members, similar to a #pragma pack statement at the start of the file. If no value is given, the default is 1. .It Sy freestanding Emit code for a freestanding environment. Currently not implemented. .El .It Fl g Include debugging information in the output code for use by symbolic and source-level debuggers. Currently this uses the .Sy stabs format, encoding information in .Em s Ns ymbol Em tab Ns le entrie Ns Em s. .It Fl k Generate PIC code. .It Fl m Ar option Target-specific options, used in machine-dependent code. Multiple .Fl m options can be given, the following options are supported: .Bl -tag -width PowerPC .It AMD64 .It ARM .Sy little-endian , .Sy big-endian , .Sy fpe=fpa , .Sy fpe=vpf , .Sy soft-float , .Sy arch=armv1 , .Sy arch=armv2 , .Sy arch=armv2a , .Sy arch=armv3 , .Sy arch=armv4 , .Sy arch=armv4t , .Sy arch=armv4tej , .Sy arch=armv5 , .Sy arch=armv5te , .Sy arch=armv5tej , .Sy arch=armv6 , .Sy arch=armv6t2 , .Sy arch=armv6kz , .Sy arch=armv6k No \*(Am .Sy arch=armv7 . .It HPPA .It i386 .It M16C .It MIPS .Sy little-endian No \*(Am .Sy big-endian . .It NOVA .It PDP-10 .It PDP-11 .It PowerPC .Sy little-endian , .Sy big-endian , .Sy soft-float No \*(Am .Sy hard-float . .It Sparc64 .It VAX .El .It Fl p Generate profiling code. .It Fl s Print statistics to standard error when complete. This includes: name table entries, name string size, permanent allocated memory, temporary allocated memory, lost memory, argument list unions, dimension/function unions, struct/union/enum blocks, inline node count, inline control blocks, and permanent symtab entries. .\" TODO: explain units for above? .It Fl v Display version. .It Fl W Ar warning Do some basic checks and emit warnings about possible coding problems. Multiple .Fl W options can be given, the following warnings are supported: .Bl -tag -width Ds .It Sy error Ns Oo = Ns Ar warning Oc Enable .Ar warning , and treat it as an error condition. If a specific warning is not given, producing any warning will cause an error. .It Sy attributes Warn when unsupported attributes are used. This warning is enabled by default. .It Sy deprecated-declarations Report whenever a symbol marked with the .Sq deprecated attribute is used. This warning is enabled by default. .It Sy implicit-function-declaration (TODO) Require explicit prototypes for all called functions. .It Sy implicit-int (TODO) Warn when a function declaration lacks a type. .It Sy missing-prototypes Require explicit prototypes for all global function definitions. .It Sy pointer-sign Warn when pointer operations are done with mismatched signed and unsigned values. .It Sy sign-compare (TODO) Warn about comparisons between signed and unsigned values. .It Sy strict-prototypes (TODO) Require that function prototypes are strictly C99. .It Sy shadow Report when a local variable shadows something from a higher scope. .It Sy truncate Report when integer values may be implicitly truncated to fit a smaller type. .It Sy uninitialized A variable is read before being written. .It Sy unknown-pragmas Report unhandled pragma statements. .It Sy unreachable-code Report statements that cannot be executed. .El .Pp Any of the above may be prefixed with .Dq no- in order to disable the effect. .\" .It Fl X Ar flags C specific debugging where .Ar flags is one or more of the following: .Pp .Bl -tag -compact -width Ds .It Sy b Building of parse trees .It Sy d Declarations (using multiple .Sy d flags gives more output) .It Sy e Pass1 trees at exit .It Sy i Initializations .It Sy n Memory allocations .It Sy o Turn off optimisations .It Sy p Prototypes .It Sy s Inlining .It Sy t Type conversions .It Sy x Target-specific flag, used in machine-dependent code .El .\" .It Fl x Ar setting Enable .Ar setting in the compiler. Multiple .Fl x options can be given, the following settings are supported: .Bl -tag -width Ds .It Sy ccp Apply sparse conditional constant propagation techniques for optimization. Currently not implemented. .It Sy dce Do dead code elimination. .It Sy deljumps Delete redundant jumps and dead code. .It Sy gnu89 .It Sy gnu99 Use GNU C semantics rather than C99 for some things. Currently only inline. .It Sy inline Replace calls to functions marked with an inline specifier with a copy of the actual function. .It Sy ssa Convert statements into static single assignment form for optimization. Not yet finished. .It Sy tailcall Enable optimization of tail-recursion functions. Currently not implemented. .It Sy temps Locate automatic variables into registers where possible, for further optimization by the register allocator. .It Sy uchar Treat character constants as unsigned values. .El .\" .It Fl Z Ar flags Code generator (pass2) specific debugging where .Ar flags is one or more of the following: .Pp .Bl -tag -compact -width Ds .It Sy b Basic block and SSA building .It Sy c Code printout .It Sy e Trees when entering pass2 .It Sy f Instruction matcher, may provide much output .It Sy g Print flow graphs .It Sy n Memory allocation .It Sy o Instruction generator .It Sy r Register allocator .It Sy s Shape matching in instruction generator .It Sy t Type matching in instruction generator .It Sy u Sethi-Ullman computations .It Sy x Target-specific flag, used in machine-dependent code .El .El .Sh PRAGMAS Input lines starting with a .Dq #pragma directive can be used to modify behaviour of .Nm during compilation. All tokens up to the first unescaped newline are considered part of the pragma command, with the following operations being recognized: .Bl -tag -width Ds .It Sy STDC Standard C99 operator follows. Currently no C99 operations are implemented, and any directives starting with this token will be silently ignored. .It Sy GCC diagnostic Ar effect Qq Ar option GNU C compatibility. Alter the effects of compiler diagnostics. The required .Ar effect should be stated as .Sy warning , .Sy error or .Sy ignored , followed by the compiler diagnostic .Ar option in double quotes. For example, to force unknown pragmas to always generate an error, a standard header might include .Bd -literal -offset 2n #pragma GCC diagnostic error "-Wunknown-pragmas" .Ed .It Sy GCC poison Ar identifier ... GNU C compatibility. Cause an error if any of the following .Ar identifier Ns s subsequently appear in the code .Pq but not in any macro expansions . Currently not implemented. .It Sy GCC system_header GNU C compatibility. Currently not implemented. .It Sy GCC visibility GNU C compatibility. Currently not implemented. .It Sy pack Ns Pq Op Ar n Set the default maximum alignment for structures and unions, such that members will have their natural alignment requirements clamped at this value and may be stored misaligned. If .Ar n is not given, the alignment is reset to the target default. .It Sy pack Ns Pq Sy push Ns Op , Ar n Push the current pack setting onto an internal stack then, if .Ar n is given, change the default alignment for structures and unions. Currently not implemented. .It Sy pack Ns Pq Sy pop Change the pack setting to the most recently pushed value, and remove that setting from the stack. Currently not implemented. .It Sy packed Op Ar n Set the maximum alignment for the structure or union defined in the current statement. If .Ar n is not given, the default value of 1 is used. .Pq Currently this works except Ar n is not used .It Sy aligned Op Ar n Set the minimum alignment for the structure or union defined in the current statement. .It Sy rename Ar name Provide an alternative .Ar name which will be used to reference the object declared in the current statement. .It Sy weak Ar name Ns Op = Ns Ar alias Mark .Ar name as a weak rather than a global symbol, to allow its definition to be overridden at link time. If an .Ar alias is given, this will be used as the default value of .Ar name . .It Sy ident Currently not implemented. .El .Lp and the following target-specific operations are handled by machine-dependent code: .Bl -tag -width Ds .It Sy tls For AMD64 and i386 targets, the variable declared in the current statement will be referenced via the .Dq thread-local storage mechanism. .It Sy init For AMD64, ARM, HPPA, i386, MIPS and PowerPC targets, when the current statement is a function declaration, generate a reference in the .Sy .ctors section, enabling library code to call the function prior to entering .Fn main . .It Sy fini For AMD64, ARM, HPPA, i386, MIPS and PowerPC targets, when the current statement is a function declaration, generate a reference in the .Sy .dtors section, enabling library code to call the function when .Fn main returns or the .Fn exit function is called. .It Sy section Ar name For AMD64, ARM, HPPA and i386 targets, place the subsequent code in the named section. .Pq This is currently broken . .It Sy alias Ar name For AMD64, HPPA and i386 targets, emit assembler instructions providing an alias for the symbol defined by the current statement. .It Sy stdcall For i386 targets, enable .Dq stdcall semantics during code generation, where function arguments are passed on the stack in right-to-left order, and the callee is responsible for adjusting the stack pointer before returning. Any function result is passed in the EAX register. On win32, the function name is postfixed with an .Dq @ and the size of the stack adjustment. .It Sy cdecl For i386 targets, enable .Dq cdecl semantics during code generation, where function arguments are passed on the stack in right-to-left order, and the caller is responsible for cleaning up the stack after the function returns. Any function result is passed in the EAX register. This is the default. .It Sy fastcall For i386-win32 targets, enable .Dq fastcall semantics during code generation. .Po Currently this is equivalent to .Sy stdcall , which is likely wrong .Pc . .It Sy dllimport For i386-win32 targets, references to the external symbol defined by the current statement will be made via indirect access through a location identified by the symbol name prefixed with .Dq __imp_ . .It Sy dllexport For i386-win32 targets, the external symbol declared by the current statement will be exported as an indirect reference to be accessed with .Sy dllimport . The global locator will be the symbol name prefixed with .Dq __imp_ . Currently this is not completely implemented. .El .Pp Any unknown .Dq #pragma directives will be ignored unless the .Fl Wunknown-pragmas diagnostic is in effect. .Sh SEE ALSO .Xr as 1 , .Xr cpp 1 , .Xr pcc 1 .Sh HISTORY The .Nm compiler is based on the original Portable C Compiler by .An "S. C. Johnson" , written in the late 70's. Even though much of the compiler has been rewritten .Pq about 50% of the frontend code and 80% of the backend , some of the basics still remain. Most is written by .An "Anders Magnusson" , with the exception of the data-flow analysis part and the SSA conversion code which is written by .An "Peter A Jonsson" , and the Mips port that were written as part of a project by undergraduate students at Lulea University of Technology. .Pp This product includes software developed or owned by Caldera International, Inc. ================================================ FILE: initrd/usr/share/man/man1/cpp.1 ================================================ .\" $Id: cpp.1,v 1.17 2013/02/26 19:27:38 plunky Exp $ .\" .\" Copyright (c) 2007 Jeremy C. Reed .\" .\" Permission to use, copy, modify, and/or distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above .\" copyright notice and this permission notice appear in all copies. .\" .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR AND CONTRIBUTORS DISCLAIM .\" ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL AUTHOR AND .\" CONTRIBUTORS BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL .\" DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR .\" PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS .\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF .\" THIS SOFTWARE. .\" .Dd February 26, 2013 .Dt CPP 1 .Os .Sh NAME .Nm cpp .Nd C preprocessor .Sh SYNOPSIS .Nm .Op Fl ACEMPtVv .Op Fl D Ar macro Ns Oo = Ns Ar value Oc .Op Fl d Ar flags .Op Fl I Ar path .Op Fl i Ar file .Op Fl S Ar path .Op Fl U Ar macro .Op Ar infile | - .Op Ar outfile .Sh DESCRIPTION The .Nm utility is a macro preprocessor used by the .Xr pcc 1 compiler. It is mainly used to include header files, expand macro definitions, discard comments, and perform conditional compilation. .Nm is written to comply with the .St -isoC-99 specification. .Pp The .Ar infile input file is optional. If not provided or the file name is .Qq - (dash), .Nm reads its initial file from standard input. The .Ar outfile output file is also optional, with output written to standard output if not provided. .Pp The options are as follows: .Bl -tag -width Ds .It Fl A For assembler-with-cpp input: treat non-directive lines starting with a # as comments. .It Fl C Do not discard comments. .It Fl D Ar macro Ns Oo = Ns Ar value Oc Create a macro definition before processing any input, as if a .Lp .Dl #define Ar macro Ar value .Lp directive had appeared in the source. If .Ar value is not set on the command-line, then a value of 1 is used. .It Fl d Ar flags Modify output according to .Ar flags , which can be a list of character flags. The following flags are currently supported: .Bl -tag -width ".Sy M" .It Sy M Do not process any input, but output a list of .Dq #define statements for all defined macros other than builtin macros .Pq see below . .El .Lp any unknown flags are ignored. .It Fl E Modify the exit code, if there were any warnings. .It Fl I Ar path Add .Ar path to the list of directories searched by the .Dq #include directive. This may be used to override system include directories .Pq see Fl S No option . .Fl I may be specified multiple times and is cumulative. .It Fl i Ar file Include a file before processing any input, as if a .Lp .Dl #include Qo Ar file Qc .Lp directive had appeared in the source. .Fl i may be specified multiple times to include several files. .It Fl M Instead of producing a processed C code file, output a list of dependencies for .Xr make 1 , detailing the files that need to be processed when compiling the input. .It Fl P Inhibit generation of line markers. This is sometimes useful when running the preprocessor on something other than C code. .It Fl S Ar path Add .Ar path to the list of system directories searched by the .Dq #include directive. The .Fl S option may be specified multiple times and is cumulative. .It Fl t Traditional cpp syntax. Do not define the .Dv __TIME__ , .Dv __DATE__ , .Dv __STDC__ , and .Dv __STDC_VERSION__ macros. .It Fl U Ar macro Undefine a macro before processing any input, as if a .Lp .Dl #undef Ar macro .Lp directive had appeared in the source. .It Fl V Verbose debugging output. .Fl V can be repeated for greater detail. .Po This is only available if the .Nm program was built with .Dv PCC_DEBUG defined, which is the default .Pc . .It Fl v Display version. .El .Pp The .Fl D , .Fl i and .Fl U options are processed in the order that they appear on the command line, before any input is read but after the command line options have been scanned. .Pp Files referenced by the .Dq #include directive as .Qq ... , are first looked for in the current directory, then as per .Aq ... files, which are first looked for in the list of directories provided by any .Fl I options, then in the list of system directories provided by any .Fl S options. Note that .Nm does not define any include directories by default; if no .Fl I or .Fl S options are given, then only the current directory will be searched and no system files will be found. .Ss Builtin Macros A few macros are interpreted inside the .Nm cpp program: .Bl -diag .It __DATE__ Expands to a quoted string literal containing the date in the form .Qq Mmm dd yyyy , where the names of the months are the same as those generated by the .Xr asctime 3 function, and the first character of dd is a space character if the value is less than 10. .It __FILE__ Expands to a quoted string literal containing the presumed name of the current source file. When reading source from standard input, it expands to .Qq Aq stdin . .It __LINE__ Expands to an integer constant representing the presumed line number of the source line containing the macro. .It __STDC__ Expands to the integer constant .Dq 1 , meaning that the compiler conforms to .St -isoC . .It __STDC_VERSION__ Expands to the integer constant .Dq 199901L , indicating that .Nm conforms to .St -isoC-99 . .It __TIME__ Expands to a quoted string literal containing the time in the form .Qq hh:mm:ss as generated by the .Xr asctime 3 function. .El .Pp Also see the .Fl t option. .Sh EXIT STATUS The .Nm utility exits with one of the following values: .Lp .Bl -tag -width Ds -offset indent -compact .It 0 Successfully finished. .It 1 An error occurred. .It 2 The .Fl E option was given, and warnings were issued. .El .Sh SEE ALSO .Xr as 1 , .Xr ccom 1 , .Xr make 1 , .Xr pcc 1 , .Xr asctime 3 .Sh HISTORY The .Nm command comes from the original Portable C Compiler by .An "S. C. Johnson" , written in the late 70's. The code originates from the V6 preprocessor with some additions from V7 cpp and ansi/c99 support. .Pp A lot of the PCC code was rewritten by .An "Anders Magnusson" . .Pp This product includes software developed or owned by Caldera International, Inc. ================================================ FILE: initrd/usr/share/man/man1/p++.1 ================================================ .\" $Id: cc.1,v 1.45 2016/10/10 11:27:49 ragge Exp $ .\" .\" Copyright (c) 2007 Jeremy C. Reed .\" .\" Permission to use, copy, modify, and/or distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above .\" copyright notice and this permission notice appear in all copies. .\" .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR AND CONTRIBUTORS DISCLAIM .\" ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL AUTHOR AND .\" CONTRIBUTORS BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL .\" DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR .\" PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS .\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF .\" THIS SOFTWARE. .\" .Dd June 20, 2014 .Dt CC 1 .Os .Sh NAME .Nm cc .Nd front-end to the C compiler .Sh SYNOPSIS .Nm .Op Fl cEgkMPSstvX .Op Fl ansi .Op Fl B Ns Ar prefix .Op Fl D Ar macro Ns Oo = Ns Ar value Oc .Op Fl d Ns Ar flags .Op Fl f Ns Ar feature .Op Fl I Ar path .Op Fl include Ar file .Op Fl isystem Ar path .Op Fl L Ns Ar path .Op Fl m Ns Ar option .Op Fl nodefaultlibs .Op Fl nostartfiles .Op Fl nostdinc .Op Fl nostdlib .Op Fl O Ns Oo Ar level Oc .Op Fl o Ar outfile .Op Fl pg .Op Fl pthread .Op Fl shared .Op Fl static .Op Fl std= Ns Ar standard .Op Fl U Ar macro .Op Fl Wa Ns , Ns Ar options .Op Fl Wc Ns , Ns Ar options .Op Fl Wl Ns , Ns Ar options .Op Fl Wp Ns , Ns Ar options .Op Fl x Ar language .Op Fl z Ar keyword .Op Ar .Sh DESCRIPTION The .Nm utility provides a front-end to the .Dq portable C compiler . Multiple files may be given on the command line. Unrecognized options are sent directly to .Xr ld 1 . .Pp .\" Brief description of its syntax: Filenames that end with .Sy \&.c are passed via .Xr cpp 1 \(-> .Xr ccom 1 \(-> .Xr as 1 \(-> .Xr ld 1 . .Pp Filenames that end with .Sy \&.i are passed via .Xr ccom 1 \(-> .Xr as 1 \(-> .Xr ld 1 . .Pp Filenames that end with .Sy \&.s are passed via .Xr as 1 \(-> .Xr ld 1 . .Pp Filenames that end with .Sy \&.S are passed via .Xr cpp 1 \(-> .Xr as 1 \(-> .Xr ld 1 . .Pp Filenames that end with .Sy \&.o are passed directly to .Xr ld 1 . .Pp .\" The options are as follows: .Bl -tag -width Ds .It Fl ansi Synonym for .Fl std=c89 . .It Fl B Ns Ar prefix Define alternate prefix path for .Xr cpp 1 , .Xr ccom 1 , .Xr as 1 , or .Xr ld 1 executables. .\" TODO: provide an example of -B .It Fl C Passed to the .Xr cpp 1 preprocessor to not discard comments. .It Fl c Stop after generating object code with .Xr as 1 . Do not link. The resulting object output is saved as a filename with a .Dq \&.o suffix unless .Fl o option is used. Note: cannot be combined with .Fl o if multiple files are given. .It Fl D Ar macro Ns Oo = Ns Ar value Oc Passed to the .Xr cpp 1 preprocessor to define .Ar macro with an optional .Ar value . .It Fl d Ns Ar flags Debug options. .Ar flags is a string of characters, which signify the following actions. .Bl -tag -width ".Sy M" .It Sy M Cause the preprocessor to output a list of macro definitions. .El .Lp any unknown flags are ignored. .It Fl E Stop after preprocessing with .Xr cpp 1 . Do not compile, assemble, or link. Output is sent to standard output unless the .Fl o option is used. .It Fl ffreestanding Assume a freestanding environment. .It Fl fPIC Generate PIC code. .\" TODO: document about avoiding machine-specific maximum size? .It Fl fpic Tells C compiler to generate PIC code and tells assembler that PIC code has been generated. .\" TODO: document difference between PIC and pic .It Fl funsigned-char Tell the compiler to treat .Sq char types as if they were unsigned unless explicitly defined otherwise. .Fl fsigned-char can be used to signify the opposite behaviour. The default for the .Sq char type depends on the compiler target architecture. .It Fl fstack-protector Tell the compiler to wrap functions with code which checks at runtime that a stack overflow has not occurred. When stack protection is in effect, the .Dv __SSP__ macro will be defined. .\" other -f GCC compatibility flags are ignored for now .It Fl g Send .Fl g flag to .Xr ccom 1 to create debug output. Debug information output can be disabled with .Fl g0 . .It Fl I Ar path Passed to the .Xr cpp 1 preprocessor to add header search directory to override system defaults. .It Fl include Ar file Tells the .Xr cpp 1 preprocessor to include the .Ar file during preprocessing. .It Fl isystem Ar path Defines .Ar path as a system header directory for the .Xr cpp 1 preprocessor. .It Fl k Generate PIC code. See .Fl fpic option. .It Fl L Ns Ar path Passed to the linker, to add .Ar path to the list of directories searched for shared libraries. .It Fl M Pass .Fl M flag to .Xr cpp 1 to generate dependencies for .Xr make 1 . .It Fl m Ns Ar option Target-dependent options. Multiple .Fl m options can be given, the following are supported: .Bl -tag -width PowerPC .It ARM \-mlittle-endian \-mbig-endian \-mfpe=fpa \-mfpe=vpf \-msoft-float \-march=armv1 \-march=armv2 \-march=armv2a \-march=armv3 \-march=armv4 \-march=armv4t \-march=armv4tej \-march=armv5 \-march=armv6 \-march=armv6t2 \-march=armv6kz \-march=armv6k \-march=armv7 .It HPPA .It i386 .It MIPS \-mlittle-endian \-mbig-endian \-mhard-float \-msoft-float .It PDP-10 .It PowerPC .It Sparc64 .It VAX .El .It Fl nodefaultlibs Do not link with the system default libraries (libc, etc.) .It Fl nostartfiles Do not link with the system startup files (crt0.c, etc.) .It Fl nostdinc Do not use the system include paths (/usr/include, etc.) .It Fl nostdlib Do not link with the system default libraries or startup files. .It Fl O Ns Oo Ar level Oc Enable compiler optimizations. Currently, for levels higher than zero, this defines .Dv __OPTIMIZE__ in the .Xr cpp 1 preprocessor, and passes .Fl xdce , .Fl xdeljumps , .Fl xtemps and .Fl xinline to .Xr ccom 1 . If no level is given the optimization level is .Fl O1 . Optimizations can be disabled using .Fl O0 . In situations where multiple optimization flags are given, the last flag is the one used. .It Fl o Ar outfile Save result to .Ar outfile . .It Fl P Inhibit generation of line markers in preprocessor output. This is sometimes useful when running the preprocessor on something other than C code. .It Fl pg Enable profiling on the generated executable. .It Fl pthread Defines the .Dv _PTHREADS preprocessor identifier for .Xr cpp 1 , and adds .Fl lpthread to the .Xr ld 1 linker arguments. .It Fl S Stop after compilation by .Xr ccom 1 . Do not assemble and do not link. The resulting assembler-language output is saved as a filename with a .Dq \&.s suffix unless the .Fl o option is used. Note: cannot be combined with .Fl o if multiple files are given. .It Fl s Passed to .Xr ld 1 to remove all symbol table and relocation information from the generated executable. This option is silently ignored if .Nm does not invoke the linker. .It Fl shared Create a shared object of the result. Tells the linker not to generate an executable. .It Fl static Do not use dynamic linkage. By default, it will link using the dynamic linker options and/or shared objects for the platform. .It Fl std= Ns Ar standard Compile to the specified .Ar standard . Accepted values for .Ar standard are .Ar c89 , .Ar c99 , .Ar gnu89 , .Ar gnu99 , .Ar gnu9x , and .Ar c11 . .It Fl t Passed to .Xr cpp 1 to suppress some default macro definitions and enable use of traditional C preprocessor syntax. .It Fl U Ar macro Passes to the .Xr cpp 1 preprocessor to remove the initial macro definition. .It Fl v Outputs the version of .Nm and shows commands as they are run with their command line arguments. .It Fl ### As per .Fl v except that the commands are not run, and the arguments will be quoted if they contain unusual characters or spaces. .It Fl Wa Ns , Ns Ar options Comma separated list of options for the assembler. .It Fl Wc Ns , Ns Ar options Comma separated list of options for the compiler. .It Fl Wl Ns , Ns Ar options Comma separated list of options for the linker. .It Fl Wp Ns , Ns Ar options Comma separated list of options for the preprocessor. .It Fl X Don't remove temporary files on exit. .It Fl x Ar language GCC compatibility option; specify the language in use rather than interpreting the filename extension. Currently known language values are .Sy none , .Sy c , .Sy c++ , .Sy assembler and .Sy assembler-with-cpp . Any unknown .Fl x options are passed to .Xr ccom 1 . .It Fl z Ar keyword Passed to .Xr ld 1 . Please refer to the documentation of your linker for acceptable values of .Ar keyword . .El .Ss Predefined Macros A few macros are predefined by .Nm when sent to .Xr cpp 1 . .Bl -diag .It __PCC__ Set to the major version of .Xr pcc 1 . These macros can be used to select code based on .Xr pcc 1 compatibility. See the .Fl v option. .It __PCC_MINOR__ Set to the minor version. .It __PCC_MINORMINOR__ Set to the minor-minor version \(em the number after the minor version. .It _PTHREADS Defined when .Fl pthread switch is used. .It __ASSEMBLER__ Defined when input files have a .S suffix, or if the .Fl x Ns assembler-with-cpp option is specified. .El .Pp Also system- and/or machine-dependent macros may also be predefined; for example: .Dv __NetBSD__ , .Dv __ELF__ , and .Dv __i386__ . .Sh SEE ALSO .Xr as 1 , .Xr ccom 1 , .Xr cpp 1 , .Xr ld 1 .Sh HISTORY The .Nm command comes from the original Portable C Compiler by .An "S. C. Johnson" , written in the late 70's. .Pp This product includes software developed or owned by Caldera International, Inc. ================================================ FILE: initrd/usr/share/man/man1/pcc.1 ================================================ .\" $Id: cc.1,v 1.45 2016/10/10 11:27:49 ragge Exp $ .\" .\" Copyright (c) 2007 Jeremy C. Reed .\" .\" Permission to use, copy, modify, and/or distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above .\" copyright notice and this permission notice appear in all copies. .\" .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR AND CONTRIBUTORS DISCLAIM .\" ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL AUTHOR AND .\" CONTRIBUTORS BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL .\" DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR .\" PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS .\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF .\" THIS SOFTWARE. .\" .Dd June 20, 2014 .Dt CC 1 .Os .Sh NAME .Nm cc .Nd front-end to the C compiler .Sh SYNOPSIS .Nm .Op Fl cEgkMPSstvX .Op Fl ansi .Op Fl B Ns Ar prefix .Op Fl D Ar macro Ns Oo = Ns Ar value Oc .Op Fl d Ns Ar flags .Op Fl f Ns Ar feature .Op Fl I Ar path .Op Fl include Ar file .Op Fl isystem Ar path .Op Fl L Ns Ar path .Op Fl m Ns Ar option .Op Fl nodefaultlibs .Op Fl nostartfiles .Op Fl nostdinc .Op Fl nostdlib .Op Fl O Ns Oo Ar level Oc .Op Fl o Ar outfile .Op Fl pg .Op Fl pthread .Op Fl shared .Op Fl static .Op Fl std= Ns Ar standard .Op Fl U Ar macro .Op Fl Wa Ns , Ns Ar options .Op Fl Wc Ns , Ns Ar options .Op Fl Wl Ns , Ns Ar options .Op Fl Wp Ns , Ns Ar options .Op Fl x Ar language .Op Fl z Ar keyword .Op Ar .Sh DESCRIPTION The .Nm utility provides a front-end to the .Dq portable C compiler . Multiple files may be given on the command line. Unrecognized options are sent directly to .Xr ld 1 . .Pp .\" Brief description of its syntax: Filenames that end with .Sy \&.c are passed via .Xr cpp 1 \(-> .Xr ccom 1 \(-> .Xr as 1 \(-> .Xr ld 1 . .Pp Filenames that end with .Sy \&.i are passed via .Xr ccom 1 \(-> .Xr as 1 \(-> .Xr ld 1 . .Pp Filenames that end with .Sy \&.s are passed via .Xr as 1 \(-> .Xr ld 1 . .Pp Filenames that end with .Sy \&.S are passed via .Xr cpp 1 \(-> .Xr as 1 \(-> .Xr ld 1 . .Pp Filenames that end with .Sy \&.o are passed directly to .Xr ld 1 . .Pp .\" The options are as follows: .Bl -tag -width Ds .It Fl ansi Synonym for .Fl std=c89 . .It Fl B Ns Ar prefix Define alternate prefix path for .Xr cpp 1 , .Xr ccom 1 , .Xr as 1 , or .Xr ld 1 executables. .\" TODO: provide an example of -B .It Fl C Passed to the .Xr cpp 1 preprocessor to not discard comments. .It Fl c Stop after generating object code with .Xr as 1 . Do not link. The resulting object output is saved as a filename with a .Dq \&.o suffix unless .Fl o option is used. Note: cannot be combined with .Fl o if multiple files are given. .It Fl D Ar macro Ns Oo = Ns Ar value Oc Passed to the .Xr cpp 1 preprocessor to define .Ar macro with an optional .Ar value . .It Fl d Ns Ar flags Debug options. .Ar flags is a string of characters, which signify the following actions. .Bl -tag -width ".Sy M" .It Sy M Cause the preprocessor to output a list of macro definitions. .El .Lp any unknown flags are ignored. .It Fl E Stop after preprocessing with .Xr cpp 1 . Do not compile, assemble, or link. Output is sent to standard output unless the .Fl o option is used. .It Fl ffreestanding Assume a freestanding environment. .It Fl fPIC Generate PIC code. .\" TODO: document about avoiding machine-specific maximum size? .It Fl fpic Tells C compiler to generate PIC code and tells assembler that PIC code has been generated. .\" TODO: document difference between PIC and pic .It Fl funsigned-char Tell the compiler to treat .Sq char types as if they were unsigned unless explicitly defined otherwise. .Fl fsigned-char can be used to signify the opposite behaviour. The default for the .Sq char type depends on the compiler target architecture. .It Fl fstack-protector Tell the compiler to wrap functions with code which checks at runtime that a stack overflow has not occurred. When stack protection is in effect, the .Dv __SSP__ macro will be defined. .\" other -f GCC compatibility flags are ignored for now .It Fl g Send .Fl g flag to .Xr ccom 1 to create debug output. Debug information output can be disabled with .Fl g0 . .It Fl I Ar path Passed to the .Xr cpp 1 preprocessor to add header search directory to override system defaults. .It Fl include Ar file Tells the .Xr cpp 1 preprocessor to include the .Ar file during preprocessing. .It Fl isystem Ar path Defines .Ar path as a system header directory for the .Xr cpp 1 preprocessor. .It Fl k Generate PIC code. See .Fl fpic option. .It Fl L Ns Ar path Passed to the linker, to add .Ar path to the list of directories searched for shared libraries. .It Fl M Pass .Fl M flag to .Xr cpp 1 to generate dependencies for .Xr make 1 . .It Fl m Ns Ar option Target-dependent options. Multiple .Fl m options can be given, the following are supported: .Bl -tag -width PowerPC .It ARM \-mlittle-endian \-mbig-endian \-mfpe=fpa \-mfpe=vpf \-msoft-float \-march=armv1 \-march=armv2 \-march=armv2a \-march=armv3 \-march=armv4 \-march=armv4t \-march=armv4tej \-march=armv5 \-march=armv6 \-march=armv6t2 \-march=armv6kz \-march=armv6k \-march=armv7 .It HPPA .It i386 .It MIPS \-mlittle-endian \-mbig-endian \-mhard-float \-msoft-float .It PDP-10 .It PowerPC .It Sparc64 .It VAX .El .It Fl nodefaultlibs Do not link with the system default libraries (libc, etc.) .It Fl nostartfiles Do not link with the system startup files (crt0.c, etc.) .It Fl nostdinc Do not use the system include paths (/usr/include, etc.) .It Fl nostdlib Do not link with the system default libraries or startup files. .It Fl O Ns Oo Ar level Oc Enable compiler optimizations. Currently, for levels higher than zero, this defines .Dv __OPTIMIZE__ in the .Xr cpp 1 preprocessor, and passes .Fl xdce , .Fl xdeljumps , .Fl xtemps and .Fl xinline to .Xr ccom 1 . If no level is given the optimization level is .Fl O1 . Optimizations can be disabled using .Fl O0 . In situations where multiple optimization flags are given, the last flag is the one used. .It Fl o Ar outfile Save result to .Ar outfile . .It Fl P Inhibit generation of line markers in preprocessor output. This is sometimes useful when running the preprocessor on something other than C code. .It Fl pg Enable profiling on the generated executable. .It Fl pthread Defines the .Dv _PTHREADS preprocessor identifier for .Xr cpp 1 , and adds .Fl lpthread to the .Xr ld 1 linker arguments. .It Fl S Stop after compilation by .Xr ccom 1 . Do not assemble and do not link. The resulting assembler-language output is saved as a filename with a .Dq \&.s suffix unless the .Fl o option is used. Note: cannot be combined with .Fl o if multiple files are given. .It Fl s Passed to .Xr ld 1 to remove all symbol table and relocation information from the generated executable. This option is silently ignored if .Nm does not invoke the linker. .It Fl shared Create a shared object of the result. Tells the linker not to generate an executable. .It Fl static Do not use dynamic linkage. By default, it will link using the dynamic linker options and/or shared objects for the platform. .It Fl std= Ns Ar standard Compile to the specified .Ar standard . Accepted values for .Ar standard are .Ar c89 , .Ar c99 , .Ar gnu89 , .Ar gnu99 , .Ar gnu9x , and .Ar c11 . .It Fl t Passed to .Xr cpp 1 to suppress some default macro definitions and enable use of traditional C preprocessor syntax. .It Fl U Ar macro Passes to the .Xr cpp 1 preprocessor to remove the initial macro definition. .It Fl v Outputs the version of .Nm and shows commands as they are run with their command line arguments. .It Fl ### As per .Fl v except that the commands are not run, and the arguments will be quoted if they contain unusual characters or spaces. .It Fl Wa Ns , Ns Ar options Comma separated list of options for the assembler. .It Fl Wc Ns , Ns Ar options Comma separated list of options for the compiler. .It Fl Wl Ns , Ns Ar options Comma separated list of options for the linker. .It Fl Wp Ns , Ns Ar options Comma separated list of options for the preprocessor. .It Fl X Don't remove temporary files on exit. .It Fl x Ar language GCC compatibility option; specify the language in use rather than interpreting the filename extension. Currently known language values are .Sy none , .Sy c , .Sy c++ , .Sy assembler and .Sy assembler-with-cpp . Any unknown .Fl x options are passed to .Xr ccom 1 . .It Fl z Ar keyword Passed to .Xr ld 1 . Please refer to the documentation of your linker for acceptable values of .Ar keyword . .El .Ss Predefined Macros A few macros are predefined by .Nm when sent to .Xr cpp 1 . .Bl -diag .It __PCC__ Set to the major version of .Xr pcc 1 . These macros can be used to select code based on .Xr pcc 1 compatibility. See the .Fl v option. .It __PCC_MINOR__ Set to the minor version. .It __PCC_MINORMINOR__ Set to the minor-minor version \(em the number after the minor version. .It _PTHREADS Defined when .Fl pthread switch is used. .It __ASSEMBLER__ Defined when input files have a .S suffix, or if the .Fl x Ns assembler-with-cpp option is specified. .El .Pp Also system- and/or machine-dependent macros may also be predefined; for example: .Dv __NetBSD__ , .Dv __ELF__ , and .Dv __i386__ . .Sh SEE ALSO .Xr as 1 , .Xr ccom 1 , .Xr cpp 1 , .Xr ld 1 .Sh HISTORY The .Nm command comes from the original Portable C Compiler by .An "S. C. Johnson" , written in the late 70's. .Pp This product includes software developed or owned by Caldera International, Inc. ================================================ FILE: initrd/usr/share/man/man1/pcpp.1 ================================================ .\" $Id: cc.1,v 1.45 2016/10/10 11:27:49 ragge Exp $ .\" .\" Copyright (c) 2007 Jeremy C. Reed .\" .\" Permission to use, copy, modify, and/or distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above .\" copyright notice and this permission notice appear in all copies. .\" .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR AND CONTRIBUTORS DISCLAIM .\" ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL AUTHOR AND .\" CONTRIBUTORS BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL .\" DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR .\" PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS .\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF .\" THIS SOFTWARE. .\" .Dd June 20, 2014 .Dt CC 1 .Os .Sh NAME .Nm cc .Nd front-end to the C compiler .Sh SYNOPSIS .Nm .Op Fl cEgkMPSstvX .Op Fl ansi .Op Fl B Ns Ar prefix .Op Fl D Ar macro Ns Oo = Ns Ar value Oc .Op Fl d Ns Ar flags .Op Fl f Ns Ar feature .Op Fl I Ar path .Op Fl include Ar file .Op Fl isystem Ar path .Op Fl L Ns Ar path .Op Fl m Ns Ar option .Op Fl nodefaultlibs .Op Fl nostartfiles .Op Fl nostdinc .Op Fl nostdlib .Op Fl O Ns Oo Ar level Oc .Op Fl o Ar outfile .Op Fl pg .Op Fl pthread .Op Fl shared .Op Fl static .Op Fl std= Ns Ar standard .Op Fl U Ar macro .Op Fl Wa Ns , Ns Ar options .Op Fl Wc Ns , Ns Ar options .Op Fl Wl Ns , Ns Ar options .Op Fl Wp Ns , Ns Ar options .Op Fl x Ar language .Op Fl z Ar keyword .Op Ar .Sh DESCRIPTION The .Nm utility provides a front-end to the .Dq portable C compiler . Multiple files may be given on the command line. Unrecognized options are sent directly to .Xr ld 1 . .Pp .\" Brief description of its syntax: Filenames that end with .Sy \&.c are passed via .Xr cpp 1 \(-> .Xr ccom 1 \(-> .Xr as 1 \(-> .Xr ld 1 . .Pp Filenames that end with .Sy \&.i are passed via .Xr ccom 1 \(-> .Xr as 1 \(-> .Xr ld 1 . .Pp Filenames that end with .Sy \&.s are passed via .Xr as 1 \(-> .Xr ld 1 . .Pp Filenames that end with .Sy \&.S are passed via .Xr cpp 1 \(-> .Xr as 1 \(-> .Xr ld 1 . .Pp Filenames that end with .Sy \&.o are passed directly to .Xr ld 1 . .Pp .\" The options are as follows: .Bl -tag -width Ds .It Fl ansi Synonym for .Fl std=c89 . .It Fl B Ns Ar prefix Define alternate prefix path for .Xr cpp 1 , .Xr ccom 1 , .Xr as 1 , or .Xr ld 1 executables. .\" TODO: provide an example of -B .It Fl C Passed to the .Xr cpp 1 preprocessor to not discard comments. .It Fl c Stop after generating object code with .Xr as 1 . Do not link. The resulting object output is saved as a filename with a .Dq \&.o suffix unless .Fl o option is used. Note: cannot be combined with .Fl o if multiple files are given. .It Fl D Ar macro Ns Oo = Ns Ar value Oc Passed to the .Xr cpp 1 preprocessor to define .Ar macro with an optional .Ar value . .It Fl d Ns Ar flags Debug options. .Ar flags is a string of characters, which signify the following actions. .Bl -tag -width ".Sy M" .It Sy M Cause the preprocessor to output a list of macro definitions. .El .Lp any unknown flags are ignored. .It Fl E Stop after preprocessing with .Xr cpp 1 . Do not compile, assemble, or link. Output is sent to standard output unless the .Fl o option is used. .It Fl ffreestanding Assume a freestanding environment. .It Fl fPIC Generate PIC code. .\" TODO: document about avoiding machine-specific maximum size? .It Fl fpic Tells C compiler to generate PIC code and tells assembler that PIC code has been generated. .\" TODO: document difference between PIC and pic .It Fl funsigned-char Tell the compiler to treat .Sq char types as if they were unsigned unless explicitly defined otherwise. .Fl fsigned-char can be used to signify the opposite behaviour. The default for the .Sq char type depends on the compiler target architecture. .It Fl fstack-protector Tell the compiler to wrap functions with code which checks at runtime that a stack overflow has not occurred. When stack protection is in effect, the .Dv __SSP__ macro will be defined. .\" other -f GCC compatibility flags are ignored for now .It Fl g Send .Fl g flag to .Xr ccom 1 to create debug output. Debug information output can be disabled with .Fl g0 . .It Fl I Ar path Passed to the .Xr cpp 1 preprocessor to add header search directory to override system defaults. .It Fl include Ar file Tells the .Xr cpp 1 preprocessor to include the .Ar file during preprocessing. .It Fl isystem Ar path Defines .Ar path as a system header directory for the .Xr cpp 1 preprocessor. .It Fl k Generate PIC code. See .Fl fpic option. .It Fl L Ns Ar path Passed to the linker, to add .Ar path to the list of directories searched for shared libraries. .It Fl M Pass .Fl M flag to .Xr cpp 1 to generate dependencies for .Xr make 1 . .It Fl m Ns Ar option Target-dependent options. Multiple .Fl m options can be given, the following are supported: .Bl -tag -width PowerPC .It ARM \-mlittle-endian \-mbig-endian \-mfpe=fpa \-mfpe=vpf \-msoft-float \-march=armv1 \-march=armv2 \-march=armv2a \-march=armv3 \-march=armv4 \-march=armv4t \-march=armv4tej \-march=armv5 \-march=armv6 \-march=armv6t2 \-march=armv6kz \-march=armv6k \-march=armv7 .It HPPA .It i386 .It MIPS \-mlittle-endian \-mbig-endian \-mhard-float \-msoft-float .It PDP-10 .It PowerPC .It Sparc64 .It VAX .El .It Fl nodefaultlibs Do not link with the system default libraries (libc, etc.) .It Fl nostartfiles Do not link with the system startup files (crt0.c, etc.) .It Fl nostdinc Do not use the system include paths (/usr/include, etc.) .It Fl nostdlib Do not link with the system default libraries or startup files. .It Fl O Ns Oo Ar level Oc Enable compiler optimizations. Currently, for levels higher than zero, this defines .Dv __OPTIMIZE__ in the .Xr cpp 1 preprocessor, and passes .Fl xdce , .Fl xdeljumps , .Fl xtemps and .Fl xinline to .Xr ccom 1 . If no level is given the optimization level is .Fl O1 . Optimizations can be disabled using .Fl O0 . In situations where multiple optimization flags are given, the last flag is the one used. .It Fl o Ar outfile Save result to .Ar outfile . .It Fl P Inhibit generation of line markers in preprocessor output. This is sometimes useful when running the preprocessor on something other than C code. .It Fl pg Enable profiling on the generated executable. .It Fl pthread Defines the .Dv _PTHREADS preprocessor identifier for .Xr cpp 1 , and adds .Fl lpthread to the .Xr ld 1 linker arguments. .It Fl S Stop after compilation by .Xr ccom 1 . Do not assemble and do not link. The resulting assembler-language output is saved as a filename with a .Dq \&.s suffix unless the .Fl o option is used. Note: cannot be combined with .Fl o if multiple files are given. .It Fl s Passed to .Xr ld 1 to remove all symbol table and relocation information from the generated executable. This option is silently ignored if .Nm does not invoke the linker. .It Fl shared Create a shared object of the result. Tells the linker not to generate an executable. .It Fl static Do not use dynamic linkage. By default, it will link using the dynamic linker options and/or shared objects for the platform. .It Fl std= Ns Ar standard Compile to the specified .Ar standard . Accepted values for .Ar standard are .Ar c89 , .Ar c99 , .Ar gnu89 , .Ar gnu99 , .Ar gnu9x , and .Ar c11 . .It Fl t Passed to .Xr cpp 1 to suppress some default macro definitions and enable use of traditional C preprocessor syntax. .It Fl U Ar macro Passes to the .Xr cpp 1 preprocessor to remove the initial macro definition. .It Fl v Outputs the version of .Nm and shows commands as they are run with their command line arguments. .It Fl ### As per .Fl v except that the commands are not run, and the arguments will be quoted if they contain unusual characters or spaces. .It Fl Wa Ns , Ns Ar options Comma separated list of options for the assembler. .It Fl Wc Ns , Ns Ar options Comma separated list of options for the compiler. .It Fl Wl Ns , Ns Ar options Comma separated list of options for the linker. .It Fl Wp Ns , Ns Ar options Comma separated list of options for the preprocessor. .It Fl X Don't remove temporary files on exit. .It Fl x Ar language GCC compatibility option; specify the language in use rather than interpreting the filename extension. Currently known language values are .Sy none , .Sy c , .Sy c++ , .Sy assembler and .Sy assembler-with-cpp . Any unknown .Fl x options are passed to .Xr ccom 1 . .It Fl z Ar keyword Passed to .Xr ld 1 . Please refer to the documentation of your linker for acceptable values of .Ar keyword . .El .Ss Predefined Macros A few macros are predefined by .Nm when sent to .Xr cpp 1 . .Bl -diag .It __PCC__ Set to the major version of .Xr pcc 1 . These macros can be used to select code based on .Xr pcc 1 compatibility. See the .Fl v option. .It __PCC_MINOR__ Set to the minor version. .It __PCC_MINORMINOR__ Set to the minor-minor version \(em the number after the minor version. .It _PTHREADS Defined when .Fl pthread switch is used. .It __ASSEMBLER__ Defined when input files have a .S suffix, or if the .Fl x Ns assembler-with-cpp option is specified. .El .Pp Also system- and/or machine-dependent macros may also be predefined; for example: .Dv __NetBSD__ , .Dv __ELF__ , and .Dv __i386__ . .Sh SEE ALSO .Xr as 1 , .Xr ccom 1 , .Xr cpp 1 , .Xr ld 1 .Sh HISTORY The .Nm command comes from the original Portable C Compiler by .An "S. C. Johnson" , written in the late 70's. .Pp This product includes software developed or owned by Caldera International, Inc. ================================================ FILE: initrd/usr/test.c ================================================ #include int main() { puts("Hello, World!\n"); } ================================================ FILE: iso/boot/grub/grub.cfg ================================================ set timeout=5 set default=0 menuentry "Aquila" { multiboot /kernel.elf.gz earlycon=ttyS0 module /initrd.img.gz boot } ================================================ FILE: kernel/Makefile ================================================ export PDIR := $(SRCDIR)/kernel # # Add include pathes to CFLAGS & ASFLAGS # CFLAGS += \ -I. \ -I$(PDIR)/arch/$(ARCH_DIR)/platform/$(PLATFORM_DIR)/include \ -I$(PDIR)/arch/$(ARCH_DIR)/include \ -I$(PDIR)/include \ -I$(PDIR) ASFLAGS += \ -I. \ -I$(PDIR)/arch/$(ARCH_DIR)/platform/$(PLATFORM_DIR)/include \ -I$(PDIR)/arch/$(ARCH_DIR)/include \ -I$(PDIR)/include \ -I$(PDIR) dirs-y = core/ fs/ dev/ sys/ mm/ net/ all: $(dirs-y) arch/ .PHONY: $(dirs-y) $(dirs-y): $(patsubst %/,%/Makefile, $(dirs-y)) @$(ECHO) " MK " kernel/$@ @$(MAKE) -C $@ $(param) .PHONY: arch/ arch/: $(dirs-y) arch/Makefile @$(ECHO) " MK " kernel/$@ @$(MAKE) -C $@ $(param) .PHONY: install install: all @$(ECHO) "Installing kernel-$(VERSION).$(ARCH) into $(DESTDIR)/boot/kernel" @$(MKDIR) -p $(DESTDIR)/boot @$(CP) arch/$(ARCH)/kernel-$(VERSION).$(ARCH) $(DESTDIR)/boot/kernel .PHONY: clean clean: param = clean clean: $(dirs-y) arch/ ================================================ FILE: kernel/README.md ================================================ # AquilaOS Kernel ### Source tree structure - arch/ - all arch. dependent code - configs/ - configurations used during build - core/ - system components that do not fit anywhere else - dev/ - kdev and supported devices - fs/ - vfs and supported filesystems - include/ - generic include headers - mm/ - arch independent memory management - scripts/ - scripts used during build - sys/ - core system components (processes, threads, scheduler, etc...) ================================================ FILE: kernel/arch/Build.mk ================================================ dirs-$(ARCH_NONE) += none/ dirs-$(ARCH_I386) += i386/ dirs-$(ARCH_X86_64) += x86_64/ dirs-$(ARCH_ARM) += arm/ ================================================ FILE: kernel/arch/Makefile ================================================ include Build.mk CWD != realpath --relative-to=$(SRCDIR) . all: builtin.o $(elf) builtin.o: $(obj-y) $(dirs-y) @$(ECHO) " LD " $(CWD)/builtin.o @$(LD) $(LDFLAGS) -r $(obj-y) $(patsubst %/,%/builtin.o, $(dirs-y)) -o $(BUILDDIR)/$(CWD)/builtin.o .PHONY: $(dirs-y) $(dirs-y): $(patsubst %/,%/Makefile, $(dirs-y)) @$(ECHO) " MK " $(CWD)/$@ @$(MAKE) -C $@ $(param) %.o:%.c @$(ECHO) " CC " $(CWD)/$@ @$(CC) $(CFLAGS) -c $< -o $@ %.o:%.S @$(ECHO) " AS " $(CWD)/$@ @$(AS) $(ASFLAGS) -c $< -o $@ .PHONY: clean clean: param = clean clean: $(dirs-y) @$(ECHO) " RM " $(obj-y) $(elf) builtin.o @$(RM) $(obj-y) $(elf) builtin.o ================================================ FILE: kernel/arch/arm/Build.mk ================================================ obj-y += none.o elf += kernel-$(VERSION).$(ARCH) kernel-$(VERSION).$(ARCH): builtin.o @echo -e " ELF " $@; @$(LD) $(LDFLAGS) -Tkernel.$(ARCH).ld -lgcc -o $@ ================================================ FILE: kernel/arch/arm/include/core/types.h ================================================ #ifndef _NONE_CORE_TYPES_H #define _NONE_CORE_TYPES_H typedef uintptr_t paddr_t; typedef uintptr_t vaddr_t; #include_next #endif /* _NONE_CORE_TYPES_H */ ================================================ FILE: kernel/arch/arm/include/cpu/io.h ================================================ #ifndef _NONE_CPU_IO_H #define _NONE_CPU_IO_H #include_next static inline uint8_t io_in8(struct ioaddr *io, uintptr_t off) { return 0; } static inline uint16_t io_in16(struct ioaddr *io, uintptr_t off) { return 0; } static inline uint32_t io_in32(struct ioaddr *io, uintptr_t off) { return 0; } static inline void io_out8(struct ioaddr *io, uintptr_t off, uint8_t val) { } static inline void io_out16(struct ioaddr *io, uintptr_t off, uint16_t val) { } static inline void io_out32(struct ioaddr *io, uintptr_t off, uint32_t val) { } #endif /* ! _NONE_CPU_IO_H */ ================================================ FILE: kernel/arch/arm/include/mm/mm.h ================================================ #ifndef _NONE_MM_MM_H #define _NONE_MM_MM_H #define USER_STACK_BASE 0 #define PAGE_SIZE (0x1000) #define PAGE_MASK (PAGE_SIZE - 1) #define ARCH_KVMEM_BASE 100 #define ARCH_KVMEM_NODES_SIZE 0 #define LMA(n) (n) #define VMA(n) (n) #include_next #endif /* _NONE_MM_MM_H */ ================================================ FILE: kernel/arch/arm/kernel.arm.ld ================================================ ENTRY(_start) INPUT(builtin.o ../../core/builtin.o ../../fs/builtin.o ../../dev/builtin.o ../../sys/builtin.o ../../mm/builtin.o ../../net/builtin.o) OUTPUT(kernel.elf) SECTIONS { LMA = 0x80010000; . = LMA; .boot.text : ALIGN(0x1000) { *boot*.o(.text*) *boot*.o(.rodata*) } .boot.data : ALIGN(0x1000) { *boot*.o(.data) } .boot.bss (NOLOAD) : ALIGN(0x1000) { *boot*.o(*) } boot_end = .; _VMA = .; .text : AT(ADDR(.text) - _VMA) ALIGN(0x1000) { *(.text*) *(.rodata*) } .__minit : AT(ADDR(.__minit) - _VMA) ALIGN(0x1000) { __minit = .; *(.__minit*) __minit_end = .; } .data : AT(ADDR(.data) - _VMA) ALIGN(0x1000) { *(.data) } .bss : AT(ADDR(.bss) - _VMA) ALIGN(0x1000) { *(.bss) } /DISCARD/ : { *(.*) } kernel_end = . - _VMA; } ================================================ FILE: kernel/arch/arm/none.c ================================================ ================================================ FILE: kernel/arch/i386/Build.mk ================================================ dirs-y += boot/ dirs-y += cpu/ dirs-y += earlycon/ dirs-y += mm/ dirs-y += sys/ dirs-y += platform/ elf += kernel-$(VERSION).$(ARCH) kernel-$(VERSION).$(ARCH): builtin.o @echo " ELF " $(CWD)/$@; @$(LD) $(LDFLAGS) -T kernel.$(ARCH).ld -o $@ ================================================ FILE: kernel/arch/i386/Makefile ================================================ include Build.mk CWD != realpath --relative-to=$(SRCDIR) . all: builtin.o $(elf) builtin.o: $(obj-y) $(dirs-y) @$(ECHO) " LD " $(CWD)/builtin.o; @$(LD) $(LDFLAGS) -r $(obj-y) $(patsubst %/,%/builtin.o, $(dirs-y)) -o builtin.o; .PHONY: $(dirs-y) $(dirs-y): $(patsubst %/,%/Makefile, $(dirs-y)) @$(ECHO) " MK " $(CWD)/$@; @$(MAKE) -C $@ $(param) %.o:%.c @$(ECHO) " CC " $(CWD)/$@; @$(CC) $(CFLAGS) -c $< -o $@ %.o:%.S @$(ECHO) " AS " $(CWD)/$@; @$(AS) $(ASFLAGS) -c $< -o $@ .PHONY: clean clean: param = clean clean: $(dirs-y) @$(ECHO) " RM " $(obj-y) $(elf) builtin.o @$(RM) $(obj-y) $(elf) builtin.o ================================================ FILE: kernel/arch/i386/boot/Build.mk ================================================ obj-$(X86_MULTIBOOT) += multiboot.o obj-$(ARCH_X86_64) += x86_64_bootstrap.o obj-y += init.o obj-y += sys.o ================================================ FILE: kernel/arch/i386/boot/Makefile ================================================ include Build.mk CWD != realpath --relative-to=$(SRCDIR) . all: builtin.o $(elf) builtin.o: $(obj-y) $(dirs-y) @$(ECHO) " LD " $(CWD)/builtin.o; @$(LD) $(LDFLAGS) -r $(obj-y) $(patsubst %/,%/builtin.o, $(dirs-y)) -o builtin.o; .PHONY: $(dirs-y) $(dirs-y): $(patsubst %/,%/Makefile, $(dirs-y)) @$(ECHO) " MK " $(CWD)/$@; @$(MAKE) -C $@ $(param) %.o:%.c @$(ECHO) " CC " $(CWD)/$@; @$(CC) $(CFLAGS) -c $< -o $@ %.o:%.S @$(ECHO) " AS " $(CWD)/$@; @$(AS) $(ASFLAGS) -c $< -o $@ .PHONY: clean clean: param = clean clean: $(dirs-y) @$(ECHO) " RM " $(obj-y) $(elf) builtin.o @$(RM) $(obj-y) $(elf) builtin.o ================================================ FILE: kernel/arch/i386/boot/init.c ================================================ /********************************************************************** * Early initalization of the kernel * (Switch to higher half kernel) * * * This file is part of AquilaOS and is released under the terms of * GNU GPLv3 - See LICENSE. * * Copyright (C) Mohamed Anwar */ #include #include #include #include #include #include /* Minimalistic Paging structure for BSP */ #if ARCH_BITS==32 volatile uint32_t _BSP_PD[1024] __aligned(PAGE_SIZE); #else volatile uint64_t _BSP_PD[512] __aligned(PAGE_SIZE); volatile uint64_t _BSP_PDPT[512] __aligned(PAGE_SIZE); volatile uint64_t _BSP_PML4[512] __aligned(PAGE_SIZE); #endif #define P _BV(0) #define RW _BV(1) #define PCD _BV(4) extern char kernel_end; char scratch[1024 * 1024] __aligned(PAGE_SIZE); /* 1 MiB scratch area */ static inline void enable_paging(uintptr_t page_directory) { write_cr3(page_directory); #if ARCH_BITS==32 uint32_t cr0 = read_cr0(); write_cr0(cr0 | CR0_PG); #endif } static void switch_to_higher_half(void) { uint32_t i; uintptr_t entries; /* zero out paging structure */ memset((void *) _BSP_PD, 0, sizeof(_BSP_PD)); #if ARCH_BITS==64 memset((void *) _BSP_PDPT, 0, sizeof(_BSP_PDPT)); memset((void *) _BSP_PML4, 0, sizeof(_BSP_PML4)); #endif /* entries count required to map the kernel */ entries = ((uintptr_t)(&kernel_end) + KERNEL_HEAP_SIZE + TABLE_MASK) / TABLE_SIZE; #if ARCH_BITS==32 uint32_t *_BSP_PT = (uint32_t *) scratch; /* identity map pages */ for (i = 0; i < entries * 1024; ++i) _BSP_PT[i] = (i * PAGE_SIZE) | P | RW; /* map the lower-half */ for (i = 0; i < entries; ++i) _BSP_PD[i] = ((uint32_t) _BSP_PT + i * PAGE_SIZE) | P | RW; /* map the upper-half */ for (i = 0; i < entries; ++i) _BSP_PD[768 + i] = ((uint32_t) _BSP_PT + i * PAGE_SIZE) | P | RW; /* Enable paging using Bootstrap Processor Page Directory */ extern void enable_paging(uint32_t); enable_paging((uint32_t) _BSP_PD); #else uint64_t *_BSP_PT = (uint64_t *) scratch; /* identity map pages */ for (i = 0; i < entries * 512; ++i) _BSP_PT[i] = (i * PAGE_SIZE) | P | RW; /* map the lower-half */ for (i = 0; i < entries; ++i) _BSP_PD[i] = ((uint64_t) _BSP_PT + i * PAGE_SIZE) | P | RW; _BSP_PDPT[0] = (uint64_t) _BSP_PD | P | RW; _BSP_PML4[0] = (uint64_t) _BSP_PDPT | P | RW; /* map the upper-half */ _BSP_PML4[256] = (uint64_t) _BSP_PDPT | P | RW; /* Enable paging using Bootstrap Processor PML4 */ enable_paging((uint64_t) _BSP_PML4); #endif } void x86_bootstrap() { /* We assume that GrUB loaded a valid GDT */ /* Then we map the kernel to the higher half */ switch_to_higher_half(); /* Now we make SP in the higher half */ #if ARCH_BITS==32 //asm volatile("add %0, %%esp"::"g"(VMA((uintptr_t) 0)):"esp"); extern void early_init_fix_stack(uintptr_t); early_init_fix_stack(VMA((uintptr_t) 0)); #else asm volatile("add %0, %%rsp"::"r"(VMA((uintptr_t) 0)):"rsp"); #endif /* Ready to get out of here */ extern void x86_cpu_init(void); x86_cpu_init(); /* Why would we ever get back here? however we should be precautious */ for (;;) asm volatile ("hlt;"); } ================================================ FILE: kernel/arch/i386/boot/multiboot.S ================================================ /********************************************************************** * Multiboot support * * * This file is part of AquilaOS and is released under the terms of * GNU GPLv3 - See LICENSE. * * Copyright (C) Mohamed Anwar */ #include #define ASM_FILE #include /* * Multiboot definitions */ #if MULTIBOOT_GFX #define MULTIBOOT_GFX_ENABLE MULTIBOOT_VIDEO_MODE #else #define MULTIBOOT_GFX_ENABLE 0 #endif #define MULTIBOOT_FLAGS MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_GFX_ENABLE #define MULTIBOOT_CHKSUM -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_FLAGS) /* * Multiboot lookup header */ /* struct multiboot_header */ .align 8 .long MULTIBOOT_HEADER_MAGIC /* magic */ .long MULTIBOOT_FLAGS /* flags */ .long MULTIBOOT_CHKSUM /* checksum */ .long 0 /* header_addr */ .long 0 /* heload_addr */ .long 0 /* heload_end_addr */ .long 0 /* hebss_end_addr */ .long 0 /* heentry_addr */ .long 0 /* mode_type */ .long 1024 /* mowidth */ .long 768 /* moheight */ .long 32 /* modepth */ /* * Entry point of the bootloader */ .global _start _start: movl %eax, (multiboot_signature) movl %ebx, (multiboot_info) and $-16, %esp /* Align stack to 16 byte */ mov $0, %ebp cli #if ARCH_BITS==32 .extern x86_bootstrap call x86_bootstrap #else .extern x86_64_bootstrap call x86_64_bootstrap #endif jmp . .global multiboot_signature .global multiboot_info multiboot_signature: .long 0 multiboot_info: .long 0 /* vim: ft=gas: */ ================================================ FILE: kernel/arch/i386/boot/sys.S ================================================ .global early_init_fix_stack early_init_fix_stack: mov 4(%esp), %eax add %eax, %esp mov $0, %ebp ret ================================================ FILE: kernel/arch/i386/boot/x86_64_bootstrap.S ================================================ .code32 .global x86_64_bootstrap x86_64_bootstrap: /* Set up basic identity paging * PML4 -> 0x0FF000 * PDPT -> 0x0FE000 * PD -> 0x0FD000 */ /* Zero out 0xFE000 -> 0x100000 */ mov $0xFE000, %edi mov $0x2000, %ecx xor %eax, %eax rep stosb /* Setup PDPT */ mov $0x0FD000, %edi mov $0x200, %ecx /* 512 entries */ mov $0x83, %eax .__pdpt: movl %eax, 0(%edi) add $0x4, %edi movl $0, 0(%edi) add $0x4, %edi add $0x200000, %eax dec %ecx jnz .__pdpt /* Page Directory */ movl $0xFE000, %edi movl $0xFD000 | 3, 0(%edi) /* PML4 */ movl $0xFF000, %edi movl $0xFE000 | 3, 0(%edi) /* Set PAE and PGE */ movl $0xA0, %eax mov %eax, %cr4 /* Point CR3 to PML4 */ movl %edi, %cr3 /* Set LME */ mov $0xC0000080, %ecx rdmsr or $0x100, %eax wrmsr /* Enable paging and protection */ mov %cr0, %eax or $0x80000001, %eax mov %eax, %cr0 /* Set up basic 64-bit GDT */ lgdt __x86_64_bootstrap_gdt_p ljmp $0x8, $__x86_64_longmode .align 4 __x86_64_bootstrap_gdt: /* NULL segment */ .quad 0x0000000000000000 /* XR_CODE, DPL0, L segment */ .quad 0x00AF9A000000FFFF /* WR_DATA, DPL0, L segment */ .quad 0x00AF92000000FFFF .align 4 __x86_64_bootstrap_gdt_p: .word . - __x86_64_bootstrap_gdt - 1 .long __x86_64_bootstrap_gdt .code64 __x86_64_longmode: mov $0x10, %ax mov %ax, %ds mov %ax, %es mov %ax, %fs mov %ax, %gs mov %ax, %ss .extern early_init call early_init hlt jmp . /* vim: ft=gas: */ ================================================ FILE: kernel/arch/i386/cpu/Build.mk ================================================ obj-y += init.o obj-y += gdt.o obj-y += idt.o obj-y += isr.o #obj-y += smp.o obj-y += fpu.o obj-y += cpu.o obj-y += arith.o obj-y += trace.o ================================================ FILE: kernel/arch/i386/cpu/Makefile ================================================ include Build.mk CWD != realpath --relative-to=$(SRCDIR) . all: builtin.o $(elf) builtin.o: $(obj-y) $(dirs-y) @$(ECHO) " LD " $(CWD)/builtin.o; @$(LD) $(LDFLAGS) -r $(obj-y) $(patsubst %/,%/builtin.o, $(dirs-y)) -o builtin.o; .PHONY: $(dirs-y) $(dirs-y): $(patsubst %/,%/Makefile, $(dirs-y)) @$(ECHO) " MK " $(CWD)/$@; @$(MAKE) -C $@ $(param) %.o:%.c @$(ECHO) " CC " $(CWD)/$@; @$(CC) $(CFLAGS) -c $< -o $@ %.o:%.S @$(ECHO) " AS " $(CWD)/$@; @$(AS) $(ASFLAGS) -c $< -o $@ .PHONY: clean clean: param = clean clean: $(dirs-y) @$(ECHO) " RM " $(obj-y) $(elf) builtin.o @$(RM) $(obj-y) $(elf) builtin.o ================================================ FILE: kernel/arch/i386/cpu/arith.c ================================================ /* * https://www.ida.liu.se/~TDIU25/pintos/src/lib/arithmetic.c */ #include /* Uses x86 DIVL instruction to divide 64-bit N by 32-bit D to yield a 32-bit quotient. Returns the quotient. Traps with a divide error (#DE) if the quotient does not fit in 32 bits. */ static inline uint32_t divl(uint64_t n, uint32_t d) { uint32_t n1 = n >> 32; uint32_t n0 = n; uint32_t q, r; asm ("divl %4" : "=d" (r), "=a" (q) : "0" (n1), "1" (n0), "rm" (d)); return q; } /* Returns the number of leading zero bits in X, which must be nonzero. */ static int nlz(uint32_t x) { int n = 0; if (x <= 0x0000FFFF) { n += 16; x <<= 16; } if (x <= 0x00FFFFFF) { n += 8; x <<= 8; } if (x <= 0x0FFFFFFF) { n += 4; x <<= 4; } if (x <= 0x3FFFFFFF) { n += 2; x <<= 2; } if (x <= 0x7FFFFFFF) n++; return n; } /* Divides unsigned 64-bit N by unsigned 64-bit D and returns the quotient. */ static uint64_t udiv64(uint64_t n, uint64_t d) { if ((d >> 32) == 0) { /* Proof of correctness: * Let n, d, b, n1, and n0 be defined as in this function. * Let [x] be the "floor" of x. Let T = b[n1/d]. Assume d * nonzero. Then: * [n/d] = [n/d] - T + T * = [n/d - T] + T by (1) below * = [(b*n1 + n0)/d - T] + T by definition of n * = [(b*n1 + n0)/d - dT/d] + T * = [(b(n1 - d[n1/d]) + n0)/d] + T * = [(b[n1 % d] + n0)/d] + T, by definition of % * which is the expression calculated below. * * (1) Note that for any real x, integer i: [x] + i = [x + i]. * * To prevent divl() from trapping, [(b[n1 % d] + n0)/d] must * be less than b. Assume that [n1 % d] and n0 take their * respective maximum values of d - 1 and b - 1: * [(b(d - 1) + (b - 1))/d] < b * <=> [(bd - 1)/d] < b * <=> [b - 1/d] < b * which is a tautology. * * Therefore, this code is correct and will not trap. */ uint64_t b = 1ULL << 32; uint32_t n1 = n >> 32; uint32_t n0 = n; uint32_t d0 = d; return divl(b * (n1 % d0) + n0, d0) + b * (n1 / d0); } else { /* Based on the algorithm and proof available from * http://www.hackersdelight.org/revisions.pdf. */ if (n < d) { return 0; } else { uint32_t d1 = d >> 32; int s = nlz(d1); uint64_t q = divl(n >> 1, (d << s) >> 32) >> (31 - s); return n - (q - 1) * d < d ? q - 1 : q; } } } /* Divides unsigned 64-bit N by unsigned 64-bit D and returns the remainder. */ static uint32_t umod64(uint64_t n, uint64_t d) { return n - d * udiv64(n, d); } /* Divides signed 64-bit N by signed 64-bit D and returns the quotient. */ static int64_t sdiv64(int64_t n, int64_t d) { uint64_t n_abs = n >= 0 ? (uint64_t) n : -(uint64_t) n; uint64_t d_abs = d >= 0 ? (uint64_t) d : -(uint64_t) d; uint64_t q_abs = udiv64 (n_abs, d_abs); return (n < 0) == (d < 0) ? (int64_t) q_abs : -(int64_t) q_abs; } /* Divides signed 64-bit N by signed 64-bit D and returns the remainder. */ static int32_t smod64(int64_t n, int64_t d) { return n - d * sdiv64(n, d); } /* These are the routines that GCC calls. */ long long __divdi3(long long n, long long d); long long __moddi3(long long n, long long d); unsigned long long __udivdi3(unsigned long long n, unsigned long long d); unsigned long long __umoddi3(unsigned long long n, unsigned long long d); /* Signed 64-bit division. */ long long __divdi3(long long n, long long d) { return sdiv64(n, d); } /* Signed 64-bit remainder. */ long long __moddi3(long long n, long long d) { return smod64 (n, d); } /* Unsigned 64-bit division. */ unsigned long long __udivdi3(unsigned long long n, unsigned long long d) { return udiv64 (n, d); } /* Unsigned 64-bit remainder. */ unsigned long long __umoddi3(unsigned long long n, unsigned long long d) { return umod64 (n, d); } ================================================ FILE: kernel/arch/i386/cpu/cpu.S ================================================ #include .global x86_cpuid_check x86_cpuid_check: #if ARCH_BITS==32 pushf pushf xorl $1 << 21, (%esp) popf pushf pop %eax xorl (%esp), %eax andl $1 << 21, %eax popf ret #else /* TODO */ #endif /* * ISRs -- Interrupt Service Routines */ .global __x86_isr_int_num, __x86_isr_err_num __x86_isr_int_num: .long 0 __x86_isr_err_num: .long 0 .macro ISR_NOERR v .global __x86_isr\v __x86_isr\v: cli #if ARCH_BITS==32 movl $0, (__x86_isr_err_num) movl $\v, (__x86_isr_int_num) #else movl $0, __x86_isr_err_num(%rip) movl $\v, __x86_isr_int_num(%rip) #endif jmp isr_handler .endm .macro ISR_ERR v .global __x86_isr\v __x86_isr\v: cli #if ARCH_BITS==32 popl (__x86_isr_err_num) movl $\v, (__x86_isr_int_num) jmp isr_handler #else push %rbx movq 8(%rsp), %rbx movl %ebx, __x86_isr_err_num(%rip) pop %rbx add $8, %rsp movl $\v, __x86_isr_int_num(%rip) jmp isr_handler #endif .endm .macro push_context #if ARCH_BITS==32 push %eax push %edx push %ecx push %ebx push %ebp push %esi push %edi #else push %rax push %rdx push %rcx push %rbx push %rbp push %rsi push %rdi push %r8 push %r9 push %r10 push %r11 push %r12 push %r13 push %r14 push %r15 #endif .endm .macro pop_context #if ARCH_BITS==32 pop %edi pop %esi pop %ebp pop %ebx pop %ecx pop %edx pop %eax #else pop %r15 pop %r14 pop %r13 pop %r12 pop %r11 pop %r10 pop %r9 pop %r8 pop %rdi pop %rsi pop %rbp pop %rbx pop %rcx pop %rdx pop %rax #endif .endm /* Refer to * - Intel 64 and IA-32 Architectures Software Developer’s Manual * - Volume 3: System Programming Guide * - Table 6-1. Protected-Mode Exceptions and Interrupts */ ISR_NOERR 0 ISR_NOERR 1 ISR_NOERR 2 ISR_NOERR 3 ISR_NOERR 4 ISR_NOERR 5 ISR_NOERR 6 ISR_NOERR 7 ISR_ERR 8 ISR_NOERR 9 ISR_ERR 10 ISR_ERR 11 ISR_ERR 12 ISR_ERR 13 ISR_ERR 14 ISR_NOERR 15 ISR_NOERR 16 ISR_ERR 17 ISR_NOERR 18 ISR_NOERR 19 ISR_NOERR 20 ISR_NOERR 21 ISR_NOERR 22 ISR_NOERR 23 ISR_NOERR 24 ISR_NOERR 25 ISR_NOERR 26 ISR_NOERR 27 ISR_NOERR 28 ISR_NOERR 29 ISR_NOERR 30 ISR_NOERR 31 ISR_NOERR 128 .extern __x86_isr isr_handler: #if ARCH_BITS==32 push_context push %esp mov $0, %ebp call __x86_isr pop %eax pop_context iret #else push_context mov %rsp, %rdi call __x86_isr pop_context iretq #endif /* * IRQs -- external interrupt requists (from PIC) */ .macro IRQ n, i .global __x86_irq\n __x86_irq\n: #if ARCH_BITS==32 cli movl $\i, (__x86_isr_int_num) jmp irq_stub #else cli movl $\i, __x86_isr_int_num(%rip) jmp irq_stub #endif .endm IRQ 0, 32 IRQ 1, 33 IRQ 2, 34 IRQ 3, 35 IRQ 4, 36 IRQ 5, 37 IRQ 6, 38 IRQ 7, 39 IRQ 8, 40 IRQ 9, 41 IRQ 10, 42 IRQ 11, 43 IRQ 12, 44 IRQ 13, 45 IRQ 14, 46 IRQ 15, 47 .extern __x86_irq_handler irq_stub: #if ARCH_BITS==32 push_context push %esp call __x86_irq_handler pop %eax pop_context iret #else push_context mov %rsp, %rdi call __x86_irq_handler pop_context iretq #endif .global x86_jump_user x86_jump_user: /* eax, eip, cs, eflags, esp, ss */ #if ARCH_BITS==32 pop %eax /* Caller return address */ mov $0x20 | 0x3, %ax movw %ax, %ds movw %ax, %es movw %ax, %fs movw %ax, %gs pop %eax /* eax for sys_fork return */ iret #else pop %rax /* Caller return address */ /* set segments */ mov $0x20 | 0x3, %ax movw %ax, %ds movw %ax, %es movw %ax, %fs movw %ax, %gs mov %rdi, %rax /* rax for sys_fork return */ /* push registers */ pushq %r9 /* ss */ pushq %r8 /* rsp */ pushq %rcx /* rflags */ pushq %rdx /* cs */ pushq %rsi /* rip */ iretq #endif .global x86_read_ip x86_read_ip: #if ARCH_BITS==32 mov (%esp), %eax #else mov (%rsp), %rax #endif ret .global x86_goto x86_goto: #if ARCH_BITS==32 pop %ebx /* Caller return address */ pop %ebx /* eip */ pop %ebp pop %esp mov $-1, %eax /* Return -1 -> Done switching */ jmp *%ebx #else pop %rbx /* Caller return address */ mov %rdi, %rbx /* rip */ mov %rsi, %rbp mov %rdx, %rsp mov $-1, %rax /* Return -1 -> Done switching */ jmp *%rbx #endif .extern internal_arch_sleep .global x86_sleep x86_sleep: push_context call internal_arch_sleep pop_context ret .global x86_fork_return x86_fork_return: #if ARCH_BITS==32 pop_context iret #else pop_context iretq #endif .global return_from_signal return_from_signal: mov 4(%esp), %edi mov %edi, %esp /* Fix stack pointer */ pop_context iret .align 8 gdt_pointer: .word 0 #if ARCH_BITS==32 .long 0 #else .quad 0 #endif .global x86_lgdt x86_lgdt: #if ARCH_BITS==32 movw 4(%esp), %ax movl 8(%esp), %ebx movw %ax, (gdt_pointer) movl %ebx, (gdt_pointer + 2) lgdt (gdt_pointer) ljmp $0x8, $1f #else movw %di, gdt_pointer(%rip) movq %rsi, (gdt_pointer + 2)(%rip) lgdt gdt_pointer(%rip) #endif 1: movl $0x10, %eax movl %eax, %ds movl %eax, %es movl %eax, %fs movl %eax, %gs movl %eax, %ss ret .global x86_lidt x86_lidt: #if ARCH_BITS==32 movl 4(%esp), %eax lidt (%eax) #else lidt (%rdi) #endif ret .global x86_ltr x86_ltr: #if ARCH_BITS==32 movl 4(%esp), %eax ltr %ax #else ltr %di #endif ret /* vim: ft=gas: */ ================================================ FILE: kernel/arch/i386/cpu/cpu.h ================================================ #ifndef _CPU_SYS_H #define _CPU_SYS_H #include void x86_lgdt(uint16_t, uintptr_t); void x86_lidt(uintptr_t); void x86_ltr(uintptr_t); #endif /* ! _CPU_SYS_H */ ================================================ FILE: kernel/arch/i386/cpu/fpu.c ================================================ #include #include #include #include #include #include #include MALLOC_DEFINE(M_X86_FPU, "x86-fpu", "x86 FPU context"); static char fpu_context[512] __aligned(16); struct thread *last_fpu_thread = NULL; void x86_fpu_enable(void) { asm volatile("clts"); write_cr0((read_cr0() & ~CR0_EM) | CR0_MP); } void x86_fpu_disable(void) { write_cr0(read_cr0() | CR0_EM); } void x86_fpu_init(void) { assert_alignof(fpu_context, 16); asm volatile("fninit"); } static inline void fpu_save(void) { asm volatile("fxsave (%0)"::"r"(fpu_context):"memory"); } static inline void fpu_restore(void) { asm volatile("fxrstor (%0)"::"r"(fpu_context):"memory"); } void x86_fpu_trap(void) { x86_fpu_enable(); struct x86_thread *arch = curthread->arch; if (!last_fpu_thread) { /* Initialize */ x86_fpu_init(); arch->fpu_enabled = 1; } else if (curthread != last_fpu_thread) { struct x86_thread *_arch = last_fpu_thread->arch; if (!_arch->fpu_context) { /* Lazy allocate */ _arch->fpu_context = kmalloc(512, &M_X86_FPU, 0); if (!_arch->fpu_context) { /* TODO */ } } fpu_save(); memcpy(_arch->fpu_context, fpu_context, 512); if (arch->fpu_enabled) { /* Restore context */ memcpy(fpu_context, arch->fpu_context, 512); fpu_restore(); } else { x86_fpu_init(); arch->fpu_enabled = 1; } } last_fpu_thread = curthread; } ================================================ FILE: kernel/arch/i386/cpu/gdt.c ================================================ /********************************************************************** * Global Descriptor Table (GDT) * * * This file is part of Aquila OS and is released under the terms of * GNU GPLv3 - See LICENSE. * * Copyright (C) Mohamed Anwar */ #include #include #include #include #include "cpu.h" #if ARCH_BITS==32 static struct { uint32_t link; uint32_t sp; uint32_t ss; uint32_t _[23]; /* To know the actuall fields, consult Intel Manuals */ } __packed tss_entry __aligned(8); #else static struct { uint32_t _; uint64_t sp; uint32_t __[23]; /* To know the actuall fields, consult Intel Manuals */ } __packed tss_entry __aligned(8); #endif #define TSS_BASE ((uintptr_t) &tss_entry) #define TSS_LIMIT (sizeof(tss_entry) - 1) #define RW_DATA 0x2 #define XR_CODE 0xA #define TSS_AVL 0x9 #define BASE 0 #define LIMIT -1 #define DPL0 0 #define DPL3 3 #if ARCH_BITS==32 #define L 0 #define D 1 #else #define L 1 #define D 0 #endif static struct gdt_entry { uint32_t limit_lo : 16; /* Segment Limit 15:00 */ uint32_t base_lo : 16; /* Base Address 15:00 */ uint32_t base_mid : 8; /* Base Address 23:16 */ uint32_t type : 4; /* Segment Type */ uint32_t s : 1; /* Descriptor type (0=system, 1=code) */ uint32_t dpl : 2; /* Descriptor Privellage Level */ uint32_t p : 1; /* Segment present */ uint32_t limit_hi : 4; /* Segment Limit 19:16 */ uint32_t avl : 1; /* Avilable for use by system software */ uint32_t l : 1; /* Long mode segment (64-bit only) */ uint32_t db : 1; /* Default operation size / upper Bound */ uint32_t g : 1; /* Granularity */ uint32_t base_hi : 8; /* Base Address 31:24 */ } __aligned(8) gdt[256] = { /* Null Segment */ {0}, /* Code Segment - Kernel */ {LIMIT, BASE, BASE, XR_CODE, 1, DPL0, 1, LIMIT, 0, L, D, 1, BASE}, /* Data Segment - Kernel */ {LIMIT, BASE, BASE, RW_DATA, 1, DPL0, 1, LIMIT, 0, L, D, 1, BASE}, /* Code Segment - User */ {LIMIT, BASE, BASE, XR_CODE, 1, DPL3, 1, LIMIT, 0, L, D, 1, BASE}, /* Data Segment - User */ {LIMIT, BASE, BASE, RW_DATA, 1, DPL3, 1, LIMIT, 0, L, D, 1, BASE}, }; void x86_gdt_setup(void) { assert_sizeof(gdt, 8*256); assert_alignof(&gdt, 8); x86_lgdt(sizeof(gdt) - 1, (uintptr_t) &gdt); } void x86_tss_setup(uintptr_t sp) { assert_sizeof(tss_entry, 104); assert_alignof(&tss_entry, 8); #if ARCH_BITS==32 tss_entry.ss = 0x10; #endif tss_entry.sp = sp; /* TSS Segment */ #if 0 gdt[5] = (struct gdt_entry){TSS_LIMIT & 0xFFFF, TSS_BASE & 0xFFFF, (TSS_BASE >> 16) & 0xFF, TSS_AVL, 0, DPL3, 1, (TSS_LIMIT >> 16) & 0xF, 0, 0, 0, 0, (TSS_BASE >> 24 & 0xFF)}; #endif gdt[5].limit_lo = TSS_LIMIT & 0xFFFF; gdt[5].base_lo = TSS_BASE & 0xFFFF; gdt[5].base_mid = (TSS_BASE >> 16) & 0xFF; gdt[5].type = TSS_AVL; gdt[5].s = 0; gdt[5].dpl = DPL3; gdt[5].p = 1; gdt[5].limit_hi = (TSS_LIMIT >> 16) & 0xF; gdt[5].avl = 0; gdt[5].l = 0; gdt[5].db = 0; gdt[5].g = 0; gdt[5].base_hi = (TSS_BASE >> 24 & 0xFF); #if ARCH_BITS==64 uint32_t *base_high = (uint32_t *) &gdt[6]; *base_high = TSS_BASE >> 32; #endif x86_ltr(0x28 | DPL3); } void x86_kernel_stack_set(uintptr_t sp) { tss_entry.sp = sp; } ================================================ FILE: kernel/arch/i386/cpu/idt.c ================================================ /********************************************************************** * Interrupt Descriptor Table (IDT) * * * This file is part of Aquila OS and is released under the terms of * GNU GPLv3 - See LICENSE. * * Copyright (C) Mohamed Anwar */ #include #include "cpu.h" #if __pragma_pack #pragma pack(1) #endif static struct idt_entry { uint32_t offset_lo : 16; /* offset 0:15 */ uint32_t selector : 16; /* Code segment selector */ uint32_t _unused : 8; /* Unused, should be set to 0 */ uint32_t flags : 5; /* Always set to 01110 */ uint32_t dpl : 2; /* Descriptor privellage level */ uint32_t p : 1; /* Present */ uint16_t offset_hi : 16; /* offset 16:31 */ #if ARCH_BITS==64 uint32_t offset_ext: 32; /* offset 32:63 */ uint32_t : 32; /* reserved */ #endif } __packed idt[256]; struct idt_ptr { uint16_t limit; uintptr_t base; } __packed idt_pointer; #if __pragma_pack #pragma pack() #endif #define DPL0 0 #define DPL3 3 /* Sets Interrupt gates in Kernel Code Segment */ void x86_idt_gate_set(uint32_t id, uintptr_t offset) { idt[id].offset_lo = (offset >> 0x00) & 0xFFFF; idt[id].offset_hi = (offset >> 0x10) & 0xFFFF; #if ARCH_BITS==64 idt[id].offset_ext = (offset >> 0x20) & 0xFFFFFFFF; #endif idt[id].selector = 0x8; idt[id].p = 1; idt[id].dpl = DPL0; idt[id].flags = 0x0E; } /* Sets Interrupt gates in User Code Segment */ void x86_idt_gate_user_set(uint32_t id, uintptr_t offset) { idt[id].offset_lo = (offset >> 0x00) & 0xFFFF; idt[id].offset_hi = (offset >> 0x10) & 0xFFFF; #if ARCH_BITS==64 idt[id].offset_ext = (offset >> 0x20) & 0xFFFFFFFF; #endif idt[id].selector = 0x8; idt[id].p = 1; idt[id].dpl = DPL3; idt[id].flags = 0x0E; } void x86_idt_setup() { idt_pointer.limit = sizeof(idt) - 1; idt_pointer.base = (uintptr_t) &idt; x86_lidt((uintptr_t) &idt_pointer); } ================================================ FILE: kernel/arch/i386/cpu/init.c ================================================ /********************************************************************** * Initalization of the kernel * (Setup CPU structures and memory managment) * * * This file is part of AquilaOS and is released under the terms of * GNU GPLv3 - See LICENSE. * * Copyright (C) Mohamed Anwar */ #include #include #include #include #include #include #include #include #include #include #include #include