#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <pxe.h>
#include <realmode.h>
#include <bios.h>
#include <pnpbios.h>
#include <basemem.h>
#include <gpxe/pci.h>
#include <undi.h>
#include <undirom.h>
#include <undiload.h>
Go to the source code of this file.
Defines | |
| #define | undi_loader __use_data16 ( undi_loader ) |
| #define | undi_loader_entry __use_data16 ( undi_loader_entry ) |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER) | |
| static struct s_UNDI_LOADER | __bss16 (undi_loader) |
| Parameter block for calling UNDI loader. | |
| static SEGOFF16_t | __bss16 (undi_loader_entry) |
| UNDI loader entry point. | |
| int | undi_load (struct undi_device *undi, struct undi_rom *undirom) |
| Call UNDI loader to create a pixie. | |
| int | undi_unload (struct undi_device *undi) |
| Unload a pixie. | |
Definition in file undiload.c.
| #define undi_loader __use_data16 ( undi_loader ) |
| #define undi_loader_entry __use_data16 ( undi_loader_entry ) |
| FILE_LICENCE | ( | GPL2_OR_LATER | ) |
| static struct s_UNDI_LOADER __bss16 | ( | undi_loader | ) | [static, read] |
Parameter block for calling UNDI loader.
| static SEGOFF16_t __bss16 | ( | undi_loader_entry | ) | [static] |
UNDI loader entry point.
| int undi_load | ( | struct undi_device * | undi, | |
| struct undi_rom * | undirom | |||
| ) |
Call UNDI loader to create a pixie.
| undi | UNDI device | |
| undirom | UNDI ROM |
| rc | Return status code |
Definition at line 55 of file undiload.c.
References __asm__(), __from_data16, BIOS_SEG, undi_rom::code_size, copy_from_real, undi_rom::data_size, DBG, DBGC, EBUSY, EIO, undi_device::entry, s_PXE::EntryPointSP, undi_device::fbms, find_pnp_bios(), gateA20_set(), get_fbms(), undi_device::isapnp_csn, undi_device::isapnp_read_port, undi_rom::loader_entry, memset(), s_SEGOFF16::offset, undi_device::pci_busdevfn, PCI_FUNC, PCI_SLOT, undi_device::ppxe, undi_device::pxenv, PXENV_EXIT_SUCCESS, REAL_CODE, undi_device::restore_fbms, s_SEGOFF16::segment, set_fbms(), strerror(), undi_loader, undi_loader_entry, UNDI_NO_ISAPNP_CSN, and UNDI_NO_PCI_BUSDEVFN.
Referenced by undi_load_pci().
00055 { 00056 struct s_PXE ppxe; 00057 unsigned int fbms_seg; 00058 uint16_t exit; 00059 int rc; 00060 00061 /* Only one UNDI instance may be loaded at any given time */ 00062 if ( undi_loader_entry.segment ) { 00063 DBG ( "UNDI %p cannot load multiple instances\n", undi ); 00064 return -EBUSY; 00065 } 00066 00067 /* Set up START_UNDI parameters */ 00068 memset ( &undi_loader, 0, sizeof ( undi_loader ) ); 00069 undi_loader.AX = undi->pci_busdevfn; 00070 undi_loader.BX = undi->isapnp_csn; 00071 undi_loader.DX = undi->isapnp_read_port; 00072 undi_loader.ES = BIOS_SEG; 00073 undi_loader.DI = find_pnp_bios(); 00074 00075 /* Allocate base memory for PXE stack */ 00076 undi->restore_fbms = get_fbms(); 00077 fbms_seg = ( undi->restore_fbms << 6 ); 00078 fbms_seg -= ( ( undirom->code_size + 0x0f ) >> 4 ); 00079 undi_loader.UNDI_CS = fbms_seg; 00080 fbms_seg -= ( ( undirom->data_size + 0x0f ) >> 4 ); 00081 undi_loader.UNDI_DS = fbms_seg; 00082 00083 /* Debug info */ 00084 DBGC ( undi, "UNDI %p loading UNDI ROM %p to CS %04x DS %04x for ", 00085 undi, undirom, undi_loader.UNDI_CS, undi_loader.UNDI_DS ); 00086 if ( undi->pci_busdevfn != UNDI_NO_PCI_BUSDEVFN ) { 00087 unsigned int bus = ( undi->pci_busdevfn >> 8 ); 00088 unsigned int devfn = ( undi->pci_busdevfn & 0xff ); 00089 DBGC ( undi, "PCI %02x:%02x.%x\n", 00090 bus, PCI_SLOT ( devfn ), PCI_FUNC ( devfn ) ); 00091 } 00092 if ( undi->isapnp_csn != UNDI_NO_ISAPNP_CSN ) { 00093 DBGC ( undi, "ISAPnP(%04x) CSN %04x\n", 00094 undi->isapnp_read_port, undi->isapnp_csn ); 00095 } 00096 00097 /* Call loader */ 00098 undi_loader_entry = undirom->loader_entry; 00099 __asm__ __volatile__ ( REAL_CODE ( "pushw %%ds\n\t" 00100 "pushw %%ax\n\t" 00101 "lcall *undi_loader_entry\n\t" 00102 "addw $4, %%sp\n\t" ) 00103 : "=a" ( exit ) 00104 : "a" ( __from_data16 ( &undi_loader ) ) 00105 : "ebx", "ecx", "edx", "esi", "edi", "ebp" ); 00106 00107 /* UNDI API calls may rudely change the status of A20 and not 00108 * bother to restore it afterwards. Intel is known to be 00109 * guilty of this. 00110 * 00111 * Note that we will return to this point even if A20 gets 00112 * screwed up by the UNDI driver, because Etherboot always 00113 * resides in an even megabyte of RAM. 00114 */ 00115 gateA20_set(); 00116 00117 if ( exit != PXENV_EXIT_SUCCESS ) { 00118 /* Clear entry point */ 00119 memset ( &undi_loader_entry, 0, sizeof ( undi_loader_entry ) ); 00120 00121 rc = -undi_loader.Status; 00122 if ( rc == 0 ) /* Paranoia */ 00123 rc = -EIO; 00124 DBGC ( undi, "UNDI %p loader failed: %s\n", 00125 undi, strerror ( rc ) ); 00126 return rc; 00127 } 00128 00129 /* Populate PXE device structure */ 00130 undi->pxenv = undi_loader.PXENVptr; 00131 undi->ppxe = undi_loader.PXEptr; 00132 copy_from_real ( &ppxe, undi->ppxe.segment, undi->ppxe.offset, 00133 sizeof ( ppxe ) ); 00134 undi->entry = ppxe.EntryPointSP; 00135 DBGC ( undi, "UNDI %p loaded PXENV+ %04x:%04x !PXE %04x:%04x " 00136 "entry %04x:%04x\n", undi, undi->pxenv.segment, 00137 undi->pxenv.offset, undi->ppxe.segment, undi->ppxe.offset, 00138 undi->entry.segment, undi->entry.offset ); 00139 00140 /* Update free base memory counter */ 00141 undi->fbms = ( fbms_seg >> 6 ); 00142 set_fbms ( undi->fbms ); 00143 DBGC ( undi, "UNDI %p using [%d,%d) kB of base memory\n", 00144 undi, undi->fbms, undi->restore_fbms ); 00145 00146 return 0; 00147 }
| int undi_unload | ( | struct undi_device * | undi | ) |
Unload a pixie.
| undi | UNDI device |
| rc | Return status code |
Definition at line 158 of file undiload.c.
References DBGC, EBUSY, undi_device::fbms, get_fbms(), memset(), s_SEGOFF16::offset, undi_device::ppxe, put_real, undi_device::pxenv, undi_device::restore_fbms, s_SEGOFF16::segment, set_fbms(), and undi_loader_entry.
Referenced by undipci_probe(), and undipci_remove().
00158 { 00159 static uint32_t dead = 0xdeaddead; 00160 00161 DBGC ( undi, "UNDI %p unloading\n", undi ); 00162 00163 /* Clear entry point */ 00164 memset ( &undi_loader_entry, 0, sizeof ( undi_loader_entry ) ); 00165 00166 /* Erase signatures */ 00167 if ( undi->pxenv.segment ) 00168 put_real ( dead, undi->pxenv.segment, undi->pxenv.offset ); 00169 if ( undi->ppxe.segment ) 00170 put_real ( dead, undi->ppxe.segment, undi->ppxe.offset ); 00171 00172 /* Free base memory, if possible */ 00173 if ( undi->fbms == get_fbms() ) { 00174 DBGC ( undi, "UNDI %p freeing [%d,%d) kB of base memory\n", 00175 undi, undi->fbms, undi->restore_fbms ); 00176 set_fbms ( undi->restore_fbms ); 00177 return 0; 00178 } else { 00179 DBGC ( undi, "UNDI %p leaking [%d,%d) kB of base memory\n", 00180 undi, undi->fbms, undi->restore_fbms ); 00181 return -EBUSY; 00182 } 00183 }
1.5.7.1