gateA20.h File Reference

Go to the source code of this file.

Functions

void gateA20_set (void)
void gateA20_unset (void)


Function Documentation

void gateA20_set ( void   ) 

Definition at line 100 of file gateA20.c.

00100                           {
00101         static char reentry_guard = 0;
00102         static int a20_method = A20_UNKNOWN;
00103         unsigned int discard_a;
00104         unsigned int scp_a;
00105         int retries = 0;
00106 
00107         /* Avoid potential infinite recursion */
00108         if ( reentry_guard )
00109                 return;
00110         reentry_guard = 1;
00111 
00112         /* Fast check to see if gate A20 is already enabled */
00113         if ( gateA20_is_set ( 0 ) )
00114                 goto out;
00115 
00116         for ( ; retries < A20_MAX_RETRIES ; retries++ ) {
00117                 switch ( a20_method ) {
00118                 case A20_UNKNOWN:
00119                 case A20_INT15:
00120                         /* Try INT 15 method */
00121                         __asm__ __volatile__ ( REAL_CODE ( "int $0x15" )
00122                                                : "=a" ( discard_a )
00123                                                : "a" ( Enable_A20 ) );
00124                         if ( gateA20_is_set ( A20_INT15_RETRIES ) ) {
00125                                 DBG ( "Enabled gate A20 using BIOS\n" );
00126                                 a20_method = A20_INT15;
00127                                 goto out;
00128                         }
00129                         /* fall through */
00130                 case A20_KBC:
00131                         /* Try keyboard controller method */
00132                         empty_8042();
00133                         outb ( KC_CMD_WOUT, K_CMD );
00134                         empty_8042();
00135                         outb ( KB_SET_A20, K_RDWR );
00136                         empty_8042();
00137                         outb ( KC_CMD_NULL, K_CMD );
00138                         empty_8042();
00139                         if ( gateA20_is_set ( A20_KBC_RETRIES ) ) {
00140                                 DBG ( "Enabled gate A20 using "
00141                                       "keyboard controller\n" );
00142                                 a20_method = A20_KBC;
00143                                 goto out;
00144                         }
00145                         /* fall through */
00146                 case A20_SCPA:
00147                         /* Try "Fast gate A20" method */
00148                         scp_a = inb ( SCP_A );
00149                         scp_a &= ~0x01; /* Avoid triggering a reset */
00150                         scp_a |= 0x02; /* Enable A20 */
00151                         iodelay();
00152                         outb ( scp_a, SCP_A );
00153                         iodelay();
00154                         if ( gateA20_is_set ( A20_SCPA_RETRIES ) ) {
00155                                 DBG ( "Enabled gate A20 using "
00156                                       "Fast Gate A20\n" );
00157                                 a20_method = A20_SCPA;
00158                                 goto out;
00159                         }
00160                 }
00161         }
00162 
00163         /* Better to die now than corrupt memory later */
00164         printf ( "FATAL: Gate A20 stuck\n" );
00165         while ( 1 ) {}
00166 
00167  out:
00168         if ( retries )
00169                 DBG ( "%d attempts were required to enable A20\n",
00170                       ( retries + 1 ) );
00171         reentry_guard = 0;
00172 }

void gateA20_unset ( void   ) 

Definition at line 174 of file gateA20.c.

Referenced by nbi_boot16().

00174                             {
00175         /* Not currently implemented */
00176 }


Generated on Tue Apr 6 20:01:12 2010 for gPXE by  doxygen 1.5.7.1