Untitled_Kernel/include/tss.h
lordtet 7b4e4afd43 Defined a couple of functions, added documentation templates
Didn't feel the need to make a new branch for this one, but i added some
doxygen documentation templates to all of the headers. It's a bit
overdue.
2025-07-17 07:36:45 -04:00

64 lines
2.3 KiB
C

/**
* @file tss.h
* @brief Task State Segment (TSS) definitions and structures
* @author Jake Holtham
* @date 2025
*
* This header file contains the structure definitions for the x86 Task State Segment (TSS).
*/
#ifndef TSS_H
#define TSS_H
#include <stdint.h>
/**
* @brief Task State Segment structure
*
* Data structure that contains information about a task,
* including the state of the processor registers, stack pointers, and other task-specific
* information. It is used by the x86 architecture for task switching and interrupt handling.
*
* Packed to make sure it's aligned and the correct size.
*
* @note This structure must be aligned on a 4byte boundary
*/
typedef struct tss_s {
uint32_t LINK; /**< Previous TSS selector*/
uint32_t ESP0; /**< Stack pointer for privilege level0*/
uint32_t SS0; /**< Stack segment for privilege level0*/
uint32_t ESP1; /**< Stack pointer for privilege level1*/
uint32_t SS1; /**< Stack segment for privilege level1*/
uint32_t ESP2; /**< Stack pointer for privilege level2*/
uint32_t SS2; /**< Stack segment for privilege level2*/
uint32_t CR3; /**< Page Directory register */
uint32_t EIP; /**< Instruction pointer */
uint32_t EFLAGS; /**< Flags register */
uint32_t EAX; /**< General purpose */
uint32_t ECX; /**< General purpose */
uint32_t EDX; /**< General purpose */
uint32_t EBX; /**< General purpose */
uint32_t ESP; /**< Stack pointer */
uint32_t ESI; /**< Source index register */
uint32_t EDI; /**< Destination index register */
uint32_t ES; /**< Extra segment register */
uint32_t CS; /**< Code segment register */
uint32_t SS; /**< Stack segment register */
uint32_t DS; /**< Data segment register */
uint32_t FS; /**< Extra segment register FS */
uint32_t GS; /**< Extra segment register GS */
uint32_t LDTR; /**< Local descriptor table register */
uint32_t IOPB; /**< I/O permission bitmap offset */
uint32_t SSP; /**< Stack segment pointer */
} __attribute__((packed)) tss_t;
/**
* @brief Global TSS instance
*
* This is the main TSS instance used by the kernel for task management.
* It contains the current task's state information.
* Defined in assembly.
*/
extern tss_t tss;
#endif /* TSS_H */