You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

bios.c 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* Etherboot routines for PCBIOS firmware.
  2. *
  3. * Body of routines taken from old pcbios.S
  4. */
  5. #include <stdint.h>
  6. #include <realmode.h>
  7. #include <bios.h>
  8. #define CF ( 1 << 0 )
  9. /**************************************************************************
  10. CURRTICKS - Get Time
  11. Use direct memory access to BIOS variables, longword 0040:006C (ticks
  12. today) and byte 0040:0070 (midnight crossover flag) instead of calling
  13. timeofday BIOS interrupt.
  14. **************************************************************************/
  15. #if defined(CONFIG_TSC_CURRTICKS)
  16. #undef CONFIG_BIOS_CURRTICKS
  17. #else
  18. #define CONFIG_BIOS_CURRTICKS 1
  19. #endif
  20. #if defined(CONFIG_BIOS_CURRTICKS)
  21. unsigned long currticks ( void ) {
  22. static uint32_t days = 0;
  23. uint32_t ticks;
  24. uint8_t midnight;
  25. /* Re-enable interrupts so that the timer interrupt can occur
  26. */
  27. __asm__ __volatile__ ( REAL_CODE ( "sti\n\t"
  28. "nop\n\t"
  29. "nop\n\t"
  30. "cli\n\t" ) : : );
  31. get_real ( ticks, BDA_SEG, 0x006c );
  32. get_real ( midnight, BDA_SEG, 0x0070 );
  33. if ( midnight ) {
  34. midnight = 0;
  35. put_real ( midnight, BDA_SEG, 0x0070 );
  36. days += 0x1800b0;
  37. }
  38. return ( days + ticks );
  39. }
  40. #endif /* CONFIG_BIOS_CURRTICKS */
  41. /**************************************************************************
  42. CPU_NAP - Save power by halting the CPU until the next interrupt
  43. **************************************************************************/
  44. void cpu_nap ( void ) {
  45. __asm__ __volatile__ ( REAL_CODE ( "sti\n\t"
  46. "hlt\n\t"
  47. "cli\n\t" ) : : );
  48. }