1 /* $OpenBSD: autoconf.c,v 1.10 2024/11/12 00:00:25 jsg Exp $ */ 2 3 /* 4 * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org> 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 #include <sys/param.h> 20 #include <sys/device.h> 21 #include <sys/reboot.h> 22 #include <sys/systm.h> 23 24 #if defined(NFSCLIENT) 25 #include <net/if.h> 26 #include <net/if_types.h> 27 #include <netinet/in.h> 28 #include <netinet/if_ether.h> 29 #endif 30 31 void 32 cpu_configure(void) 33 { 34 splhigh(); 35 36 softintr_init(); 37 config_rootfound("mainbus", NULL); 38 39 cold = 0; 40 spl0(); 41 } 42 43 void 44 diskconf(void) 45 { 46 #if defined(NFSCLIENT) 47 extern uint8_t *bootmac; 48 dev_t tmpdev = NODEV; 49 #endif 50 struct device *bootdv = NULL; 51 int part = 0; 52 53 #if defined(NFSCLIENT) 54 if (bootmac) { 55 struct ifnet *ifp; 56 57 TAILQ_FOREACH(ifp, &ifnetlist, if_list) { 58 if (ifp->if_type == IFT_ETHER && 59 memcmp(bootmac, ((struct arpcom *)ifp)->ac_enaddr, 60 ETHER_ADDR_LEN) == 0) 61 break; 62 } 63 if (ifp) 64 bootdv = parsedisk(ifp->if_xname, strlen(ifp->if_xname), 65 0, &tmpdev); 66 } 67 #endif 68 69 setroot(bootdv, part, RB_USERREQ); 70 } 71 72 void 73 device_register(struct device *dev, void *aux) 74 { 75 } 76 77 const struct nam2blk nam2blk[] = { 78 { "vnd", 1 }, 79 { "rd", 2 }, 80 { "sd", 3 }, 81 { "cd", 4 }, 82 { "wd", 5 }, 83 { NULL, -1 } 84 }; 85