Add MD functions for establishing and disestablishing interrupt handlers.
This commit is contained in:
parent
4c8f1ccfba
commit
f608d0812d
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: acpi_machdep.c,v 1.5 2018/11/12 12:56:05 jmcneill Exp $ */
|
||||
/* $NetBSD: acpi_machdep.c,v 1.6 2018/11/16 23:03:55 jmcneill Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2018 The NetBSD Foundation, Inc.
|
||||
@ -32,7 +32,7 @@
|
||||
#include "pci.h"
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.5 2018/11/12 12:56:05 jmcneill Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.6 2018/11/16 23:03:55 jmcneill Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -83,12 +83,7 @@ ACPI_STATUS
|
||||
acpi_md_OsInstallInterruptHandler(UINT32 irq, ACPI_OSD_HANDLER handler, void *context,
|
||||
void **cookiep, const char *xname)
|
||||
{
|
||||
const int ipl = IPL_TTY;
|
||||
const int type = IST_LEVEL; /* TODO: MADT */
|
||||
|
||||
*cookiep = intr_establish(irq, ipl, type, (int (*)(void *))handler, context);
|
||||
|
||||
return *cookiep == NULL ? AE_NO_MEMORY : AE_OK;
|
||||
return AE_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
void
|
||||
@ -200,6 +195,18 @@ acpi_md_OsDisableInterrupt(void)
|
||||
cpsid(I32_bit);
|
||||
}
|
||||
|
||||
void *
|
||||
acpi_md_intr_establish(uint32_t irq, int ipl, int type, int (*handler)(void *), void *arg, bool mpsafe, const char *xname)
|
||||
{
|
||||
return intr_establish_xname(irq, ipl, type | (mpsafe ? IST_MPSAFE : 0), handler, arg, xname);
|
||||
}
|
||||
|
||||
void
|
||||
acpi_md_intr_disestablish(void *ih)
|
||||
{
|
||||
intr_disestablish(ih);
|
||||
}
|
||||
|
||||
int
|
||||
acpi_md_sleep(int state)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: acpi_machdep.h,v 1.1 2018/10/12 22:12:12 jmcneill Exp $ */
|
||||
/* $NetBSD: acpi_machdep.h,v 1.2 2018/11/16 23:03:55 jmcneill Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2018 The NetBSD Foundation, Inc.
|
||||
@ -46,6 +46,9 @@ BOOLEAN acpi_md_OsReadable(void *, UINT32);
|
||||
BOOLEAN acpi_md_OsWritable(void *, UINT32);
|
||||
void acpi_md_OsEnableInterrupt(void);
|
||||
void acpi_md_OsDisableInterrupt(void);
|
||||
void * acpi_md_intr_establish(uint32_t, int, int, int (*)(void *),
|
||||
void *, bool, const char *);
|
||||
void acpi_md_intr_disestablish(void *);
|
||||
int acpi_md_sleep(int);
|
||||
uint32_t acpi_md_pdc(void);
|
||||
uint32_t acpi_md_ncpus(void);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: acpi_machdep.c,v 1.7 2018/03/20 12:14:52 bouyer Exp $ */
|
||||
/* $NetBSD: acpi_machdep.c,v 1.8 2018/11/16 23:03:55 jmcneill Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2009 KIYOHARA Takashi
|
||||
* All rights reserved.
|
||||
@ -28,7 +28,7 @@
|
||||
* Machine-dependent routines for ACPICA.
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.7 2018/03/20 12:14:52 bouyer Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.8 2018/11/16 23:03:55 jmcneill Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
@ -74,29 +74,34 @@ acpi_md_OsGetRootPointer(void)
|
||||
return acpi_root_phys;
|
||||
}
|
||||
|
||||
ACPI_STATUS
|
||||
acpi_md_OsInstallInterruptHandler(UINT32 InterruptNumber,
|
||||
ACPI_OSD_HANDLER ServiceRoutine,
|
||||
void *Context, void **cookiep,
|
||||
const char *xname)
|
||||
static int
|
||||
acpi_isa_irq_to_vector(UINT32 irq)
|
||||
{
|
||||
static int isa_irq_to_vector_map[16] = {
|
||||
/* i8259 IRQ translation, first 16 entries */
|
||||
0x2f, 0x20, 0x2e, 0x2d, 0x2c, 0x2b, 0x2a, 0x29,
|
||||
0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21,
|
||||
};
|
||||
int irq;
|
||||
void *ih;
|
||||
|
||||
if (has_i8259 && InterruptNumber < 16)
|
||||
irq = isa_irq_to_vector_map[InterruptNumber];
|
||||
else
|
||||
irq = InterruptNumber;
|
||||
if (has_i8259 && irq < 16)
|
||||
return isa_irq_to_vector_map[InterruptNumber];
|
||||
|
||||
return irq;
|
||||
}
|
||||
|
||||
ACPI_STATUS
|
||||
acpi_md_OsInstallInterruptHandler(UINT32 InterruptNumber,
|
||||
ACPI_OSD_HANDLER ServiceRoutine,
|
||||
void *Context, void **cookiep,
|
||||
const char *xname)
|
||||
{
|
||||
const int vec = acpi_isa_irq_to_vector(irq);
|
||||
void *ih;
|
||||
|
||||
/*
|
||||
* XXX probably, IPL_BIO is enough.
|
||||
*/
|
||||
ih = intr_establish(irq, IST_LEVEL, IPL_TTY,
|
||||
ih = intr_establish(vec, IST_LEVEL, IPL_TTY,
|
||||
(int (*)(void *)) ServiceRoutine, Context);
|
||||
if (ih == NULL)
|
||||
return AE_NO_MEMORY;
|
||||
@ -111,6 +116,21 @@ acpi_md_OsRemoveInterruptHandler(void *cookie)
|
||||
intr_disestablish(cookie);
|
||||
}
|
||||
|
||||
void *
|
||||
acpi_md_intr_establish(uint32_t irq, int ipl, int type, int (*handler)(void *),
|
||||
void *arg, bool mpsafe, const char *xname)
|
||||
{
|
||||
const int vec = acpi_isa_irq_to_vector(irq);
|
||||
|
||||
return intr_establish(vec, type, ipl, handler, arg);
|
||||
}
|
||||
|
||||
void
|
||||
acpi_md_intr_disestablish(void *ih)
|
||||
{
|
||||
intr_disestablish(ih);
|
||||
}
|
||||
|
||||
ACPI_STATUS
|
||||
acpi_md_OsMapMemory(ACPI_PHYSICAL_ADDRESS PhysicalAddress, UINT32 Length,
|
||||
void **LogicalAddress)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: acpi_machdep.h,v 1.7 2018/03/20 12:14:52 bouyer Exp $ */
|
||||
/* $NetBSD: acpi_machdep.h,v 1.8 2018/11/16 23:03:55 jmcneill Exp $ */
|
||||
|
||||
ACPI_STATUS acpi_md_OsInitialize(void);
|
||||
ACPI_PHYSICAL_ADDRESS acpi_md_OsGetRootPointer(void);
|
||||
@ -25,6 +25,10 @@ BOOLEAN acpi_md_OsWritable(void *, UINT32);
|
||||
void acpi_md_OsEnableInterrupt(void);
|
||||
void acpi_md_OsDisableInterrupt(void);
|
||||
|
||||
void * acpi_md_intr_establish(uint32_t, int, int, int (*)(void *),
|
||||
void *, bool, const char *);
|
||||
void acpi_md_intr_disestablish(void *);
|
||||
|
||||
int acpi_md_sleep(int);
|
||||
uint32_t acpi_md_pdc(void);
|
||||
uint32_t acpi_md_ncpus(void);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: acpi_machdep.c,v 1.19 2018/03/20 12:14:52 bouyer Exp $ */
|
||||
/* $NetBSD: acpi_machdep.c,v 1.20 2018/11/16 23:03:55 jmcneill Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 2001 Wasabi Systems, Inc.
|
||||
@ -40,7 +40,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.19 2018/03/20 12:14:52 bouyer Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.20 2018/11/16 23:03:55 jmcneill Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -265,6 +265,27 @@ acpi_md_OsRemoveInterruptHandler(void *cookie)
|
||||
intr_disestablish(cookie);
|
||||
}
|
||||
|
||||
void *
|
||||
acpi_md_intr_establish(uint32_t irq, int ipl, int type, int (*handler)(void *),
|
||||
void *arg, bool mpsafe, const char *xname)
|
||||
{
|
||||
struct pic *pic;
|
||||
int pin;
|
||||
|
||||
pic = intr_findpic(irq);
|
||||
if (pic == NULL)
|
||||
return NULL;
|
||||
pin = irq - pic->pic_vecbase;
|
||||
|
||||
return intr_establish_xname(irq, pic, pin, type, ipl, handler, arg, mpsafe, xname);
|
||||
}
|
||||
|
||||
void
|
||||
acpi_md_intr_disestablish(void *ih)
|
||||
{
|
||||
intr_disestablish(ih);
|
||||
}
|
||||
|
||||
ACPI_STATUS
|
||||
acpi_md_OsMapMemory(ACPI_PHYSICAL_ADDRESS PhysicalAddress,
|
||||
uint32_t Length, void **LogicalAddress)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: acpi_machdep.h,v 1.12 2018/03/20 12:14:52 bouyer Exp $ */
|
||||
/* $NetBSD: acpi_machdep.h,v 1.13 2018/11/16 23:03:55 jmcneill Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 2001 Wasabi Systems, Inc.
|
||||
@ -70,6 +70,10 @@ BOOLEAN acpi_md_OsWritable(void *, UINT32);
|
||||
void acpi_md_OsDisableInterrupt(void);
|
||||
void acpi_md_OsEnableInterrupt(void);
|
||||
|
||||
void * acpi_md_intr_establish(uint32_t, int, int, int (*)(void *),
|
||||
void *, bool, const char *);
|
||||
void acpi_md_intr_disestablish(void *);
|
||||
|
||||
int acpi_md_sleep(int);
|
||||
void acpi_md_sleep_init(void);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user