12 #include <variant/onboard.h>
32 static unsigned int search(
char *p,
u8 *a,
unsigned int lengthp,
38 for (j = 0; j <= lengtha - lengthp; j++) {
39 for (i = 0; i < lengthp && p[i] == a[i + j]; i++)
49 unsigned char retval = 0;
53 retval = *
offset -
'A' + 0x0A;
55 retval = *
offset -
'a' + 0x0a;
67 u8 *search_address,
u32 search_length)
69 char key[] =
"ethernet_mac";
73 offset =
search(key, search_address,
sizeof(key) - 1, search_length);
74 if (
offset == search_length) {
76 "Error: Could not locate '%s' in VPD\n", key);
93 for (i = 0; i < 4; i++) {
102 for (i = 0; i < 2; i++) {
110 return *high_dword | *low_dword;
115 void *search_address =
NULL;
116 size_t search_length = -1;
119 u32 high_dword = 0xD0BA00A0;
120 u32 low_dword = 0x0000AD0B;
128 if (search_address !=
NULL)
132 search_address =
cbfs_map(
"vpd.bin", &search_length);
135 if (search_address ==
NULL)
146 outb(0xc0, io_base + 0x50);
147 outl(high_dword, io_base);
148 outl(low_dword, io_base + 0x04);
149 outb(0x60, io_base + 54);
151 outb(0x00, io_base + 0x50);
163 if (ethernet_dev !=
NULL) {
191 outb(0xc0, io_base + 0x50);
193 outb(0x00, io_base + 0x50);
int smbios_write_type41(unsigned long *current, int *handle, const char *name, u8 instance, u16 segment, u8 bus, u8 device, u8 function, u8 device_type)
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)
int variant_smbios_data(struct device *dev, int *handle, unsigned long *current)
#define BUDDY_NIC_VENDOR_ID
#define BOARD_TOUCHSCREEN_IRQ
#define BOARD_TOUCHSCREEN_I2C_ADDR
#define BUDDY_NIC_DEVICE_ID
#define BOARD_TOUCHSCREEN_NAME
#define BUDDY_NIC_LED_MODE
#define BOARD_TOUCHSCREEN_I2C_BUS
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 __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)
@ SMBIOS_DEVICE_TYPE_OTHER
#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)