processor.h 921 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * (C) Copyright 2002
  3. * Daniel Engström, Omicron Ceti AB, daniel@omicron.se
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #ifndef __ASM_PROCESSOR_H_
  8. #define __ASM_PROCESSOR_H_ 1
  9. #define X86_GDT_ENTRY_SIZE 8
  10. #ifndef __ASSEMBLY__
  11. enum {
  12. X86_GDT_ENTRY_NULL = 0,
  13. X86_GDT_ENTRY_UNUSED,
  14. X86_GDT_ENTRY_32BIT_CS,
  15. X86_GDT_ENTRY_32BIT_DS,
  16. X86_GDT_ENTRY_32BIT_FS,
  17. X86_GDT_ENTRY_16BIT_CS,
  18. X86_GDT_ENTRY_16BIT_DS,
  19. X86_GDT_NUM_ENTRIES
  20. };
  21. #else
  22. /* NOTE: If the above enum is modified, this define must be checked */
  23. #define X86_GDT_ENTRY_32BIT_DS 3
  24. #define X86_GDT_NUM_ENTRIES 7
  25. #endif
  26. #define X86_GDT_SIZE (X86_GDT_NUM_ENTRIES * X86_GDT_ENTRY_SIZE)
  27. #ifndef __ASSEMBLY__
  28. static inline __attribute__((always_inline)) void cpu_hlt(void)
  29. {
  30. asm("hlt");
  31. }
  32. static inline ulong cpu_get_sp(void)
  33. {
  34. ulong result;
  35. asm volatile(
  36. "mov %%esp, %%eax"
  37. : "=a" (result));
  38. return result;
  39. }
  40. #endif /* __ASSEMBLY__ */
  41. #endif