diff --git a/AVR-Crypto-Lib-logo+text.svg b/AVR-Crypto-Lib-logo+text.svg
new file mode 100644
index 0000000..e140390
--- /dev/null
+++ b/AVR-Crypto-Lib-logo+text.svg
@@ -0,0 +1,453 @@
+
+
diff --git a/AVR-Crypto-Lib-logo.svg b/AVR-Crypto-Lib-logo.svg
new file mode 100644
index 0000000..bb90e43
--- /dev/null
+++ b/AVR-Crypto-Lib-logo.svg
@@ -0,0 +1,350 @@
+
+
diff --git a/Makefile b/Makefile
index f51b1a7..7afbe74 100644
--- a/Makefile
+++ b/Makefile
@@ -108,7 +108,12 @@ info:
#-------------------------------------------------------------------------------
+define SOURCEFILE_TEMPLATE
+$(BIN_DIR)$(1): $(2)/$(3).c
+ $(CC) $(CFLAGS) -c -o $@ $<
+endef
+#-------------------------------------------------------------------------------
$(BIN_DIR)%.o: %.c
@echo "[gcc]: $@"
@$(CC) $(CFLAGS) -c -o $@ $<
diff --git a/avr-makefile.inc b/avr-makefile.inc
index d44ca11..323786a 100644
--- a/avr-makefile.inc
+++ b/avr-makefile.inc
@@ -1,7 +1,7 @@
MCU_TARGET = atmega644
OPTIMIZE = -Os
-PROGRAMMER = stk500v2 # avr911
+PROGRAMMER = avr911
DEFS = -D$(call uc, $(MCU_TARGET))
FLASHCMD = avrdude -p $(MCU_TARGET) -P /dev/ttyUSB0 -c $(PROGRAMMER) -U flash:w:# no space at the end
#FLASHCMD = avrdude -p $(MCU_TARGET) -c usbasp -U flash:w:# no space at the end
diff --git a/camellia128-stub.c b/camellia128-stub.c
index 95fb5df..a09223a 100644
--- a/camellia128-stub.c
+++ b/camellia128-stub.c
@@ -28,7 +28,7 @@
#include
#include "camellia.h"
#if 0
- #include "uart.h"
+ #include "cli.h"
#include "debug.h"
#include
#endif
@@ -72,11 +72,11 @@ uint32_t PROGMEM camellia_sigma[12]={ /* 48 byte table */
/*****************************************************************************/
/*
void camellia128_ctx_dump(camellia128_ctx_t *s){
- uart_putstr_P(PSTR("\r\n==State Dump=="));
- uart_putstr_P(PSTR("\n\rKAl: ")); uart_hexdump(&(s->kal), 8);
- uart_putstr_P(PSTR("\n\rKAr: ")); uart_hexdump(&(s->kar), 8);
- uart_putstr_P(PSTR("\n\rKLl: ")); uart_hexdump(&(s->kll), 8);
- uart_putstr_P(PSTR("\n\rKLr: ")); uart_hexdump(&(s->klr), 8);
+ cli_putstr_P(PSTR("\r\n==State Dump=="));
+ cli_putstr_P(PSTR("\n\rKAl: ")); cli_hexdump(&(s->kal), 8);
+ cli_putstr_P(PSTR("\n\rKAr: ")); cli_hexdump(&(s->kar), 8);
+ cli_putstr_P(PSTR("\n\rKLl: ")); cli_hexdump(&(s->kll), 8);
+ cli_putstr_P(PSTR("\n\rKLr: ")); cli_hexdump(&(s->klr), 8);
return;
}
*/
diff --git a/camellia_C.c b/camellia_C.c
index e6ea17f..c8cf450 100644
--- a/camellia_C.c
+++ b/camellia_C.c
@@ -28,7 +28,7 @@
#include
#include "camellia.h"
#if 0
- #include "uart.h"
+ #include "cli.h"
#include "debug.h"
#include
#endif
@@ -100,7 +100,7 @@ uint8_t camellia_s4(uint8_t b){
/*****************************************************************************/
uint64_t camellia_s(uint64_t d){
-// uart_putstr("\n\r S von "); uart_hexdump(&(d), 8);
+// cli_putstr("\n\r S von "); cli_hexdump(&(d), 8);
#define D ((uint8_t*)(&d))
D[7] = camellia_s1(D[7]);
D[6] = camellia_s2(D[6]);
@@ -112,7 +112,7 @@ uint64_t camellia_s(uint64_t d){
D[1] = camellia_s4(D[1]);
D[0] = camellia_s1(D[0]);
#undef D
-// uart_putstr(" ist "); uart_hexdump(&(d), 8);
+// cli_putstr(" ist "); cli_hexdump(&(d), 8);
return d;
}
@@ -133,7 +133,7 @@ uint64_t camellia_p(uint64_t d){
Z[7] = D[3] ^ D[5] ^ D[4];
*/
// Z[7] = z1 z3 z4 z6 z7 z8
-// uart_putstr("\n\r P von "); uart_hexdump(&(d), 8);
+// cli_putstr("\n\r P von "); cli_hexdump(&(d), 8);
Z[7] = D[7] ^ D[5] ^ D[4] ^ D[2] ^ D[1] ^ D[0];
Z[6] = D[7] ^ D[6] ^ D[4] ^ D[3] ^ D[1] ^ D[0];
@@ -144,7 +144,7 @@ uint64_t camellia_p(uint64_t d){
Z[1] = D[5] ^ D[4] ^ D[3] ^ D[2] ^ D[0];
Z[0] = D[7] ^ D[4] ^ D[3] ^ D[2] ^ D[1] ;
-// uart_putstr(" ist "); uart_hexdump(&(z), 8);
+// cli_putstr(" ist "); cli_hexdump(&(z), 8);
#undef Z
#undef D
@@ -176,12 +176,12 @@ uint64_t camellia_fl(uint64_t x, uint64_t k){
yl = (yr | K[0]) ^ (X[1]); /* Yl */
/*
- uart_putstr("\r\nFL(");
- uart_hexdump(&(x), 8);
- uart_putstr(", ");
- uart_hexdump(&(k), 8);
- uart_putstr(") = ");
- uart_hexdump(y, 8);
+ cli_putstr("\r\nFL(");
+ cli_hexdump(&(x), 8);
+ cli_putstr(", ");
+ cli_hexdump(&(k), 8);
+ cli_putstr(") = ");
+ cli_hexdump(y, 8);
*/
#undef K
#undef X
@@ -206,11 +206,11 @@ uint64_t camellia_fl_inv(uint64_t y, uint64_t k){
X[0]=rol32((X[1] & K[1]),1) ^ Y[0];
/*
- uart_putstr("\r\nFL_inv(");
- uart_hexdump(&(y), 8);
- uart_putstr(", ");
- uart_hexdump(&(k), 8);
- uart_putstr(") = ");
+ cli_putstr("\r\nFL_inv(");
+ cli_hexdump(&(y), 8);
+ cli_putstr(", ");
+ cli_hexdump(&(k), 8);
+ cli_putstr(") = ");
*/
#undef K
#undef X
@@ -232,11 +232,11 @@ uint64_t camellia_sigma[6]={
/*****************************************************************************/
#if 0
void camellia128_ctx_dump(camellia128_ctx_t *s){
- uart_putstr("\r\n==State Dump==");
- uart_putstr("\n\rKAl: "); uart_hexdump(&(s->kal), 8);
- uart_putstr("\n\rKAr: "); uart_hexdump(&(s->kar), 8);
- uart_putstr("\n\rKLl: "); uart_hexdump(&(s->kll), 8);
- uart_putstr("\n\rKLr: "); uart_hexdump(&(s->klr), 8);
+ cli_putstr("\r\n==State Dump==");
+ cli_putstr("\n\rKAl: "); cli_hexdump(&(s->kal), 8);
+ cli_putstr("\n\rKAr: "); cli_hexdump(&(s->kar), 8);
+ cli_putstr("\n\rKLl: "); cli_hexdump(&(s->kll), 8);
+ cli_putstr("\n\rKLr: "); cli_hexdump(&(s->klr), 8);
return;
}
#endif
@@ -270,7 +270,7 @@ void camellia128_init(const void* key, camellia128_ctx_t* s){
s->kar ^= camellia_f(s->kal, camellia_sigma[2]);
s->kal ^= camellia_f(s->kar, camellia_sigma[3]);
/**/
-// uart_putstr("\n\r----------------init finished--------------------");
+// cli_putstr("\n\r----------------init finished--------------------");
}
/*****************************************************************************/
diff --git a/cast5.c b/cast5.c
index 57d6f43..6d7f42f 100644
--- a/cast5.c
+++ b/cast5.c
@@ -36,7 +36,7 @@
#undef DEBUG
#ifdef DEBUG
- #include "uart.h"
+ #include "cli.h"
#endif
#include "cast5-sbox.h"
@@ -112,7 +112,7 @@ void cast5_init_rM(uint8_t *klo, uint8_t *khi, uint8_t offset, uint8_t *src, boo
klo[offset*2+1] |= t<<4;
h |= t&0x10; h >>=1;
#ifdef DEBUG
- uart_putstr("\r\n\t h="); uart_hexdump(&h,1);
+ cli_putstr("\r\n\t h="); cli_hexdump(&h,1);
#endif
khi[offset>>1] |= h<<((offset&0x1)?4:0);
}
@@ -204,17 +204,17 @@ uint32_t cast5_f1(uint32_t d, uint32_t m, uint8_t r){
t = ROTL32((d + m),r);
#ifdef DEBUG
uint32_t ia,ib,ic,id;
- uart_putstr("\r\n f1("); uart_hexdump(&d, 4); uart_putc(',');
- uart_hexdump(&m , 4); uart_putc(','); uart_hexdump(&r, 1);uart_putstr("): I=");
- uart_hexdump(&t, 4);
+ cli_putstr("\r\n f1("); cli_hexdump(&d, 4); cli_putc(',');
+ cli_hexdump(&m , 4); cli_putc(','); cli_hexdump(&r, 1);cli_putstr("): I=");
+ cli_hexdump(&t, 4);
ia = pgm_read_dword(&s1[((uint8_t*)&t)[IA]] );
ib = pgm_read_dword(&s2[((uint8_t*)&t)[IB]] );
ic = pgm_read_dword(&s3[((uint8_t*)&t)[IC]] );
id = pgm_read_dword(&s4[((uint8_t*)&t)[ID]] );
- uart_putstr("\r\n\tIA="); uart_hexdump(&ia, 4);
- uart_putstr("\r\n\tIB="); uart_hexdump(&ib, 4);
- uart_putstr("\r\n\tIC="); uart_hexdump(&ic, 4);
- uart_putstr("\r\n\tID="); uart_hexdump(&id, 4);
+ cli_putstr("\r\n\tIA="); cli_hexdump(&ia, 4);
+ cli_putstr("\r\n\tIB="); cli_hexdump(&ib, 4);
+ cli_putstr("\r\n\tIC="); cli_hexdump(&ic, 4);
+ cli_putstr("\r\n\tID="); cli_hexdump(&id, 4);
return (((ia ^ ib) - ic) + id);
@@ -234,19 +234,19 @@ uint32_t cast5_f2(uint32_t d, uint32_t m, uint8_t r){
t = ROTL32((d ^ m),r);
#ifdef DEBUG
uint32_t ia,ib,ic,id;
- uart_putstr("\r\n f2("); uart_hexdump(&d, 4); uart_putc(',');
- uart_hexdump(&m , 4); uart_putc(','); uart_hexdump(&r, 1);uart_putstr("): I=");
- uart_hexdump(&t, 4);
+ cli_putstr("\r\n f2("); cli_hexdump(&d, 4); cli_putc(',');
+ cli_hexdump(&m , 4); cli_putc(','); cli_hexdump(&r, 1);cli_putstr("): I=");
+ cli_hexdump(&t, 4);
ia = pgm_read_dword(&s1[((uint8_t*)&t)[IA]] );
ib = pgm_read_dword(&s2[((uint8_t*)&t)[IB]] );
ic = pgm_read_dword(&s3[((uint8_t*)&t)[IC]] );
id = pgm_read_dword(&s4[((uint8_t*)&t)[ID]] );
- uart_putstr("\r\n\tIA="); uart_hexdump(&ia, 4);
- uart_putstr("\r\n\tIB="); uart_hexdump(&ib, 4);
- uart_putstr("\r\n\tIC="); uart_hexdump(&ic, 4);
- uart_putstr("\r\n\tID="); uart_hexdump(&id, 4);
+ cli_putstr("\r\n\tIA="); cli_hexdump(&ia, 4);
+ cli_putstr("\r\n\tIB="); cli_hexdump(&ib, 4);
+ cli_putstr("\r\n\tIC="); cli_hexdump(&ic, 4);
+ cli_putstr("\r\n\tID="); cli_hexdump(&id, 4);
return (((ia - ib) + ic) ^ id);
#else
@@ -267,19 +267,19 @@ uint32_t cast5_f3(uint32_t d, uint32_t m, uint8_t r){
#ifdef DEBUG
uint32_t ia,ib,ic,id;
- uart_putstr("\r\n f3("); uart_hexdump(&d, 4); uart_putc(',');
- uart_hexdump(&m , 4); uart_putc(','); uart_hexdump(&r, 1);uart_putstr("): I=");
- uart_hexdump(&t, 4);
+ cli_putstr("\r\n f3("); cli_hexdump(&d, 4); cli_putc(',');
+ cli_hexdump(&m , 4); cli_putc(','); cli_hexdump(&r, 1);cli_putstr("): I=");
+ cli_hexdump(&t, 4);
ia = pgm_read_dword(&s1[((uint8_t*)&t)[IA]] );
ib = pgm_read_dword(&s2[((uint8_t*)&t)[IB]] );
ic = pgm_read_dword(&s3[((uint8_t*)&t)[IC]] );
id = pgm_read_dword(&s4[((uint8_t*)&t)[ID]] );
- uart_putstr("\r\n\tIA="); uart_hexdump(&ia, 4);
- uart_putstr("\r\n\tIB="); uart_hexdump(&ib, 4);
- uart_putstr("\r\n\tIC="); uart_hexdump(&ic, 4);
- uart_putstr("\r\n\tID="); uart_hexdump(&id, 4);
+ cli_putstr("\r\n\tIA="); cli_hexdump(&ia, 4);
+ cli_putstr("\r\n\tIB="); cli_hexdump(&ib, 4);
+ cli_putstr("\r\n\tIC="); cli_hexdump(&ic, 4);
+ cli_putstr("\r\n\tID="); cli_hexdump(&id, 4);
return (((ia + ib) ^ ic) - id);
#else
return (( pgm_read_dword(&s1[((uint8_t*)&t)[IA]] )
@@ -298,16 +298,16 @@ void cast5_enc(void* block, const cast5_ctx_t *s){
cast5_f_t* f[]={cast5_f1,cast5_f2,cast5_f3};
l=((uint32_t*)block)[0];
r=((uint32_t*)block)[1];
-// uart_putstr("\r\n round[-1] = ");
-// uart_hexdump(&r, 4);
+// cli_putstr("\r\n round[-1] = ");
+// cli_hexdump(&r, 4);
for (i=0;i<(s->shortkey?12:16);++i){
x = r;
y = (f[i%3])(CHANGE_ENDIAN32(r), CHANGE_ENDIAN32(s->mask[i]),
(((s->roth[i>>3]) & (1<<(i&0x7)))?0x10:0x00)
+ ( ((s->rotl[i>>1])>>((i&1)?4:0)) & 0x0f) );
r = l ^ CHANGE_ENDIAN32(y);
-// uart_putstr("\r\n round["); DEBUG_B(i); uart_putstr("] = ");
-// uart_hexdump(&r, 4);
+// cli_putstr("\r\n round["); DEBUG_B(i); cli_putstr("] = ");
+// cli_hexdump(&r, 4);
l = x;
}
((uint32_t*)block)[0]=r;
diff --git a/cast6.c b/cast6.c
index cb0754b..c4922fc 100644
--- a/cast6.c
+++ b/cast6.c
@@ -194,31 +194,31 @@ void w(void* buffer, uint8_t* tr, uint32_t* tm){
/*
void dump_ctx(const cast6_ctx_t* ctx){
uint8_t i,t;
- uart_putstr_P(PSTR("\r\n DBG:"));
+ cli_putstr_P(PSTR("\r\n DBG:"));
for(i=0; i<12; ++i){
- uart_putstr_P(PSTR("\r\n DBG:"));
- uart_putstr_P(PSTR(" rotk1="));
+ cli_putstr_P(PSTR("\r\n DBG:"));
+ cli_putstr_P(PSTR(" rotk1="));
t=kr(i*4+0, ctx);
- uart_hexdump(&t,1);
- uart_putstr_P(PSTR(" rotk2="));
+ cli_hexdump(&t,1);
+ cli_putstr_P(PSTR(" rotk2="));
t=kr(i*4+1, ctx);
- uart_hexdump(&t,1);
- uart_putstr_P(PSTR(" rotk3="));
+ cli_hexdump(&t,1);
+ cli_putstr_P(PSTR(" rotk3="));
t=kr(i*4+2, ctx);
- uart_hexdump(&t,1);
- uart_putstr_P(PSTR(" rotk4="));
+ cli_hexdump(&t,1);
+ cli_putstr_P(PSTR(" rotk4="));
t=kr(i*4+3, ctx);
- uart_hexdump(&t,1);
- uart_putstr_P(PSTR("\r\n "));
- uart_putstr_P(PSTR(" mask1="));
- uart_hexdump(&(ctx->km[i][0]),4);
- uart_putstr_P(PSTR(" mask2="));
- uart_hexdump(&(ctx->km[i][1]),4);
- uart_putstr_P(PSTR(" mask3="));
- uart_hexdump(&(ctx->km[i][2]),4);
- uart_putstr_P(PSTR(" mask4="));
- uart_hexdump(&(ctx->km[i][3]),4);
- uart_putstr_P(PSTR("\r\n;-----"));
+ cli_hexdump(&t,1);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_putstr_P(PSTR(" mask1="));
+ cli_hexdump(&(ctx->km[i][0]),4);
+ cli_putstr_P(PSTR(" mask2="));
+ cli_hexdump(&(ctx->km[i][1]),4);
+ cli_putstr_P(PSTR(" mask3="));
+ cli_hexdump(&(ctx->km[i][2]),4);
+ cli_putstr_P(PSTR(" mask4="));
+ cli_hexdump(&(ctx->km[i][3]),4);
+ cli_putstr_P(PSTR("\r\n;-----"));
}
}
*/
diff --git a/config.h b/config.h
index 20af845..252a924 100644
--- a/config.h
+++ b/config.h
@@ -24,6 +24,7 @@
// #define F_CPU 14745600
+#include "uart_defs.h"
#define DEBUG uart
@@ -38,6 +39,17 @@
#define UART_XON_XOFF_THRESHOLD_2 (UART_RXBUFSIZE - 60)
#undef UART_LEDS
+
+#define UART0_I 1
+#define UART0_BAUD_RATE 38400
+#define UART0_PARATY UART_PARATY_NONE
+#define UART0_STOPBITS UART_STOPBITS_1
+#define UART0_DATABITS UART_DATABITS_8
+#define UART0_RXBUFFER_SIZE 64
+#define UART0_TXBUFFER_SIZE 64
+#define UART0_SWFLOWCTRL 1
+#define UART0_THRESH_LOW 10
+#define UART0_THRESH_HIGH 48
/*
#define UART_HWFLOWCONTROL
#define UART_RTS_PORT PORTA
diff --git a/des.c b/des.c
index 57bc7e3..2600a22 100644
--- a/des.c
+++ b/des.c
@@ -27,7 +27,7 @@
*/
#include "config.h"
#include "debug.h"
-#include "uart.h"
+#include "cli.h"
#include
#include
#include
diff --git a/md5.c b/md5.c
index 20ec519..003699e 100644
--- a/md5.c
+++ b/md5.c
@@ -27,7 +27,7 @@
#include "md5.h"
#include "md5_sbox.h"
- #include "uart.h"
+ #include "cli.h"
#include
#include
@@ -73,12 +73,12 @@ void md5_core(uint32_t* a, void* block, uint8_t as, uint8_t s, uint8_t i, uint8_
/* a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */
#ifdef DEBUG
char funcc[]={'*', '-', '+', '~'};
- uart_putstr("\r\n DBG: md5_core [");
- uart_putc(funcc[fi]);
- uart_hexdump(&as, 1); uart_putc(' ');
- uart_hexdump(&k, 1); uart_putc(' ');
- uart_hexdump(&s, 1); uart_putc(' ');
- uart_hexdump(&i, 1); uart_putc(']');
+ cli_putstr("\r\n DBG: md5_core [");
+ cli_putc(funcc[fi]);
+ cli_hexdump(&as, 1); cli_putc(' ');
+ cli_hexdump(&k, 1); cli_putc(' ');
+ cli_hexdump(&s, 1); cli_putc(' ');
+ cli_hexdump(&i, 1); cli_putc(']');
#endif
t = a[as] + funcs[fi](a[(as+1)&3], a[(as+2)&3], a[(as+3)&3])
+ *((uint32_t*)block) + pgm_read_dword(md5_T+i) ;
@@ -90,11 +90,11 @@ void md5_nextBlock(md5_ctx_t *state, const void* block){
uint8_t m,n,i=0;
/* this requires other mixed sboxes */
#ifdef DEBUG
- uart_putstr("\r\n DBG: md5_nextBlock: block:\r\n");
- uart_hexdump(block, 16); uart_putstr("\r\n");
- uart_hexdump(block+16, 16); uart_putstr("\r\n");
- uart_hexdump(block+32, 16); uart_putstr("\r\n");
- uart_hexdump(block+48, 16); uart_putstr("\r\n");
+ cli_putstr("\r\n DBG: md5_nextBlock: block:\r\n");
+ cli_hexdump(block, 16); cli_putstr("\r\n");
+ cli_hexdump(block+16, 16); cli_putstr("\r\n");
+ cli_hexdump(block+32, 16); cli_putstr("\r\n");
+ cli_hexdump(block+48, 16); cli_putstr("\r\n");
#endif
a[0]=state->a[0];
diff --git a/mkfiles/001_cli_std.mk b/mkfiles/001_cli_std.mk
index a13bf72..22608a3 100644
--- a/mkfiles/001_cli_std.mk
+++ b/mkfiles/001_cli_std.mk
@@ -1 +1,2 @@
-CLI_STD = debug.o uart.o hexdigit_tab.o dbz_strings.o cli.o string-extras.o
+CLI_STD = cli-stub.o cli-basics.o cli-core.o cli-hexdump.o debug.o hexdigit_tab.o \
+ dbz_strings.o string-extras-asm.o uart_i-asm.o circularbytebuffer-asm.o
diff --git a/mkfiles/a5_1.mk b/mkfiles/a5_1.mk
index 63f59ec..5dfcadd 100644
--- a/mkfiles/a5_1.mk
+++ b/mkfiles/a5_1.mk
@@ -5,8 +5,7 @@ ALGO_NAME := A51
STREAM_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := A5_1.o
-$(ALGO_NAME)_TEST_BIN := main-a5_1-test.o debug.o uart.o hexdigit_tab.o \
- nessie_stream_test.o dbz_strings.o nessie_common.o cli.o string-extras.o
+$(ALGO_NAME)_TEST_BIN := main-a5_1-test.o nessie_stream_test.o nessie_common.o $(CLI_STD)
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/aes.mk b/mkfiles/aes.mk
index 871434b..f19a1c6 100644
--- a/mkfiles/aes.mk
+++ b/mkfiles/aes.mk
@@ -7,8 +7,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := aes_enc-asm.o aes_dec-asm.o aes_sbox-asm.o aes_invsbox-asm.o \
aes_keyschedule-asm.o
-$(ALGO_NAME)_TEST_BIN := main-aes-test.o debug.o uart.o hexdigit_tab.o \
- nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-aes-test.o $(CLI_STD) \
+ nessie_bc_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := test nessie
$(ALGO_NAME)_PERFORMANCE_TEST := performance
diff --git a/mkfiles/aes_asm_faster.mk b/mkfiles/aes_asm_faster.mk
index ad5acb5..18ba9d8 100644
--- a/mkfiles/aes_asm_faster.mk
+++ b/mkfiles/aes_asm_faster.mk
@@ -7,8 +7,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := aes_enc-asm.o aes_dec-asm_faster.o aes_sbox-asm.o aes_invsbox-asm.o \
aes_keyschedule-asm.o
-$(ALGO_NAME)_TEST_BIN := main-aes-test.o debug.o uart.o hexdigit_tab.o \
- nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-aes-test.o $(CLI_STD) \
+ nessie_bc_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := test nessie
$(ALGO_NAME)_PERFORMANCE_TEST := performance
diff --git a/mkfiles/aes_c.mk b/mkfiles/aes_c.mk
index dcc6c62..8f0a4e1 100644
--- a/mkfiles/aes_c.mk
+++ b/mkfiles/aes_c.mk
@@ -9,8 +9,8 @@ $(ALGO_NAME)_OBJ := aes_enc.o aes_dec.o aes_sbox.o aes_invsbox.o \
aes_keyschedule.o gf256mul.o \
aes128_enc.o aes128_dec.o aes192_enc.o aes192_dec.o \
aes256_enc.o aes256_dec.o
-$(ALGO_NAME)_TEST_BIN := main-aes-test.o debug.o uart.o hexdigit_tab.o \
- nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-aes-test.o $(CLI_STD) \
+ nessie_bc_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := test nessie
$(ALGO_NAME)_PERFORMANCE_TEST := performance
diff --git a/mkfiles/arcfour.mk b/mkfiles/arcfour.mk
index 7cc4c8e..d62c144 100644
--- a/mkfiles/arcfour.mk
+++ b/mkfiles/arcfour.mk
@@ -5,9 +5,8 @@ ALGO_NAME := ARCFOUR
STREAM_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := arcfour-asm.o
-$(ALGO_NAME)_TEST_BIN := main-arcfour-test.o debug.o uart.o hexdigit_tab.o \
- nessie_stream_test.o dbz_strings.o nessie_common.o cli.o string-extras.o \
- performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-arcfour-test.o $(CLI_STD) \
+ nessie_stream_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/arcfour_c.mk b/mkfiles/arcfour_c.mk
index 23a4135..40a3a84 100644
--- a/mkfiles/arcfour_c.mk
+++ b/mkfiles/arcfour_c.mk
@@ -5,8 +5,8 @@ ALGO_NAME := ARCFOUR_C
STREAM_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := arcfour.o
-$(ALGO_NAME)_TEST_BIN := main-arcfour-test.o debug.o uart.o hexdigit_tab.o \
- nessie_stream_test.o dbz_strings.o nessie_common.o cli.o string-extras.o \
+$(ALGO_NAME)_TEST_BIN := main-arcfour-test.o $(CLI_STD) \
+ nessie_stream_test.o nessie_common.o \
performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/base64.mk b/mkfiles/base64.mk
index 35695c4..58883c3 100644
--- a/mkfiles/base64.mk
+++ b/mkfiles/base64.mk
@@ -6,9 +6,8 @@ ENCODINGS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := base64_enc.o base64_dec.o
-$(ALGO_NAME)_TEST_BIN := main-base64-test.o debug.o uart.o hexdigit_tab.o \
- cli.o string-extras.o performance_test.o noekeon_asm.o noekeon_prng.o \
- memxor.o
+$(ALGO_NAME)_TEST_BIN := main-base64-test.o $(CLI_STD) \
+ performance_test.o noekeon_asm.o noekeon_prng.o memxor.o
$(ALGO_NAME)_PERFORMANCE_TEST := performance
diff --git a/mkfiles/camellia.mk b/mkfiles/camellia.mk
index 2cd0581..0a7fbc5 100644
--- a/mkfiles/camellia.mk
+++ b/mkfiles/camellia.mk
@@ -5,9 +5,8 @@ ALGO_NAME := CAMELLIA
BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := camellia128-stub.o camellia-asm.o
-$(ALGO_NAME)_TEST_BIN := main-camellia-test.o debug.o uart.o hexdigit_tab.o \
- nessie_bc_test.o \
- dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-camellia-test.o $(CLI_STD) nessie_bc_test.o \
+ nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/cast5.mk b/mkfiles/cast5.mk
index df2fd13..08ead6e 100644
--- a/mkfiles/cast5.mk
+++ b/mkfiles/cast5.mk
@@ -5,8 +5,8 @@ ALGO_NAME := CAST5
BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := cast5.o
-$(ALGO_NAME)_TEST_BIN := main-cast5-test.o debug.o uart.o hexdigit_tab.o cli.o string-extras.o\
- nessie_bc_test.o dbz_strings.o nessie_common.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-cast5-test.o $(CLI_STD) \
+ nessie_bc_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/cast6.mk b/mkfiles/cast6.mk
index eb3baad..3f8539f 100644
--- a/mkfiles/cast6.mk
+++ b/mkfiles/cast6.mk
@@ -6,8 +6,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := cast6.o
-$(ALGO_NAME)_TEST_BIN := main-cast6-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
- nessie_bc_test.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-cast6-test.o $(CLI_STD) \
+ nessie_bc_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := test nessie
$(ALGO_NAME)_PERFORMANCE_TEST := performance
diff --git a/mkfiles/des.mk b/mkfiles/des.mk
index 17c5709..5d9540d 100644
--- a/mkfiles/des.mk
+++ b/mkfiles/des.mk
@@ -5,8 +5,8 @@ ALGO_NAME := DES
BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := des.o
-$(ALGO_NAME)_TEST_BIN := main-des-test.o debug.o uart.o hexdigit_tab.o \
- nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-des-test.o $(CLI_STD) \
+ nessie_bc_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/entropium.mk b/mkfiles/entropium.mk
index f6c16f6..02ad75b 100644
--- a/mkfiles/entropium.mk
+++ b/mkfiles/entropium.mk
@@ -5,8 +5,7 @@ ALGO_NAME := ENTROPIUM
PRNGS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := entropium.o sha256-asm.o
-$(ALGO_NAME)_TEST_BIN := main-entropium-test.o debug.o uart.o hexdigit_tab.o \
- cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-entropium-test.o $(CLI_STD) performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/grain.mk b/mkfiles/grain.mk
index a79076d..1b0da65 100644
--- a/mkfiles/grain.mk
+++ b/mkfiles/grain.mk
@@ -5,9 +5,8 @@ ALGO_NAME := GRAIN
STREAM_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := grain.o
-$(ALGO_NAME)_TEST_BIN := main-grain-test.o debug.o uart.o hexdigit_tab.o \
- nessie_stream_test.o dbz_strings.o nessie_common.o cli.o string-extras.o \
- performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-grain-test.o $(CLI_STD) \
+ nessie_stream_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/hmac-md5.mk b/mkfiles/hmac-md5.mk
index a816ed3..7d3f644 100644
--- a/mkfiles/hmac-md5.mk
+++ b/mkfiles/hmac-md5.mk
@@ -5,8 +5,8 @@ ALGO_NAME := HMAC-MD5
MACS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := hmac-md5.o md5-asm.o
-$(ALGO_NAME)_TEST_BIN := main-hmac-md5-test.o debug.o uart.o hexdigit_tab.o cli.o string-extras.o \
- nessie_mac_test.o dbz_strings.o nessie_common.o base64_enc.o base64_dec.o
+$(ALGO_NAME)_TEST_BIN := main-hmac-md5-test.o $(CLI_STD) \
+ nessie_mac_test.o nessie_common.o base64_enc.o base64_dec.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/hmac-sha1.mk b/mkfiles/hmac-sha1.mk
index 3c75921..9087400 100644
--- a/mkfiles/hmac-sha1.mk
+++ b/mkfiles/hmac-sha1.mk
@@ -5,8 +5,8 @@ ALGO_NAME := HMAC-SHA1
MACS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := hmac-sha1.o sha1-asm.o
-$(ALGO_NAME)_TEST_BIN := main-hmac-sha1-test.o debug.o uart.o hexdigit_tab.o cli.o string-extras.o \
- nessie_mac_test.o dbz_strings.o nessie_common.o
+$(ALGO_NAME)_TEST_BIN := main-hmac-sha1-test.o $(CLI_STD) \
+ nessie_mac_test.o nessie_common.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/hmac-sha256.mk b/mkfiles/hmac-sha256.mk
index 2dd2973..ba221ab 100644
--- a/mkfiles/hmac-sha256.mk
+++ b/mkfiles/hmac-sha256.mk
@@ -5,8 +5,8 @@ ALGO_NAME := HMAC-SHA256
MACS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := hmac-sha256.o sha256-asm.o
-$(ALGO_NAME)_TEST_BIN := main-hmac-sha256-test.o debug.o uart.o hexdigit_tab.o \
- nessie_mac_test.o dbz_strings.o nessie_common.o cli.o string-extras.o
+$(ALGO_NAME)_TEST_BIN := main-hmac-sha256-test.o $(CLI_STD) \
+ nessie_mac_test.o nessie_common.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/mickey128.mk b/mkfiles/mickey128.mk
index 382fcb9..6c95c96 100644
--- a/mkfiles/mickey128.mk
+++ b/mkfiles/mickey128.mk
@@ -5,8 +5,8 @@ ALGO_NAME := MICKEY128
STREAM_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := mickey128.o
-$(ALGO_NAME)_TEST_BIN := main-mickey128-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
- nessie_stream_test.o nessie_common.o cli.o string-extras.o
+$(ALGO_NAME)_TEST_BIN := main-mickey128-test.o $(CLI_STD) \
+ nessie_stream_test.o nessie_common.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/mugi.mk b/mkfiles/mugi.mk
index 0e1e61f..7bcb92f 100644
--- a/mkfiles/mugi.mk
+++ b/mkfiles/mugi.mk
@@ -5,8 +5,8 @@ ALGO_NAME := MUGI_C
STREAM_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := mugi.o gf256mul.o aes_sbox.o
-$(ALGO_NAME)_TEST_BIN := main-mugi-test.o debug.o uart.o hexdigit_tab.o \
- nessie_stream_test.o dbz_strings.o nessie_common.o cli.o string-extras.o \
+$(ALGO_NAME)_TEST_BIN := main-mugi-test.o $(CLI_STD) \
+ nessie_stream_test.o nessie_common.o \
performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/noekeon.mk b/mkfiles/noekeon.mk
index 9c70942..0863162 100644
--- a/mkfiles/noekeon.mk
+++ b/mkfiles/noekeon.mk
@@ -6,8 +6,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := noekeon_asm.o
-$(ALGO_NAME)_TEST_BIN := main-noekeon-test.o debug.o uart.o hexdigit_tab.o \
- nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-noekeon-test.o $(CLI_STD) \
+ nessie_bc_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := test nessie
$(ALGO_NAME)_PERFORMANCE_TEST := performance
diff --git a/mkfiles/noekeon_c.mk b/mkfiles/noekeon_c.mk
index 700e8c2..0f7f087 100644
--- a/mkfiles/noekeon_c.mk
+++ b/mkfiles/noekeon_c.mk
@@ -6,8 +6,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := noekeon.o
-$(ALGO_NAME)_TEST_BIN := main-noekeon-test.o debug.o uart.o hexdigit_tab.o \
- nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-noekeon-test.o $(CLI_STD) \
+ nessie_bc_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := test nessie
$(ALGO_NAME)_PERFORMANCE_TEST := performance
diff --git a/mkfiles/omac_noekeon.mk b/mkfiles/omac_noekeon.mk
index 3429a4a..5c8ba7c 100644
--- a/mkfiles/omac_noekeon.mk
+++ b/mkfiles/omac_noekeon.mk
@@ -6,8 +6,8 @@ MACS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := noekeon_asm.o omac_noekeon.o memxor.o
-$(ALGO_NAME)_TEST_BIN := main-omac-noekeon-test.o debug.o uart.o hexdigit_tab.o \
- nessie_mac_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-omac-noekeon-test.o $(CLI_STD) \
+ nessie_mac_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := test nessie
$(ALGO_NAME)_PERFORMANCE_TEST := performance
diff --git a/mkfiles/omac_noekeon_c.mk b/mkfiles/omac_noekeon_c.mk
index e704b1e..4346d33 100644
--- a/mkfiles/omac_noekeon_c.mk
+++ b/mkfiles/omac_noekeon_c.mk
@@ -6,8 +6,8 @@ MACS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := noekeon_asm.o omac_noekeon_C.o memxor.o
-$(ALGO_NAME)_TEST_BIN := main-omac-noekeon-test.o debug.o uart.o hexdigit_tab.o \
- nessie_mac_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-omac-noekeon-test.o $(CLI_STD) \
+ nessie_mac_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := test nessie
$(ALGO_NAME)_PERFORMANCE_TEST := performance
diff --git a/mkfiles/present.mk b/mkfiles/present.mk
index 2c8e9d1..3a4012c 100644
--- a/mkfiles/present.mk
+++ b/mkfiles/present.mk
@@ -6,8 +6,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := present.o
-$(ALGO_NAME)_TEST_BIN := main-present-test.o debug.o uart.o hexdigit_tab.o \
- nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-present-test.o $(CLI_STD) \
+ nessie_bc_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/rc5.mk b/mkfiles/rc5.mk
index f948b62..3a5f128 100644
--- a/mkfiles/rc5.mk
+++ b/mkfiles/rc5.mk
@@ -6,9 +6,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := rc5.o
-$(ALGO_NAME)_TEST_BIN := main-rc5-test.o debug.o uart.o hexdigit_tab.o \
- nessie_bc_test.o \
- dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-rc5-test.o $(CLI_STD) nessie_bc_test.o \
+ nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := test nessie
$(ALGO_NAME)_PERFORMANCE_TEST := performance
diff --git a/mkfiles/rc6.mk b/mkfiles/rc6.mk
index f6729e3..e0bc603 100644
--- a/mkfiles/rc6.mk
+++ b/mkfiles/rc6.mk
@@ -6,8 +6,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := rc6.o
-$(ALGO_NAME)_TEST_BIN := main-rc6-test.o debug.o uart.o hexdigit_tab.o \
- nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-rc6-test.o $(CLI_STD) \
+ nessie_bc_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := test nessie
$(ALGO_NAME)_PERFORMANCE_TEST := performance
diff --git a/mkfiles/seed.mk b/mkfiles/seed.mk
index 28b437a..1c2b605 100644
--- a/mkfiles/seed.mk
+++ b/mkfiles/seed.mk
@@ -5,9 +5,8 @@ ALGO_NAME := SEED
BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := seed-asm.o
-$(ALGO_NAME)_TEST_BIN := main-seed-test.o debug.o uart.o hexdigit_tab.o \
- nessie_bc_test.o dbz_strings.o nessie_common.o \
- cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-seed-test.o $(CLI_STD) \
+ nessie_bc_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/seed_C.mk b/mkfiles/seed_C.mk
index 7ec687f..14aa8ac 100644
--- a/mkfiles/seed_C.mk
+++ b/mkfiles/seed_C.mk
@@ -5,9 +5,8 @@ ALGO_NAME := SEED_C
BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := seed_C.o
-$(ALGO_NAME)_TEST_BIN := main-seed-test.o debug.o uart.o hexdigit_tab.o \
- nessie_bc_test.o dbz_strings.o nessie_common.o \
- cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-seed-test.o $(CLI_STD) \
+ nessie_bc_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/serpent-bitslice.mk b/mkfiles/serpent-bitslice.mk
index d1e5a9a..6a9b76a 100644
--- a/mkfiles/serpent-bitslice.mk
+++ b/mkfiles/serpent-bitslice.mk
@@ -6,8 +6,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := serpent-asm.o serpent-sboxes-bitslice-asm.o memxor.o
-$(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o hexdigit_tab.o \
- nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-serpent-test.o $(CLI_STD) \
+ nessie_bc_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/serpent_asm_bitslice.mk b/mkfiles/serpent_asm_bitslice.mk
index f8cb7b7..afd0868 100644
--- a/mkfiles/serpent_asm_bitslice.mk
+++ b/mkfiles/serpent_asm_bitslice.mk
@@ -6,8 +6,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := serpent-sboxes-bitslice-asm.o serpent-asm.o memxor.o
-$(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o hexdigit_tab.o \
- nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-serpent-test.o $(CLI_STD) \
+ nessie_bc_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/serpent_asm_fast.mk b/mkfiles/serpent_asm_fast.mk
index d9c3760..3e3a4fb 100644
--- a/mkfiles/serpent_asm_fast.mk
+++ b/mkfiles/serpent_asm_fast.mk
@@ -6,8 +6,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := serpent-asm.o serpent-sboxes-fast.o memxor.o
-$(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o hexdigit_tab.o \
- nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-serpent-test.o $(CLI_STD) \
+ nessie_bc_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/serpent_asm_small.mk b/mkfiles/serpent_asm_small.mk
index 52cfda2..6dde94b 100644
--- a/mkfiles/serpent_asm_small.mk
+++ b/mkfiles/serpent_asm_small.mk
@@ -6,8 +6,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := serpent-asm.o serpent-sboxes-small.o memxor.o
-$(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o hexdigit_tab.o \
- nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-serpent-test.o $(CLI_STD) \
+ nessie_bc_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/serpent_c.mk b/mkfiles/serpent_c.mk
index e8c7be4..dd3a69b 100644
--- a/mkfiles/serpent_c.mk
+++ b/mkfiles/serpent_c.mk
@@ -6,8 +6,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := serpent.o serpent-sboxes_c.o memxor.o
-$(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o hexdigit_tab.o \
- nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-serpent-test.o $(CLI_STD) \
+ nessie_bc_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/sha1.mk b/mkfiles/sha1.mk
index 434697e..45df051 100644
--- a/mkfiles/sha1.mk
+++ b/mkfiles/sha1.mk
@@ -5,7 +5,7 @@ ALGO_NAME := SHA1
HASHES += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := sha1-asm.o
-$(ALGO_NAME)_TEST_BIN := main-sha1-test.o hfal_sha1.o $(CLI_STD) $(HFAL_STD) dump.o
+$(ALGO_NAME)_TEST_BIN := main-sha1-test.o hfal_sha1.o $(CLI_STD) $(HFAL_STD) dump-decl.o dump-asm.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/sha1_c.mk b/mkfiles/sha1_c.mk
index 4ce9f0a..4b0b7ae 100644
--- a/mkfiles/sha1_c.mk
+++ b/mkfiles/sha1_c.mk
@@ -5,7 +5,7 @@ ALGO_NAME := SHA1_C
HASHES += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := sha1.o
-$(ALGO_NAME)_TEST_BIN := main-sha1-test.o hfal_sha1.o dump.o $(CLI_STD) $(HFAL_STD)
+$(ALGO_NAME)_TEST_BIN := main-sha1-test.o hfal_sha1.o dump-asm.o dump-decl.o $(CLI_STD) $(HFAL_STD)
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/sha256.mk b/mkfiles/sha256.mk
index 92dc0bc..93ebdc7 100644
--- a/mkfiles/sha256.mk
+++ b/mkfiles/sha256.mk
@@ -5,8 +5,7 @@ ALGO_NAME := SHA256
HASHES += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := sha256-asm.o
-$(ALGO_NAME)_TEST_BIN := main-sha256-test.o dump.o hfal_sha256.o $(CLI_STD) $(HFAL_STD)
-
+$(ALGO_NAME)_TEST_BIN := main-sha256-test.o dump-asm.o dump-decl.o hfal_sha256.o $(CLI_STD) $(HFAL_STD)
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/sha256_c.mk b/mkfiles/sha256_c.mk
index 0e172db..d52fe88 100644
--- a/mkfiles/sha256_c.mk
+++ b/mkfiles/sha256_c.mk
@@ -5,7 +5,7 @@ ALGO_NAME := SHA256_C
HASHES += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := sha256.o
-$(ALGO_NAME)_TEST_BIN := main-sha256-test.o $(CLI_STD) $(HFAL_STD) hfal_sha256.o dump.o
+$(ALGO_NAME)_TEST_BIN := main-sha256-test.o $(CLI_STD) $(HFAL_STD) hfal_sha256.o dump-asm.o dump-decl.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/shabea.mk b/mkfiles/shabea.mk
index fb65dd4..e5f4a68 100644
--- a/mkfiles/shabea.mk
+++ b/mkfiles/shabea.mk
@@ -5,8 +5,8 @@ ALGO_NAME := SHABEA
BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := shabea.o sha256-asm.o memxor.o
-$(ALGO_NAME)_TEST_BIN := main-shabea-test.o debug.o uart.o hexdigit_tab.o \
- nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-shabea-test.o $(CLI_STD) \
+ nessie_bc_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/shacal1enc.mk b/mkfiles/shacal1enc.mk
index 728116e..63be6c8 100644
--- a/mkfiles/shacal1enc.mk
+++ b/mkfiles/shacal1enc.mk
@@ -6,8 +6,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := shacal1_enc.o sha1-asm.o
-$(ALGO_NAME)_TEST_BIN := main-shacal1_enc-test.o debug.o uart.o hexdigit_tab.o \
- nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-shacal1_enc-test.o $(CLI_STD) \
+ nessie_bc_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/shacal2enc.mk b/mkfiles/shacal2enc.mk
index fe24aba..e8a91a2 100644
--- a/mkfiles/shacal2enc.mk
+++ b/mkfiles/shacal2enc.mk
@@ -6,8 +6,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := shacal2_enc.o sha256-asm.o
-$(ALGO_NAME)_TEST_BIN := main-shacal2_enc-test.o debug.o uart.o hexdigit_tab.o \
- nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-shacal2_enc-test.o $(CLI_STD) \
+ nessie_bc_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/skipjack.mk b/mkfiles/skipjack.mk
index a325577..56579b2 100644
--- a/mkfiles/skipjack.mk
+++ b/mkfiles/skipjack.mk
@@ -5,9 +5,8 @@ ALGO_NAME := SKIPJACK
BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := skipjack.o
-$(ALGO_NAME)_TEST_BIN := main-skipjack-test.o debug.o uart.o hexdigit_tab.o \
- nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o \
- performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-skipjack-test.o $(CLI_STD) \
+ nessie_bc_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/tdes.mk b/mkfiles/tdes.mk
index 34740e9..7bdc41e 100644
--- a/mkfiles/tdes.mk
+++ b/mkfiles/tdes.mk
@@ -5,8 +5,8 @@ ALGO_NAME := TDES
BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := des.o
-$(ALGO_NAME)_TEST_BIN := main-tdes-test.o debug.o uart.o hexdigit_tab.o \
- nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-tdes-test.o $(CLI_STD) \
+ nessie_bc_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/threefish.mk b/mkfiles/threefish.mk
index ef68ed4..7781f37 100644
--- a/mkfiles/threefish.mk
+++ b/mkfiles/threefish.mk
@@ -8,8 +8,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := threefish256_enc_asm.o threefish512_enc_asm.o threefish1024_enc_asm.o\
threefish_mix.o threefish_invmix.o \
threefish256_dec_asm.o threefish512_dec_asm.o threefish1024_dec_asm.o
-$(ALGO_NAME)_TEST_BIN := main-threefish-test.o debug.o uart.o hexdigit_tab.o \
- nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-threefish-test.o $(CLI_STD) \
+ nessie_bc_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := test nessie
$(ALGO_NAME)_PERFORMANCE_TEST := performance
diff --git a/mkfiles/trivium.mk b/mkfiles/trivium.mk
index 1478cb6..bbfba3b 100644
--- a/mkfiles/trivium.mk
+++ b/mkfiles/trivium.mk
@@ -5,9 +5,8 @@ ALGO_NAME := TRIVIUM
STREAM_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := trivium.o
-$(ALGO_NAME)_TEST_BIN := main-trivium-test.o debug.o uart.o hexdigit_tab.o \
- nessie_stream_test.o dbz_strings.o nessie_common.o cli.o string-extras.o \
- performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-trivium-test.o $(CLI_STD) \
+ nessie_stream_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/ubi.mk b/mkfiles/ubi.mk
index 9f0984d..4c1965e 100644
--- a/mkfiles/ubi.mk
+++ b/mkfiles/ubi.mk
@@ -8,8 +8,8 @@ AUX += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := threefish_mix.o threefish256_enc_asm.o ubi256_asm.o \
threefish512_enc_asm.o ubi512_asm.o threefish1024_enc_asm.o \
ubi1024_asm.o memxor.o
-$(ALGO_NAME)_TEST_BIN := main-ubi-test.o debug.o uart.o hexdigit_tab.o \
- dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-ubi-test.o $(CLI_STD) \
+ nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := test nessie
$(ALGO_NAME)_PERFORMANCE_TEST := performance
diff --git a/mkfiles/xtea.mk b/mkfiles/xtea.mk
index a26ec22..68adcfb 100644
--- a/mkfiles/xtea.mk
+++ b/mkfiles/xtea.mk
@@ -5,8 +5,8 @@ ALGO_NAME := XTEA
BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := xtea-asm.o
-$(ALGO_NAME)_TEST_BIN := main-xtea-test.o debug.o uart.o hexdigit_tab.o \
- nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-xtea-test.o $(CLI_STD) \
+ nessie_bc_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/mkfiles/xtea_c.mk b/mkfiles/xtea_c.mk
index 9779aff..dec8f8c 100644
--- a/mkfiles/xtea_c.mk
+++ b/mkfiles/xtea_c.mk
@@ -5,8 +5,8 @@ ALGO_NAME := XTEA_C
BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := xtea.o
-$(ALGO_NAME)_TEST_BIN := main-xtea-test.o debug.o uart.o hexdigit_tab.o \
- nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-xtea-test.o $(CLI_STD) \
+ nessie_bc_test.o nessie_common.o performance_test.o
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
diff --git a/noekeon.c b/noekeon.c
index 4b80755..f48d1e6 100644
--- a/noekeon.c
+++ b/noekeon.c
@@ -32,7 +32,7 @@
#include
#endif
#include "noekeon.h"
-// #include "uart.h"
+// #include "cli.h"
#define ROUND_NR 16
@@ -172,8 +172,8 @@ void noekeon_dec(void* buffer, const void* key){
changendian(dkey);
theta((uint32_t*)nullv, (uint32_t*)dkey);
-// uart_putstr_P(PSTR("\r\nTheta: "));
-// uart_hexdump(dkey, 16);
+// cli_putstr_P(PSTR("\r\nTheta: "));
+// cli_hexdump(dkey, 16);
for(i=ROUND_NR-1; i>=0; --i){
#ifdef __AVR__
diff --git a/seed_C.c b/seed_C.c
index 4460fa5..7a9afc0 100644
--- a/seed_C.c
+++ b/seed_C.c
@@ -29,7 +29,7 @@
#include
#include
#include "seed_sbox.h"
-#include "uart.h"
+#include "cli.h"
#include "debug.h"
@@ -221,19 +221,19 @@ void seed_enc(void * buffer, const seed_ctx_t * ctx){
for(r=0; r<8; ++r){
k = getnextkeys(((seed_ctx_t*)ctx)->k, 2*r);
/*
- DEBUG_S("\r\n\tDBG ka,0: "); uart_hexdump(&k.k0, 4);
- DEBUG_S("\r\n\tDBG ka,1: "); uart_hexdump(&k.k1, 4);
- DEBUG_S("\r\n\t DBG L: "); uart_hexdump((uint8_t*)buffer+0, 8);
- DEBUG_S("\r\n\t DBG R: "); uart_hexdump((uint8_t*)buffer+8, 8);
+ DEBUG_S("\r\n\tDBG ka,0: "); cli_hexdump(&k.k0, 4);
+ DEBUG_S("\r\n\tDBG ka,1: "); cli_hexdump(&k.k1, 4);
+ DEBUG_S("\r\n\t DBG L: "); cli_hexdump((uint8_t*)buffer+0, 8);
+ DEBUG_S("\r\n\t DBG R: "); cli_hexdump((uint8_t*)buffer+8, 8);
*/
L ^= f_function(&R,k.k0,k.k1);
k = getnextkeys(((seed_ctx_t*)ctx)->k, 2*r+1);
/*
- DEBUG_S("\r\n\tDBG kb,0: "); uart_hexdump(&k.k0, 4);
- DEBUG_S("\r\n\tDBG kb,1: "); uart_hexdump(&k.k1, 4);
- DEBUG_S("\r\n\t DBG L: "); uart_hexdump((uint8_t*)buffer+8, 8);
- DEBUG_S("\r\n\t DBG R: "); uart_hexdump((uint8_t*)buffer+0, 8);
+ DEBUG_S("\r\n\tDBG kb,0: "); cli_hexdump(&k.k0, 4);
+ DEBUG_S("\r\n\tDBG kb,1: "); cli_hexdump(&k.k1, 4);
+ DEBUG_S("\r\n\t DBG L: "); cli_hexdump((uint8_t*)buffer+8, 8);
+ DEBUG_S("\r\n\t DBG R: "); cli_hexdump((uint8_t*)buffer+0, 8);
*/
R ^= f_function(&L,k.k0,k.k1);
}
@@ -254,19 +254,19 @@ void seed_dec(void * buffer, seed_ctx_t * ctx){
for(r=7; r>=0; --r){
k = getprevkeys(((seed_ctx_t*)ctx)->k, 2*r+1);
/*
- DEBUG_S("\r\n\tDBG ka,0: "); uart_hexdump(&k.k0, 4);
- DEBUG_S("\r\n\tDBG ka,1: "); uart_hexdump(&k.k1, 4);
- DEBUG_S("\r\n\t DBG L: "); uart_hexdump((uint8_t*)buffer+0, 8);
- DEBUG_S("\r\n\t DBG R: "); uart_hexdump((uint8_t*)buffer+8, 8);
+ DEBUG_S("\r\n\tDBG ka,0: "); cli_hexdump(&k.k0, 4);
+ DEBUG_S("\r\n\tDBG ka,1: "); cli_hexdump(&k.k1, 4);
+ DEBUG_S("\r\n\t DBG L: "); cli_hexdump((uint8_t*)buffer+0, 8);
+ DEBUG_S("\r\n\t DBG R: "); cli_hexdump((uint8_t*)buffer+8, 8);
*/
L ^= f_function(&R,k.k0,k.k1);
k = getprevkeys(((seed_ctx_t*)ctx)->k, 2*r+0);
/*
- DEBUG_S("\r\n\tDBG kb,0: "); uart_hexdump(&k.k0, 4);
- DEBUG_S("\r\n\tDBG kb,1: "); uart_hexdump(&k.k1, 4);
- DEBUG_S("\r\n\t DBG L: "); uart_hexdump((uint8_t*)buffer+8, 8);
- DEBUG_S("\r\n\t DBG R: "); uart_hexdump((uint8_t*)buffer+0, 8);
+ DEBUG_S("\r\n\tDBG kb,0: "); cli_hexdump(&k.k0, 4);
+ DEBUG_S("\r\n\tDBG kb,1: "); cli_hexdump(&k.k1, 4);
+ DEBUG_S("\r\n\t DBG L: "); cli_hexdump((uint8_t*)buffer+8, 8);
+ DEBUG_S("\r\n\t DBG R: "); cli_hexdump((uint8_t*)buffer+0, 8);
*/
R ^= f_function(&L,k.k0,k.k1);
}
diff --git a/sha1.c b/sha1.c
index 2f38e60..97cde32 100644
--- a/sha1.c
+++ b/sha1.c
@@ -110,7 +110,7 @@ void sha1_nextBlock (sha1_ctx_t *state, const void* block){
DEBUG_B(dbgi);
DEBUG_C(':');
#ifdef DEBUG
- uart_hexdump(&(w[dbgi]) ,4);
+ cli_hexdump(&(w[dbgi]) ,4);
#endif
}
@@ -124,12 +124,12 @@ void sha1_nextBlock (sha1_ctx_t *state, const void* block){
s = t & MASK;
if(t>=16){
#ifdef DEBUG
- DEBUG_S("\r\n ws = "); uart_hexdump(&ws, 4);
+ DEBUG_S("\r\n ws = "); cli_hexdump(&ws, 4);
#endif
w[s] = rotl32( w[(s+13)&MASK] ^ w[(s+8)&MASK] ^
w[(s+ 2)&MASK] ^ w[s] ,1);
#ifdef DEBUG
- DEBUG_S(" --> ws = "); uart_hexdump(&(w[s]), 4);
+ DEBUG_S(" --> ws = "); cli_hexdump(&(w[s]), 4);
#endif
}
@@ -143,15 +143,15 @@ void sha1_nextBlock (sha1_ctx_t *state, const void* block){
DEBUG_S("\r\nt = "); DEBUG_B(t);
DEBUG_S("; a[]: ");
#ifdef DEBUG
- uart_hexdump(a, 5*4);
+ cli_hexdump(a, 5*4);
#endif
DEBUG_S("; k = ");
#ifdef DEBUG
- uart_hexdump(&(k[t/20]), 4);
+ cli_hexdump(&(k[t/20]), 4);
#endif
DEBUG_S("; f(b,c,d) = ");
#ifdef DEBUG
- uart_hexdump(&dtemp, 4);
+ cli_hexdump(&dtemp, 4);
#endif
}
diff --git a/test_src/circularbytebuffer-asm.S b/test_src/circularbytebuffer-asm.S
new file mode 100644
index 0000000..bd0d310
--- /dev/null
+++ b/test_src/circularbytebuffer-asm.S
@@ -0,0 +1,372 @@
+/* circularbytebuffer-asm.S */
+/*
+ This file is part of the AVR-circularbytebuffer.
+ Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 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, see .
+*/
+/**
+ * \file circularbytebuffer-asm.S
+ * \email daniel.otte@rub.de
+ * \author Daniel Otte
+ * \date 2009-07-25
+ * \license GPLv3 or later
+ * \ingroup circularbytebuffer
+ * \brief declaration for circular byte buffer
+ */
+/*
+ typedef struct {
+ uint8_t buffer_size;
+ uint8_t fillcount;
+ uint8_t* buffer;
+ uint8_t* head;
+ uint8_t* tail;
+ uint8_t* top;
+} circularbytebuffer_t;
+*/
+
+#include "config.h"
+
+#define BUFFER_SIZE_OFFSET 0
+#define FILLCOUNT_OFFSET 1
+#define BUFFER_OFFSET 2
+#define HEAD_OFFSET 4
+#define TAIL_OFFSET 6
+#define TOP_OFFSET 8
+
+#ifndef CIRCULARBYTEBUFFER_NO_MALLOC
+# define CIRCULARBYTEBUFFER_NO_MALLOC 0
+#endif
+
+#ifndef CIRCULARBYTEBUFFER_NO_INIT2
+# define CIRCULARBYTEBUFFER_NO_INIT2 0
+#endif
+
+#if CIRCULARBYTEBUFFER_NO_MALLOC==0
+
+/******************************************************************************/
+/*
+ * uint8_t circularbytebuffer_init(uint8_t buffersize, circularbytebuffer_t* cb){
+ * cb->buffer_size = buffersize;
+ * cb->buffer = malloc(buffersize);
+ * cb->head = cb->tail = cb->buffer;
+ * cb->top = cb->buffer + cb->buffer_size;
+ * cb->fillcount = 0;
+ * if(cb->buffer)
+ * return 1; / * success * /
+ * return 0; / * malloc failed * /
+ * }
+ *
+ * param buffersize: r24
+ * param cb: r22:r23
+ */
+.global circularbytebuffer_init
+circularbytebuffer_init:
+ push r28
+ push r29
+ movw r28, r22
+ std Y+0, r24 /* set buffer_size */
+ std Y+1, r1 /* set fillcount to 0 */
+ clr r25
+ call malloc
+ adiw r24, 0
+ brne 10f
+ clr r24
+ rjmp 99f
+10:
+ std Y+2, r24
+ std Y+3, r25
+ std Y+4, r24
+ std Y+5, r25
+ std Y+6, r24
+ std Y+7, r25
+ ld r22, Y
+ add r24, r22
+ adc r25, r1
+ std Y+8, r24
+ std Y+9, r25
+ ldi r24, 1
+99:
+ clr r25
+ pop r29
+ pop r28
+ ret
+
+/******************************************************************************/
+/*
+ * void circularbytebuffer_free(circularbytebuffer_t* cb){
+ * free(cb->buffer);
+ * }
+ *
+ * param cb: r24:r25
+ */
+.global circularbytebuffer_free
+circularbytebuffer_free:
+ movw r30, r24
+ ldd r24, Z+BUFFER_OFFSET
+ ldd r25, Z+BUFFER_OFFSET+1
+ jmp free
+
+#endif /* CIRCULARBYTEBUFFER_NO_MALLOC==0 */
+
+#if CIRCULARBYTEBUFFER_NO_INIT2==0
+
+/******************************************************************************/
+/*
+ * void circularbytebuffer_init2(uint8_t buffersize, circularbytebuffer_t* cb, void* buffer){
+ * cb->buffer_size = buffersize;
+ * cb->buffer = buffer
+ * cb->head = cb->tail = cb->buffer;
+ * cb->top = cb->buffer + cb->buffer_size;
+ * cb->fillcount = 0;
+ * }
+ *
+ * param buffersize: r24
+ * param cb: r22:r23
+ * param buffer: r20:r21
+ */
+.global circularbytebuffer_init2
+circularbytebuffer_init2:
+ movw r30, r22
+ std Z+0, r24 /* set buffer_size */
+ std Z+1, r1 /* set fillcount to 0 */
+ std Z+2, r20
+ std Z+3, r21
+ std Z+4, r20
+ std Z+5, r21
+ std Z+6, r20
+ std Z+7, r21
+ add r20, r24
+ adc r21, r1
+ std Z+8, r20
+ std Z+9, r21
+ ret
+
+#endif /* CIRCULARBYTEBUFFER_NO_INIT2==0 */
+
+/******************************************************************************/
+/*
+ * uint8_t circularbytebuffer_cnt(circularbytebuffer_t* cb){
+ * return (cb->fillcount);
+ * }
+ *
+ * param cb: r24:r25
+ */
+.global circularbytebuffer_cnt
+circularbytebuffer_cnt:
+ movw r30, r24
+ ldd r24, Z+FILLCOUNT_OFFSET
+ clr r25
+ ret
+
+/******************************************************************************/
+/*
+ * uint16_t circularbytebuffer_get_lifo(circularbytebuffer_t* cb){
+ * uint8_t ret;
+ * if(cb->fillcount==0)
+ * return 0xffff;
+ * --cb->fillcount;
+ * ret=*(cb->tail);
+ * cb->tail = (uint8_t*)(cb->tail) + 1;
+ * if(cb->tail>=cb->top)
+ * cb->tail = (uint8_t*)(cb->tail) - cb->buffer_size;
+ * return ret;
+ * }
+ * param cb: r24:r25
+ */
+.global circularbytebuffer_get_lifo
+circularbytebuffer_get_lifo:
+ movw r30, r24
+ ldd r23, Z+FILLCOUNT_OFFSET
+ tst r23
+ brne 10f
+ ser r24
+ ser r25
+ ret
+10:
+ dec r23
+ std Z+FILLCOUNT_OFFSET, r23
+ ldd r26, Z+TAIL_OFFSET
+ ldd r27, Z+TAIL_OFFSET+1
+ ld r24, X+
+ clr r25
+ ldd r22, Z+TOP_OFFSET
+ ldd r23, Z+TOP_OFFSET+1
+ cp r26, r22
+ cpc r27, r23
+ brlo 20f
+ ldd r22, Z+BUFFER_SIZE_OFFSET
+ sub r26, r22
+ sbc r27, r1
+20:
+ std Z+TAIL_OFFSET, r26
+ std Z+TAIL_OFFSET+1, r27
+ ret
+
+/******************************************************************************/
+/*
+ * uint16_t circularbytebuffer_get_fifo(circularbytebuffer_t* cb){
+ * uint8_t ret;
+ * if(cb->fillcount==0)
+ * return 0xffff;
+ * --cb->fillcount;
+ * ret=*(cb->head);
+ * cb->head = (uint8_t*)(cb->head) - 1;
+ * if(cb->headbuffer)
+ * cb->head = (uint8_t*)(cb->head) + cb->buffer_size;
+ * return ret;
+ * }
+ *
+ * param cb: r24:r25
+ */
+.global circularbytebuffer_get_fifo
+circularbytebuffer_get_fifo:
+ movw r30, r24
+ ldd r23, Z+FILLCOUNT_OFFSET
+ tst r23
+ brne 10f
+ ser r24
+ ser r25
+ ret
+10:
+ dec r23
+ std Z+FILLCOUNT_OFFSET, r23
+ ldd r26, Z+HEAD_OFFSET
+ ldd r27, Z+HEAD_OFFSET+1
+ ld r24, X
+ clr 25
+ sbiw r26, 1
+ ldd r22, Z+BUFFER_OFFSET
+ ldd r23, Z+BUFFER_OFFSET+1
+ cp r26, r22
+ cpc r27, r23
+ brge 20f
+ ldd r22, Z+BUFFER_SIZE_OFFSET
+ add r26, r22
+ adc r27, r1
+20:
+ std Z+HEAD_OFFSET, r26
+ std Z+HEAD_OFFSET+1, r27
+ ret
+
+/******************************************************************************/
+/*
+ * uint8_t circularbytebuffer_append(uint8_t elem, circularbytebuffer_t* cb){
+ * if(cb->fillcount==cb->buffer_size)
+ * return 1;
+ * cb->fillcount++;
+ * cb->tail = cb->tail - 1;
+ * if(cb->tailbuffer)
+ * cb->tail = (uint8_t*)(cb->tail) + cb->buffer_size;
+ * if(cb->fillcount==1)
+ * cb->head = cb->tail;
+ * *(cb->tail) = elem;
+ * return 0;
+ * }
+ *
+ * param elem: r24
+ * param cb: r22:r23
+ */
+.global circularbytebuffer_append
+circularbytebuffer_append:
+ movw r30, r22
+ ldd r22, Z+FILLCOUNT_OFFSET
+ ldd r23, Z+BUFFER_SIZE_OFFSET
+ cp r22, r23
+ brne 10f
+ ldi r24, 1
+ ret
+10:
+ clt
+ tst r22
+ brne 11f
+ set
+11:
+ inc r22
+ std Z+FILLCOUNT_OFFSET, r22
+ ldd r26, Z+TAIL_OFFSET
+ ldd r27, Z+TAIL_OFFSET+1
+ sbiw r26, 1
+ ldd r22, Z+BUFFER_OFFSET
+ ldd r23, Z+BUFFER_OFFSET+1
+ cp r26, r22
+ cpc r27, r23
+ brge 20f
+ ldd r22, Z+BUFFER_SIZE_OFFSET
+ add r26, r22
+ adc r27, r1
+20:
+ std Z+TAIL_OFFSET, r26
+ std Z+TAIL_OFFSET+1, r27
+ brtc 30f
+ std Z+HEAD_OFFSET, r26
+ std Z+HEAD_OFFSET+1, r27
+30:
+ st X, r24
+ clr r24
+ ret
+
+/******************************************************************************/
+/*
+ * uint8_t circularbytebuffer_push(uint8_t elem, circularbytebuffer_t* cb){
+ * if(cb->fillcount==cb->buffer_size)
+ * return 1;
+ * cb->fillcount++;
+ * cb->head = cb->head + 1;
+ * if(cb->head>=cb->top)
+ * cb->head = (uint8_t*)(cb->head) - cb->buffer_size;
+ * if(cb->fillcount==1)
+ * cb->tail = cb->head;
+ * *(cb->head) = elem;
+ * return 0;
+ * }
+ *
+ * param elem: r24
+ * param cb: r22:r23
+ */
+.global circularbytebuffer_push
+circularbytebuffer_push:
+ movw r30, r22
+ ldd r22, Z+FILLCOUNT_OFFSET
+ ldd r23, Z+BUFFER_SIZE_OFFSET
+ cp r22, r23
+ brne 10f
+ ldi r24, 1
+ ret
+10:
+ clt
+ tst r22
+ brne 11f
+ set
+11:
+ inc r22
+ std Z+FILLCOUNT_OFFSET, r22
+ ldd r26, Z+HEAD_OFFSET
+ ldd r27, Z+HEAD_OFFSET+1
+ adiw r26, 1
+ ldd r22, Z+TOP_OFFSET
+ ldd r23, Z+TOP_OFFSET+1
+ cp r26, r22
+ cpc r27, r23
+ brlo 20f
+ ldd r22, Z+BUFFER_SIZE_OFFSET
+ sub r26, r22
+ sbc r27, r1
+20:
+ std Z+HEAD_OFFSET, r26
+ std Z+HEAD_OFFSET+1, r27
+ brtc 30b
+ std Z+TAIL_OFFSET, r26
+ std Z+TAIL_OFFSET+1, r27
+ rjmp 30b
diff --git a/test_src/circularbytebuffer.h b/test_src/circularbytebuffer.h
new file mode 100644
index 0000000..d1e40e4
--- /dev/null
+++ b/test_src/circularbytebuffer.h
@@ -0,0 +1,59 @@
+/* circularbytebuffer.h */
+/*
+ This file is part of the AVR-circularbytebuffer.
+ Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 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, see .
+*/
+/**
+ * \file circularbytebuffer.h
+ * \email daniel.otte@rub.de
+ * \author Daniel Otte
+ * \date 2009-07-24
+ * \license GPLv3 or later
+ * \ingroup circularbytebuffer
+ * \brief declaration for circular byte buffer
+ */
+
+#ifndef CIRCULARBYTEBUFFER_H_
+#define CIRCULARBYTEBUFFER_H_
+
+#include
+#include
+#include "config.h"
+
+ typedef struct {
+ uint8_t buffer_size;
+ uint8_t fillcount;
+ uint8_t* buffer;
+ uint8_t* head;
+ uint8_t* tail;
+ uint8_t* top;
+} circularbytebuffer_t;
+
+
+#if CIRCULARBYTEBUFFER_NO_MALLOC==0
+uint8_t circularbytebuffer_init(uint8_t buffersize, circularbytebuffer_t* cb);
+#endif
+#if CIRCULARBYTEBUFFER_NO_INIT2==0
+void circularbytebuffer_init2(uint8_t buffersize, circularbytebuffer_t* cb, void* buffer);
+#endif
+uint16_t circularbytebuffer_get_lifo(circularbytebuffer_t* cb);
+uint16_t circularbytebuffer_get_fifo(circularbytebuffer_t* cb);
+uint8_t circularbytebuffer_append(uint8_t, circularbytebuffer_t* cb);
+uint8_t circularbytebuffer_push(uint8_t, circularbytebuffer_t* cb);
+uint8_t circularbytebuffer_cnt(circularbytebuffer_t* cb);
+void circularbytebuffer_free(circularbytebuffer_t* cb);
+
+#endif /* CIRCULARBYTEBUFFER_H_ */
diff --git a/test_src/cli-basics.S b/test_src/cli-basics.S
new file mode 100644
index 0000000..e3cefc7
--- /dev/null
+++ b/test_src/cli-basics.S
@@ -0,0 +1,150 @@
+/* cli-basics.S */
+/*
+ This file is part of the AVR-Huffman.
+ Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 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, see .
+*/
+
+#include "avr-asm-macros.S"
+
+.extern cli_tx
+.extern cli_rx
+.extern cli_echo
+
+/******************************************************************************/
+.global cli_putc
+cli_putc:
+ lds r30, cli_tx
+ lds r31, cli_tx+1
+ adiw r30, 0
+ breq 2f
+ ijmp
+
+/******************************************************************************/
+.global cli_getc
+cli_getc:
+ lds r30, cli_rx
+ lds r31, cli_rx+1
+ adiw r30, 0
+ breq 1f
+ ijmp
+1:
+ ser r24
+ ser r25
+2:
+ ret
+
+/******************************************************************************/
+.global cli_getc_cecho
+cli_getc_cecho:
+ lds r30, cli_rx
+ lds r31, cli_rx+1
+ adiw r30, 0
+ brne 1f
+ ser r25
+ ser r24
+ ret
+1:
+ icall
+ lds r20, cli_echo
+ tst r20
+ brne 2f
+ ret
+2:
+ push r2
+ mov r2, r24
+ rcall cli_putc
+ mov r24, r2
+ clr r25
+ pop r2
+ ret
+
+/******************************************************************************/
+.global cli_putstr
+cli_putstr:
+ push r28
+ push r29
+ movw r28, r24
+1:
+ ld r24, Y+
+ clr r25
+ tst r24
+ breq 2f
+ rcall cli_putc
+ rjmp 1b
+2:
+ pop r29
+ pop r28
+ ret
+
+/******************************************************************************/
+.global cli_putstr_P
+cli_putstr_P:
+ push r28
+ push r29
+ movw r28, r24
+1:
+ movw r30, r28
+ lpm r24, Z
+ clr r25
+ tst r24
+ breq 2f
+ rcall cli_putc
+ adiw r28, 1
+ rjmp 1b
+2:
+ pop r29
+ pop r28
+ ret
+
+/******************************************************************************/
+/*
+ * param s: r24:r25
+ * param n: r22:r23
+ */
+.global cli_getsn
+cli_getsn:
+ push r28
+ push r29
+ push r16
+ push r17
+ movw r28, r24
+ ldi r20, 2
+ movw r24, r22
+ adiw r24, 0
+ breq 9f
+1:
+ movw r16, r22
+2: clr r20
+ rcall cli_getc
+ cpi r24, '\r'
+ breq 9f
+ ldi r20, 1
+ tst r24
+ breq 9f
+ st Y+, r24
+ movw r26, r16
+ sbiw r26, 1
+ movw r16, r24
+ brne 2b
+9:
+ clr r25
+ mov r24, r20
+ st Y, r1
+ pop r17
+ pop r16
+ pop r28
+ pop r29
+ ret
diff --git a/test_src/cli-core.S b/test_src/cli-core.S
new file mode 100644
index 0000000..f074b04
--- /dev/null
+++ b/test_src/cli-core.S
@@ -0,0 +1,406 @@
+/* cli-core.S */
+/*
+ This file is part of the AVR-Huffman.
+ Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 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, see .
+*/
+
+#include "avr-asm-macros.S"
+
+#define CMDLIST_ENTRY_SIZE 8
+
+/******************************************************************************/
+/* uint16_t max_cmd_length(PGM_VOID_P cmdlist){
+ uint16_t t,ret=0;
+ char* str;
+ for(;;){
+ str = (char*)pgm_read_word(cmdlist);
+ cmdlist = (uint8_t*)cmdlist + CMDLIST_ENTRY_SIZE;
+ if(str==NULL)
+ return ret;
+ t = strlen_P(str);
+ if(t>ret)
+ ret=t;
+ }
+}
+ * param cmdlist: r24:r25
+ */
+TMP_CNT_0 = 26
+TMP_CNT_1 = 27
+.global max_cmd_length
+max_cmd_length:
+ movw r30, r24
+ clr r24
+ clr r25
+1:
+ lpm r26, Z+
+ lpm r27, Z+
+ movw r20, r30
+ adiw r26, 0
+ brne 3f
+ ret
+3:
+ movw r30, r26
+ clr TMP_CNT_0
+ clr TMP_CNT_1
+4:
+ lpm r1, Z+
+ adiw TMP_CNT_0, 1
+ tst r1
+ brne 4b
+ sbiw TMP_CNT_0, 1
+ movw r30, r20
+ adiw r30, CMDLIST_ENTRY_SIZE-2
+ cp r24, TMP_CNT_0
+ cpc r25, TMP_CNT_1
+ brge 1b
+ movw r24, TMP_CNT_0
+ rjmp 1b
+
+/******************************************************************************/
+.global echo_ctrl
+echo_ctrl:
+ call strstrip
+ tst r24
+ brne 3f
+ tst r25
+ breq print_echo_status
+3:
+ call strlwr
+ movw r26, r24
+ ld r20, X+
+ tst r20
+ breq print_echo_status
+ cpi r20, '1'
+ breq exit_1
+ cpi r20, '0'
+ breq exit_0
+ cpi r20, 't'
+ breq exit_1
+ cpi r20, 'f'
+ breq exit_0
+ ld r20, X+
+ cpi r20, 'n'
+ breq exit_1
+ cpi r20, 'f'
+ breq exit_0
+ ret
+exit_1:
+ ldi r20, 1
+ rjmp exit
+exit_0:
+ ldi r20, 0
+exit:
+ sts cli_echo, r20
+ ret
+print_echo_status:
+ ldi r24, lo8(pecho)
+ ldi r25, hi8(pecho)
+ rcall cli_putstr_P
+ lds r20, cli_echo
+ tst r20
+ breq 3f
+ clr r25
+ ldi r24, 'n'
+ rcall cli_putc
+ rjmp 4f
+3: clr r25
+ ldi r24, 'f'
+ rcall cli_putc
+ clr r25
+ ldi r24, 'f'
+ rcall cli_putc
+4: clr r25
+ ldi r24, '\r'
+ rcall cli_putc
+ clr r25
+ ldi r24, '\n'
+ rcall cli_putc
+ ret
+pecho:
+.asciz "\r\necho is o"
+
+/******************************************************************************/
+/* int8_t search_and_call(char* cmd, uint16_t maxcmdlength, PGM_VOID_P cmdlist)
+ * param cmd: r24:r25
+ * param maxcmdlength: r22:r23
+ * param cmdlist: r20:r21
+ */
+LEN_0 = 14
+LEN_1 = 15
+CMD_0 = 16
+CMD_1 = 17
+
+snc_auto_help:
+ movw r24, r22
+ movw r22, r20
+ rcall cli_auto_help
+snc_return_1:
+ ldi r24, 1
+ rjmp snc_return
+snc_return_2:
+ ldi r24, 2
+snc_return:
+ clr r25
+ ret
+
+.global search_and_call
+search_and_call:
+ adiw r24, 0
+ breq snc_return_1
+1: movw r26, r24
+ ld r18, X+
+ cpi r18, 0
+ breq snc_return_1
+ cpi r18, '#'
+ breq snc_return_1
+ cpi r18, '?'
+ breq 2f
+ cpi r18, 'h'
+ brne 1f
+ ld r18, X+
+ cpi r18, 'e'
+ brne 1f
+ ld r18, X+
+ cpi r18, 'l'
+ brne 1f
+ ld r18, X+
+ cpi r18, 'p'
+ brne 1f
+ ld r18, X+
+ tst r18
+ brne 1f
+2: rjmp snc_auto_help
+1:
+ push r28
+ push r29
+ push CMD_0
+ push CMD_1
+ push LEN_0
+ push LEN_1
+ movw CMD_0, r24
+ movw r28, r20
+ rcall firstword_length
+ movw LEN_0, r24
+ movw r26, CMD_0
+ add r26, LEN_0
+ adc r27, LEN_1
+ st X, r1
+ movw r24, CMD_0
+ ldi r22, lo8(exit_str)
+ ldi r23, hi8(exit_str)
+ call strcmp_P
+ adiw r24, 0
+ breq snc_return_0
+1:
+ movw r30, r28
+ lpm r24, Z+
+ lpm r25, Z+
+ adiw r24, 0
+ brne 3f
+ ldi r24, lo8(nocommand_str)
+ ldi r25, hi8(nocommand_str)
+ rcall cli_putstr_P
+ ldi r24, 1
+ rjmp 5f
+3: movw r22, r24
+ movw r24, CMD_0
+ call strcmp_P
+ adiw r24, 0
+ breq snc_found
+ adiw r28, CMDLIST_ENTRY_SIZE
+ rjmp 1b
+snc_found:
+ movw r24, CMD_0
+ add r24, LEN_0
+ adc r25, LEN_1
+ adiw r24, 1
+ movw r30, r28
+ adiw r30, 4
+ lpm r22, Z+
+ lpm r23, Z+
+ movw r30, r22
+ adiw r30, 0
+ breq 4f ;snc_return_2
+ icall
+ ldi r24, 1
+ rjmp 5f
+4: ldi r24, 2
+snc_return_0:
+ clr r24
+5: pop LEN_1
+ pop LEN_0
+ pop CMD_1
+ pop CMD_0
+ pop r29
+ pop r28
+ rjmp snc_return
+
+exit_str:
+.asciz "exit"
+help_str:
+.asciz "help"
+nocommand_str:
+.asciz "\r\ncommand not found, try 'help'"
+
+/******************************************************************************/
+/* void cli_option_listing(char* buffer, PGM_VOID_P cmdlist)
+ * param buffer: r24:r25
+ * param cmdlist: r22:r23
+ */
+ITM_0 = 12
+ITM_1 = 13
+CMD_0 = 14
+CMD_1 = 15
+LEN_0 = 16
+LEN_1 = 17
+LST_0 = 28
+LST_1 = 29
+.global cli_option_listing
+cli_option_listing:
+ push_range 12, 17
+ push_range 28, 29
+ movw CMD_0, r24
+ movw LST_0, r22
+ call strlen
+ sbiw r24, 1
+ movw LEN_0, r24
+1:
+ movw r30, LST_0
+ lpm r24, Z+
+ lpm r25, Z+
+ movw ITM_0, r24
+ adiw r24, 0
+ breq 99f
+ movw r22, r24
+ movw r24, CMD_0
+ movw r20, LEN_0
+ adiw r28, CMDLIST_ENTRY_SIZE
+ call strncmp_P
+ adiw r24, 0
+ brne 1b
+ ldi r24, lo8(itemprefix_str)
+ ldi r25, hi8(itemprefix_str)
+ rcall cli_putstr_P
+ movw r24, ITM_0
+ rcall cli_putstr_P
+ rjmp 1b
+99:
+ ldi r24, lo8(prompt_str)
+ ldi r25, hi8(prompt_str)
+ rcall cli_putstr_P
+ movw r24, CMD_0
+ rcall cli_putstr
+ pop_range 28, 29
+ pop_range 12, 17
+ ret
+
+prompt_str:
+.asciz "\r\n>"
+itemprefix_str:
+.asciz "\r\n "
+
+/******************************************************************************/
+/* void cli_auto_help(uint16_t maxcmdlength, PGM_VOID_P cmdlist)
+ * param maxcmdlength: r24:r25
+ * param cmdlist: r22:r23
+ */
+
+TMP_0 = 14
+TMP_1 = 15
+LEN_0 = 16
+LEN_1 = 17
+LST_0 = 28
+LST_1 = 29
+cli_auto_help:
+ push_range 16, 17
+ push_range 28, 29
+ movw LEN_0, r24
+ movw r28, r22
+ ldi r24, lo8(ahelphead_str)
+ ldi r25, hi8(ahelphead_str)
+ rcall cli_putstr_P
+1:
+ movw r30, r28
+ lpm r24, Z+
+ lpm r25, Z+
+ movw r28, r30
+ adiw r24, 0
+ breq 99f
+ movw TMP_0, r24
+ rcall cli_putstr_P
+ movw r24, TMP_0
+ call strlen_P
+ movw TMP_0, LEN_0
+ sub TMP_0, r24
+ sbc TMP_1, r25
+ breq 4f
+2: ldi r24, ' '
+ clr r25
+ rcall cli_putc
+ dec TMP_0
+ brne 2b
+4: ldi r24, lo8(sep_str)
+ ldi r25, hi8(sep_str)
+ ldi r22, lo8(none_str)
+ ldi r23, hi8(none_str)
+ rcall cli_putstr_P
+ movw r30, r28
+ lpm r24, Z+
+ lpm r25, Z+
+ movw r28, r30
+ adiw r24, 0
+ breq 5f
+ ldi r22, lo8(yes_str)
+ ldi r23, hi8(yes_str)
+5: movw r24, r22
+ rcall cli_putstr_P
+ ldi r24, lo8(sep2_str)
+ ldi r25, hi8(sep2_str)
+ rcall cli_putstr_P
+ movw r30, r28
+ adiw r30, 1
+ lpm r24, Z
+ rcall cli_hexdump_byte
+ movw r30, r28
+ lpm r24, Z
+ rcall cli_hexdump_byte
+ ldi r24, '\r'
+ clr r25
+ rcall cli_putc
+ ldi r24, '\n'
+ clr r25
+ rcall cli_putc
+ adiw r28, CMDLIST_ENTRY_SIZE-4
+ rjmp 1b
+99:
+ pop_range 28, 29
+ pop_range 14, 17
+ ret
+ahelphead_str:
+.asciz "\r\n[auto help] available commands:\r\n - - \r\n"
+sep_str:
+.asciz " - "
+none_str:
+.asciz "none"
+yes_str:
+.asciz "yes "
+sep2_str:
+.asciz" \t - 0x"
+.byte 0
+
+
+
+
diff --git a/test_src/cli-hexdump.S b/test_src/cli-hexdump.S
new file mode 100644
index 0000000..0a34984
--- /dev/null
+++ b/test_src/cli-hexdump.S
@@ -0,0 +1,205 @@
+/* cli-hexdump.S */
+/*
+ This file is part of the AVR-Huffman.
+ Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 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, see .
+*/
+
+#include "avr-asm-macros.S"
+/******************************************************************************/
+/* cli_hexdump_byte
+ * param data: r24
+ */
+.global cli_hexdump_byte
+cli_hexdump_byte:
+ push r24
+ swap r24
+ andi r24, 0x0f
+ ldi r30, lo8(hexdigit_tab_P)
+ ldi r31, hi8(hexdigit_tab_P)
+ add r30, r24
+ adc r31, r1
+ clr r25
+ lpm r24, Z
+ rcall cli_putc
+ pop r24
+ andi r24, 0x0f
+ ldi r30, lo8(hexdigit_tab_P)
+ ldi r31, hi8(hexdigit_tab_P)
+ add r30, r24
+ adc r31, r1
+ clr r25
+ lpm r24, Z
+ rcall cli_putc
+ ret
+
+/******************************************************************************/
+/* cli_hexdump
+ * param data: r24:r25
+ * param length: r22:r23
+ */
+.global cli_hexdump
+cli_hexdump:
+ push r28
+ push r29
+ push r16
+ push r17
+ movw r28, r24
+ movw r16, r22
+ movw r26, r22
+ adiw r26, 0
+ breq hexdump_exit
+2:
+ ld r24, Y+
+ rcall cli_hexdump_byte
+ subi r16, 1
+ sbc r17, r1
+ brne 2b
+hexdump_exit:
+ pop r17
+ pop r16
+ pop r29
+ pop r28
+ ret
+
+/******************************************************************************/
+/* cli_hexdump_rev
+ * param data: r24:r25
+ * param length: r22:r23
+ */
+.global cli_hexdump_rev
+cli_hexdump_rev:
+ push r28
+ push r29
+ push r16
+ push r17
+ movw r28, r24
+ movw r16, r22
+ add r28, r22
+ adc r29, r23
+ movw r26, r22
+ adiw r26, 0
+1:
+ breq hexdump_exit
+ ld r24, -Y
+ rcall cli_hexdump_byte
+ subi r16, 1
+ sbci r17, 0
+ rjmp 1b
+
+/******************************************************************************/
+/* cli_hexdump2
+ * param data: r24:r25
+ * param length: r22:r23
+ */
+.global cli_hexdump2
+cli_hexdump2:
+ push r28
+ push r29
+ push r16
+ push r17
+ movw r28, r24
+ movw r16, r22
+ movw r26, r16
+ adiw r26, 0
+1:
+ breq hexdump_exit
+ ld r24, Y+
+ rcall cli_hexdump_byte
+ clr r25
+ ldi r24,' '
+ rcall cli_putc
+
+ subi r16, 1
+ sbci r17, 0
+ rjmp 1b
+
+/******************************************************************************/
+/* void cli_hexdump_block(const void* data, uint16_t length, uint8_t indent, uint8_t width)
+ * param data: r24:r25
+ * param length: r22:r23
+ * param indent: r20
+ * param width: r18
+ */
+WIDTH = 2
+INDENT = 3
+DATA_0 = 28
+DATA_1 = 29
+LENG_0 = 16
+LENG_1 = 17
+
+.global cli_hexdump_block
+cli_hexdump_block:
+ tst r22
+ brne 1f
+ tst r23
+ brne 1f
+ ret
+1:
+ push WIDTH
+ push INDENT
+ push DATA_0
+ push DATA_1
+ push LENG_0
+ push LENG_1
+ push r4
+ mov WIDTH, r18
+ mov INDENT, r20
+ movw DATA_0, r24
+ movw LENG_0, r22
+2:
+ clr r25
+ ldi r24, '\r'
+ rcall cli_putc
+ clr r25
+ ldi r24, '\n'
+ rcall cli_putc
+ mov r4, INDENT
+ tst r4
+ breq 4f
+3: clr r25
+ ldi r24, ' '
+ rcall cli_putc
+ dec r4
+ brne 3b
+4:
+ movw r24, DATA_0
+ clr r23
+ mov r22, WIDTH
+ tst LENG_1
+ brne 7f
+ cp WIDTH, LENG_0
+ breq 6f
+ brmi 7f
+ mov r22, LENG_0
+6: inc r4
+7:
+ rcall cli_hexdump2
+ add DATA_0, WIDTH
+ adc DATA_1, r1
+ sub LENG_0, WIDTH
+ sbc LENG_0, r1
+ tst r4
+ breq 2b
+ pop r4
+ pop LENG_1
+ pop LENG_0
+ pop DATA_1
+ pop DATA_0
+ pop INDENT
+ pop WIDTH
+ ret
+
+
diff --git a/test_src/cli-stub.c b/test_src/cli-stub.c
new file mode 100644
index 0000000..ec6ac1d
--- /dev/null
+++ b/test_src/cli-stub.c
@@ -0,0 +1,189 @@
+/* cli.c */
+/*
+ This file is part of the AVR-Crypto-Lib.
+ Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 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, see .
+*/
+/**
+ *
+ * author: Daniel Otte
+ * email: daniel.otte@rub.de
+ * license: GPLv3 or later
+ *
+ * components to help implementing simple command based interaction
+ *
+ **/
+
+#include
+#include
+#include
+#include
+#include
+#include "string-extras.h"
+#include "cli.h"
+#include "config.h"
+#include "hexdigit_tab.h"
+
+cli_rx_fpt cli_rx = NULL;
+cli_tx_fpt cli_tx = NULL;
+uint8_t cli_echo=1;
+
+void echo_ctrl(char* s);
+uint16_t max_cmd_length(PGM_VOID_P cmdlist);
+int8_t search_and_call(char* cmd, uint16_t maxcmdlength, PGM_VOID_P cmdlist);
+void cli_option_listing(char* buffer, PGM_VOID_P cmdlist);
+
+
+void cli_auto_help(uint16_t maxcmdlength, PGM_VOID_P cmdlist);/*
+{
+ cmdlist_entry_t item;
+ uint16_t i;
+ if(!cli_tx)
+ return;
+
+ cli_putstr_P(PSTR("\r\n[auto help] available commands:\r\n"
+ " - - \r\n"));
+ for(;;){
+ item.cmd_name = (void*)pgm_read_word(cmdlist+0);
+ item.cmd_param_str = (void*)pgm_read_word(cmdlist+2);
+ item.cmd_function = (void_fpt)pgm_read_word(cmdlist+4);
+ cmdlist = (uint8_t*)cmdlist+CMDLIST_ENTRY_SIZE;
+ if(item.cmd_name==NULL){
+ return;
+ }
+ cli_tx(' ');
+ cli_putstr_P(item.cmd_name);
+ i=maxcmdlength-strlen_P(item.cmd_name);
+ while(i--)
+ cli_tx(' ');
+ cli_putstr_P(PSTR(" - "));
+ if(item.cmd_param_str==NULL){
+ cli_putstr_P(PSTR("none \t- 0x"));
+ } else {
+ if(item.cmd_param_str==(void*)1){
+ cli_putstr_P(PSTR("yes \t- 0x"));
+ } else {
+ cli_putstr_P(item.cmd_param_str);
+ cli_putstr_P(PSTR(" \t- 0x"));
+ }
+ }
+ cli_hexdump_rev(&item.cmd_function, 2);
+ cli_putstr_P(PSTR("\r\n"));
+ }
+}
+*/
+typedef void(*str_fpt)(char*);
+#define CLI_ENTER 13
+#define CLI_BACKSPACE 8
+#define CLI_TABULATOR 9
+
+uint8_t cli_completion(char* buffer, uint16_t maxcmdlength, PGM_VOID_P cmdlist){
+ uint8_t i=0;
+ char ref[maxcmdlength+1];
+ char* itemstr;
+ ref[0]='\0';
+ /* check if we are behind the first word */
+ while(buffer[i]){
+ if(!isgraph(buffer[i++]))
+ return 0;
+ }
+ for(;;){
+ itemstr = (char*)pgm_read_word(cmdlist);
+ if(itemstr==NULL)
+ break;
+ cmdlist = (uint8_t*)cmdlist +CMDLIST_ENTRY_SIZE;
+ if(!strncmp_P(buffer, itemstr, i)){
+ if(!ref[0]){
+ strcpy_P(ref, itemstr);
+ }else{
+ ref[stridentcnt_P(ref, itemstr)]='\0';
+ }
+ }
+ }
+ i = strcmp(buffer, ref);
+ if(i)
+ strcpy(buffer, ref);
+ return ~i;
+}
+
+int8_t cmd_interface(PGM_VOID_P cmd_desc){
+ uint16_t cli_buffer_size;
+ uint16_t cli_buffer_index;
+ int8_t exit_code;
+ uint8_t completion_failed=0;
+ char* cli_buffer;
+ char c;
+ uint16_t maxcmdlength = max_cmd_length(cmd_desc);
+ cli_buffer = calloc(1,cli_buffer_size=maxcmdlength+2);
+ cli_buffer_index=0;
+ if(!cli_rx)
+ return -1;
+ if(cli_tx)
+ cli_tx('>');
+ for(;;){
+ c = cli_rx();
+ switch (c){
+ case CLI_ENTER:
+ if((exit_code=search_and_call(cli_buffer, maxcmdlength, cmd_desc))<=0){
+ free(cli_buffer);
+ return exit_code;
+ }
+ memset(cli_buffer, 0, cli_buffer_size);
+ cli_buffer_index=0;
+ cli_putstr_P(PSTR("\r\n>"));
+ completion_failed=0;
+ break;
+ case CLI_BACKSPACE:
+ completion_failed=0;
+ if(cli_buffer_index==0)
+ break;
+ cli_buffer_index--;
+ cli_buffer[cli_buffer_index] = '\0';
+ if(cli_echo && cli_tx){
+ cli_tx(c);
+ }
+ break;
+ case CLI_TABULATOR:
+ if(completion_failed || cli_buffer_index==0){
+ if(cli_tx)
+ cli_option_listing(cli_buffer, cmd_desc);
+ } else {
+ uint16_t old_idx = cli_buffer_index;
+ completion_failed =
+ ~cli_completion(cli_buffer, maxcmdlength, cmd_desc);
+ cli_buffer_index = strlen(cli_buffer);
+ if(cli_echo && cli_tx){
+ while(old_idx.
-*/
-/**
- *
- * author: Daniel Otte
- * email: daniel.otte@rub.de
- * license: GPLv3 or later
- *
- * components to help implementing simple command based interaction
- *
- **/
-
-#include
-#include
-#include
-#include
-#include
-#include "string-extras.h"
-#include "cli.h"
-#include "config.h"
-#include "hexdigit_tab.h"
-
-cli_rx_fpt cli_rx = NULL;
-cli_tx_fpt cli_tx = NULL;
-uint8_t cli_echo=1;
-
-/**
- * \brief output a character to the console
- *
- */
-
-void cli_putc(char c){
- if(cli_tx)
- cli_tx(c);
-}
-
-/**
- * \brief get a character from the console
- * Gets a character from the console input and blocks
- * until a character is recieved
- */
-uint16_t cli_getc(void){
- if(cli_rx)
- return cli_rx();
- return ((uint16_t)-1);
-}
-
-/**
- * \brief get a character from the console
- * Gets a char from the console input (like cli_getc())
- * and echos it back to the console if echo is enabled.
- */
-uint16_t cli_getc_cecho(void){
- char c;
- if(cli_rx){
- c = cli_rx();
- if(cli_tx && cli_echo)
- cli_tx(c);
- return c;
- }
- return ((uint16_t)-1);
-}
-
-/**
- * \brief ouputs a zero-terminated string from ram to the console
- */
-void cli_putstr(const char* s){
- if(!cli_tx)
- return;
- while(*s)
- cli_tx(*s++);
-}
-
-
-/**
- * \brief ouputs a zero-terminated string from flash to the console
- */
-void cli_putstr_P(PGM_P s){
- char c;
- if(!cli_tx)
- return;
- for(;;){
- c = pgm_read_byte(s++);
- if(!c)
- return;
- cli_tx(c);
- }
-}
-
-/**
- * \brief reads a line or max n characters from the console
- * Writes characters from the console into the supplyed buffer until a '\r'
- * character is recieved or until n character a read (whatever happens first).
- * The string will always be terminated by a '\0' character, so the buffer
- * should have at least a size of n+1.
- */
-uint8_t cli_getsn(char* s, uint16_t n){
- char c;
- if(n==0)
- return 2;
- while((c=cli_getc_cecho())!='\0' && c!='\r' && n--){
- *s++=c;
- }
- *s='\0';
- return (c=='\r')?0:1;
-}
-
-/**
- * \brief dumps the contents of a buffer to the console
- * Dumps length bytes from data to the console ouput. The dump
- * will have 2*n continous hexadecimal characters.
- */
-void cli_hexdump(const void* data, uint16_t length){
- if(!cli_tx)
- return;
- while(length--){
- cli_tx(pgm_read_byte(hexdigit_tab_P +((*((uint8_t*)data))>>4)));
- cli_tx(pgm_read_byte(hexdigit_tab_P +((*((uint8_t*)data))&0xf)));
- data = (uint8_t*)data +1;
- }
-}
-
-/**
- * \brief dumps the contents of a buffer to the console
- * This function behaves like cli_hexdump except that the
- * bytes are dumped in reverse order. This is usefull to dump
- * integers which ar e in little endian order.
- */
-void cli_hexdump_rev(const void* data, uint16_t length){
- if(!cli_tx)
- return;
- data = (uint8_t*)data + length -1;
- while(length--){
- cli_tx(pgm_read_byte(hexdigit_tab_P +((*((uint8_t*)data))>>4)));
- cli_tx(pgm_read_byte(hexdigit_tab_P +((*((uint8_t*)data))&0xf)));
- data = (uint8_t*)data -1;
- }
-}
-
-/**
- * \brief dumps the contents of a buffer to the console
- * Like cli_hexdump but bytes are seperated with a single space
- * on the console output.
- */
-void cli_hexdump2(const void* data, uint16_t length){
- if(!cli_tx)
- return;
- while(length--){
- cli_tx(pgm_read_byte(hexdigit_tab_P +((*((uint8_t*)data))>>4)));
- cli_tx(pgm_read_byte(hexdigit_tab_P +((*((uint8_t*)data))&0xf)));
- cli_tx(' ');
- data = (uint8_t*)data +1;
- }
-}
-
-/**
- * \brief dumps the contents of a buffer to the console
- * Like cli_hexdump but bytes are seperated with a single space
- * on the console output.
- */
-void cli_hexdump_block(const void* data, uint16_t length, uint8_t indent, uint8_t width){
- uint16_t i;
- uint8_t j;
- if(!cli_tx)
- return;
- for(i=0; i>4)));
- cli_tx(pgm_read_byte(hexdigit_tab_P +((*((uint8_t*)data))&0xf)));
- cli_tx(' ');
- data = (uint8_t*)data +1;
- }
-}
-
-static
-void cli_auto_help(uint16_t maxcmdlength, PGM_VOID_P cmdlist){
- cmdlist_entry_t item;
- uint16_t i;
- if(!cli_tx)
- return;
-
- cli_putstr_P(PSTR("\r\n[auto help] available commands:\r\n"
- " - - \r\n"));
- for(;;){
- item.cmd_name = (void*)pgm_read_word(cmdlist+0);
- item.cmd_param_str = (void*)pgm_read_word(cmdlist+2);
- item.cmd_function = (void_fpt)pgm_read_word(cmdlist+4);
- cmdlist = (uint8_t*)cmdlist+CMDLIST_ENTRY_SIZE;
- if(item.cmd_name==NULL){
- return;
- }
- cli_tx(' ');
- cli_putstr_P(item.cmd_name);
- i=maxcmdlength-strlen_P(item.cmd_name);
- while(i--)
- cli_tx(' ');
- cli_putstr_P(PSTR(" - "));
- if(item.cmd_param_str==NULL){
- cli_putstr_P(PSTR("none \t- 0x"));
- } else {
- if(item.cmd_param_str==(void*)1){
- cli_putstr_P(PSTR("yes \t- 0x"));
- } else {
- cli_putstr_P(item.cmd_param_str);
- cli_putstr_P(PSTR(" \t- 0x"));
- }
- }
- cli_hexdump_rev(&item.cmd_function, 2);
- cli_putstr_P(PSTR("\r\n"));
- }
-}
-
-void echo_ctrl(char* s){
- s = strstrip(s);
- if(s==NULL || *s=='\0'){
- cli_putstr_P(PSTR("\r\necho is "));
- cli_putstr_P(cli_echo?PSTR("on"):PSTR("off"));
- cli_putstr_P(PSTR("\r\n"));
- }
- strlwr(s);
- if(!strcmp_P(s, PSTR("true")) || !strcmp_P(s, PSTR("on")) || *s=='1'){
- cli_echo=1;
- }
- if(!strcmp_P(s, PSTR("false")) || !strcmp_P(s, PSTR("off")) || *s=='0'){
- cli_echo=0;
- }
-}
-
-typedef void(*str_fpt)(char*);
-#define CLI_ENTER 13
-#define CLI_BACKSPACE 8
-#define CLI_TABULATOR 9
-
-int8_t search_and_call(char* cmd, uint16_t maxcmdlength, PGM_VOID_P cmdlist){
- PGM_VOID_P cmdlist_orig = cmdlist;
- if(*cmd=='\0' || *cmd=='#')
- return 1;
- if(!strcmp_P(cmd, PSTR("exit")))
- return 0;
- if((!strcmp_P(cmd, PSTR("help"))) || (!strcmp_P(cmd, PSTR("?")))){
- cli_auto_help(maxcmdlength, cmdlist);
- return 1;
- }
- uint16_t fwlength=firstword_length(cmd);
- char fw[fwlength+1];
- memcpy(fw, cmd, fwlength);
- fw[fwlength] = '\0';
- cmdlist_entry_t item;
- do{
- item.cmd_name = (void*)pgm_read_word(cmdlist+0);
- item.cmd_param_str = (void*)pgm_read_word(cmdlist+2);
- item.cmd_function = (void_fpt)pgm_read_word(cmdlist+4);
- cmdlist = (uint8_t*)cmdlist+CMDLIST_ENTRY_SIZE;
- }while(item.cmd_name!=NULL && strcmp_P(fw, item.cmd_name));
- if(item.cmd_name==NULL){
- cli_auto_help(maxcmdlength, cmdlist_orig);
- } else {
- if(item.cmd_function==NULL)
- return 2;
- switch((uint16_t)item.cmd_param_str){
- case 0:
- item.cmd_function();
- break;
- case 1:
- if(cmd[fwlength]=='\0'){
- ((str_fpt)item.cmd_function)(cmd+fwlength);
- } else {
- ((str_fpt)item.cmd_function)(cmd+fwlength+1);
- }
- break;
- default:
- cli_putstr_P(PSTR("\r\nparam parsing currently not implemented!\r\n"));
- break;
- }
-
- }
- return 1;
-}
-
-uint16_t max_cmd_length(PGM_VOID_P cmdlist){
- uint16_t t,ret=0;
- char* str;
- for(;;){
- str = (char*)pgm_read_word(cmdlist);
- cmdlist = (uint8_t*)cmdlist + CMDLIST_ENTRY_SIZE;
- if(str==NULL)
- return ret;
- t = strlen_P(str);
- if(t>ret)
- ret=t;
- }
-}
-
-uint8_t cli_completion(char* buffer, uint16_t maxcmdlength, PGM_VOID_P cmdlist){
- uint8_t i=0;
- char ref[maxcmdlength+1];
- char* itemstr;
- ref[0]='\0';
- /* check if we are behind the first word */
- while(buffer[i]){
- if(!isgraph(buffer[i++]))
- return 0;
- }
- for(;;){
- itemstr = (char*)pgm_read_word(cmdlist);
- if(itemstr==NULL)
- break;
- cmdlist = (uint8_t*)cmdlist +CMDLIST_ENTRY_SIZE;
- if(!strncmp_P(buffer, itemstr, i)){
- if(!ref[0]){
- strcpy_P(ref, itemstr);
- }else{
- ref[stridentcnt_P(ref, itemstr)]='\0';
- }
- }
- }
- i = strcmp(buffer, ref);
- if(i)
- strcpy(buffer, ref);
- return ~i;
-}
-
-void cli_option_listing(char* buffer, PGM_VOID_P cmdlist){
- char* itemstr;
- uint16_t len=strlen(buffer);
- for(;;){
- itemstr = (char*)pgm_read_word(cmdlist);
- if(itemstr==NULL){
- cli_putstr_P(PSTR("\r\n>"));
- cli_putstr(buffer);
- return;
- }
- cmdlist = (uint8_t*)cmdlist +CMDLIST_ENTRY_SIZE;
- if(!strncmp_P(buffer, itemstr, len)){
- cli_putstr_P(PSTR("\r\n "));
- cli_putstr_P(itemstr);
- }
- }
-}
-
-int8_t cmd_interface(PGM_VOID_P cmd_desc){
- uint16_t cli_buffer_size;
- uint16_t cli_buffer_index;
- int8_t exit_code;
- uint8_t completion_failed=0;
- char* cli_buffer;
- char c;
- uint16_t maxcmdlength = max_cmd_length(cmd_desc);
- cli_buffer = calloc(1,cli_buffer_size=maxcmdlength+2);
- cli_buffer_index=0;
- if(!cli_rx)
- return -1;
- if(cli_tx)
- cli_tx('>');
- for(;;){
- c = cli_rx();
- switch (c){
- case CLI_ENTER:
- if((exit_code=search_and_call(cli_buffer, maxcmdlength, cmd_desc))<=0){
- free(cli_buffer);
- return exit_code;
- }
- memset(cli_buffer, 0, cli_buffer_size);
- cli_buffer_index=0;
- cli_putstr_P(PSTR("\r\n>"));
- completion_failed=0;
- break;
- case CLI_BACKSPACE:
- completion_failed=0;
- if(cli_buffer_index==0)
- break;
- cli_buffer_index--;
- cli_buffer[cli_buffer_index] = '\0';
- if(cli_echo && cli_tx){
- cli_tx(c);
- }
- break;
- case CLI_TABULATOR:
- if(completion_failed || cli_buffer_index==0){
- if(cli_tx)
- cli_option_listing(cli_buffer, cmd_desc);
- } else {
- uint16_t old_idx = cli_buffer_index;
- completion_failed =
- ~cli_completion(cli_buffer, maxcmdlength, cmd_desc);
- cli_buffer_index = strlen(cli_buffer);
- if(cli_echo && cli_tx){
- while(old_idx.
+*/
+
+#include "avr-asm-macros.S"
+#include
+#include
+#define DUMP_WIDTH 16
+
+#define ADDR_BASE 16
+/******************************************************************************/
+/* uint8_t charisinstr_P(char c, PGM_P str)
+ * param c: r24
+ * param str: r22:r23
+ */
+charisinstr_P:
+ movw r30, r22
+1:
+ lpm r22, Z+
+ tst r22
+ brne 2f
+ clr r24
+ ret
+2:
+ cp r22, r24
+ brne 1b
+ ldi r24, 1
+ ret
+
+/******************************************************************************/
+/* void dump_chars(uint8_t* buffer, uint8_t len)
+ * param buffer: r24:r25
+ * param len: r22
+ */
+dump_chars:
+ push r16
+ push r17
+ push r28
+ push r29
+ movw r28, r24
+ mov r16, r22
+ ldi r24, '|'
+ clr r25
+ call cli_putc
+ mov r17, r16
+1:
+ ld r24, Y
+ clr r25
+ call isprint
+ tst r24
+ brne 2f
+ ldi r24, '.'
+ adiw r28, 1
+ rjmp 3f
+2: ld r24, Y+
+3:
+ clr r25
+ call cli_putc
+ dec r17
+ brne 1b
+ subi r16, DUMP_WIDTH
+ tst r16
+ breq 5f
+ neg r16
+4:
+ ldi r24, ' '
+ clr r25
+ call cli_putc
+ dec r16
+ brne 4b
+5:
+ ldi r24, '|'
+ clr r25
+ call cli_putc
+ pop r29
+ pop r28
+ pop r17
+ pop r16
+ ret
+
+ /*****************************************************************************/
+ /* void print_aligned(unsigned long value, uint8_t align)
+ * param value: r22:r25
+ * param align: r20
+ */
+print_aligned:
+ push r16
+ push r28
+ push r29
+ stack_alloc 12, r28, r29
+ adiw r28, 1
+ mov r16, r20
+ movw r20, r28
+ ldi r18, ADDR_BASE
+ clr r19
+ call ultoa
+ movw r24, r28
+ call strlen
+ sub r16, r24
+ brmi 3f
+ breq 3f
+1:
+ ldi r24, ' '
+ clr r25
+ call cli_putc
+ dec r16
+ brne 1b
+3:
+ movw r24, r28
+ call cli_putstr
+ stack_free 12
+ pop r29
+ pop r28
+ pop r16
+ ret
+
+ /*****************************************************************************/
+ /* void dump(char* s)
+ * param s: r24:r25
+ */
+
+STR_0 = 4
+STR_1 = 5
+ADDR_0 = 6
+ADDR_1 = 7
+ADDR_2 = 8
+ADDR_3 = 9
+SIZE_0 = 10
+SIZE_1 = 11
+SIZE_2 = 12
+SIZE_3 = 13
+MEM_0 = 14
+MEM_1 = 15
+xREADLEN = 16
+TMP = 17
+
+.global dump
+dump:
+ call strstrip
+ push_range 4, 17
+ push_range 28, 29
+ movw r26, r24
+ ld TMP, X
+ movw STR_0, r26
+ ldi r30, lo8(memtype_desc)
+ ldi r31, hi8(memtype_desc)
+1:
+ lpm r22, Z+
+ lpm r23, Z+
+ tst r22
+ brne 2f
+ tst r23
+ breq 5f
+2:
+ movw r28, r30
+ mov r24, TMP
+ clr r25
+ rcall charisinstr_P
+ movw r30, r28
+ tst r24
+ brne 6f
+ adiw r30, 4
+ rjmp 1b
+5:
+ ldi r30, lo8(memtype_desc+2)
+ ldi r31, hi8(memtype_desc+2)
+6:
+ movw MEM_0, r30
+ movw r26, STR_0
+61:
+ ld r20, X+
+ ori r20, 'A'^'a'
+ cpi r20, 'a'
+ brmi 7f
+ cpi r20, 'z'+1
+ brge 7f
+ rjmp 61b
+7:
+ sbiw r26, 1
+ stack_alloc 2+DUMP_WIDTH, r28, r29
+ adiw r28, 1
+ movw r24, r26
+ movw r22, r28
+ clr r20
+ clr r21
+ call strtoul
+ movw ADDR_0, r22
+ movw ADDR_2, r24
+ ld r24, Y+
+ ld r25, Y+
+ clr r23
+ clr r22
+ clr r21
+ clr r20
+ call strtoul
+ movw SIZE_0, r22
+ movw SIZE_2, r24
+ tst SIZE_0
+ brne 72f
+ tst SIZE_1
+ brne 72f
+ tst SIZE_2
+ brne 72f
+ tst SIZE_3
+ brne 72f
+ ldi TMP, 128
+ mov SIZE_0, TMP
+72:
+ ldi r24, lo8(dumping)
+ ldi r25, hi8(dumping)
+ call cli_putstr_P
+ movw r24, SIZE_2
+ movw r22, SIZE_0
+ movw r20, r28
+ clr r19
+ ldi r18, 10
+ call ultoa
+ movw r24, r28
+ call cli_putstr
+ ldi r24, lo8(bytesof)
+ ldi r25, hi8(bytesof)
+ call cli_putstr_P
+ movw r30, MEM_0
+ lpm r24, Z+
+ lpm r25, Z+
+ call cli_putstr_P
+ ldi r24, lo8(beginning)
+ ldi r25, hi8(beginning)
+ call cli_putstr_P
+ movw r24, ADDR_2
+ movw r22, ADDR_0
+ movw r20, r28
+ clr r19
+ ldi r18, 16
+ call ultoa
+ movw r24, r28
+ call cli_putstr
+ ldi r24, lo8(suffix)
+ ldi r25, hi8(suffix)
+ call cli_putstr_P
+
+ movw r30, MEM_0
+ adiw r30, 2
+ lpm MEM_0, Z+
+ lpm MEM_1, Z
+
+1:
+ ldi xREADLEN, DUMP_WIDTH
+ tst SIZE_3
+ brne 3f
+ tst SIZE_2
+ brne 3f
+ tst SIZE_1
+ brne 3f
+ tst SIZE_0
+ brne 2f
+ rjmp 90f
+2:
+ cp DUMP_WIDTH, SIZE_0
+ brmi 3f
+ mov xREADLEN, SIZE_0
+3:
+ movw r24, r28
+ movw r22, ADDR_2
+ movw r20, ADDR_0
+ clr r19
+ mov r18, xREADLEN
+ movw r30, MEM_0
+ icall
+ movw r24, ADDR_2
+ movw r22, ADDR_0
+ clr r21
+ ldi r20, 6
+ rcall print_aligned
+ clr r25
+ ldi r24, ':'
+ call cli_putc
+ clr r25
+ ldi r24, ' '
+ call cli_putc
+ movw r24, r28
+ clr r23
+ mov r22, xREADLEN
+ call cli_hexdump2
+ ldi TMP, DUMP_WIDTH
+ sub TMP, xREADLEN
+ tst TMP
+ breq 5f
+4:
+ clr r25
+ ldi r24, ' '
+ call cli_putc
+ clr r25
+ ldi r24, ' '
+ call cli_putc
+ clr r25
+ ldi r24, ' '
+ call cli_putc
+ dec TMP
+ brne 4b
+5:
+ clr r25
+ ldi r24, '\t'
+ call cli_putc
+ movw r24, r28
+ clr r23
+ mov r22, xREADLEN
+ rcall dump_chars
+ add ADDR_0, xREADLEN
+ adc ADDR_1, r1
+ adc ADDR_2, r1
+ adc ADDR_3, r1
+ sub SIZE_0, xREADLEN
+ sbc SIZE_1, r1
+ sbc SIZE_2, r1
+ sbc SIZE_3, r1
+ clr r25
+ ldi r24, '\r'
+ call cli_putc
+ clr r25
+ ldi r24, '\n'
+ call cli_putc
+ rjmp 1b
+90:
+ stack_free 2+DUMP_WIDTH
+
+ pop_range 28,29
+ pop_range 4, 17
+ ret
+
+dumping:
+.asciz "\r\ndumping "
+bytesof:
+.asciz " bytes of "
+beginning:
+.asciz ", beginnig at 0x"
+suffix:
+.asciz ":\r\n"
+.byte 0
+
+/******************************************************************************/
+/* void pgm_read_block(void* buffer, uint32_t addr, uint8_t length)
+ * param buffer: r24:r25
+ * param addr: r20:r23
+ * param length: r18
+ */
+.global pgm_read_block
+pgm_read_block:
+#if RAMEND<0x10000
+ movw r26, r24
+ movw r30, r20
+ tst r18
+ breq 3f
+1:
+ lpm r20, Z+
+ st X+, r20
+ dec r18
+ brne 1b
+3:
+ ret
+#else
+ movw r26, r24
+ movw r30, r20
+ out RAMPZ, r22
+ tst r18
+ breq 3f
+1:
+ elpm r20, Z+
+ st X+, r20
+ dec r18
+ brne 1b
+3:
+ ret
+
+#endif
+
+/******************************************************************************/
+/* void ram_read_block(void* buffer, uint32_t addr, uint8_t length)
+ * param buffer: r24:r25
+ * param addr: r20:r23
+ * param length: r18
+ */
+.global ram_read_block
+ram_read_block:
+ movw r26, r24
+ movw r30, r20
+ tst r18
+ breq 3f
+1:
+ ld r20, Z+
+ st X+, r20
+ dec r18
+ brne 1b
+3:
+ ret
+
+/******************************************************************************/
+/* void ee_read_block(void* buffer, uint32_t addr, uint8_t length)
+ * param buffer: r24:r25
+ * param addr: r20:r23
+ * param length: r18
+ */
+.global ee_read_block
+ee_read_block:
+ movw r26, r24
+ movw r30, r20
+ tst r18
+ breq 3f
+1:
+ sbic _SFR_IO_ADDR(EECR), EEPE
+ rjmp 1b
+ out _SFR_IO_ADDR(EEARH), r31
+ out _SFR_IO_ADDR(EEARL), r30
+ sbi _SFR_IO_ADDR(EECR), EERE
+ adiw r30, 1
+ in r20, _SFR_IO_ADDR(EEDR)
+ st X+, r20
+ dec r18
+ brne 1b
+3:
+ ret
diff --git a/test_src/dump-decl.c b/test_src/dump-decl.c
new file mode 100644
index 0000000..0053df8
--- /dev/null
+++ b/test_src/dump-decl.c
@@ -0,0 +1,64 @@
+/* dump.c */
+/*
+ This file is part of the AVR-Crypto-Lib.
+ Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 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, see .
+*/
+/**
+ * \file dump.c
+ * \email daniel.otte@rub.de
+ * \author Daniel Otte
+ * \date 2009-02-04
+ * \license GPLv3 or later
+ *
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include "cli.h"
+#include "string-extras.h"
+
+#define DUMP_WIDTH 16
+
+void pgm_read_block(void* buffer, uint32_t addr, uint8_t length);
+void ee_read_block(void* buffer, uint32_t addr, uint8_t length);
+void ram_read_block(void* buffer, uint32_t addr, uint8_t length);
+
+const char flash_trigger[] PROGMEM = "fF";
+const char ram_trigger[] PROGMEM = "sSrRmM";
+const char eeprom_trigger[] PROGMEM = "eE";
+
+const char flash_desc[] PROGMEM = "flash";
+const char ram_desc[] PROGMEM = "ram";
+const char eeprom_desc[] PROGMEM = "eeprom";
+
+typedef struct {
+ PGM_P trigger;
+ PGM_P desc;
+ void (*fpt)(void*, uint32_t, uint8_t);
+} memtype_desc_t;
+
+memtype_desc_t memtype_desc[] PROGMEM = {
+ { flash_trigger, flash_desc, pgm_read_block },
+ { eeprom_trigger, eeprom_desc, ee_read_block },
+ { ram_trigger, ram_desc , ram_read_block },
+ { NULL, NULL, NULL }
+};
+
+void dump(char* s);
diff --git a/test_src/dump.c b/test_src/dump.c
deleted file mode 100644
index 04b35cb..0000000
--- a/test_src/dump.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/* dump.c */
-/*
- This file is part of the AVR-Crypto-Lib.
- Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 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, see .
-*/
-/**
- * \file dump.c
- * \email daniel.otte@rub.de
- * \author Daniel Otte
- * \date 2009-02-04
- * \license GPLv3 or later
- *
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include "cli.h"
-#include "string-extras.h"
-
-#define DUMP_WIDTH 16
-
-static
-void dump_chars(uint8_t* buffer){
- uint8_t i;
- cli_putc('|');
- for(i=0; i=DUMP_WIDTH){
- if(flash){
- for(i=0; i
@@ -79,8 +79,8 @@ int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-aes-test.c b/test_src/main-aes-test.c
index c505753..8d2aba6 100644
--- a/test_src/main-aes-test.c
+++ b/test_src/main-aes-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "aes.h"
@@ -319,8 +319,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-aes128-test.c b/test_src/main-aes128-test.c
index aa23163..e9b3ce4 100644
--- a/test_src/main-aes128-test.c
+++ b/test_src/main-aes128-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "aes.h"
@@ -170,8 +170,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-aes192-test.c b/test_src/main-aes192-test.c
index 2dc0f0e..577d057 100644
--- a/test_src/main-aes192-test.c
+++ b/test_src/main-aes192-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "aes.h"
@@ -149,8 +149,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-aes256-test.c b/test_src/main-aes256-test.c
index d800b7f..6b9f0b5 100644
--- a/test_src/main-aes256-test.c
+++ b/test_src/main-aes256-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "aes.h"
@@ -151,8 +151,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-arcfour-test.c b/test_src/main-arcfour-test.c
index f80fd96..7e54892 100644
--- a/test_src/main-arcfour-test.c
+++ b/test_src/main-arcfour-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include
@@ -107,8 +107,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-base64-test.c b/test_src/main-base64-test.c
index ece676c..a4ce3f3 100644
--- a/test_src/main-base64-test.c
+++ b/test_src/main-base64-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "noekeon.h"
@@ -154,8 +154,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-blake-test.c b/test_src/main-blake-test.c
index 316d1a0..379ba2b 100644
--- a/test_src/main-blake-test.c
+++ b/test_src/main-blake-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "blake_small.h"
@@ -132,8 +132,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
shavs_algolist=(hfdesc_t**)algolist;
shavs_algo=(hfdesc_t*)&blake32_desc;
for(;;){
diff --git a/test_src/main-bmw-test.c b/test_src/main-bmw-test.c
index 22a370d..c76dc06 100644
--- a/test_src/main-bmw-test.c
+++ b/test_src/main-bmw-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "bmw_small.h"
@@ -134,8 +134,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
shavs_algolist=(hfdesc_t**)algolist;
shavs_algo=(hfdesc_t*)&bmw256_desc;
for(;;){
diff --git a/test_src/main-camellia-test.c b/test_src/main-camellia-test.c
index c54765a..2401557 100644
--- a/test_src/main-camellia-test.c
+++ b/test_src/main-camellia-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "camellia.h"
@@ -158,8 +158,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-cast5-test.c b/test_src/main-cast5-test.c
index 4d2530c..fe5915c 100644
--- a/test_src/main-cast5-test.c
+++ b/test_src/main-cast5-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include
@@ -209,8 +209,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-cast6-test.c b/test_src/main-cast6-test.c
index a259974..d13a100 100644
--- a/test_src/main-cast6-test.c
+++ b/test_src/main-cast6-test.c
@@ -5,7 +5,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "cast6.h"
@@ -156,8 +156,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-des-test.c b/test_src/main-des-test.c
index 26a6415..5ccf7b6 100644
--- a/test_src/main-des-test.c
+++ b/test_src/main-des-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "des.h"
@@ -113,8 +113,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-entropium-test.c b/test_src/main-entropium-test.c
index 95f3fc1..50ad2b1 100644
--- a/test_src/main-entropium-test.c
+++ b/test_src/main-entropium-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "entropium.h"
@@ -45,7 +45,7 @@ void testrun_entropium(void){
char c, str[16];
uint8_t data[32];
uint32_t i=0;
- while(!uart_getc_nb(&c)){
+ while('q'!=cli_getc()){
entropium_getRandomBlock(data);
cli_putstr_P(PSTR("\r\n "));
ultoa(i, str, 10);
@@ -106,8 +106,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
diff --git a/test_src/main-grain-test.c b/test_src/main-grain-test.c
index 04f0333..d1de7ea 100644
--- a/test_src/main-grain-test.c
+++ b/test_src/main-grain-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "cli.h"
@@ -169,8 +169,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-groestl-test.c b/test_src/main-groestl-test.c
index 30d4bbe..545f4eb 100644
--- a/test_src/main-groestl-test.c
+++ b/test_src/main-groestl-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "groestl_small.h"
@@ -134,8 +134,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
shavs_algolist=(hfdesc_t**)algolist;
shavs_algo=(hfdesc_t*)&groestl256_desc;
for(;;){
diff --git a/test_src/main-hmac-md5-test.c b/test_src/main-hmac-md5-test.c
index a2b2a22..dfbcead 100644
--- a/test_src/main-hmac-md5-test.c
+++ b/test_src/main-hmac-md5-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "md5.h"
@@ -181,8 +181,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-hmac-sha1-test.c b/test_src/main-hmac-sha1-test.c
index 865300f..33c0600 100644
--- a/test_src/main-hmac-sha1-test.c
+++ b/test_src/main-hmac-sha1-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "sha1.h"
@@ -76,8 +76,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-hmac-sha256-test.c b/test_src/main-hmac-sha256-test.c
index 553cc50..0cc773a 100644
--- a/test_src/main-hmac-sha256-test.c
+++ b/test_src/main-hmac-sha256-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "sha256.h"
@@ -94,8 +94,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-md5-test.c b/test_src/main-md5-test.c
index 7cd6049..7f76748 100644
--- a/test_src/main-md5-test.c
+++ b/test_src/main-md5-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "md5.h"
@@ -142,8 +142,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-mickey128-test.c b/test_src/main-mickey128-test.c
index 5547ccf..cd83212 100644
--- a/test_src/main-mickey128-test.c
+++ b/test_src/main-mickey128-test.c
@@ -5,7 +5,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "cli.h"
@@ -137,8 +137,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-mugi-test.c b/test_src/main-mugi-test.c
index f493401..d8f3898 100644
--- a/test_src/main-mugi-test.c
+++ b/test_src/main-mugi-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "mugi.h"
@@ -129,8 +129,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-noekeon-test.c b/test_src/main-noekeon-test.c
index acd501d..a08f38f 100644
--- a/test_src/main-noekeon-test.c
+++ b/test_src/main-noekeon-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include
@@ -231,8 +231,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-omac-noekeon-test.c b/test_src/main-omac-noekeon-test.c
index 50a40c0..3df0d2e 100644
--- a/test_src/main-omac-noekeon-test.c
+++ b/test_src/main-omac-noekeon-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "noekeon.h"
@@ -168,8 +168,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-present-test.c b/test_src/main-present-test.c
index b2371b8..1ae9ad6 100644
--- a/test_src/main-present-test.c
+++ b/test_src/main-present-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include
@@ -143,8 +143,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-rc5-test.c b/test_src/main-rc5-test.c
index fa656b8..e154020 100644
--- a/test_src/main-rc5-test.c
+++ b/test_src/main-rc5-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "rc5.h"
@@ -121,8 +121,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-rc6-test.c b/test_src/main-rc6-test.c
index aa1d897..57f249a 100644
--- a/test_src/main-rc6-test.c
+++ b/test_src/main-rc6-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "rc6.h"
@@ -128,8 +128,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-seed-test.c b/test_src/main-seed-test.c
index 768e8d9..cd2a5e8 100644
--- a/test_src/main-seed-test.c
+++ b/test_src/main-seed-test.c
@@ -28,7 +28,7 @@
*/
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "seed.h"
@@ -179,8 +179,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-serpent-test.c b/test_src/main-serpent-test.c
index b7fc4e5..142e993 100644
--- a/test_src/main-serpent-test.c
+++ b/test_src/main-serpent-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "serpent.h"
@@ -133,8 +133,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-sha1-test.c b/test_src/main-sha1-test.c
index 77104b9..311bb05 100644
--- a/test_src/main-sha1-test.c
+++ b/test_src/main-sha1-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "sha1.h"
@@ -159,8 +159,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
shavs_algolist=(hfdesc_t**)algolist;
shavs_algo=(hfdesc_t*)&sha1_desc;
for(;;){
diff --git a/test_src/main-sha256-test.c b/test_src/main-sha256-test.c
index 80c864e..61ee231 100644
--- a/test_src/main-sha256-test.c
+++ b/test_src/main-sha256-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "sha256.h"
@@ -87,8 +87,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
shavs_algolist=(hfdesc_t**)algolist;
shavs_algo=(hfdesc_t*)&sha256_desc;
for(;;){
diff --git a/test_src/main-shabal-test.c b/test_src/main-shabal-test.c
index 93a1900..b08d800 100644
--- a/test_src/main-shabal-test.c
+++ b/test_src/main-shabal-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "shabal.h"
@@ -218,8 +218,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
shavs_algolist=(hfdesc_t**)algolist;
shavs_algo=(hfdesc_t*)&shabal256_desc;
for(;;){
diff --git a/test_src/main-shabea-test.c b/test_src/main-shabea-test.c
index c577b6b..5a6c5fa 100644
--- a/test_src/main-shabea-test.c
+++ b/test_src/main-shabea-test.c
@@ -27,7 +27,7 @@
*/
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "shabea.h"
@@ -182,8 +182,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-shacal1_enc-test.c b/test_src/main-shacal1_enc-test.c
index a4ff3c6..96aad56 100644
--- a/test_src/main-shacal1_enc-test.c
+++ b/test_src/main-shacal1_enc-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "shacal1_enc.h"
@@ -99,8 +99,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-shacal2_enc-test.c b/test_src/main-shacal2_enc-test.c
index 4e88063..6a8a4ea 100644
--- a/test_src/main-shacal2_enc-test.c
+++ b/test_src/main-shacal2_enc-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "shacal2_enc.h"
@@ -99,8 +99,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-skein-test.c b/test_src/main-skein-test.c
index 0a44e34..b1e8464 100644
--- a/test_src/main-skein-test.c
+++ b/test_src/main-skein-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "skein.h"
@@ -243,8 +243,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
shavs_algolist=(hfdesc_t**)algolist;
shavs_algo=(hfdesc_t*)&skein256_256_desc;
for(;;){
diff --git a/test_src/main-skipjack-test.c b/test_src/main-skipjack-test.c
index fd686b6..2e31179 100644
--- a/test_src/main-skipjack-test.c
+++ b/test_src/main-skipjack-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "skipjack.h"
@@ -153,8 +153,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-tdes-test.c b/test_src/main-tdes-test.c
index a0107d5..dd025d0 100644
--- a/test_src/main-tdes-test.c
+++ b/test_src/main-tdes-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "des.h"
@@ -113,8 +113,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-threefish-test.c b/test_src/main-threefish-test.c
index 7d05eb8..f0af2b5 100644
--- a/test_src/main-threefish-test.c
+++ b/test_src/main-threefish-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "threefish.h"
@@ -433,8 +433,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-trivium-test.c b/test_src/main-trivium-test.c
index 6924c4f..cbc3c7c 100644
--- a/test_src/main-trivium-test.c
+++ b/test_src/main-trivium-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "cli.h"
@@ -115,8 +115,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-twister-test.c b/test_src/main-twister-test.c
index 505bbaf..0f6fc49 100644
--- a/test_src/main-twister-test.c
+++ b/test_src/main-twister-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "twister-small.h"
@@ -141,8 +141,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
shavs_algolist=(hfdesc_t**)algolist;
shavs_algo=(hfdesc_t*)&twister256_desc;
for(;;){
diff --git a/test_src/main-ubi-test.c b/test_src/main-ubi-test.c
index 140362d..b9ae810 100644
--- a/test_src/main-ubi-test.c
+++ b/test_src/main-ubi-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "ubi.h"
@@ -196,8 +196,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/main-xtea-test.c b/test_src/main-xtea-test.c
index f450a9f..bc13d95 100644
--- a/test_src/main-xtea-test.c
+++ b/test_src/main-xtea-test.c
@@ -23,7 +23,7 @@
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "xtea.h"
@@ -103,8 +103,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
int main (void){
DEBUG_INIT();
- cli_rx = uart_getc;
- cli_tx = uart_putc;
+ cli_rx = (cli_rx_fpt)uart0_getc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
diff --git a/test_src/nessie_bc_test.c b/test_src/nessie_bc_test.c
index 3f05a55..6d55c57 100644
--- a/test_src/nessie_bc_test.c
+++ b/test_src/nessie_bc_test.c
@@ -29,7 +29,6 @@
#include
#include "nessie_bc_test.h"
#include "nessie_common.h"
-#include "uart.h"
nessie_bc_ctx_t nessie_bc_ctx;
diff --git a/test_src/nessie_mac_test.c b/test_src/nessie_mac_test.c
index d95c911..80093a0 100644
--- a/test_src/nessie_mac_test.c
+++ b/test_src/nessie_mac_test.c
@@ -32,7 +32,6 @@
#include "nessie_mac_test.h"
#include "nessie_common.h"
#include "dbz_strings.h"
-#include "uart.h"
nessie_mac_ctx_t nessie_mac_ctx;
diff --git a/test_src/nessie_stream_test.c b/test_src/nessie_stream_test.c
index cc4ac1f..751669b 100644
--- a/test_src/nessie_stream_test.c
+++ b/test_src/nessie_stream_test.c
@@ -29,7 +29,6 @@
#include
#include "nessie_stream_test.h"
#include "nessie_common.h"
-#include "uart.h"
nessie_stream_ctx_t nessie_stream_ctx;
diff --git a/test_src/performance_test.c b/test_src/performance_test.c
index e371a5f..ad745fc 100644
--- a/test_src/performance_test.c
+++ b/test_src/performance_test.c
@@ -31,7 +31,7 @@
#include
#include
#include
-#include "uart.h"
+#include "cli.h"
#include "performance_test.h"
@@ -89,24 +89,24 @@ void getOverhead(uint16_t* constoh, uint16_t* intoh){
void print_time_P(PGM_P s, uint64_t t){
char sv[16];
uint8_t c;
- uart_putstr_P(PSTR("\r\n"));
- uart_putstr_P(s);
+ cli_putstr_P(PSTR("\r\n"));
+ cli_putstr_P(s);
ultoa((unsigned long)t, sv, 10);
for(c=strlen(sv); c<11; ++c){
- uart_putc(' ');
+ cli_putc(' ');
}
- uart_putstr(sv);
+ cli_putstr(sv);
}
void print_overhead(void){
char str[16];
- uart_putstr_P(PSTR("\r\n\r\n=== benchmark ==="));
+ cli_putstr_P(PSTR("\r\n\r\n=== benchmark ==="));
utoa(const_overhead, str, 10);
- uart_putstr_P(PSTR("\r\n\tconst overhead: "));
- uart_putstr(str);
+ cli_putstr_P(PSTR("\r\n\tconst overhead: "));
+ cli_putstr(str);
utoa(int_overhead, str, 10);
- uart_putstr_P(PSTR("\r\n\tinterrupt overhead: "));
- uart_putstr(str);
+ cli_putstr_P(PSTR("\r\n\tinterrupt overhead: "));
+ cli_putstr(str);
}
diff --git a/test_src/serial-tools.c b/test_src/serial-tools.c
index 7bfd25d..6fb36bc 100644
--- a/test_src/serial-tools.c
+++ b/test_src/serial-tools.c
@@ -26,18 +26,18 @@
*/
#include "config.h"
-#include "uart.h"
+#include "uart_i.h"
#include
#include
int getnextwordn(char *s, int n){ /* words are seperated by spaces, lf or cr */
char c = ' ';
do{
- c=uart_getc();
+ c=uart0_getc();
}while(c==' ' || c=='\r' || c=='\n');
*s++ = c;
do{
- *s++ = c = uart_getc();
+ *s++ = c = uart0_getc();
}while(c!=' ' && c!='\r' && c!='\n' && --n);
*(s-1) = '\0';
return n;
@@ -50,7 +50,7 @@ void readhex2buffer(void* buffer, int n){
// DEBUG_S("\r\nDBG: n="); DEBUG_B(n&0xff); DEBUG_S("\r\n");
for(i=0; i=c){
((uint8_t*)buffer)[i] = c - '0';
} else {
@@ -64,7 +64,7 @@ void readhex2buffer(void* buffer, int n){
((uint8_t*)buffer)[i] <<= 4;
- c = uart_getc();
+ c = uart0_getc();
if ('0'<= c && '9'>=c){
((uint8_t*)buffer)[i] |= c - '0';
} else {
@@ -78,7 +78,7 @@ void readhex2buffer(void* buffer, int n){
} /* for i=0 .. n */
}
-void uart_putptr(void* p){
- uart_hexdump((void*) &p,2);
+void uart0_putptr(void* p){
+ uart0_hexdump((void*) &p,2);
}
diff --git a/test_src/string-extras-asm.S b/test_src/string-extras-asm.S
new file mode 100644
index 0000000..c40e442
--- /dev/null
+++ b/test_src/string-extras-asm.S
@@ -0,0 +1,138 @@
+/* string-extras-asm.S */
+/*
+ This file is part of the AVR-Huffman.
+ Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 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, see .
+*/
+
+#include "avr-asm-macros.S"
+
+/******************************************************************************/
+/*
+ uint16_t stridentcnt_P(char* a, PGM_P b){
+ uint16_t i=0;
+ char c;
+ for(;;){
+ c = pgm_read_byte(b++);
+ if(*a != c || c=='\0')
+ return i;
+ i++;
+ a++;
+ }
+ }
+
+ param a: r24:r25
+ param b: r22:r23
+*/
+.global stridentcnt_P
+stridentcnt_P:
+ movw r30, r22
+ movw r26, r24
+ clr r24
+ clr r25
+1:
+ ld r22, X+
+ lpm r23, Z+
+ cpse r22, r23
+ ret
+ cpse r22, r1
+ ret
+ adiw r24, 1
+ rjmp 1b
+
+
+/******************************************************************************/
+/*
+ uint16_t firstword_length(char* s){
+ uint16_t ret=0;
+ while(isgraph(*s++))
+ ret++;
+ return ret;
+ }
+
+ param s: r24:r25
+*/
+.global firstword_length
+firstword_length:
+ push r28
+ push r29
+ push r2
+ push r3
+ movw r2, r24
+ movw r28, r24
+1:
+ clr r25
+ ld r24, Y+
+ call isgraph
+ adiw r24, 0
+ brne 1b
+ movw r24, r28
+ sbiw r24, 1
+ sub r24, r2
+ sbc r25, r3
+ pop r3
+ pop r2
+ pop r29
+ pop r28
+ ret
+
+
+/******************************************************************************/
+/*
+ char* strstrip(char* str){
+ if(!str)
+ return str;
+ char* endptr;
+ while(*str && (*str==' ' || *str=='\t'))
+ ++str;
+ endptr=str;
+ while(*endptr)
+ ++endptr;
+ do{
+ --endptr;
+ }while(*endptr==' ' || *endptr=='\t');
+ endptr[1]='\0';
+ return str;
+ }
+
+ param str: r24:r25
+*/
+.global strstrip
+strstrip:
+ movw r26, r24
+ adiw r26, 0
+ breq 9f
+1:
+ ld r22, X+
+ cpi r22, ' '
+ breq 1b
+ cpi r22, '\t'
+ breq 1b
+ sbiw r26, 1
+ movw r30, r26
+2:
+ ld r22, Z+
+ tst r22
+ brne 2b
+3:
+ ld r22, -Z
+ cpi r22, ' '
+ breq 3b
+ cpi r22, '\t'
+ breq 3b
+ st Z, r1
+ movw r24, r26
+9:
+ ret
diff --git a/test_src/string-extras.h b/test_src/string-extras.h
new file mode 100644
index 0000000..bf2cbf7
--- /dev/null
+++ b/test_src/string-extras.h
@@ -0,0 +1,55 @@
+/* string-extras.h */
+/*
+ This file is part of the AVR-Crypto-Lib.
+ Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 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, see .
+*/
+/**
+ * \file string-extras.h
+ * \author Daniel Otte
+ * \date 2006-05-16
+ * \license GPLv3 or later
+ *
+ */
+
+/** \fn stridentcnt_P(char* a, PGM_P b)
+ * \brief counts the number of identic chars
+ *
+ * This function compares the supplyed strings and returns the index of the
+ * first char where the strings differ.
+ * \param a pointer to string in RAM
+ * \param b pointer to string in Flash
+ * \return index of the first char where \c a and \c b differ
+ */
+uint16_t stridentcnt_P(char* a, PGM_P b);
+
+/** \fn firstword_length(char* s)
+ * \brief compute the length of the first word in supllyed string
+ *
+ * This function searches for the first whitespace in the string and returns the
+ * number of chars before the first whitespace.
+ * \param s string
+ * \return number of chars in first word
+ */
+uint16_t firstword_length(char* s);
+
+/** \fn strstrip(char* str)
+ * \brief removes whitespace at the beginning and the end of a string
+ *
+ * This function removes whitespaces at the end of a string.
+ * \param str sting
+ * \return pointer to the first non-whitespace char in string
+ */
+char* strstrip(char* str);
diff --git a/test_src/uart.c b/test_src/uart.c
deleted file mode 100644
index 56b22dd..0000000
--- a/test_src/uart.c
+++ /dev/null
@@ -1,349 +0,0 @@
-/* uart.c */
-/*
- This file is part of the AVR-Crypto-Lib.
- Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 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, see .
-*/
-/* USART-Init beim ATmegaXX */
-
-#include "config.h"
-
-#include
-#include
-#include
-#include "hexdigit_tab.h"
-#include "uart.h"
-
-#ifdef ATMEGA128
-#define UCSRB UCSR0B
-#define UCSRC UCSR0C
-#define UDR UDR0
-#define UBRRH UBRR0H
-#define UBRRL UBRR0L
-#define URSEL UMSEL
-#define USART_UDRE_vect USART0_UDRE_vect
-#define USART_RXC_vect USART0_RX_vect
-#define UCSRA UCSR0A
-#endif
-
-#ifdef ATMEGA644
-#define UCSRB UCSR0B
-#define UCSRC UCSR0C
-#define UDR UDR0
-#define UBRRH UBRR0H
-#define UBRRL UBRR0L
-#define URSEL UMSEL00
-#define USART_UDRE_vect USART0_UDRE_vect
-#define USART_RXC_vect USART0_RX_vect
-#define UDRIE UDRIE0
-#define TXEN TXEN0
-#define UMSEL UMSEL0
-#define RXEN RXEN0
-#define RXCIE RXCIE0
-#define UCSZ0 UCSZ00
-#define UCSRA UCSR0A
-#define UDRE UDRE0
-#define RXC RXC0
-#endif
-
-#ifdef AT90USB162
-#define UCSRB UCSR1B
-#define UCSRC UCSR1C
-#define UDR UDR1
-#define UBRRH UBRR1H
-#define UBRRL UBRR1L
-#define URSEL UMSEL10
-#define USART_UDRE_vect USART1_UDRE_vect
-#define USART_RXC_vect USART1_RX_vect
-#define UDRIE UDRIE1
-#define TXEN TXEN1
-#define UMSEL UMSEL1
-#define RXEN RXEN1
-#define RXCIE RXCIE1
-#define UCSZ0 UCSZ10
-#define UCSRA UCSR1A
-#define UDRE UDRE1
-#define RXC RXC1
-#endif
-
-
-
-#ifdef UART_XON_XOFF
-#define XON 0x11
-#define XOFF 0x13
-
- #ifdef UART_INTERRUPT
- void uart_insertc(char c);
- #else
- #define uart_insertc uart_putc
- #endif /* UART_INTERRUPT */
-#endif
-
-#define UART_BAUD_CALC(UART_BAUD_RATE,F_OSC) ((F_OSC)/((UART_BAUD_RATE)*16L)-1)
-
-#ifdef UART_XON_XOFF
- typedef enum{go=1,nogo=0} gonogo;
- static gonogo txon=go;
- static gonogo rxon=go;
-#endif
-
-#ifdef UART_INTERRUPT
-volatile static char rxbuf[UART_RXBUFSIZE];
-volatile static char txbuf[UART_TXBUFSIZE];
-volatile static char *volatile rxhead, *volatile rxtail;
-volatile static char *volatile txhead, *volatile txtail;
-
-#ifdef UART_HOOK
- void (*uart_hook) (uint8_t) = (void*)0; /* this is a pointer to a function ;-) */
-#endif
-
-ISR(USART_UDRE_vect) {
-#ifdef UART_LEDS
- PORTC ^= 0x01;
-#endif
-
- if ( txhead == txtail ) {
- UCSRB &= ~(1 << UDRIE); /* disable data register empty IRQ */
- } else {
- #ifdef UART_XON_XOFF
- while(txon==nogo)
- ;
- #endif
- UDR = *txtail; /* schreibt das Zeichen x auf die Schnittstelle */
- if (++txtail == (txbuf + UART_TXBUFSIZE)) txtail = txbuf;
- }
-}
-
-ISR(USART_RXC_vect) {
- int diff;
- char c;
-#ifdef UART_HOOK
- static volatile uint8_t hook_running=0;
-#endif
-#ifdef UART_LEDS
- PORTC ^= 0x02;
-#endif
- c=UDR;
- #ifdef UART_XON_XOFF
- if (c==XON){
- txon=go;
- return;
- }
- if (c==XOFF){
- txon=nogo;
- return;
- }
- #endif
- /* buffer full? */
- diff = rxhead - rxtail;
- if (diff < 0) diff += UART_RXBUFSIZE; /* diff is the amount of bytes in buffer */
- if (diff < UART_RXBUFSIZE -1) {
- // buffer NOT full
-#ifdef UART_HOOK
- if(!hook_running && uart_hook){
- uint8_t t=c;
- hook_running = 1;
- sei(); /* reenable interrupts, avoid recursion!!! */
- do {
- uart_hook(t);
- } while(uart_getc_nb((char*)&t));
- hook_running = 0;
- } else {
- *rxhead = c;
- ++rxhead;
- if (rxhead == (rxbuf + UART_RXBUFSIZE)) rxhead = rxbuf;
- }
-#else
- *rxhead = c;
- ++rxhead;
- if (rxhead == (rxbuf + UART_RXBUFSIZE))
- rxhead = rxbuf;
-#endif
- } else {
- //reads the buffer to clear the interrupt condition
- }
-#ifdef UART_XON_XOFF
- if((diff > UART_XON_XOFF_THRESHOLD_1) && (rxon==go)){
- rxon=nogo;
- uart_insertc(XOFF);
- }
- if((diff < UART_XON_XOFF_THRESHOLD_2) && (rxon==nogo)){
- rxon=go;
- uart_insertc(XON);
- }
-#endif
-}
-
-#endif // UART_INTERRUPT
-
-
-void uart_init() {
- PORTD |= 0x01; //Pullup an RXD an
-
- UCSRB |= (1<>8);
- UBRRL=(uint8_t)(UART_BAUD_CALC(UART_BAUD_RATE,F_CPU));
-
-#ifdef UART_INTERRUPT
- // init buffers
- rxhead = rxtail = rxbuf;
- txhead = txtail = txbuf;
-
- // activate rx IRQ
- UCSRB |= _BV(RXCIE) | _BV(UDRIE);
- sei();
-// #ifdef ATMEGA644
-// UCSRB |= _BV(UDRIE);
-// #endif
-#endif // UART_INTERRUPT
-}
-
-#ifdef UART_INTERRUPT
-#ifdef UART_XON_XOFF
-
-void uart_insertc(char c){
- volatile int diff;
- do {
- diff = txhead - txtail;
- if ( diff < 0 ) diff += UART_TXBUFSIZE;
- } while ( diff >= UART_TXBUFSIZE -1 );
-
- cli();
- if (--txtail == (txbuf-1)) txtail += UART_TXBUFSIZE;
- *txtail = c;
-
- UCSRB |= (1 << UDRIE); /* enable data register empty IRQ */
- sei();
-}
-#endif /* UART_XON_XOFF */
-void uart_putc(char c) {
- volatile int diff;
-
- /* buffer full? */
- do {
- diff = txhead - txtail;
- if ( diff < 0 ) diff += UART_TXBUFSIZE;
- } while ( diff >= UART_TXBUFSIZE -1 );
-
- cli();
- *txhead = c;
- if (++txhead == (txbuf + UART_TXBUFSIZE)) txhead = txbuf;
-
- UCSRB |= (1 << UDRIE); /* enable data register empty IRQ */
- sei();
-}
-#else // WITHOUT INTERRUPT
-void uart_putc(char c) {
- while (!(UCSRA & (1<>4)));
- uart_putc(pgm_read_byte(hexdigit_tab_P + ((*((uint8_t*)buf))&0xf)));
- uart_putc(' ');
- buf=(uint8_t*)buf+1;
- }
-}
-
-
-#ifdef UART_INTERRUPT
-char uart_getc(void)
-{
- char val;
-
- while(rxhead==rxtail)
- ;
-
- val = *rxtail;
- ++rxtail;
- if (rxtail == (rxbuf + UART_RXBUFSIZE))
- rxtail = rxbuf;
-
- return val;
-}
-#else // WITHOUT INTERRUPT
-char uart_getc(void)
-{
- char t;
- while (!(UCSRA & (1<.
+*/
+
+#ifndef UART_DEFS_H_
+#define UART_DEFS_H_
+
+#define UART_PARATY_NONE 0 /** \def UART_PARATY_NONE define no paraty */
+#define UART_PARATY_EVEN 2 /** \def UART_PARATY_EVEN define even paraty */
+#define UART_PARATY_ODD 3 /** \def UART_PARATY_ODD define odd paraty */
+#define UART_STOPBITS_1 0 /** \def UART_STOPBITS_1 define 1 stop bit */
+#define UART_STOPBITS_2 1 /** \def UART_STOPBITS_2 define 2 stop bits */
+#define UART_DATABITS_5 0 /** \def UART_DATABITS_5 define 5 data bits */
+#define UART_DATABITS_6 1 /** \def UART_DATABITS_6 define 6 data bits */
+#define UART_DATABITS_7 2 /** \def UART_DATABITS_7 define 7 data bits */
+#define UART_DATABITS_8 3 /** \def UART_DATABITS_8 define 8 data bits */
+#define UART_DATABITS_9 7 /** \def UART_DATABITS_9 define 9 data bits */
+
+#endif /* UART_DEFS_H_ */
diff --git a/test_src/uart_i-asm.S b/test_src/uart_i-asm.S
new file mode 100644
index 0000000..8ce866b
--- /dev/null
+++ b/test_src/uart_i-asm.S
@@ -0,0 +1,447 @@
+/* uart_i-asm.S */
+/*
+ This file is part of the AVR-uart_i.
+ Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 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, see .
+*/
+/**
+ * \file uart_i-asm.S
+ * \email daniel.otte@rub.de
+ * \author Daniel Otte
+ * \date 2009-07-24
+ * \license GPLv3 or later
+ * \ingroup uart_i
+ * \brief implementation of interrupt based uart
+ */
+
+#include
+#include "config.h"
+#include "avr-asm-macros.S"
+
+#define XON_VALUE 0x11
+#define XOFF_VALUE 0x13
+
+#ifdef UDR
+# define OLD_UART
+# ifdef UDR0
+# error "can not decide which registernames to use, UDR and UDR0 are defined"
+# endif
+#endif
+
+#ifdef OLD_UART
+# define UCSR0A UCSRA
+# define UCSR0B UCSRB
+# define UCSR0C UCSRC
+# define UBRR0H UBRRH
+# define UBRR0L UBRRL
+# define UDR0 UDR
+# define TXEN0 TXEN
+# define RXEN0 RXEN
+# define UDRE0 UDRE
+# define RXC0 RXC
+# define TXB80 TXB8
+# define RXB80 RXB8
+#endif
+
+#define CBB_SIZE 10
+
+#define UART0_CBB_RX_OFFSET 0
+#define UART0_CBB_TX_OFFSET 10
+
+#define CTX_BASE_SIZE (2*(CBB_SIZE))
+
+#if UART0_HOOK
+# if UART0_SWFLOWCTRL
+# define UART0_CTX_SIZE (3+2+CTX_BASE_SIZE)
+# define UART0_HOOK_OFFSET 20
+# define UART0_HOOKR_OFFSET 22
+# define UART0_TXON_OFFSET 23
+# define UART0_RXON_OFFSET 24
+# else
+# define UART0_CTX_SIZE (3+0+CTX_BASE_SIZE)
+# define UART0_HOOK_OFFSET 20
+# define UART0_HOOKR_OFFSET 22
+# endif
+#else
+# if UART0_SWFLOWCTRL
+# define UART0_CTX_SIZE (0+2+CTX_BASE_SIZE)
+# define UART0_TXON_OFFSET 20
+# define UART0_RXON_OFFSET 21
+# else
+# define UART0_CTX_SIZE (0+0+CTX_BASE_SIZE)
+# endif
+#endif
+
+ .section .bss
+.global uart0_rxbuffer
+uart0_rxbuffer:
+ .fill UART0_RXBUFFER_SIZE, 1, 0
+.global uart0_txbuffer
+uart0_txbuffer:
+ .fill UART0_TXBUFFER_SIZE, 1, 0
+.global uart0_ctx
+uart0_ctx:
+ .fill UART0_CTX_SIZE, 1, 0
+/******************************************************************************/
+/* Baudrate calculation */
+#ifdef BAUD
+#undef BAUD
+#endif
+
+#define BAUD UART0_BAUD_RATE
+#include "setbaud_asm.inc"
+
+ .section .text
+/******************************************************************************/
+/*
+ * void uart0_init(void){
+ * circularbytebuffer_init2(UART0_RXBUFFER_SIZE, &(uart0_ctx.rxb), uart0_rxbuffer);
+ * circularbytebuffer_init2(UART0_TXBUFFER_SIZE, &(uart0_ctx.txb), uart0_txbuffer);
+ * #if UART0_HOOK
+ * uart0_ctx.hook = NULL;
+ * uart0_ctx.hook_running = 0;
+ * #endif
+ * #if UART0_SWFLOWCTRL
+ * uart0_ctx.txon = 1;
+ * uart0_ctx.rxon = 1;
+ * #endif
+ * #define BAUD UART0_BAUD_RATE
+ * #include
+ * UBRR0H = UBRRH_VALUE;
+ * UBRR0L = UBRRL_VALUE;
+ * #if USE_2X
+ * UCSR0A |= _BV(U2X0);
+ * #else
+ * UCSR0A &= ~_BV(U2X0);
+ * #endif
+ * UCSR0C = (UART0_PARATY<<4)|(UART0_STOPBITS<<3)|((UART0_DATABITS&3)<<1);
+ * UCSR0B = _BV(RXCIE0) | _BV(UDRIE0) | _BV(RXEN0) | _BV(TXEN0) ; / * enable TX and RX and interrupts * /
+ * sei();
+ * }
+ *
+ */
+.global uart0_init
+uart0_init:
+ ldi r24, UART0_RXBUFFER_SIZE
+ clr r25
+ ldi r22, lo8(uart0_ctx+UART0_CBB_RX_OFFSET)
+ ldi r23, hi8(uart0_ctx+UART0_CBB_RX_OFFSET)
+ ldi r24, UART0_RXBUFFER_SIZE
+ ldi r20, lo8(uart0_rxbuffer)
+ ldi r21, hi8(uart0_rxbuffer)
+ rcall circularbytebuffer_init2
+ ldi r24, UART0_TXBUFFER_SIZE
+ clr r25
+ ldi r22, lo8(uart0_ctx+UART0_CBB_TX_OFFSET)
+ ldi r23, hi8(uart0_ctx+UART0_CBB_TX_OFFSET)
+ ldi r24, UART0_TXBUFFER_SIZE
+ ldi r20, lo8(uart0_txbuffer)
+ ldi r21, hi8(uart0_txbuffer)
+ rcall circularbytebuffer_init2
+#if UART0_SWFLOWCTRL
+ ldi r30, lo8(uart0_ctx)
+ ldi r31, hi8(uart0_ctx)
+ ldi r24, 1
+ std Z+UART0_TXON_OFFSET, r24
+ std Z+UART0_RXON_OFFSET, r24
+#endif
+ ldi r24, UBRRH_VALUE
+ STORE_IO UBRR0H, r24
+ ldi r24, UBRRL_VALUE
+ STORE_IO UBRR0L, r24
+#if USE_2X
+ SET_BIT_IO UCSR0A, U2X0, r24
+#else
+ CLEAR_BIT_IO UCSR0A, U2X0, r24
+/* UCSR0A */
+#endif
+ ldi r24, (UART0_PARATY<<4)|(UART0_STOPBITS<<3)|((UART0_DATABITS&3)<<1)
+ STORE_IO UCSR0C, r24
+ ldi r24, _BV(RXCIE0) | _BV(UDRIE0) | _BV(RXEN0) | _BV(TXEN0)
+ STORE_IO UCSR0B, r24
+ sei
+ ret
+
+/******************************************************************************/
+/*
+ * ISR(USART0_UDRE_vect){
+ * uint16_t x;
+ * x = circularbytebuffer_get_fifo(&(uart0_ctx.txb));
+ * if(x==0xffff){
+ * / * the transmit buffer is empty, disable interrupt * /
+ * UCSR0B &= (uint8_t)~_BV(UDRIE0);
+ * return;
+ * }
+ * #if UART0_SWFLOWCTRL
+ * while(!uart0_ctx.txon)
+ * ;
+ * #endif
+ * UDR0 = x;
+ * }
+ */
+
+.global USART0_UDRE_vect
+USART0_UDRE_vect:
+ push_range 21, 26
+ push_range 30, 31
+ in r21, _SFR_IO_ADDR(SREG)
+ ldi r24, lo8(uart0_ctx+UART0_CBB_TX_OFFSET)
+ ldi r25, hi8(uart0_ctx+UART0_CBB_TX_OFFSET)
+ rcall circularbytebuffer_get_fifo
+ cpi r25, 0xff
+ brne 20f
+ CLEAR_BIT_IO UCSR0B, UDRIE0, r24
+ rjmp 99f
+20:
+#if UART0_SWFLOWCTRL
+ ldi r30, lo8(uart0_ctx+UART0_TXON_OFFSET)
+ ldi r31, hi8(uart0_ctx+UART0_TXON_OFFSET)
+30:
+ ld r22, Z
+ tst r22
+ breq 30b
+#endif
+ STORE_IO UDR0, r24
+99:
+ out _SFR_IO_ADDR(SREG), r21
+ pop_range 30, 31
+ pop_range 21, 26
+ reti
+
+/******************************************************************************/
+/*
+ * void uart0_putc (uint16_t c){
+ * #if UART0_SWFLOWCTRL
+ * while(!uart0_ctx.txon)
+ * ;
+ * #endif
+ * while(circularbytebuffer_cnt(&(uart0_ctx.txb))==UART0_TXBUFFER_SIZE)
+ * ;
+ * cli();
+ * circularbytebuffer_append((uint8_t)c, &(uart0_ctx.txb));
+ * sei();
+ * UCSR0B |= (uint8_t)_BV(UDRIE0);
+ * }
+ *
+ * param c: r24:r25
+ */
+.global uart0_putc
+uart0_putc:
+ mov r18, r24
+#if UART0_SWFLOWCTRL
+ ldi r30, lo8(uart0_ctx+UART0_TXON_OFFSET)
+ ldi r31, hi8(uart0_ctx+UART0_TXON_OFFSET)
+10:
+ ld r22, Z
+ tst r22
+ breq 10b
+#endif
+ ldi r26, lo8(uart0_ctx+UART0_CBB_TX_OFFSET)
+ ldi r27, hi8(uart0_ctx+UART0_CBB_TX_OFFSET)
+20:
+ movw r24, r26
+ rcall circularbytebuffer_cnt
+ cpi r24, UART0_TXBUFFER_SIZE
+ breq 20b
+ movw r22, r26
+ mov r24, r18
+ clr r25
+ cli
+ rcall circularbytebuffer_append
+ sei
+ SET_BIT_IO UCSR0B, UDRIE0, r24
+ ret
+
+/******************************************************************************/
+/*
+ * ISR(USART0_RX_vect){
+ * uint16_t c;
+ * c = UDR0;
+ * #if UART0_SWFLOWCTRL
+ * if(c==XON_VALUE){
+ * uart0_ctx.txon = 1;
+ * return;
+ * }
+ * if(c==XOFF_VALUE){
+ * uart0_ctx.txon = 0;
+ * return;
+ * }
+ * #endif
+ * #if UART0_HOOK
+ * if((!uart0_ctx.hook_running) && uart0_ctx.hook){
+ * uart0_ctx.hook_running=1;
+ * sei();
+ * do{
+ * uart0_ctx.hook(c);
+ * }while((c=circularbytebuffer_get_fifo(&(uart0_ctx.rxb)))!=0xffff);
+ * uart0_ctx.hook_running=0;
+ * return;
+ * }
+ * #endif
+ * if(circularbytebuffer_cnt(&(uart0_ctx.rxb))==UART0_RXBUFFER_SIZE)
+ * return;
+ * circularbytebuffer_append(c, &(uart0_ctx.rxb));
+ * #if UART0_SWFLOWCTRL
+ * if(circularbytebuffer_cnt(&(uart0_ctx.rxb))>UART0_THRESH_HIGH && uart0_ctx.rxon){
+ * uart0_ctx.rxon = 0;
+ * circularbytebuffer_push(XOFF_VALUE, &(uart0_ctx.txb));
+ * UCSR0B |= (uint8_t)_BV(UDRIE0);
+ * }
+ * if(circularbytebuffer_cnt(&(uart0_ctx.rxb)).
+*/
+/**
+ * \file uart_i.h
+ * \email daniel.otte@rub.de
+ * \author Daniel Otte
+ * \date 2009-07-24
+ * \license GPLv3 or later
+ * \ingroup uart_i
+ * \brief declaration for non-interrupt uart
+ */
+
+#ifndef UART_I_H_
+#define UART_I_H_
+
+#include "config.h"
+#include "circularbytebuffer.h"
+#include
+
+typedef struct{
+ circularbytebuffer_t rxb;
+ circularbytebuffer_t txb;
+#if UART0_HOOK
+ void(*hook)(uint8_t);
+ volatile uint8_t hook_running;
+#endif
+#if UART0_SWFLOWCTRL
+ volatile uint8_t txon;
+ volatile uint8_t rxon;
+#endif
+} uart0_ctx_t;
+
+
+typedef struct{
+ circularbytebuffer_t rxb;
+ circularbytebuffer_t txb;
+#if UART1_HOOK
+ void(*hook)(uint8_t);
+ volatile uint8_t hook_running;
+#endif
+#if UART1_SWFLOWCTRL
+ volatile uint8_t txon;
+ volatile uint8_t rxon;
+#endif
+} uart1_ctx_t;
+
+#if UART0_I
+
+/** \fn uart0_init(void)
+ * \brief initialize uart0.
+ * This function initializes the first uart according to the parameter specifyed
+ * in config.h .
+ */
+void uart0_init(void);
+
+/** \fn uart0_putc(uint16_t)
+ * \brief send data through uart0.
+ * This function sends data through the first uart
+ * (the data size is debfined in config.h).
+ * \param c data to send
+ */
+void uart0_putc(uint16_t c);
+
+/** \fn uart0_getc(void)
+ * \brief read data from uart0.
+ * This function reads data from the first uart
+ * (the data size is debfined in config.h).
+ * \return data recived by uart0
+ */
+uint16_t uart0_getc(void);
+
+/** \fn uart0_dataavail(void)
+ * \brief checks if data is available.
+ *
+ * This function checks the state of the input buffer of uart0 and
+ * returns if data is available or not.
+ * \return zero if no data is available else a value different from zero is returned
+ */
+uint8_t uart0_dataavail(void);
+
+#if UART0_HOOK
+void uart0_sethook(void(*fpt)(uint8_t));
+#endif
+
+
+#endif /* UART0_I */
+
+#if UART1_I
+/** \fn uart1_init(void)
+ * \brief initialize uart1.
+ * This function initializes the second uart according to the parameter specifyed
+ * in config.h .
+ */
+void uart1_init(void);
+
+/** \fn uart1_putc(uint16_t)
+ * \brief send data through uart1.
+ * This function sends data through the second uart
+ * (the data size is debfined in config.h).
+ * \param c data to send
+ */
+void uart1_putc(uint16_t c);
+
+/** \fn uart1_getc(void)
+ * \brief read data from uart1.
+ * This function reads data from the second uart
+ * (the data size is debfined in config.h).
+ * \return data recived by uart1
+ */
+uint16_t uart1_getc(void);
+
+/** \fn uart1_dataavail(void)
+ * \brief checks if data is available.
+ * This function checks the state of the input buffer of uart1 and
+ * returns if data is available or not.
+ * \return zero if no data is available else a value different from zero is returned
+ */
+uint8_t uart1_dataavail(void);
+
+void uart0_sethook(void(*fpt)(uint8_t));
+#endif
+
+#endif /* UART_I_H_ */