freebsd compat. layer: a few more symbols, also respect malloc's M_ZERO

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20999 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Hugo Santos 2007-05-03 16:40:08 +00:00
parent 4bfa8f22df
commit 070b62bf11
3 changed files with 92 additions and 2 deletions

View File

@ -206,3 +206,12 @@ bus_teardown_intr(device_t dev, struct resource *res, void *arg)
return 0;
}
int
bus_generic_detach(device_t dev)
{
/* TODO */
return B_ERROR;
}

View File

@ -53,6 +53,20 @@ pci_get_device(device_t dev)
}
uint16_t
pci_get_subvendor(device_t dev)
{
return pci_read_config(dev, PCI_subsystem_vendor_id, 2);
}
uint16_t
pci_get_subdevice(device_t dev)
{
return pci_read_config(dev, PCI_subsystem_id, 2);
}
uint8_t
pci_get_revid(device_t dev)
{
@ -60,6 +74,22 @@ pci_get_revid(device_t dev)
}
static void
pci_set_command_bit(device_t dev, uint16_t bit)
{
uint16_t command = pci_read_config(dev, PCI_command, 2);
pci_write_config(dev, PCI_command, command | bit, 2);
}
int
pci_enable_busmaster(device_t dev)
{
pci_set_command_bit(dev, PCI_command_master);
return 0;
}
int
device_printf(device_t dev, const char *format, ...)
{
@ -74,6 +104,45 @@ device_printf(device_t dev, const char *format, ...)
}
void
device_set_desc(device_t dev, const char *desc)
{
dev->description = desc;
}
const char *
device_get_name(device_t dev)
{
/*
* if (dev != NULL && dev->devclass)
* return devclass_get_name(dev->devclass);
*/
return NULL;
}
int
device_get_unit(device_t dev)
{
return dev->unit;
}
const char *
device_get_nameunit(device_t dev)
{
return dev->nameunit;
}
void *
device_get_softc(device_t dev)
{
return dev->softc;
}
int
printf(const char *format, ...)
{
@ -99,9 +168,16 @@ int resource_int_value(const char *name, int unit, const char *resname,
void *
_kernel_malloc(size_t size, int flags)
{
// our kernel malloc() is insufficent
// our kernel malloc() is insufficent, must handle M_WAIT
return malloc(size);
void *ptr = malloc(size);
if (ptr == NULL)
return ptr;
if (flags & M_ZERO)
memset(ptr, 0, size);
return ptr;
}

View File

@ -31,6 +31,11 @@ struct device {
sem_id receive_sem;
struct ifnet * ifp;
int unit;
char nameunit[64];
const char * description;
void * softc;
};