Appearance
file /Users/ios_developer/workspace/coldwave-os/build/_deps/flake-src/portable/portable.h
Types
Name | |
---|---|
struct | flakeThreadAttr_t Attributes structure for thread. |
struct | flakeMutexAttr_t Attributes structure for mutex. |
enum | flakePriority_t |
enum | flakeTimerType_t |
typedef void * | flakeThreadId_t |
typedef void(*)(void *argument) | flakeThreadFunc_t |
typedef void * | flakeSemaphoreId_t |
typedef void * | flakeMutexId_t |
typedef void * | flakeMessageQueueId_t |
typedef void * | flakeTimerId_t |
typedef void(*)(void *argument) | flakeTimerFunc_t |
typedef void * | flakeTLSContext_t |
Functions Overview
Defines
Name | |
---|---|
flakeMutexRecursive | Recursive mutex. |
flakeWaitForever | Wait forever timeout value. |
Types Documentation
enum flakePriority_t
Enumerator | Description |
---|---|
flakeThreadPriorityNone | No priority (not initialized). |
flakeThreadPriorityIdle | Reserved for Idle thread. |
flakeThreadPriorityLow | Priority: low. |
flakeThreadPriorityBelowNormal | Priority: below normal. |
flakeThreadPriorityNormal | Priority: normal. |
flakeThreadPriorityAboveNormal | Priority: above normal. |
flakeThreadPriorityHigh | Priority: high. |
flakeThreadPriorityISR | Reserved for ISR deferred thread. |
flakeThreadPriorityError | System cannot determine priority or illegal priority. |
enum flakeTimerType_t
Enumerator | Description |
---|---|
flakeTimerOnce | One-shot timer. |
flakeTimerPeriodic | Repeating timer. |
typedef flakeThreadId_t
cpp
typedef void* flakeThreadId_t;
Thread ID identifies the thread.
typedef flakeThreadFunc_t
cpp
typedef void(* flakeThreadFunc_t) (void *argument);
typedef flakeSemaphoreId_t
cpp
typedef void* flakeSemaphoreId_t;
Semaphore ID identifies the semaphore.
typedef flakeMutexId_t
cpp
typedef void* flakeMutexId_t;
Mutex ID identifies the mutex.
typedef flakeMessageQueueId_t
cpp
typedef void* flakeMessageQueueId_t;
Message Queue ID identifies the message queue.
typedef flakeTimerId_t
cpp
typedef void* flakeTimerId_t;
typedef flakeTimerFunc_t
cpp
typedef void(* flakeTimerFunc_t) (void *argument);
typedef flakeTLSContext_t
cpp
typedef void* flakeTLSContext_t;
Function Details
function flakeThreadNew
cpp
int8_t flakeThreadNew(
flakeThreadId_t * thread_id,
flakeThreadFunc_t func,
void * argument,
const flakeThreadAttr_t * attr
)
function flakeThreadTerminate
cpp
int8_t flakeThreadTerminate(
flakeThreadId_t thread_id
)
function flakeSocketThreadSemaphoreCleanup
cpp
void flakeSocketThreadSemaphoreCleanup(
void
)
function flakeSocketThreadSemaphoreInit
cpp
void flakeSocketThreadSemaphoreInit(
void
)
function flakeThreadExit
cpp
void flakeThreadExit(
void
)
function flakeSemaphoreNew
cpp
int8_t flakeSemaphoreNew(
flakeSemaphoreId_t * semaphore_id,
uint32_t max_count,
uint32_t initial_count
)
function flakeSemaphoreAcquire
cpp
int8_t flakeSemaphoreAcquire(
flakeSemaphoreId_t semaphore_id,
int timeout
)
function flakeSemaphoreRelease
cpp
int8_t flakeSemaphoreRelease(
flakeSemaphoreId_t semaphore_id
)
function flakeSemaphoreDelete
cpp
int8_t flakeSemaphoreDelete(
flakeSemaphoreId_t semaphore_id
)
function flakeMutexNew
cpp
int8_t flakeMutexNew(
flakeMutexId_t * mutex_id,
const flakeMutexAttr_t * attr
)
function flakeMutexRelease
cpp
int8_t flakeMutexRelease(
flakeMutexId_t mutex_id
)
function flakeMutexAcquire
cpp
int8_t flakeMutexAcquire(
flakeMutexId_t mutex_id
)
function flakeMutexDelete
cpp
int8_t flakeMutexDelete(
flakeMutexId_t mutex_id
)
function flakeMessageQueueNew
cpp
int8_t flakeMessageQueueNew(
flakeMessageQueueId_t * mq_id,
uint32_t msg_count,
uint32_t msg_size
)
function flakeMessageQueueDelete
cpp
int8_t flakeMessageQueueDelete(
flakeMessageQueueId_t mq_id
)
function flakeMessageQueueGetCount
cpp
uint32_t flakeMessageQueueGetCount(
flakeMessageQueueId_t mq_id
)
function flakeMessageQueueReset
cpp
int8_t flakeMessageQueueReset(
flakeMessageQueueId_t mq_id
)
function flakeMessageQueuePut
cpp
int8_t flakeMessageQueuePut(
flakeMessageQueueId_t mq_id,
const void * msg_ptr,
uint8_t msg_prio,
uint32_t timeout
)
function flakeMessageQueueGet
cpp
int8_t flakeMessageQueueGet(
flakeMessageQueueId_t mq_id,
void * msg_ptr,
uint8_t * msg_prio,
uint32_t timeout
)
function flakeTimerNew
cpp
flakeTimerId_t flakeTimerNew(
flakeTimerFunc_t func,
flakeTimerType_t type,
void * argument
)
function flakeTimerStart
cpp
int8_t flakeTimerStart(
flakeTimerId_t timer_id,
uint32_t ticks
)
function flakePortableLog
cpp
void flakePortableLog(
const char * format,
va_list args
)
function flakeThreadId
cpp
unsigned flakeThreadId()
function flakeUSleep
cpp
void flakeUSleep(
uint32_t us
)
function flakeTLSSetCACert
cpp
int flakeTLSSetCACert(
flakeTLSContext_t * ctx,
unsigned char * x509_ca_cert,
unsigned int x509_ca_cert_len
)
function flakeTLSSetOwnCert
cpp
int flakeTLSSetOwnCert(
flakeTLSContext_t * ctx,
unsigned char * x509_cert,
unsigned int x509_cert_len,
unsigned char * pk_key,
unsigned int pk_key_len
)
function flakeTLSContextCreate
cpp
int flakeTLSContextCreate(
flakeTLSContext_t * ctx,
int server_context
)
function flakeTLSConnectionBind
cpp
int flakeTLSConnectionBind(
flakeTLSContext_t * ctx,
const char * ip,
const char * port
)
function flakeTLSConnectionAccept
cpp
int flakeTLSConnectionAccept(
flakeTLSContext_t * ctx,
flakeTLSContext_t * client
)
function flakeTLSConnectionOpen
cpp
int flakeTLSConnectionOpen(
flakeTLSContext_t * ctx,
const char * host,
const char * port
)
function flakeTLSConnectionWrite
cpp
size_t flakeTLSConnectionWrite(
flakeTLSContext_t * ctx,
const unsigned char * buf,
size_t len
)
function flakeTLSConnectionRead
cpp
size_t flakeTLSConnectionRead(
flakeTLSContext_t * ctx,
unsigned char * buf,
size_t len
)
function flakeTLSConnectionClose
cpp
void flakeTLSConnectionClose(
flakeTLSContext_t * ctx
)
function flakeTLSContextFree
cpp
void flakeTLSContextFree(
flakeTLSContext_t * ctx
)
function flakeDTLSConnectionInit
cpp
int flakeDTLSConnectionInit(
flakeTLSContext_t * ctx
)
function flakeDTLSConnectionOpen
cpp
int flakeDTLSConnectionOpen(
flakeTLSContext_t * ctx,
const char * host,
const char * port
)
function flakeDTLSConnectionWrite
cpp
size_t flakeDTLSConnectionWrite(
flakeTLSContext_t * ctx,
const unsigned char * buf,
size_t len
)
function flakeDTLSConnectionRead
cpp
size_t flakeDTLSConnectionRead(
flakeTLSContext_t * ctx,
unsigned char * buf,
size_t len
)
function flakeDTLSConnectionClose
cpp
void flakeDTLSConnectionClose(
flakeTLSContext_t * ctx
)
function flakeMSTickCount
cpp
uint32_t flakeMSTickCount()
function flakeRandom
cpp
unsigned flakeRandom()
Macros Documentation
define flakeMutexRecursive
cpp
#define flakeMutexRecursive 0x00000001U
Recursive mutex.
define flakeWaitForever
cpp
#define flakeWaitForever 0xFFFFFFFFU
Wait forever timeout value.
Source code
cpp
//
// Created by Sebastian Floss on 28.12.18.
// Copyright (c) 2018 ImagineOn GmbH. All rights reserved.
//
#ifndef XOS_PORTABLE_H
#define XOS_PORTABLE_H
#include <inttypes.h>
#include <wchar.h>
#include <stdarg.h>
#define flakeMutexRecursive 0x00000001U
#define flakeWaitForever 0xFFFFFFFFU
#if defined (__cplusplus)
extern "C" {
#endif
//--------------
//
// Threads
//
typedef void *flakeThreadId_t;
typedef enum {
flakeThreadPriorityNone = 0,
flakeThreadPriorityIdle = 1,
flakeThreadPriorityLow = 8,
flakeThreadPriorityBelowNormal = 16,
flakeThreadPriorityNormal = 24,
flakeThreadPriorityAboveNormal = 32,
flakeThreadPriorityHigh = 40,
flakeThreadPriorityISR = 56,
flakeThreadPriorityError = -1,
} flakePriority_t;
typedef struct {
const char *name;
uint32_t attr_bits;
void *cb_mem;
uint32_t cb_size;
void *stack_mem;
uint32_t stack_size;
flakePriority_t priority;
uint32_t tz_module;
uint32_t reserved;
} flakeThreadAttr_t;
typedef void (*flakeThreadFunc_t) (void *argument);
int8_t
flakeThreadNew (flakeThreadId_t *thread_id, flakeThreadFunc_t func, void *argument, const flakeThreadAttr_t *attr);
int8_t
flakeThreadTerminate (flakeThreadId_t thread_id);
void
flakeSocketThreadSemaphoreCleanup (void);
void
flakeSocketThreadSemaphoreInit (void);
void
flakeThreadExit (void);
//--------------
//
// Semaphores
//
typedef void *flakeSemaphoreId_t;
int8_t
flakeSemaphoreNew (flakeSemaphoreId_t *semaphore_id, uint32_t max_count, uint32_t initial_count);
int8_t
flakeSemaphoreAcquire (flakeSemaphoreId_t semaphore_id, int timeout);
int8_t
flakeSemaphoreRelease (flakeSemaphoreId_t semaphore_id);
int8_t
flakeSemaphoreDelete (flakeSemaphoreId_t semaphore_id);
//--------------
//
// Mutexes
//
typedef void *flakeMutexId_t;
typedef struct {
const char *name;
uint32_t attr_bits;
void *cb_mem;
uint32_t cb_size;
} flakeMutexAttr_t;
int8_t
flakeMutexNew (flakeMutexId_t *mutex_id, const flakeMutexAttr_t *attr);
int8_t
flakeMutexRelease (flakeMutexId_t mutex_id);
int8_t
flakeMutexAcquire (flakeMutexId_t mutex_id);
int8_t
flakeMutexDelete (flakeMutexId_t mutex_id);
//--------------
//
// Queues
//
typedef void *flakeMessageQueueId_t;
int8_t
flakeMessageQueueNew (flakeMessageQueueId_t *mq_id, uint32_t msg_count, uint32_t msg_size);
int8_t
flakeMessageQueueDelete (flakeMessageQueueId_t mq_id);
uint32_t
flakeMessageQueueGetCount (flakeMessageQueueId_t mq_id);
int8_t
flakeMessageQueueReset (flakeMessageQueueId_t mq_id);
int8_t
flakeMessageQueuePut (flakeMessageQueueId_t mq_id, const void *msg_ptr, uint8_t msg_prio, uint32_t timeout);
int8_t
flakeMessageQueueGet (flakeMessageQueueId_t mq_id, void *msg_ptr, uint8_t *msg_prio, uint32_t timeout);
//--------------
//
// Timers
//
typedef void *flakeTimerId_t;
typedef enum {
flakeTimerOnce = 0,
flakeTimerPeriodic = 1
} flakeTimerType_t;
typedef void (*flakeTimerFunc_t) (void *argument);
flakeTimerId_t
flakeTimerNew (flakeTimerFunc_t func, flakeTimerType_t type, void *argument);
int8_t
flakeTimerStart (flakeTimerId_t timer_id, uint32_t ticks);
//--------------
//
// Generic
//
void flakePortableLog (const char *format, va_list args);
unsigned flakeThreadId();
void flakeUSleep (uint32_t us);
//--------------
//
// TLS
//
typedef void *flakeTLSContext_t;
int
flakeTLSSetCACert (flakeTLSContext_t *ctx, unsigned char *x509_ca_cert, unsigned int x509_ca_cert_len);
int
flakeTLSSetOwnCert (flakeTLSContext_t *ctx, unsigned char *x509_cert, unsigned int x509_cert_len,
unsigned char *pk_key, unsigned int pk_key_len);
int
flakeTLSContextCreate (flakeTLSContext_t *ctx, int server_context);
int
flakeTLSConnectionBind (flakeTLSContext_t *ctx, const char *ip, const char *port);
int
flakeTLSConnectionAccept (flakeTLSContext_t *ctx, flakeTLSContext_t *client);
int
flakeTLSConnectionOpen (flakeTLSContext_t *ctx, const char *host, const char *port);
size_t
flakeTLSConnectionWrite (flakeTLSContext_t *ctx, const unsigned char *buf, size_t len);
size_t
flakeTLSConnectionRead (flakeTLSContext_t *ctx, unsigned char *buf, size_t len);
void
flakeTLSConnectionClose (flakeTLSContext_t *ctx);
void
flakeTLSContextFree (flakeTLSContext_t *ctx);
//--------------
//
// DTLS
//
int
flakeDTLSConnectionInit (flakeTLSContext_t *ctx);
int
flakeDTLSConnectionOpen (flakeTLSContext_t *ctx, const char *host, const char *port);
size_t
flakeDTLSConnectionWrite (flakeTLSContext_t *ctx, const unsigned char *buf, size_t len);
size_t
flakeDTLSConnectionRead (flakeTLSContext_t *ctx, unsigned char *buf, size_t len);
void
flakeDTLSConnectionClose (flakeTLSContext_t *ctx);
uint32_t
flakeMSTickCount ();
unsigned
flakeRandom();
#if FLAKE_BLE_ECDH_CRPTO
typedef uint8_t[32] flakeCryptoUINT256_t;
void flakeCryptoECDHGenerateOwnPubkey ( flakeCryptoUINT256_t * client_public_dh_key );
int flakeCryptoECDHGenerateAESKey ( flakeCryptoUINT256_t const * server_public_dh_key, flakeCryptoUINT256_t ** aes_encryption_key) ;
#endif
#if defined (__cplusplus)
}
#endif
#endif //XOS_PORTABLE_H