1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:37:35 +00:00

Build: Switch to CMake :^)

Closes https://github.com/SerenityOS/serenity/issues/2080
This commit is contained in:
Sergey Bugaev 2020-05-06 18:40:06 +03:00 committed by Andreas Kling
parent 49727ffee4
commit 450a2a0f9c
236 changed files with 1774 additions and 2337 deletions

181
Kernel/CMakeLists.txt Normal file
View file

@ -0,0 +1,181 @@
set(KERNEL_SOURCES
ACPI/DMIDecoder.cpp
ACPI/DynamicParser.cpp
ACPI/Initialize.cpp
ACPI/MultiProcessorParser.cpp
ACPI/Parser.cpp
Arch/i386/CPU.cpp
CMOS.cpp
CommandLine.cpp
Devices/BlockDevice.cpp
Devices/BXVGADevice.cpp
Devices/CharacterDevice.cpp
Devices/Device.cpp
Devices/DiskPartition.cpp
Devices/EBRPartitionTable.cpp
Devices/FullDevice.cpp
Devices/GPTPartitionTable.cpp
Devices/KeyboardDevice.cpp
Devices/MBRPartitionTable.cpp
Devices/MBVGADevice.cpp
Devices/NullDevice.cpp
Devices/PATAChannel.cpp
Devices/PATADiskDevice.cpp
Devices/PCSpeaker.cpp
Devices/PS2MouseDevice.cpp
Devices/RandomDevice.cpp
Devices/SB16.cpp
Devices/SerialDevice.cpp
Devices/VMWareBackdoor.cpp
Devices/ZeroDevice.cpp
DoubleBuffer.cpp
FileSystem/Custody.cpp
FileSystem/DevPtsFS.cpp
FileSystem/Ext2FileSystem.cpp
FileSystem/FIFO.cpp
FileSystem/FileBackedFileSystem.cpp
FileSystem/File.cpp
FileSystem/FileDescription.cpp
FileSystem/FileSystem.cpp
FileSystem/Inode.cpp
FileSystem/InodeFile.cpp
FileSystem/InodeWatcher.cpp
FileSystem/ProcFS.cpp
FileSystem/TmpFS.cpp
FileSystem/VirtualFileSystem.cpp
Heap/kmalloc.cpp
Heap/SlabAllocator.cpp
init.cpp
Interrupts/APIC.cpp
Interrupts/GenericInterruptHandler.cpp
Interrupts/InterruptManagement.cpp
Interrupts/IOAPIC.cpp
Interrupts/IRQHandler.cpp
Interrupts/PIC.cpp
Interrupts/SharedIRQHandler.cpp
Interrupts/SpuriousInterruptHandler.cpp
Interrupts/UnhandledInterruptHandler.cpp
KBufferBuilder.cpp
KSyms.cpp
Lock.cpp
Net/E1000NetworkAdapter.cpp
Net/IPv4Socket.cpp
Net/LocalSocket.cpp
Net/LoopbackAdapter.cpp
Net/NetworkAdapter.cpp
Net/NetworkTask.cpp
Net/Routing.cpp
Net/RTL8139NetworkAdapter.cpp
Net/Socket.cpp
Net/TCPSocket.cpp
Net/UDPSocket.cpp
PCI/Access.cpp
PCI/Device.cpp
PCI/Initializer.cpp
PCI/IOAccess.cpp
PCI/MMIOAccess.cpp
PerformanceEventBuffer.cpp
Process.cpp
Profiling.cpp
Ptrace.cpp
Random.cpp
RTC.cpp
Scheduler.cpp
SharedBuffer.cpp
Syscall.cpp
Tasks/FinalizerTask.cpp
Tasks/SyncTask.cpp
Thread.cpp
ThreadTracer.cpp
Time/HardwareTimer.cpp
Time/HPETComparator.cpp
Time/HPET.cpp
Time/PIT.cpp
TimerQueue.cpp
Time/RTC.cpp
Time/TimeManagement.cpp
TTY/MasterPTY.cpp
TTY/PTYMultiplexer.cpp
TTY/SlavePTY.cpp
TTY/TTY.cpp
TTY/VirtualConsole.cpp
VM/AnonymousVMObject.cpp
VM/ContiguousVMObject.cpp
VM/InodeVMObject.cpp
VM/MemoryManager.cpp
VM/PageDirectory.cpp
VM/PhysicalPage.cpp
VM/PhysicalRegion.cpp
VM/PrivateInodeVMObject.cpp
VM/ProcessPagingScope.cpp
VM/PurgeableVMObject.cpp
VM/RangeAllocator.cpp
VM/Region.cpp
VM/SharedInodeVMObject.cpp
VM/VMObject.cpp
WaitQueue.cpp
)
set(AK_SOURCES
../AK/FileSystemPath.cpp
../AK/FlyString.cpp
../AK/JsonParser.cpp
../AK/JsonValue.cpp
../AK/LogStream.cpp
../AK/String.cpp
../AK/StringBuilder.cpp
../AK/StringImpl.cpp
../AK/StringUtils.cpp
../AK/StringView.cpp
)
set(ELF_SOURCES
../Libraries/LibELF/Image.cpp
../Libraries/LibELF/Loader.cpp
../Libraries/LibELF/Validation.cpp
)
set(BARE_METAL_SOURCES
../Libraries/LibBareMetal/Output/Console.cpp
../Libraries/LibBareMetal/Output/kprintf.cpp
../Libraries/LibBareMetal/StdLib.cpp
)
set(SOURCES
${KERNEL_SOURCES}
${AK_SOURCES}
${ELF_SOURCES}
${BARE_METAL_SOURCES}
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DKERNEL")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pie -fPIE -ffreestanding -fbuiltin")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mno-80387 -mno-mmx -mno-sse -mno-sse2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-asynchronous-unwind-tables")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdlib -nostdinc -nostdinc++")
add_link_options(LINKER:-T ${CMAKE_CURRENT_BINARY_DIR}/linker.ld -nostdlib)
add_library(boot OBJECT Arch/i386/Boot/boot.S)
file(GENERATE OUTPUT linker.ld INPUT linker.ld)
if (${CMAKE_HOST_SYSTEM_NAME} MATCHES SerenityOS)
include_directories(/usr/local/include/c++/9.3.0/)
include_directories(/usr/local/include/c++/9.3.0/i686-pc-serenity/)
else()
include_directories(../Toolchain/Local/i686-pc-serenity/include/c++/9.3.0/)
include_directories(../Toolchain/Local/i686-pc-serenity/include/c++/9.3.0/i686-pc-serenity/)
endif()
add_executable(Kernel ${SOURCES})
target_link_libraries(Kernel gcc stdc++)
add_dependencies(Kernel boot)
install(TARGETS Kernel RUNTIME DESTINATION boot)
add_custom_command(
TARGET Kernel
COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/mkmap.sh
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kernel.map DESTINATION res)
add_subdirectory(Modules)

View file

@ -26,12 +26,12 @@
#pragma once
#include "KeyCode.h"
#include <AK/CircularQueue.h>
#include <AK/DoublyLinkedList.h>
#include <AK/Types.h>
#include <Kernel/Devices/CharacterDevice.h>
#include <Kernel/Interrupts/IRQHandler.h>
#include <Kernel/KeyCode.h>
namespace Kernel {

View file

@ -24,10 +24,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "ProcFS.h"
#include "KSyms.h"
#include "Process.h"
#include "Scheduler.h"
#include <AK/JsonArraySerializer.h>
#include <AK/JsonObject.h>
#include <AK/JsonObjectSerializer.h>
@ -38,11 +34,13 @@
#include <Kernel/FileSystem/Custody.h>
#include <Kernel/FileSystem/FileBackedFileSystem.h>
#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/FileSystem/ProcFS.h>
#include <Kernel/FileSystem/VirtualFileSystem.h>
#include <Kernel/Heap/kmalloc.h>
#include <Kernel/Interrupts/GenericInterruptHandler.h>
#include <Kernel/Interrupts/InterruptManagement.h>
#include <Kernel/KBufferBuilder.h>
#include <Kernel/KSyms.h>
#include <Kernel/Module.h>
#include <Kernel/Net/LocalSocket.h>
#include <Kernel/Net/NetworkAdapter.h>
@ -50,7 +48,9 @@
#include <Kernel/Net/TCPSocket.h>
#include <Kernel/Net/UDPSocket.h>
#include <Kernel/PCI/Access.h>
#include <Kernel/Process.h>
#include <Kernel/Profiling.h>
#include <Kernel/Scheduler.h>
#include <Kernel/TTY/TTY.h>
#include <Kernel/VM/MemoryManager.h>
#include <Kernel/VM/PurgeableVMObject.h>

View file

@ -26,7 +26,7 @@
#include <AK/PrintfImplementation.h>
#include <AK/StdLibExtras.h>
#include <KBufferBuilder.h>
#include <Kernel/KBufferBuilder.h>
#include <stdarg.h>
namespace Kernel {

View file

@ -1,171 +0,0 @@
OBJS = \
../AK/FileSystemPath.o \
../AK/FlyString.o \
../AK/JsonParser.o \
../AK/JsonValue.o \
../AK/LogStream.o \
../AK/String.o \
../AK/StringBuilder.o \
../AK/StringImpl.o \
../AK/StringUtils.o \
../AK/StringView.o \
../Libraries/LibELF/Image.o \
../Libraries/LibELF/Loader.o \
../Libraries/LibELF/Validation.o \
../Libraries/LibBareMetal/Output/Console.o \
../Libraries/LibBareMetal/Output/kprintf.o \
../Libraries/LibBareMetal/StdLib.o \
Arch/i386/CPU.o \
CommandLine.o \
Interrupts/InterruptManagement.o \
Interrupts/APIC.o \
Interrupts/IOAPIC.o \
Interrupts/PIC.o \
Interrupts/GenericInterruptHandler.o \
Interrupts/UnhandledInterruptHandler.o \
Interrupts/SpuriousInterruptHandler.o \
Interrupts/IRQHandler.o \
Interrupts/SharedIRQHandler.o \
CMOS.o \
Time/PIT.o \
Time/TimeManagement.o \
Time/HardwareTimer.o \
Time/RTC.o \
Time/HPET.o \
Time/HPETComparator.o \
Devices/BXVGADevice.o \
Devices/BlockDevice.o \
Devices/CharacterDevice.o \
Devices/Device.o \
Devices/DiskPartition.o \
Devices/FullDevice.o \
Devices/GPTPartitionTable.o \
Devices/EBRPartitionTable.o \
Devices/KeyboardDevice.o \
Devices/MBRPartitionTable.o \
Devices/MBVGADevice.o \
Devices/NullDevice.o \
Devices/PATAChannel.o \
Devices/PATADiskDevice.o \
Devices/PCSpeaker.o \
Devices/PS2MouseDevice.o \
Devices/RandomDevice.o \
Devices/SB16.o \
Devices/SerialDevice.o \
Devices/ZeroDevice.o \
Devices/VMWareBackdoor.o \
DoubleBuffer.o \
FileSystem/Custody.o \
FileSystem/DevPtsFS.o \
FileSystem/Ext2FileSystem.o \
FileSystem/FileBackedFileSystem.o \
FileSystem/FIFO.o \
FileSystem/File.o \
FileSystem/FileDescription.o \
FileSystem/FileSystem.o \
FileSystem/Inode.o \
FileSystem/InodeFile.o \
FileSystem/InodeWatcher.o \
FileSystem/ProcFS.o \
FileSystem/TmpFS.o \
FileSystem/VirtualFileSystem.o \
Heap/SlabAllocator.o \
Heap/kmalloc.o \
KBufferBuilder.o \
KSyms.o \
Lock.o \
Net/E1000NetworkAdapter.o \
Net/IPv4Socket.o \
Net/LocalSocket.o \
Net/LoopbackAdapter.o \
Net/NetworkAdapter.o \
Net/NetworkTask.o \
Net/RTL8139NetworkAdapter.o \
Net/Routing.o \
Net/Socket.o \
Net/TCPSocket.o \
Net/UDPSocket.o \
PCI/Access.o \
PCI/IOAccess.o \
PCI/MMIOAccess.o \
PCI/Initializer.o \
PCI/Device.o \
PerformanceEventBuffer.o \
Process.o \
ThreadTracer.o \
Profiling.o \
RTC.o \
Random.o \
Scheduler.o \
SharedBuffer.o \
Syscall.o \
Tasks/FinalizerTask.o \
Tasks/SyncTask.o \
TimerQueue.o \
TTY/MasterPTY.o \
TTY/PTYMultiplexer.o \
TTY/SlavePTY.o \
TTY/TTY.o \
TTY/VirtualConsole.o \
Thread.o \
VM/AnonymousVMObject.o \
VM/ContiguousVMObject.o \
VM/InodeVMObject.o \
VM/MemoryManager.o \
VM/PageDirectory.o \
VM/PhysicalPage.o \
VM/PhysicalRegion.o \
VM/PurgeableVMObject.o \
VM/PrivateInodeVMObject.o \
VM/ProcessPagingScope.o \
VM/RangeAllocator.o \
VM/Region.o \
VM/SharedInodeVMObject.o \
VM/VMObject.o \
ACPI/DMIDecoder.o \
ACPI/DynamicParser.o \
ACPI/Initialize.o \
ACPI/MultiProcessorParser.o \
ACPI/Parser.o \
WaitQueue.o \
init.o \
Ptrace.o
OBJ_SUFFIX = .kernel
MODULE_OBJS = TestModule$(OBJ_SUFFIX).o
EXTRA_OBJS = Arch/i386/Boot/boot.ao
KERNEL = 1
PROGRAM = kernel
SUBPROJECT_CXXFLAGS += -pie -fPIE -ffreestanding -fbuiltin -mno-80387 -mno-mmx -mno-sse -mno-sse2 -fno-asynchronous-unwind-tables
SUBPROJECT_CXXFLAGS += -nostdlib -nostdinc -nostdinc++ $(SERENITY_KERNEL_CUSTOM_CXXFLAGS)
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),SerenityOS)
SUBPROJECT_CXXFLAGS += -I/usr/local/include/c++/9.3.0/
SUBPROJECT_CXXFLAGS += -I/usr/local/include/c++/9.3.0/i686-pc-serenity/
else
SUBPROJECT_CXXFLAGS += -I../Toolchain/Local/i686-pc-serenity/include/c++/9.3.0/
SUBPROJECT_CXXFLAGS += -I../Toolchain/Local/i686-pc-serenity/include/c++/9.3.0/i686-pc-serenity/
endif
LDFLAGS += -Wl,-T linker.ld -nostdlib -lgcc -lstdc++ $(SERENITY_KERNEL_CUSTOM_LDFLAGS)
all: $(PROGRAM) $(MODULE_OBJS) kernel.map
kernel.map: kernel
@echo "MKMAP $@"
$(QUIET) sh mkmap.sh
EXTRA_CLEAN += kernel.map
install:
mkdir -p $(SERENITY_BASE_DIR)/Root/usr/include/Kernel/
cp *.h $(SERENITY_BASE_DIR)/Root/usr/include/Kernel/
include ../Makefile.common

View file

@ -0,0 +1,8 @@
set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)
function(serenity_kernel_module name sources)
add_library(${name} STATIC ${sources})
install(FILES $<TARGET_OBJECTS:${name}> DESTINATION mod)
endfunction()
serenity_kernel_module(TestModule TestModule.cpp)

View file

@ -24,7 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "Process.h"
#include <Kernel/Process.h>
#include <Kernel/TTY/TTY.h>
#include <LibC/errno_numbers.h>
#include <LibC/signal_numbers.h>

View file

@ -24,14 +24,14 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "CMOS.h"
#include "Process.h"
#include <AK/Assertions.h>
#include <AK/Memory.h>
#include <AK/StringView.h>
#include <Kernel/Arch/i386/CPU.h>
#include <Kernel/CMOS.h>
#include <Kernel/FileSystem/Inode.h>
#include <Kernel/Multiboot.h>
#include <Kernel/Process.h>
#include <Kernel/VM/AnonymousVMObject.h>
#include <Kernel/VM/ContiguousVMObject.h>
#include <Kernel/VM/MemoryManager.h>

View file

@ -1,104 +0,0 @@
#!/bin/sh
set -e
die() {
echo "die: $*"
exit 1
}
if [ "$(id -u)" != 0 ]; then
die "this script needs to run as root"
fi
grub=$(command -v grub-install 2>/dev/null) || true
if [ -z "$grub" ]; then
grub=$(command -v grub2-install 2>/dev/null) || true
fi
if [ -z "$grub" ]; then
echo "can't find a grub-install or grub2-install binary, oh no"
exit 1
fi
echo "using grub-install at ${grub}"
echo "setting up disk image..."
dd if=/dev/zero of=_disk_image bs=1M count="${DISK_SIZE:-800}" status=none || die "couldn't create disk image"
chown "$SUDO_UID":"$SUDO_GID" _disk_image || die "couldn't adjust permissions on disk image"
echo "done"
printf "creating loopback device... "
dev=$(losetup --find --partscan --show _disk_image)
if [ -z "$dev" ]; then
die "couldn't mount loopback device"
fi
echo "loopback device is at ${dev}"
cleanup() {
if [ -d mnt ]; then
printf "unmounting filesystem... "
umount mnt || ( sleep 1 && sync && umount mnt )
rm -rf mnt
echo "done"
fi
if [ -e "${dev}" ]; then
printf "cleaning up loopback device... "
losetup -d "${dev}"
echo "done"
fi
}
trap cleanup EXIT
printf "creating partition table... "
if [ "$1" = "mbr" ]; then
parted -s "${dev}" mklabel msdos mkpart primary ext2 32k 100% -a minimal set 1 boot on || die "couldn't partition disk"
partition_number="p1"
partition_scheme="mbr"
elif [ "$1" = "gpt" ]; then
parted -s "${dev}" mklabel gpt mkpart BIOSBOOT ext3 1MiB 8MiB mkpart OS ext2 8MiB 700MiB set 1 bios_grub || die "couldn't partition disk"
partition_number="p2"
partition_scheme="gpt"
elif [ "$1" = "ebr" ]; then
parted -s "${dev}" mklabel msdos mkpart primary 32k 200MiB mkpart primary 200MiB 201MiB mkpart primary 201MiB 202MiB mkpart extended 250MiB 739MiB mkpart logical 372MiB 739MiB -a minimal set 1 boot on || die "couldn't partition disk"
partition_number="p5"
partition_scheme="ebr"
else
parted -s "${dev}" mklabel msdos mkpart primary ext2 32k 100% -a minimal set 1 boot on || die "couldn't partition disk"
partition_number="p1"
partition_scheme="mbr"
fi
echo "done"
printf "destroying old filesystem... "
dd if=/dev/zero of="${dev}${partition_number}" bs=1M count=1 status=none || die "couldn't destroy old filesystem"
echo "done"
printf "creating new filesystem... "
mke2fs -q -I 128 "${dev}${partition_number}" || die "couldn't create filesystem"
echo "done"
printf "mounting filesystem... "
mkdir -p mnt
mount "${dev}${partition_number}" mnt/ || die "couldn't mount filesystem"
echo "done"
./build-root-filesystem.sh
printf "creating /boot... "
mkdir -p mnt/boot
echo "done"
echo "installing grub using $grub..."
$grub --boot-directory=mnt/boot --target=i386-pc --modules="ext2 part_msdos" "${dev}"
if [ -d mnt/boot/grub2 ]; then
cp grub-"${partition_scheme}".cfg mnt/boot/grub2/grub.cfg
else
cp grub-"${partition_scheme}".cfg mnt/boot/grub/grub.cfg
fi
echo "done"
printf "installing kernel in /boot... "
cp kernel mnt/boot
echo "done"

View file

@ -1,87 +0,0 @@
#!/bin/sh
set -e
die() {
echo "die: $*"
exit 1
}
if [ "$(id -u)" != 0 ]; then
die "this script needs to run as root"
fi
if [ "$(uname -s)" = "Darwin" ]; then
export PATH="/usr/local/opt/e2fsprogs/bin:$PATH"
export PATH="/usr/local/opt/e2fsprogs/sbin:$PATH"
fi
echo "setting up disk image..."
qemu-img create _disk_image "${DISK_SIZE:-600}"m || die "could not create disk image"
chown "$SUDO_UID":"$SUDO_GID" _disk_image || die "could not adjust permissions on disk image"
echo "done"
printf "creating new filesystem... "
if [ "$(uname -s)" = "OpenBSD" ]; then
VND=$(vnconfig _disk_image)
(echo "e 0"; echo 83; echo n; echo 0; echo "*"; echo "quit") | fdisk -e "$VND"
mkfs.ext2 -I 128 -F "/dev/${VND}i" || die "could not create filesystem"
elif [ "$(uname -s)" = "FreeBSD" ]; then
MD=$(mdconfig _disk_image)
mke2fs -q -I 128 _disk_image || die "could not create filesystem"
else
if [ -x /sbin/mke2fs ]; then
/sbin/mke2fs -q -I 128 _disk_image || die "could not create filesystem"
else
mke2fs -q -I 128 _disk_image || die "could not create filesystem"
fi
fi
echo "done"
printf "mounting filesystem... "
mkdir -p mnt
use_genext2fs=0
if [ "$(uname -s)" = "Darwin" ]; then
fuse-ext2 _disk_image mnt -o rw+,allow_other,uid=501,gid=20 || die "could not mount filesystem"
elif [ "$(uname -s)" = "OpenBSD" ]; then
mount -t ext2fs "/dev/${VND}i" mnt/ || die "could not mount filesystem"
elif [ "$(uname -s)" = "FreeBSD" ]; then
fuse-ext2 -o rw+ "/dev/${MD}" mnt/ || die "could not mount filesystem"
else
if ! mount _disk_image mnt/ ; then
if command -v genext2fs 1>/dev/null ; then
echo "mount failed but genext2fs exists, use it instead"
use_genext2fs=1
else
die "could not mount filesystem and genext2fs is missing"
fi
fi
fi
echo "done"
cleanup() {
if [ -d mnt ]; then
if [ $use_genext2fs = 0 ] ; then
printf "unmounting filesystem... "
umount mnt || ( sleep 1 && sync && umount mnt )
fi
rm -rf mnt
if [ "$(uname -s)" = "OpenBSD" ]; then
vnconfig -u "$VND"
elif [ "$(uname -s)" = "FreeBSD" ]; then
mdconfig -d -u "$MD"
fi
echo "done"
fi
}
trap cleanup EXIT
./build-root-filesystem.sh
if [ $use_genext2fs = 1 ]; then
# regenerate new image, since genext2fs is unable to reuse the previously written image.
# genext2fs is very slow in generating big images, so I use a smaller image here. size can be updated
# if it's not enough.
# not using "-i 128" since it hangs. Serenity handles whatever default this uses instead.
genext2fs -b 250000 -d mnt _disk_image || die "try increasing image size (genext2fs -b)"
# if using docker with shared mount, file is created as root, so make it writable for users
chmod 0666 _disk_image
fi

View file

@ -1,228 +0,0 @@
#!/bin/sh
set -e
wheel_gid=1
tty_gid=2
phys_gid=3
audio_gid=4
window_uid=13
window_gid=13
die() {
echo "die: $*"
exit 1
}
if [ "$(id -u)" != 0 ]; then
die "this script needs to run as root"
fi
umask 0022
printf "creating initial filesystem structure... "
for dir in bin etc proc mnt tmp; do
mkdir -p mnt/$dir
done
chmod 1777 mnt/tmp
echo "done"
printf "setting up device nodes... "
mkdir -p mnt/dev
mkdir -p mnt/dev/pts
mknod mnt/dev/fb0 b 29 0
chmod 660 mnt/dev/fb0
chown 0:$phys_gid mnt/dev/fb0
mknod mnt/dev/tty0 c 4 0
mknod mnt/dev/tty1 c 4 1
mknod mnt/dev/tty2 c 4 2
mknod mnt/dev/tty3 c 4 3
mknod mnt/dev/ttyS0 c 4 64
mknod mnt/dev/ttyS1 c 4 65
mknod mnt/dev/ttyS2 c 4 66
mknod mnt/dev/ttyS3 c 4 67
for tty in 0 1 2 3 S0 S1 S2 S3; do
chmod 620 mnt/dev/tty$tty
chown 0:$tty_gid mnt/dev/tty$tty
done
mknod mnt/dev/random c 1 8
mknod mnt/dev/null c 1 3
mknod mnt/dev/zero c 1 5
mknod mnt/dev/full c 1 7
# random, is failing (randomly) on fuse-ext2 on macos :)
chmod 666 mnt/dev/random || true
chmod 666 mnt/dev/null
chmod 666 mnt/dev/zero
chmod 666 mnt/dev/full
mknod mnt/dev/keyboard c 85 1
chmod 440 mnt/dev/keyboard
chown 0:$phys_gid mnt/dev/keyboard
mknod mnt/dev/mouse c 10 1
chmod 440 mnt/dev/mouse
chown 0:$phys_gid mnt/dev/mouse
mknod mnt/dev/audio c 42 42
chmod 220 mnt/dev/audio
chown 0:$audio_gid mnt/dev/audio
mknod mnt/dev/ptmx c 5 2
chmod 666 mnt/dev/ptmx
mknod mnt/dev/hda b 3 0
mknod mnt/dev/hdb b 3 1
mknod mnt/dev/hdc b 4 0
mknod mnt/dev/hdd b 4 1
for hd in a b c d; do
chmod 600 mnt/dev/hd$hd
done
ln -s /proc/self/fd/0 mnt/dev/stdin
ln -s /proc/self/fd/1 mnt/dev/stdout
ln -s /proc/self/fd/2 mnt/dev/stderr
echo "done"
printf "installing base system... "
cp -R ../Base/* mnt/
cp -R ../Root/* mnt/
cp kernel.map mnt/res/
chmod 400 mnt/res/kernel.map
chmod 660 mnt/etc/WindowServer/WindowServer.ini
chown $window_uid:$window_gid mnt/etc/WindowServer/WindowServer.ini
echo "/bin/sh" > mnt/etc/shells
echo "done"
printf "installing users... "
mkdir -p mnt/root
mkdir -p mnt/home/anon
mkdir -p mnt/home/anon/Desktop
mkdir -p mnt/home/anon/Downloads
mkdir -p mnt/home/nona
cp ../ReadMe.md mnt/home/anon/
cp -r ../Libraries/LibJS/Tests mnt/home/anon/js-tests
chmod 700 mnt/root
chmod 700 mnt/home/anon
chmod 700 mnt/home/nona
chown -R 0:0 mnt/root
chown -R 100:100 mnt/home/anon
chown -R 200:200 mnt/home/nona
echo "done"
printf "installing userland... "
if [ "$(uname -s)" = "Darwin" ]; then
find ../Userland/ -type f -perm +111 -exec cp {} mnt/bin/ \;
elif [ "$(uname -s)" = "OpenBSD" ] || [ "$(uname -s)" = "FreeBSD" ]; then
find ../Userland/ -type f -perm -555 -exec cp {} mnt/bin/ \;
else
find ../Userland/ -type f -executable -exec cp {} mnt/bin/ \;
fi
chown 0:$wheel_gid mnt/bin/su
chown 0:$phys_gid mnt/bin/shutdown
chown 0:$phys_gid mnt/bin/reboot
chmod 4750 mnt/bin/su
chmod 4755 mnt/bin/ping
chmod 4750 mnt/bin/reboot
chmod 4750 mnt/bin/shutdown
echo "done"
printf "installing applications... "
cp ../Applications/About/About mnt/bin/About
cp ../Applications/FileManager/FileManager mnt/bin/FileManager
cp ../Applications/FontEditor/FontEditor mnt/bin/FontEditor
cp ../Applications/IRCClient/IRCClient mnt/bin/IRCClient
cp ../Applications/SystemMonitor/SystemMonitor mnt/bin/SystemMonitor
cp ../Applications/Terminal/Terminal mnt/bin/Terminal
cp ../Applications/TextEditor/TextEditor mnt/bin/TextEditor
cp ../Applications/HexEditor/HexEditor mnt/bin/HexEditor
cp ../Applications/PaintBrush/PaintBrush mnt/bin/PaintBrush
cp ../Applications/QuickShow/QuickShow mnt/bin/QuickShow
cp ../Applications/Piano/Piano mnt/bin/Piano
cp ../Applications/Calculator/Calculator mnt/bin/Calculator
cp ../Applications/Calendar/Calendar mnt/bin/Calendar
cp ../Applications/SoundPlayer/SoundPlayer mnt/bin/SoundPlayer
cp ../Applications/DisplaySettings/DisplaySettings mnt/bin/DisplaySettings
cp ../Applications/Welcome/Welcome mnt/bin/Welcome
cp ../Applications/Help/Help mnt/bin/Help
cp ../Applications/Browser/Browser mnt/bin/Browser
cp ../Applications/Debugger/Debugger mnt/bin/sdb
cp ../Games/Solitaire/Solitaire mnt/bin/Solitaire
cp ../Demos/HelloWorld/HelloWorld mnt/bin/HelloWorld
cp ../Demos/WidgetGallery/WidgetGallery mnt/bin/WidgetGallery
cp ../Demos/Cube/Cube mnt/bin/Cube
cp ../Demos/Screensaver/Screensaver mnt/bin/Screensaver
cp ../Demos/Fire/Fire mnt/bin/Fire
cp ../Demos/LibGfxDemo/LibGfxDemo mnt/bin/LibGfxDemo
cp ../Demos/Mouse/Mouse mnt/bin/Mouse
cp ../Demos/DynamicLink/LinkDemo/LinkDemo mnt/bin/LinkDemo
cp ../DevTools/HackStudio/HackStudio mnt/bin/HackStudio
cp ../DevTools/VisualBuilder/VisualBuilder mnt/bin/VisualBuilder
cp ../DevTools/Inspector/Inspector mnt/bin/Inspector
cp ../DevTools/ProfileViewer/ProfileViewer mnt/bin/ProfileViewer
cp ../Games/Minesweeper/Minesweeper mnt/bin/Minesweeper
cp ../Games/Snake/Snake mnt/bin/Snake
cp ../Services/DHCPClient/DHCPClient mnt/bin/DHCPClient
cp ../Services/LookupServer/LookupServer mnt/bin/LookupServer
cp ../Services/SystemServer/SystemServer mnt/bin/SystemServer
cp ../Services/WindowServer/WindowServer mnt/bin/WindowServer
cp ../Services/AudioServer/AudioServer mnt/bin/AudioServer
cp ../Services/TTYServer/TTYServer mnt/bin/TTYServer
cp ../Services/Taskbar/Taskbar mnt/bin/Taskbar
cp ../Services/TelnetServer/TelnetServer mnt/bin/TelnetServer
cp ../Services/ProtocolServer/ProtocolServer mnt/bin/ProtocolServer
cp ../Services/SystemMenu/SystemMenu mnt/bin/SystemMenu
cp ../Services/NotificationServer/NotificationServer mnt/bin/NotificationServer
cp ../Services/WebServer/WebServer mnt/bin/WebServer
cp ../Services/LaunchServer/LaunchServer mnt/bin/LaunchServer
cp ../Shell/Shell mnt/bin/Shell
cp ../MenuApplets/Audio/Audio.MenuApplet mnt/bin/
cp ../MenuApplets/ResourceGraph/ResourceGraph.MenuApplet mnt/bin/
cp ../MenuApplets/Clock/Clock.MenuApplet mnt/bin/
cp ../MenuApplets/UserName/UserName.MenuApplet mnt/bin
echo "done"
printf "installing dynamic libraries... "
cp ../Demos/DynamicLink/LinkLib/libDynamicLib.so mnt/usr/lib
echo "done"
printf "installing shortcuts... "
ln -s FileManager mnt/bin/fm
ln -s HelloWorld mnt/bin/hw
ln -s IRCClient mnt/bin/irc
ln -s Minesweeper mnt/bin/ms
ln -s Shell mnt/bin/sh
ln -s Snake mnt/bin/sn
ln -s Taskbar mnt/bin/tb
ln -s VisualBuilder mnt/bin/vb
ln -s WidgetGallery mnt/bin/wg
ln -s TextEditor mnt/bin/te
ln -s HexEditor mnt/bin/he
ln -s PaintBrush mnt/bin/pb
ln -s QuickShow mnt/bin/qs
ln -s Piano mnt/bin/pi
ln -s SystemDialog mnt/bin/sd
ln -s Calculator mnt/bin/calc
ln -s Calendar mnt/bin/calendar
ln -s Inspector mnt/bin/ins
ln -s SoundPlayer mnt/bin/sp
ln -s Help mnt/bin/help
ln -s Browser mnt/bin/br
ln -s HackStudio mnt/bin/hs
ln -s SystemMonitor mnt/bin/sm
ln -s ProfileViewer mnt/bin/pv
ln -s WebServer mnt/bin/ws
ln -s Solitaire mnt/bin/sl
echo "done"
mkdir -p mnt/boot/
chmod 700 mnt/boot/
cp kernel mnt/boot/
chmod 600 mnt/boot/kernel
mkdir -p mnt/mod/
chmod 700 mnt/mod/
cp TestModule.kernel.o mnt/mod/TestModule.o
chmod 600 mnt/mod/*.o
# Run local sync script, if it exists
if [ -f sync-local.sh ]; then
sh sync-local.sh
fi

View file

@ -1,14 +0,0 @@
#!/bin/sh
# Set this environment variable to override the default debugger.
#
[ -z "$SERENITY_KERNEL_DEBUGGER" ] && SERENITY_KERNEL_DEBUGGER="gdb"
# The QEMU -s option (enabled by default in ./run) sets up a debugger
# remote on localhost:1234. So point our debugger there, and inform
# the debugger which binary to load symbols, etc from.
#
$SERENITY_KERNEL_DEBUGGER \
-ex "file $(pwd)/kernel" \
-ex 'set arch i386:intel' \
-ex 'target remote localhost:1234'

View file

@ -1,17 +0,0 @@
timeout=1
menuentry 'SerenityOS (normal)' {
root=hd0,5
multiboot /boot/kernel root=/dev/hda5
}
menuentry 'SerenityOS (No ACPI)' {
root=hd0,5
multiboot /boot/kernel root=/dev/hda5 acpi=off
}
menuentry 'SerenityOS (with serial debug)' {
root=hd0,5
multiboot /boot/kernel serial_debug root=/dev/hda5
}

View file

@ -1,16 +0,0 @@
timeout=1
menuentry 'SerenityOS (normal)' {
root=hd0,2
multiboot /boot/kernel root=/dev/hda2
}
menuentry 'SerenityOS (No ACPI)' {
root=hd0,2
multiboot /boot/kernel root=/dev/hda2 acpi=off
}
menuentry 'SerenityOS (with serial debug)' {
root=hd0,2
multiboot /boot/kernel serial_debug root=/dev/hda2
}

View file

@ -1,16 +0,0 @@
timeout=1
menuentry 'SerenityOS (normal)' {
root=hd0,1
multiboot /boot/kernel root=/dev/hda1
}
menuentry 'SerenityOS (No ACPI)' {
root=hd0,1
multiboot /boot/kernel root=/dev/hda1 acpi=off
}
menuentry 'SerenityOS (with serial debug)' {
root=hd0,1
multiboot /boot/kernel serial_debug root=/dev/hda1
}

View file

@ -8,7 +8,7 @@ SECTIONS
.text ALIGN(4K) : AT (ADDR(.text) - 0xc0000000)
{
Arch/i386/Boot/boot.ao
$<TARGET_OBJECTS:boot>
*(.multiboot)
start_of_kernel_text = .;
*(.text)

View file

@ -1,37 +0,0 @@
#!/bin/sh
set -e
script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
cd "$script_path"
fast_mode=
while [ "$1" != "" ]; do
case $1 in
-f | --fast ) fast_mode=1
;;
-h | --help ) printf -- "-f or --fast: build fast without cleaning or running tests\n"
exit 0
;;
esac
shift
done
sudo id
MAKE="make"
if [ "$(uname -s)" = "OpenBSD" ] || [ "$(uname -s)" = "FreeBSD" ]; then
MAKE="gmake"
fi
if [ "$fast_mode" = "1" ]; then
$MAKE -C ../ && \
$MAKE -C ../ install &&
sudo -E PATH="$PATH" ./build-image-qemu.sh
else
$MAKE -C ../ clean && \
$MAKE -C ../ && \
$MAKE -C ../ test && \
$MAKE -C ../ install &&
sudo -E PATH="$PATH" ./build-image-qemu.sh
fi

View file

@ -1,6 +1,6 @@
#!/bin/sh
tmp=$(mktemp)
nm -n kernel | awk '{ if ($2 != "a") print; }' | uniq > "$tmp"
nm -n Kernel | awk '{ if ($2 != "a") print; }' | uniq > "$tmp"
printf "%08x\n" "$(wc -l "$tmp" | cut -f1 -d' ')" > kernel.map
cat "$tmp" >> kernel.map
rm -f "$tmp"

View file

@ -1,123 +0,0 @@
#!/bin/sh
# shellcheck disable=SC2086 # FIXME: fix these globing warnings
set -e
script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
cd "$script_path"
#SERENITY_PACKET_LOGGING_ARG="-object filter-dump,id=hue,netdev=breh,file=e1000.pcap"
[ -e /dev/kvm ] && [ -r /dev/kvm ] && [ -w /dev/kvm ] && SERENITY_KVM_ARG="-enable-kvm"
[ -z "$SERENITY_BOCHS_BIN" ] && SERENITY_BOCHS_BIN="bochs"
[ -z "$SERENITY_QEMU_BIN" ] && SERENITY_QEMU_BIN="qemu-system-i386"
[ -z "$SERENITY_KERNEL_CMDLINE" ] && SERENITY_KERNEL_CMDLINE="hello"
[ -z "$SERENITY_RAM_SIZE" ] && SERENITY_RAM_SIZE=256M
[ -z "$SERENITY_COMMON_QEMU_ARGS" ] && SERENITY_COMMON_QEMU_ARGS="
$SERENITY_EXTRA_QEMU_ARGS
-s -m $SERENITY_RAM_SIZE
-cpu max
-d cpu_reset,guest_errors
-smp 2
-device VGA,vgamem_mb=64
-hda _disk_image
-device ich9-ahci
-debugcon stdio
-soundhw pcspk
-soundhw sb16
"
[ -z "$SERENITY_COMMON_QEMU_Q35_ARGS" ] && SERENITY_COMMON_QEMU_Q35_ARGS="
$SERENITY_EXTRA_QEMU_ARGS
-s -m $SERENITY_RAM_SIZE
-cpu max
-machine q35
-d cpu_reset,guest_errors
-smp 2
-device VGA,vgamem_mb=64
-device piix3-ide
-drive file=_disk_image,id=disk,if=none
-device ide-hd,bus=ide.6,drive=disk,unit=0
-debugcon stdio
-soundhw pcspk
-soundhw sb16
"
export SDL_VIDEO_X11_DGAMOUSE=0
if [ "$1" = "b" ]; then
# ./run b: bochs
$SERENITY_BOCHS_BIN -q -f .bochsrc
elif [ "$1" = "qn" ]; then
# ./run qn: qemu without network
$SERENITY_QEMU_BIN \
$SERENITY_COMMON_QEMU_ARGS \
-device e1000 \
-kernel kernel \
-append "${SERENITY_KERNEL_CMDLINE}"
elif [ "$1" = "qtap" ]; then
# ./run qtap: qemu with tap
sudo $SERENITY_QEMU_BIN \
$SERENITY_COMMON_QEMU_ARGS \
$SERENITY_KVM_ARG \
$SERENITY_PACKET_LOGGING_ARG \
-netdev tap,ifname=tap0,id=br0 \
-device e1000,netdev=br0 \
-kernel kernel \
-append "${SERENITY_KERNEL_CMDLINE}"
elif [ "$1" = "qgrub" ]; then
# ./run qgrub: qemu with grub
$SERENITY_QEMU_BIN \
$SERENITY_COMMON_QEMU_ARGS \
$SERENITY_KVM_ARG \
$SERENITY_PACKET_LOGGING_ARG \
-netdev user,id=breh,hostfwd=tcp:127.0.0.1:8888-10.0.2.15:8888,hostfwd=tcp:127.0.0.1:8823-10.0.2.15:23 \
-device e1000,netdev=breh
elif [ "$1" = "q35_cmd" ]; then
SERENITY_KERNEL_CMDLINE=""
# FIXME: Someone who knows sh syntax better, please help:
for _ in $(seq 2 $#); do
shift
SERENITY_KERNEL_CMDLINE="$SERENITY_KERNEL_CMDLINE $1"
done
echo "Starting SerenityOS, Commandline: ${SERENITY_KERNEL_CMDLINE}"
# ./run: qemu with SerenityOS with custom commandline
$SERENITY_QEMU_BIN \
$SERENITY_COMMON_QEMU_Q35_ARGS \
$SERENITY_KVM_ARG \
-netdev user,id=breh,hostfwd=tcp:127.0.0.1:8888-10.0.2.15:8888,hostfwd=tcp:127.0.0.1:8823-10.0.2.15:23 \
-device e1000,netdev=breh \
-kernel kernel \
-append "${SERENITY_KERNEL_CMDLINE}"
elif [ "$1" = "qcmd" ]; then
SERENITY_KERNEL_CMDLINE=""
# FIXME: Someone who knows sh syntax better, please help:
for _ in $(seq 2 $#); do
shift
SERENITY_KERNEL_CMDLINE="$SERENITY_KERNEL_CMDLINE $1"
done
echo "Starting SerenityOS, Commandline: ${SERENITY_KERNEL_CMDLINE}"
# ./run: qemu with SerenityOS with custom commandline
$SERENITY_QEMU_BIN \
$SERENITY_COMMON_QEMU_ARGS \
$SERENITY_KVM_ARG \
-netdev user,id=breh,hostfwd=tcp:127.0.0.1:8888-10.0.2.15:8888,hostfwd=tcp:127.0.0.1:8823-10.0.2.15:23 \
-device e1000,netdev=breh \
-kernel kernel \
-append "${SERENITY_KERNEL_CMDLINE}"
else
# ./run: qemu with user networking
$SERENITY_QEMU_BIN \
$SERENITY_COMMON_QEMU_ARGS \
$SERENITY_KVM_ARG \
$SERENITY_PACKET_LOGGING_ARG \
-netdev user,id=breh,hostfwd=tcp:127.0.0.1:8888-10.0.2.15:8888,hostfwd=tcp:127.0.0.1:8823-10.0.2.15:23,hostfwd=tcp:127.0.0.1:8000-10.0.2.15:8000,hostfwd=tcp:127.0.0.1:2222-10.0.2.15:22 \
-device e1000,netdev=breh \
-kernel kernel \
-append "${SERENITY_KERNEL_CMDLINE}"
fi

View file

@ -1,7 +0,0 @@
#!/bin/sh
set -e
script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
cd "$script_path"
sudo -E PATH="$PATH" ./build-image-qemu.sh