#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.20 2025/10/13 14:49:16 thorpej Exp $");
#include "opt_md.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/reboot.h>
#include <sys/disklabel.h>
#include <sys/device.h>
#include <sys/conf.h>
#include <sys/kernel.h>
#include <net/if.h>
#include <net/if_ether.h>
#include <machine/autoconf.h>
#include <machine/intr.h>
#include <iyonix/iyonix/iyonixvar.h>
#include <acorn32/include/bootconfig.h>
extern struct bootconfig bootconfig;
void
cpu_rootconf(void)
{
aprint_normal("boot device: %s\n",
booted_device != NULL ? device_xname(booted_device) : "<unknown>");
rootconf();
}
void
cpu_configure(void)
{
struct mainbus_attach_args maa;
(void) splhigh();
(void) splserial();
maa.ma_name = "mainbus";
config_rootfound("mainbus", &maa);
spl0();
}
#define BUILTIN_ETHERNET_P(pa) \
((pa)->pa_bus == 0 && (pa)->pa_device == 4 && (pa)->pa_function == 0)
#define SETPROP(x, y) \
do { \
if (prop_dictionary_set(device_properties(dev), \
x, y) == false) { \
printf("WARNING: unable to set " x " " \
"property for %s\n", device_xname(dev)); \
} \
prop_object_release(y); \
} while (0)
void
device_register(device_t dev, void *aux)
{
device_t pdev;
if ((pdev = device_parent(dev)) != NULL &&
device_is_a(pdev, "pci")) {
struct pci_attach_args *pa = aux;
if (BUILTIN_ETHERNET_P(pa)) {
prop_number_t cfg1, cfg2, swdpin;
cfg1 = prop_number_create_integer(0);
KASSERT(cfg1 != NULL);
cfg2 = prop_number_create_integer(0);
KASSERT(cfg2 != NULL);
swdpin = prop_number_create_integer(0);
KASSERT(swdpin != NULL);
device_setprop_data(dev, "mac-address",
iyonix_macaddr, ETHER_ADDR_LEN);
SETPROP("i82543-cfg1", cfg1);
SETPROP("i82543-cfg2", cfg2);
SETPROP("i82543-swdpin", swdpin);
}
}
if ((device_is_a(dev, "genfb") || device_is_a(dev, "gffb")) &&
device_is_a(device_parent(dev), "pci") ) {
prop_dictionary_t dict = device_properties(dev);
struct pci_attach_args *pa = aux;
pcireg_t bar0, bar1;
uint32_t fbaddr;
bus_space_handle_t vgah;
bar0 = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_MAPREG_START);
bar1 = pci_conf_read(pa->pa_pc, pa->pa_tag,
PCI_MAPREG_START + 0x04);
#define VGASIZE 0x1000
#define IRQENABLE_ADDR 0x140
bus_space_map(pa->pa_memt, PCI_MAPREG_MEM_ADDR(bar0),
VGASIZE, 0, &vgah);
bus_space_write_4(pa->pa_memt, vgah, 0x140, 0);
bus_space_unmap(pa->pa_memt, vgah, 0x1000);
fbaddr = PCI_MAPREG_MEM_ADDR(bar1);
prop_dictionary_set_bool(dict, "is_console", 1);
prop_dictionary_set_uint32(dict, "width",
bootconfig.width + 1);
prop_dictionary_set_uint32(dict, "height",
bootconfig.height + 1);
prop_dictionary_set_uint32(dict, "depth",
1 << bootconfig.log2_bpp);
if (bootconfig.log2_bpp == 5)
prop_dictionary_set_bool(dict, "is_bgr", 1);
prop_dictionary_set_uint32(dict, "address", fbaddr);
}
if (device_is_a(dev, "dsrtc")) {
device_setprop_uint(dev, "start-year", 2000);
}
}