david/ipxe
Archived
1
0
This repository has been archived on 2020-12-06. You can view files and clone it, but cannot push or open issues or pull requests.
ipxe/src/include/dev.h

71 lines
1.6 KiB
C
Raw Normal View History

2005-03-08 19:53:11 +01:00
#ifndef DEV_H
#define DEV_H
2005-04-12 18:38:23 +02:00
#include "stdint.h"
#include "nic.h"
#include "pci.h"
2005-04-13 05:00:50 +02:00
#include "mca.h"
2005-03-08 19:53:11 +01:00
/* Need to check the packing of this struct if Etherboot is ported */
2005-04-12 18:38:23 +02:00
struct dev_id {
uint16_t vendor_id;
uint16_t device_id;
uint8_t bus_type;
2005-03-08 19:53:11 +01:00
#define PCI_BUS_TYPE 1
#define ISA_BUS_TYPE 2
2005-04-13 05:00:50 +02:00
#define MCA_BUS_TYPE 3
2005-04-12 18:38:23 +02:00
} __attribute__ ((packed));
2005-03-08 19:53:11 +01:00
/* Dont use sizeof, that will include the padding */
#define DEV_ID_SIZE 8
2005-04-12 18:38:23 +02:00
struct dev {
struct dev_operations *dev_op;
2005-04-12 18:38:23 +02:00
const char *name;
struct dev_id devid; /* device ID string (sent to DHCP server) */
/* All possible bus types */
union {
struct pci_device pci;
2005-04-13 05:00:50 +02:00
struct mca_device mca;
};
2005-04-12 18:38:23 +02:00
/* All possible device types */
union {
struct nic nic;
};
2005-03-08 19:53:11 +01:00
};
2005-04-12 18:38:23 +02:00
struct dev_operations {
void ( *disable ) ( struct dev * );
void ( *print_info ) ( struct dev * );
2005-04-12 18:38:23 +02:00
int ( *load_configuration ) ( struct dev * );
int ( *load ) ( struct dev * );
2005-03-08 19:53:11 +01:00
};
2005-04-12 18:38:23 +02:00
struct boot_driver {
char *name;
int (*probe) ( struct dev * );
2005-03-08 19:53:11 +01:00
};
2005-04-12 18:38:23 +02:00
#define BOOT_DRIVER( driver_name, probe_func ) \
static struct boot_driver boot_driver \
__attribute__ ((used,__section__(".boot_drivers"))) = { \
.name = driver_name, \
.probe = probe_func, \
};
/* Functions in dev.c */
extern void print_drivers ( void );
extern int probe ( struct dev *dev );
extern void disable ( struct dev *dev );
static inline void print_info ( struct dev *dev ) {
dev->dev_op->print_info ( dev );
}
2005-04-12 18:38:23 +02:00
static inline int load_configuration ( struct dev *dev ) {
return dev->dev_op->load_configuration ( dev );
}
static inline int load ( struct dev *dev ) {
return dev->dev_op->load ( dev );
}
2005-03-08 19:53:11 +01:00
#endif /* DEV_H */