The Pedigree Project 0.1
Modules | Classes | Macros | Typedefs | Enumerations | Functions | Variables
kernel

The kernel. More...

+ Collaboration diagram for kernel:

Modules

 utilities
 Utilities.
 
 processor-specifc kernel
 processor-specific kernel interface
 
 machine-specifc kernel
 machine-specific kernel interface
 
 debugger
 the kernel debugger
 
 linker
 the kernel linker
 

Classes

class  Atomic< T, bAllow >
 
class  Atomic< T, true >
 
class  Atomic< bool, true >
 
class  BootstrapStruct_t
 
class  ConstexprLockGuard< T, Condition >
 
class  LockGuard< T >
 
class  LockGuard< Mutex >
 
class  ConstexprLockGuard< Mutex, true >
 
class  LockGuard< Semaphore >
 
class  RecursingLockGuard< T >
 
class  Log
 the kernel's log More...
 

Macros

#define BOOTSTRAP_FLAG_CMDLINE   0x001
 
#define BOOTSTRAP_FLAG_MODULES   0x002
 
#define BOOTSTRAP_FLAG_ELF   0x004
 
#define BOOTSTRAP_FLAG_MEMORY_MAP   0x008
 
#define BOOTSTRAP_FLAG_ACPI   0x010
 
#define BOOTSTRAP_FLAG_SMBIOS   0x020
 
#define BOOTSTRAP_FLAG_FRAMEBUFFER   0x040
 
#define BOOTSTRAP_FLAG_UEFI   0x080
 
#define DEPRECATED   __attribute__((deprecated))
 
#define NORETURN   __attribute__((noreturn))
 
#define PURE   __attribute__((pure))
 
#define CONST   __attribute__((const))
 
#define ALWAYS_INLINE   __attribute__((always_inline))
 
#define NEVER_INLINE   __attribute__((noinline))
 
#define ALIGN(x)   __attribute__((aligned(x)))
 
#define PACKED   __attribute__((packed))
 
#define MAY_ALIAS   __attribute__((may_alias))
 
#define CONSTRUCTOR   __attribute__((constructor))
 
#define LIKELY(exp)   __builtin_expect(!!(exp), 1)
 
#define UNLIKELY(exp)   __builtin_expect(!!(exp), 0)
 
#define UNREACHABLE   __builtin_unreachable()
 
#define FORMAT(type, idx, first)   __attribute__((format(type, idx, first)))
 
#define IS_CONSTANT(x)   __builtin_constant_p(x)
 
#define SECTION(x)   __attribute__((__section__(x)))
 
#define MUST_USE_RESULT   __attribute__((warn_unused_result))
 
#define USED   __attribute__((used))
 
#define WEAK   __attribute__((weak))
 
#define FALLSTHROUGH
 
#define MALLOC   __attribute__((malloc))
 
#define ALLOC_SIZE(...)   __attribute__((alloc_size(__VA_ARGS__)))
 
#define C_NOTHROW   __attribute__((nothrow))
 
#define EMIT_IF(...)   if constexpr (__VA_ARGS__)
 
#define EXPORTED_PUBLIC   __attribute__((visibility("default")))
 
#define SYMBOL_HIDDEN   __attribute__((visibility("hidden")))
 
#define __has_builtin(x)   0
 
#define __has_feature(x)   0
 
#define ASSUME_ALIGNMENT(b, sz)   __builtin_assume_aligned((b), sz)
 
#define INITIALISATION_ONLY   SECTION(".init.text")
 
#define INITIALISATION_ONLY_DATA   SECTION(".init.data")
 
#define HAS_ADDRESS_SANITIZER   0
 
#define HAS_THREAD_SANITIZER   0
 
#define BARRIER()   __asm__ __volatile__("" ::: "memory")
 
#define FENCE()   __sync_synchronize()
 
#define SHOW_FILE_IN_LOGS   0
 
#define HUGE_STATIC_LOG   0
 
#define FILE_LOG(entry, level)
 
#define LOG_AT_LEVEL(level, text, lock)
 
#define DEBUG_LOG(text)
 
#define DEBUG_LOG_NOLOCK(text)
 
#define NOTICE(text)
 
#define NOTICE_NOLOCK(text)
 
#define WARNING(text)
 
#define WARNING_NOLOCK(text)
 
#define ERROR(text)
 
#define ERROR_NOLOCK(text)
 
#define FATAL(text)
 
#define FATAL_NOLOCK(text)
 
#define PEDANTRY(text)
 
#define LOG_LENGTH   128
 
#define LOG_ENTRIES   ((1 << 16) / sizeof(LogEntry))
 
#define LOG_CALLBACK_COUNT   16
 
#define assert(x)
 
#define assert_heap_ptr_valid(x)
 
#define bool   char
 

Typedefs

typedef StaticCord< 8 > LogCord
 
typedef void(* BootProgressUpdateFn) (const char *)
 

Enumerations

enum  NumberType { Hex , Dec , Oct }
 
enum  LogEntryModifier { Unlocked , NoTimestamp }
 

Functions

void installSerialLogger ()
 
void EXPORTED_PUBLIC panic (const char *msg) NORETURN
 
void EXPORTED_PUBLIC _assert (bool b, const char *file, int line, const char *func)
 
bool _assert_ptr_valid (uintptr_t x)
 

Variables

BootstrapStruct_t *g_pBootstrapInfo EXPORTED_PUBLIC
 
class EXPORTED_PUBLIC BootstrapStruct_t PACKED
 
size_t g_BootProgressCurrent
 
size_t g_BootProgressTotal
 
BootProgressUpdateFn g_BootProgressUpdate
 

Detailed Description

The kernel.

Classes, functions, defines belonging to the kernel

Macro Definition Documentation

◆ __has_builtin

#define __has_builtin (   x)    0

Definition at line 100 of file system/include/pedigree/kernel/compiler.h.

◆ __has_feature

#define __has_feature (   x)    0

Definition at line 104 of file system/include/pedigree/kernel/compiler.h.

◆ ALIGN

#define ALIGN (   x)    __attribute__((aligned(x)))

Specific alignment for a type/variable

Definition at line 46 of file system/include/pedigree/kernel/compiler.h.

◆ ALLOC_SIZE

#define ALLOC_SIZE (   ...)    __attribute__((alloc_size(__VA_ARGS__)))

Hint for the size of an allocation.

Definition at line 85 of file system/include/pedigree/kernel/compiler.h.

◆ ALWAYS_INLINE

#define ALWAYS_INLINE   __attribute__((always_inline))

Functions that should always be inlined

Definition at line 42 of file system/include/pedigree/kernel/compiler.h.

◆ assert

#define assert (   x)
Value:
do { \
bool __pedigree_assert_chk = (x); \
if (UNLIKELY(!__pedigree_assert_chk)) \
_assert(__pedigree_assert_chk, __FILE__, __LINE__, __PRETTY_FUNCTION__); \
} while (0)

If the passed argument resolves to a Boolean false value, execution will be halted and a message displayed.

Definition at line 39 of file assert.h.

◆ assert_heap_ptr_valid

#define assert_heap_ptr_valid (   x)
Value:
_assert(_assert_ptr_valid(reinterpret_cast<uintptr_t>(x)), __FILE__, __LINE__, \
__PRETTY_FUNCTION__)
void EXPORTED_PUBLIC _assert(bool b, const char *file, int line, const char *func)
Definition assert.cc:27

Definition at line 47 of file assert.h.

◆ ASSUME_ALIGNMENT

#define ASSUME_ALIGNMENT (   b,
  sz 
)    __builtin_assume_aligned((b), sz)

Definition at line 108 of file system/include/pedigree/kernel/compiler.h.

◆ BARRIER

#define BARRIER ( )    __asm__ __volatile__("" ::: "memory")

Definition at line 151 of file system/include/pedigree/kernel/compiler.h.

◆ bool

#define bool   char

Definition at line 60 of file assert.h.

◆ BOOTSTRAP_FLAG_ACPI

#define BOOTSTRAP_FLAG_ACPI   0x010

Definition at line 38 of file BootstrapInfo.h.

◆ BOOTSTRAP_FLAG_CMDLINE

#define BOOTSTRAP_FLAG_CMDLINE   0x001

Definition at line 34 of file BootstrapInfo.h.

◆ BOOTSTRAP_FLAG_ELF

#define BOOTSTRAP_FLAG_ELF   0x004

Definition at line 36 of file BootstrapInfo.h.

◆ BOOTSTRAP_FLAG_FRAMEBUFFER

#define BOOTSTRAP_FLAG_FRAMEBUFFER   0x040

Definition at line 40 of file BootstrapInfo.h.

◆ BOOTSTRAP_FLAG_MEMORY_MAP

#define BOOTSTRAP_FLAG_MEMORY_MAP   0x008

Definition at line 37 of file BootstrapInfo.h.

◆ BOOTSTRAP_FLAG_MODULES

#define BOOTSTRAP_FLAG_MODULES   0x002

Definition at line 35 of file BootstrapInfo.h.

◆ BOOTSTRAP_FLAG_SMBIOS

#define BOOTSTRAP_FLAG_SMBIOS   0x020

Definition at line 39 of file BootstrapInfo.h.

◆ BOOTSTRAP_FLAG_UEFI

#define BOOTSTRAP_FLAG_UEFI   0x080

Definition at line 41 of file BootstrapInfo.h.

◆ C_NOTHROW

#define C_NOTHROW   __attribute__((nothrow))

C function cannot throw an exception.

Definition at line 87 of file system/include/pedigree/kernel/compiler.h.

◆ CONST

#define CONST   __attribute__((const))

Function does not have a side-effect and does only depend on its arguments

Definition at line 40 of file system/include/pedigree/kernel/compiler.h.

◆ CONSTRUCTOR

#define CONSTRUCTOR   __attribute__((constructor))

The function is a constructor to be run at program load time.

Definition at line 52 of file system/include/pedigree/kernel/compiler.h.

◆ DEBUG_LOG

#define DEBUG_LOG (   text)

Definition at line 112 of file Log.h.

◆ DEBUG_LOG_NOLOCK

#define DEBUG_LOG_NOLOCK (   text)

Definition at line 113 of file Log.h.

◆ DEPRECATED

#define DEPRECATED   __attribute__((deprecated))

Deprecated function/variable/type

Definition at line 33 of file system/include/pedigree/kernel/compiler.h.

◆ EMIT_IF

#define EMIT_IF (   ...)    if constexpr (__VA_ARGS__)

Macros to wrap things in compile-times conditions.

Definition at line 89 of file system/include/pedigree/kernel/compiler.h.

◆ ERROR

#define ERROR (   text)

Definition at line 118 of file Log.h.

◆ ERROR_NOLOCK

#define ERROR_NOLOCK (   text)

Definition at line 119 of file Log.h.

◆ EXPORTED_PUBLIC

#define EXPORTED_PUBLIC   __attribute__((visibility("default")))

This function or variable is to be exposed to other objects. This is needed for anything that the kernel will expose to kernel modules.

Definition at line 95 of file system/include/pedigree/kernel/compiler.h.

◆ FALLSTHROUGH

#define FALLSTHROUGH

A switch fallthrough is indeed intentional.

Definition at line 79 of file system/include/pedigree/kernel/compiler.h.

◆ FATAL

#define FATAL (   text)

Definition at line 120 of file Log.h.

◆ FATAL_NOLOCK

#define FATAL_NOLOCK (   text)

Definition at line 121 of file Log.h.

◆ FENCE

#define FENCE ( )    __sync_synchronize()

Definition at line 154 of file system/include/pedigree/kernel/compiler.h.

◆ FILE_LOG

#define FILE_LOG (   entry,
  level 
)

Definition at line 51 of file Log.h.

◆ FORMAT

#define FORMAT (   type,
  idx,
  first 
)    __attribute__((format(type, idx, first)))

This function handles a format string.

Definition at line 60 of file system/include/pedigree/kernel/compiler.h.

◆ HAS_ADDRESS_SANITIZER

#define HAS_ADDRESS_SANITIZER   0

Definition at line 125 of file system/include/pedigree/kernel/compiler.h.

◆ HAS_THREAD_SANITIZER

#define HAS_THREAD_SANITIZER   0

Definition at line 131 of file system/include/pedigree/kernel/compiler.h.

◆ HUGE_STATIC_LOG

#define HUGE_STATIC_LOG   0

Definition at line 41 of file Log.h.

◆ INITIALISATION_ONLY

#define INITIALISATION_ONLY   SECTION(".init.text")

Pack initialisation functions into a special section that could be freed after the kernel initialisation is finished

Definition at line 116 of file system/include/pedigree/kernel/compiler.h.

◆ INITIALISATION_ONLY_DATA

#define INITIALISATION_ONLY_DATA   SECTION(".init.data")

Definition at line 117 of file system/include/pedigree/kernel/compiler.h.

◆ IS_CONSTANT

#define IS_CONSTANT (   x)    __builtin_constant_p(x)

True if the expression is constant at compile time, false otherwise.

Definition at line 62 of file system/include/pedigree/kernel/compiler.h.

◆ LIKELY

#define LIKELY (   exp)    __builtin_expect(!!(exp), 1)

The expression is very likely to be true

Definition at line 54 of file system/include/pedigree/kernel/compiler.h.

◆ LOG_AT_LEVEL

#define LOG_AT_LEVEL (   level,
  text,
  lock 
)
Value:
do { \
Log::LogEntry __log_macro_logentry; \
FILE_LOG(__log_macro_logentry, level); \
__log_macro_logentry << level << text; \
if (!lock) \
__log_macro_logentry << Unlocked; \
Log::instance().addEntry(__log_macro_logentry, lock); \
} while (0)
@ Unlocked
Definition Log.h:152

Definition at line 54 of file Log.h.

◆ LOG_CALLBACK_COUNT

#define LOG_CALLBACK_COUNT   16

Maximum number of output callbacks that can be registered.

Definition at line 137 of file Log.h.

◆ LOG_ENTRIES

#define LOG_ENTRIES   ((1 << 16) / sizeof(LogEntry))

The maximum number of static entries in the log.

Definition at line 134 of file Log.h.

◆ LOG_LENGTH

#define LOG_LENGTH   128

The maximum length of an individual static log entry.

Definition at line 127 of file Log.h.

◆ MALLOC

#define MALLOC   __attribute__((malloc))

The function is malloc-like, i.e. doesn't return an aliased pointer, memory is uninitialized, and so on.

Definition at line 83 of file system/include/pedigree/kernel/compiler.h.

◆ MAY_ALIAS

#define MAY_ALIAS   __attribute__((may_alias))

The type may alias

Definition at line 50 of file system/include/pedigree/kernel/compiler.h.

◆ MUST_USE_RESULT

#define MUST_USE_RESULT   __attribute__((warn_unused_result))

This function must have its return value used somehow.

Definition at line 70 of file system/include/pedigree/kernel/compiler.h.

◆ NEVER_INLINE

#define NEVER_INLINE   __attribute__((noinline))

Functions that should never be inlined

Definition at line 44 of file system/include/pedigree/kernel/compiler.h.

◆ NORETURN

#define NORETURN   __attribute__((noreturn))

Function does not return

Definition at line 35 of file system/include/pedigree/kernel/compiler.h.

◆ NOTICE

#define NOTICE (   text)

Definition at line 114 of file Log.h.

◆ NOTICE_NOLOCK

#define NOTICE_NOLOCK (   text)

Definition at line 115 of file Log.h.

◆ PACKED

#define PACKED   __attribute__((packed))

No padding for a type/variable

Definition at line 48 of file system/include/pedigree/kernel/compiler.h.

◆ PEDANTRY

#define PEDANTRY (   text)

Definition at line 122 of file Log.h.

◆ PURE

#define PURE   __attribute__((pure))

Function does not have a side-effect (except for the return value)

Definition at line 37 of file system/include/pedigree/kernel/compiler.h.

◆ SECTION

#define SECTION (   x)    __attribute__((__section__(x)))

This code should be placed in the given section.

Definition at line 67 of file system/include/pedigree/kernel/compiler.h.

◆ SHOW_FILE_IN_LOGS

#define SHOW_FILE_IN_LOGS   0

Definition at line 40 of file Log.h.

◆ SYMBOL_HIDDEN

#define SYMBOL_HIDDEN   __attribute__((visibility("hidden")))

Definition at line 96 of file system/include/pedigree/kernel/compiler.h.

◆ UNLIKELY

#define UNLIKELY (   exp)    __builtin_expect(!!(exp), 0)

The expression is very unlikely to be true

Definition at line 56 of file system/include/pedigree/kernel/compiler.h.

◆ UNREACHABLE

#define UNREACHABLE   __builtin_unreachable()

This code is not reachable.

Definition at line 58 of file system/include/pedigree/kernel/compiler.h.

◆ USED

#define USED   __attribute__((used))

This function or variable is used, even if it doesn't appear that way.

Definition at line 72 of file system/include/pedigree/kernel/compiler.h.

◆ WARNING

#define WARNING (   text)

Definition at line 116 of file Log.h.

◆ WARNING_NOLOCK

#define WARNING_NOLOCK (   text)

Definition at line 117 of file Log.h.

◆ WEAK

#define WEAK   __attribute__((weak))

This function can be overridden by a library.

Definition at line 74 of file system/include/pedigree/kernel/compiler.h.

Typedef Documentation

◆ BootProgressUpdateFn

typedef void(* BootProgressUpdateFn) (const char *)

Definition at line 159 of file Log.h.

◆ LogCord

typedef StaticCord<8> LogCord

Definition at line 43 of file Log.h.

Enumeration Type Documentation

◆ LogEntryModifier

Modifiers for LogEntry

Enumerator
Unlocked 

This log entry should be pushed to log targets without locking.

NoTimestamp 

Don't add a timestamp to this log message.

Definition at line 150 of file Log.h.

◆ NumberType

enum NumberType

Radix for Log's integer output

Enumerator
Hex 

Hexadecimal

Dec 

Decimal

Oct 

Octal

Definition at line 140 of file Log.h.

Function Documentation

◆ _assert()

void EXPORTED_PUBLIC _assert ( bool  b,
const char *  file,
int  line,
const char *  func 
)

Internal use only, the assert() macro passes the additional arguments automatically

Definition at line 27 of file assert.cc.

References ProcessorBase::breakpoint(), Dec, Machine::getSerial(), Hex, ProcessorBase::m_Initialised, and panic().

◆ _assert_ptr_valid()

bool _assert_ptr_valid ( uintptr_t  x)

Definition at line 1511 of file SlamAllocator.cc.

◆ installSerialLogger()

void installSerialLogger ( )
extern

Definition at line 41 of file SerialLog.cc.

◆ panic()

void EXPORTED_PUBLIC panic ( const char *  msg)

Prints out a message to the screen and the most recent log entries and halts the processor. This function should only be called in unrecoverable emergency cases, e.g. when the kernel is unable to successfully complete its initialisation.

Note
This function and all functions called from this function may not allocate any resources, e.g. no I/O port & memory-region allocations and even no 'normal' memory allocations.
Parameters
[in]msgthe message to print to the screen

Definition at line 117 of file panic.cc.

References GraphicsService::GraphicsProvider::bTextModes, Machine::displayShutdownMessage(), SerialIO::drawString(), ServiceManager::enumerateOperations(), Machine::getSerial(), ServiceManager::getService(), ProcessorBase::halt(), KernelElf::instance(), ProcessorBase::pause(), ServiceFeatures::probe, ServiceFeatures::provides(), Service::serve(), ProcessorBase::setInterrupts(), Display::setScreenMode(), Machine::stopAllOtherProcessors(), and ProcessorBase::tlbInvalidationTerminal().

Referenced by _assert(), Spinlock::acquire(), Spinlock::acquireContended(), Log::addEntry(), Ehci::addInterruptInHandler(), PerProcessorScheduler::addThread(), PerProcessorScheduler::addThread(), SlamAllocator::allocate(), HostedPhysicalMemoryManager::allocatePage(), X86CommonPhysicalMemoryManager::allocatePage(), HostedPhysicalMemoryManager::allocateRegion(), X86CommonPhysicalMemoryManager::allocateRegion(), Archive::Archive(), Ehci::cancelAsyncAndDrain(), Xhci::cancelInterruptInAndDrain(), Ehci::cancelInterruptInAndDrain(), Ohci::cancelInterruptInAndDrain(), Uhci::cancelInterruptInAndDrain(), UsbHubDevice::cancelInterruptInAndDrain(), PerProcessorScheduler::checkEventState(), Pc::deinitialise(), AtaDisk::doWrite(), PanicCommand::execute(), X86CommonPhysicalMemoryManager::PageStack::free(), SlamAllocator::freeSlabUnlocked(), Rtl8139::haltController(), HostedVirtualAddressSpace::handleCopyOnWriteFault(), HostedMachine::initialise(), Pc::initialise(), X86CommonPhysicalMemoryManager::initialise(), PerProcessorScheduler::initialise(), ProcessorBase::initialise1(), HostedMachine::initialise3(), Pc::initialise3(), X86CommonPhysicalMemoryManager::initialise64(), HostedInterruptManager::interrupt(), X64InterruptManager::interrupt(), PageFaultHandler::interrupt(), OwnedThread::join(), AdmittedThread::launchDetached(), OperationBarrier::leave(), HostedVirtualAddressSpace::map(), X64VirtualAddressSpace::mapPageStructures(), SlamAllocator::markSlabReady(), IoPort::read16(), IoPort::read32(), IoPort::read8(), Xhci::releaseDeviceAddress(), PerProcessorScheduler::requestCurrentThreadExitToIdle(), Pic::reservePciRoute(), Rtl8139::resetController(), ScsiDisk::shutdownCache(), ScsiController::shutdownDiskCaches(), Uhci::start(), Debugger::start(), Uhci::stop(), Spinlock::trackRelease(), Ohci::transitionControllerState(), Rtc::uninitialise(), OperationBarrier::wait(), IoPort::write16(), IoPort::write32(), and IoPort::write8().

Variable Documentation

◆ g_BootProgressCurrent

size_t g_BootProgressCurrent
extern

Definition at line 51 of file Log.cc.

◆ g_BootProgressTotal

size_t g_BootProgressTotal
extern

Definition at line 50 of file Log.cc.

◆ g_BootProgressUpdate

BootProgressUpdateFn g_BootProgressUpdate
extern

Definition at line 49 of file Log.cc.