kernel/state/subcats/cpu.rs
1// SPDX-License-Identifier: GPL-3.0-only
2//! Per-CPU state and SMP topology placeholder for [`KState`].
3//!
4//! Authors: MarioS271
5
6use crate::config;
7use crate::arch::tables;
8
9/// Per-CPU descriptor tables: one TSS and GDT per CPU, plus the shared IDT.
10pub struct Cpu {
11 pub tss: [tables::tss::Tss; config::MAX_CPUS],
12 pub gdt: [tables::gdt::Gdt; config::MAX_CPUS],
13 pub idt: tables::idt::Idt,
14}
15impl Cpu {
16 /// Construct with a default TSS and GDT for every CPU and a fresh IDT.
17 pub const fn new() -> Self {
18 Self {
19 tss: [const { tables::tss::Tss::new() }; config::MAX_CPUS],
20 gdt: [const { tables::gdt::Gdt::new() }; config::MAX_CPUS],
21 idt: tables::idt::Idt::new(),
22 }
23 }
24}