Skip to content

Commit

Permalink
Expose udelay
Browse files Browse the repository at this point in the history
  • Loading branch information
Extrems committed Nov 8, 2024
1 parent f937160 commit 70db9ee
Show file tree
Hide file tree
Showing 16 changed files with 18 additions and 42 deletions.
12 changes: 7 additions & 5 deletions gc/ogc/timesupp.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,20 @@
extern "C" {
#endif

extern u32 gettick(void);
extern u64 gettime(void);
extern void settime(u64);
u32 gettick(void);
u64 gettime(void);
void settime(u64 time);

extern void __SYS_SetTime(s64 time);
extern s64 __SYS_GetSystemTime(void);
void __SYS_SetTime(s64 time);
s64 __SYS_GetSystemTime(void);

u32 diff_sec(u64 start,u64 end);
u32 diff_msec(u64 start,u64 end);
u32 diff_usec(u64 start,u64 end);
u32 diff_nsec(u64 start,u64 end);

void udelay(u32 usec);

#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 0 additions & 2 deletions libasnd/asndlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ static t_sound_data sound_data_dma ATTRIBUTE_ALIGN(32);
static s16 mute_buf[SND_BUFFERSIZE] ATTRIBUTE_ALIGN(32);
static s16 audio_buf[2][SND_BUFFERSIZE] ATTRIBUTE_ALIGN(32);

extern u32 gettick();

static __inline__ char* snd_set0b( char *p, int n)
{
while(n>0) {*p++=0;n--;}
Expand Down
4 changes: 1 addition & 3 deletions libdb/tcpip.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "asm.h"
#include "processor.h"
#include "timesupp.h"

#include "uIP/bba.h"
#include "uIP/memr.h"
Expand Down Expand Up @@ -49,9 +50,6 @@ static struct uip_netif netif;
static struct dbginterface netif_device;
static struct tcpip_sock *tcpip_accepted_sockets = NULL;

extern s64 gettime(void);
extern u32 diff_msec(s64 start,s64 end);

static s32_t tcpip_allocsocket(struct uip_tcp_pcb *pcb)
{
s32_t i;
Expand Down
6 changes: 1 addition & 5 deletions libdb/uIP/bba.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "exi.h"
#include "cache.h"
#include "bba.h"
#include "timesupp.h"
#include "uip_pbuf.h"
#include "uip_netif.h"
#include "uip_arp.h"
Expand Down Expand Up @@ -230,11 +231,6 @@ static void bba_outs(u32 reg,void *val,u32 len);

static void bba_devpoll(u16 *pstatus);

extern void udelay(int us);
extern u32 diff_msec(long long start,long long end);
extern u32 diff_usec(long long start,long long end);
extern long long gettime();

static __inline__ void bba_cmd_insnosel(u32 reg,void *val,u32 len)
{
u16 req;
Expand Down
2 changes: 0 additions & 2 deletions libdb/uIP/uip_ip.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ static u8_t uip_reassflags;
static u8_t uip_reasstmr;
static s64 uip_reasstime = 0;

extern s64 gettime(void);

static struct uip_pbuf* uip_copyfrom_pbuf(struct uip_pbuf *p,u16_t *offset,u8_t *buffer,u16_t len)
{
u16_t l;
Expand Down
2 changes: 0 additions & 2 deletions libmodplay/gcmodplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ static AESNDPB *modvoice = NULL;
#ifdef _GCMOD_DEBUG
static u64 mixtime = 0;
static u64 reqcbtime = 0;
extern u32 diff_usec(unsigned long long start,unsigned long long end);
extern u32 diff_msec(unsigned long long start,unsigned long long end);
#endif

static void* player(void *arg)
Expand Down
2 changes: 1 addition & 1 deletion libogc/card.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ distribution.
#include "cache.h"
#include "dsp.h"
#include "lwp.h"
#include "timesupp.h"
#include "exi.h"
#include "card.h"
#include "timesupp.h"

//#define _CARD_DEBUG

Expand Down
6 changes: 1 addition & 5 deletions libogc/dvd.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ distribution.
#include "ogcsys.h"
#include "system.h"
#include "dvd.h"
#include "timesupp.h"

//#define _DVD_DEBUG

Expand Down Expand Up @@ -412,13 +413,8 @@ s32 DVD_GcodeLowRead(void *buf,u32 len,u32 offset,dvdcallbacklow cb);
s32 DVD_GcodeLowWriteBuffer(void *buf,u32 len,dvdcallbacklow cb);
s32 DVD_GcodeLowWrite(u32 len,u32 offset,dvdcallbacklow cb);

extern void udelay(int us);
extern u32 diff_msec(unsigned long long start,unsigned long long end);
extern void __MaskIrq(u32);
extern void __UnmaskIrq(u32);
extern syssramex* __SYS_LockSramEx(void);
extern u32 __SYS_UnlockSramEx(u32 write);
extern s64 __SYS_GetSystemTime(void);

static u8 err2num(u32 errorcode)
{
Expand Down
1 change: 0 additions & 1 deletion libogc/exception.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ static int reload_timer = -1;

void __exception_sethandler(u32 nExcept, void (*pHndl)(frame_context*));

extern void udelay(int us);
extern void fpu_exceptionhandler(frame_context*);
extern void irq_exceptionhandler(frame_context*);
extern void dec_exceptionhandler(frame_context*);
Expand Down
2 changes: 1 addition & 1 deletion libogc/ios.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ distribution.
#include "es.h"
#include "ios.h"
#include "irq.h"
#include "timesupp.h"

#define IOS_HEAP_SIZE 0x1000
#define MAX_IPC_RETRIES 400
Expand All @@ -50,7 +51,6 @@ distribution.
#define IOS_MIN_VERSION 28

static s32 __ios_hid = -1;
extern void udelay(int us);

s32 __IOS_InitHeap(void)
{
Expand Down
5 changes: 1 addition & 4 deletions libogc/ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ distribution.
#include "ipc.h"
#include "cache.h"
#include "system.h"
#include "timesupp.h"
#include "lwp_heap.h"
#include "lwp_wkspace.h"

Expand Down Expand Up @@ -170,13 +171,9 @@ static struct _ipcheap _ipc_heaps[IPC_NUMHEAPS] =

static vu32* const _ipcReg = (u32*)0xCD000000;

extern void __MaskIrq(u32 nMask);
extern void __UnmaskIrq(u32 nMask);
extern void* __SYS_GetIPCBufferLo(void);
extern void* __SYS_GetIPCBufferHi(void);

extern u32 gettick(void);

static __inline__ u32 IPC_ReadReg(u32 reg)
{
return _ipcReg[reg];
Expand Down
2 changes: 0 additions & 2 deletions libogc/pad.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ static sys_resetinfo pad_resetinfo = {
127
};

extern void udelay(int);

static s32 __pad_onreset(s32 final)
{
u32 ret;
Expand Down
3 changes: 1 addition & 2 deletions libogc/sdgecko_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "card_cmn.h"
//#include "card_fat.h"
#include "card_io.h"
#include "timesupp.h"

//#define _CARDIO_DEBUG
#ifdef _CARDIO_DEBUG
Expand Down Expand Up @@ -86,8 +87,6 @@ static u32 _initType[MAX_DRIVE];
static u32 _ioAddressingType[MAX_DRIVE];
static u32 _ioTransferMode[MAX_DRIVE];

extern unsigned long gettick(void);

static __inline__ u32 __check_response(s32 drv_no,u8 res)
{
if(drv_no<0 || drv_no>=MAX_DRIVE) return CARDIO_ERROR_NOCARD;
Expand Down
6 changes: 3 additions & 3 deletions libogc/timesupp.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,14 @@ int __syscall_clock_getres(clockid_t clock_id, struct timespec *res)
}

// this function spins till timeout is reached
void udelay(unsigned us)
void udelay(u32 usec)
{
unsigned long long start, end;
u64 start, end;
start = gettime();
while (1)
{
end = gettime();
if (diff_usec(start,end) >= us)
if (diff_usec(start,end) >= usec)
break;
}
}
Expand Down
3 changes: 1 addition & 2 deletions libogc/video.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ video.c -- VIDEO subsystem
#include "system.h"
#include "video.h"
#include "video_types.h"
#include "timesupp.h"

//#define _VIDEO_DEBUG

Expand Down Expand Up @@ -1653,8 +1654,6 @@ static vu16* const _viReg = (u16*)0xCC002000;

extern void __VIClearFramebuffer(void*,u32,u32);

extern void udelay(int us);

#ifdef _VIDEO_DEBUG
static u32 messages$128 = 0;
static u32 printregs = 1;
Expand Down
2 changes: 0 additions & 2 deletions lwip/arch/gc/netif/gcif.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ static struct netif *gc_netif = NULL;
static err_t __bba_link_tx(struct netif *dev,struct pbuf *p);
static u32 __bba_rx_err(u8 status,struct bba_priv *priv);

extern void udelay(int us);

/* new functions */
#define bba_select() EXI_Select(EXI_CHANNEL_0,EXI_DEVICE_2,EXI_SPEED32MHZ)
#define bba_deselect() EXI_Deselect(EXI_CHANNEL_0)
Expand Down

0 comments on commit 70db9ee

Please sign in to comment.