IgrOS-Kernel 0.1.34.545
Simple C++20 Kernel for i386/x86_64
Loading...
Searching...
No Matches
igros::x86 Namespace Reference

Code shared by i386 and x86_64: ports, interrupts, exceptions, paging. More...

Namespaces

namespace  anonymous_namespace{paging.cpp}
 Paging state.

Classes

class  except
 Exceptions structure. More...
class  io
 I/O structure. More...
class  irq
 IRQ structure. More...
class  paging
 Paging. More...

Typedefs

using port_t = igros_word_t
 Define port data type which is 16bit word.
using isr_t = std::add_pointer_t<void(const register_t* const)>
 Interrupt service routine handler type.

Enumerations

enum class  CR0 : igros_usize_t {
  PE = 0x00000001 , MP = 0x00000002 , EM = 0x00000004 , TS = 0x00000008 ,
  ET = 0x00000010 , NE = 0x00000020 , WP = 0x00010000 , AM = 0x00040000 ,
  NW = 0x20000000 , CD = 0x40000000 , PG = 0x80000000
}
 CR0 register bits. More...
enum class  irq_t : igros_dword_t {
  PIT = 0_u32 , KEYBOARD = 1_u32 , CASCADE = 2_u32 , UART2 = 3_u32 ,
  UART1 = 4_u32 , LPT2 = 5_u32 , FLOPPY = 6_u32 , LPT1 = 7_u32 ,
  RTC = 8_u32 , ACPI = 9_u32 , FREE_10 = 10_u32 , FREE_11 = 11_u32 ,
  MOUSE = 12_u32 , FPU = 13_u32 , ATA_PRIMARY = 14_u32 , ATA_SECONDARY = 15_u32
}
 Interrupts number enumeration (PIC lines). More...

Functions

constexpr auto irqVector (const irq_t line) noexcept -> igros_usize_t
 Interrupt vector of IRQ line.
constexpr auto isIrqVector (const igros_usize_t vector) noexcept -> bool
 Check if interrupt vector belongs to IRQ line.
constexpr auto irqFromVector (const igros_usize_t vector) noexcept -> irq_t
 IRQ line of interrupt vector (vector must be IRQ vector).
void isrHandlerInstall (const igros_usize_t number, const isr_t handle) noexcept
 Install interrupt service routine handler.
void isrHandlerUninstall (const igros_usize_t number) noexcept
 Uninstall interrupt service routine handler.
static constexpr auto flag (const paging::FLAGS value) noexcept -> paging::entry_t
 Entry flag value.
static constexpr auto hasFlag (const paging::entry_t entry, const paging::FLAGS value) noexcept -> bool
 Is flag set in entry.
static void platformInit () noexcept
 Initialize x86.
static void platformFinalize () noexcept
 Finalize x86.
static void platformShutdown () noexcept
 Shutdown x86.
static void platformReboot () noexcept
 Reboot x86.
static void platformSuspend () noexcept
 Suspend x86.
static void platformWakeup () noexcept
 Wakeup x86.

Variables

constexpr auto PIC_MASTER_CONTROL {static_cast<port_t>(0x0020_u16)}
 Master PIC command port.
constexpr auto PIC_MASTER_DATA {static_cast<port_t>(PIC_MASTER_CONTROL + 1_u16)}
 Master PIC data (mask) port.
constexpr auto PIC_SLAVE_CONTROL {static_cast<port_t>(0x00A0_u16)}
 Slave PIC command port.
constexpr auto PIC_SLAVE_DATA {static_cast<port_t>(PIC_SLAVE_CONTROL + 1_u16)}
 Slave PIC data (mask) port.
constexpr auto IRQ_LINES {16_usize}
 Number of PIC interrupt lines.
static constinit auto isrList {std::array<isr_t, ISR_SIZE> {}}
 Interrupt handlers.
constexpr auto IRQ_OFFSET {32_usize}
 IRQ offset in ISR list.
constexpr auto ISR_SIZE {256_usize}
 ISR list size.
constexpr auto ARCH_NAME {"x86_64"}
 Current architecture.

Detailed Description

Code shared by i386 and x86_64: ports, interrupts, exceptions, paging.

Typedef Documentation

◆ isr_t

using igros::x86::isr_t = std::add_pointer_t<void(const register_t* const)>

Interrupt service routine handler type.

Definition at line 35 of file isr.hpp.

◆ port_t

Define port data type which is 16bit word.

Definition at line 25 of file io.hpp.

Enumeration Type Documentation

◆ CR0

enum class igros::x86::CR0 : igros_usize_t
strong

CR0 register bits.

Enumerator
PE 

Protected mode enable.

MP 

Monitor coprocessor.

EM 

x87 emulation

TS 

Task switched.

ET 

Extension type.

NE 

Native x87 errors.

WP 

Write protect (kernel can't write to read-only pages).

AM 

Alignment mask.

NW 

Not write-through.

CD 

Cache disable.

PG 

Paging enable.

Definition at line 25 of file cr.hpp.

◆ irq_t

enum class igros::x86::irq_t : igros_dword_t
strong

Interrupts number enumeration (PIC lines).

Enumerator
CASCADE 

Slave PIC.

LPT1 

Master PIC spurious.

ATA_SECONDARY 

Slave PIC spurious.

Definition at line 62 of file irq.hpp.

Function Documentation

◆ flag()

constexpr auto igros::x86::flag ( const paging::FLAGS value) ->paging::entry_t
staticnodiscardconstexprnoexcept

Entry flag value.

Parameters
valueFlag
Returns
Flag bits in entry

Definition at line 60 of file paging.cpp.

◆ hasFlag()

constexpr auto igros::x86::hasFlag ( const paging::entry_t entry,
const paging::FLAGS value )->bool
staticnodiscardconstexprnoexcept

Is flag set in entry.

Parameters
entryTable entry
valueFlag
Returns
true if flag is set in entry

Definition at line 69 of file paging.cpp.

◆ irqFromVector()

auto igros::x86::irqFromVector ( const igros_usize_t vector) ->irq_t
nodiscardconstexprnoexcept

IRQ line of interrupt vector (vector must be IRQ vector).

Parameters
vectorIRQ interrupt vector
Returns
IRQ line

Definition at line 105 of file irq.hpp.

◆ irqVector()

auto igros::x86::irqVector ( const irq_t line) ->igros_usize_t
nodiscardconstexprnoexcept

Interrupt vector of IRQ line.

Parameters
lineIRQ line
Returns
Interrupt vector

Definition at line 89 of file irq.hpp.

◆ isIrqVector()

auto igros::x86::isIrqVector ( const igros_usize_t vector) ->bool
nodiscardconstexprnoexcept

Check if interrupt vector belongs to IRQ line.

Parameters
vectorInterrupt vector
Returns
true if vector is an IRQ vector

Definition at line 97 of file irq.hpp.

◆ isrHandlerInstall()

void igros::x86::isrHandlerInstall ( const igros_usize_t number,
const isr_t handle )
noexcept

Install interrupt service routine handler.

Parameters
numberInterrupt vector
handleHandler

Definition at line 31 of file isr.cpp.

◆ isrHandlerUninstall()

void igros::x86::isrHandlerUninstall ( const igros_usize_t number)
noexcept

Uninstall interrupt service routine handler.

Parameters
numberInterrupt vector

Definition at line 37 of file isr.cpp.

◆ platformFinalize()

void igros::x86::platformFinalize ( )
staticnoexcept

Finalize x86.

Definition at line 91 of file platform-x86.cpp.

◆ platformInit()

void igros::x86::platformInit ( )
staticnoexcept

Initialize x86.

Definition at line 54 of file platform-x86.cpp.

◆ platformReboot()

void igros::x86::platformReboot ( )
staticnoexcept

Reboot x86.

Definition at line 109 of file platform-x86.cpp.

◆ platformShutdown()

void igros::x86::platformShutdown ( )
staticnoexcept

Shutdown x86.

Definition at line 100 of file platform-x86.cpp.

◆ platformSuspend()

void igros::x86::platformSuspend ( )
staticnoexcept

Suspend x86.

Definition at line 118 of file platform-x86.cpp.

◆ platformWakeup()

void igros::x86::platformWakeup ( )
staticnoexcept

Wakeup x86.

Definition at line 127 of file platform-x86.cpp.

Variable Documentation

◆ ARCH_NAME

auto igros::x86::ARCH_NAME {"x86_64"}
constexpr

Current architecture.

Current architecture name

Definition at line 51 of file native.hpp.

◆ IRQ_LINES

auto igros::x86::IRQ_LINES {16_usize}
constexpr

Number of PIC interrupt lines.

Definition at line 82 of file irq.hpp.

◆ IRQ_OFFSET

auto igros::x86::IRQ_OFFSET {32_usize}
constexpr

IRQ offset in ISR list.

Definition at line 30 of file isr.hpp.

◆ ISR_SIZE

auto igros::x86::ISR_SIZE {256_usize}
constexpr

ISR list size.

Definition at line 32 of file isr.hpp.

◆ isrList

auto igros::x86::isrList {std::array<isr_t, ISR_SIZE> {}}
staticconstinit

Interrupt handlers.

Definition at line 27 of file isr.cpp.

◆ PIC_MASTER_CONTROL

auto igros::x86::PIC_MASTER_CONTROL {static_cast<port_t>(0x0020_u16)}
constexpr

Master PIC command port.

Definition at line 54 of file irq.hpp.

◆ PIC_MASTER_DATA

auto igros::x86::PIC_MASTER_DATA {static_cast<port_t>(PIC_MASTER_CONTROL + 1_u16)}
constexpr

Master PIC data (mask) port.

Definition at line 55 of file irq.hpp.

◆ PIC_SLAVE_CONTROL

auto igros::x86::PIC_SLAVE_CONTROL {static_cast<port_t>(0x00A0_u16)}
constexpr

Slave PIC command port.

Definition at line 57 of file irq.hpp.

◆ PIC_SLAVE_DATA

auto igros::x86::PIC_SLAVE_DATA {static_cast<port_t>(PIC_SLAVE_CONTROL + 1_u16)}
constexpr

Slave PIC data (mask) port.

Definition at line 58 of file irq.hpp.