2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
6 #include <aros/asmcall.h>
7 #include <aros/debug.h>
8 #include <aros/symbolsets.h>
9 #include <exec/memory.h>
10 #include <utility/hooks.h>
11 #include <proto/exec.h>
12 #include <proto/acpica.h>
14 #include "hpet_intern.h"
16 /* acpica.library is optional */
17 struct Library
*ACPICABase
= NULL
;
19 AROS_UFH3(static BOOL
, hpetEnumFunc
,
20 AROS_UFHA(struct Hook
*, hook
, A0
),
21 AROS_UFHA(ACPI_TABLE_HPET
*, table
, A2
),
22 AROS_UFHA(struct HPETBase
*, base
, A1
))
28 if (table
->Address
.SpaceId
!= ACPI_ADR_SPACE_SYSTEM_MEMORY
)
31 n
= (table
->Id
& HPET_NUM_COMPARATORS_MASK
) >> HPET_NUM_COMPARATORS_SHIFT
;
35 IPTR blk
= table
->Address
.Address
+ 0x0100;
38 for (i
= 0; i
< n
; i
++)
40 base
->units
[base
->unitCnt
+ i
].base
= table
->Address
.Address
;
41 base
->units
[base
->unitCnt
+ i
].block
= blk
;
42 base
->units
[base
->unitCnt
+ i
].Owner
= NULL
;
54 static const struct Hook enumHook
=
56 .h_Entry
= (APTR
)hpetEnumFunc
59 static int hpet_Init(struct HPETBase
*base
)
63 ACPICABase
= OpenLibrary("acpica.library", 0);
67 /* During the 1st pass base->units is NULL, so we will just count HPETs */
68 AcpiScanTables("HPET", &enumHook
, base
);
70 D(bug("[HPET] %u units total\n", base
->unitCnt
));
72 base
->units
= AllocMem(sizeof(struct HPETUnit
) * base
->unitCnt
, MEMF_CLEAR
);
74 InitSemaphore(&base
->lock
);
76 /* Fill in the data */
78 AcpiScanTables("HPET", &enumHook
, base
);
79 CloseLibrary(ACPICABase
);
86 CloseLibrary(ACPICABase
);
91 ADD2INITLIB(hpet_Init
, 0);