fix the host/emulation build
Going for __ARM__ to distinguish host and firmware builds is not sufficient here, since we might be building on a ARM host, so there is now a OCTSIMFWBUILD define. Change-Id: Ib07a58b6102b1709f295d08a764c6f118a2d0b9e
This commit is contained in:
parent
89b1e06803
commit
e84a571c04
|
@ -98,7 +98,11 @@ static void iso_fsm_slot_icc_power_on_async(struct ccid_slot *cs, struct msgb *m
|
||||||
osmo_fsm_inst_dispatch(ss->fi, ISO7816_E_POWER_UP_IND, NULL);
|
osmo_fsm_inst_dispatch(ss->fi, ISO7816_E_POWER_UP_IND, NULL);
|
||||||
cs->icc_powered = true;
|
cs->icc_powered = true;
|
||||||
card_uart_ctrl(ss->cuart, CUART_CTL_CLOCK, true);
|
card_uart_ctrl(ss->cuart, CUART_CTL_CLOCK, true);
|
||||||
|
#ifdef OCTSIMFWBUILD
|
||||||
delay_us(10000);
|
delay_us(10000);
|
||||||
|
#else
|
||||||
|
usleep(10000);
|
||||||
|
#endif
|
||||||
|
|
||||||
osmo_fsm_inst_dispatch(ss->fi, ISO7816_E_RESET_REL_IND, NULL);
|
osmo_fsm_inst_dispatch(ss->fi, ISO7816_E_RESET_REL_IND, NULL);
|
||||||
card_uart_ctrl(ss->cuart, CUART_CTL_RST, false);
|
card_uart_ctrl(ss->cuart, CUART_CTL_RST, false);
|
||||||
|
@ -119,7 +123,9 @@ static void iso_fsm_clot_user_cb(struct osmo_fsm_inst *fi, int event, int cause,
|
||||||
case ISO7816_E_PPS_DONE_IND:
|
case ISO7816_E_PPS_DONE_IND:
|
||||||
case ISO7816_E_PPS_FAILED_IND:
|
case ISO7816_E_PPS_FAILED_IND:
|
||||||
cs->event_data = data;
|
cs->event_data = data;
|
||||||
|
#ifdef OCTSIMFWBUILD
|
||||||
asm volatile("dmb st": : :"memory");
|
asm volatile("dmb st": : :"memory");
|
||||||
|
#endif
|
||||||
cs->event = event;
|
cs->event = event;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -329,35 +335,38 @@ static int iso_fsm_slot_init(struct ccid_slot *cs)
|
||||||
void *ctx = g_tall_ctx; /* FIXME */
|
void *ctx = g_tall_ctx; /* FIXME */
|
||||||
struct iso_fsm_slot *ss = ccid_slot2iso_fsm_slot(cs);
|
struct iso_fsm_slot *ss = ccid_slot2iso_fsm_slot(cs);
|
||||||
struct card_uart *cuart = talloc_zero(ctx, struct card_uart);
|
struct card_uart *cuart = talloc_zero(ctx, struct card_uart);
|
||||||
char id_buf[16] = "SIM0";
|
char id_buf[3+3+1];
|
||||||
char devname[] = "foobar";
|
char devname[2+1];
|
||||||
|
char *devnamep = 0;
|
||||||
|
char *drivername = "asf4";
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
LOGPCS(cs, LOGL_DEBUG, "%s\n", __func__);
|
LOGPCS(cs, LOGL_DEBUG, "%s\n", __func__);
|
||||||
|
|
||||||
/* HACK: make this in some way configurable so it works both in the firmware
|
snprintf(id_buf, sizeof(id_buf), "SIM%d", cs->slot_nr);
|
||||||
* and on the host (functionfs) */
|
#ifdef OCTSIMFWBUILD
|
||||||
// if (cs->slot_nr == 0) {
|
snprintf(devname, sizeof(devname), "%d", cs->slot_nr);
|
||||||
// cs->icc_present = true;
|
devnamep = devname;
|
||||||
// devname = "/dev/ttyUSB5";
|
#else
|
||||||
// }
|
if (cs->slot_nr == 0) {
|
||||||
devname[0] = cs->slot_nr +0x30;
|
cs->icc_present = true;
|
||||||
devname[1] = 0;
|
devnamep = "/dev/ttyUSB5";
|
||||||
//sprintf(devname, "%d", cs->slot_nr);
|
}
|
||||||
|
drivername = "tty";
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!cuart)
|
if (!cuart)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
//snprintf(id_buf, sizeof(id_buf), "SIM%d", cs->slot_nr);
|
if (devnamep) {
|
||||||
id_buf[3] = cs->slot_nr +0x30;
|
rc = card_uart_open(cuart, drivername, devnamep);
|
||||||
if (devname) {
|
|
||||||
rc = card_uart_open(cuart, "asf4", devname);
|
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
LOGPCS(cs, LOGL_ERROR, "Cannot open UART %s: %d\n", devname, rc);
|
LOGPCS(cs, LOGL_ERROR, "Cannot open UART %s: %d\n", devname, rc);
|
||||||
talloc_free(cuart);
|
talloc_free(cuart);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ss->fi = iso7816_fsm_alloc(ctx, LOGL_DEBUG, id_buf, cuart, iso_fsm_clot_user_cb, ss);
|
ss->fi = iso7816_fsm_alloc(ctx, LOGL_DEBUG, id_buf, cuart, iso_fsm_clot_user_cb, ss);
|
||||||
if (!ss->fi) {
|
if (!ss->fi) {
|
||||||
LOGPCS(cs, LOGL_ERROR, "Cannot allocate ISO FSM\n");
|
LOGPCS(cs, LOGL_ERROR, "Cannot allocate ISO FSM\n");
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include "utils.h"
|
#include <osmocom/core/utils.h>
|
||||||
#include "iso7816_3.h"
|
#include "iso7816_3.h"
|
||||||
|
|
||||||
const uint16_t iso7816_3_fi_table[16] = {
|
const uint16_t iso7816_3_fi_table[16] = {
|
||||||
|
|
|
@ -1193,7 +1193,7 @@ static void tpdu_s_init_action(struct osmo_fsm_inst *fi, uint32_t event, void *d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <hal_gpio.h>
|
|
||||||
static void tpdu_s_tx_hdr_action(struct osmo_fsm_inst *fi, uint32_t event, void *data)
|
static void tpdu_s_tx_hdr_action(struct osmo_fsm_inst *fi, uint32_t event, void *data)
|
||||||
{
|
{
|
||||||
struct osmo_fsm_inst *parent_fi = fi->proc.parent;
|
struct osmo_fsm_inst *parent_fi = fi->proc.parent;
|
||||||
|
@ -1213,7 +1213,9 @@ static void tpdu_s_tx_hdr_action(struct osmo_fsm_inst *fi, uint32_t event, void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
#include <hal_gpio.h>
|
||||||
|
#endif
|
||||||
static void tpdu_s_procedure_action(struct osmo_fsm_inst *fi, uint32_t event, void *data)
|
static void tpdu_s_procedure_action(struct osmo_fsm_inst *fi, uint32_t event, void *data)
|
||||||
{
|
{
|
||||||
struct tpdu_fsm_priv *tfp = get_tpdu_fsm_priv(fi);
|
struct tpdu_fsm_priv *tfp = get_tpdu_fsm_priv(fi);
|
||||||
|
|
|
@ -11,6 +11,7 @@ ccid_functionfs: ccid_main_functionfs.o \
|
||||||
../ccid_common/ccid_proto.o \
|
../ccid_common/ccid_proto.o \
|
||||||
../ccid_common/ccid_device.o \
|
../ccid_common/ccid_device.o \
|
||||||
../ccid_common/ccid_slot_fsm.o \
|
../ccid_common/ccid_slot_fsm.o \
|
||||||
|
../ccid_common/iso7816_3.o \
|
||||||
../ccid_common/iso7816_fsm.o
|
../ccid_common/iso7816_fsm.o
|
||||||
$(CC) $(CFLAGS) -o $@ $^ $(LIBS) -laio
|
$(CC) $(CFLAGS) -o $@ $^ $(LIBS) -laio
|
||||||
|
|
||||||
|
@ -28,6 +29,7 @@ cuart_fsm_test: cuart_fsm_test.o \
|
||||||
cuart_driver_tty.o \
|
cuart_driver_tty.o \
|
||||||
utils_ringbuffer.o \
|
utils_ringbuffer.o \
|
||||||
../ccid_common/iso7816_fsm.o \
|
../ccid_common/iso7816_fsm.o \
|
||||||
|
../ccid_common/iso7816_3.o \
|
||||||
../ccid_common/cuart.o
|
../ccid_common/cuart.o
|
||||||
$(CC) $(CFLAGS) -o $@ $^ $(LIBS) $(shell pkg-config --libs libosmosim)
|
$(CC) $(CFLAGS) -o $@ $^ $(LIBS) $(shell pkg-config --libs libosmosim)
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ CROSS_COMPILE= arm-none-eabi-
|
||||||
|
|
||||||
CFLAGS_CPU=-D__SAME54N19A__ -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16
|
CFLAGS_CPU=-D__SAME54N19A__ -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16
|
||||||
CFLAGS=-x c -mthumb -DDEBUG -Os -ffunction-sections -fdata-sections -mlong-calls \
|
CFLAGS=-x c -mthumb -DDEBUG -Os -ffunction-sections -fdata-sections -mlong-calls \
|
||||||
-g3 -Wall -c -std=gnu99 $(CFLAGS_CPU)
|
-g3 -Wall -c -std=gnu99 $(CFLAGS_CPU) -DOCTSIMFWBUILD
|
||||||
|
|
||||||
CC = $(CROSS_COMPILE)gcc
|
CC = $(CROSS_COMPILE)gcc
|
||||||
LD = $(CROSS_COMPILE)ld
|
LD = $(CROSS_COMPILE)ld
|
||||||
|
|
Loading…
Reference in New Issue