Skip to content

Commit ad2b812

Browse files
stffrdhrnjeremybennett
authored andcommitted
testsuite: Get test code compiling again
There were various compile errors preventing the test suite code from compiling with the latest GCC. Update to get compiling.
1 parent 5922e6a commit ad2b812

File tree

7 files changed

+93
-49
lines changed

7 files changed

+93
-49
lines changed

testsuite/test-code-or1k/acv-uart/acv-uart.c

Lines changed: 64 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
/* UART test using ACV */
2929

30+
#include <unistd.h>
3031
#include "spr-defs.h"
3132
#include "support.h"
3233

@@ -76,7 +77,7 @@
7677
#define WAIT() {asm ("l.nop");asm ("l.nop");asm ("l.nop");asm ("l.nop");}
7778
/* fails if there is an error */
7879
#define NO_ERROR() { unsigned x = getreg (UART_LSR); if ((x & (LSR_BREAK|LSR_FE|LSR_PE|LSR_OE)) && !(x & LSR_ERR)) \
79-
printf ("LSR7 (0x%02x) ERR @ %i\n", x, __LINE__); ASSERT(!(x & LSR_ERR) && ((x & 0x60) != 0x40));}
80+
{ printf ("LSR7 (0x%02x) ERR @ %i\n", x, __LINE__); } ASSERT(!(x & LSR_ERR) && ((x & 0x60) != 0x40));}
8081
#define MARK() printf ("Passed line %i\n", __LINE__)
8182

8283
#ifndef __LINE__
@@ -93,12 +94,12 @@ void fail (char *func, int line)
9394
exit (1);
9495
}
9596

96-
inline void setreg (unsigned long addr, unsigned char value)
97+
static inline void setreg (unsigned long addr, unsigned char value)
9798
{
9899
*((volatile unsigned char *)addr) = value;
99100
}
100101

101-
inline unsigned long getreg (unsigned long addr)
102+
static inline unsigned long getreg (unsigned long addr)
102103
{
103104
return *((volatile unsigned char *)addr);
104105
}
@@ -148,7 +149,9 @@ void recv_char (int ch)
148149
char r;
149150
report (ch);
150151
/* Wait for rx fifo to be */
151-
while (!((x = getreg (UART_LSR)) & LSR_DR));
152+
while (!((x = getreg (UART_LSR)) & LSR_DR)) {
153+
;
154+
}
152155
if ((x & (LSR_BREAK|LSR_FE|LSR_PE|LSR_OE)) && !(x & LSR_ERR)) printf ("LSR7 (0x%02x) ERR @ recv_char\n", x);
153156
ASSERT(!(x & LSR_ERR));
154157

@@ -167,7 +170,9 @@ void send_char_no_wait (int ch)
167170
void send_char (int ch)
168171
{
169172
report (ch);
170-
while (!(getreg (UART_LSR) & LSR_TXFE));
173+
while (!(getreg (UART_LSR) & LSR_TXFE)) {
174+
;
175+
}
171176
NO_ERROR();
172177
setreg (UART_THR, ch); /* send character */
173178
NO_ERROR();
@@ -348,7 +353,9 @@ void send_recv_test ()
348353
s = "test_";
349354
while (*s) {
350355
/* Wait for tx fifo and tx to be empty */
351-
while (!(getreg (UART_LSR) & LSR_TXE));
356+
while (!(getreg (UART_LSR) & LSR_TXE)) {
357+
;
358+
}
352359
NO_ERROR();
353360
setreg (UART_THR, *s); /* send character */
354361
NO_ERROR();
@@ -373,7 +380,9 @@ void send_recv_test ()
373380

374381
/* Receives and compares the string */
375382
s = "recv";
376-
while (*s) recv_char (*s++);
383+
while (*s) {
384+
recv_char (*s++);
385+
}
377386
MARK();
378387
printf ("OK\n");
379388
}
@@ -401,7 +410,9 @@ void break_test ()
401410
/* Receive a break */
402411
send_char ('!');
403412
MARK();
404-
while (!((x = getreg (UART_LSR)) & LSR_DR));
413+
while (!((x = getreg (UART_LSR)) & LSR_DR)) {
414+
;
415+
}
405416
/* we should receive zero character with broken frame and break bit should be set */
406417
printf("[%x]\n", (LSR_DR | LSR_BREAK | LSR_ERR | LSR_TXFE | LSR_TXE));
407418
ASSERT (x == (LSR_DR | LSR_BREAK | LSR_ERR | LSR_TXFE | LSR_TXE));
@@ -410,7 +421,9 @@ void break_test ()
410421

411422
/* Send a # to release break */
412423
setreg (UART_THR, '#');
413-
while (!(getreg (UART_LSR) & LSR_DR));
424+
while (!(getreg (UART_LSR) & LSR_DR)) {
425+
;
426+
}
414427
NO_ERROR(); /* BREAK bit should be cleared now */
415428
ASSERT (getreg (UART_RBR) == '$');
416429
MARK();
@@ -419,7 +432,9 @@ void break_test ()
419432
s = "ns";
420433
while (*s) send_char (*s++);
421434
ASSERT (!(getreg (UART_LSR) & LSR_DR));
422-
while (!(getreg (UART_LSR) & LSR_TXE)); /* Wait till we send everything */
435+
while (!(getreg (UART_LSR) & LSR_TXE)) {
436+
; /* Wait till we send everything */
437+
}
423438
/* this should break the * char, so it should not be received */
424439
setreg (UART_THR, '*');
425440
setreg (UART_LCR, 0x3 | LCR_BREAK);
@@ -433,7 +448,9 @@ void break_test ()
433448

434449
/* Receive a break */
435450
send_char ('#');
436-
while (!((x = getreg (UART_LSR)) & LSR_DR));
451+
while (!((x = getreg (UART_LSR)) & LSR_DR)) {
452+
;
453+
}
437454
/* we should receive zero character with broken frame and break bit
438455
should not be set, because we cleared it */
439456
printf("[%x:%x]\n", x, (LSR_DR | LSR_BREAK |LSR_ERR | LSR_TXFE | LSR_TXE));
@@ -442,7 +459,9 @@ void break_test ()
442459
MARK();
443460
send_char ('?');
444461
MARK();
445-
while (!(getreg (UART_LSR) & LSR_DR));
462+
while (!(getreg (UART_LSR) & LSR_DR)) {
463+
;
464+
}
446465
recv_char ('!');
447466
printf ("OK\n");
448467
}
@@ -513,18 +532,24 @@ void different_modes_test ()
513532

514533
/* Restore normal mode */
515534
send_char ('T');
516-
while (getreg (UART_LSR) != 0x60); /* Wait for THR to be empty */
535+
while (getreg (UART_LSR) != 0x60) {
536+
; /* Wait for THR to be empty */
537+
}
517538
setreg (UART_LCR, LCR_DIVL);
518539
setreg (UART_DLH, 2 >> 8);
519540
setreg (UART_DLL, 2 & 0xff);
520541
setreg (UART_LCR, 0x03); /* 8N1 @ 2 */
521542
MARK();
522-
while (!(getreg (UART_LSR) & 1)); /* Receive 'x' char */
543+
while (!(getreg (UART_LSR) & 1)) {
544+
; /* Receive 'x' char */
545+
}
523546
getreg (UART_RBR);
524547
MARK();
525548

526549
send_char ('T');
527-
while (getreg (UART_LSR) != 0x60); /* Wait for THR to be empty */
550+
while (getreg (UART_LSR) != 0x60) {
551+
; /* Wait for THR to be empty */
552+
}
528553
MARK();
529554
printf ("OK\n");
530555
}
@@ -546,22 +571,28 @@ void interrupt_test ()
546571
setreg (UART_FCR, 0x01); /* Set trigger level = 1 char, fifo should not be reset */
547572
setreg (UART_IER, 0x07); /* Enable interrupts: line status, THR empty, data ready */
548573

549-
while (!int_cnt); /* Clear previous THR interrupt */
574+
while (!int_cnt) {
575+
; /* Clear previous THR interrupt */
576+
}
550577
ASSERT (--int_cnt == 0);
551578
ASSERT (int_iir == 0xc2);
552579
ASSERT ((int_lsr & 0xbe) == 0x20);
553580
MARK();
554581

555582
/* I am configured - start interrupt test */
556583
send_char ('I');
557-
while (!int_cnt); /* Wait for THR to be empty */
584+
while (!int_cnt) {
585+
; /* Wait for THR to be empty */
586+
}
558587
ASSERT (--int_cnt == 0);
559588
ASSERT (int_iir == 0xc2);
560589
ASSERT ((int_lsr & 0xbe) == 0x20);
561590
MARK();
562591

563592
int_rbr = '0';
564-
while (!int_cnt); /* Wait for DR */
593+
while (!int_cnt) {
594+
; /* Wait for DR */
595+
}
565596
ASSERT (--int_cnt == 0);
566597
ASSERT (int_iir == 0xc4);
567598
ASSERT (int_lsr == 0x61);
@@ -572,14 +603,18 @@ void interrupt_test ()
572603

573604
/* Everything ok here, send me 4 more */
574605
send_char ('I');
575-
while (!int_cnt); /* Wait for THR to be empty */
606+
while (!int_cnt) {
607+
; /* Wait for THR to be empty */
608+
}
576609
ASSERT (--int_cnt == 0);
577610
ASSERT (int_iir == 0xc2);
578611
ASSERT ((int_lsr & 0xbe) == 0x20);
579612
MARK();
580613

581614
int_rbr = '1';
582-
while (!int_cnt); /* Wait for DR */
615+
while (!int_cnt) {
616+
; /* Wait for DR */
617+
}
583618
ASSERT (--int_cnt == 0);
584619
ASSERT (int_iir == 0xc4);
585620
ASSERT (int_lsr == 0x61);
@@ -589,14 +624,18 @@ void interrupt_test ()
589624

590625
/* Everything ok here, send me 5 more */
591626
send_char ('I');
592-
while (!int_cnt); /* Wait for THR to be empty */
627+
while (!int_cnt) {
628+
; /* Wait for THR to be empty */
629+
}
593630
ASSERT (--int_cnt == 0);
594631
ASSERT (int_iir == 0xc2);
595632
ASSERT ((int_lsr & 0xbe) == 0x20);
596633
MARK();
597634

598635
int_rbr = '2';
599-
while (!int_cnt); /* Wait for DR */
636+
while (!int_cnt) {
637+
; /* Wait for DR */
638+
}
600639
ASSERT (--int_cnt == 0);
601640
ASSERT (int_iir == 0xc4);
602641
ASSERT (int_lsr == 0x61);
@@ -606,7 +645,9 @@ void interrupt_test ()
606645

607646
/* Everything ok here, send me 7 more */
608647
send_char ('I');
609-
while (!int_cnt); /* Wait for THR to be empty */
648+
while (!int_cnt) {
649+
; /* Wait for THR to be empty */
650+
}
610651
ASSERT (--int_cnt == 0);
611652
ASSERT (int_iir == 0xc2);
612653
ASSERT ((int_lsr & 0xbe) == 0x20);

testsuite/test-code-or1k/cache/cache.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ extern unsigned long ic_inv_test(void);
7070
extern unsigned long dc_inv_test(unsigned long);
7171

7272
extern void (*jalr)(void);
73-
extern void (*jr)(void);
73+
/* Number of instructions in jump */
74+
extern unsigned long jr[6];
7475

7576
/* Index on jump table */
7677
unsigned long jump_indx;
@@ -102,14 +103,12 @@ void jump(void)
102103
/* Jump to that address */
103104
asm("l.jr\t\tr3") ;
104105
/* Report that we succeeded */
105-
#ifndef __OR1K_NODELAY__
106106
asm("l.nop\t0");
107-
#endif
108107
}
109108

110109
void copy_jr(unsigned long add)
111110
{
112-
memcpy((void *)add, (void *)&jr, 24);
111+
memcpy((void *)add, jr, 24);
113112
}
114113

115114
void call(unsigned long add)

testsuite/test-code-or1k/eth/eth.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ static void transmit_one_packet( void )
140140
SET_FLAG(*eth_moder, ETH_MODER, TXEN);
141141

142142
/* Now wait till sent */
143-
while ( TEST_FLAG( eth_bd_base[tx_bindex], ETH_TX_BD, READY ) );
143+
while ( TEST_FLAG( eth_bd_base[tx_bindex], ETH_TX_BD, READY ) )
144+
;
144145
CLEAR_FLAG(*eth_moder, ETH_MODER, TXEN);
145146
*eth_int_source = 0x7f;
146147
}
@@ -178,7 +179,8 @@ static void receive_one_packet(void)
178179
SET_FLAG(eth_bd_base[rx_bindex], ETH_RX_BD, READY);
179180
SET_FLAG(*eth_moder, ETH_MODER, RXEN);
180181

181-
while ( TEST_FLAG( eth_bd_base[rx_bindex], ETH_RX_BD, READY ) );
182+
while ( TEST_FLAG( eth_bd_base[rx_bindex], ETH_RX_BD, READY ) )
183+
;
182184
CLEAR_FLAG(*eth_moder, ETH_MODER, RXEN);
183185
*eth_int_source = 0x7f;
184186

@@ -243,15 +245,17 @@ int main()
243245
transmit_one_packet_int();
244246
tx_bindex += 2;
245247
/* printf("waiting for int\n"); */
246-
while (!int_happend);
248+
while (!int_happend)
249+
;
247250
CLEAR_FLAG(*eth_int_mask, ETH_INT_MASK, TXB_M);
248251

249252
printf("seting mask flag RX\n");
250253
SET_FLAG(*eth_int_mask, ETH_INT_MASK, RXB_M);
251254
receive_one_packet_int();
252255
rx_bindex += 2;
253256
/* printf("waiting for int\n"); */
254-
while (!int_happend);
257+
while (!int_happend)
258+
;
255259
CLEAR_FLAG(*eth_int_mask, ETH_INT_MASK, RXB_M);
256260

257261

testsuite/test-code-or1k/except-test/except-test.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ extern void b_trap (void);
100100
extern void range (void);
101101
extern void b_range (void);
102102
extern int except_basic (void);
103-
extern void (*test)(void);
103+
extern unsigned long test[2]; /* Number of instructions in test_dummy */
104104
extern int load_acc_32 (unsigned long add);
105105
extern int load_acc_16 (unsigned long add);
106106
extern int store_acc_32 (unsigned long add);
@@ -132,19 +132,19 @@ volatile unsigned long except_ea;
132132
/* Eception PC */
133133
volatile unsigned long except_pc;
134134

135-
unsigned long excpt_buserr;
136-
unsigned long excpt_dpfault;
137-
unsigned long excpt_ipfault;
138-
unsigned long excpt_tick;
139-
unsigned long excpt_align;
140-
unsigned long excpt_illinsn;
141-
unsigned long excpt_int;
142-
unsigned long excpt_dtlbmiss;
143-
unsigned long excpt_itlbmiss;
144-
unsigned long excpt_range;
145-
unsigned long excpt_syscall;
146-
unsigned long excpt_break;
147-
unsigned long excpt_trap;
135+
extern unsigned long excpt_buserr;
136+
extern unsigned long excpt_dpfault;
137+
extern unsigned long excpt_ipfault;
138+
extern unsigned long excpt_tick;
139+
extern unsigned long excpt_align;
140+
extern unsigned long excpt_illinsn;
141+
extern unsigned long excpt_int;
142+
extern unsigned long excpt_dtlbmiss;
143+
extern unsigned long excpt_itlbmiss;
144+
extern unsigned long excpt_range;
145+
extern unsigned long excpt_syscall;
146+
extern unsigned long excpt_break;
147+
extern unsigned long excpt_trap;
148148

149149

150150
void fail (char *func, int line)
@@ -170,7 +170,7 @@ void test_dummy (void)
170170

171171
void copy_test (unsigned long phy_add)
172172
{
173-
memcpy((void *)phy_add, (void *)&test, 8);
173+
memcpy((void *)phy_add, test, 8);
174174
}
175175

176176
/* Bus error handler */

testsuite/test-code-or1k/mc-ssram/mc-ssram.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ unsigned long set_config()
5555
lpoc = *mc_poc;
5656

5757
for (ch=0; ch<8; ch++) {
58-
if (MC_SSRAM_CSMASK && (0x01 << ch) ) {
58+
if (MC_SSRAM_CSMASK & (0x01 << ch) ) {
5959
mc_csc = (unsigned long*)(MC_BASE + MC_CSC(ch));
6060
SET_FIELD(*mc_csc, MC_CSC, SEL, mc_ssram_cs[ch].M);
6161
SET_FLAG(*mc_csc, MC_CSC, EN);

testsuite/test-code-or1k/upcalls/upcall-basic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131

3232
/*!Alignment exception handler defined here. */
33-
unsigned long excpt_align;
33+
extern unsigned long excpt_align;
3434

3535

3636
/* --------------------------------------------------------------------------*/

testsuite/test-code-or1k/upcalls/upcall-misaligned.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131

3232
/*!Alignment exception handler defined here. */
33-
unsigned long excpt_align;
33+
extern unsigned long excpt_align;
3434

3535
/*!Flag set if we get a misaligned access */
3636
static int misaligned_p;

0 commit comments

Comments
 (0)