Deleted Added
full compact
OsdInterrupt.c (67760) OsdInterrupt.c (71875)
1/*-
2 * Copyright (c) 2000 Michael Smith
3 * Copyright (c) 2000 BSDi
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 10 unchanged lines hidden (view full) ---

19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
1/*-
2 * Copyright (c) 2000 Michael Smith
3 * Copyright (c) 2000 BSDi
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 10 unchanged lines hidden (view full) ---

19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * $FreeBSD: head/sys/dev/acpica/Osd/OsdInterrupt.c 67760 2000-10-28 06:56:15Z msmith $
27 * $FreeBSD: head/sys/dev/acpica/Osd/OsdInterrupt.c 71875 2001-01-31 09:34:54Z msmith $
28 */
29
30/*
31 * 6.5 : Interrupt handling
32 */
33
34#include "acpi.h"
35
36#include <sys/bus.h>
37#include <machine/resource.h>
38#include <machine/bus.h>
39#include <sys/rman.h>
40
41#include <dev/acpica/acpivar.h>
42
28 */
29
30/*
31 * 6.5 : Interrupt handling
32 */
33
34#include "acpi.h"
35
36#include <sys/bus.h>
37#include <machine/resource.h>
38#include <machine/bus.h>
39#include <sys/rman.h>
40
41#include <dev/acpica/acpivar.h>
42
43#define _COMPONENT OS_DEPENDENT
44MODULE_NAME("INTERRUPT")
45
43/*
44 * XXX this does not correctly free resources in the case of partically successful
45 * attachment.
46 */
47ACPI_STATUS
48AcpiOsInstallInterruptHandler(UINT32 InterruptNumber, OSD_HANDLER ServiceRoutine, void *Context)
49{
50 struct acpi_softc *sc;
51
46/*
47 * XXX this does not correctly free resources in the case of partically successful
48 * attachment.
49 */
50ACPI_STATUS
51AcpiOsInstallInterruptHandler(UINT32 InterruptNumber, OSD_HANDLER ServiceRoutine, void *Context)
52{
53 struct acpi_softc *sc;
54
55 FUNCTION_TRACE(__FUNCTION__);
56
52 if ((InterruptNumber < 0) || (InterruptNumber > 255))
57 if ((InterruptNumber < 0) || (InterruptNumber > 255))
53 return(AE_BAD_PARAMETER);
58 return_ACPI_STATUS(AE_BAD_PARAMETER);
54 if (ServiceRoutine == NULL)
59 if (ServiceRoutine == NULL)
55 return(AE_BAD_PARAMETER);
60 return_ACPI_STATUS(AE_BAD_PARAMETER);
56
57 if ((sc = devclass_get_softc(acpi_devclass, 0)) == NULL)
58 panic("can't find ACPI device to register interrupt");
59 if (sc->acpi_dev == NULL)
60 panic("acpi softc has invalid device");
61
62 /*
63 * This isn't strictly true, as we ought to be able to handle > 1 interrupt. The ACPI
64 * spec doesn't call for this though.
65 */
66 if (sc->acpi_irq != NULL) {
67 device_printf(sc->acpi_dev, "attempt to register more than one interrupt handler\n");
61
62 if ((sc = devclass_get_softc(acpi_devclass, 0)) == NULL)
63 panic("can't find ACPI device to register interrupt");
64 if (sc->acpi_dev == NULL)
65 panic("acpi softc has invalid device");
66
67 /*
68 * This isn't strictly true, as we ought to be able to handle > 1 interrupt. The ACPI
69 * spec doesn't call for this though.
70 */
71 if (sc->acpi_irq != NULL) {
72 device_printf(sc->acpi_dev, "attempt to register more than one interrupt handler\n");
68 return(AE_EXIST);
73 return_ACPI_STATUS(AE_EXIST);
69 }
70 sc->acpi_irq_rid = 0;
71 bus_set_resource(sc->acpi_dev, SYS_RES_IRQ, 0, InterruptNumber, 1);
72 if ((sc->acpi_irq = bus_alloc_resource(sc->acpi_dev, SYS_RES_IRQ, &sc->acpi_irq_rid, 0, ~0, 1,
73 RF_SHAREABLE | RF_ACTIVE)) == NULL) {
74 device_printf(sc->acpi_dev, "could not allocate SCI interrupt\n");
74 }
75 sc->acpi_irq_rid = 0;
76 bus_set_resource(sc->acpi_dev, SYS_RES_IRQ, 0, InterruptNumber, 1);
77 if ((sc->acpi_irq = bus_alloc_resource(sc->acpi_dev, SYS_RES_IRQ, &sc->acpi_irq_rid, 0, ~0, 1,
78 RF_SHAREABLE | RF_ACTIVE)) == NULL) {
79 device_printf(sc->acpi_dev, "could not allocate SCI interrupt\n");
75 return(AE_EXIST);
80 return_ACPI_STATUS(AE_EXIST);
76 }
77 if (bus_setup_intr(sc->acpi_dev, sc->acpi_irq, INTR_TYPE_MISC, (driver_intr_t *)ServiceRoutine, Context,
78 &sc->acpi_irq_handle)) {
79 device_printf(sc->acpi_dev, "could not set up SCI interrupt\n");
81 }
82 if (bus_setup_intr(sc->acpi_dev, sc->acpi_irq, INTR_TYPE_MISC, (driver_intr_t *)ServiceRoutine, Context,
83 &sc->acpi_irq_handle)) {
84 device_printf(sc->acpi_dev, "could not set up SCI interrupt\n");
80 return(AE_EXIST);
85 return_ACPI_STATUS(AE_EXIST);
81 }
82
86 }
87
83 return(AE_OK);
88 return_ACPI_STATUS(AE_OK);
84}
85
86ACPI_STATUS
87AcpiOsRemoveInterruptHandler (UINT32 InterruptNumber, OSD_HANDLER ServiceRoutine)
88{
89 struct acpi_softc *sc;
90
89}
90
91ACPI_STATUS
92AcpiOsRemoveInterruptHandler (UINT32 InterruptNumber, OSD_HANDLER ServiceRoutine)
93{
94 struct acpi_softc *sc;
95
96 FUNCTION_TRACE(__FUNCTION__);
97
91 if ((InterruptNumber < 0) || (InterruptNumber > 255))
98 if ((InterruptNumber < 0) || (InterruptNumber > 255))
92 return(AE_BAD_PARAMETER);
99 return_ACPI_STATUS(AE_BAD_PARAMETER);
93 if (ServiceRoutine == NULL)
100 if (ServiceRoutine == NULL)
94 return(AE_BAD_PARAMETER);
101 return_ACPI_STATUS(AE_BAD_PARAMETER);
95
96 if ((sc = devclass_get_softc(acpi_devclass, 0)) == NULL)
97 panic("can't find ACPI device to deregister interrupt");
98
99 if (sc->acpi_irq == NULL)
102
103 if ((sc = devclass_get_softc(acpi_devclass, 0)) == NULL)
104 panic("can't find ACPI device to deregister interrupt");
105
106 if (sc->acpi_irq == NULL)
100 return(AE_NOT_EXIST);
107 return_ACPI_STATUS(AE_NOT_EXIST);
101
102 bus_teardown_intr(sc->acpi_dev, sc->acpi_irq, sc->acpi_irq_handle);
103 bus_release_resource(sc->acpi_dev, SYS_RES_IRQ, 0, sc->acpi_irq);
104 bus_delete_resource(sc->acpi_dev, SYS_RES_IRQ, 0);
105
106 sc->acpi_irq = NULL;
107
108
109 bus_teardown_intr(sc->acpi_dev, sc->acpi_irq, sc->acpi_irq_handle);
110 bus_release_resource(sc->acpi_dev, SYS_RES_IRQ, 0, sc->acpi_irq);
111 bus_delete_resource(sc->acpi_dev, SYS_RES_IRQ, 0);
112
113 sc->acpi_irq = NULL;
114
108 return(AE_OK);
115 return_ACPI_STATUS(AE_OK);
109}
110
116}
117