diff options
author | wdenk <wdenk> | 2003-04-05 00:53:31 +0000 |
---|---|---|
committer | wdenk <wdenk> | 2003-04-05 00:53:31 +0000 |
commit | 3e38691e8f7aa0d9b498d76c7279ddec6e4946f3 (patch) | |
tree | bec2e661298847dc5bcf9335ef31259686e882e1 /examples | |
parent | 36c05a80ecbe3997abd9aa628a68dd6c0bacf681 (diff) |
* Patch by Arun Dharankar, 4 Apr 2003:LABEL_2003_04_05_0300
Add IDMA example code (tested on 8260 only)
* Add support for Purple Board (MIPS64 5Kc)
* Add support for MIPS64 5Kc CPUs
* Fix missing setting of "loadaddr" and "bootfile" on ARM and MIPS
* Patch by Denis Peter, 04 Apr 2003:
- update MIP405-4 board
* Patches by Denis Peter, 03 April 2003:
- fix PCI IRQs on MPL boards
- fix two more un-relocated pointer problems
* Fix behaviour of "run" command:
- print error message iv variable does not exist
- terminate processing of arguments in case of error
* Patches by Peter Figuli, 10 Mar 2003
- Add support for BTUART on PXA platform
- Add support for WEP EP250 (PXA) board
* Fix flash problems on INCA-IP; add tool to allow bruning images to
flash using a BDI2000
* Implement fix for I2C Edge Conditions problem for all boards that
use the bit-banging driver (common/soft_i2c.c)
* Add patches by Robert Schwebel, 31 Mar 2003:
- csb226 board: bring in sync with innokom/memsetup.S
- csb226 board: fix MDREFR handling
- misc doc fixes / extensions
- innokom board: cleanup, MDREFR fix in memsetup.S, config update
- add BOOT_PROGRESS to armlinux.c
Diffstat (limited to 'examples')
-rw-r--r-- | examples/Makefile | 8 | ||||
-rw-r--r-- | examples/mem_to_mem_idma2intr.c | 391 | ||||
-rw-r--r-- | examples/ppc_longjmp.S | 4 | ||||
-rw-r--r-- | examples/ppc_setjmp.S | 4 | ||||
-rw-r--r-- | examples/sched.c | 112 |
5 files changed, 460 insertions, 59 deletions
diff --git a/examples/Makefile b/examples/Makefile index 163b404e405..b690fa07024 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -33,7 +33,7 @@ SREC += sched.srec BIN += sched.bin endif -ifeq ($(CPU),mips) +ifeq ($(ARCH),mips) SREC = BIN = endif @@ -44,6 +44,12 @@ SREC += timer.srec BIN += timer.bin endif +# The following example is 8260 specific... +ifeq ($(CPU),mpc8260) +SREC += mem_to_mem_idma2intr.srec +BIN += mem_to_mem_idma2intr.bin +endif + # Utility for resetting i82559 EEPROM ifeq ($(BOARD),oxc) SREC += eepro100_eeprom.srec diff --git a/examples/mem_to_mem_idma2intr.c b/examples/mem_to_mem_idma2intr.c new file mode 100644 index 00000000000..93c6f77ca57 --- /dev/null +++ b/examples/mem_to_mem_idma2intr.c @@ -0,0 +1,391 @@ +/* The dpalloc function used and implemented in this file was derieved + * from PPCBoot/U-Boot file "cpu/mpc8260/commproc.c". + */ + +/* Author: Arun Dharankar <ADharankar@ATTBI.Com> + * This example is meant to only demonstrate how the IDMA could be used. + */ + +/* + * This file is based on "arch/ppc/8260_io/commproc.c" - here is it's + * copyright notice: + * + * General Purpose functions for the global management of the + * 8260 Communication Processor Module. + * Copyright (c) 1999 Dan Malek (dmalek@jlc.net) + * Copyright (c) 2000 MontaVista Software, Inc (source@mvista.com) + * 2.3.99 Updates + * + * In addition to the individual control of the communication + * channels, there are a few functions that globally affect the + * communication processor. + * + * Buffer descriptors must be allocated from the dual ported memory + * space. The allocator for that is here. When the communication + * process is reset, we reclaim the memory available. There is + * currently no deallocator for this memory. + */ + + + +#include <common.h> +#include <syscall.h> + +#define STANDALONE + +#ifndef STANDALONE /* Linked into/Part of PPCBoot */ +#include <command.h> +#include <watchdog.h> +#else /* Standalone app of PPCBoot */ +#include <syscall.h> +#define printf mon_printf +#define tstc mon_tstc +#define getc mon_getc +#define putc mon_putc +#define udelay mon_udelay +#define malloc mon_malloc +#define WATCHDOG_RESET() { \ + *(ushort *)(CFG_IMMR + 0x1000E) = 0x556c; \ + *(ushort *)(CFG_IMMR + 0x1000E) = 0xaa39; \ + } +#endif /* STANDALONE */ + +static int debug = 1; + +#define DEBUG(fmt, args...) { \ + if(debug != 0) { \ + printf("[%s %d %s]: ",__FILE__,__LINE__,__FUNCTION__); \ + printf(fmt, ##args); \ + } \ +} + +#define CPM_CR_IDMA1_SBLOCK (0x14) +#define CPM_CR_IDMA2_SBLOCK (0x15) +#define CPM_CR_IDMA3_SBLOCK (0x16) +#define CPM_CR_IDMA4_SBLOCK (0x17) +#define CPM_CR_IDMA1_PAGE (0x07) +#define CPM_CR_IDMA2_PAGE (0x08) +#define CPM_CR_IDMA3_PAGE (0x09) +#define CPM_CR_IDMA4_PAGE (0x0a) +#define PROFF_IDMA1_BASE ((uint)0x87fe) +#define PROFF_IDMA2_BASE ((uint)0x88fe) +#define PROFF_IDMA3_BASE ((uint)0x89fe) +#define PROFF_IDMA4_BASE ((uint)0x8afe) + +#define CPM_CR_INIT_TRX ((ushort)0x0000) +#define CPM_CR_FLG ((ushort)0x0001) + +#define mk_cr_cmd(PG, SBC, MCN, OP) \ + ((PG << 26) | (SBC << 21) | (MCN << 6) | OP) + + +#pragma pack(1) +typedef struct ibdbits { + unsigned b_valid:1; + unsigned b_resv1:1; + unsigned b_wrap:1; + unsigned b_interrupt:1; + unsigned b_last:1; + unsigned b_resv2:1; + unsigned b_cm:1; + unsigned b_resv3:2; + unsigned b_sdn:1; + unsigned b_ddn:1; + unsigned b_dgbl:1; + unsigned b_dbo:2; + unsigned b_resv4:1; + unsigned b_ddtb:1; + unsigned b_resv5:2; + unsigned b_sgbl:1; + unsigned b_sbo:2; + unsigned b_resv6:1; + unsigned b_sdtb:1; + unsigned b_resv7:9; +} ibdbits_t; + +#pragma pack(1) +typedef union ibdbitsu { + ibdbits_t b; + uint i; +} ibdbitsu_t; + +#pragma pack(1) +typedef struct idma_buf_desc { + ibdbitsu_t ibd_bits; /* Status and Control */ + uint ibd_datlen; /* Data length in buffer */ + uint ibd_sbuf; /* Source buffer addr in host mem */ + uint ibd_dbuf; /* Destination buffer addr in host mem */ +} ibd_t; + + +#pragma pack(1) +typedef struct dcmbits { + unsigned b_fb:1; + unsigned b_lp:1; + unsigned b_resv1:3; + unsigned b_tc2:1; + unsigned b_resv2:1; + unsigned b_wrap:3; + unsigned b_sinc:1; + unsigned b_dinc:1; + unsigned b_erm:1; + unsigned b_dt:1; + unsigned b_sd:2; +} dcmbits_t; + +#pragma pack(1) +typedef union dcmbitsu { + dcmbits_t b; + ushort i; +} dcmbitsu_t; + +#pragma pack(1) +typedef struct pram_idma { + ushort pi_ibase; + dcmbitsu_t pi_dcmbits; + ushort pi_ibdptr; + ushort pi_dprbuf; + ushort pi_bufinv; /* internal to CPM */ + ushort pi_ssmax; + ushort pi_dprinptr; /* internal to CPM */ + ushort pi_sts; + ushort pi_dproutptr; /* internal to CPM */ + ushort pi_seob; + ushort pi_deob; + ushort pi_dts; + ushort pi_retadd; + ushort pi_resv1; /* internal to CPM */ + uint pi_bdcnt; + uint pi_sptr; + uint pi_dptr; + uint pi_istate; +} pram_idma_t; + + +volatile immap_t *immap = (immap_t *) CFG_IMMR; +volatile ibd_t *bdf; +volatile pram_idma_t *piptr; + +volatile int dmadone; +volatile int *dmadonep = &dmadone; +void dmadone_handler (void *); + +int idma_init (void); +void idma_start (int, int, int, uint, uint, int); +uint dpalloc (uint, uint); + + +uint dpinit_done = 0; + + +#ifdef STANDALONE +int ctrlc (void) +{ + if (mon_tstc()) { + switch (mon_getc ()) { + case 0x03: /* ^C - Control C */ + return 1; + default: + break; + } + } + return 0; +} +void * memset(void * s,int c,size_t count) +{ + char *xs = (char *) s; + while (count--) + *xs++ = c; + return s; +} +int memcmp(const void * cs,const void * ct,size_t count) +{ + const unsigned char *su1, *su2; + int res = 0; + for( su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--) + if ((res = *su1 - *su2) != 0) + break; + return res; +} +#endif /* STANDALONE */ + +#ifdef STANDALONE +int mem_to_mem_idma2intr (bd_t * bd, int argc, char *argv[]) +#else +int do_idma (bd_t * bd, int argc, char *argv[]) +#endif /* STANDALONE */ +{ + int i; + + dpinit_done = 0; + + idma_init (); + + DEBUG ("Installing dma handler\n"); + mon_install_hdlr (7, dmadone_handler, (void *) bdf); + + memset ((void *) 0x100000, 'a', 512); + memset ((void *) 0x200000, 'b', 512); + + for (i = 0; i < 32; i++) { + printf ("Startin IDMA, iteration=%d\n", i); + idma_start (1, 1, 512, 0x100000, 0x200000, 3); + } + + DEBUG ("Uninstalling dma handler\n"); + mon_free_hdlr (7); + + return 0; +} + +void +idma_start (int sinc, int dinc, int sz, uint sbuf, uint dbuf, int ttype) +{ + /* ttype is for M-M, M-P, P-M or P-P: not used for now */ + + piptr->pi_istate = 0; /* manual says: clear it before every START_IDMA */ + piptr->pi_dcmbits.b.b_resv1 = 0; + + if (sinc == 1) + piptr->pi_dcmbits.b.b_sinc = 1; + else + piptr->pi_dcmbits.b.b_sinc = 0; + + if (dinc == 1) + piptr->pi_dcmbits.b.b_dinc = 1; + else + piptr->pi_dcmbits.b.b_dinc = 0; + + piptr->pi_dcmbits.b.b_erm = 0; + piptr->pi_dcmbits.b.b_sd = 0x00; /* M-M */ + + bdf->ibd_sbuf = sbuf; + bdf->ibd_dbuf = dbuf; + bdf->ibd_bits.b.b_cm = 0; + bdf->ibd_bits.b.b_interrupt = 1; + bdf->ibd_bits.b.b_wrap = 1; + bdf->ibd_bits.b.b_last = 1; + bdf->ibd_bits.b.b_sdn = 0; + bdf->ibd_bits.b.b_ddn = 0; + bdf->ibd_bits.b.b_dgbl = 0; + bdf->ibd_bits.b.b_ddtb = 0; + bdf->ibd_bits.b.b_sgbl = 0; + bdf->ibd_bits.b.b_sdtb = 0; + bdf->ibd_bits.b.b_dbo = 1; + bdf->ibd_bits.b.b_sbo = 1; + bdf->ibd_bits.b.b_valid = 1; + bdf->ibd_datlen = 512; + + *dmadonep = 0; + + immap->im_sdma.sdma_idmr2 = (uchar) 0xf; + + immap->im_cpm.cp_cpcr = mk_cr_cmd (CPM_CR_IDMA2_PAGE, + CPM_CR_IDMA2_SBLOCK, 0x0, + 0x9) | 0x00010000; + + while (*dmadonep != 1) { + if (ctrlc ()) { + DEBUG ("\nInterrupted waiting for DMA interrupt.\n"); + goto done; + } + printf ("Waiting for DMA interrupt (dmadone=%d b_valid = %d)...\n", + dmadone, bdf->ibd_bits.b.b_valid); + udelay (1000000); + } + printf ("DMA complete notification received!\n"); + + done: + DEBUG ("memcmp(0x%08x, 0x%08x, 512) = %d\n", + sbuf, dbuf, memcmp ((void *) sbuf, (void *) dbuf, 512)); + + return; +} + +#define MAX_INT_BUFSZ 64 +#define DCM_WRAP 0 /* MUST be consistant with MAX_INT_BUFSZ */ + +int idma_init (void) +{ + uint memaddr; + + immap->im_cpm.cp_rccr &= ~0x00F3FFFF; + immap->im_cpm.cp_rccr |= 0x00A00A00; + + memaddr = dpalloc (sizeof (pram_idma_t), 64); + + *(volatile ushort *) &immap->im_dprambase[PROFF_IDMA2_BASE] = memaddr; + piptr = (volatile pram_idma_t *) ((uint) (immap) + memaddr); + + piptr->pi_resv1 = 0; /* manual says: clear it */ + piptr->pi_dcmbits.b.b_fb = 0; + piptr->pi_dcmbits.b.b_lp = 1; + piptr->pi_dcmbits.b.b_erm = 0; + piptr->pi_dcmbits.b.b_dt = 0; + + memaddr = (uint) dpalloc (sizeof (ibd_t), 64); + piptr->pi_ibase = piptr->pi_ibdptr = (volatile short) memaddr; + bdf = (volatile ibd_t *) ((uint) (immap) + memaddr); + bdf->ibd_bits.b.b_valid = 0; + + memaddr = (uint) dpalloc (64, 64); + piptr->pi_dprbuf = (volatile ushort) memaddr; + piptr->pi_dcmbits.b.b_wrap = 4; + piptr->pi_ssmax = 32; + + piptr->pi_sts = piptr->pi_ssmax; + piptr->pi_dts = piptr->pi_ssmax; + + return 1; +} + +void dmadone_handler (void *arg) +{ + immap->im_sdma.sdma_idmr2 = (uchar) 0x0; + + *dmadonep = 1; + + return; +} + + +static uint dpbase = 0; + +uint dpalloc (uint size, uint align) +{ + DECLARE_GLOBAL_DATA_PTR; + + volatile immap_t *immr = (immap_t *) CFG_IMMR; + uint retloc; + uint align_mask, off; + uint savebase; + + /* Pointer to initial global data area */ + + if (dpinit_done == 0) { + dpbase = gd->dp_alloc_base; + dpinit_done = 1; + } + + align_mask = align - 1; + savebase = dpbase; + + if ((off = (dpbase & align_mask)) != 0) + dpbase += (align - off); + + if ((off = size & align_mask) != 0) + size += align - off; + + if ((dpbase + size) >= gd->dp_alloc_top) { + dpbase = savebase; + printf ("dpalloc: ran out of dual port ram!"); + return 0; + } + + retloc = dpbase; + dpbase += size; + + memset ((void *) &immr->im_dprambase[retloc], 0, size); + + return (retloc); +} diff --git a/examples/ppc_longjmp.S b/examples/ppc_longjmp.S index ad8285a86b1..5ca6f6f3da9 100644 --- a/examples/ppc_longjmp.S +++ b/examples/ppc_longjmp.S @@ -30,9 +30,9 @@ #define FP(x...) x #define FP(x...) x -.globl longjmp; +.globl ppc_longjmp; -longjmp: +ppc_longjmp: lwz r1,(JB_GPR1*4)(r3) lwz r2,(JB_GPR2*4)(r3) lwz r0,(JB_LR*4)(r3) diff --git a/examples/ppc_setjmp.S b/examples/ppc_setjmp.S index b7181130232..421abfd6eb4 100644 --- a/examples/ppc_setjmp.S +++ b/examples/ppc_setjmp.S @@ -34,8 +34,8 @@ setctxsp: mr r1, r3 blr -.globl _setjmp; -_setjmp: +.globl ppc_setjmp; +ppc_setjmp: stw r1,(JB_GPR1*4)(3) mflr r0 stw r2,(JB_GPR2*4)(3) diff --git a/examples/sched.c b/examples/sched.c index 4f6f98e78f0..ceb5c1f08ec 100644 --- a/examples/sched.c +++ b/examples/sched.c @@ -3,12 +3,12 @@ * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, @@ -17,7 +17,6 @@ #include <common.h> #include <syscall.h> -#include <setjmp.h> /* * Author: Arun Dharankar <ADharankar@ATTBI.Com> @@ -54,6 +53,13 @@ #define RC_FAILURE (-1) #define RC_SUCCESS (0) +typedef vu_char *jmp_ctx; +unsigned long setctxsp (vu_char *sp); +int ppc_setjmp(jmp_ctx env); +void ppc_longjmp(jmp_ctx env, int val); +#define setjmp ppc_setjmp +#define longjmp ppc_longjmp + struct lthread { int state; int retval; @@ -68,13 +74,13 @@ static volatile int current_tid = MASTER_THREAD; static uchar dbg = 0; -#define DEBUG(fmt, args...) { \ - if(dbg != 0) { \ - mon_printf("[%s %d %s]: ", __FILE__, __LINE__, __FUNCTION__); \ - mon_printf(fmt, ##args); \ - mon_printf("\n"); \ - } \ - } +#define PDEBUG(fmt, args...) { \ + if(dbg != 0) { \ + mon_printf("[%s %d %s]: ",__FILE__,__LINE__,__FUNCTION__);\ + mon_printf(fmt, ##args); \ + mon_printf("\n"); \ + } \ +} static int testthread (void *); static void sched_init (void); @@ -83,14 +89,15 @@ static int thread_start (int id); static void thread_yield (void); static int thread_delete (int id); static int thread_join (int *ret); -#if 0 /* not used yet */ + +#if 0 /* not used yet */ static int thread_stop (int id); -#endif /* not used yet */ +#endif /* not used yet */ /* An example of schedular test */ #define NUMTHREADS 7 -int sched (bd_t *bd, int ac, char *av[]) +int sched (bd_t * bd, int ac, char *av[]) { int i, j; int tid[NUMTHREADS]; @@ -102,11 +109,10 @@ int sched (bd_t *bd, int ac, char *av[]) names[i] = i; j = thread_create (testthread, (void *) &names[i]); if (j == RC_FAILURE) - mon_printf ("schedtest: Failed to create thread %d\n", - i); + mon_printf ("schedtest: Failed to create thread %d\n", i); if (j > 0) { mon_printf ("schedtest: Created thread with id %d, name %d\n", - j, i); + j, i); tid[i] = j; } } @@ -125,8 +131,7 @@ int sched (bd_t *bd, int ac, char *av[]) if (mon_tstc () && mon_getc () == 0x3) { mon_printf ("schedtest: Aborting threads...\n"); for (i = 0; i < NUMTHREADS; i++) { - mon_printf ("schedtest: Deleting thread %d\n", - tid[i]); + mon_printf ("schedtest: Deleting thread %d\n", tid[i]); thread_delete (tid[i]); } return RC_SUCCESS; @@ -135,11 +140,10 @@ int sched (bd_t *bd, int ac, char *av[]) i = thread_join (&j); if (i == RC_FAILURE) { mon_printf ("schedtest: No threads pending, " - "exiting schedular test\n"); + "exiting schedular test\n"); return RC_SUCCESS; } - mon_printf ("schedtest: thread is %d returned %d\n", i, - j); + mon_printf ("schedtest: thread is %d returned %d\n", i, j); thread_yield (); } @@ -151,14 +155,14 @@ static int testthread (void *name) int i; mon_printf ("testthread: Begin executing thread, myname %d, &i=0x%08x\n", - *(int *) name, &i); + *(int *) name, &i); mon_printf ("Thread %02d, i=%d\n", *(int *) name); for (i = 0; i < 0xffff * (*(int *) name + 1); i++) { if (mon_tstc () && mon_getc () == 0x3) { mon_printf ("testthread: myname %d terminating.\n", - *(int *) name); + *(int *) name); return *(int *) name + 1; } @@ -167,7 +171,7 @@ static int testthread (void *name) } mon_printf ("testthread: returning %d, i=0x%x\n", - *(int *) name + 1, i); + *(int *) name + 1, i); return *(int *) name + 1; } @@ -182,8 +186,8 @@ static void sched_init (void) current_tid = MASTER_THREAD; lthreads[current_tid].state = STATE_RUNNABLE; - DEBUG ("sched_init: master context = 0x%08x", - lthreads[current_tid].context); + PDEBUG ("sched_init: master context = 0x%08x", + lthreads[current_tid].context); return; } @@ -191,19 +195,19 @@ static void thread_yield (void) { static int i; - DEBUG ("thread_yield: current tid=%d", current_tid); + PDEBUG ("thread_yield: current tid=%d", current_tid); #define SWITCH(new) \ if(lthreads[new].state == STATE_RUNNABLE) { \ - DEBUG("thread_yield: %d match, ctx=0x%08x", \ + PDEBUG("thread_yield: %d match, ctx=0x%08x", \ new, lthreads[current_tid].context); \ if(setjmp(lthreads[current_tid].context) == 0) { \ current_tid = new; \ - DEBUG("thread_yield: tid %d returns 0", \ + PDEBUG("thread_yield: tid %d returns 0", \ new); \ longjmp(lthreads[new].context, 1); \ } else { \ - DEBUG("thread_yield: tid %d returns 1", \ + PDEBUG("thread_yield: tid %d returns 1", \ new); \ return; \ } \ @@ -219,7 +223,7 @@ static void thread_yield (void) } } - DEBUG ("thread_yield: returning from thread_yield"); + PDEBUG ("thread_yield: returning from thread_yield"); return; } @@ -232,12 +236,12 @@ static int thread_create (int (*func) (void *), void *arg) lthreads[i].state = STATE_STOPPED; lthreads[i].func = func; lthreads[i].arg = arg; - DEBUG ("thread_create: returns new tid %d", i); + PDEBUG ("thread_create: returns new tid %d", i); return i; } } - DEBUG ("thread_create: returns failure"); + PDEBUG ("thread_create: returns failure"); return RC_FAILURE; } @@ -255,13 +259,13 @@ static int thread_delete (int id) static void thread_launcher (void) { - DEBUG ("thread_launcher: invoking func=0x%08x", + PDEBUG ("thread_launcher: invoking func=0x%08x", lthreads[current_tid].func); lthreads[current_tid].retval = - lthreads[current_tid].func(lthreads[current_tid].arg); + lthreads[current_tid].func (lthreads[current_tid].arg); - DEBUG ("thread_launcher: tid %d terminated", current_tid); + PDEBUG ("thread_launcher: tid %d terminated", current_tid); lthreads[current_tid].state = STATE_TERMINATED; thread_yield (); @@ -272,7 +276,7 @@ static void thread_launcher (void) static int thread_start (int id) { - DEBUG ("thread_start: id=%d", id); + PDEBUG ("thread_start: id=%d", id); if (id <= MASTER_THREAD || id > MAX_THREADS) { return RC_FAILURE; } @@ -283,17 +287,17 @@ static int thread_start (int id) if (setjmp (lthreads[current_tid].context) == 0) { lthreads[id].state = STATE_RUNNABLE; current_tid = id; - DEBUG ("thread_start: to be stack=0%08x", lthreads[id].stack); + PDEBUG ("thread_start: to be stack=0%08x", lthreads[id].stack); setctxsp (<hreads[id].stack[STK_SIZE]); thread_launcher (); } - DEBUG ("thread_start: Thread id=%d started, parent returns", id); + PDEBUG ("thread_start: Thread id=%d started, parent returns", id); return RC_SUCCESS; } -#if 0 /* not used so far */ +#if 0 /* not used so far */ static int thread_stop (int id) { if (id <= MASTER_THREAD || id >= MAX_THREADS) @@ -305,46 +309,46 @@ static int thread_stop (int id) lthreads[id].state = STATE_STOPPED; return RC_SUCCESS; } -#endif /* not used so far */ +#endif /* not used so far */ static int thread_join (int *ret) { int i, j = 0; - DEBUG ("thread_join: *ret = %d", *ret); + PDEBUG ("thread_join: *ret = %d", *ret); if (!(*ret == -1 || *ret > MASTER_THREAD || *ret < MAX_THREADS)) { - DEBUG ("thread_join: invalid tid %d", *ret); + PDEBUG ("thread_join: invalid tid %d", *ret); return RC_FAILURE; } if (*ret == -1) { - DEBUG ("Checking for tid = -1"); + PDEBUG ("Checking for tid = -1"); while (1) { - /* DEBUG("thread_join: start while-loopn"); */ + /* PDEBUG("thread_join: start while-loopn"); */ j = 0; for (i = MASTER_THREAD + 1; i < MAX_THREADS; i++) { if (lthreads[i].state == STATE_TERMINATED) { *ret = lthreads[i].retval; lthreads[i].state = STATE_EMPTY; - /* DEBUG("thread_join: returning retval %d of tid %d", - ret, i); */ + /* PDEBUG("thread_join: returning retval %d of tid %d", + ret, i); */ return RC_SUCCESS; } if (lthreads[i].state != STATE_EMPTY) { - DEBUG ("thread_join: %d used slots tid %d state=%d", - j, i, lthreads[i].state); + PDEBUG ("thread_join: %d used slots tid %d state=%d", + j, i, lthreads[i].state); j++; } } if (j == 0) { - DEBUG ("thread_join: all slots empty!"); + PDEBUG ("thread_join: all slots empty!"); return RC_FAILURE; } - /* DEBUG("thread_join: yielding"); */ + /* PDEBUG("thread_join: yielding"); */ thread_yield (); - /* DEBUG("thread_join: back from yield"); */ + /* PDEBUG("thread_join: back from yield"); */ } } @@ -352,10 +356,10 @@ static int thread_join (int *ret) i = *ret; *ret = lthreads[*ret].retval; lthreads[*ret].state = STATE_EMPTY; - DEBUG ("thread_join: returing %d for tid %d", *ret, i); + PDEBUG ("thread_join: returing %d for tid %d", *ret, i); return RC_SUCCESS; } - DEBUG ("thread_join: thread %d is not terminated!", *ret); + PDEBUG ("thread_join: thread %d is not terminated!", *ret); return RC_FAILURE; } |