1*974cf03dSad /* $NetBSD: miniroot.c,v 1.3 2008/11/16 15:47:35 ad Exp $ */
28c94e76aSad
38c94e76aSad /*-
48c94e76aSad * Copyright (c) 2008 The NetBSD Foundation, Inc.
58c94e76aSad * All rights reserved.
68c94e76aSad *
78c94e76aSad * Redistribution and use in source and binary forms, with or without
88c94e76aSad * modification, are permitted provided that the following conditions
98c94e76aSad * are met:
108c94e76aSad * 1. Redistributions of source code must retain the above copyright
118c94e76aSad * notice, this list of conditions and the following disclaimer.
128c94e76aSad * 2. Redistributions in binary form must reproduce the above copyright
138c94e76aSad * notice, this list of conditions and the following disclaimer in the
148c94e76aSad * documentation and/or other materials provided with the distribution.
158c94e76aSad *
168c94e76aSad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
178c94e76aSad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
188c94e76aSad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
198c94e76aSad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
208c94e76aSad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
218c94e76aSad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
228c94e76aSad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
238c94e76aSad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
248c94e76aSad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
258c94e76aSad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
268c94e76aSad * POSSIBILITY OF SUCH DAMAGE.
278c94e76aSad */
288c94e76aSad
298c94e76aSad #include <sys/cdefs.h>
30*974cf03dSad __KERNEL_RCSID(0, "$NetBSD: miniroot.c,v 1.3 2008/11/16 15:47:35 ad Exp $");
318c94e76aSad
328c94e76aSad #include <sys/param.h>
338c94e76aSad #include <sys/kernel.h>
348c94e76aSad #include <sys/module.h>
358c94e76aSad
368c94e76aSad #include <dev/md.h>
378c94e76aSad
388c94e76aSad MODULE(MODULE_CLASS_MISC, miniroot, NULL);
398c94e76aSad
408c94e76aSad static int
miniroot_modcmd(modcmd_t cmd,void * arg)418c94e76aSad miniroot_modcmd(modcmd_t cmd, void *arg)
428c94e76aSad {
438c94e76aSad void *addr;
448c94e76aSad int error;
458c94e76aSad size_t size;
468c94e76aSad
478c94e76aSad switch (cmd) {
488c94e76aSad case MODULE_CMD_INIT:
498c94e76aSad error = module_find_section("miniroot", &addr, &size);
50*974cf03dSad if (error == 0) {
51*974cf03dSad if (size == 0) {
52*974cf03dSad error = EINVAL;
53*974cf03dSad } else {
548c94e76aSad md_root_setconf(addr, size);
55*974cf03dSad }
56*974cf03dSad }
57*974cf03dSad return error;
588c94e76aSad
5915fabc99Sad case MODULE_CMD_FINI:
6015fabc99Sad return EOPNOTSUPP;
6115fabc99Sad
628c94e76aSad default:
638c94e76aSad return ENOTTY;
648c94e76aSad }
658c94e76aSad }
66