13 static unsigned int search(
char *p,
u8 *a,
unsigned int lengthp,
19 for (j = 0; j <= lengtha - lengthp; j++) {
20 for (i = 0; i < lengthp && p[i] == a[i + j]; i++)
30 unsigned char retval = 0;
34 retval = *
offset -
'A' + 0x0A;
36 retval = *
offset -
'a' + 0x0a;
48 u8 *search_address,
u32 search_length)
50 char key[] =
"ethernet_mac";
54 offset =
search(key, search_address,
sizeof(key) - 1, search_length);
55 if (
offset == search_length) {
57 "Error: Could not locate '%s' in VPD\n", key);
74 for (i = 0; i < 4; i++) {
83 for (i = 0; i < 2; i++) {
91 return *high_dword | *low_dword;
96 void *search_address =
NULL;
97 size_t search_length = -1;
100 u32 high_dword = 0xD0BA00A0;
101 u32 low_dword = 0x0000AD0B;
109 if (search_address !=
NULL)
113 search_address =
cbfs_map(
"vpd.bin", &search_length);
116 if (search_address ==
NULL)
127 outb(0xc0, io_base + 0x50);
128 outl(high_dword, io_base);
129 outl(low_dword, io_base + 0x04);
130 outb(0x60, io_base + 54);
132 outb(0x00, io_base + 0x50);
144 if (ethernet_dev !=
NULL) {
172 outb(0xc0, io_base + 0x50);
174 outb(0x00, io_base + 0x50);
static unsigned char get_hex_digit(u8 *offset)
static unsigned int search(char *p, u8 *a, unsigned int lengthp, unsigned int lengtha)
static int get_mac_address(u32 *high_dword, u32 *low_dword, u8 *search_address, u32 search_length)
static void program_mac_address(u16 io_base)
static void * cbfs_map(const char *name, size_t *size_out)
#define printk(level,...)
void outb(u8 val, u16 port)
void outl(u32 val, u16 port)
struct device * dev_find_device(u16 vendor, u16 device, struct device *from)
Find a device of a given vendor and type.
static struct region_device rdev
int fmap_locate_area_as_rdev(const char *name, struct region_device *area)
static __always_inline u16 pci_read_config16(const struct device *dev, u16 reg)
static __always_inline void pci_write_config8(const struct device *dev, u16 reg, u8 val)
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
static size_t region_device_sz(const struct region_device *rdev)
static void * rdev_mmap_full(const struct region_device *rd)