mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 08:24:32 -08:00
In order to avoid cyclic dependencies in the case of page faults while bringing up an AP, pre-allocate the cpu_data structure and related CPU control structures, and pass them to the AP startup code. This also changes the following: - cpu_early_init() was split out of cpu_early_init() to allow early usage of current_cpu() on the BSP before we're ready for the rest of cpu_init(). (These functions were also renamed to follow the preferred area_action naming style.) - isr_handler now zeroes out the IST entry for its vector instead of trying to increment the IST stack pointer - the IST stacks are allocated outside of cpu_init, to also help reduce stack pressue and chance of page faults before APs are ready - share stack areas between AP idle threads so we only waste 1K per additional AP for the unused idle stack
40 lines
1003 B
C++
40 lines
1003 B
C++
#pragma once
|
|
/// \file tss.h
|
|
/// Definitions relating to the TSS
|
|
#include <stdint.h>
|
|
|
|
/// The 64bit TSS table
|
|
class TSS
|
|
{
|
|
public:
|
|
TSS();
|
|
|
|
/// Get the currently running CPU's TSS.
|
|
static TSS & current();
|
|
|
|
/// Ring stack accessor. Returns a mutable reference.
|
|
/// \arg ring Which ring (0-3) to get the stack for
|
|
/// \returns A mutable reference to the stack pointer
|
|
uintptr_t & ring_stack(unsigned ring);
|
|
|
|
/// IST stack accessor. Returns a mutable reference.
|
|
/// \arg ist Which IST entry (1-7) to get the stack for
|
|
/// \returns A mutable reference to the stack pointer
|
|
uintptr_t & ist_stack(unsigned ist);
|
|
|
|
/// Allocate new stacks for the given IST entries.
|
|
/// \arg ist_entries A bitmap of used IST entries
|
|
void create_ist_stacks(uint8_t ist_entries);
|
|
|
|
private:
|
|
uint32_t m_reserved0;
|
|
|
|
uintptr_t m_rsp[3]; // stack pointers for CPL 0-2
|
|
uintptr_t m_ist[8]; // ist[0] is reserved
|
|
|
|
uint64_t m_reserved1;
|
|
uint16_t m_reserved2;
|
|
uint16_t m_iomap_offset;
|
|
} __attribute__ ((packed));
|
|
|