diff --git a/src/MakefileOG b/src/MakefileOG new file mode 100644 index 0000000000000000000000000000000000000000..a5f22905ccb0afd50d01534a876f86628aa3ae13 --- /dev/null +++ b/src/MakefileOG @@ -0,0 +1,44 @@ +# Makefile for busy-wait IO tests +# +XCC = /u/wbcowan/gnuarm-4.0.2/arm-elf/bin/gcc +AS = /u/wbcowan/gnuarm-4.0.2/arm-elf/bin/as +AR = /u/wbcowan/gnuarm-4.0.2/arm-elf/bin/ar +CFLAGS = -c -fPIC -Wall -I. -I../../include -mcpu=arm920t -msoft-float +# -g: include hooks for gdb +# -c: only compile +# -mcpu=arm920t: generate code for the 920t architecture +# -fpic: emit position-independent code +# -Wall: report all warnings + +ASFLAGS = -mcpu=arm920t -mapcs-32 +# -mapcs: always generate a complete stack frame + +ARFLAGS = rcs + +all: bwio.a + + +buffer.s: buffer.c + $(XCC) -S $(CFLAGS) buffer.c + +bwio.s: bwio.c + $(XCC) -S $(CFLAGS) bwio.c + +buffer.o: buffer.s + $(AS) $(ASFLAGS) -o buffer.o buffer.s + +bwio.o: bwio.s + $(AS) $(ASFLAGS) -o bwio.o bwio.s + +buffer.a: buffer.o + $(AR) $(ARFLAGS) $@ buffer.o + +bwio.a: bwio.o + $(AR) $(ARFLAGS) $@ bwio.o + +install: bwio.a buffer.a + mv bwio.a ../../lib/libbwio.a + mv buffer.a ../../lib/libbuffer.a + +clean: + -rm -f *.s *.o *.a *~ ../../lib/*.a diff --git a/src/bwio.a b/src/bwio.a new file mode 100644 index 0000000000000000000000000000000000000000..d86d70ea81123a029983dfa5eb4a32fe52b59840 Binary files /dev/null and b/src/bwio.a differ diff --git a/src/bwio.c b/src/bwio.c new file mode 100644 index 0000000000000000000000000000000000000000..dcb131845013e29fe7cea02ef4c33d21b9e1c5f0 --- /dev/null +++ b/src/bwio.c @@ -0,0 +1,257 @@ +/* + * bwio.c - busy-wait I/O routines for diagnosis + * + * Specific to the TS-7200 ARM evaluation board + * + */ + +#include <ts7200.h> +#include <bwio.h> + +/* + * The UARTs are initialized by RedBoot to the following state + * 115,200 bps + * 8 bits + * no parity + * fifos enabled + */ +int bwsetfifo( int channel, int state ) { + int *line, buf; + switch( channel ) { + case COM1: + line = (int *)( UART1_BASE + UART_LCRH_OFFSET ); + break; + case COM2: + line = (int *)( UART2_BASE + UART_LCRH_OFFSET ); + break; + default: + return -1; + break; + } + buf = *line; + buf = state ? buf | FEN_MASK : buf & ~FEN_MASK; + *line = buf; + return 0; +} + +int bwsetspeed( int channel, int speed ) { + int *high, *low; + switch( channel ) { + case COM1: + high = (int *)( UART1_BASE + UART_LCRM_OFFSET ); + low = (int *)( UART1_BASE + UART_LCRL_OFFSET ); + break; + case COM2: + high = (int *)( UART2_BASE + UART_LCRM_OFFSET ); + low = (int *)( UART2_BASE + UART_LCRL_OFFSET ); + break; + default: + return -1; + break; + } + switch( speed ) { + case 115200: + *high = 0x0; + *low = 0x3; + return 0; + case 2400: + *high = 0x0; + *low = 0xbf; + return 0; + default: + return -1; + } +} + +int bwputc( int channel, char c ) { + int *flags, *data; + switch( channel ) { + case COM1: + flags = (int *)( UART1_BASE + UART_FLAG_OFFSET ); + data = (int *)( UART1_BASE + UART_DATA_OFFSET ); + break; + case COM2: + flags = (int *)( UART2_BASE + UART_FLAG_OFFSET ); + data = (int *)( UART2_BASE + UART_DATA_OFFSET ); + break; + default: + return -1; + break; + } + while( ( *flags & TXFF_MASK ) ) ; + *data = c; + return 0; +} + +char c2x( char ch ) { + if ( (ch <= 9) ) return '0' + ch; + return 'a' + ch - 10; +} + +int bwputx( int channel, char c ) { + char chh, chl; + + chh = c2x( c / 16 ); + chl = c2x( c % 16 ); + bwputc( channel, chh ); + return bwputc( channel, chl ); +} + +int bwputr( int channel, unsigned int reg ) { + int byte; + char *ch = (char *) ® + + for( byte = 3; byte >= 0; byte-- ) bwputx( channel, ch[byte] ); + return bwputc( channel, ' ' ); +} + +int bwputstr( int channel, char *str ) { + while( *str ) { + if( bwputc( channel, *str ) < 0 ) return -1; + str++; + } + return 0; +} + +void bwputw( int channel, int n, char fc, char *bf ) { + char ch; + char *p = bf; + + while( *p++ && n > 0 ) n--; + while( n-- > 0 ) bwputc( channel, fc ); + while( ( ch = *bf++ ) ) bwputc( channel, ch ); +} + +int bwgetc( int channel ) { + int *flags, *data; + unsigned char c; + + switch( channel ) { + case COM1: + flags = (int *)( UART1_BASE + UART_FLAG_OFFSET ); + data = (int *)( UART1_BASE + UART_DATA_OFFSET ); + break; + case COM2: + flags = (int *)( UART2_BASE + UART_FLAG_OFFSET ); + data = (int *)( UART2_BASE + UART_DATA_OFFSET ); + break; + default: + return -1; + break; + } + while ( !( *flags & RXFF_MASK ) ) ; + c = *data; + return c; +} + +int bwa2d( char ch ) { + if( ch >= '0' && ch <= '9' ) return ch - '0'; + if( ch >= 'a' && ch <= 'f' ) return ch - 'a' + 10; + if( ch >= 'A' && ch <= 'F' ) return ch - 'A' + 10; + return -1; +} + +char bwa2i( char ch, char **src, int base, int *nump ) { + int num, digit; + char *p; + + p = *src; num = 0; + while( ( digit = bwa2d( ch ) ) >= 0 ) { + if ( digit > base ) break; + num = num*base + digit; + ch = *p++; + } + *src = p; *nump = num; + return ch; +} + +void bwui2a( unsigned int num, unsigned int base, char *bf ) { + int n = 0; + int dgt; + unsigned int d = 1; + + while( (num / d) >= base ) d *= base; + while( d != 0 ) { + dgt = num / d; + num %= d; + d /= base; + if( n || dgt > 0 || d == 0 ) { + *bf++ = dgt + ( dgt < 10 ? '0' : 'a' - 10 ); + ++n; + } + } + *bf = 0; +} + +void bwi2a( int num, char *bf ) { + if( num < 0 ) { + num = -num; + *bf++ = '-'; + } + bwui2a( num, 10, bf ); +} + +void bwformat ( int channel, char *fmt, va_list va ) { + char bf[12]; + char ch, lz; + int w; + + + while ( ( ch = *(fmt++) ) ) { + if ( ch != '%' ) + bwputc( channel, ch ); + else { + lz = 0; w = 0; + ch = *(fmt++); + switch ( ch ) { + case '0': + lz = 1; ch = *(fmt++); + break; + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + ch = bwa2i( ch, &fmt, 10, &w ); + break; + } + switch( ch ) { + case 0: return; + case 'c': + bwputc( channel, va_arg( va, char ) ); + break; + case 's': + bwputw( channel, w, 0, va_arg( va, char* ) ); + break; + case 'u': + bwui2a( va_arg( va, unsigned int ), 10, bf ); + bwputw( channel, w, lz, bf ); + break; + case 'd': + bwi2a( va_arg( va, int ), bf ); + bwputw( channel, w, lz, bf ); + break; + case 'x': + bwui2a( va_arg( va, unsigned int ), 16, bf ); + bwputw( channel, w, lz, bf ); + break; + case '%': + bwputc( channel, ch ); + break; + } + } + } +} + +void bwprintf( int channel, char *fmt, ... ) { + va_list va; + + va_start(va,fmt); + bwformat( channel, fmt, va ); + va_end(va); +} + diff --git a/src/bwio.o b/src/bwio.o new file mode 100644 index 0000000000000000000000000000000000000000..1f01e290b85e1e1a3aedabe0cb298ef39089b2f4 Binary files /dev/null and b/src/bwio.o differ diff --git a/src/bwio.s b/src/bwio.s new file mode 100644 index 0000000000000000000000000000000000000000..11317325ffb0ede5c4f5b9a8861dd4c4f912516e --- /dev/null +++ b/src/bwio.s @@ -0,0 +1,982 @@ + .file "bwio.c" + .text + .align 2 + .global bwsetfifo + .type bwsetfifo, %function +bwsetfifo: + @ args = 0, pretend = 0, frame = 28 + @ frame_needed = 1, uses_anonymous_args = 0 + mov ip, sp + stmfd sp!, {fp, ip, lr, pc} + sub fp, ip, #4 + sub sp, sp, #28 + str r0, [fp, #-24] + str r1, [fp, #-28] + ldr r3, [fp, #-24] + str r3, [fp, #-40] + ldr r3, [fp, #-40] + cmp r3, #0 + beq .L3 + ldr r3, [fp, #-40] + cmp r3, #1 + beq .L4 + b .L2 +.L3: + ldr r3, .L11 + str r3, [fp, #-20] + b .L5 +.L4: + ldr r3, .L11+4 + str r3, [fp, #-20] + b .L5 +.L2: + mvn r3, #0 + str r3, [fp, #-36] + b .L6 +.L5: + ldr r3, [fp, #-20] + ldr r3, [r3, #0] + str r3, [fp, #-16] + ldr r3, [fp, #-28] + cmp r3, #0 + beq .L7 + ldr r3, [fp, #-16] + orr r3, r3, #16 + str r3, [fp, #-32] + b .L9 +.L7: + ldr r3, [fp, #-16] + bic r3, r3, #16 + str r3, [fp, #-32] +.L9: + ldr r3, [fp, #-32] + str r3, [fp, #-16] + ldr r2, [fp, #-20] + ldr r3, [fp, #-16] + str r3, [r2, #0] + mov r3, #0 + str r3, [fp, #-36] +.L6: + ldr r3, [fp, #-36] + mov r0, r3 + sub sp, fp, #12 + ldmfd sp, {fp, sp, pc} +.L12: + .align 2 +.L11: + .word -2138308600 + .word -2138243064 + .size bwsetfifo, .-bwsetfifo + .align 2 + .global bwsetspeed + .type bwsetspeed, %function +bwsetspeed: + @ args = 0, pretend = 0, frame = 28 + @ frame_needed = 1, uses_anonymous_args = 0 + mov ip, sp + stmfd sp!, {fp, ip, lr, pc} + sub fp, ip, #4 + sub sp, sp, #28 + str r0, [fp, #-24] + str r1, [fp, #-28] + ldr r2, [fp, #-24] + str r2, [fp, #-36] + ldr r3, [fp, #-36] + cmp r3, #0 + beq .L15 + ldr r2, [fp, #-36] + cmp r2, #1 + beq .L16 + b .L14 +.L15: + ldr r3, .L23 + str r3, [fp, #-20] + ldr r3, .L23+4 + str r3, [fp, #-16] + b .L17 +.L16: + ldr r3, .L23+8 + str r3, [fp, #-20] + ldr r3, .L23+12 + str r3, [fp, #-16] + b .L17 +.L14: + mvn r3, #0 + str r3, [fp, #-32] + b .L18 +.L17: + ldr r2, [fp, #-28] + str r2, [fp, #-40] + ldr r3, [fp, #-40] + cmp r3, #2400 + beq .L20 + ldr r3, .L23+16 + ldr r2, [fp, #-40] + cmp r2, r3 + beq .L21 + b .L19 +.L21: + ldr r2, [fp, #-20] + mov r3, #0 + str r3, [r2, #0] + ldr r2, [fp, #-16] + mov r3, #3 + str r3, [r2, #0] + mov r3, #0 + str r3, [fp, #-32] + b .L18 +.L20: + ldr r2, [fp, #-20] + mov r3, #0 + str r3, [r2, #0] + ldr r2, [fp, #-16] + mov r3, #191 + str r3, [r2, #0] + mov r2, #0 + str r2, [fp, #-32] + b .L18 +.L19: + mvn r3, #0 + str r3, [fp, #-32] +.L18: + ldr r3, [fp, #-32] + mov r0, r3 + sub sp, fp, #12 + ldmfd sp, {fp, sp, pc} +.L24: + .align 2 +.L23: + .word -2138308596 + .word -2138308592 + .word -2138243060 + .word -2138243056 + .word 115200 + .size bwsetspeed, .-bwsetspeed + .align 2 + .global bwputc + .type bwputc, %function +bwputc: + @ args = 0, pretend = 0, frame = 24 + @ frame_needed = 1, uses_anonymous_args = 0 + mov ip, sp + stmfd sp!, {fp, ip, lr, pc} + sub fp, ip, #4 + sub sp, sp, #24 + str r0, [fp, #-24] + mov r3, r1 + strb r3, [fp, #-28] + ldr r3, [fp, #-24] + str r3, [fp, #-36] + ldr r3, [fp, #-36] + cmp r3, #0 + beq .L27 + ldr r3, [fp, #-36] + cmp r3, #1 + beq .L28 + b .L26 +.L27: + ldr r3, .L33 + str r3, [fp, #-20] + ldr r3, .L33+4 + str r3, [fp, #-16] + b .L29 +.L28: + ldr r3, .L33+8 + str r3, [fp, #-20] + ldr r3, .L33+12 + str r3, [fp, #-16] + b .L29 +.L26: + mvn r3, #0 + str r3, [fp, #-32] + b .L30 +.L29: + ldr r3, [fp, #-20] + ldr r3, [r3, #0] + mov r3, r3, lsr #5 + and r3, r3, #1 + and r3, r3, #255 + cmp r3, #0 + bne .L29 + ldrb r2, [fp, #-28] @ zero_extendqisi2 + ldr r3, [fp, #-16] + str r2, [r3, #0] + mov r3, #0 + str r3, [fp, #-32] +.L30: + ldr r3, [fp, #-32] + mov r0, r3 + sub sp, fp, #12 + ldmfd sp, {fp, sp, pc} +.L34: + .align 2 +.L33: + .word -2138308584 + .word -2138308608 + .word -2138243048 + .word -2138243072 + .size bwputc, .-bwputc + .align 2 + .global c2x + .type c2x, %function +c2x: + @ args = 0, pretend = 0, frame = 8 + @ frame_needed = 1, uses_anonymous_args = 0 + mov ip, sp + stmfd sp!, {fp, ip, lr, pc} + sub fp, ip, #4 + sub sp, sp, #8 + mov r3, r0 + strb r3, [fp, #-16] + ldrb r3, [fp, #-16] @ zero_extendqisi2 + cmp r3, #9 + bhi .L36 + ldrb r3, [fp, #-16] @ zero_extendqisi2 + add r3, r3, #48 + and r3, r3, #255 + and r3, r3, #255 + str r3, [fp, #-20] + b .L38 +.L36: + ldrb r3, [fp, #-16] @ zero_extendqisi2 + add r3, r3, #87 + and r3, r3, #255 + and r3, r3, #255 + str r3, [fp, #-20] +.L38: + ldr r3, [fp, #-20] + mov r0, r3 + sub sp, fp, #12 + ldmfd sp, {fp, sp, pc} + .size c2x, .-c2x + .align 2 + .global bwputx + .type bwputx, %function +bwputx: + @ args = 0, pretend = 0, frame = 12 + @ frame_needed = 1, uses_anonymous_args = 0 + mov ip, sp + stmfd sp!, {fp, ip, lr, pc} + sub fp, ip, #4 + sub sp, sp, #12 + str r0, [fp, #-20] + mov r3, r1 + strb r3, [fp, #-24] + ldrb r3, [fp, #-24] @ zero_extendqisi2 + mov r3, r3, lsr #4 + and r3, r3, #255 + mov r0, r3 + bl c2x(PLT) + mov r3, r0 + strb r3, [fp, #-14] + ldrb r3, [fp, #-24] @ zero_extendqisi2 + and r3, r3, #15 + mov r0, r3 + bl c2x(PLT) + mov r3, r0 + strb r3, [fp, #-13] + ldrb r3, [fp, #-14] @ zero_extendqisi2 + ldr r0, [fp, #-20] + mov r1, r3 + bl bwputc(PLT) + ldrb r3, [fp, #-13] @ zero_extendqisi2 + ldr r0, [fp, #-20] + mov r1, r3 + bl bwputc(PLT) + mov r3, r0 + mov r0, r3 + sub sp, fp, #12 + ldmfd sp, {fp, sp, pc} + .size bwputx, .-bwputx + .align 2 + .global bwputr + .type bwputr, %function +bwputr: + @ args = 0, pretend = 0, frame = 16 + @ frame_needed = 1, uses_anonymous_args = 0 + mov ip, sp + stmfd sp!, {fp, ip, lr, pc} + sub fp, ip, #4 + sub sp, sp, #16 + str r0, [fp, #-24] + str r1, [fp, #-28] + sub r3, fp, #28 + str r3, [fp, #-16] + mov r3, #3 + str r3, [fp, #-20] + b .L43 +.L44: + ldr r3, [fp, #-20] + mov r2, r3 + ldr r3, [fp, #-16] + add r3, r2, r3 + ldrb r3, [r3, #0] @ zero_extendqisi2 + ldr r0, [fp, #-24] + mov r1, r3 + bl bwputx(PLT) + ldr r3, [fp, #-20] + sub r3, r3, #1 + str r3, [fp, #-20] +.L43: + ldr r3, [fp, #-20] + cmp r3, #0 + bge .L44 + ldr r0, [fp, #-24] + mov r1, #32 + bl bwputc(PLT) + mov r3, r0 + mov r0, r3 + sub sp, fp, #12 + ldmfd sp, {fp, sp, pc} + .size bwputr, .-bwputr + .align 2 + .global bwputstr + .type bwputstr, %function +bwputstr: + @ args = 0, pretend = 0, frame = 12 + @ frame_needed = 1, uses_anonymous_args = 0 + mov ip, sp + stmfd sp!, {fp, ip, lr, pc} + sub fp, ip, #4 + sub sp, sp, #12 + str r0, [fp, #-16] + str r1, [fp, #-20] + b .L48 +.L49: + ldr r3, [fp, #-20] + ldrb r3, [r3, #0] @ zero_extendqisi2 + ldr r0, [fp, #-16] + mov r1, r3 + bl bwputc(PLT) + mov r3, r0 + cmp r3, #0 + bge .L50 + mvn r3, #0 + str r3, [fp, #-24] + b .L52 +.L50: + ldr r3, [fp, #-20] + add r3, r3, #1 + str r3, [fp, #-20] +.L48: + ldr r3, [fp, #-20] + ldrb r3, [r3, #0] @ zero_extendqisi2 + cmp r3, #0 + bne .L49 + mov r3, #0 + str r3, [fp, #-24] +.L52: + ldr r3, [fp, #-24] + mov r0, r3 + sub sp, fp, #12 + ldmfd sp, {fp, sp, pc} + .size bwputstr, .-bwputstr + .align 2 + .global bwputw + .type bwputw, %function +bwputw: + @ args = 0, pretend = 0, frame = 24 + @ frame_needed = 1, uses_anonymous_args = 0 + mov ip, sp + stmfd sp!, {fp, ip, lr, pc} + sub fp, ip, #4 + sub sp, sp, #24 + str r0, [fp, #-24] + str r1, [fp, #-28] + str r3, [fp, #-36] + mov r3, r2 + strb r3, [fp, #-32] + ldr r3, [fp, #-36] + str r3, [fp, #-16] + b .L56 +.L57: + ldr r3, [fp, #-28] + sub r3, r3, #1 + str r3, [fp, #-28] +.L56: + ldr r3, [fp, #-16] + ldrb r3, [r3, #0] @ zero_extendqisi2 + cmp r3, #0 + moveq r3, #0 + movne r3, #1 + and r2, r3, #255 + ldr r3, [fp, #-16] + add r3, r3, #1 + str r3, [fp, #-16] + eor r3, r2, #1 + and r3, r3, #255 + cmp r3, #0 + bne .L60 + ldr r3, [fp, #-28] + cmp r3, #0 + bgt .L57 + b .L60 +.L61: + ldrb r3, [fp, #-32] @ zero_extendqisi2 + ldr r0, [fp, #-24] + mov r1, r3 + bl bwputc(PLT) +.L60: + ldr r3, [fp, #-28] + cmp r3, #0 + movle r3, #0 + movgt r3, #1 + and r2, r3, #255 + ldr r3, [fp, #-28] + sub r3, r3, #1 + str r3, [fp, #-28] + cmp r2, #0 + bne .L61 + b .L63 +.L64: + ldrb r3, [fp, #-17] @ zero_extendqisi2 + ldr r0, [fp, #-24] + mov r1, r3 + bl bwputc(PLT) +.L63: + ldr r3, [fp, #-36] + ldrb r3, [r3, #0] + strb r3, [fp, #-17] + ldrb r3, [fp, #-17] @ zero_extendqisi2 + cmp r3, #0 + moveq r3, #0 + movne r3, #1 + and r2, r3, #255 + ldr r3, [fp, #-36] + add r3, r3, #1 + str r3, [fp, #-36] + cmp r2, #0 + bne .L64 + sub sp, fp, #12 + ldmfd sp, {fp, sp, pc} + .size bwputw, .-bwputw + .align 2 + .global bwgetc + .type bwgetc, %function +bwgetc: + @ args = 0, pretend = 0, frame = 24 + @ frame_needed = 1, uses_anonymous_args = 0 + mov ip, sp + stmfd sp!, {fp, ip, lr, pc} + sub fp, ip, #4 + sub sp, sp, #24 + str r0, [fp, #-28] + ldr r3, [fp, #-28] + str r3, [fp, #-36] + ldr r3, [fp, #-36] + cmp r3, #0 + beq .L69 + ldr r3, [fp, #-36] + cmp r3, #1 + beq .L70 + b .L68 +.L69: + ldr r3, .L75 + str r3, [fp, #-24] + ldr r3, .L75+4 + str r3, [fp, #-20] + b .L71 +.L70: + ldr r3, .L75+8 + str r3, [fp, #-24] + ldr r3, .L75+12 + str r3, [fp, #-20] + b .L71 +.L68: + mvn r3, #0 + str r3, [fp, #-32] + b .L72 +.L71: + ldr r3, [fp, #-24] + ldr r3, [r3, #0] + mov r3, r3, lsr #6 + and r3, r3, #1 + cmp r3, #0 + beq .L71 + ldr r3, [fp, #-20] + ldr r3, [r3, #0] + strb r3, [fp, #-13] + ldrb r3, [fp, #-13] @ zero_extendqisi2 + str r3, [fp, #-32] +.L72: + ldr r3, [fp, #-32] + mov r0, r3 + sub sp, fp, #12 + ldmfd sp, {fp, sp, pc} +.L76: + .align 2 +.L75: + .word -2138308584 + .word -2138308608 + .word -2138243048 + .word -2138243072 + .size bwgetc, .-bwgetc + .align 2 + .global bwa2d + .type bwa2d, %function +bwa2d: + @ args = 0, pretend = 0, frame = 8 + @ frame_needed = 1, uses_anonymous_args = 0 + mov ip, sp + stmfd sp!, {fp, ip, lr, pc} + sub fp, ip, #4 + sub sp, sp, #8 + mov r3, r0 + strb r3, [fp, #-16] + ldrb r3, [fp, #-16] @ zero_extendqisi2 + cmp r3, #47 + bls .L78 + ldrb r3, [fp, #-16] @ zero_extendqisi2 + cmp r3, #57 + bhi .L78 + ldrb r3, [fp, #-16] @ zero_extendqisi2 + sub r3, r3, #48 + str r3, [fp, #-20] + b .L81 +.L78: + ldrb r3, [fp, #-16] @ zero_extendqisi2 + cmp r3, #96 + bls .L82 + ldrb r3, [fp, #-16] @ zero_extendqisi2 + cmp r3, #102 + bhi .L82 + ldrb r3, [fp, #-16] @ zero_extendqisi2 + sub r3, r3, #87 + str r3, [fp, #-20] + b .L81 +.L82: + ldrb r3, [fp, #-16] @ zero_extendqisi2 + cmp r3, #64 + bls .L85 + ldrb r3, [fp, #-16] @ zero_extendqisi2 + cmp r3, #70 + bhi .L85 + ldrb r3, [fp, #-16] @ zero_extendqisi2 + sub r3, r3, #55 + str r3, [fp, #-20] + b .L81 +.L85: + mvn r3, #0 + str r3, [fp, #-20] +.L81: + ldr r3, [fp, #-20] + mov r0, r3 + sub sp, fp, #12 + ldmfd sp, {fp, sp, pc} + .size bwa2d, .-bwa2d + .align 2 + .global bwa2i + .type bwa2i, %function +bwa2i: + @ args = 0, pretend = 0, frame = 28 + @ frame_needed = 1, uses_anonymous_args = 0 + mov ip, sp + stmfd sp!, {fp, ip, lr, pc} + sub fp, ip, #4 + sub sp, sp, #28 + str r1, [fp, #-32] + str r2, [fp, #-36] + str r3, [fp, #-40] + mov r3, r0 + strb r3, [fp, #-28] + ldr r3, [fp, #-32] + ldr r3, [r3, #0] + str r3, [fp, #-16] + mov r3, #0 + str r3, [fp, #-24] + b .L90 +.L91: + ldr r2, [fp, #-20] + ldr r3, [fp, #-36] + cmp r2, r3 + bgt .L92 + ldr r2, [fp, #-24] + ldr r3, [fp, #-36] + mul r2, r3, r2 + ldr r3, [fp, #-20] + add r3, r2, r3 + str r3, [fp, #-24] + ldr r3, [fp, #-16] + ldrb r3, [r3, #0] + strb r3, [fp, #-28] + ldr r3, [fp, #-16] + add r3, r3, #1 + str r3, [fp, #-16] +.L90: + ldrb r3, [fp, #-28] @ zero_extendqisi2 + mov r0, r3 + bl bwa2d(PLT) + mov r3, r0 + str r3, [fp, #-20] + ldr r3, [fp, #-20] + cmp r3, #0 + bge .L91 +.L92: + ldr r2, [fp, #-32] + ldr r3, [fp, #-16] + str r3, [r2, #0] + ldr r2, [fp, #-40] + ldr r3, [fp, #-24] + str r3, [r2, #0] + ldrb r3, [fp, #-28] @ zero_extendqisi2 + mov r0, r3 + sub sp, fp, #12 + ldmfd sp, {fp, sp, pc} + .size bwa2i, .-bwa2i + .global __udivsi3 + .global __umodsi3 + .align 2 + .global bwui2a + .type bwui2a, %function +bwui2a: + @ args = 0, pretend = 0, frame = 28 + @ frame_needed = 1, uses_anonymous_args = 0 + mov ip, sp + stmfd sp!, {fp, ip, lr, pc} + sub fp, ip, #4 + sub sp, sp, #28 + str r0, [fp, #-28] + str r1, [fp, #-32] + str r2, [fp, #-36] + mov r3, #0 + str r3, [fp, #-24] + mov r3, #1 + str r3, [fp, #-16] + b .L96 +.L97: + ldr r3, [fp, #-16] + ldr r2, [fp, #-32] + mul r3, r2, r3 + str r3, [fp, #-16] +.L96: + ldr r0, [fp, #-28] + ldr r1, [fp, #-16] + bl __udivsi3(PLT) + mov r3, r0 + mov r2, r3 + ldr r3, [fp, #-32] + cmp r2, r3 + bcs .L97 + b .L109 +.L100: + ldr r0, [fp, #-28] + ldr r1, [fp, #-16] + bl __udivsi3(PLT) + mov r3, r0 + str r3, [fp, #-20] + ldr r3, [fp, #-28] + mov r0, r3 + ldr r1, [fp, #-16] + bl __umodsi3(PLT) + mov r3, r0 + str r3, [fp, #-28] + ldr r0, [fp, #-16] + ldr r1, [fp, #-32] + bl __udivsi3(PLT) + mov r3, r0 + str r3, [fp, #-16] + ldr r3, [fp, #-24] + cmp r3, #0 + bne .L101 + ldr r3, [fp, #-20] + cmp r3, #0 + bgt .L101 + ldr r3, [fp, #-16] + cmp r3, #0 + bne .L99 +.L101: + ldr r3, [fp, #-20] + cmp r3, #9 + bgt .L104 + mov r1, #48 + str r1, [fp, #-40] + b .L106 +.L104: + mov r3, #87 + str r3, [fp, #-40] +.L106: + ldr r3, [fp, #-20] + and r3, r3, #255 + ldr r1, [fp, #-40] + mov r2, r1 + add r3, r2, r3 + and r3, r3, #255 + and r3, r3, #255 + ldr r2, [fp, #-36] + strb r3, [r2, #0] + ldr r3, [fp, #-36] + add r3, r3, #1 + str r3, [fp, #-36] + ldr r3, [fp, #-24] + add r3, r3, #1 + str r3, [fp, #-24] +.L99: +.L109: + ldr r3, [fp, #-16] + cmp r3, #0 + bne .L100 + ldr r3, [fp, #-36] + mov r2, #0 + strb r2, [r3, #0] + sub sp, fp, #12 + ldmfd sp, {fp, sp, pc} + .size bwui2a, .-bwui2a + .align 2 + .global bwi2a + .type bwi2a, %function +bwi2a: + @ args = 0, pretend = 0, frame = 8 + @ frame_needed = 1, uses_anonymous_args = 0 + mov ip, sp + stmfd sp!, {fp, ip, lr, pc} + sub fp, ip, #4 + sub sp, sp, #8 + str r0, [fp, #-16] + str r1, [fp, #-20] + ldr r3, [fp, #-16] + cmp r3, #0 + bge .L111 + ldr r3, [fp, #-16] + rsb r3, r3, #0 + str r3, [fp, #-16] + ldr r2, [fp, #-20] + mov r3, #45 + strb r3, [r2, #0] + ldr r3, [fp, #-20] + add r3, r3, #1 + str r3, [fp, #-20] +.L111: + ldr r3, [fp, #-16] + mov r0, r3 + mov r1, #10 + ldr r2, [fp, #-20] + bl bwui2a(PLT) + sub sp, fp, #12 + ldmfd sp, {fp, sp, pc} + .size bwi2a, .-bwi2a + .align 2 + .global bwformat + .type bwformat, %function +bwformat: + @ args = 0, pretend = 0, frame = 40 + @ frame_needed = 1, uses_anonymous_args = 0 + mov ip, sp + stmfd sp!, {fp, ip, lr, pc} + sub fp, ip, #4 + sub sp, sp, #40 + str r0, [fp, #-36] + str r1, [fp, #-40] + str r2, [fp, #-44] + b .L133 +.L116: + ldrb r3, [fp, #-14] @ zero_extendqisi2 + cmp r3, #37 + beq .L117 + ldrb r3, [fp, #-14] @ zero_extendqisi2 + ldr r0, [fp, #-36] + mov r1, r3 + bl bwputc(PLT) + b .L115 +.L117: + mov r3, #0 + strb r3, [fp, #-13] + mov r3, #0 + str r3, [fp, #-32] + ldr r2, [fp, #-40] + ldrb r3, [r2, #0] + strb r3, [fp, #-14] + add r3, r2, #1 + str r3, [fp, #-40] + ldrb r3, [fp, #-14] @ zero_extendqisi2 + str r3, [fp, #-52] + ldr r3, [fp, #-52] + cmp r3, #48 + beq .L120 + ldr r3, [fp, #-52] + cmp r3, #48 + blt .L119 + ldr r3, [fp, #-52] + cmp r3, #57 + bgt .L119 + b .L121 +.L120: + mov r3, #1 + strb r3, [fp, #-13] + ldr r2, [fp, #-40] + ldrb r3, [r2, #0] + strb r3, [fp, #-14] + add r3, r2, #1 + str r3, [fp, #-40] + b .L119 +.L121: + ldrb r3, [fp, #-14] @ zero_extendqisi2 + sub r2, fp, #40 + sub ip, fp, #32 + mov r0, r3 + mov r1, r2 + mov r2, #10 + mov r3, ip + bl bwa2i(PLT) + mov r3, r0 + strb r3, [fp, #-14] +.L119: + ldrb r3, [fp, #-14] @ zero_extendqisi2 + str r3, [fp, #-48] + ldr r3, [fp, #-48] + cmp r3, #115 + beq .L126 + ldr r3, [fp, #-48] + cmp r3, #115 + bgt .L129 + ldr r3, [fp, #-48] + cmp r3, #99 + beq .L124 + ldr r3, [fp, #-48] + cmp r3, #99 + bgt .L130 + ldr r3, [fp, #-48] + cmp r3, #0 + beq .L132 + ldr r3, [fp, #-48] + cmp r3, #37 + beq .L123 + b .L115 +.L130: + ldr r3, [fp, #-48] + cmp r3, #100 + beq .L125 + b .L115 +.L129: + ldr r3, [fp, #-48] + cmp r3, #117 + beq .L127 + ldr r3, [fp, #-48] + cmp r3, #120 + beq .L128 + b .L115 +.L124: + ldr r3, [fp, #-44] + add r3, r3, #4 + str r3, [fp, #-44] + ldr r3, [fp, #-44] + sub r3, r3, #4 + ldrb r3, [r3, #0] @ zero_extendqisi2 + ldr r0, [fp, #-36] + mov r1, r3 + bl bwputc(PLT) + b .L115 +.L126: + ldr r2, [fp, #-32] + ldr r3, [fp, #-44] + add r3, r3, #4 + str r3, [fp, #-44] + ldr r3, [fp, #-44] + sub r3, r3, #4 + ldr r3, [r3, #0] + ldr r0, [fp, #-36] + mov r1, r2 + mov r2, #0 + bl bwputw(PLT) + b .L115 +.L127: + ldr r3, [fp, #-44] + add r3, r3, #4 + str r3, [fp, #-44] + ldr r3, [fp, #-44] + sub r3, r3, #4 + ldr r3, [r3, #0] + sub r2, fp, #26 + mov r0, r3 + mov r1, #10 + bl bwui2a(PLT) + ldr r3, [fp, #-32] + ldrb r2, [fp, #-13] @ zero_extendqisi2 + sub ip, fp, #26 + ldr r0, [fp, #-36] + mov r1, r3 + mov r3, ip + bl bwputw(PLT) + b .L115 +.L125: + ldr r3, [fp, #-44] + add r3, r3, #4 + str r3, [fp, #-44] + ldr r3, [fp, #-44] + sub r3, r3, #4 + ldr r3, [r3, #0] + sub r2, fp, #26 + mov r0, r3 + mov r1, r2 + bl bwi2a(PLT) + ldr r3, [fp, #-32] + ldrb r2, [fp, #-13] @ zero_extendqisi2 + sub ip, fp, #26 + ldr r0, [fp, #-36] + mov r1, r3 + mov r3, ip + bl bwputw(PLT) + b .L115 +.L128: + ldr r3, [fp, #-44] + add r3, r3, #4 + str r3, [fp, #-44] + ldr r3, [fp, #-44] + sub r3, r3, #4 + ldr r3, [r3, #0] + sub r2, fp, #26 + mov r0, r3 + mov r1, #16 + bl bwui2a(PLT) + ldr r3, [fp, #-32] + ldrb r2, [fp, #-13] @ zero_extendqisi2 + sub ip, fp, #26 + ldr r0, [fp, #-36] + mov r1, r3 + mov r3, ip + bl bwputw(PLT) + b .L115 +.L123: + ldrb r3, [fp, #-14] @ zero_extendqisi2 + ldr r0, [fp, #-36] + mov r1, r3 + bl bwputc(PLT) +.L115: +.L133: + ldr r1, [fp, #-40] + ldrb r3, [r1, #0] + strb r3, [fp, #-14] + ldrb r3, [fp, #-14] @ zero_extendqisi2 + cmp r3, #0 + moveq r3, #0 + movne r3, #1 + and r2, r3, #255 + add r3, r1, #1 + str r3, [fp, #-40] + cmp r2, #0 + bne .L116 +.L132: + sub sp, fp, #12 + ldmfd sp, {fp, sp, pc} + .size bwformat, .-bwformat + .align 2 + .global bwprintf + .type bwprintf, %function +bwprintf: + @ args = 4, pretend = 12, frame = 8 + @ frame_needed = 1, uses_anonymous_args = 1 + mov ip, sp + stmfd sp!, {r1, r2, r3} + stmfd sp!, {fp, ip, lr, pc} + sub fp, ip, #16 + sub sp, sp, #8 + str r0, [fp, #-20] + add r3, fp, #8 + str r3, [fp, #-16] + ldr r0, [fp, #-20] + ldr r1, [fp, #4] + ldr r2, [fp, #-16] + bl bwformat(PLT) + sub sp, fp, #12 + ldmfd sp, {fp, sp, pc} + .size bwprintf, .-bwprintf + .ident "GCC: (GNU) 4.0.2" diff --git a/src/scheduler.c b/src/scheduler.c new file mode 100644 index 0000000000000000000000000000000000000000..1b389b55717f11156c3ca00837dcb06021d89517 --- /dev/null +++ b/src/scheduler.c @@ -0,0 +1,13 @@ +#include "scheduler.h" + +// int schedulerInit() { +// return 0; +// } // add the IDLE task with lowest priority and first USER task maybe + +// int pushToScheduler (KernelStruct* Colonel, TD* Task) { +// return 0; +// } + +// TD* getNextTaskScheduler (KernelStruct* Colonel) { +// return NULL; +// } diff --git a/src/task-descriptor.c b/src/task-descriptor.c new file mode 100644 index 0000000000000000000000000000000000000000..43e70426a1f385810a17e334cfd68ff63b6934a8 --- /dev/null +++ b/src/task-descriptor.c @@ -0,0 +1,14 @@ +#include "task-descriptor.h" + + +//void TaskInit(); + +int isTaskAlive(int TaskID) { + return 0; +} + + + + + +