Fix a couple of errors we no longer have (ain't regression wonderful)

Change to using device drivers for null, zero and digit
Small changes to the way we init devices.

NB the random driver has shown that devices are not being handled correctly,
   so this is something we'll ahve to live with until the vfs person fixes it.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@148 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
David Reid 2002-07-12 19:24:26 +00:00
parent fb8aa06112
commit 100b0f973d
3 changed files with 12 additions and 25 deletions

View File

@ -3,8 +3,6 @@ SubDir OBOS_TOP src kernel drivers ;
KernelStaticLibrary libdrivers :
<$(SOURCE_GRIST)>dev.c
<$(SOURCE_GRIST)>devs.c
<$(SOURCE_GRIST)>common/null.c
<$(SOURCE_GRIST)>common/zero.c
<$(SOURCE_GRIST)>arch/$(OBOS_ARCH)/console/console.c
<$(SOURCE_GRIST)>arch/$(OBOS_ARCH)/keyboard/keyboard.c
<$(SOURCE_GRIST)>arch/$(OBOS_ARCH)/ps2mouse/ps2mouse.c

View File

@ -17,7 +17,10 @@
#include <stdio.h>
/* These are mainly here to allow testing and this needs to be revisited */
const char *device_paths[] = {
"/boot/addons/drivers/dev",
"/boot/addons/drivers/dev/audio",
"/boot/addons/drivers/dev/misc",
"/boot/addons/drivers/dev/net",
NULL
@ -31,7 +34,6 @@ int dev_init(kernel_args *ka)
dprintf("dev_init: entry\n");
for (ptr = device_paths; (*ptr); ptr++) {
dprintf("DEV: looking at directory %s\n", *ptr);
fd = sys_open(*ptr, STREAM_TYPE_DIR, 0);
if(fd >= 0) {
ssize_t len;
@ -53,7 +55,7 @@ image_id dev_load_dev_module(const char *name, const char *dirpath)
{
image_id id;
status_t (*init_hardware)(void);
const char **(*publish_devices)(void);
const char **(*publish_devices)(void) = NULL;
device_hooks *(*find_device)(const char *);
void (*bootstrap)();
char path[SYS_MAX_PATH_LEN];
@ -68,7 +70,7 @@ image_id dev_load_dev_module(const char *name, const char *dirpath)
init_hardware = (void*)elf_lookup_symbol(id, "init_hardware");
if (init_hardware) {
// dprintf("DEV: found init_hardware in %s\n", name);
dprintf("DEV: found init_hardware in %s\n", name);
if (init_hardware() != 0) {
dprintf("DEV: %s: init_hardware failed :(\n", name);
elf_unload_kspace(path);
@ -79,23 +81,25 @@ image_id dev_load_dev_module(const char *name, const char *dirpath)
// dprintf("DEV: %s: found publish_devices\n", name);
devfs_paths = publish_devices();
// dprintf("DEV: %s: publish_devices = %p\n", name, (char*)devfs_paths);
for (; *devfs_paths; devfs_paths++) {
dprintf("DEV: %s: wants to be known as %s\n", name, *devfs_paths);
}
// for (; *devfs_paths; devfs_paths++) {
// dprintf("DEV: %s: wants to be known as %s\n", name, *devfs_paths);
// }
find_device = (void*)elf_lookup_symbol(id, "find_device");
if (!find_device) {
elf_unload_kspace(path);
return EFTYPE;
dprintf("failed to find the find_device symbol!\n");
return EINVAL; /* should be EFTYPE */
}
/* Should really cycle through these... */
devfs_paths = publish_devices();
for (; *devfs_paths; devfs_paths++) {
hooks = find_device(*devfs_paths);
dprintf("publishing %s\n", *devfs_paths);
if (hooks)
devfs_publish_device(*devfs_paths, NULL, hooks);
}
} else
return EFTYPE;
return EINVAL; /* should be FTYPE */
return id;
}

View File

@ -4,17 +4,11 @@
*/
#include <kernel.h>
#include <devs.h>
#include <vfs.h>
#include <debug.h>
#include <string.h>
#ifdef ARCH_x86
#include <arch/x86/ide_bus.h>
#include <arch/x86/console_dev.h>
#include <arch/x86/keyboard.h>
#include <arch/x86/ps2mouse.h>
#include <arch/x86/rtl8139_dev.h>
#endif
#ifdef ARCH_sh4
#include <kernel/dev/arch/sh4/maple/maple_bus.h>
@ -22,28 +16,19 @@
#include <kernel/dev/arch/sh4/console/console_dev.h>
#include <kernel/dev/arch/sh4/rtl8139/rtl8139_dev.h>
#endif
#include <null.h>
#include <zero.h>
#include <fb_console.h>
int devs_init(kernel_args *ka)
{
null_dev_init(ka);
zero_dev_init(ka);
#ifdef ARCH_x86
// ide_bus_init(ka);
keyboard_dev_init(ka);
// mouse_dev_init(ka);
console_dev_init(ka);
// rtl8139_dev_init(ka);
// netblock_dev_init(ka);
#endif
#ifdef ARCH_sh4
maple_bus_init(ka);
keyboard_dev_init(ka);
// console_dev_init(ka);
rtl8139_dev_init(ka);
#endif
fb_console_dev_init(ka);