mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-09 04:15:52 +00:00
dde_bsd: seperate PCI back end
The supported drivers so far exclusively used PCI and for practical reasons the emulation environment was to tied to. To make future addition of drivers that employ other transport busses easier, split the bus handling into its own backend. This is preliminary clean-up work before introducing the USB audio driver. Issue #3929.
This commit is contained in:
parent
6c7f0cb7cc
commit
3faf5c43a8
@ -13,7 +13,7 @@ INC_DIR += $(AUDIO_CONTRIB_DIR)
|
||||
|
||||
LIBS += dde_bsd_audio_include
|
||||
|
||||
SRC_CC += bus.cc dummies.cc driver.cc irq.cc mem.cc misc.cc scheduler.cc timer.cc
|
||||
SRC_CC += dummies.cc driver.cc irq.cc mem.cc misc.cc scheduler.cc timer.cc
|
||||
SRC_C += bsd_emul.c
|
||||
SRC_S += setjmp.S
|
||||
|
||||
@ -30,26 +30,9 @@ CC_C_OPT += -Wno-maybe-uninitialized
|
||||
|
||||
# enable when debugging
|
||||
#CC_OPT += -DAUDIO_DEBUG
|
||||
#CC_OPT += -DAC97_DEBUG
|
||||
#CC_OPT += -DAUICH_DEBUG
|
||||
#CC_OPT += -DAZALIA_DEBUG
|
||||
#CC_OPT += -DDIAGNOSTIC
|
||||
|
||||
# audio interface
|
||||
SRC_C += dev/audio.c
|
||||
|
||||
# AC97 codec
|
||||
SRC_C += dev/ic/ac97.c
|
||||
|
||||
# HDA driver
|
||||
SRC_C += dev/pci/azalia.c dev/pci/azalia_codec.c
|
||||
|
||||
# ICH driver
|
||||
SRC_C += dev/pci/auich.c
|
||||
|
||||
# ES1370
|
||||
SRC_C += dev/pci/eap.c
|
||||
|
||||
SRC_C += dev/mulaw.c
|
||||
|
||||
vpath %.c $(AUDIO_CONTRIB_DIR)
|
||||
|
49
repos/dde_bsd/lib/mk/dde_bsd_audio_pci.mk
Normal file
49
repos/dde_bsd/lib/mk/dde_bsd_audio_pci.mk
Normal file
@ -0,0 +1,49 @@
|
||||
LIB_DIR = $(REP_DIR)/src/lib/audio
|
||||
LIB_INC_DIR = $(LIB_DIR)/include
|
||||
|
||||
AUDIO_CONTRIB_DIR := $(call select_from_ports,dde_bsd)/src/lib/audio
|
||||
|
||||
#
|
||||
# Set include paths up before adding the dde_bsd_audio_include library
|
||||
# because it will use INC_DIR += and must be at the end
|
||||
#
|
||||
INC_DIR += $(LIB_DIR)
|
||||
INC_DIR += $(LIB_INC_DIR)
|
||||
INC_DIR += $(AUDIO_CONTRIB_DIR)
|
||||
|
||||
LIBS += dde_bsd_audio_include
|
||||
|
||||
SRC_C := bsd_emul_pci.c
|
||||
SRC_CC += pci.cc
|
||||
|
||||
CC_OPT += -Wno-unused-but-set-variable
|
||||
|
||||
# disable builtins
|
||||
CC_OPT += -fno-builtin-printf -fno-builtin-snprintf -fno-builtin-vsnprintf \
|
||||
-fno-builtin-malloc -fno-builtin-free -fno-builtin-log -fno-builtin-log2
|
||||
|
||||
CC_OPT += -D_KERNEL
|
||||
|
||||
# enable when debugging
|
||||
#CC_OPT += -DAC97_DEBUG
|
||||
#CC_OPT += -DAUICH_DEBUG
|
||||
#CC_OPT += -DAZALIA_DEBUG
|
||||
#CC_OPT += -DDIAGNOSTIC
|
||||
|
||||
# AC97 codec
|
||||
SRC_C += dev/ic/ac97.c
|
||||
|
||||
# HDA driver
|
||||
SRC_C += dev/pci/azalia.c dev/pci/azalia_codec.c
|
||||
|
||||
# ICH driver
|
||||
SRC_C += dev/pci/auich.c
|
||||
|
||||
# ES1370
|
||||
SRC_C += dev/pci/eap.c
|
||||
|
||||
vpath %.c $(AUDIO_CONTRIB_DIR)
|
||||
vpath %.c $(LIB_DIR)
|
||||
vpath %.cc $(LIB_DIR)
|
||||
|
||||
# vi: set ft=make :
|
@ -1,6 +1,8 @@
|
||||
PORT_DIR := $(call port_dir,$(REP_DIR)/ports/dde_bsd)
|
||||
|
||||
LIB_MK := $(addprefix lib/mk/, dde_bsd_audio.inc dde_bsd_audio_include.mk) \
|
||||
MK_FILES := dde_bsd_audio.inc dde_bsd_audio_include.mk dde_bsd_audio_pci.mk
|
||||
|
||||
LIB_MK := $(addprefix lib/mk/, $(MK_FILES)) \
|
||||
$(foreach SPEC,x86_32 x86_64,lib/mk/spec/$(SPEC)/dde_bsd_audio.mk) \
|
||||
lib/import/import-dde_bsd_audio_include.mk
|
||||
|
||||
@ -21,6 +23,7 @@ MIRROR_FROM_PORT_DIR := $(addprefix src/lib/audio/, \
|
||||
dev/audio.c \
|
||||
dev/ic/ac97.h \
|
||||
dev/ic/ac97.c \
|
||||
lib/libkern \
|
||||
sys/device.h \
|
||||
sys/audioio.h \
|
||||
sys/queue.h)
|
||||
|
@ -1,7 +1,7 @@
|
||||
REQUIRES = x86 pci
|
||||
TARGET = audio_drv
|
||||
SRC_CC = main.cc
|
||||
LIBS = dde_bsd_audio base
|
||||
LIBS = dde_bsd_audio dde_bsd_audio_pci base
|
||||
INC_DIR += $(REP_DIR)/include
|
||||
|
||||
CC_CXX_WARN_STRICT =
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014-2017 Genode Labs GmbH
|
||||
* Copyright (C) 2014-2020 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
@ -19,9 +19,6 @@
|
||||
#include <base/env.h>
|
||||
#include <irq_session/capability.h>
|
||||
|
||||
/* local includes */
|
||||
#include <scheduler.h>
|
||||
|
||||
namespace Bsd {
|
||||
|
||||
int probe_drivers(Genode::Env&, Genode::Allocator&);
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014-2017 Genode Labs GmbH
|
||||
* Copyright (C) 2014-2020 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
@ -24,31 +24,11 @@
|
||||
int hz = HZ;
|
||||
|
||||
|
||||
/* ioconf.c */
|
||||
int enodev(void) { return ENODEV; }
|
||||
|
||||
|
||||
extern struct cfdriver audio_cd;
|
||||
extern struct cfattach audio_ca;
|
||||
extern struct cfdriver azalia_cd;
|
||||
extern struct cfattach azalia_ca;
|
||||
extern struct cfdriver eap_cd;
|
||||
extern struct cfattach eap_ca;
|
||||
extern struct cfdriver auich_cd;
|
||||
extern struct cfattach auich_ca;
|
||||
|
||||
|
||||
/* original value */
|
||||
enum { PCI_BUS_PARENT = 56 };
|
||||
short pv[] = { -1, PCI_BUS_PARENT };
|
||||
|
||||
|
||||
struct cfdata cfdata[] = {
|
||||
{&audio_ca, &audio_cd, 0, 0, 0, 0, pv+0, 0, 0},
|
||||
{&azalia_ca, &azalia_cd, 0, 0, 0, 0, pv+1, 0, 0},
|
||||
{&eap_ca, &eap_cd, 0, 0, 0, 0, pv+1, 0, 0},
|
||||
{&auich_ca, &auich_cd, 0, 0, 0, 0, pv+1, 0, 0},
|
||||
};
|
||||
|
||||
|
||||
int enodev(void) { return ENODEV; }
|
||||
|
||||
|
||||
/* global character device switch table */
|
||||
@ -75,49 +55,6 @@ struct cdevsw cdevsw[] = {
|
||||
int nchrdev = sizeof(cdevsw) / sizeof(struct cdevsw);
|
||||
|
||||
|
||||
struct device pci_bus = { DV_DULL, { 0, 0 }, 0, 0, { 'p', 'c', 'i', '0'}, 0, 0, 0 };
|
||||
|
||||
/**
|
||||
* This function is our little helper that matches and attaches
|
||||
* the driver to the device.
|
||||
*/
|
||||
int probe_cfdata(struct pci_attach_args *pa)
|
||||
{
|
||||
size_t ncd = sizeof(cfdata) / sizeof(struct cfdata);
|
||||
|
||||
size_t i;
|
||||
for (i = 0; i < ncd; i++) {
|
||||
struct cfdata *cf = &cfdata[i];
|
||||
struct cfdriver *cd = cf->cf_driver;
|
||||
|
||||
if (*cf->cf_parents != PCI_BUS_PARENT)
|
||||
continue;
|
||||
|
||||
struct cfattach *ca = cf->cf_attach;
|
||||
if (!ca->ca_match)
|
||||
continue;
|
||||
|
||||
int rv = ca->ca_match(&pci_bus, 0, pa);
|
||||
|
||||
if (rv) {
|
||||
struct device *dev = (struct device *) malloc(ca->ca_devsize,
|
||||
M_DEVBUF, M_NOWAIT|M_ZERO);
|
||||
|
||||
dev->dv_cfdata = cf;
|
||||
|
||||
snprintf(dev->dv_xname, sizeof(dev->dv_xname), "%s%d", cd->cd_name,
|
||||
dev->dv_unit);
|
||||
printf("%s at %s\n", dev->dv_xname, pci_bus.dv_xname);
|
||||
ca->ca_attach(&pci_bus, dev, pa);
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
struct device *config_found_sm(struct device *parent, void *aux, cfprint_t print,
|
||||
cfmatch_t submatch)
|
||||
{
|
||||
@ -157,6 +94,7 @@ struct device *device_lookup(struct cfdriver *cd, int unit)
|
||||
return audio_cd.cd_devs[unit];
|
||||
}
|
||||
|
||||
|
||||
/*****************
|
||||
** sys/ucred.h **
|
||||
*****************/
|
||||
|
88
repos/dde_bsd/src/lib/audio/bsd_emul_pci.c
Normal file
88
repos/dde_bsd/src/lib/audio/bsd_emul_pci.c
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* \brief Audio driver BSD API emulation
|
||||
* \author Josef Soentgen
|
||||
* \date 2014-11-09
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014-2020 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#include <bsd_emul.h>
|
||||
|
||||
#include <sys/device.h>
|
||||
#include <dev/audio_if.h>
|
||||
|
||||
|
||||
/******************
|
||||
** sys/kernel.h **
|
||||
******************/
|
||||
|
||||
/* ioconf.c */
|
||||
extern struct cfdriver audio_cd;
|
||||
extern struct cfattach audio_ca;
|
||||
extern struct cfdriver azalia_cd;
|
||||
extern struct cfattach azalia_ca;
|
||||
extern struct cfdriver eap_cd;
|
||||
extern struct cfattach eap_ca;
|
||||
extern struct cfdriver auich_cd;
|
||||
extern struct cfattach auich_ca;
|
||||
|
||||
|
||||
/* original value */
|
||||
enum { PCI_BUS_PARENT = 56 };
|
||||
short pv[] = { -1, PCI_BUS_PARENT };
|
||||
|
||||
|
||||
struct cfdata cfdata[] = {
|
||||
{&audio_ca, &audio_cd, 0, 0, 0, 0, pv+0, 0, 0},
|
||||
{&azalia_ca, &azalia_cd, 0, 0, 0, 0, pv+1, 0, 0},
|
||||
{&eap_ca, &eap_cd, 0, 0, 0, 0, pv+1, 0, 0},
|
||||
{&auich_ca, &auich_cd, 0, 0, 0, 0, pv+1, 0, 0},
|
||||
};
|
||||
|
||||
|
||||
struct device pci_bus = { DV_DULL, { 0, 0 }, 0, 0, { 'p', 'c', 'i', '0'}, 0, 0, 0 };
|
||||
|
||||
/**
|
||||
* This function is our little helper that matches and attaches
|
||||
* the driver to the device.
|
||||
*/
|
||||
int probe_cfdata(struct pci_attach_args *pa)
|
||||
{
|
||||
size_t ncd = sizeof(cfdata) / sizeof(struct cfdata);
|
||||
|
||||
size_t i;
|
||||
for (i = 0; i < ncd; i++) {
|
||||
struct cfdata *cf = &cfdata[i];
|
||||
struct cfdriver *cd = cf->cf_driver;
|
||||
|
||||
if (*cf->cf_parents != PCI_BUS_PARENT)
|
||||
continue;
|
||||
|
||||
struct cfattach *ca = cf->cf_attach;
|
||||
if (!ca->ca_match)
|
||||
continue;
|
||||
|
||||
int rv = ca->ca_match(&pci_bus, 0, pa);
|
||||
|
||||
if (rv) {
|
||||
struct device *dev = (struct device *) malloc(ca->ca_devsize,
|
||||
M_DEVBUF, M_NOWAIT|M_ZERO);
|
||||
|
||||
dev->dv_cfdata = cf;
|
||||
|
||||
snprintf(dev->dv_xname, sizeof(dev->dv_xname), "%s%d", cd->cd_name,
|
||||
dev->dv_unit);
|
||||
printf("%s at %s\n", dev->dv_xname, pci_bus.dv_xname);
|
||||
ca->ca_attach(&pci_bus, dev, pa);
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014-2017 Genode Labs GmbH
|
||||
* Copyright (C) 2014-2020 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
@ -23,6 +23,7 @@
|
||||
#include <audio/audio.h>
|
||||
#include <bsd.h>
|
||||
#include <bsd_emul.h>
|
||||
#include <scheduler.h>
|
||||
|
||||
#include <extern_c_begin.h>
|
||||
# include <sys/device.h>
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014-2017 Genode Labs GmbH
|
||||
* Copyright (C) 2014-2020 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
@ -22,6 +22,7 @@
|
||||
#include <audio/audio.h>
|
||||
#include <bsd.h>
|
||||
#include <bsd_emul.h>
|
||||
#include <scheduler.h>
|
||||
|
||||
|
||||
namespace Bsd {
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014-2017 Genode Labs GmbH
|
||||
* Copyright (C) 2014-2020 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
@ -23,6 +23,7 @@
|
||||
#include <list.h>
|
||||
#include <bsd.h>
|
||||
#include <bsd_emul.h>
|
||||
#include <scheduler.h>
|
||||
|
||||
|
||||
static Genode::uint64_t millisecs;
|
||||
|
Loading…
x
Reference in New Issue
Block a user