ladybird/Kernel/Makefile
Liav A 9db291d885 Kernel: Introduce the new Time management subsystem
This new subsystem includes better abstractions of how time will be
handled in the OS. We take advantage of the existing RTC timer to aid
in keeping time synchronized. This is standing in contrast to how we
handled time-keeping in the kernel, where the PIT was responsible for
that function in addition to update the scheduler about ticks.
With that new advantage, we can easily change the ticking dynamically
and still keep the time synchronized.

In the process context, we no longer use a fixed declaration of
TICKS_PER_SECOND, but we call the TimeManagement singleton class to
provide us the right value. This allows us to use dynamic ticking in
the future, a feature known as tickless kernel.

The scheduler no longer does by himself the calculation of real time
(Unix time), and just calls the TimeManagment singleton class to provide
the value.

Also, we can use 2 new boot arguments:
- the "time" boot argument accpets either the value "modern", or
  "legacy". If "modern" is specified, the time management subsystem will
  try to setup HPET. Otherwise, for "legacy" value, the time subsystem
  will revert to use the PIT & RTC, leaving HPET disabled.
  If this boot argument is not specified, the default pattern is to try
  to setup HPET.
- the "hpet" boot argumet accepts either the value "periodic" or
  "nonperiodic". If "periodic" is specified, the HPET will scan for
  periodic timers, and will assert if none are found. If only one is
  found, that timer will be assigned for the time-keeping task. If more
  than one is found, both time-keeping task & scheduler-ticking task
  will be assigned to periodic timers.
  If this boot argument is not specified, the default pattern is to try
  to scan for HPET periodic timers. This boot argument has no effect if
  HPET is disabled.

In hardware context, PIT & RealTimeClock classes are merely inheriting
from the HardwareTimer class, and they allow to use the old i8254 (PIT)
and RTC devices, managing them via IO ports. By default, the RTC will be
programmed to a frequency of 1024Hz. The PIT will be programmed to a
frequency close to 1000Hz.

About HPET, depending if we need to scan for periodic timers or not,
we try to set a frequency close to 1000Hz for the time-keeping timer
and scheduler-ticking timer. Also, if possible, we try to enable the
Legacy replacement feature of the HPET. This feature if exists,
instructs the chipset to disconnect both i8254 (PIT) and RTC.
This behavior is observable on QEMU, and was verified against the source
code:
ce967e2f33

The HPETComparator class is inheriting from HardwareTimer class, and is
responsible for an individual HPET comparator, which is essentially a
timer. Therefore, it needs to call the singleton HPET class to perform
HPET-related operations.

The new abstraction of Hardware timers brings an opportunity of more new
features in the foreseeable future. For example, we can change the
callback function of each hardware timer, thus it makes it possible to
swap missions between hardware timers, or to allow to use a hardware
timer for other temporary missions (e.g. calibrating the LAPIC timer,
measuring the CPU frequency, etc).
2020-03-19 15:48:00 +01:00

161 lines
4.1 KiB
Makefile

OBJS = \
../AK/FileSystemPath.o \
../AK/JsonParser.o \
../AK/JsonValue.o \
../AK/LogStream.o \
../AK/String.o \
../AK/StringBuilder.o \
../AK/StringImpl.o \
../AK/StringView.o \
../AK/StringUtils.o \
../Libraries/LibELF/ELFImage.o \
../Libraries/LibELF/ELFLoader.o \
../Libraries/LibBareMetal/Output/Console.o \
../Libraries/LibBareMetal/Output/kprintf.o \
../Libraries/LibBareMetal/StdLib.o \
Arch/i386/CPU.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/DebugLogDevice.o \
Devices/Device.o \
Devices/DiskPartition.o \
Devices/FloppyDiskDevice.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/DiskBackedFileSystem.o \
FileSystem/Ext2FileSystem.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 \
KParams.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 \
ProcessTracer.o \
Profiling.o \
RTC.o \
Random.o \
Scheduler.o \
SharedBuffer.o \
Syscall.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/ACPIParser.o \
ACPI/ACPIStaticParser.o \
ACPI/ACPIDynamicParser.o \
ACPI/DMIDecoder.o \
ACPI/MultiProcessorParser.o \
WaitQueue.o \
init.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++
SUBPROJECT_CXXFLAGS += -I../Toolchain/Local/i686-pc-serenity/include/c++/9.2.0/
SUBPROJECT_CXXFLAGS += -I../Toolchain/Local/i686-pc-serenity/include/c++/9.2.0/i686-pc-serenity/
LDFLAGS += -Wl,-T linker.ld -nostdlib -lgcc -lstdc++
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