1*63e179a8Sriastradh /* $NetBSD: rump_dev.c,v 1.29 2023/04/23 07:03:30 riastradh Exp $ */
228631b61Spooka
328631b61Spooka /*
428631b61Spooka * Copyright (c) 2009 Antti Kantee. All Rights Reserved.
528631b61Spooka *
628631b61Spooka * Redistribution and use in source and binary forms, with or without
728631b61Spooka * modification, are permitted provided that the following conditions
828631b61Spooka * are met:
928631b61Spooka * 1. Redistributions of source code must retain the above copyright
1028631b61Spooka * notice, this list of conditions and the following disclaimer.
1128631b61Spooka * 2. Redistributions in binary form must reproduce the above copyright
1228631b61Spooka * notice, this list of conditions and the following disclaimer in the
1328631b61Spooka * documentation and/or other materials provided with the distribution.
1428631b61Spooka *
1528631b61Spooka * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
1628631b61Spooka * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1728631b61Spooka * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1828631b61Spooka * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1928631b61Spooka * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2028631b61Spooka * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
2128631b61Spooka * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2228631b61Spooka * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2328631b61Spooka * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2428631b61Spooka * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2528631b61Spooka * SUCH DAMAGE.
2628631b61Spooka */
2728631b61Spooka
2828631b61Spooka #include <sys/cdefs.h>
29*63e179a8Sriastradh __KERNEL_RCSID(0, "$NetBSD: rump_dev.c,v 1.29 2023/04/23 07:03:30 riastradh Exp $");
3028631b61Spooka
3128631b61Spooka #include <sys/param.h>
3228631b61Spooka #include <sys/device.h>
3328631b61Spooka
346bb51422Spooka #include <rump-sys/kern.h>
356bb51422Spooka #include <rump-sys/dev.h>
3628631b61Spooka
37*63e179a8Sriastradh int rumpdev_do_sys_sync_stub(struct lwp *);
38*63e179a8Sriastradh int
rumpdev_do_sys_sync_stub(struct lwp * l)39*63e179a8Sriastradh rumpdev_do_sys_sync_stub(struct lwp *l)
40*63e179a8Sriastradh {
41*63e179a8Sriastradh return 0;
42*63e179a8Sriastradh }
43*63e179a8Sriastradh __weak_alias(do_sys_sync,rumpdev_do_sys_sync_stub);
44*63e179a8Sriastradh
45*63e179a8Sriastradh int rumpdev_vfs_syncwait_stub(void);
46*63e179a8Sriastradh int
rumpdev_vfs_syncwait_stub(void)47*63e179a8Sriastradh rumpdev_vfs_syncwait_stub(void)
48*63e179a8Sriastradh {
49*63e179a8Sriastradh return 0;
50*63e179a8Sriastradh }
51*63e179a8Sriastradh __weak_alias(vfs_syncwait,rumpdev_vfs_syncwait_stub);
5228631b61Spooka
538d38112cSpooka const char *rootspec = "rump0a"; /* usually comes from config */
548d38112cSpooka
RUMP_COMPONENT(RUMP__FACTION_DEV)5576a5d8abSpooka RUMP_COMPONENT(RUMP__FACTION_DEV)
5628631b61Spooka {
5773ad6a8bSpooka extern int cold;
5828631b61Spooka
59d52e469dSpooka pmf_init();
60d52e469dSpooka
619b32227dSpooka KERNEL_LOCK(1, curlwp);
629b32227dSpooka
63d9a6bf91Spooka rump_mainbus_init();
6428631b61Spooka
65510a73e0Spooka rump_component_init(RUMP_COMPONENT_DEV);
6628631b61Spooka
6728631b61Spooka rump_pdev_finalize();
6828631b61Spooka
6973ad6a8bSpooka cold = 0;
70f12cd61cSpooka
71f12cd61cSpooka /*
72f12cd61cSpooka * XXX: does the "if" make any sense? What if someone wants
73f12cd61cSpooka * to dynamically load a driver later on?
74f12cd61cSpooka */
75f12cd61cSpooka if (rump_component_count(RUMP_COMPONENT_DEV) > 0
76f12cd61cSpooka || rump_component_count(RUMP_COMPONENT_DEV_AFTERMAINBUS) > 0) {
77d9a6bf91Spooka rump_mainbus_attach();
78eeb94c80Spooka if (config_rootfound("mainbus", NULL) == NULL)
79eeb94c80Spooka panic("no mainbus");
80eeb94c80Spooka
81f12cd61cSpooka rump_component_init(RUMP_COMPONENT_DEV_AFTERMAINBUS);
82665d28b4Spooka }
8328631b61Spooka config_finalize();
849b32227dSpooka
859b32227dSpooka KERNEL_UNLOCK_LAST(curlwp);
86e7f2e099Spooka
87e7f2e099Spooka /* if there is a vfs, perform activity deferred until mountroot */
88e7f2e099Spooka if (rump_component_count(RUMP__FACTION_VFS)) {
89e7f2e099Spooka config_create_mountrootthreads();
90e7f2e099Spooka yield();
91e7f2e099Spooka }
9228631b61Spooka }
9328631b61Spooka
948d38112cSpooka void
cpu_rootconf(void)958d38112cSpooka cpu_rootconf(void)
968d38112cSpooka {
978d38112cSpooka
988d38112cSpooka panic("%s: unimplemented", __func__);
998d38112cSpooka }
1008d38112cSpooka
10128631b61Spooka void
cpu_bootconf(void)102478a0b6fSchristos cpu_bootconf(void)
103478a0b6fSchristos {
104478a0b6fSchristos }
105478a0b6fSchristos
106478a0b6fSchristos void
device_register(device_t dev,void * v)107cbab9cadSchs device_register(device_t dev, void *v)
10828631b61Spooka {
10928631b61Spooka
11028631b61Spooka /* nada */
11128631b61Spooka }
112693845d2Smartin
113693845d2Smartin void
device_register_post_config(device_t dev,void * v)114cbab9cadSchs device_register_post_config(device_t dev, void *v)
115693845d2Smartin {
116693845d2Smartin
117693845d2Smartin /* nada */
118693845d2Smartin }
119