Fixed a hang on boot problem with bus manager initialization. Apparently the BeOS kernel doesn't seem to like using spinlocks as the ver first thing in the boot process, so I rolled my own. Everything is now working consistently.

I also fixed my power button, so I don't need to test acpi_button by shorting motherboard contacts with a screwdriver...


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11465 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Nathan Whitehorn 2005-02-24 02:40:06 +00:00
parent a28a2204fb
commit 0a60ca24de
2 changed files with 28 additions and 13 deletions

View File

@ -1,5 +1,6 @@
#include <ACPI.h>
#include <KernelExport.h>
#include <stdio.h>
#include "acpi.h"
#include "acpixf.h"
@ -86,4 +87,4 @@ uint32 read_acpi_reg(uint32 id) {
void write_acpi_reg(uint32 id, uint32 value) {
AcpiSetRegister(id,value,ACPI_MTX_LOCK);
}
}

View File

@ -123,6 +123,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <malloc.h>
#include <sys/time.h>
#include <OS.h>
@ -501,12 +502,12 @@ AcpiOsMapMemory (
int page_offset = ACPI_TO_INTEGER(where) % B_PAGE_SIZE;
void *map_base = ACPI_PTR_ADD(void,where,0L - page_offset);
area_id area;
area = map_physical_memory("acpi_physical_mem_area", map_base, ROUNDUP(length + page_offset,B_PAGE_SIZE),B_ANY_KERNEL_BLOCK_ADDRESS,0,there);
*there += page_offset;
#endif
#endif
return (area > 0 ? AE_OK : AE_BAD_ADDRESS);
}
@ -688,8 +689,10 @@ ACPI_STATUS
AcpiOsCreateLock (
ACPI_HANDLE *OutHandle)
{
*OutHandle = (ACPI_HANDLE)memalign(sizeof(spinlock),sizeof(spinlock));
*OutHandle = (ACPI_HANDLE)malloc(sizeof(spinlock));
*((spinlock *)(*OutHandle)) = 1;
return AE_OK;
}
@ -706,15 +709,24 @@ AcpiOsAcquireLock (
ACPI_HANDLE Handle,
UINT32 Flags)
{
cpu_status cpu;
/*cpu_status cpu;
if (Flags == ACPI_NOT_ISR)
cpu = disable_interrupts();
acquire_spinlock ((spinlock *)(Handle));
if (Flags == ACPI_NOT_ISR)
restore_interrupts(cpu);
restore_interrupts(cpu);*/
/* Why aren't we using real spinlocks? Well, they seem to cause
kernel hangs at boot, at least on Dano. I don't really know
why, as they should be equivalent to this. Maybe in sysinit2
interrupts are already off, and the double disable interrupts
call is hanging the system? I'm not sure how to detect that
though. Anyway, this works, even if it's stupid. */
while (atomic_add(((spinlock *)(Handle)),0) <= 0);
}
@ -723,7 +735,7 @@ AcpiOsReleaseLock (
ACPI_HANDLE Handle,
UINT32 Flags)
{
cpu_status cpu;
/*cpu_status cpu;
if (Flags == ACPI_NOT_ISR)
cpu = disable_interrupts();
@ -731,7 +743,9 @@ AcpiOsReleaseLock (
release_spinlock ((spinlock *)(Handle));
if (Flags == ACPI_NOT_ISR)
restore_interrupts(cpu);
restore_interrupts(cpu);*/
atomic_add(((spinlock *)(Handle)),1);
}
@ -787,7 +801,7 @@ AcpiOsRemoveInterruptHandler (
{
#ifdef _KERNEL_MODE
dprintf("AcpiOsRemoveInterruptHandler()\n");
remove_io_interrupt_handler(InterruptNumber,(interrupt_handler)ServiceRoutine,NULL);
/* Crap. We don't get the Context argument back. */
#warning Sketchy code!
@ -896,7 +910,7 @@ AcpiOsStall (
if (microseconds)
{
snooze (microseconds);
spin (microseconds);
}
return;
}