Skip to content

Commit

Permalink
Timer fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
waninkoko committed Jul 31, 2010
1 parent 80f17fa commit 8da8cf5
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 20 deletions.
3 changes: 2 additions & 1 deletion Makefile
Expand Up @@ -21,7 +21,8 @@ LIBS =
TARGET = ehci-module

# Objects
OBJS = ipc.o \
OBJS = es.o \
ipc.o \
loop.o \
main.o \
mem.o \
Expand Down
2 changes: 1 addition & 1 deletion link.ld
Expand Up @@ -6,7 +6,7 @@ ENTRY(_start)
MEMORY {
table : ORIGIN = 0x0, LENGTH = 0x4000
exe(rwx) : ORIGIN = 0x13780000, LENGTH = 0x4000
ram(rw) : ORIGIN = 0x13784000, LENGTH = 0x27000
ram(rw) : ORIGIN = 0x13784000, LENGTH = 0x28000
}

__exe_start_phys__ = 0x13780000;
Expand Down
24 changes: 19 additions & 5 deletions loop.c
Expand Up @@ -27,6 +27,7 @@

#include "ehci_types.h"
#include "ehci.h"
#include "es.h"
#include "ipc.h"
#include "mem.h"
#include "module.h"
Expand Down Expand Up @@ -301,7 +302,7 @@ void __EHCI_Watchdog(void)
Mem_Free(buffer);

/* Restart watchdog timer */
os_restart_timer(timerId, WATCHDOG_TIMER);
os_restart_timer(timerId, 0, WATCHDOG_TIMER);
}
}
}
Expand All @@ -312,12 +313,12 @@ s32 __EHCI_Init(u32 *queuehandle, u32 *timerId)
s32 ret;

/* Allocate buffer*/
buffer = Mem_Alloc(0x40);
buffer = Mem_Alloc(0x80);
if (!buffer)
return IPC_ENOMEM;

/* Create message queue */
ret = os_message_queue_create(buffer, 16);
ret = os_message_queue_create(buffer, 32);
if (ret < 0)
return ret;

Expand All @@ -328,7 +329,7 @@ s32 __EHCI_Init(u32 *queuehandle, u32 *timerId)
os_device_register(DEVICE, ret);

/* Create watchdog timer */
ret = os_create_timer(WATCHDOG_TIMER, WATCHDOG_TIMER, *queuehandle, 0);
ret = os_create_timer(WATCHDOG_TIMER, WATCHDOG_TIMER, ret, 0);
if (ret < 0)
return ret;

Expand Down Expand Up @@ -373,6 +374,19 @@ s32 EHCI_Loop(void)
char *devpath = message->open.device;
s32 resultfd = message->open.resultfd;

u64 tid;

/* Get title ID */
ret = ES_GetTitleID(&tid);

/* Check title ID */
if (ret >= 0) {
write("EHCI: Title identified. Blocking opening request.\n");

ret = IPC_ENOENT;
break;
}

/* Module device */
if (!strcmp(devpath, DEVICE)) {
/* Discover devices */
Expand Down Expand Up @@ -433,7 +447,7 @@ s32 EHCI_Loop(void)


/* Restart watchdog timer */
os_restart_timer(timerId, WATCHDOG_TIMER);
os_restart_timer(timerId, 0, WATCHDOG_TIMER);

/* Acknowledge message */
if (ack)
Expand Down
7 changes: 4 additions & 3 deletions start.s
Expand Up @@ -25,15 +25,16 @@
.arm

.EQU ios_thread_arg, 4
.EQU ios_thread_priority, 0x48
.EQU ios_thread_stacksize, 0x2000
.EQU ios_thread_priority, 0x78
.EQU ios_thread_stacksize, 0x3000


.global _start
_start:
mov r0, #0 @ int argc
mov r1, #0 @ char *argv[]
blx main
ldr r3, =main
bx r3



Expand Down
2 changes: 1 addition & 1 deletion syscalls.h
Expand Up @@ -59,7 +59,7 @@ s32 os_ioctl(s32 fd, s32 request, void *in, s32 bytes_in, void *out, s32 byte
s32 os_create_timer(s32 time_us, s32 repeat_time_us, s32 message_queue, s32 message);
s32 os_destroy_timer(s32 time_id);
s32 os_stop_timer(s32 timer_id);
s32 os_restart_timer(s32 timer_id, s32 time_us);
s32 os_restart_timer(s32 timer_id, s32 dummy, s32 time_us);
s32 os_timer_now(s32 time_id);
s32 os_register_event_handler(s32 device, s32 queue, s32 message);
s32 os_unregister_event_handler(s32 device);
Expand Down
14 changes: 5 additions & 9 deletions timer.c
Expand Up @@ -43,32 +43,28 @@ void Timer_Init(void)
queuehandle = os_message_queue_create(queuespace, 16);

/* Create timer */
timerId = os_create_timer(1000000, 1, queuehandle, 0x666);
timerId = os_create_timer(0, 0, queuehandle, 0x666);

/* Stop timer */
os_stop_timer(timerId);
}

void Timer_Sleep(u32 time)
{
u32 message;

/* Send message */
os_message_queue_send(queuehandle, 0x555, 0);

/* Restart timer */
os_restart_timer(timerId, time);
os_restart_timer(timerId, 0, time);

while (1) {
/* Wait to receive message */
os_message_queue_receive(queuehandle, (void *)&message, 0);

/* Message received */
if (message == 0x555)
if (message == 0x666)
break;
}


os_message_queue_receive(queuehandle, (void *)&message, 0);

/* Stop timer */
os_stop_timer(timerId);
}

0 comments on commit 8da8cf5

Please sign in to comment.