1 /* Etherboot routines for PCBIOS firmware.
3 * Body of routines taken from old pcbios.S
9 #define BIOS_DATA_SEG 0x0040
13 /**************************************************************************
15 Use direct memory access to BIOS variables, longword 0040:006C (ticks
16 today) and byte 0040:0070 (midnight crossover flag) instead of calling
17 timeofday BIOS interrupt.
18 **************************************************************************/
19 #if defined(CONFIG_TSC_CURRTICKS)
20 #undef CONFIG_BIOS_CURRTICKS
22 #define CONFIG_BIOS_CURRTICKS 1
24 #if defined(CONFIG_BIOS_CURRTICKS)
25 unsigned long currticks ( void ) {
26 static uint32_t days = 0;
30 /* Re-enable interrupts so that the timer interrupt can occur
32 REAL_EXEC ( rm_currticks,
40 CLOBBER ( "eax" ) ); /* can't have an empty clobber list */
42 get_real ( ticks, BIOS_DATA_SEG, 0x006c );
43 get_real ( midnight, BIOS_DATA_SEG, 0x0070 );
47 put_real ( midnight, BIOS_DATA_SEG, 0x0070 );
50 return ( days + ticks );
52 #endif /* CONFIG_BIOS_CURRTICKS */
54 /**************************************************************************
55 CPU_NAP - Save power by halting the CPU until the next interrupt
56 **************************************************************************/
57 void cpu_nap ( void ) {
58 REAL_EXEC ( rm_cpu_nap,
65 CLOBBER ( "eax" ) ); /* can't have an empty clobber list */
68 #if (TRY_FLOPPY_FIRST > 0)
69 /**************************************************************************
70 DISK_INIT - Initialize the disk system
71 **************************************************************************/
72 void disk_init ( void ) {
73 REAL_EXEC ( rm_disk_init,
82 CLOBBER ( "eax", "ebx", "ecx", "edx",
83 "ebp", "esi", "edi" ) );
86 /**************************************************************************
87 DISK_READ - Read a sector from disk
88 **************************************************************************/
89 unsigned int pcbios_disk_read ( int drive, int cylinder, int head, int sector,
91 uint16_t ax, flags, discard_c, discard_d;
92 segoff_t buf = SEGOFF ( fixme_buf );
94 /* FIXME: buf should be passed in as a segoff_t rather than a
98 REAL_EXEC ( rm_pcbios_disk_read,
100 "pushl %%ebx\n\t" /* Convert %ebx to %es:bx */
103 "movb $0x02, %%ah\n\t" /* INT 13,2 - Read disk sector */
104 "movb $0x01, %%al\n\t" /* Read one sector */
110 OUT_CONSTRAINTS ( "=a" ( ax ), "=b" ( flags ),
111 "=c" ( discard_c ), "=d" ( discard_d ) ),
112 IN_CONSTRAINTS ( "c" ( ( ( cylinder & 0xff ) << 8 ) |
113 ( ( cylinder >> 8 ) & 0x3 ) |
115 "d" ( ( head << 8 ) | drive ),
117 CLOBBER ( "ebp", "esi", "edi" ) );
120 return ( flags & CF ) ? ax : 0;
122 #endif /* TRY_FLOPPY_FIRST */