Style cleanups to reduce diffs to locking tree.

This commit is contained in:
Nate Lawson 2004-04-14 03:39:08 +00:00
parent ea6b2bc923
commit c871a6da4c
5 changed files with 91 additions and 111 deletions

View file

@ -33,17 +33,9 @@
#include "opt_ddb.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/cons.h>
#include <sys/kernel.h>
#include <sys/bus.h>
#include <machine/resource.h>
#include <machine/bus.h>
#include <sys/rman.h>
#include <ddb/ddb.h>
#include <ddb/db_output.h>
#include "acpi.h"
#include "acdebug.h"
@ -59,29 +51,28 @@ AcpiOsGetLine(char *Buffer)
for (cp = Buffer; *cp != 0; cp++)
if (*cp == '\n')
*cp = 0;
return(AE_OK);
return (AE_OK);
#else
printf("AcpiOsGetLine called but no input support");
return(AE_NOT_EXIST);
#endif
return (AE_NOT_EXIST);
#endif /* DDB */
}
void
AcpiOsDbgAssert(void *FailedAssertion, void *FileName, UINT32 LineNumber, char *Message)
AcpiOsDbgAssert(void *FailedAssertion, void *FileName, UINT32 LineNumber,
char *Message)
{
printf("ACPI: %s:%d - %s\n", (char *)FileName, LineNumber, Message);
printf("ACPI: assertion %s\n", (char *)FailedAssertion);
}
ACPI_STATUS
AcpiOsSignal (
UINT32 Function,
void *Info)
AcpiOsSignal(UINT32 Function, void *Info)
{
ACPI_SIGNAL_FATAL_INFO *fatal;
char *message;
switch(Function) {
switch (Function) {
case ACPI_SIGNAL_FATAL:
fatal = (ACPI_SIGNAL_FATAL_INFO *)Info;
printf("ACPI fatal signal, type 0x%x code 0x%x argument 0x%x",
@ -95,9 +86,10 @@ AcpiOsSignal (
break;
default:
return(AE_BAD_PARAMETER);
return (AE_BAD_PARAMETER);
}
return(AE_OK);
return (AE_OK);
}
#ifdef ACPI_DEBUGGER
@ -116,4 +108,4 @@ acpi_EnterDebugger(void)
printf("Entering ACPICA debugger...\n");
AcpiDbUserCommands('A', &obj);
}
#endif
#endif /* ACPI_DEBUGGER */

View file

@ -67,34 +67,31 @@
#endif
ACPI_STATUS
AcpiOsReadPort (
ACPI_IO_ADDRESS InPort,
UINT32 *Value,
UINT32 Width)
AcpiOsReadPort(ACPI_IO_ADDRESS InPort, UINT32 *Value, UINT32 Width)
{
switch (Width) {
case 8:
*(u_int8_t *)Value = bus_space_read_1(ACPI_BUS_SPACE_IO, ACPI_BUS_HANDLE, InPort);
*(u_int8_t *)Value = bus_space_read_1(ACPI_BUS_SPACE_IO,
ACPI_BUS_HANDLE, InPort);
break;
case 16:
*(u_int16_t *)Value = bus_space_read_2(ACPI_BUS_SPACE_IO, ACPI_BUS_HANDLE, InPort);
*(u_int16_t *)Value = bus_space_read_2(ACPI_BUS_SPACE_IO,
ACPI_BUS_HANDLE, InPort);
break;
case 32:
*(u_int32_t *)Value = bus_space_read_4(ACPI_BUS_SPACE_IO, ACPI_BUS_HANDLE, InPort);
*(u_int32_t *)Value = bus_space_read_4(ACPI_BUS_SPACE_IO,
ACPI_BUS_HANDLE, InPort);
break;
default:
/* debug trap goes here */
break;
}
return(AE_OK);
return (AE_OK);
}
ACPI_STATUS
AcpiOsWritePort (
ACPI_IO_ADDRESS OutPort,
UINT32 Value,
UINT32 Width)
AcpiOsWritePort(ACPI_IO_ADDRESS OutPort, UINT32 Value, UINT32 Width)
{
switch (Width) {
case 8:
@ -111,23 +108,21 @@ AcpiOsWritePort (
break;
}
return(AE_OK);
return (AE_OK);
}
ACPI_STATUS
AcpiOsReadPciConfiguration (
ACPI_PCI_ID *PciId,
UINT32 Register,
void *Value,
UINT32 Width)
AcpiOsReadPciConfiguration(ACPI_PCI_ID *PciId, UINT32 Register, void *Value,
UINT32 Width)
{
u_int32_t byte_width = Width / 8;
u_int32_t val;
if (!pci_cfgregopen())
return(AE_NOT_EXIST);
return (AE_NOT_EXIST);
val = pci_cfgregread(PciId->Bus, PciId->Device, PciId->Function, Register, byte_width);
val = pci_cfgregread(PciId->Bus, PciId->Device, PciId->Function, Register,
byte_width);
switch (Width) {
case 8:
*(u_int8_t *)Value = val & 0xff;
@ -143,26 +138,23 @@ AcpiOsReadPciConfiguration (
break;
}
return(AE_OK);
return (AE_OK);
}
ACPI_STATUS
AcpiOsWritePciConfiguration (
ACPI_PCI_ID *PciId,
UINT32 Register,
ACPI_INTEGER Value,
UINT32 Width)
AcpiOsWritePciConfiguration (ACPI_PCI_ID *PciId, UINT32 Register,
ACPI_INTEGER Value, UINT32 Width)
{
u_int32_t byte_width = Width / 8;
if (!pci_cfgregopen())
return(AE_NOT_EXIST);
return (AE_NOT_EXIST);
pci_cfgregwrite(PciId->Bus, PciId->Device, PciId->Function, Register, Value, byte_width);
pci_cfgregwrite(PciId->Bus, PciId->Device, PciId->Function, Register,
Value, byte_width);
return(AE_OK);
return (AE_OK);
}
/* XXX should use acpivar.h but too many include dependencies */
@ -176,33 +168,37 @@ static int
acpi_bus_number(ACPI_HANDLE root, ACPI_HANDLE curr, ACPI_PCI_ID *PciId)
{
ACPI_HANDLE parent;
ACPI_STATUS status;
ACPI_OBJECT_TYPE type;
UINT32 adr;
int bus, slot, func, class, subclass, header;
/* Try to get the _BBN object of the root, otherwise assume it is 0 */
/* Try to get the _BBN object of the root, otherwise assume it is 0. */
bus = 0;
if (root == curr) {
if (ACPI_FAILURE(acpi_GetInteger(root, "_BBN", &bus)) &&
bootverbose)
printf("acpi_bus_number: root bus has no _BBN, assuming 0\n");
status = acpi_GetInteger(root, "_BBN", &bus);
if (ACPI_FAILURE(status) && bootverbose)
printf("acpi_bus_number: root bus has no _BBN, assuming 0\n");
return (bus);
}
if (ACPI_FAILURE(AcpiGetParent(curr, &parent)))
return (bus);
status = AcpiGetParent(curr, &parent);
if (ACPI_FAILURE(status))
return (bus);
/* First, recurse up the tree until we find the host bus */
/* First, recurse up the tree until we find the host bus. */
bus = acpi_bus_number(root, parent, PciId);
/* Validate parent bus device type */
/* Validate parent bus device type. */
if (ACPI_FAILURE(AcpiGetType(parent, &type)) || type != ACPI_TYPE_DEVICE) {
printf("acpi_bus_number: not a device, type %d\n", type);
return (bus);
printf("acpi_bus_number: not a device, type %d\n", type);
return (bus);
}
/* Get the parent's slot and function */
if (ACPI_FAILURE(acpi_GetInteger(parent, "_ADR", &adr))) {
printf("acpi_bus_number: can't get _ADR\n");
return (bus);
/* Get the parent's slot and function. */
status = acpi_GetInteger(parent, "_ADR", &adr);
if (ACPI_FAILURE(status)) {
printf("acpi_bus_number: can't get _ADR\n");
return (bus);
}
slot = ACPI_HIWORD(adr);
func = ACPI_LOWORD(adr);
@ -210,14 +206,15 @@ acpi_bus_number(ACPI_HANDLE root, ACPI_HANDLE curr, ACPI_PCI_ID *PciId)
/* Is this a PCI-PCI or Cardbus-PCI bridge? */
class = pci_cfgregread(bus, slot, func, PCIR_CLASS, 1);
if (class != PCIC_BRIDGE)
return (bus);
return (bus);
subclass = pci_cfgregread(bus, slot, func, PCIR_SUBCLASS, 1);
/* Find the header type, masking off the multifunction bit */
/* Find the header type, masking off the multifunction bit. */
header = pci_cfgregread(bus, slot, func, PCIR_HDRTYPE, 1) & PCIM_HDRTYPE;
if (header == PCIM_HDRTYPE_BRIDGE && subclass == PCIS_BRIDGE_PCI)
bus = pci_cfgregread(bus, slot, func, PCIR_SECBUS_1, 1);
bus = pci_cfgregread(bus, slot, func, PCIR_SECBUS_1, 1);
if (header == PCIM_HDRTYPE_CARDBUS && subclass == PCIS_BRIDGE_CARDBUS)
bus = pci_cfgregread(bus, slot, func, PCIR_SECBUS_2, 1);
bus = pci_cfgregread(bus, slot, func, PCIR_SECBUS_2, 1);
return (bus);
}
@ -229,24 +226,23 @@ acpi_bus_number(ACPI_HANDLE root, ACPI_HANDLE curr, ACPI_PCI_ID *PciId)
* PciId: pointer to device slot and function, we fill out bus
*/
void
AcpiOsDerivePciId (
ACPI_HANDLE rhandle,
ACPI_HANDLE chandle,
ACPI_PCI_ID **PciId)
AcpiOsDerivePciId(ACPI_HANDLE rhandle, ACPI_HANDLE chandle, ACPI_PCI_ID **PciId)
{
ACPI_HANDLE parent;
ACPI_STATUS status;
int bus;
if (pci_cfgregopen() == 0)
panic("AcpiOsDerivePciId unable to initialize pci bus");
panic("AcpiOsDerivePciId unable to initialize pci bus");
/* Try to read _BBN for bus number if we're at the root */
bus = 0;
if (rhandle == chandle) {
if (ACPI_FAILURE(acpi_GetInteger(rhandle, "_BBN", &bus)) &&
bootverbose)
printf("AcpiOsDerivePciId: root bus has no _BBN, assuming 0\n");
status = acpi_GetInteger(rhandle, "_BBN", &bus);
if (ACPI_FAILURE(status) && bootverbose)
printf("AcpiOsDerivePciId: root bus has no _BBN, assuming 0\n");
}
/*
* Get the parent handle and call the recursive case. It is not
* clear why we seem to be getting a chandle that points to a child
@ -254,10 +250,10 @@ AcpiOsDerivePciId (
* here works.
*/
if (ACPI_SUCCESS(AcpiGetParent(chandle, &parent)))
bus = acpi_bus_number(rhandle, parent, *PciId);
bus = acpi_bus_number(rhandle, parent, *PciId);
(*PciId)->Bus = bus;
if (bootverbose) {
printf("AcpiOsDerivePciId: bus %d dev %d func %d\n",
(*PciId)->Bus, (*PciId)->Device, (*PciId)->Function);
printf("AcpiOsDerivePciId: bus %d dev %d func %d\n",
(*PciId)->Bus, (*PciId)->Device, (*PciId)->Function);
}
}

View file

@ -39,40 +39,42 @@
#include <vm/vm.h>
#include <vm/pmap.h>
static MALLOC_DEFINE(M_ACPICA, "acpica", "ACPI CA memory pool");
MALLOC_DEFINE(M_ACPICA, "acpica", "ACPI CA memory pool");
void *
AcpiOsAllocate(ACPI_SIZE Size)
{
return(malloc(Size, M_ACPICA, M_NOWAIT));
return (malloc(Size, M_ACPICA, M_NOWAIT));
}
void
AcpiOsFree (void *Memory)
AcpiOsFree(void *Memory)
{
free(Memory, M_ACPICA);
}
ACPI_STATUS
AcpiOsMapMemory (ACPI_PHYSICAL_ADDRESS PhysicalAddress, ACPI_SIZE Length, void **LogicalAddress)
AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS PhysicalAddress, ACPI_SIZE Length,
void **LogicalAddress)
{
*LogicalAddress = pmap_mapdev((vm_offset_t)PhysicalAddress, Length);
if (*LogicalAddress == NULL)
return(AE_BAD_ADDRESS);
return(AE_OK);
return (AE_BAD_ADDRESS);
return (AE_OK);
}
void
AcpiOsUnmapMemory (void *LogicalAddress, ACPI_SIZE Length)
AcpiOsUnmapMemory(void *LogicalAddress, ACPI_SIZE Length)
{
pmap_unmapdev((vm_offset_t)LogicalAddress, Length);
}
ACPI_STATUS
AcpiOsGetPhysicalAddress(void *LogicalAddress, ACPI_PHYSICAL_ADDRESS *PhysicalAddress)
AcpiOsGetPhysicalAddress(void *LogicalAddress,
ACPI_PHYSICAL_ADDRESS *PhysicalAddress)
{
/* we can't necessarily do this, so cop out */
return(AE_BAD_ADDRESS);
/* We can't necessarily do this, so cop out. */
return (AE_BAD_ADDRESS);
}
/*
@ -82,26 +84,22 @@ AcpiOsGetPhysicalAddress(void *LogicalAddress, ACPI_PHYSICAL_ADDRESS *PhysicalAd
BOOLEAN
AcpiOsReadable (void *Pointer, ACPI_SIZE Length)
{
return(TRUE);
return (TRUE);
}
BOOLEAN
AcpiOsWritable (void *Pointer, ACPI_SIZE Length)
{
return(TRUE);
return (TRUE);
}
ACPI_STATUS
AcpiOsReadMemory (
ACPI_PHYSICAL_ADDRESS Address,
UINT32 *Value,
UINT32 Width)
AcpiOsReadMemory(ACPI_PHYSICAL_ADDRESS Address, UINT32 *Value, UINT32 Width)
{
void *LogicalAddress;
if (AcpiOsMapMemory(Address, Width / 8, &LogicalAddress) != AE_OK) {
return(AE_NOT_EXIST);
}
if (AcpiOsMapMemory(Address, Width / 8, &LogicalAddress) != AE_OK)
return (AE_NOT_EXIST);
switch (Width) {
case 8:
@ -123,20 +121,16 @@ AcpiOsReadMemory (
AcpiOsUnmapMemory(LogicalAddress, Width / 8);
return(AE_OK);
return (AE_OK);
}
ACPI_STATUS
AcpiOsWriteMemory (
ACPI_PHYSICAL_ADDRESS Address,
UINT32 Value,
UINT32 Width)
AcpiOsWriteMemory(ACPI_PHYSICAL_ADDRESS Address, UINT32 Value, UINT32 Width)
{
void *LogicalAddress;
if (AcpiOsMapMemory(Address, Width / 8, &LogicalAddress) != AE_OK) {
return(AE_NOT_EXIST);
}
if (AcpiOsMapMemory(Address, Width / 8, &LogicalAddress) != AE_OK)
return (AE_NOT_EXIST);
switch (Width) {
case 8:
@ -158,5 +152,5 @@ AcpiOsWriteMemory (
AcpiOsUnmapMemory(LogicalAddress, Width / 8);
return(AE_OK);
return (AE_OK);
}

View file

@ -34,7 +34,7 @@
#include "acpi.h"
void
AcpiOsPrintf (const char *Format, ...)
AcpiOsPrintf(const char *Format, ...)
{
va_list ap;
@ -44,8 +44,7 @@ AcpiOsPrintf (const char *Format, ...)
}
void
AcpiOsVprintf (const char *Format, va_list Args)
AcpiOsVprintf(const char *Format, va_list Args)
{
vprintf(Format, Args);
}

View file

@ -70,7 +70,6 @@ struct acpi_softc {
int acpi_sleep_delay;
int acpi_s4bios;
int acpi_disable_on_poweroff;
int acpi_verbose;
bus_dma_tag_t acpi_waketag;
@ -88,7 +87,7 @@ struct acpi_device {
int ad_magic;
void *ad_private;
/* resources */
/* Resources */
struct resource_list ad_rl;
};