1/1

|
[or1ksim #20] Pass a pointer as the parameter in the schedular callback
by Unknown on Feb 4, 2005 |
Not available! | ||
|
Hi,
This does produce numerous warnings amongst the peripherals. They will however
be cleaned up when I get to them.
I have also made the SCHED_ADD function an inline to be able to easier detect
and fix warnings.
ChangeLog:
* Pass a pointer as the user given argument in the schedular callback.
nog.
-------------- next part --------------
--- support/sched.h 2004-10-16 00:52:59.000000000 +0200
+++ ../or1ksim-ac/support/sched.h 2005-02-04 11:51:12.000000000 +0100
@@ -30,8 +30,8 @@
/* Structure for holding one job entry */
struct sched_entry {
long long time; /* Clock cycles before job starts */
- int param; /* Parameter to pass to the function */
- void (*func)(int); /* Function to call when time reaches 0 */
+ void *param; /* Parameter to pass to the function */
+ void (*func)(void *); /* Function to call when time reaches 0 */
};
/* Heap of jobs */
@@ -44,7 +44,7 @@
/* Dummy function, representing a guard, which protects heap from
emptying */
-extern void sched_guard (int i);
+extern void sched_guard (void *);
/* Init scheduler -- clear the heap */
#define SCHED_INIT() {\
@@ -64,19 +64,32 @@
#endif
/* Adds new job to the queue */
-#define SCHED_ADD(job_func, job_param, job_time) {\
- int ___i;\
- if (SCHED_DEBUG > 0) PRINTF ("%s@%i:SCHED_ADD(func %p, param %i, time %i)\n", __FUNCTION__, runtime.sim.cycles, (job_func), (job_param), (job_time));\
- SCHED_PRINT_JOBS();\
- if (SCHED_DEBUG > 1) PRINTF ("--------\n");\
- ___i = scheduler.size++;\
- while (___i > 1 && scheduler.heap[___i / 2].time > (job_time)) scheduler.heap[___i] = scheduler.heap[___i /= 2];\
- scheduler.heap[___i].func = (job_func);\
- scheduler.heap[___i].param = (job_param);\
- scheduler.heap[___i].time = (job_time);\
- SCHED_PRINT_JOBS();\
+static inline void sched_add(void (*job_func)(void *), void *job_param,
+ long long job_time, const char *func)
+{
+ int i;
+
+ if (SCHED_DEBUG > 0)
+ PRINTF ("%s@%lli:SCHED_ADD(func %p, param %p, time %lli)\n", func,
+ runtime.sim.cycles, job_func, job_param, job_time);
+ SCHED_PRINT_JOBS();
+
+ if (SCHED_DEBUG > 1) PRINTF ("--------\n");\
+
+ i = scheduler.size++;
+ while (i > 1 && scheduler.heap[i / 2].time > job_time) {
+ scheduler.heap = scheduler.heap[i / 2];
+ i /= 2;
+ }
+
+ scheduler.heap.func = job_func;
+ scheduler.heap.param = job_param;
+ scheduler.heap.time = job_time;
+ SCHED_PRINT_JOBS();
}
+#define SCHED_ADD(job_func, job_param, job_time) sched_add(job_func, job_param, job_time, __FUNCTION__)
+
/* Removes an item from the heap */
#define SCHED_REMOVE_ITEM(index) {\
struct sched_entry *tmp;\
--- support/sched.c 2005-02-04 11:15:30.000000000 +0100
+++ ../or1ksim-ac/support/sched.c 2005-02-04 11:46:20.000000000 +0100
@@ -28,13 +28,22 @@
#include
#include "config.h"
+
+#ifdef HAVE_INTTYPES_H
+#include
+#endif
+
+#include "port.h"
+#include "arch.h"
+#include "sim-config.h"
+#include "config.h"
#include "sched.h"
struct scheduler_struct scheduler;
/* Dummy function, representing a guard, which protects heap from
emptying */
-void sched_guard (int i)
+void sched_guard (void *dat)
{
SCHED_INIT ();
}
--- peripheral/atadevice.c 2005-02-04 11:15:22.000000000 +0100
+++ ../or1ksim-ac/peripheral/atadevice.c 2005-02-04 11:50:23.000000000 +0100
@@ -32,7 +32,6 @@
#include "port.h"
#include "arch.h"
#include "abstract.h"
-#include "sched.h"
#include "messages.h"
#include "atadevice.h"
--- pic/pic.c 2005-02-04 12:18:44.000000000 +0100
+++ ../or1ksim-ac/pic/pic.c 2005-02-04 12:17:40.000000000 +0100
@@ -51,13 +51,13 @@
}
/* Simulation hook. Called when interrupts are masked. */
-void pic_clock(int i)
+void pic_clock(void *dat)
{
/* Don't do anything if interrupts not currently enabled */
if(testsprbits (SPR_SR, SPR_SR_IEE))
except_handle(EXCEPT_INT, mfspr(SPR_EEAR_BASE));
else
- SCHED_ADD(pic_clock, 0, runtime.sim.cycles + 1);
+ SCHED_ADD(pic_clock, NULL, runtime.sim.cycles + 1);
}
/* WARNING: Don't eaven try and call this function *during* a simulated
@@ -78,6 +78,6 @@
except_handle(EXCEPT_INT, mfspr(SPR_EEAR_BASE));
else
/* Interrupts not currently enabled, retry next clock cycle */
- SCHED_ADD(pic_clock, 0, runtime.sim.cycles + 1);
+ SCHED_ADD(pic_clock, NULL, runtime.sim.cycles + 1);
}
}
--- tick/tick.c 2005-02-04 12:18:39.000000000 +0100
+++ ../or1ksim-ac/tick/tick.c 2005-02-04 12:08:12.000000000 +0100
@@ -61,7 +61,7 @@
}
/* Job handler for tick timer */
-void tick_job (int param)
+void tick_job (void *param)
{
int mode = (ttmr & SPR_TTMR_M) >> 30;
/*debug (7, "tick_job%i, param %i\n", param, mode);*/
@@ -70,7 +70,7 @@
if (!param) {
sprs[SPR_TTCR] = ttcr = 0;
cycles_start = runtime.sim.cycles - ttcr;
- SCHED_ADD(tick_job, 0, runtime.sim.cycles + (ttmr & SPR_TTMR_PERIOD) - ttcr);
+ SCHED_ADD(tick_job, (void *)0, runtime.sim.cycles + (ttmr & SPR_TTMR_PERIOD) - ttcr);
}
case 2:
if (ttmr & SPR_TTMR_IE) {
@@ -81,7 +81,7 @@
else
/* If TEE is currently not set we have to pend tick exception
by rescheduling. */
- SCHED_ADD(tick_job, 1, runtime.sim.cycles + 1);
+ SCHED_ADD(tick_job, (void *)1, runtime.sim.cycles + 1);
}
break;
}
@@ -94,10 +94,10 @@
/*debug (7, "ttcr = %08x\n", value);*/
ttcr = value;
/* Remove previous if it exists */
- SCHED_FIND_REMOVE(tick_job, 0);
- SCHED_FIND_REMOVE(tick_job, 1);
+ SCHED_FIND_REMOVE(tick_job, (void *)0);
+ SCHED_FIND_REMOVE(tick_job, (void *)1);
if (mode == 1 || mode == 2) {
- SCHED_ADD(tick_job, 0, runtime.sim.cycles + (ttmr & SPR_TTMR_PERIOD) - ttcr);
+ SCHED_ADD(tick_job, (void *)0, runtime.sim.cycles + (ttmr & SPR_TTMR_PERIOD) - ttcr);
cycles_start = runtime.sim.cycles - ttcr;
}
}
@@ -109,19 +109,19 @@
/* Handle the modes properly. */
switch((ttmr & SPR_TTMR_M) >> 30) {
case 0: /* Timer is disabled */
- SCHED_FIND_REMOVE(tick_job, 0);
- SCHED_FIND_REMOVE(tick_job, 1);
+ SCHED_FIND_REMOVE(tick_job, (void *)0);
+ SCHED_FIND_REMOVE(tick_job, (void *)1);
break;
case 1: /* Timer should auto restart */
sprs[SPR_TTCR] = ttcr = 0;
cycles_start = runtime.sim.cycles;
- SCHED_FIND_REMOVE(tick_job, 0);
- SCHED_FIND_REMOVE(tick_job, 1);
- SCHED_ADD(tick_job, 0, runtime.sim.cycles + (ttmr & SPR_TTMR_PERIOD) - ttcr);
+ SCHED_FIND_REMOVE(tick_job, (void *)0);
+ SCHED_FIND_REMOVE(tick_job, (void *)1);
+ SCHED_ADD(tick_job, (void *)0, runtime.sim.cycles + (ttmr & SPR_TTMR_PERIOD) - ttcr);
break;
case 2: /* Stop the timer when match */
- SCHED_FIND_REMOVE(tick_job, 0);
- SCHED_FIND_REMOVE(tick_job, 1);
+ SCHED_FIND_REMOVE(tick_job, (void *)0);
+ SCHED_FIND_REMOVE(tick_job, (void *)1);
break;
case 3: /* Timer keeps running -- do nothing*/
break;
--- toplevel.c 2005-02-04 15:55:48.000000000 +0100
+++ ../or1ksim-ac/toplevel.c 2005-02-04 15:54:32.000000000 +0100
@@ -347,8 +345,8 @@
/* Executes jobs in time queue */
static inline void do_scheduler ()
{
- void (*func)(int);
- int param;
+ void (*func)(void *);
+ void *param;
/* Execute all jobs till now */
do {
|
|||
1/1

