mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-19 23:08:34 +03:00
Change directory structure to align with Atmel softpack
This way we can easily check with 'diff' for differences in our code and Atmel softpack. Also, this layout is more suitable for building various different firmware images (e.g. factory-test, dfu-loader, main application) for a variety of different boards (simtrace, owhw, qmod).
This commit is contained in:
6
firmware/libcommon/include/iso7816_fidi.h
Normal file
6
firmware/libcommon/include/iso7816_fidi.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* compute the F/D ratio based on Fi and Di values */
|
||||
int compute_fidi_ratio(uint8_t fi, uint8_t di);
|
||||
27
firmware/libcommon/include/llist_irqsafe.h
Normal file
27
firmware/libcommon/include/llist_irqsafe.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include "osmocom/core/linuxlist.h"
|
||||
|
||||
static inline void llist_add_tail_irqsafe(struct llist_head *_new,
|
||||
struct llist_head *head)
|
||||
{
|
||||
__disable_irq();
|
||||
llist_add_tail(_new, head);
|
||||
__enable_irq();
|
||||
}
|
||||
|
||||
static inline struct llist_head *llist_head_dequeue_irqsafe(struct llist_head *head)
|
||||
{
|
||||
struct llist_head *lh;
|
||||
|
||||
__disable_irq();
|
||||
if (llist_empty(head)) {
|
||||
lh = NULL;
|
||||
} else {
|
||||
lh = head->next;
|
||||
llist_del(lh);
|
||||
}
|
||||
__enable_irq();
|
||||
|
||||
return lh;
|
||||
}
|
||||
61
firmware/libcommon/include/req_ctx.h
Normal file
61
firmware/libcommon/include/req_ctx.h
Normal file
@@ -0,0 +1,61 @@
|
||||
#pragma once
|
||||
|
||||
#define RCTX_SIZE_LARGE 960
|
||||
#define RCTX_SIZE_SMALL 320
|
||||
#define MAX_HDRSIZE sizeof(struct openpcd_hdr)
|
||||
|
||||
#include <stdint.h>
|
||||
#include "osmocom/core/linuxlist.h"
|
||||
|
||||
#define __ramfunc
|
||||
|
||||
enum req_ctx_state {
|
||||
/* free to be allocated */
|
||||
RCTX_S_FREE,
|
||||
|
||||
/* USB -> UART */
|
||||
/* In USB driver, waiting for data from host */
|
||||
RCTX_S_USB_RX_BUSY,
|
||||
/* somewhere in the main loop */
|
||||
RCTX_S_MAIN_PROCESSING,
|
||||
/* pending (in queue) for transmission on UART */
|
||||
RCTX_S_UART_TX_PENDING,
|
||||
/* currently in active transmission on UART */
|
||||
RCTX_S_UART_TX_BUSY,
|
||||
|
||||
/* UART -> USB */
|
||||
/* currently in active reception on UART */
|
||||
RCTX_S_UART_RX_BUSY,
|
||||
/* pending (in queue) for transmission over USB to host */
|
||||
RCTX_S_USB_TX_PENDING,
|
||||
/* currently in transmission over USB to host */
|
||||
RCTX_S_USB_TX_BUSY,
|
||||
|
||||
/* number of states */
|
||||
RCTX_STATE_COUNT
|
||||
};
|
||||
|
||||
struct req_ctx {
|
||||
/* if this req_ctx is on a queue... */
|
||||
struct llist_head list;
|
||||
uint32_t ep;
|
||||
|
||||
/* enum req_ctx_state */
|
||||
volatile uint32_t state;
|
||||
/* size of th 'data' buffer */
|
||||
uint16_t size;
|
||||
/* total number of used bytes in buffer */
|
||||
uint16_t tot_len;
|
||||
/* index into the buffer, user specific */
|
||||
uint16_t idx;
|
||||
/* actual data buffer */
|
||||
uint8_t *data;
|
||||
};
|
||||
|
||||
extern void req_ctx_init(void);
|
||||
extern struct req_ctx __ramfunc *req_ctx_find_get(int large, uint32_t old_state, uint32_t new_state);
|
||||
extern struct req_ctx *req_ctx_find_busy(void);
|
||||
extern void req_ctx_set_state(struct req_ctx *ctx, uint32_t new_state);
|
||||
extern void req_ctx_put(struct req_ctx *ctx);
|
||||
extern uint8_t req_ctx_num(struct req_ctx *ctx);
|
||||
unsigned int req_ctx_count(uint32_t state);
|
||||
23
firmware/libcommon/include/ringbuffer.h
Normal file
23
firmware/libcommon/include/ringbuffer.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef SIMTRACE_RINGBUF_H
|
||||
#define SIMTRACE_RINGBUF_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define RING_BUFLEN 128
|
||||
|
||||
typedef struct ringbuf {
|
||||
uint8_t buf[RING_BUFLEN];
|
||||
size_t ird;
|
||||
size_t iwr;
|
||||
} ringbuf;
|
||||
|
||||
void rbuf_reset(volatile ringbuf * rb);
|
||||
uint8_t rbuf_read(volatile ringbuf * rb);
|
||||
uint8_t rbuf_peek(volatile ringbuf * rb);
|
||||
void rbuf_write(volatile ringbuf * rb, uint8_t item);
|
||||
bool rbuf_is_empty(volatile ringbuf * rb);
|
||||
bool rbuf_is_full(volatile ringbuf * rb);
|
||||
|
||||
#endif /* end of include guard: SIMTRACE_RINGBUF_H */
|
||||
65
firmware/libcommon/include/syscalls.h
Normal file
65
firmware/libcommon/include/syscalls.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file syscalls.h
|
||||
*
|
||||
* Implementation of newlib syscall.
|
||||
*
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
extern caddr_t _sbrk ( int incr ) ;
|
||||
|
||||
extern int _close( int file ) ;
|
||||
|
||||
extern int _fstat( int file, struct stat *st ) ;
|
||||
|
||||
extern int _isatty( int file ) ;
|
||||
|
||||
extern int _lseek( int file, int ptr, int dir ) ;
|
||||
|
||||
extern int _read(int file, char *ptr, int len) ;
|
||||
|
||||
extern int _write( int file, char *ptr, int len ) ;
|
||||
|
||||
extern void mdelay(unsigned int msecs);
|
||||
18
firmware/libcommon/include/utils.h
Normal file
18
firmware/libcommon/include/utils.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
#ifdef __ARM
|
||||
#define local_irq_save(x) \
|
||||
({ \
|
||||
x = __get_PRIMASK(); \
|
||||
__disable_irq(); \
|
||||
})
|
||||
|
||||
#define local_irq_restore(x) \
|
||||
__set_PRIMASK(x)
|
||||
#else
|
||||
#warning "local_irq_{save,restore}() not implemented"
|
||||
#define local_irq_save(x)
|
||||
#define local_irq_restore(x)
|
||||
#endif
|
||||
Reference in New Issue
Block a user