1*97f8debdSpgoyette /* $NetBSD: md_component.c,v 1.3 2022/03/31 19:30:17 pgoyette Exp $ */
25102012cSpooka
35102012cSpooka /*
45102012cSpooka * Copyright (c) 2010 Antti Kantee. All Rights Reserved.
55102012cSpooka *
65102012cSpooka * Redistribution and use in source and binary forms, with or without
75102012cSpooka * modification, are permitted provided that the following conditions
85102012cSpooka * are met:
95102012cSpooka * 1. Redistributions of source code must retain the above copyright
105102012cSpooka * notice, this list of conditions and the following disclaimer.
115102012cSpooka * 2. Redistributions in binary form must reproduce the above copyright
125102012cSpooka * notice, this list of conditions and the following disclaimer in the
135102012cSpooka * documentation and/or other materials provided with the distribution.
145102012cSpooka *
155102012cSpooka * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
165102012cSpooka * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
175102012cSpooka * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
185102012cSpooka * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
195102012cSpooka * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
205102012cSpooka * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
215102012cSpooka * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
225102012cSpooka * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
235102012cSpooka * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
245102012cSpooka * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
255102012cSpooka * SUCH DAMAGE.
265102012cSpooka */
275102012cSpooka
285102012cSpooka #include <sys/cdefs.h>
29*97f8debdSpgoyette __KERNEL_RCSID(0, "$NetBSD: md_component.c,v 1.3 2022/03/31 19:30:17 pgoyette Exp $");
305102012cSpooka
315102012cSpooka #include <sys/param.h>
325102012cSpooka #include <sys/conf.h>
335102012cSpooka #include <sys/device.h>
345102012cSpooka #include <sys/mbuf.h>
355102012cSpooka #include <sys/stat.h>
365102012cSpooka
375102012cSpooka #include "ioconf.c"
385102012cSpooka
396bb51422Spooka #include <rump-sys/kern.h>
406bb51422Spooka #include <rump-sys/dev.h>
416bb51422Spooka #include <rump-sys/vfs.h>
425102012cSpooka
435102012cSpooka extern void mdattach(int); /* XXX */
445102012cSpooka
RUMP_COMPONENT(RUMP_COMPONENT_DEV)455102012cSpooka RUMP_COMPONENT(RUMP_COMPONENT_DEV)
465102012cSpooka {
475102012cSpooka extern const struct bdevsw md_bdevsw;
485102012cSpooka extern const struct cdevsw md_cdevsw;
495102012cSpooka devmajor_t bmaj, cmaj;
505102012cSpooka int error;
515102012cSpooka
525102012cSpooka bmaj = cmaj = NODEVMAJOR;
535102012cSpooka if ((error = devsw_attach("md", &md_bdevsw, &bmaj,
545102012cSpooka &md_cdevsw, &cmaj)) != 0)
555102012cSpooka panic("md devsw attach failed: %d", error);
565102012cSpooka
57*97f8debdSpgoyette config_init_component(cfdriver_ioconf_md,
58*97f8debdSpgoyette cfattach_ioconf_md, cfdata_ioconf_md);
59*97f8debdSpgoyette
605102012cSpooka if ((error = rump_vfs_makedevnodes(S_IFBLK, "/dev/md0", 'a',
615102012cSpooka bmaj, 0, 7)) != 0)
625102012cSpooka panic("cannot create cooked md dev nodes: %d", error);
635102012cSpooka if ((error = rump_vfs_makedevnodes(S_IFCHR, "/dev/rmd0", 'a',
645102012cSpooka cmaj, 0, 7)) != 0)
655102012cSpooka panic("cannot create raw md dev nodes: %d", error);
665102012cSpooka
675102012cSpooka rump_pdev_add(mdattach, 0);
685102012cSpooka }
69