[BACK]Return to config_rootdev.c CVS log [TXT][DIR] Up to [local] / prex-old / dev / core

File: [local] / prex-old / dev / core / config_rootdev.c (download)

Revision 1.1, Fri Aug 8 12:37:11 2008 UTC (15 years, 8 months ago) by nbrk
Branch: MAIN
CVS Tags: HEAD

Heads up! Implement universal device attachment and autoconfiguration machinery.
This is somewhat similar to traditional BSD autoconf but much more simple.
Three basic data structures involved in autoconfiguration process are:
struct device, which represents abstract device and its private (driver softc) data;
struct driver, which holds {attach,match,detach} entries, name and softc size;
struct attachment, which tells us how drivers are interacted with each other.
Attachment basically describes how to attach devices in system.
Machine specified part should export arrays config_table[] and *drivers[] for config.

This might have broken i386 & gba tree, but there is only a question of time.

/*
 * $Id: config_rootdev.c,v 1.1 2008/08/08 12:37:11 nbrk Exp $
 */
/*
 * 'root' is the parent to all devices in system.
 * Device module calls config_attach_rootdev() to initiate recursive 
 * autoconfiguration process.
 */
#include <driver.h>

/*
 * rootdev driver.
 */
struct driver	root_drv = {
	"root",	/* name */
	0,		/* datasize */
	NULL,	/* match */
	NULL,	/* attach */
	NULL,	/* detach */
	-1		/* nunits XXX */
};

/*
 * rootdev device.
 */
struct device	*root_dev;


void
config_attach_rootdev()
{
	/*
	 * Attach our one and only child, 'hostio'.
	 * Panic if attachment failed.
	 */
	int	ndevs;

	/*
	 * Allocate and construct ourselfes.
	 */
	root_dev = config_alloc_device(&root_drv);
	root_dev->dv_parent = root_dev;

	ndevs = config_search_children(root_dev, NULL);
	if (ndevs == 0)
		panic("rootdev: can't find hostio");
}