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