Deleted Added
full compact
OsdSchedule.c (71418) OsdSchedule.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/OsdSchedule.c 71418 2001-01-23 09:43:23Z peter $
27 * $FreeBSD: head/sys/dev/acpica/Osd/OsdSchedule.c 71875 2001-01-31 09:34:54Z msmith $
28 */
29
30/*
31 * 6.3 : Scheduling services
32 */
33
34#include "acpi.h"
35
36#include <sys/kernel.h>
37#include <sys/malloc.h>
38#include <sys/taskqueue.h>
39#include <machine/clock.h>
40
28 */
29
30/*
31 * 6.3 : Scheduling services
32 */
33
34#include "acpi.h"
35
36#include <sys/kernel.h>
37#include <sys/malloc.h>
38#include <sys/taskqueue.h>
39#include <machine/clock.h>
40
41#define _COMPONENT OS_DEPENDENT
42MODULE_NAME("SCHEDULE")
43
41/*
42 * This is a little complicated due to the fact that we need to build and then
43 * free a 'struct task' for each task we enqueue.
44 *
45 * We use the default taskqueue_swi queue, since it really doesn't matter what
46 * else we're queued along with.
47 */
48

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

56 void *at_context;
57};
58
59ACPI_STATUS
60AcpiOsQueueForExecution(UINT32 Priority, OSD_EXECUTION_CALLBACK Function, void *Context)
61{
62 struct acpi_task *at;
63
44/*
45 * This is a little complicated due to the fact that we need to build and then
46 * free a 'struct task' for each task we enqueue.
47 *
48 * We use the default taskqueue_swi queue, since it really doesn't matter what
49 * else we're queued along with.
50 */
51

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

59 void *at_context;
60};
61
62ACPI_STATUS
63AcpiOsQueueForExecution(UINT32 Priority, OSD_EXECUTION_CALLBACK Function, void *Context)
64{
65 struct acpi_task *at;
66
67 FUNCTION_TRACE(__FUNCTION__);
68
64 if (Function == NULL)
69 if (Function == NULL)
65 return(AE_BAD_PARAMETER);
70 return_ACPI_STATUS(AE_BAD_PARAMETER);
66
67 at = malloc(sizeof(*at), M_ACPITASK, M_NOWAIT); /* Interrupt Context */
68 if (at == NULL)
71
72 at = malloc(sizeof(*at), M_ACPITASK, M_NOWAIT); /* Interrupt Context */
73 if (at == NULL)
69 return(AE_NO_MEMORY);
74 return_ACPI_STATUS(AE_NO_MEMORY);
70 bzero(at, sizeof(*at));
71
72 at->at_function = Function;
73 at->at_context = Context;
74 at->at_task.ta_func = AcpiOsExecuteQueue;
75 at->at_task.ta_context = at;
76 switch (Priority) {
77 case OSD_PRIORITY_GPE:

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

83 case OSD_PRIORITY_MED:
84 at->at_task.ta_priority = 2;
85 break;
86 case OSD_PRIORITY_LO:
87 at->at_task.ta_priority = 1;
88 break;
89 default:
90 free(at, M_ACPITASK);
75 bzero(at, sizeof(*at));
76
77 at->at_function = Function;
78 at->at_context = Context;
79 at->at_task.ta_func = AcpiOsExecuteQueue;
80 at->at_task.ta_context = at;
81 switch (Priority) {
82 case OSD_PRIORITY_GPE:

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

88 case OSD_PRIORITY_MED:
89 at->at_task.ta_priority = 2;
90 break;
91 case OSD_PRIORITY_LO:
92 at->at_task.ta_priority = 1;
93 break;
94 default:
95 free(at, M_ACPITASK);
91 return(AE_BAD_PARAMETER);
96 return_ACPI_STATUS(AE_BAD_PARAMETER);
92 }
93
94 taskqueue_enqueue(taskqueue_swi, (struct task *)at);
97 }
98
99 taskqueue_enqueue(taskqueue_swi, (struct task *)at);
95 return(AE_OK);
100 return_ACPI_STATUS(AE_OK);
96}
97
98static void
99AcpiOsExecuteQueue(void *arg, int pending)
100{
101 struct acpi_task *at = (struct acpi_task *)arg;
102 OSD_EXECUTION_CALLBACK Function;
103 void *Context;
104
101}
102
103static void
104AcpiOsExecuteQueue(void *arg, int pending)
105{
106 struct acpi_task *at = (struct acpi_task *)arg;
107 OSD_EXECUTION_CALLBACK Function;
108 void *Context;
109
110 FUNCTION_TRACE(__FUNCTION__);
111
105 Function = (OSD_EXECUTION_CALLBACK)at->at_function;
106 Context = at->at_context;
107
108 free(at, M_ACPITASK);
109
110 Function(Context);
112 Function = (OSD_EXECUTION_CALLBACK)at->at_function;
113 Context = at->at_context;
114
115 free(at, M_ACPITASK);
116
117 Function(Context);
118 return_VOID;
111}
112
113/*
114 * We don't have any sleep granularity better than hz, so
115 * make do with that.
116 */
117void
118AcpiOsSleep (UINT32 Seconds, UINT32 Milliseconds)
119{
120 int timo;
121
119}
120
121/*
122 * We don't have any sleep granularity better than hz, so
123 * make do with that.
124 */
125void
126AcpiOsSleep (UINT32 Seconds, UINT32 Milliseconds)
127{
128 int timo;
129
130 FUNCTION_TRACE(__FUNCTION__);
131
122 timo = (Seconds * hz) + Milliseconds / (1000 * hz);
123 if (timo == 0)
124 timo = 1;
125 tsleep(NULL, 0, "acpislp", timo);
132 timo = (Seconds * hz) + Milliseconds / (1000 * hz);
133 if (timo == 0)
134 timo = 1;
135 tsleep(NULL, 0, "acpislp", timo);
136 return_VOID;
126}
127
128void
129AcpiOsSleepUsec (UINT32 Microseconds)
130{
137}
138
139void
140AcpiOsSleepUsec (UINT32 Microseconds)
141{
142 FUNCTION_TRACE(__FUNCTION__);
143
131 if (Microseconds > 1000) { /* long enough to be worth the overhead of sleeping */
132 AcpiOsSleep(0, Microseconds / 1000);
133 } else {
134 DELAY(Microseconds);
135 }
144 if (Microseconds > 1000) { /* long enough to be worth the overhead of sleeping */
145 AcpiOsSleep(0, Microseconds / 1000);
146 } else {
147 DELAY(Microseconds);
148 }
149 return_VOID;
136}
150}