aboutsummaryrefslogtreecommitdiffhomepage
path: root/pyecsca/codegen/hal
diff options
context:
space:
mode:
authorJ08nY2019-11-25 17:45:35 +0100
committerJ08nY2019-11-25 17:45:35 +0100
commit8a56c7a95e662862cfe78b834ccb091e95d5372f (patch)
tree1fd57480b7fc681f00c0bfb6c0e5cfea86762f87 /pyecsca/codegen/hal
parentc8d0bff46001bd5636825c5b0bb4c896cb34a4e6 (diff)
downloadpyecsca-codegen-8a56c7a95e662862cfe78b834ccb091e95d5372f.tar.gz
pyecsca-codegen-8a56c7a95e662862cfe78b834ccb091e95d5372f.tar.zst
pyecsca-codegen-8a56c7a95e662862cfe78b834ccb091e95d5372f.zip
Add libtommath, HOST build, and a simple PRNG.
Diffstat (limited to 'pyecsca/codegen/hal')
-rw-r--r--pyecsca/codegen/hal/Makefile.hal5
-rw-r--r--pyecsca/codegen/hal/hal.h3
-rw-r--r--pyecsca/codegen/hal/host/Makefile.host10
-rw-r--r--pyecsca/codegen/hal/host/host_hal.c2
-rw-r--r--pyecsca/codegen/hal/host/host_hal.h14
-rw-r--r--pyecsca/codegen/hal/host/uart.c7
-rw-r--r--pyecsca/codegen/hal/host/uart.h13
7 files changed, 54 insertions, 0 deletions
diff --git a/pyecsca/codegen/hal/Makefile.hal b/pyecsca/codegen/hal/Makefile.hal
index 14d4c97..3c81d00 100644
--- a/pyecsca/codegen/hal/Makefile.hal
+++ b/pyecsca/codegen/hal/Makefile.hal
@@ -20,6 +20,8 @@ define KNOWN_PLATFORMS
+-------------------------------------------------------+
| CW308_STM32F3 | CW308T-STM32F3 (ST Micro STM32F3) |
+-------------------------------------------------------+
+| HOST | Host machine |
++-------------------------------------------------------+
endef
@@ -44,6 +46,9 @@ else ifeq ($(PLATFORM),CW308_STM32F0)
else ifeq ($(PLATFORM),CW308_STM32F3)
HAL = stm32f3
PLTNAME = CW308T: STM32F3 Target
+else ifeq ($(PLATFORM),HOST)
+ HAL = host
+ PLTNAME = HOST: Host machine target
else
$(error Invalid or empty PLATFORM: $(PLATFORM). Known platforms: $(KNOWN_PLATFORMS))
endif
diff --git a/pyecsca/codegen/hal/hal.h b/pyecsca/codegen/hal/hal.h
index 831276f..b14dacf 100644
--- a/pyecsca/codegen/hal/hal.h
+++ b/pyecsca/codegen/hal/hal.h
@@ -24,6 +24,7 @@ void platform_init(void);
#define HAL_xmega 1
#define HAL_stm32f0 2
#define HAL_stm32f3 3
+#define HAL_host 4
#if HAL == HAL_xmega
#include <avr/io.h>
@@ -34,6 +35,8 @@ void platform_init(void);
#include "stm32f0/stm32f0_hal.h"
#elif HAL == HAL_stm32f3
#include "stm32f3/stm32f3_hal.h"
+#elif HAL == HAL_host
+ #include "host/host_hal.h"
#else
#error "Unsupported HAL Type"
#endif
diff --git a/pyecsca/codegen/hal/host/Makefile.host b/pyecsca/codegen/hal/host/Makefile.host
new file mode 100644
index 0000000..933c899
--- /dev/null
+++ b/pyecsca/codegen/hal/host/Makefile.host
@@ -0,0 +1,10 @@
+VPATH += :$(HALPATH)/host
+SRC += uart.c host_hal.c
+EXTRAINCDIRS += $(HALPATH)/host
+
+CC = gcc
+OBJCOPY = objcopy
+OBJDUMP = objdump
+SIZE = size
+AR = ar rcs
+NM = nm \ No newline at end of file
diff --git a/pyecsca/codegen/hal/host/host_hal.c b/pyecsca/codegen/hal/host/host_hal.c
new file mode 100644
index 0000000..fe71aab
--- /dev/null
+++ b/pyecsca/codegen/hal/host/host_hal.c
@@ -0,0 +1,2 @@
+
+void platform_init(void) {} \ No newline at end of file
diff --git a/pyecsca/codegen/hal/host/host_hal.h b/pyecsca/codegen/hal/host/host_hal.h
new file mode 100644
index 0000000..b78172c
--- /dev/null
+++ b/pyecsca/codegen/hal/host/host_hal.h
@@ -0,0 +1,14 @@
+#ifndef HOST_HAL_H_
+#define HOST_HAL_H_
+
+#include "uart.h"
+
+#define trigger_setup()
+#define trigger_high()
+#define trigger_low()
+
+#define init_uart init_uart0
+#define putch output_ch_0
+#define getch input_ch_0
+
+#endif //HOST_HAL_H_
diff --git a/pyecsca/codegen/hal/host/uart.c b/pyecsca/codegen/hal/host/uart.c
new file mode 100644
index 0000000..3931d6d
--- /dev/null
+++ b/pyecsca/codegen/hal/host/uart.c
@@ -0,0 +1,7 @@
+#include "uart.h"
+
+void init_uart0(void) {}
+
+char input_ch_0(void) { return getchar(); }
+
+void output_ch_0(char data) { putchar(data); } \ No newline at end of file
diff --git a/pyecsca/codegen/hal/host/uart.h b/pyecsca/codegen/hal/host/uart.h
new file mode 100644
index 0000000..d6063bc
--- /dev/null
+++ b/pyecsca/codegen/hal/host/uart.h
@@ -0,0 +1,13 @@
+#ifndef UART_H_
+#define UART_H_
+
+#include <stdio.h>
+
+
+void init_uart0(void);
+
+char input_ch_0(void);
+
+void output_ch_0(char data);
+
+#endif //UART_H_ \ No newline at end of file