Search
lxdream.org :: lxdream/src/eventq.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/eventq.h
changeset 1119:45602839e067
prev1112:4cac5e474d4c
author nkeynes
date Fri Mar 02 23:49:10 2012 +1000 (8 years ago)
permissions -rw-r--r--
last change Android WIP:
* Rename gui_jni.c to gui_android.c - now quite android specific.
* Implement generic EGL driver with very minimal Java wrapper
* Run emulation in separate thread, and implement simple queue for
inter-thread communication.
* Add menu/action-bar items for start + reset
view annotate diff log raw
     1 /**
     2  * $Id$
     3  *
     4  * Simple implementation of one-shot timers. Effectively this allows IO
     5  * devices to wait until a particular time before completing. We expect 
     6  * there to be at least half a dozen or so continually scheduled events
     7  * (TMU and PVR2), peaking around 20+.
     8  *
     9  * Copyright (c) 2005 Nathan Keynes.
    10  *
    11  * This program is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
    14  * (at your option) any later version.
    15  *
    16  * This program is distributed in the hope that it will be useful,
    17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
    20  */
    22 #ifndef lxdream_eventq_H
    23 #define lxdream_eventq_H 1
    25 #include "lxdream.h"
    27 #ifdef __cplusplus
    28 extern "C" {
    29 #endif
    31 #define NOT_SCHEDULED 0xFFFFFFFF /* Sentinel value */
    34 typedef void (*event_func_t)(int eventid);
    36 /**
    37  * Register the callback to be associated with the given event ID.
    38  * Note: These should be registered at init time and never changed.
    39  */
    40 void register_event_callback( int eventid, event_func_t func );
    42 /**
    43  * Schedule a new pending event.
    44  * @param eventid Unique ID identifying the event in question (used to remove it
    45  * at a later time). If the eventid is scheduled more than once, only the lastest
    46  * schedule for that ID will be valid.
    47  * @param nanosecs Nanoseconds from the current SH4 time at which the event
    48  * should occur.
    49  */
    50 void event_schedule( int eventid, uint32_t nanosecs );
    52 /**
    53  * Schedule a long-duration pending event
    54  */
    55 void event_schedule_long( int eventid, uint32_t seconds, uint32_t nanosecs );
    57 /**
    58  * Remove a previously created event without triggering it. This is usually
    59  * only used when an operation is aborted.
    60  */
    61 void event_cancel( int eventid );
    63 /**
    64  * Return the slice cycle time of the next event, or NOT_SCHEDULED
    65  * if no events are scheduled for this time slice.
    66  */
    67 uint32_t event_get_next_time();
    69 /**
    70  * Execute the event on the top of the queue, and remove it.
    71  */
    72 void event_execute();
    74 /**
    75  * Initialize the event queue.
    76  */
    77 void event_init();
    79 #define MAX_EVENT_ID 128
    81 /* Events 1..96 are defined as the corresponding ASIC events. */
    83 #define EVENT_TMU0 97
    84 #define EVENT_TMU1 98
    85 #define EVENT_TMU2 99
    86 #define EVENT_GUNPOS 100
    88 #define EVENT_ENDTIMESLICE 127
    89 #ifdef __cplusplus
    90 }
    91 #endif
    93 #endif /* !lxdream_eventq_H */
.