Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
/*
* util.h
*
* Utility definitions.
*
* Written & released by Keir Fraser <keir.xen@gmail.com>
*
* This is free and unencumbered software released into the public domain.
* See the file COPYING for more details, or visit <http://unlicense.org>.
*/
#define ASSERT(p) if (!(p)) illegal();
typedef char bool_t;
#define TRUE 1
#define FALSE 0
#ifndef offsetof
#define offsetof(a,b) __builtin_offsetof(a,b)
#endif
#define container_of(ptr, type, member) ({ \
typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#define min(x,y) ({ \
const typeof(x) _x = (x); \
const typeof(y) _y = (y); \
(void) (&_x == &_y); \
_x < _y ? _x : _y; })
#define max(x,y) ({ \
const typeof(x) _x = (x); \
const typeof(y) _y = (y); \
(void) (&_x == &_y); \
_x > _y ? _x : _y; })
#define min_t(type,x,y) \
({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
#define max_t(type,x,y) \
({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
void *memset(void *s, int c, size_t n);
void *memcpy(void *dest, const void *src, size_t n);
void *memmove(void *dest, const void *src, size_t n);
int strcmp(const char *s1, const char *s2);
int strncmp(const char *s1, const char *s2, size_t n);
char *strrchr(const char *s, int c);
int tolower(int c);
uint16_t crc16_ccitt(const void *buf, size_t len, uint16_t crc);
int vsnprintf(char *str, size_t size, const char *format, va_list ap)
__attribute__ ((format (printf, 3, 0)));
int vprintk(const char *format, va_list ap)
__attribute__ ((format (printf, 1, 0)));
int printk(const char *format, ...)
__attribute__ ((format (printf, 1, 2)));
#define le16toh(x) (x)
#define le32toh(x) (x)
#define htole16(x) (x)
#define htole32(x) (x)
#define be16toh(x) _rev16(x)
#define be32toh(x) _rev32(x)
#define htobe16(x) _rev16(x)
#define htobe32(x) _rev32(x)
void console_init(void);
void console_sync(void);
void console_barrier(void);
void speaker_init(void);
void speaker_pulses(uint8_t nr);
void rom_bank_set(unsigned int bank);
void recall_init(void);
unsigned int recall_get(void);
void recall_set(unsigned int image);
void recall_erase(void);
/* Configuration. */
void config_init(void);
extern struct ksw_config {
uint16_t reset_delays[3]; /* reset delay to switch (ms) */
uint16_t long_beep; /* long beep length (ms) */
uint8_t volumes[3]; /* beeper volume */
uint8_t nr_images; /* # images to cycle between */
uint8_t image_map[8]; /* which rom bank addressed by each image # */
uint8_t menu_rom_bank; /* which rom bank addressed during menu */
uint8_t image_recall; /* remember last image across reset/power-off? */
uint16_t crc16_ccitt;
} ksw_config;
/* Text/data/BSS address ranges. */
extern char _stext[], _etext[];
extern char _sdat[], _edat[], _ldat[];
extern char _sbss[], _ebss[];
/* Stacks. */
extern uint32_t _thread_stacktop[], _thread_stackbottom[];
extern uint32_t _irq_stacktop[], _irq_stackbottom[];
/* IRQ priorities, 0 (highest) to 15 (lowest). */
#define TIMER_IRQ_PRI 8
#define CONSOLE_IRQ_PRI 14
/*
* Local variables:
* mode: C
* c-file-style: "Linux"
* c-basic-offset: 4
* tab-width: 4
* indent-tabs-mode: nil
* End:
*/
28c442cecThis file is pinned to the selected release. Download the original to open it in your design tool.