10 #include <variant/onboard.h>
12 static unsigned int search(
char *p,
u8 *a,
unsigned int lengthp,
18 for (j = 0; j <= lengtha - lengthp; j++) {
19 for (i = 0; i < lengthp && p[i] == a[i + j]; i++)
29 unsigned char retval = 0;
33 retval = *
offset -
'A' + 0x0A;
35 retval = *
offset -
'a' + 0x0a;
47 u8 *search_address,
u32 search_length)
49 char key[] =
"ethernet_mac";
53 offset =
search(key, search_address,
sizeof(key) - 1, search_length);
54 if (
offset == search_length) {
56 "Error: Could not locate '%s' in VPD\n", key);
73 for (i = 0; i < 4; i++) {
82 for (i = 0; i < 2; i++) {
90 return *high_dword | *low_dword;
95 void *search_address =
NULL;
96 size_t search_length = -1;
99 u32 high_dword = 0xD0BA00A0;
100 u32 low_dword = 0x0000AD0B;
108 if (search_address !=
NULL)
112 search_address =
cbfs_map(
"vpd.bin", &search_length);
115 if (search_address ==
NULL)
126 outb(0xc0, io_base + 0x50);
127 outl(high_dword, io_base);
128 outl(low_dword, io_base + 0x04);
129 outb(0x60, io_base + 54);
131 outb(0x00, io_base + 0x50);
143 if (ethernet_dev !=
NULL) {
171 outb(0xc0, io_base + 0x50);
173 outb(0x00, io_base + 0x50);
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)
#define SUMO_NIC_LED_MODE
#define SUMO_NIC_DEVICE_ID
#define SUMO_NIC_VENDOR_ID
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 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 size_t region_device_sz(const struct region_device *rdev)
static void * rdev_mmap_full(const struct region_device *rd)