2021-05-23 23:20:22 +03:00
|
|
|
if (ENABLE_EXTRA_KERNEL_DEBUG_SYMBOLS)
|
|
|
|
add_compile_options(-Og)
|
|
|
|
add_compile_options(-ggdb3)
|
|
|
|
else()
|
2021-12-14 11:42:26 +03:00
|
|
|
add_compile_options(-O2)
|
2021-05-23 23:20:22 +03:00
|
|
|
endif()
|
2021-02-24 13:30:19 +03:00
|
|
|
|
2021-08-27 22:23:43 +03:00
|
|
|
if ("${SERENITY_ARCH}" STREQUAL "aarch64")
|
|
|
|
set(KERNEL_ARCH aarch64)
|
|
|
|
elseif ("${SERENITY_ARCH}" STREQUAL "i686")
|
2021-03-04 19:50:05 +03:00
|
|
|
set(KERNEL_ARCH i386)
|
|
|
|
elseif("${SERENITY_ARCH}" STREQUAL "x86_64")
|
|
|
|
set(KERNEL_ARCH x86_64)
|
|
|
|
endif()
|
|
|
|
|
2020-08-10 18:44:35 +03:00
|
|
|
set(KERNEL_HEAP_SOURCES
|
|
|
|
Heap/kmalloc.cpp
|
|
|
|
)
|
|
|
|
|
2020-05-06 18:40:06 +03:00
|
|
|
set(KERNEL_SOURCES
|
2021-02-14 23:47:10 +03:00
|
|
|
AddressSanitizer.cpp
|
2022-01-07 15:10:44 +03:00
|
|
|
Bus/PCI/Controller/HostBridge.cpp
|
|
|
|
Bus/PCI/Controller/MemoryBackedHostBridge.cpp
|
2022-01-15 10:17:07 +03:00
|
|
|
Bus/PCI/Controller/VolumeManagementDevice.cpp
|
2021-06-25 09:46:17 +03:00
|
|
|
Bus/PCI/Access.cpp
|
Kernel/PCI: Simplify the entire subsystem
A couple of things were changed:
1. Semantic changes - PCI segments are now called PCI domains, to better
match what they are really. It's also the name that Linux gave, and it
seems that Wikipedia also uses this name.
We also remove PCI::ChangeableAddress, because it was used in the past
but now it's no longer being used.
2. There are no WindowedMMIOAccess or MMIOAccess classes anymore, as
they made a bunch of unnecessary complexity. Instead, Windowed access is
removed entirely (this was tested, but never was benchmarked), so we are
left with IO access and memory access options. The memory access option
is essentially mapping the PCI bus (from the chosen PCI domain), to
virtual memory as-is. This means that unless needed, at any time, there
is only one PCI bus being mapped, and this is changed if access to
another PCI bus in the same PCI domain is needed. For now, we don't
support mapping of different PCI buses from different PCI domains at the
same time, because basically it's still a non-issue for most machines
out there.
2. OOM-safety is increased, especially when constructing the Access
object. It means that we pre-allocating any needed resources, and we try
to find PCI domains (if requested to initialize memory access) after we
attempt to construct the Access object, so it's possible to fail at this
point "gracefully".
3. All PCI API functions are now separated into a different header file,
which means only "clients" of the PCI subsystem API will need to include
that header file.
4. Functional changes - we only allow now to enumerate the bus after
a hardware scan. This means that the old method "enumerate_hardware"
is removed, so, when initializing an Access object, the initializing
function must call rescan on it to force it to find devices. This makes
it possible to fail rescan, and also to defer it after construction from
both OOM-safety terms and hotplug capabilities.
2021-09-07 12:08:38 +03:00
|
|
|
Bus/PCI/API.cpp
|
2021-08-21 06:58:43 +03:00
|
|
|
Bus/PCI/Device.cpp
|
2021-06-25 09:46:17 +03:00
|
|
|
Bus/PCI/Initializer.cpp
|
Kernel/PCI: Simplify the entire subsystem
A couple of things were changed:
1. Semantic changes - PCI segments are now called PCI domains, to better
match what they are really. It's also the name that Linux gave, and it
seems that Wikipedia also uses this name.
We also remove PCI::ChangeableAddress, because it was used in the past
but now it's no longer being used.
2. There are no WindowedMMIOAccess or MMIOAccess classes anymore, as
they made a bunch of unnecessary complexity. Instead, Windowed access is
removed entirely (this was tested, but never was benchmarked), so we are
left with IO access and memory access options. The memory access option
is essentially mapping the PCI bus (from the chosen PCI domain), to
virtual memory as-is. This means that unless needed, at any time, there
is only one PCI bus being mapped, and this is changed if access to
another PCI bus in the same PCI domain is needed. For now, we don't
support mapping of different PCI buses from different PCI domains at the
same time, because basically it's still a non-issue for most machines
out there.
2. OOM-safety is increased, especially when constructing the Access
object. It means that we pre-allocating any needed resources, and we try
to find PCI domains (if requested to initialize memory access) after we
attempt to construct the Access object, so it's possible to fail at this
point "gracefully".
3. All PCI API functions are now separated into a different header file,
which means only "clients" of the PCI subsystem API will need to include
that header file.
4. Functional changes - we only allow now to enumerate the bus after
a hardware scan. This means that the old method "enumerate_hardware"
is removed, so, when initializing an Access object, the initializing
function must call rescan on it to force it to find devices. This makes
it possible to fail rescan, and also to defer it after construction from
both OOM-safety terms and hotplug capabilities.
2021-09-07 12:08:38 +03:00
|
|
|
Bus/PCI/SysFSPCI.cpp
|
2021-08-14 06:31:00 +03:00
|
|
|
Bus/USB/SysFSUSB.cpp
|
2021-08-13 09:10:43 +03:00
|
|
|
Bus/USB/UHCI/UHCIController.cpp
|
|
|
|
Bus/USB/UHCI/UHCIRootHub.cpp
|
2021-08-08 21:50:20 +03:00
|
|
|
Bus/USB/USBController.cpp
|
2021-06-25 09:51:22 +03:00
|
|
|
Bus/USB/USBDevice.cpp
|
2021-08-13 22:47:13 +03:00
|
|
|
Bus/USB/USBHub.cpp
|
2021-08-08 21:50:20 +03:00
|
|
|
Bus/USB/USBManagement.cpp
|
2021-06-25 09:51:22 +03:00
|
|
|
Bus/USB/USBPipe.cpp
|
|
|
|
Bus/USB/USBTransfer.cpp
|
2021-08-27 12:24:50 +03:00
|
|
|
Bus/VirtIO/Console.cpp
|
|
|
|
Bus/VirtIO/ConsolePort.cpp
|
|
|
|
Bus/VirtIO/Device.cpp
|
|
|
|
Bus/VirtIO/Queue.cpp
|
|
|
|
Bus/VirtIO/RNG.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
CMOS.cpp
|
|
|
|
CommandLine.cpp
|
2021-08-22 15:51:04 +03:00
|
|
|
Coredump.cpp
|
2020-11-02 21:16:01 +03:00
|
|
|
Devices/AsyncDeviceRequest.cpp
|
2021-11-23 03:13:02 +03:00
|
|
|
Devices/Audio/AC97.cpp
|
2022-02-11 22:47:45 +03:00
|
|
|
Devices/Audio/Channel.cpp
|
|
|
|
Devices/Audio/Management.cpp
|
2020-05-16 13:00:04 +03:00
|
|
|
Devices/BlockDevice.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
Devices/CharacterDevice.cpp
|
2021-09-12 21:37:31 +03:00
|
|
|
Devices/ConsoleDevice.cpp
|
2021-01-01 13:20:55 +03:00
|
|
|
Devices/Device.cpp
|
2021-12-20 12:10:35 +03:00
|
|
|
Devices/DeviceControlDevice.cpp
|
2021-09-11 09:19:20 +03:00
|
|
|
Devices/DeviceManagement.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
Devices/FullDevice.cpp
|
2021-06-07 02:15:07 +03:00
|
|
|
Devices/KCOVDevice.cpp
|
|
|
|
Devices/KCOVInstance.cpp
|
2021-01-29 15:03:25 +03:00
|
|
|
Devices/MemoryDevice.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
Devices/NullDevice.cpp
|
2021-04-23 17:26:52 +03:00
|
|
|
Devices/PCISerialDevice.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
Devices/PCSpeaker.cpp
|
|
|
|
Devices/RandomDevice.cpp
|
2022-02-15 22:24:31 +03:00
|
|
|
Devices/SelfTTYDevice.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
Devices/SerialDevice.cpp
|
|
|
|
Devices/VMWareBackdoor.cpp
|
|
|
|
Devices/ZeroDevice.cpp
|
2021-04-02 23:21:35 +03:00
|
|
|
Devices/HID/I8042Controller.cpp
|
|
|
|
Devices/HID/HIDManagement.cpp
|
|
|
|
Devices/HID/KeyboardDevice.cpp
|
|
|
|
Devices/HID/MouseDevice.cpp
|
|
|
|
Devices/HID/PS2KeyboardDevice.cpp
|
|
|
|
Devices/HID/PS2MouseDevice.cpp
|
|
|
|
Devices/HID/VMWareMouseDevice.cpp
|
2021-06-23 00:24:25 +03:00
|
|
|
GlobalProcessExposed.cpp
|
2021-07-09 10:27:19 +03:00
|
|
|
Graphics/Bochs/GraphicsAdapter.cpp
|
2022-01-29 06:42:23 +03:00
|
|
|
Graphics/Console/BootFramebufferConsole.cpp
|
2021-06-12 15:30:05 +03:00
|
|
|
Graphics/Console/GenericFramebufferConsole.cpp
|
|
|
|
Graphics/Console/ContiguousFramebufferConsole.cpp
|
2021-04-16 22:58:51 +03:00
|
|
|
Graphics/Console/TextModeConsole.cpp
|
|
|
|
Graphics/Console/VGAConsole.cpp
|
2021-03-05 15:23:08 +03:00
|
|
|
Graphics/FramebufferDevice.cpp
|
|
|
|
Graphics/GraphicsManagement.cpp
|
2021-07-08 20:30:13 +03:00
|
|
|
Graphics/Intel/NativeGraphicsAdapter.cpp
|
2022-01-21 17:15:46 +03:00
|
|
|
Graphics/VGA/ISAAdapter.cpp
|
|
|
|
Graphics/VGA/PCIAdapter.cpp
|
2021-09-21 08:51:36 +03:00
|
|
|
Graphics/VirtIOGPU/FramebufferDevice.cpp
|
2021-07-07 16:51:33 +03:00
|
|
|
Graphics/VirtIOGPU/Console.cpp
|
2022-02-13 08:45:30 +03:00
|
|
|
Graphics/VirtIOGPU/GPU3DDevice.cpp
|
2021-07-07 16:51:33 +03:00
|
|
|
Graphics/VirtIOGPU/GraphicsAdapter.cpp
|
2021-09-22 17:13:12 +03:00
|
|
|
Graphics/GenericFramebufferDevice.cpp
|
2021-06-07 02:15:07 +03:00
|
|
|
SanCov.cpp
|
2021-11-13 11:19:31 +03:00
|
|
|
Storage/ATA/AHCIController.cpp
|
|
|
|
Storage/ATA/AHCIPort.cpp
|
|
|
|
Storage/ATA/AHCIPortHandler.cpp
|
|
|
|
Storage/ATA/ATADevice.cpp
|
|
|
|
Storage/ATA/ATADiskDevice.cpp
|
|
|
|
Storage/ATA/ATAPIDiscDevice.cpp
|
|
|
|
Storage/ATA/BMIDEChannel.cpp
|
2022-01-21 17:18:31 +03:00
|
|
|
Storage/ATA/ISAIDEController.cpp
|
|
|
|
Storage/ATA/PCIIDEController.cpp
|
2021-11-13 11:19:31 +03:00
|
|
|
Storage/ATA/IDEController.cpp
|
|
|
|
Storage/ATA/IDEChannel.cpp
|
2020-12-25 21:23:35 +03:00
|
|
|
Storage/Partition/DiskPartition.cpp
|
2020-12-25 23:48:29 +03:00
|
|
|
Storage/Partition/DiskPartitionMetadata.cpp
|
2020-12-25 21:23:35 +03:00
|
|
|
Storage/Partition/EBRPartitionTable.cpp
|
2020-12-26 17:53:30 +03:00
|
|
|
Storage/Partition/GUIDPartitionTable.cpp
|
2020-12-25 21:23:35 +03:00
|
|
|
Storage/Partition/MBRPartitionTable.cpp
|
2020-12-26 17:53:30 +03:00
|
|
|
Storage/Partition/PartitionTable.cpp
|
2021-12-16 18:07:54 +03:00
|
|
|
Storage/NVMe/NVMeController.cpp
|
|
|
|
Storage/NVMe/NVMeNameSpace.cpp
|
2022-01-27 14:14:58 +03:00
|
|
|
Storage/NVMe/NVMeInterruptQueue.cpp
|
|
|
|
Storage/NVMe/NVMePollQueue.cpp
|
2021-12-16 18:07:54 +03:00
|
|
|
Storage/NVMe/NVMeQueue.cpp
|
2022-03-19 12:55:55 +03:00
|
|
|
Storage/Ramdisk/Controller.cpp
|
|
|
|
Storage/Ramdisk/Device.cpp
|
2020-12-19 13:50:57 +03:00
|
|
|
Storage/StorageDevice.cpp
|
2020-12-19 16:25:06 +03:00
|
|
|
Storage/StorageManagement.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
DoubleBuffer.cpp
|
2021-01-15 13:28:07 +03:00
|
|
|
FileSystem/AnonymousFile.cpp
|
2020-07-02 12:48:08 +03:00
|
|
|
FileSystem/BlockBasedFileSystem.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
FileSystem/Custody.cpp
|
|
|
|
FileSystem/DevPtsFS.cpp
|
2021-08-14 16:28:09 +03:00
|
|
|
FileSystem/DevTmpFS.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
FileSystem/Ext2FileSystem.cpp
|
|
|
|
FileSystem/FIFO.cpp
|
|
|
|
FileSystem/File.cpp
|
2020-05-16 13:00:04 +03:00
|
|
|
FileSystem/FileBackedFileSystem.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
FileSystem/FileSystem.cpp
|
|
|
|
FileSystem/Inode.cpp
|
|
|
|
FileSystem/InodeFile.cpp
|
|
|
|
FileSystem/InodeWatcher.cpp
|
2021-07-29 23:19:12 +03:00
|
|
|
FileSystem/ISO9660FileSystem.cpp
|
2021-07-11 01:46:06 +03:00
|
|
|
FileSystem/Mount.cpp
|
2021-09-07 14:39:11 +03:00
|
|
|
FileSystem/OpenFileDescription.cpp
|
2020-07-02 13:05:56 +03:00
|
|
|
FileSystem/Plan9FileSystem.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
FileSystem/ProcFS.cpp
|
2021-03-13 13:01:44 +03:00
|
|
|
FileSystem/SysFS.cpp
|
2021-07-11 02:14:53 +03:00
|
|
|
FileSystem/SysFSComponent.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
FileSystem/TmpFS.cpp
|
|
|
|
FileSystem/VirtualFileSystem.cpp
|
2021-09-11 10:39:47 +03:00
|
|
|
Firmware/ACPI/Initialize.cpp
|
|
|
|
Firmware/ACPI/Parser.cpp
|
2021-12-23 18:51:11 +03:00
|
|
|
Firmware/MultiProcessor/Parser.cpp
|
2021-09-11 10:39:47 +03:00
|
|
|
Firmware/BIOS.cpp
|
2021-09-11 12:20:47 +03:00
|
|
|
Firmware/PowerStateSwitch.cpp
|
2021-09-11 11:19:33 +03:00
|
|
|
Firmware/SysFSFirmware.cpp
|
2020-12-22 09:21:58 +03:00
|
|
|
FutexQueue.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
Interrupts/APIC.cpp
|
|
|
|
Interrupts/GenericInterruptHandler.cpp
|
|
|
|
Interrupts/IOAPIC.cpp
|
|
|
|
Interrupts/IRQHandler.cpp
|
2020-05-16 13:00:04 +03:00
|
|
|
Interrupts/InterruptManagement.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
Interrupts/PIC.cpp
|
|
|
|
Interrupts/SharedIRQHandler.cpp
|
|
|
|
Interrupts/SpuriousInterruptHandler.cpp
|
|
|
|
Interrupts/UnhandledInterruptHandler.cpp
|
|
|
|
KBufferBuilder.cpp
|
2021-07-06 12:16:17 +03:00
|
|
|
KLexicalPath.cpp
|
2021-05-28 10:25:02 +03:00
|
|
|
KString.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
KSyms.cpp
|
2021-08-06 14:57:39 +03:00
|
|
|
Memory/AddressSpace.cpp
|
2021-08-06 11:45:34 +03:00
|
|
|
Memory/AnonymousVMObject.cpp
|
|
|
|
Memory/InodeVMObject.cpp
|
|
|
|
Memory/MemoryManager.cpp
|
|
|
|
Memory/PageDirectory.cpp
|
|
|
|
Memory/PhysicalPage.cpp
|
|
|
|
Memory/PhysicalRegion.cpp
|
|
|
|
Memory/PhysicalZone.cpp
|
|
|
|
Memory/PrivateInodeVMObject.cpp
|
|
|
|
Memory/Region.cpp
|
|
|
|
Memory/RingBuffer.cpp
|
|
|
|
Memory/ScatterGatherList.cpp
|
2022-01-10 21:01:01 +03:00
|
|
|
Memory/ScopedAddressSpaceSwitcher.cpp
|
2021-08-06 11:45:34 +03:00
|
|
|
Memory/SharedInodeVMObject.cpp
|
|
|
|
Memory/VMObject.cpp
|
2021-08-06 14:54:48 +03:00
|
|
|
Memory/VirtualRange.cpp
|
|
|
|
Memory/VirtualRangeAllocator.cpp
|
2021-07-18 15:47:32 +03:00
|
|
|
MiniStdLib.cpp
|
2021-09-07 12:40:31 +03:00
|
|
|
Locking/LockRank.cpp
|
2021-07-18 10:10:27 +03:00
|
|
|
Locking/Mutex.cpp
|
2021-12-25 11:58:04 +03:00
|
|
|
Net/Intel/E1000ENetworkAdapter.cpp
|
|
|
|
Net/Intel/E1000NetworkAdapter.cpp
|
2021-12-25 12:06:12 +03:00
|
|
|
Net/NE2000/NetworkAdapter.cpp
|
2021-12-25 12:09:34 +03:00
|
|
|
Net/Realtek/RTL8139NetworkAdapter.cpp
|
|
|
|
Net/Realtek/RTL8168NetworkAdapter.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
Net/IPv4Socket.cpp
|
|
|
|
Net/LocalSocket.cpp
|
|
|
|
Net/LoopbackAdapter.cpp
|
|
|
|
Net/NetworkAdapter.cpp
|
|
|
|
Net/NetworkTask.cpp
|
2021-08-06 11:45:34 +03:00
|
|
|
Net/NetworkingManagement.cpp
|
2020-05-16 13:00:04 +03:00
|
|
|
Net/Routing.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
Net/Socket.cpp
|
|
|
|
Net/TCPSocket.cpp
|
|
|
|
Net/UDPSocket.cpp
|
2021-02-14 11:01:52 +03:00
|
|
|
Panic.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
PerformanceEventBuffer.cpp
|
|
|
|
Process.cpp
|
Kernel: Introduce the new ProcFS design
The new ProcFS design consists of two main parts:
1. The representative ProcFS class, which is derived from the FS class.
The ProcFS and its inodes are much more lean - merely 3 classes to
represent the common type of inodes - regular files, symbolic links and
directories. They're backed by a ProcFSExposedComponent object, which
is responsible for the functional operation behind the scenes.
2. The backend of the ProcFS - the ProcFSComponentsRegistrar class
and all derived classes from the ProcFSExposedComponent class. These
together form the entire backend and handle all the functions you can
expect from the ProcFS.
The ProcFSExposedComponent derived classes split to 3 types in the
manner of lifetime in the kernel:
1. Persistent objects - this category includes all basic objects, like
the root folder, /proc/bus folder, main blob files in the root folders,
etc. These objects are persistent and cannot die ever.
2. Semi-persistent objects - this category includes all PID folders,
and subdirectories to the PID folders. It also includes exposed objects
like the unveil JSON'ed blob. These object are persistent as long as the
the responsible process they represent is still alive.
3. Dynamic objects - this category includes files in the subdirectories
of a PID folder, like /proc/PID/fd/* or /proc/PID/stacks/*. Essentially,
these objects are always created dynamically and when no longer in need
after being used, they're deallocated.
Nevertheless, the new allocated backend objects and inodes try to use
the same InodeIndex if possible - this might change only when a thread
dies and a new thread is born with a new thread stack, or when a file
descriptor is closed and a new one within the same file descriptor
number is opened. This is needed to actually be able to do something
useful with these objects.
The new design assures that many ProcFS instances can be used at once,
with one backend for usage for all instances.
2021-06-12 04:23:58 +03:00
|
|
|
ProcessExposed.cpp
|
2021-06-23 00:24:25 +03:00
|
|
|
ProcessSpecificExposed.cpp
|
2020-08-15 22:13:19 +03:00
|
|
|
ProcessGroup.cpp
|
2021-08-14 15:43:34 +03:00
|
|
|
ProcessProcFSTraits.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
RTC.cpp
|
2020-05-16 13:00:04 +03:00
|
|
|
Random.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
Scheduler.cpp
|
2020-05-16 13:00:04 +03:00
|
|
|
StdLib.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
Syscall.cpp
|
2021-01-15 13:28:07 +03:00
|
|
|
Syscalls/anon_create.cpp
|
2020-07-31 00:38:15 +03:00
|
|
|
Syscalls/access.cpp
|
|
|
|
Syscalls/alarm.cpp
|
|
|
|
Syscalls/beep.cpp
|
|
|
|
Syscalls/chdir.cpp
|
|
|
|
Syscalls/chmod.cpp
|
|
|
|
Syscalls/chown.cpp
|
|
|
|
Syscalls/clock.cpp
|
|
|
|
Syscalls/debug.cpp
|
2020-08-04 14:51:11 +03:00
|
|
|
Syscalls/disown.cpp
|
2020-08-15 11:54:00 +03:00
|
|
|
Syscalls/dup2.cpp
|
2021-03-09 10:16:00 +03:00
|
|
|
Syscalls/emuctl.cpp
|
2020-07-31 00:38:15 +03:00
|
|
|
Syscalls/execve.cpp
|
|
|
|
Syscalls/exit.cpp
|
|
|
|
Syscalls/fcntl.cpp
|
|
|
|
Syscalls/fork.cpp
|
2021-09-12 06:28:59 +03:00
|
|
|
Syscalls/fsync.cpp
|
2020-07-31 00:38:15 +03:00
|
|
|
Syscalls/ftruncate.cpp
|
|
|
|
Syscalls/futex.cpp
|
|
|
|
Syscalls/get_dir_entries.cpp
|
|
|
|
Syscalls/get_stack_bounds.cpp
|
|
|
|
Syscalls/getrandom.cpp
|
|
|
|
Syscalls/getuid.cpp
|
|
|
|
Syscalls/hostname.cpp
|
|
|
|
Syscalls/ioctl.cpp
|
2021-01-30 23:35:54 +03:00
|
|
|
Syscalls/keymap.cpp
|
2020-07-31 00:38:15 +03:00
|
|
|
Syscalls/kill.cpp
|
|
|
|
Syscalls/link.cpp
|
|
|
|
Syscalls/lseek.cpp
|
|
|
|
Syscalls/mkdir.cpp
|
|
|
|
Syscalls/mknod.cpp
|
|
|
|
Syscalls/mmap.cpp
|
|
|
|
Syscalls/mount.cpp
|
|
|
|
Syscalls/open.cpp
|
|
|
|
Syscalls/perf_event.cpp
|
|
|
|
Syscalls/pipe.cpp
|
|
|
|
Syscalls/pledge.cpp
|
2021-12-12 12:44:37 +03:00
|
|
|
Syscalls/poll.cpp
|
2020-12-25 20:27:42 +03:00
|
|
|
Syscalls/prctl.cpp
|
2020-07-31 00:38:15 +03:00
|
|
|
Syscalls/process.cpp
|
|
|
|
Syscalls/profiling.cpp
|
|
|
|
Syscalls/ptrace.cpp
|
|
|
|
Syscalls/purge.cpp
|
|
|
|
Syscalls/read.cpp
|
|
|
|
Syscalls/readlink.cpp
|
|
|
|
Syscalls/realpath.cpp
|
|
|
|
Syscalls/rename.cpp
|
2022-02-01 00:09:30 +03:00
|
|
|
Syscalls/resource.cpp
|
2020-07-31 00:38:15 +03:00
|
|
|
Syscalls/rmdir.cpp
|
|
|
|
Syscalls/sched.cpp
|
|
|
|
Syscalls/sendfd.cpp
|
|
|
|
Syscalls/setpgid.cpp
|
|
|
|
Syscalls/setuid.cpp
|
|
|
|
Syscalls/sigaction.cpp
|
|
|
|
Syscalls/socket.cpp
|
|
|
|
Syscalls/stat.cpp
|
2021-05-19 12:31:43 +03:00
|
|
|
Syscalls/statvfs.cpp
|
2020-07-31 00:38:15 +03:00
|
|
|
Syscalls/sync.cpp
|
|
|
|
Syscalls/sysconf.cpp
|
|
|
|
Syscalls/thread.cpp
|
|
|
|
Syscalls/times.cpp
|
|
|
|
Syscalls/umask.cpp
|
|
|
|
Syscalls/uname.cpp
|
|
|
|
Syscalls/unlink.cpp
|
|
|
|
Syscalls/unveil.cpp
|
|
|
|
Syscalls/utime.cpp
|
|
|
|
Syscalls/waitid.cpp
|
2021-05-12 22:17:51 +03:00
|
|
|
Syscalls/inode_watcher.cpp
|
2020-07-31 00:38:15 +03:00
|
|
|
Syscalls/write.cpp
|
2021-04-16 22:58:51 +03:00
|
|
|
TTY/ConsoleManagement.cpp
|
2020-05-16 13:00:04 +03:00
|
|
|
TTY/MasterPTY.cpp
|
|
|
|
TTY/PTYMultiplexer.cpp
|
|
|
|
TTY/SlavePTY.cpp
|
|
|
|
TTY/TTY.cpp
|
|
|
|
TTY/VirtualConsole.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
Tasks/FinalizerTask.cpp
|
|
|
|
Tasks/SyncTask.cpp
|
|
|
|
Thread.cpp
|
2020-11-30 02:05:27 +03:00
|
|
|
ThreadBlockers.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
ThreadTracer.cpp
|
2020-10-25 18:13:47 +03:00
|
|
|
Time/APICTimer.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
Time/HPET.cpp
|
2020-05-16 13:00:04 +03:00
|
|
|
Time/HPETComparator.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
Time/PIT.cpp
|
|
|
|
Time/RTC.cpp
|
|
|
|
Time/TimeManagement.cpp
|
2020-05-16 13:00:04 +03:00
|
|
|
TimerQueue.cpp
|
2021-02-05 21:44:26 +03:00
|
|
|
UBSanitizer.cpp
|
2020-09-12 06:11:07 +03:00
|
|
|
UserOrKernelBuffer.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
WaitQueue.cpp
|
2021-02-06 09:36:38 +03:00
|
|
|
WorkQueue.cpp
|
2020-05-16 13:00:04 +03:00
|
|
|
init.cpp
|
|
|
|
kprintf.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
)
|
|
|
|
|
2021-08-27 22:23:43 +03:00
|
|
|
if ("${SERENITY_ARCH}" STREQUAL "i686" OR "${SERENITY_ARCH}" STREQUAL "x86_64")
|
2021-10-15 22:55:22 +03:00
|
|
|
set(KERNEL_SOURCES
|
|
|
|
${KERNEL_SOURCES}
|
2021-10-17 00:41:09 +03:00
|
|
|
Arch/x86/common/ScopedCritical.cpp
|
|
|
|
Arch/x86/common/SmapDisabler.cpp
|
2022-02-02 14:49:32 +03:00
|
|
|
Arch/x86/common/Spinlock.cpp
|
2021-10-15 22:55:22 +03:00
|
|
|
)
|
|
|
|
|
2021-08-27 22:23:43 +03:00
|
|
|
set(KERNEL_SOURCES
|
|
|
|
${KERNEL_SOURCES}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/${KERNEL_ARCH}/ASM_wrapper.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/${KERNEL_ARCH}/Boot/ap_setup.S
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/${KERNEL_ARCH}/InterruptEntry.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/${KERNEL_ARCH}/Processor.cpp
|
|
|
|
)
|
2021-06-21 18:34:09 +03:00
|
|
|
|
2021-08-27 22:23:43 +03:00
|
|
|
set(KERNEL_SOURCES
|
|
|
|
${KERNEL_SOURCES}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/ASM_wrapper.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/CPU.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/Interrupts.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/Processor.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/ProcessorInfo.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/SafeMem.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/TrapFrame.cpp
|
|
|
|
)
|
2021-07-23 23:52:25 +03:00
|
|
|
|
|
|
|
if("${SERENITY_ARCH}" STREQUAL "x86_64")
|
|
|
|
set(KERNEL_SOURCES
|
|
|
|
${KERNEL_SOURCES}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/${KERNEL_ARCH}/SyscallEntry.cpp
|
|
|
|
)
|
|
|
|
endif()
|
2021-08-27 22:23:43 +03:00
|
|
|
endif()
|
2021-03-07 23:28:28 +03:00
|
|
|
|
2020-05-06 18:40:06 +03:00
|
|
|
set(AK_SOURCES
|
2020-08-09 12:34:26 +03:00
|
|
|
../AK/GenericLexer.cpp
|
2020-12-31 14:17:03 +03:00
|
|
|
../AK/Hex.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
../AK/StringBuilder.cpp
|
|
|
|
../AK/StringUtils.cpp
|
|
|
|
../AK/StringView.cpp
|
2020-08-26 02:19:16 +03:00
|
|
|
../AK/Time.cpp
|
2020-09-22 14:05:40 +03:00
|
|
|
../AK/Format.cpp
|
2020-12-31 14:17:03 +03:00
|
|
|
../AK/UUID.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
)
|
|
|
|
|
2022-01-01 08:02:55 +03:00
|
|
|
set(EDID_SOURCES
|
|
|
|
../Userland/Libraries/LibEDID/DMT.cpp
|
|
|
|
../Userland/Libraries/LibEDID/EDID.cpp
|
|
|
|
../Userland/Libraries/LibEDID/VIC.cpp
|
|
|
|
)
|
|
|
|
|
2020-05-06 18:40:06 +03:00
|
|
|
set(ELF_SOURCES
|
2021-01-12 14:17:30 +03:00
|
|
|
../Userland/Libraries/LibELF/Image.cpp
|
|
|
|
../Userland/Libraries/LibELF/Validation.cpp
|
2020-05-06 18:40:06 +03:00
|
|
|
)
|
|
|
|
|
2021-05-08 21:37:43 +03:00
|
|
|
generate_state_machine(../Userland/Libraries/LibVT/StateMachine.txt ../Userland/Libraries/LibVT/EscapeSequenceStateMachine.h)
|
|
|
|
|
2020-05-27 00:35:14 +03:00
|
|
|
set(VT_SOURCES
|
2021-01-12 14:17:30 +03:00
|
|
|
../Userland/Libraries/LibVT/Terminal.cpp
|
|
|
|
../Userland/Libraries/LibVT/Line.cpp
|
2021-05-08 21:37:43 +03:00
|
|
|
../Userland/Libraries/LibVT/EscapeSequenceParser.cpp
|
2020-05-27 00:35:14 +03:00
|
|
|
)
|
|
|
|
|
2020-06-23 05:23:35 +03:00
|
|
|
set(CRYPTO_SOURCES
|
2021-01-12 14:17:30 +03:00
|
|
|
../Userland/Libraries/LibCrypto/Cipher/AES.cpp
|
|
|
|
../Userland/Libraries/LibCrypto/Hash/SHA2.cpp
|
2020-06-23 05:23:35 +03:00
|
|
|
)
|
|
|
|
|
2021-10-15 16:57:42 +03:00
|
|
|
set(SOURCES
|
|
|
|
${AK_SOURCES}
|
|
|
|
)
|
2021-08-28 20:43:55 +03:00
|
|
|
if (NOT "${SERENITY_ARCH}" STREQUAL "aarch64")
|
|
|
|
set(SOURCES
|
|
|
|
${KERNEL_SOURCES}
|
|
|
|
${SOURCES}
|
2022-01-01 08:02:55 +03:00
|
|
|
${EDID_SOURCES}
|
2021-08-28 20:43:55 +03:00
|
|
|
${ELF_SOURCES}
|
|
|
|
${VT_SOURCES}
|
|
|
|
${CRYPTO_SOURCES}
|
|
|
|
)
|
|
|
|
else()
|
|
|
|
set(SOURCES
|
2022-03-08 20:21:40 +03:00
|
|
|
Arch/aarch64/BootPPMParser.cpp
|
|
|
|
Arch/aarch64/GPIO.cpp
|
|
|
|
Arch/aarch64/Framebuffer.cpp
|
|
|
|
Arch/aarch64/Mailbox.cpp
|
|
|
|
Arch/aarch64/MainIdRegister.cpp
|
|
|
|
Arch/aarch64/MMIO.cpp
|
|
|
|
Arch/aarch64/Timer.cpp
|
|
|
|
Arch/aarch64/UART.cpp
|
|
|
|
Arch/aarch64/Utils.cpp
|
|
|
|
|
|
|
|
# Preload specific
|
|
|
|
Arch/aarch64/init.cpp
|
|
|
|
Arch/aarch64/PrekernelMMU.cpp
|
|
|
|
Arch/aarch64/PrekernelExceptions.cpp
|
|
|
|
Arch/aarch64/PrekernelCommon.cpp
|
|
|
|
|
|
|
|
# Assembly
|
|
|
|
Arch/aarch64/boot.S
|
|
|
|
Arch/aarch64/Aarch64_asm_utils.S
|
|
|
|
Arch/aarch64/vector_table.S
|
2022-02-01 00:09:30 +03:00
|
|
|
|
2021-10-15 00:53:48 +03:00
|
|
|
Arch/aarch64/SmapDisabler.cpp
|
2021-10-15 22:55:22 +03:00
|
|
|
Arch/aarch64/ScopedCritical.cpp
|
2021-10-17 00:51:40 +03:00
|
|
|
MiniStdLib.cpp
|
2022-03-08 20:21:40 +03:00
|
|
|
Prekernel/UBSanitizer.cpp
|
2021-08-28 20:43:55 +03:00
|
|
|
)
|
2021-10-13 21:21:24 +03:00
|
|
|
|
|
|
|
# Otherwise linker errors e.g undefined reference to `__aarch64_cas8_acq_rel'
|
2021-10-14 22:22:45 +03:00
|
|
|
add_compile_options(-mno-outline-atomics -latomic)
|
2021-08-28 20:43:55 +03:00
|
|
|
endif()
|
2020-05-06 18:40:06 +03:00
|
|
|
|
2021-10-14 02:04:04 +03:00
|
|
|
add_compile_options(-fsigned-char)
|
2021-09-07 11:21:36 +03:00
|
|
|
add_compile_options(-Wno-unknown-warning-option -Wvla -Wnull-dereference)
|
|
|
|
add_compile_options(-fno-rtti -ffreestanding -fbuiltin)
|
2021-08-27 22:23:43 +03:00
|
|
|
if ("${SERENITY_ARCH}" STREQUAL "i686" OR "${SERENITY_ARCH}" STREQUAL "x86_64")
|
2021-09-07 11:21:36 +03:00
|
|
|
add_compile_options(-mno-80387 -mno-mmx -mno-sse -mno-sse2)
|
2021-08-27 22:23:43 +03:00
|
|
|
endif()
|
2021-09-07 11:21:36 +03:00
|
|
|
add_compile_options(-fno-asynchronous-unwind-tables)
|
|
|
|
add_compile_options(-fstack-protector-strong)
|
|
|
|
add_compile_options(-fno-exceptions)
|
2021-08-08 05:13:26 +03:00
|
|
|
# FIXME: remove -nodefaultlibs after the next toolchain update
|
2021-09-07 11:21:36 +03:00
|
|
|
add_compile_options(-nodefaultlibs -nostdlib)
|
2020-05-06 18:40:06 +03:00
|
|
|
|
2021-09-07 11:21:36 +03:00
|
|
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
|
|
# Apply any flags that are only available on >= GCC 11.1
|
|
|
|
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "11.1")
|
|
|
|
# Zero any registers used within a function on return (to reduce data lifetime and ROP gadgets).
|
|
|
|
add_compile_options(-fzero-call-used-regs=used-gpr)
|
|
|
|
endif()
|
|
|
|
link_directories(${TOOLCHAIN_ROOT}/${SERENITY_ARCH}-pc-serenity/lib)
|
|
|
|
link_directories(${TOOLCHAIN_ROOT}/lib/gcc/${SERENITY_ARCH}-pc-serenity/${GCC_VERSION}/)
|
Toolchain+Meta: Update LLVM version to 13.0.0
This commit updates the Clang toolchain's version to 13.0.0, which comes
with better C++20 support and improved handling of new features by
clang-format. Due to the newly enabled `-Bsymbolic-functions` flag, our
Clang binaries will only be 2-4% slower than if we dynamically linked
them, but we save hundreds of megabytes of disk space.
The `BuildClang.sh` script has been reworked to build the entire
toolchain in just three steps: one for the compiler, one for GNU
binutils, and one for the runtime libraries. This reduces the complexity
of the build script, and will allow us to modify the CI configuration to
only rebuild the libraries when our libc headers change.
Most of the compile flags have been moved out to a separate CMake cache
file, similarly to how the Android and Fuchsia toolchains are
implemented within the LLVM repo. This provides a nicer interface than
the heaps of command-line arguments.
We no longer build separate toolchains for each architecture, as the
same Clang binary can compile code for multiple targets.
The horrible mess that `SERENITY_CLANG_ARCH` was, has been removed in
this commit. Clang happily accepts an `i686-pc-serenity` target triple,
which matches what our GCC toolchain accepts.
2021-08-13 13:11:12 +03:00
|
|
|
|
|
|
|
set(TARGET_STRING "")
|
2022-02-05 17:48:32 +03:00
|
|
|
|
|
|
|
add_link_options(LINKER:-z,pack-relative-relocs)
|
2021-09-07 11:21:36 +03:00
|
|
|
else() # Assume Clang
|
Kernel: Fix UB caused by taking a reference to a packed struct's member
Taking a reference or a pointer to a value that's not aligned properly
is undefined behavior. While `[[gnu::packed]]` ensures that reads from
and writes to fields of packed structs is a safe operation, the
information about the reduced alignment is lost when creating pointers
to these values.
Weirdly enough, GCC's undefined behavior sanitizer doesn't flag these,
even though the doc of `-Waddress-of-packed-member` says that it usually
leads to UB. In contrast, x86_64 Clang does flag these, which renders
the 64-bit kernel unable to boot.
For now, the `address-of-packed-member` warning will only be enabled in
the kernel, as it is absolutely crucial there because of KUBSAN, but
might get excessively noisy for the userland in the future.
Also note that we can't append to `CMAKE_CXX_FLAGS` like we do for other
flags in the kernel, because flags added via `add_compile_options` come
after these, so the `-Wno-address-of-packed-member` in the root would
cancel it out.
2021-08-01 21:30:43 +03:00
|
|
|
add_compile_options(-Waddress-of-packed-member)
|
2021-09-07 11:21:36 +03:00
|
|
|
add_compile_options(-faligned-allocation)
|
Toolchain+Meta: Update LLVM version to 13.0.0
This commit updates the Clang toolchain's version to 13.0.0, which comes
with better C++20 support and improved handling of new features by
clang-format. Due to the newly enabled `-Bsymbolic-functions` flag, our
Clang binaries will only be 2-4% slower than if we dynamically linked
them, but we save hundreds of megabytes of disk space.
The `BuildClang.sh` script has been reworked to build the entire
toolchain in just three steps: one for the compiler, one for GNU
binutils, and one for the runtime libraries. This reduces the complexity
of the build script, and will allow us to modify the CI configuration to
only rebuild the libraries when our libc headers change.
Most of the compile flags have been moved out to a separate CMake cache
file, similarly to how the Android and Fuchsia toolchains are
implemented within the LLVM repo. This provides a nicer interface than
the heaps of command-line arguments.
We no longer build separate toolchains for each architecture, as the
same Clang binary can compile code for multiple targets.
The horrible mess that `SERENITY_CLANG_ARCH` was, has been removed in
this commit. Clang happily accepts an `i686-pc-serenity` target triple,
which matches what our GCC toolchain accepts.
2021-08-13 13:11:12 +03:00
|
|
|
|
|
|
|
# We need this in order to pick up the #define __serenity__, otherwise we end up including unistd.h into the linker script
|
|
|
|
set(TARGET_STRING "--target=${CMAKE_CXX_COMPILER_TARGET}")
|
2022-02-01 00:09:30 +03:00
|
|
|
|
2022-02-05 17:48:32 +03:00
|
|
|
add_link_options(LINKER:--build-id=none LINKER:--pack-dyn-relocs=relr)
|
2021-07-13 17:43:45 +03:00
|
|
|
endif()
|
|
|
|
|
|
|
|
macro (set_new_alignment alignment)
|
2021-09-07 11:21:36 +03:00
|
|
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
2021-07-13 17:43:45 +03:00
|
|
|
add_compile_options(-faligned-new=${alignment})
|
2021-09-07 11:21:36 +03:00
|
|
|
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang$")
|
|
|
|
add_compile_options(-fnew-alignment=${alignment})
|
2021-07-13 17:43:45 +03:00
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2021-03-04 19:50:05 +03:00
|
|
|
if ("${SERENITY_ARCH}" STREQUAL "x86_64")
|
2021-09-07 11:21:36 +03:00
|
|
|
add_compile_options(-mcmodel=large -mno-red-zone)
|
2021-07-13 17:43:45 +03:00
|
|
|
set_new_alignment(8)
|
2021-06-26 07:28:50 +03:00
|
|
|
else()
|
2021-07-13 17:43:45 +03:00
|
|
|
set_new_alignment(4)
|
2021-03-04 19:50:05 +03:00
|
|
|
endif()
|
|
|
|
|
2021-07-26 16:10:51 +03:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-pie")
|
2021-07-23 13:56:35 +03:00
|
|
|
|
2021-06-07 02:15:07 +03:00
|
|
|
# Kernel Coverage (KCOV) is an API to collect and expose program counters of
|
|
|
|
# kernel code that has been run to user space. It's rather slow and likely not
|
|
|
|
# secure to run in production builds. Useful for coverage guided fuzzing.
|
|
|
|
if (ENABLE_KERNEL_COVERAGE_COLLECTION)
|
|
|
|
add_definitions(-DENABLE_KERNEL_COVERAGE_COLLECTION)
|
2021-08-25 06:28:51 +03:00
|
|
|
add_compile_options(-fsanitize-coverage=trace-pc)
|
2021-06-07 02:15:07 +03:00
|
|
|
set(KCOV_EXCLUDED_SOURCES
|
|
|
|
# Make sure we don't instrument any code called from __sanitizer_cov_trace_pc
|
|
|
|
# otherwise we'll end up with recursive calls to that function.
|
|
|
|
../AK/Format.cpp
|
|
|
|
../AK/StringBuilder.cpp
|
|
|
|
../Kernel/Arch/x86/${KERNEL_ARCH}/Processor.cpp
|
|
|
|
../Kernel/Devices/KCOVDevice.cpp
|
|
|
|
../Kernel/Devices/KCOVInstance.cpp
|
|
|
|
../Kernel/FileSystem/File.cpp
|
2021-09-07 14:39:11 +03:00
|
|
|
../Kernel/FileSystem/OpenFileDescription.cpp
|
2021-06-07 02:15:07 +03:00
|
|
|
../Kernel/init.cpp
|
|
|
|
../Kernel/SanCov.cpp
|
|
|
|
# GCC assumes that the caller saves registers for functions according
|
|
|
|
# to the System V ABI and happily inserts coverage calls into the
|
|
|
|
# function prologue for all functions. This assumption is not true for
|
|
|
|
# interrupt handlers because their calling convention is not compatible
|
|
|
|
# with the System V ABI.
|
|
|
|
../Kernel/Arch/x86/common/Interrupts.cpp
|
|
|
|
../Kernel/Syscall.cpp
|
|
|
|
)
|
|
|
|
set_source_files_properties(${KCOV_EXCLUDED_SOURCES} PROPERTIES COMPILE_FLAGS "-fno-sanitize-coverage=trace-pc")
|
|
|
|
endif()
|
|
|
|
|
2021-02-24 22:47:56 +03:00
|
|
|
# Kernel Undefined Behavior Sanitizer (KUBSAN)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
|
|
|
|
|
2021-02-14 23:47:10 +03:00
|
|
|
# Kernel Address Sanitize (KASAN) implementation is still a work in progress, this option
|
|
|
|
# is not currently meant to be used, besides when developing Kernel ASAN support.
|
|
|
|
#
|
|
|
|
if (ENABLE_KERNEL_ADDRESS_SANITIZER)
|
2021-08-25 06:28:51 +03:00
|
|
|
add_compile_options(-fsanitize=kernel-address)
|
2021-09-07 11:21:36 +03:00
|
|
|
add_link_options(-fsanitize=kernel-address)
|
2021-02-14 23:47:10 +03:00
|
|
|
endif()
|
|
|
|
|
2022-03-08 20:21:40 +03:00
|
|
|
if ("${SERENITY_ARCH}" STREQUAL "aarch64")
|
|
|
|
add_compile_options(-fno-threadsafe-statics)
|
|
|
|
endif()
|
|
|
|
|
2021-02-11 23:20:10 +03:00
|
|
|
add_compile_definitions(KERNEL)
|
2021-08-18 18:39:04 +03:00
|
|
|
add_link_options(LINKER:-z,notext)
|
|
|
|
|
2021-08-28 20:43:55 +03:00
|
|
|
if (NOT "${SERENITY_ARCH}" STREQUAL "aarch64")
|
|
|
|
add_library(kernel_heap STATIC ${KERNEL_HEAP_SOURCES})
|
|
|
|
endif()
|
2021-07-18 15:47:32 +03:00
|
|
|
add_executable(Kernel ${SOURCES})
|
|
|
|
add_dependencies(Kernel generate_EscapeSequenceStateMachine.h)
|
2021-05-20 12:44:23 +03:00
|
|
|
|
2022-03-08 20:21:40 +03:00
|
|
|
if (NOT "${SERENITY_ARCH}" STREQUAL "aarch64")
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/linker.ld
|
|
|
|
COMMAND "${CMAKE_CXX_COMPILER}" ${TARGET_STRING} -E -P -x c -I${CMAKE_CURRENT_SOURCE_DIR}/.. "${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/linker.ld" -o "${CMAKE_CURRENT_BINARY_DIR}/linker.ld"
|
|
|
|
MAIN_DEPENDENCY "Arch/x86/linker.ld"
|
|
|
|
COMMENT "Preprocessing linker.ld"
|
|
|
|
VERBATIM
|
|
|
|
)
|
2021-07-20 11:40:09 +03:00
|
|
|
|
2022-03-08 20:21:40 +03:00
|
|
|
add_custom_target(generate_kernel_linker_script DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/linker.ld)
|
|
|
|
target_link_options(Kernel PRIVATE LINKER:-T ${CMAKE_CURRENT_BINARY_DIR}/linker.ld -nostdlib -nodefaultlibs)
|
|
|
|
set_target_properties(Kernel PROPERTIES LINK_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/linker.ld")
|
|
|
|
else()
|
|
|
|
target_link_options(Kernel PRIVATE LINKER:-T ${CMAKE_CURRENT_SOURCE_DIR}/Arch/aarch64/linker.ld -nostdlib LINKER:--no-pie)
|
|
|
|
set_target_properties(Kernel PROPERTIES LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/Arch/aarch64/linker.ld)
|
|
|
|
endif()
|
2021-06-17 20:26:37 +03:00
|
|
|
|
2021-04-29 16:25:31 +03:00
|
|
|
if (ENABLE_KERNEL_LTO)
|
|
|
|
include(CheckIPOSupported)
|
|
|
|
check_ipo_supported()
|
2021-10-09 20:05:19 +03:00
|
|
|
add_definitions(-DENABLE_KERNEL_LTO)
|
2021-07-18 15:47:32 +03:00
|
|
|
set_property(TARGET Kernel PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
|
2021-09-21 23:59:03 +03:00
|
|
|
if (NOT "${SERENITY_ARCH}" STREQUAL "aarch64")
|
|
|
|
set_property(TARGET kernel_heap PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
|
|
|
|
endif()
|
2021-04-29 16:25:31 +03:00
|
|
|
endif()
|
2021-07-13 17:43:45 +03:00
|
|
|
|
2021-08-28 20:43:55 +03:00
|
|
|
if (NOT "${SERENITY_ARCH}" STREQUAL "aarch64")
|
2021-09-07 11:21:36 +03:00
|
|
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
|
|
target_link_libraries(Kernel PRIVATE kernel_heap gcc)
|
|
|
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang$")
|
Toolchain+Meta: Update LLVM version to 13.0.0
This commit updates the Clang toolchain's version to 13.0.0, which comes
with better C++20 support and improved handling of new features by
clang-format. Due to the newly enabled `-Bsymbolic-functions` flag, our
Clang binaries will only be 2-4% slower than if we dynamically linked
them, but we save hundreds of megabytes of disk space.
The `BuildClang.sh` script has been reworked to build the entire
toolchain in just three steps: one for the compiler, one for GNU
binutils, and one for the runtime libraries. This reduces the complexity
of the build script, and will allow us to modify the CI configuration to
only rebuild the libraries when our libc headers change.
Most of the compile flags have been moved out to a separate CMake cache
file, similarly to how the Android and Fuchsia toolchains are
implemented within the LLVM repo. This provides a nicer interface than
the heaps of command-line arguments.
We no longer build separate toolchains for each architecture, as the
same Clang binary can compile code for multiple targets.
The horrible mess that `SERENITY_CLANG_ARCH` was, has been removed in
this commit. Clang happily accepts an `i686-pc-serenity` target triple,
which matches what our GCC toolchain accepts.
2021-08-13 13:11:12 +03:00
|
|
|
target_link_libraries(Kernel PRIVATE kernel_heap clang_rt.builtins)
|
2021-08-28 20:43:55 +03:00
|
|
|
endif()
|
2021-07-13 17:43:45 +03:00
|
|
|
endif()
|
|
|
|
|
2021-06-24 14:08:19 +03:00
|
|
|
add_custom_command(
|
2022-03-08 20:21:40 +03:00
|
|
|
TARGET Kernel POST_BUILD
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E env NM=${CMAKE_NM} sh ${CMAKE_CURRENT_SOURCE_DIR}/mkmap.sh
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E env OBJCOPY=${CMAKE_OBJCOPY} sh ${CMAKE_CURRENT_SOURCE_DIR}/embedmap.sh
|
|
|
|
COMMAND ${CMAKE_OBJCOPY} --only-keep-debug Kernel Kernel.debug
|
|
|
|
COMMAND ${CMAKE_OBJCOPY} --strip-debug Kernel
|
|
|
|
COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=Kernel.debug Kernel
|
|
|
|
BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/kernel.map
|
2021-06-24 14:08:19 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Kernel" DESTINATION boot)
|
2021-07-17 10:43:15 +03:00
|
|
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Kernel.debug" DESTINATION boot)
|
2021-07-14 22:04:18 +03:00
|
|
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/kernel.map" DESTINATION res)
|
2020-05-06 18:40:06 +03:00
|
|
|
|
2022-03-08 20:21:40 +03:00
|
|
|
if ("${SERENITY_ARCH}" STREQUAL "aarch64")
|
|
|
|
embed_resource(Kernel serenity_boot_logo "Arch/aarch64/SerenityLogoRGB.ppm")
|
|
|
|
add_custom_command(
|
|
|
|
TARGET Kernel POST_BUILD
|
|
|
|
COMMAND ${CMAKE_OBJCOPY} -O binary Kernel kernel8.img
|
|
|
|
BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/kernel8.img
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2020-05-26 21:20:24 +03:00
|
|
|
serenity_install_headers(Kernel)
|
2020-08-15 15:11:10 +03:00
|
|
|
serenity_install_sources(Kernel)
|
2020-05-26 21:20:24 +03:00
|
|
|
|
2022-03-08 20:21:40 +03:00
|
|
|
# aarch64 does not need a Prekernel
|
|
|
|
if (NOT "${SERENITY_ARCH}" STREQUAL "aarch64")
|
|
|
|
add_subdirectory(Prekernel)
|
|
|
|
endif()
|