From e95b721457156ef060802532a92ada31cc8c3504 Mon Sep 17 00:00:00 2001 From: deraadt Date: Tue, 5 Oct 2021 18:32:27 +0000 Subject: [PATCH] cleanup conf.c, and bring in wd(4) support ok kettenis --- sys/arch/riscv64/conf/files.riscv64 | 8 +++--- sys/arch/riscv64/include/conf.h | 41 +---------------------------- sys/arch/riscv64/riscv64/conf.c | 25 +++++++++++------- 3 files changed, 20 insertions(+), 54 deletions(-) diff --git a/sys/arch/riscv64/conf/files.riscv64 b/sys/arch/riscv64/conf/files.riscv64 index 59cde247d1d..998c313677a 100644 --- a/sys/arch/riscv64/conf/files.riscv64 +++ b/sys/arch/riscv64/conf/files.riscv64 @@ -1,13 +1,13 @@ -# $OpenBSD: files.riscv64,v 1.16 2021/06/29 17:49:49 matthieu Exp $ +# $OpenBSD: files.riscv64,v 1.17 2021/10/05 18:32:27 deraadt Exp $ # Standard stanzas config(8) can't run without maxpartitions 16 maxusers 2 8 128 # Major number for block devices, for ``root on'' lines -major { sd = 0 } -#major { cd = 3 } -#major { wd = 4 } +major { wd = 0 } +major { sd = 4 } +major { cd = 6 } major { rd = 8 } file arch/riscv64/riscv64/autoconf.c diff --git a/sys/arch/riscv64/include/conf.h b/sys/arch/riscv64/include/conf.h index 3770ba3df7a..127b5ba3091 100644 --- a/sys/arch/riscv64/include/conf.h +++ b/sys/arch/riscv64/include/conf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.h,v 1.2 2021/05/12 01:20:52 jsg Exp $ */ +/* $OpenBSD: conf.h,v 1.3 2021/10/05 18:32:28 deraadt Exp $ */ /* * Copyright (c) 1996 Christos Zoulas. All rights reserved. @@ -47,43 +47,4 @@ cdev_decl(mm); cdev_decl(openprom); -/* - * These numbers have to be in sync with bdevsw/cdevsw. - */ - -#define BMAJ_WD 0 -#define BMAJ_SW 1 -#define BMAJ_SD 4 -#define BMAJ_ST 5 - -#define CMAJ_MM 2 -#define CMAJ_PTS 5 -#define CMAJ_PTC 6 -#define CMAJ_COM 8 -#define CMAJ_WSDISPLAY 12 -#define CMAJ_ST 14 -#define CMAJ_LPT 16 -#define CMAJ_CH 17 -#define CMAJ_UK 20 -#define CMAJ_BPF 23 -#define CMAJ_TUN 40 -#define CMAJ_AUDIO 42 -#define CMAJ_VIDEO 44 -#define CMAJ_BKTR 49 -#define CMAJ_MIDI 52 -#define CMAJ_USB 61 -#define CMAJ_UHID 62 -#define CMAJ_UGEN 63 -#define CMAJ_ULPT 64 -#define CMAJ_UCOM 66 -#define CMAJ_WSKBD 67 -#define CMAJ_WSMOUSE 68 -#ifdef USER_PCICONF -#define CMAJ_PCI 72 -#endif -#define CMAJ_RADIO 76 -#define CMAJ_DRM 87 -#define CMAJ_GPIO 88 -#define CMAJ_VSCSI 89 - #endif /* _MACHINE_CONF_H_ */ diff --git a/sys/arch/riscv64/riscv64/conf.c b/sys/arch/riscv64/riscv64/conf.c index 732a71ee26c..bdebadc79e0 100644 --- a/sys/arch/riscv64/riscv64/conf.c +++ b/sys/arch/riscv64/riscv64/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.10 2021/06/25 19:27:40 matthieu Exp $ */ +/* $OpenBSD: conf.c,v 1.11 2021/10/05 18:32:28 deraadt Exp $ */ /* * Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved. @@ -38,6 +38,8 @@ #include +#include "wd.h" +bdev_decl(wd); #include "sd.h" #include "cd.h" #include "uk.h" @@ -46,7 +48,7 @@ struct bdevsw bdevsw[] = { - bdev_notdef(), /* */ + bdev_disk_init(NWD,wd), /* 0: ST506/ESDI/IDE disk */ bdev_swap_init(1,sw), /* 1: swap pseudo-device */ bdev_notdef(), /* 2: was floppy diskette */ bdev_notdef(), /* 3 */ @@ -71,6 +73,7 @@ int nblkdev = nitems(bdevsw); #define mmread mmrw #define mmwrite mmrw cdev_decl(mm); +cdev_decl(wd); #include "bio.h" #include "pty.h" #include "com.h" @@ -114,7 +117,7 @@ struct cdevsw cdevsw[] = cdev_cn_init(1,cn), /* 0: virtual console */ cdev_ctty_init(1,ctty), /* 1: controlling terminal */ cdev_mm_init(1,mm), /* 2: /dev/{null,mem,kmem,...} */ - cdev_notdef(), /* 3: */ + cdev_disk_init(NWD,wd), /* 3: ST506/ESDI/IDE disk */ cdev_notdef(), /* 4 was /dev/drum */ cdev_tty_init(NPTY,pts), /* 5: pseudo-tty slave */ cdev_ptc_init(NPTY,ptc), /* 6: pseudo-tty master */ @@ -223,6 +226,8 @@ struct cdevsw cdevsw[] = }; int nchrdev = nitems(cdevsw); +int mem_no = 2; /* major device number of memory special file */ + /* * Swapdev is a fake device implemented * in sw.c used only internally to get to swstrategy. @@ -232,7 +237,7 @@ int nchrdev = nitems(cdevsw); * confuse, e.g. the hashing routines. Instead, /dev/drum is * provided as a character (raw) device. */ -dev_t swapdev = makedev(BMAJ_SW, 0); +dev_t swapdev = makedev(1, 0); /* * Returns true if dev is /dev/mem or /dev/kmem. @@ -241,7 +246,7 @@ int iskmemdev(dev_t dev) { - return (major(dev) == CMAJ_MM && (minor(dev) < 2 || minor(dev) == 14)); + return (major(dev) == mem_no && (minor(dev) < 2 || minor(dev) == 14)); } /* @@ -251,13 +256,13 @@ int iszerodev(dev_t dev) { - return (major(dev) == CMAJ_MM && minor(dev) == 12); + return (major(dev) == mem_no && minor(dev) == 12); } dev_t getnulldev(void) { - return makedev(CMAJ_MM, 2); + return makedev(mem_no, 2); } int chrtoblktbl[] = { @@ -265,7 +270,7 @@ int chrtoblktbl[] = { /* 0 */ NODEV, /* 1 */ NODEV, /* 2 */ NODEV, - /* 3 */ NODEV, + /* 3 */ 0, /* wd */ /* 4 */ NODEV, /* 5 */ NODEV, /* 6 */ NODEV, @@ -334,8 +339,8 @@ dev_rawpart(struct device *dv) switch (majdev) { /* add here any device you want to be checksummed on boot */ - case BMAJ_WD: - case BMAJ_SD: + case 0: + case 4: return (MAKEDISKDEV(majdev, dv->dv_unit, RAW_PART)); break; default: -- 2.20.1