tss.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef __USERPROG_TSS_H__
  2. #define __USERPROG_TSS_H__
  3. #include "../thread/thread.h"
  4. #include "../lib/stdint.h"
  5. /**
  6. * @file tss.h
  7. * @brief Header file for the Task State Segment (TSS) structure.
  8. *
  9. * This file contains the definition of the TSS structure used in the
  10. * operating system kernel's user program module. The TSS is used to
  11. * store information about a task, such as stack pointers and segment
  12. * selectors, which are essential for task switching in protected mode.
  13. */
  14. typedef struct tss
  15. {
  16. uint32_t backlink;
  17. uint32_t *esp0;
  18. uint32_t ss0;
  19. uint32_t *esp1;
  20. uint32_t ss1;
  21. uint32_t *esp2;
  22. uint32_t ss2;
  23. uint32_t cr3;
  24. uint32_t (*eip)(void);
  25. uint32_t eflags;
  26. uint32_t eax;
  27. uint32_t ecx;
  28. uint32_t edx;
  29. uint32_t ebx;
  30. uint32_t esp;
  31. uint32_t ebp;
  32. uint32_t esi;
  33. uint32_t edi;
  34. uint32_t es;
  35. uint32_t cs;
  36. uint32_t ss;
  37. uint32_t ds;
  38. uint32_t fs;
  39. uint32_t gs;
  40. uint32_t ldt;
  41. uint32_t trap;
  42. uint32_t iomap;
  43. } Tss;
  44. /// @brief 更新 tss 中 esp0 字段的值为 pthread 的 0 级线程
  45. /// @param pthread
  46. void update_tss_esp(struct task_struct *pthread);
  47. void tss_init(void);
  48. #endif // !__USERPROG_TSS_H__