mirror of
https://github.com/ipxe/ipxe
synced 2026-04-04 03:00:20 +03:00
Created a bus/device API that allows for the ROM prefix to specify an
initial device, and will also allow for e.g. a device menu to be presented to the user.
This commit is contained in:
@@ -408,7 +408,7 @@ static void btext_init(void)
|
||||
|
||||
#warning "pci_find_device_x no longer exists; use find_pci_device instead"
|
||||
/* pci_find_device_x(0x1002, 0x4752, 0, &dev); */
|
||||
if(dev.vendor==0) return; // no fb
|
||||
if(dev.vendor_id==0) return; // no fb
|
||||
|
||||
frame_buffer = (uint32_t)dev.membase;
|
||||
#else
|
||||
|
||||
171
src/core/dev.c
171
src/core/dev.c
@@ -16,51 +16,154 @@
|
||||
* function (probe).
|
||||
*/
|
||||
|
||||
/* Defined by linker */
|
||||
extern struct boot_driver boot_drivers[];
|
||||
extern struct boot_driver boot_drivers_end[];
|
||||
/* Current attempted boot device */
|
||||
struct dev dev = {
|
||||
.bus_driver = bus_drivers,
|
||||
.device_driver = device_drivers,
|
||||
};
|
||||
|
||||
/* Current attempted boot driver */
|
||||
static struct boot_driver *boot_driver = boot_drivers;
|
||||
|
||||
/* Print all drivers */
|
||||
/*
|
||||
* Print all drivers
|
||||
*
|
||||
*/
|
||||
void print_drivers ( void ) {
|
||||
struct boot_driver *driver;
|
||||
struct device_driver *driver;
|
||||
|
||||
for ( driver = boot_drivers ; driver < boot_drivers_end ; driver++ ) {
|
||||
for ( driver = device_drivers ;
|
||||
driver < device_drivers_end ;
|
||||
driver++ ) {
|
||||
printf ( "%s ", driver->name );
|
||||
}
|
||||
}
|
||||
|
||||
/* Get the next available boot device */
|
||||
int find_boot_device ( struct dev *dev ) {
|
||||
for ( ; boot_driver < boot_drivers_end ; boot_driver++ ) {
|
||||
dev->driver = boot_driver;
|
||||
dev->name = boot_driver->name;
|
||||
DBG ( "Probing driver %s...\n", dev->name );
|
||||
if ( boot_driver->find_bus_boot_device ( dev,
|
||||
boot_driver->bus_driver ) ) {
|
||||
DBG ( "Found device %s (ID %hhx:%hx:%hx)\n",
|
||||
dev->name, dev->devid.bus_type,
|
||||
dev->devid.vendor_id, dev->devid.device_id );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Move to the next location on any bus
|
||||
*
|
||||
*/
|
||||
static inline int next_location ( struct bus_driver **bus_driver,
|
||||
struct bus_loc *bus_loc ) {
|
||||
/* Move to next location on this bus, if any */
|
||||
if ( (*bus_driver)->next_location ( bus_loc ) )
|
||||
return 1;
|
||||
|
||||
/* No more boot devices found */
|
||||
boot_driver = boot_drivers;
|
||||
/* Move to first (zeroed) location on next bus, if any */
|
||||
if ( ++(*bus_driver) < bus_drivers_end )
|
||||
return 1;
|
||||
|
||||
/* Reset to first bus, return "no more locations" */
|
||||
*bus_driver = bus_drivers;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Probe the boot device */
|
||||
int probe ( struct dev *dev ) {
|
||||
return dev->driver->probe ( dev, dev->bus );
|
||||
/*
|
||||
* Find the next available device on any bus
|
||||
*
|
||||
* Set skip=1 to skip over the current device
|
||||
*
|
||||
*/
|
||||
int find_any ( struct bus_driver **bus_driver, struct bus_loc *bus_loc,
|
||||
struct bus_dev *bus_dev, signed int skip ) {
|
||||
DBG ( "searching for any device\n" );
|
||||
do {
|
||||
if ( --skip >= 0 )
|
||||
continue;
|
||||
if ( ! (*bus_driver)->fill_device ( bus_dev, bus_loc ) )
|
||||
continue;
|
||||
DBG ( "found device %s\n",
|
||||
(*bus_driver)->describe ( bus_dev ) );
|
||||
return 1;
|
||||
} while ( next_location ( bus_driver, bus_loc ) );
|
||||
|
||||
DBG ( "found no device\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Disable a device */
|
||||
void disable ( struct dev *dev ) {
|
||||
if ( dev->dev_op ) {
|
||||
dev->dev_op->disable ( dev );
|
||||
dev->dev_op = NULL;
|
||||
}
|
||||
/*
|
||||
* Find a driver by specified device.
|
||||
*
|
||||
* Set skip=1 to skip over the current driver
|
||||
*
|
||||
*/
|
||||
int find_by_device ( struct device_driver **device_driver,
|
||||
struct bus_driver *bus_driver, struct bus_dev *bus_dev,
|
||||
signed int skip ) {
|
||||
DBG ( "searching for a driver for device %s\n",
|
||||
bus_driver->describe ( bus_dev ) );
|
||||
do {
|
||||
if ( --skip >= 0 )
|
||||
continue;
|
||||
if ( (*device_driver)->bus_driver != bus_driver )
|
||||
continue;
|
||||
if ( ! bus_driver->check_driver ( bus_dev, *device_driver ))
|
||||
continue;
|
||||
DBG ( "found driver %s\n", (*device_driver)->name );
|
||||
return 1;
|
||||
} while ( ++(*device_driver) < device_drivers_end );
|
||||
|
||||
/* Reset to first driver, return "not found" */
|
||||
DBG ( "found no driver for device %s\n",
|
||||
bus_driver->describe ( bus_dev ) );
|
||||
*device_driver = device_drivers;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find a device by specified driver.
|
||||
*
|
||||
* Set skip=1 to skip over the current device
|
||||
*
|
||||
*/
|
||||
int find_by_driver ( struct bus_loc *bus_loc, struct bus_dev *bus_dev,
|
||||
struct device_driver *device_driver,
|
||||
signed int skip ) {
|
||||
struct bus_driver *bus_driver = device_driver->bus_driver;
|
||||
|
||||
DBG ( "searching for a device for driver %s\n", device_driver->name );
|
||||
do {
|
||||
if ( --skip >= 0 )
|
||||
continue;
|
||||
if ( ! bus_driver->fill_device ( bus_dev, bus_loc ) )
|
||||
continue;
|
||||
if ( ! bus_driver->check_driver ( bus_dev, device_driver ) )
|
||||
continue;
|
||||
DBG ( "found device %s\n", bus_driver->describe ( bus_dev ) );
|
||||
return 1;
|
||||
} while ( bus_driver->next_location ( bus_loc ) );
|
||||
|
||||
DBG ( "found no device for driver %s\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the next available (device,driver) combination
|
||||
*
|
||||
* Set skip=1 to skip over the current (device,driver)
|
||||
*
|
||||
* Note that the struct dev may not have been previously used, and so
|
||||
* may not contain a valid (device,driver) combination.
|
||||
*
|
||||
*/
|
||||
int find_any_with_driver ( struct dev *dev, signed int skip ) {
|
||||
signed int skip_device = 0;
|
||||
signed int skip_driver = skip;
|
||||
|
||||
while ( find_any ( &dev->bus_driver, &dev->bus_loc, &dev->bus_dev,
|
||||
skip_device ) ) {
|
||||
if ( find_by_device ( &dev->device_driver, dev->bus_driver,
|
||||
&dev->bus_dev, skip_driver ) ) {
|
||||
/* Set type_driver to be that of the device
|
||||
* driver
|
||||
*/
|
||||
dev->type_driver = dev->device_driver->type_driver;
|
||||
/* Set type device instance to be the single
|
||||
* instance provided by the type driver
|
||||
*/
|
||||
dev->type_dev = dev->type_driver->type_dev;
|
||||
return 1;
|
||||
}
|
||||
skip_driver = 0;
|
||||
skip_device = 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -143,12 +143,6 @@ static int exit_status;
|
||||
static int initialized;
|
||||
|
||||
|
||||
/* Global instance of the current boot device */
|
||||
DEV_BUS(struct bus_device, dev_bus);
|
||||
struct dev dev = {
|
||||
.bus = &dev_bus,
|
||||
};
|
||||
|
||||
/**************************************************************************
|
||||
* initialise() - perform any C-level initialisation
|
||||
*
|
||||
@@ -169,6 +163,7 @@ void initialise ( void ) {
|
||||
MAIN - Kick off routine
|
||||
**************************************************************************/
|
||||
int main ( void ) {
|
||||
int skip = 0;
|
||||
|
||||
/* Print out configuration */
|
||||
print_config();
|
||||
@@ -181,36 +176,34 @@ int main ( void ) {
|
||||
for ( ; ; disable ( &dev ), call_reset_fns() ) {
|
||||
|
||||
/* Get next boot device */
|
||||
if ( ! find_boot_device ( &dev ) ) {
|
||||
if ( ! find_any_with_driver ( &dev, skip ) ) {
|
||||
/* Reached end of device list */
|
||||
printf ( "No more boot devices\n" );
|
||||
skip = 0;
|
||||
sleep ( 2 );
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Skip this device the next time we encounter it */
|
||||
skip = 1;
|
||||
|
||||
/* Print out what we're doing */
|
||||
printf ( "Booting from %s %s at %s "
|
||||
"using the %s driver\n",
|
||||
dev.bus_driver->name ( &dev.bus_dev ),
|
||||
dev.type_driver->name,
|
||||
dev.bus_driver->describe ( &dev.bus_dev ),
|
||||
dev.device_driver->name );
|
||||
|
||||
/* Probe boot device */
|
||||
if ( ! probe ( &dev ) ) {
|
||||
/* Device found on bus, but probe failed */
|
||||
printf ( "Probe failed on %s, trying next device\n",
|
||||
dev.name );
|
||||
printf ( "...probe failed on %s\n" );
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Print device info */
|
||||
print_info ( &dev );
|
||||
|
||||
/* Load configuration (e.g. DHCP) */
|
||||
if ( ! load_configuration ( &dev ) ) {
|
||||
/* DHCP failed */
|
||||
printf ( "Could not configure device %s\n", dev.name );
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Load image */
|
||||
if ( ! load ( &dev ) )
|
||||
/* Load failed */
|
||||
printf ( "Could not boot from device %s\n", dev.name );
|
||||
continue;
|
||||
printf ( "%s: %s\n", dev.bus_driver->name ( &dev.bus_dev ),
|
||||
dev.type_driver->describe ( dev.type_dev ) );
|
||||
}
|
||||
|
||||
/* Call registered per-object exit functions */
|
||||
@@ -463,8 +456,7 @@ void cleanup(void)
|
||||
nfs_umountall(ARP_SERVER);
|
||||
#endif
|
||||
/* Stop receiving packets */
|
||||
eth_disable();
|
||||
disk_disable();
|
||||
disable ( &dev );
|
||||
initialized = 0;
|
||||
}
|
||||
|
||||
|
||||
113
src/core/nic.c
113
src/core/nic.c
@@ -52,7 +52,7 @@ static unsigned char dhcp_machine_info[] = {
|
||||
/* Our enclosing DHCP tag */
|
||||
RFC1533_VENDOR_ETHERBOOT_ENCAP, 11,
|
||||
/* Our boot device */
|
||||
RFC1533_VENDOR_NIC_DEV_ID, 5, PCI_BUS_TYPE, 0, 0, 0, 0,
|
||||
RFC1533_VENDOR_NIC_DEV_ID, 5, 0, 0, 0, 0, 0,
|
||||
/* Our current architecture */
|
||||
RFC1533_VENDOR_ARCH, 2, EM_CURRENT & 0xff, (EM_CURRENT >> 8) & 0xff,
|
||||
#ifdef EM_CURRENT_64
|
||||
@@ -231,13 +231,10 @@ static int bootp(void);
|
||||
static unsigned short tcpudpchksum(struct iphdr *ip);
|
||||
|
||||
|
||||
struct nic *nic = &dev.nic;
|
||||
|
||||
/*
|
||||
* Find out what our boot parameters are
|
||||
*/
|
||||
static int nic_load_configuration ( struct dev *dev ) {
|
||||
struct nic *nic = &dev->nic;
|
||||
static int nic_load_configuration ( struct nic *nic ) {
|
||||
int server_found;
|
||||
|
||||
if ( ! nic->nic_op->connect ( nic ) ) {
|
||||
@@ -321,35 +318,31 @@ static int nic_load(struct dev *dev __unused)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void nic_disable ( struct dev *dev ) {
|
||||
struct nic *nic = &dev->nic;
|
||||
|
||||
void nic_disable ( struct nic *nic __unused ) {
|
||||
#ifdef MULTICAST_LEVEL2
|
||||
int i;
|
||||
for(i = 0; i < MAX_IGMP; i++) {
|
||||
leave_group(i);
|
||||
}
|
||||
#endif
|
||||
|
||||
nic->nic_op->disable ( nic );
|
||||
}
|
||||
|
||||
static void nic_print_info ( struct dev *dev ) {
|
||||
struct nic *nic = &dev->nic;
|
||||
|
||||
printf ( "Found %s NIC (MAC %!)\n", dev->name, nic->node_addr );
|
||||
static char * nic_describe ( struct type_dev *type_dev ) {
|
||||
struct nic *nic = ( struct nic * ) type_dev;
|
||||
static char nic_description[] = "MAC 00:00:00:00:00:00";
|
||||
|
||||
sprintf ( nic_description + 4, "%!", nic->node_addr );
|
||||
return nic_description;
|
||||
}
|
||||
|
||||
/*
|
||||
* Device operations tables
|
||||
*
|
||||
*/
|
||||
static struct dev_operations nic_operations = {
|
||||
.disable = nic_disable,
|
||||
.print_info = nic_print_info,
|
||||
.load_configuration = nic_load_configuration,
|
||||
.load = nic_load,
|
||||
struct type_driver nic_driver = {
|
||||
.name = "NIC",
|
||||
.type_dev = ( struct type_dev * ) &nic,
|
||||
.describe = nic_describe,
|
||||
};
|
||||
|
||||
/* Careful. We need an aligned buffer to avoid problems on machines
|
||||
@@ -360,19 +353,10 @@ static struct dev_operations nic_operations = {
|
||||
*/
|
||||
static char packet[ETH_FRAME_LEN + ETH_DATA_ALIGN] __aligned;
|
||||
|
||||
/*
|
||||
* Set up a struct dev to operate as a NIC, return the struct nic *
|
||||
*
|
||||
*/
|
||||
struct nic * nic_device ( struct dev *dev ) {
|
||||
struct nic *nic = &dev->nic;
|
||||
|
||||
memset ( nic, 0, sizeof ( *nic ) );
|
||||
nic->node_addr = arptable[ARP_CLIENT].node;
|
||||
nic->packet = packet + ETH_DATA_ALIGN;
|
||||
dev->dev_op = &nic_operations;
|
||||
return nic;
|
||||
}
|
||||
struct nic nic = {
|
||||
.node_addr = arptable[ARP_CLIENT].node,
|
||||
.packet = packet + ETH_DATA_ALIGN,
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -408,9 +392,9 @@ static int await_arp(int ival, void *ptr,
|
||||
struct arprequest *arpreply;
|
||||
if (ptype != ETH_P_ARP)
|
||||
return 0;
|
||||
if (nic->packetlen < ETH_HLEN + sizeof(struct arprequest))
|
||||
if (nic.packetlen < ETH_HLEN + sizeof(struct arprequest))
|
||||
return 0;
|
||||
arpreply = (struct arprequest *)&nic->packet[ETH_HLEN];
|
||||
arpreply = (struct arprequest *)&nic.packet[ETH_HLEN];
|
||||
|
||||
if (arpreply->opcode != htons(ARP_REPLY))
|
||||
return 0;
|
||||
@@ -697,7 +681,7 @@ int tftp_block ( struct tftpreq_info_t *request, struct tftpblk_info_t *block )
|
||||
continue; /* Back to waiting for packet */
|
||||
}
|
||||
/* Packet has been received */
|
||||
rcvd = (struct tftp_t *)&nic->packet[ETH_HLEN];
|
||||
rcvd = (struct tftp_t *)&nic.packet[ETH_HLEN];
|
||||
recvlen = ntohs(rcvd->udp.len) - sizeof(struct udphdr)
|
||||
- sizeof(rcvd->opcode);
|
||||
rport = ntohs(rcvd->udp.src);
|
||||
@@ -777,9 +761,9 @@ static int await_rarp(int ival, void *ptr,
|
||||
struct arprequest *arpreply;
|
||||
if (ptype != ETH_P_RARP)
|
||||
return 0;
|
||||
if (nic->packetlen < ETH_HLEN + sizeof(struct arprequest))
|
||||
if (nic.packetlen < ETH_HLEN + sizeof(struct arprequest))
|
||||
return 0;
|
||||
arpreply = (struct arprequest *)&nic->packet[ETH_HLEN];
|
||||
arpreply = (struct arprequest *)&nic.packet[ETH_HLEN];
|
||||
if (arpreply->opcode != htons(RARP_REPLY))
|
||||
return 0;
|
||||
if ((arpreply->opcode == htons(RARP_REPLY)) &&
|
||||
@@ -841,9 +825,9 @@ static int await_bootp(int ival __unused, void *ptr __unused,
|
||||
if (!udp) {
|
||||
return 0;
|
||||
}
|
||||
bootpreply = (struct bootp_t *)&nic->packet[ETH_HLEN +
|
||||
bootpreply = (struct bootp_t *)&nic.packet[ETH_HLEN +
|
||||
sizeof(struct iphdr) + sizeof(struct udphdr)];
|
||||
if (nic->packetlen < ETH_HLEN + sizeof(struct iphdr) +
|
||||
if (nic.packetlen < ETH_HLEN + sizeof(struct iphdr) +
|
||||
sizeof(struct udphdr) +
|
||||
#ifdef NO_DHCP_SUPPORT
|
||||
sizeof(struct bootp_t)
|
||||
@@ -916,14 +900,7 @@ static int bootp(void)
|
||||
unsigned char *bp_vend;
|
||||
|
||||
#ifndef NO_DHCP_SUPPORT
|
||||
struct {
|
||||
uint8_t bus_type;
|
||||
uint16_t vendor_id;
|
||||
uint16_t device_id;
|
||||
} __attribute__((packed)) *dhcp_dev_id = (void*)&dhcp_machine_info[4];
|
||||
dhcp_dev_id->bus_type = dev.devid.bus_type;
|
||||
dhcp_dev_id->vendor_id = htons ( dev.devid.vendor_id );
|
||||
dhcp_dev_id->device_id = htons ( dev.devid.device_id );
|
||||
* ( ( struct dhcp_dev_id * ) &dhcp_machine_info[4] ) = nic.dhcp_dev_id;
|
||||
#endif /* NO_DHCP_SUPPORT */
|
||||
memset(&ip, 0, sizeof(struct bootpip_t));
|
||||
ip.bp.bp_op = BOOTP_REQUEST;
|
||||
@@ -1089,11 +1066,11 @@ static void process_igmp(struct iphdr *ip, unsigned long now)
|
||||
int i;
|
||||
unsigned iplen;
|
||||
if (!ip || (ip->protocol == IP_IGMP) ||
|
||||
(nic->packetlen < sizeof(struct iphdr) + sizeof(struct igmp))) {
|
||||
(nic.packetlen < sizeof(struct iphdr) + sizeof(struct igmp))) {
|
||||
return;
|
||||
}
|
||||
iplen = (ip->verhdrlen & 0xf)*4;
|
||||
igmp = (struct igmp *)&nic->packet[sizeof(struct iphdr)];
|
||||
igmp = (struct igmp *)&nic.packet[sizeof(struct iphdr)];
|
||||
if (ipchksum(igmp, ntohs(ip->len) - iplen) != 0)
|
||||
return;
|
||||
if ((igmp->type == IGMP_QUERY) &&
|
||||
@@ -1300,7 +1277,7 @@ int tcp_transaction(unsigned long destip, unsigned int destsock, void *ptr,
|
||||
syn_ack = state == CLOSED || state == SYN_RCVD;
|
||||
consumed = ntohl(tcp->ack) - send_seq - syn_ack;
|
||||
if (consumed < 0 || consumed > can_send) {
|
||||
tcp_reset((struct iphdr *)&nic->packet[ETH_HLEN]);
|
||||
tcp_reset((struct iphdr *)&nic.packet[ETH_HLEN]);
|
||||
goto recv_data;
|
||||
}
|
||||
|
||||
@@ -1342,7 +1319,7 @@ int tcp_transaction(unsigned long destip, unsigned int destsock, void *ptr,
|
||||
}
|
||||
|
||||
consume_data:
|
||||
ip = (struct iphdr *)&nic->packet[ETH_HLEN];
|
||||
ip = (struct iphdr *)&nic.packet[ETH_HLEN];
|
||||
header_size = sizeof(struct iphdr) + ((ntohs(tcp->ctrl)>>10)&0x3C);
|
||||
payload = ntohs(ip->len) - header_size;
|
||||
if (payload > 0 && state == ESTABLISHED) {
|
||||
@@ -1351,7 +1328,7 @@ int tcp_transaction(unsigned long destip, unsigned int destsock, void *ptr,
|
||||
recv_seq += payload - old_bytes;
|
||||
if (state != FIN_WAIT_1 && state != FIN_WAIT_2 &&
|
||||
!recv(payload - old_bytes,
|
||||
&nic->packet[ETH_HLEN+header_size+old_bytes],
|
||||
&nic.packet[ETH_HLEN+header_size+old_bytes],
|
||||
ptr)) {
|
||||
goto close;
|
||||
}
|
||||
@@ -1463,15 +1440,15 @@ int await_reply(reply_t reply, int ival, void *ptr, long timeout)
|
||||
/* We have something! */
|
||||
|
||||
/* Find the Ethernet packet type */
|
||||
if (nic->packetlen >= ETH_HLEN) {
|
||||
ptype = ((unsigned short) nic->packet[12]) << 8
|
||||
| ((unsigned short) nic->packet[13]);
|
||||
if (nic.packetlen >= ETH_HLEN) {
|
||||
ptype = ((unsigned short) nic.packet[12]) << 8
|
||||
| ((unsigned short) nic.packet[13]);
|
||||
} else continue; /* what else could we do with it? */
|
||||
/* Verify an IP header */
|
||||
ip = 0;
|
||||
if ((ptype == ETH_P_IP) && (nic->packetlen >= ETH_HLEN + sizeof(struct iphdr))) {
|
||||
if ((ptype == ETH_P_IP) && (nic.packetlen >= ETH_HLEN + sizeof(struct iphdr))) {
|
||||
unsigned ipoptlen;
|
||||
ip = (struct iphdr *)&nic->packet[ETH_HLEN];
|
||||
ip = (struct iphdr *)&nic.packet[ETH_HLEN];
|
||||
if ((ip->verhdrlen < 0x45) || (ip->verhdrlen > 0x4F))
|
||||
continue;
|
||||
iplen = (ip->verhdrlen & 0xf) * 4;
|
||||
@@ -1493,17 +1470,17 @@ int await_reply(reply_t reply, int ival, void *ptr, long timeout)
|
||||
/* Delete the ip options, to guarantee
|
||||
* good alignment, and make etherboot simpler.
|
||||
*/
|
||||
memmove(&nic->packet[ETH_HLEN + sizeof(struct iphdr)],
|
||||
&nic->packet[ETH_HLEN + iplen],
|
||||
nic->packetlen - ipoptlen);
|
||||
nic->packetlen -= ipoptlen;
|
||||
memmove(&nic.packet[ETH_HLEN + sizeof(struct iphdr)],
|
||||
&nic.packet[ETH_HLEN + iplen],
|
||||
nic.packetlen - ipoptlen);
|
||||
nic.packetlen -= ipoptlen;
|
||||
}
|
||||
}
|
||||
udp = 0;
|
||||
if (ip && (ip->protocol == IP_UDP) &&
|
||||
(nic->packetlen >=
|
||||
(nic.packetlen >=
|
||||
ETH_HLEN + sizeof(struct iphdr) + sizeof(struct udphdr))) {
|
||||
udp = (struct udphdr *)&nic->packet[ETH_HLEN + sizeof(struct iphdr)];
|
||||
udp = (struct udphdr *)&nic.packet[ETH_HLEN + sizeof(struct iphdr)];
|
||||
|
||||
/* Make certain we have a reasonable packet length */
|
||||
if (ntohs(udp->len) > (ntohs(ip->len) - iplen))
|
||||
@@ -1517,9 +1494,9 @@ int await_reply(reply_t reply, int ival, void *ptr, long timeout)
|
||||
tcp = 0;
|
||||
#ifdef DOWNLOAD_PROTO_HTTP
|
||||
if (ip && (ip->protocol == IP_TCP) &&
|
||||
(nic->packetlen >=
|
||||
(nic.packetlen >=
|
||||
ETH_HLEN + sizeof(struct iphdr) + sizeof(struct tcphdr))){
|
||||
tcp = (struct tcphdr *)&nic->packet[ETH_HLEN +
|
||||
tcp = (struct tcphdr *)&nic.packet[ETH_HLEN +
|
||||
sizeof(struct iphdr)];
|
||||
/* Make certain we have a reasonable packet length */
|
||||
if (((ntohs(tcp->ctrl) >> 10) & 0x3C) >
|
||||
@@ -1541,11 +1518,11 @@ int await_reply(reply_t reply, int ival, void *ptr, long timeout)
|
||||
* action. This allows us reply to arp, igmp, and lacp queries.
|
||||
*/
|
||||
if ((ptype == ETH_P_ARP) &&
|
||||
(nic->packetlen >= ETH_HLEN + sizeof(struct arprequest))) {
|
||||
(nic.packetlen >= ETH_HLEN + sizeof(struct arprequest))) {
|
||||
struct arprequest *arpreply;
|
||||
unsigned long tmp;
|
||||
|
||||
arpreply = (struct arprequest *)&nic->packet[ETH_HLEN];
|
||||
arpreply = (struct arprequest *)&nic.packet[ETH_HLEN];
|
||||
memcpy(&tmp, arpreply->tipaddr, sizeof(in_addr));
|
||||
if ((arpreply->opcode == htons(ARP_REQUEST)) &&
|
||||
(tmp == arptable[ARP_CLIENT].ipaddr.s_addr)) {
|
||||
|
||||
@@ -169,7 +169,7 @@ int pxe_shutdown_nic ( void ) {
|
||||
if ( pxe_stack->state <= MIDWAY ) return 1;
|
||||
|
||||
eth_irq ( DISABLE );
|
||||
eth_disable();
|
||||
disable ( &dev );
|
||||
pxe_stack->state = MIDWAY;
|
||||
return 1;
|
||||
}
|
||||
@@ -433,7 +433,7 @@ PXENV_EXIT_t pxenv_undi_set_station_address ( t_PXENV_UNDI_SET_STATION_ADDRESS
|
||||
* the current value anyway then return success, otherwise
|
||||
* return UNSUPPORTED.
|
||||
*/
|
||||
if ( memcmp ( nic->node_addr,
|
||||
if ( memcmp ( nic.node_addr,
|
||||
&undi_set_station_address->StationAddress,
|
||||
ETH_ALEN ) == 0 ) {
|
||||
undi_set_station_address->Status = PXENV_STATUS_SUCCESS;
|
||||
@@ -465,8 +465,8 @@ PXENV_EXIT_t pxenv_undi_get_information ( t_PXENV_UNDI_GET_INFORMATION
|
||||
DBG ( "PXENV_UNDI_GET_INFORMATION" );
|
||||
ENSURE_READY ( undi_get_information );
|
||||
|
||||
undi_get_information->BaseIo = nic->ioaddr;
|
||||
undi_get_information->IntNumber = nic->irqno;
|
||||
undi_get_information->BaseIo = nic.ioaddr;
|
||||
undi_get_information->IntNumber = nic.irqno;
|
||||
/* Cheat: assume all cards can cope with this */
|
||||
undi_get_information->MaxTranUnit = ETH_MAX_MTU;
|
||||
/* Cheat: we only ever have Ethernet cards */
|
||||
@@ -476,12 +476,12 @@ PXENV_EXIT_t pxenv_undi_get_information ( t_PXENV_UNDI_GET_INFORMATION
|
||||
* node address. This is a valid assumption within Etherboot
|
||||
* at the time of writing.
|
||||
*/
|
||||
memcpy ( &undi_get_information->CurrentNodeAddress, nic->node_addr,
|
||||
memcpy ( &undi_get_information->CurrentNodeAddress, nic.node_addr,
|
||||
ETH_ALEN );
|
||||
memcpy ( &undi_get_information->PermNodeAddress, nic->node_addr,
|
||||
memcpy ( &undi_get_information->PermNodeAddress, nic.node_addr,
|
||||
ETH_ALEN );
|
||||
undi_get_information->ROMAddress = 0;
|
||||
/* nic->rom_info->rom_segment; */
|
||||
/* nic.rom_info->rom_segment; */
|
||||
/* We only provide the ability to receive or transmit a single
|
||||
* packet at a time. This is a bootloader, not an OS.
|
||||
*/
|
||||
@@ -637,7 +637,7 @@ PXENV_EXIT_t pxenv_undi_get_iface_info ( t_PXENV_UNDI_GET_IFACE_INFO
|
||||
* Status: working
|
||||
*/
|
||||
PXENV_EXIT_t pxenv_undi_isr ( t_PXENV_UNDI_ISR *undi_isr ) {
|
||||
media_header_t *media_header = (media_header_t*)nic->packet;
|
||||
media_header_t *media_header = (media_header_t*)nic.packet;
|
||||
|
||||
DBG ( "PXENV_UNDI_ISR" );
|
||||
/* We can't call ENSURE_READY, because this could be being
|
||||
@@ -683,8 +683,8 @@ PXENV_EXIT_t pxenv_undi_isr ( t_PXENV_UNDI_ISR *undi_isr ) {
|
||||
*/
|
||||
DBG ( " PROCESS" );
|
||||
if ( eth_poll ( 1 ) ) {
|
||||
DBG ( " RECEIVE %d", nic->packetlen );
|
||||
if ( nic->packetlen > sizeof(pxe_stack->packet) ) {
|
||||
DBG ( " RECEIVE %d", nic.packetlen );
|
||||
if ( nic.packetlen > sizeof(pxe_stack->packet) ) {
|
||||
/* Should never happen */
|
||||
undi_isr->FuncFlag = PXENV_UNDI_ISR_OUT_DONE;
|
||||
undi_isr->Status =
|
||||
@@ -692,10 +692,10 @@ PXENV_EXIT_t pxenv_undi_isr ( t_PXENV_UNDI_ISR *undi_isr ) {
|
||||
return PXENV_EXIT_FAILURE;
|
||||
}
|
||||
undi_isr->FuncFlag = PXENV_UNDI_ISR_OUT_RECEIVE;
|
||||
undi_isr->BufferLength = nic->packetlen;
|
||||
undi_isr->FrameLength = nic->packetlen;
|
||||
undi_isr->BufferLength = nic.packetlen;
|
||||
undi_isr->FrameLength = nic.packetlen;
|
||||
undi_isr->FrameHeaderLength = ETH_HLEN;
|
||||
memcpy ( pxe_stack->packet, nic->packet, nic->packetlen);
|
||||
memcpy ( pxe_stack->packet, nic.packet, nic.packetlen);
|
||||
PTR_TO_SEGOFF16 ( pxe_stack->packet, undi_isr->Frame );
|
||||
switch ( ntohs(media_header->nstype) ) {
|
||||
case IP : undi_isr->ProtType = P_IP; break;
|
||||
@@ -1026,7 +1026,7 @@ PXENV_EXIT_t pxenv_udp_read ( t_PXENV_UDP_READ *udp_read ) {
|
||||
PXENV_EXIT_t pxenv_udp_write ( t_PXENV_UDP_WRITE *udp_write ) {
|
||||
uint16_t src_port;
|
||||
uint16_t dst_port;
|
||||
struct udppacket *packet = (struct udppacket *)nic->packet;
|
||||
struct udppacket *packet = (struct udppacket *)nic.packet;
|
||||
int packet_size;
|
||||
|
||||
DBG ( "PXENV_UDP_WRITE" );
|
||||
|
||||
Reference in New Issue
Block a user