#define OS_ID win32
// FIXME: Maybe disable Win32 exceptions?
- typedef int cpuflags_t;
+ typedef int cpu_flags_t;
#define IRQ_DISABLE FIXME
#define IRQ_ENABLE FIXME
#define IRQ_SAVE_DISABLE(old_sigs) FIXME
* The POSIX moral equivalent of disabling IRQs is disabling signals.
*/
#include <signal.h>
- typedef sigset_t cpuflags_t;
+ typedef sigset_t cpu_flags_t;
#define SET_ALL_SIGNALS(sigs) \
do { \
{
struct ArmSerial *hw = (struct ArmSerial *)_hw;
- cpuflags_t flags;
+ cpu_flags_t flags;
IRQ_SAVE_DISABLE(flags);
/* Send data only if the SPI is not already transmitting */
{
struct ArmSerial *hw = (struct ArmSerial *)_hw;
- cpuflags_t flags;
+ cpu_flags_t flags;
IRQ_SAVE_DISABLE(flags);
/* Send data only if the SPI is not already transmitting */
*motor->timer->comp_c_reg = 0;
//Register interrupt vector
- cpuflags_t flags;
+ cpu_flags_t flags;
IRQ_SAVE_DISABLE(flags);
/*
TC2_RA = 0;
TC2_RB = 0;
- cpuflags_t flags;
+ cpu_flags_t flags;
IRQ_SAVE_DISABLE(flags);
/* Set the vector. */
*/
void sysirq_init(void)
{
- cpuflags_t flags;
+ cpu_flags_t flags;
IRQ_SAVE_DISABLE(flags);
/* Disable all system interrupts */
{
sysirq_init();
- cpuflags_t flags;
+ cpu_flags_t flags;
MOD_CHECK(sysirq);
#define KDBG_WRITE_CHAR(c) _kdebug_bitbang_putchar((c))
#define KDBG_MASK_IRQ(old) do { IRQ_SAVE_DISABLE((old)); } while(0)
#define KDBG_RESTORE_IRQ(old) do { IRQ_RESTORE((old)); } while(0)
- typedef cpuflags_t kdbg_irqsave_t;
+ typedef cpu_flags_t kdbg_irqsave_t;
#define KDBG_DELAY (((CLOCK_FREQ + CONFIG_KDEBUG_BAUDRATE / 2) / CONFIG_KDEBUG_BAUDRATE) + 7) / 14
MOD_CHECK(timer);
// FIXME: interrupts are already disabled when we get here?!?
- cpuflags_t flags;
+ cpu_flags_t flags;
IRQ_SAVE_DISABLE(flags);
PORTB |= BV(LCD_PB_A0);
{
struct AvrSerial *hw = (struct AvrSerial *)_hw;
- cpuflags_t flags;
+ cpu_flags_t flags;
IRQ_SAVE_DISABLE(flags);
/* Send data only if the SPI is not already transmitting */
static void timer_hw_init(void)
{
- cpuflags_t flags;
+ cpu_flags_t flags;
IRQ_SAVE_DISABLE(flags);
/* Reset Timer flags */
static void timer_hw_init(void)
{
- cpuflags_t flags;
+ cpu_flags_t flags;
IRQ_SAVE_DISABLE(flags);
/* Reset Timer overflow flag */
#elif (CONFIG_TIMER == TIMER_ON_OUTPUT_COMPARE2)
static void timer_hw_init(void)
{
- cpuflags_t flags;
+ cpu_flags_t flags;
IRQ_SAVE_DISABLE(flags);
/* Reset Timer flags */
static void timer_hw_init(void)
{
- cpuflags_t flags;
+ cpu_flags_t flags;
IRQ_SAVE_DISABLE(flags);
/* Reset Timer overflow flag */
#if !CPU_SP_ON_EMPTY_SLOT
/* DSP56K and other weirdos */
#define CPU_PUSH_WORD(sp, data) \
- do { *++(sp) = (cpustack_t)(data); } while (0)
+ do { *++(sp) = (cpu_stack_t)(data); } while (0)
#define CPU_POP_WORD(sp) \
(*(sp)--)
#else
#define CPU_PUSH_CALL_FRAME(sp, func) \
do { \
- CPU_PUSH_WORD((sp), (cpustack_t)(func)); /* LR -> 8(SP) */ \
+ CPU_PUSH_WORD((sp), (cpu_stack_t)(func)); /* LR -> 8(SP) */ \
CPU_PUSH_WORD((sp), 0); /* CR -> 4(SP) */ \
} while (0)
#else
#define CPU_PUSH_CALL_FRAME(sp, func) \
- CPU_PUSH_WORD((sp), (cpustack_t)(func))
+ CPU_PUSH_WORD((sp), (cpu_stack_t)(func))
#endif
/**
#if __CPU_MODE__ == 1 /* Thumb */
/* Use stubs */
- extern cpuflags_t get_CPSR(void);
- extern void set_CPSR(cpuflags_t flags);
+ extern cpu_flags_t get_CPSR(void);
+ extern void set_CPSR(cpu_flags_t flags);
#else
#define get_CPSR __get_CPSR
#define set_CPSR __set_CPSR
#define CPU_READ_FLAGS() \
({ \
- cpuflags_t sreg; \
+ cpu_flags_t sreg; \
asm volatile ( \
"mrs %0, cpsr\n\t" \
: "=r" (sreg) \
*/
#define ATOMIC(CODE) \
do { \
- cpuflags_t __flags; \
+ cpu_flags_t __flags; \
IRQ_SAVE_DISABLE(__flags); \
CODE; \
IRQ_RESTORE(__flags); \
#if CPU_I196
- typedef uint16_t cpuflags_t; // FIXME
- typedef unsigned int cpustack_t;
- typedef unsigned int cpuatomic_t;
+ typedef uint16_t cpu_flags_t; // FIXME
+ typedef unsigned int cpu_stack_t;
+ typedef unsigned int cpu_atomic_t;
#warning Verify following constant
#define SIZEOF_CPUSTACK_T 2
#elif CPU_X86
- /* Get cpuflags_t definition from the hosting environment. */
+ /* Get cpu_flags_t definition from the hosting environment. */
#include <cfg/os.h>
#if OS_EMBEDDED
- typedef uint32_t cpuflags_t; // FIXME
+ typedef uint32_t cpu_flags_t; // FIXME
#endif /* OS_EMBEDDED */
- typedef uint32_t cpuatomic_t;
+ typedef uint32_t cpu_atomic_t;
#if CPU_X86_64
- typedef uint64_t cpustack_t;
+ typedef uint64_t cpu_stack_t;
#define SIZEOF_CPUSTACK_T 8
#else
- typedef uint32_t cpustack_t;
+ typedef uint32_t cpu_stack_t;
#define SIZEOF_CPUSTACK_T 4
#endif
#elif CPU_ARM
- typedef uint32_t cpuflags_t;
- typedef uint32_t cpuatomic_t;
- typedef uint32_t cpustack_t;
+ typedef uint32_t cpu_flags_t;
+ typedef uint32_t cpu_atomic_t;
+ typedef uint32_t cpu_stack_t;
#define SIZEOF_CPUSTACK_T 4
#elif CPU_PPC
- /* Get cpuflags_t definition from the hosting environment. */
+ /* Get cpu_flags_t definition from the hosting environment. */
#include <cfg/os.h>
#if OS_EMBEDDED
- typedef uint32_t cpuflags_t;
+ typedef uint32_t cpu_flags_t;
#endif
- typedef uint32_t cpuatomic_t;
- typedef uint32_t cpustack_t;
+ typedef uint32_t cpu_atomic_t;
+ typedef uint32_t cpu_stack_t;
#define SIZEOF_CPUSTACK_T 4
#elif CPU_DSP56K
- typedef uint16_t cpuflags_t;
- typedef uint16_t cpuatomic_t;
- typedef unsigned int cpustack_t;
+ typedef uint16_t cpu_flags_t;
+ typedef uint16_t cpu_atomic_t;
+ typedef unsigned int cpu_stack_t;
#warning Verify following costant
#define SIZEOF_CPUSTACK_T 2
#elif CPU_AVR
- typedef uint8_t cpuflags_t;
- typedef uint8_t cpuatomic_t;
- typedef uint8_t cpustack_t;
+ typedef uint8_t cpu_flags_t;
+ typedef uint8_t cpu_atomic_t;
+ typedef uint8_t cpu_stack_t;
#define SIZEOF_CPUSTACK_T 1
#else
STATIC_ASSERT(sizeof(int64_t) * CPU_BITS_PER_CHAR == 64);
STATIC_ASSERT(sizeof(uint64_t) * CPU_BITS_PER_CHAR == 64);
#endif
-STATIC_ASSERT(sizeof(cpustack_t) == SIZEOF_CPUSTACK_T);
+STATIC_ASSERT(sizeof(cpu_stack_t) == SIZEOF_CPUSTACK_T);
#endif /* CPU_TYPES_H */
*/
void buz_beep(mtime_t time)
{
- cpuflags_t flags;
+ cpu_flags_t flags;
IRQ_SAVE_DISABLE(flags);
/* Remove the software interrupt if it was already queued */
*/
void buz_repeat_stop(void)
{
- cpuflags_t flags;
+ cpu_flags_t flags;
IRQ_SAVE_DISABLE(flags);
/* Remove the software interrupt if it was already queued */
static DCMotor dcm_all[CONFIG_NUM_DC_MOTOR];
/// Stack process for DC motor poll.
-static cpustack_t dc_motor_poll_stack[200];
+static cpu_stack_t dc_motor_poll_stack[200];
///< Sample period for all DC motor.
static mtime_t sample_period;
KbdHandler *node;
List *list;
- cpuflags_t flags;
+ cpu_flags_t flags;
IRQ_SAVE_DISABLE(flags);
/* Choose between raw and coocked handlers list */
*/
void phase_setDuty(TriacDev dev, triac_duty_t duty)
{
- cpuflags_t flags;
+ cpu_flags_t flags;
IRQ_SAVE_DISABLE(flags);
phase_setDutyUnlock(dev,duty);
*/
void phase_init(void)
{
- cpuflags_t flags;
+ cpu_flags_t flags;
TriacDev dev;
/* Init timers and ensure that all triac are off */
*/
void pwm_init(void)
{
- cpuflags_t flags;
+ cpu_flags_t flags;
PwmDev dev;
IRQ_SAVE_DISABLE(flags);
void timer_add(Timer *timer)
{
Timer *node;
- cpuflags_t flags;
+ cpu_flags_t flags;
/* Inserting timers twice causes mayhem. */
INLINE void lcd_bus_init(void)
{
- cpuflags_t flags;
+ cpu_flags_t flags;
IRQ_SAVE_DISABLE(flags);
/*
* Saving and restoring the context on the stack is done by a CPU-dependent
* support routine which usually needs to be written in assembly.
*/
-EXTERN_C void asm_switch_context(cpustack_t **new_sp, cpustack_t **save_sp);
+EXTERN_C void asm_switch_context(cpu_stack_t **new_sp, cpu_stack_t **save_sp);
/**
*/
static void proc_schedule(void)
{
- cpuflags_t flags;
+ cpu_flags_t flags;
ATOMIC(LIST_ASSERT_VALID(&ProcReadyList));
ASSERT_USER_CONTEXT();
*/
if (CurrentProcess != old_process)
{
- cpustack_t *dummy;
+ cpu_stack_t *dummy;
#if CONFIG_KERN_MONITOR
LOG_INFO("Switch from %p(%s) to %p(%s)\n",
#include <cfg/module.h>
-static cpustack_t idle_stack[CONFIG_KERN_MINSTACKSIZE / sizeof(cpustack_t)];
+static cpu_stack_t idle_stack[CONFIG_KERN_MINSTACKSIZE / sizeof(cpu_stack_t)];
/**
* The idle process
proc->monitor.name = name;
}
-size_t monitor_checkStack(cpustack_t *stack_base, size_t stack_size)
+size_t monitor_checkStack(cpu_stack_t *stack_base, size_t stack_size)
{
- cpustack_t *beg;
- cpustack_t *cur;
- cpustack_t *end;
+ cpu_stack_t *beg;
+ cpu_stack_t *cur;
+ cpu_stack_t *end;
int inc;
size_t sp_free;
beg = stack_base;
- end = stack_base + stack_size / sizeof(cpustack_t);
+ end = stack_base + stack_size / sizeof(cpu_stack_t);
inc = +1;
if (CPU_STACK_GROWS_UPWARD)
cur += inc;
}
- sp_free = ABS(cur - beg) * sizeof(cpustack_t);
+ sp_free = ABS(cur - beg) * sizeof(cpu_stack_t);
return sp_free;
}
}
-void monitor_start(size_t stacksize, cpustack_t *stack)
+void monitor_start(size_t stacksize, cpu_stack_t *stack)
{
proc_new(monitor, NULL, stacksize, stack);
}
* \note The stack is provided by the caller so that there is no wasted space if the monitor
* is not used.
*/
-void monitor_start(size_t stacksize, cpustack_t *stack);
+void monitor_start(size_t stacksize, cpu_stack_t *stack);
/**
* \note For this function to work, the stack must have been filled at startup with
* CONFIG_KERN_STACKFILLCODE.
*/
-size_t monitor_checkStack(cpustack_t *stack_base, size_t stack_size);
+size_t monitor_checkStack(cpu_stack_t *stack_base, size_t stack_size);
/** Print a report of the stack status through kdebug */
MOD_DEFINE(preempt)
/// Global preemption disabling nesting counter
-cpuatomic_t _preempt_forbid_cnt;
+cpu_atomic_t _preempt_forbid_cnt;
static Timer preempt_timer;
List StackFreeList;
#define NPROC 8
-cpustack_t proc_stacks[NPROC][(64 * 1024) / sizeof(cpustack_t)];
+cpu_stack_t proc_stacks[NPROC][(64 * 1024) / sizeof(cpu_stack_t)];
#endif
/** The main process (the one that executes main()). */
* \return Process structure of new created process
* if successful, NULL otherwise.
*/
-struct Process *proc_new_with_name(UNUSED_ARG(const char *, name), void (*entry)(void), iptr_t data, size_t stack_size, cpustack_t *stack_base)
+struct Process *proc_new_with_name(UNUSED_ARG(const char *, name), void (*entry)(void), iptr_t data, size_t stack_size, cpu_stack_t *stack_base)
{
Process *proc;
- const size_t PROC_SIZE_WORDS = ROUND_UP2(sizeof(Process), sizeof(cpustack_t)) / sizeof(cpustack_t);
+ const size_t PROC_SIZE_WORDS = ROUND_UP2(sizeof(Process), sizeof(cpu_stack_t)) / sizeof(cpu_stack_t);
#if CONFIG_KERN_HEAP
bool free_stack = false;
#endif
#if (ARCH & ARCH_EMUL)
/* Ignore stack provided by caller and use the large enough default instead. */
- PROC_ATOMIC(stack_base = (cpustack_t *)list_remHead(&StackFreeList));
+ PROC_ATOMIC(stack_base = (cpu_stack_t *)list_remHead(&StackFreeList));
stack_size = CONFIG_KERN_MINSTACKSIZE;
#elif CONFIG_KERN_HEAP
}
else
{
- proc = (Process *)(stack_base + stack_size / sizeof(cpustack_t) - PROC_SIZE_WORDS);
- proc->stack = (cpustack_t *)proc;
+ proc = (Process *)(stack_base + stack_size / sizeof(cpu_stack_t) - PROC_SIZE_WORDS);
+ proc->stack = (cpu_stack_t *)proc;
if (CPU_SP_ON_EMPTY_SLOT)
proc->stack--;
}
#include <cfg/debug.h> // ASSERT()
#endif
-#include <cpu/types.h> // cpustack_t
+#include <cpu/types.h> // cpu_stack_t
#include <cpu/frame.h> // CPU_SAVED_REGS_CNT
/*
/* Task scheduling services */
void proc_init(void);
-struct Process *proc_new_with_name(const char* name, void (*entry)(void), iptr_t data, size_t stacksize, cpustack_t *stack);
+struct Process *proc_new_with_name(const char* name, void (*entry)(void), iptr_t data, size_t stacksize, cpu_stack_t *stack);
#if !CONFIG_KERN_MONITOR
#define proc_new(entry,data,size,stack) proc_new_with_name(NULL,(entry),(data),(size),(stack))
INLINE void proc_forbid(void)
{
#if CONFIG_KERN_PREEMPT
- extern cpuatomic_t _preempt_forbid_cnt;
+ extern cpu_atomic_t _preempt_forbid_cnt;
/*
* We don't need to protect the counter against other processes.
* The reason why is a bit subtle.
* flushed to memory before task switching is re-enabled.
*/
MEMORY_BARRIER;
- extern cpuatomic_t _preempt_forbid_cnt;
+ extern cpu_atomic_t _preempt_forbid_cnt;
/* No need to protect against interrupts here. */
ASSERT(_preempt_forbid_cnt != 0);
--_preempt_forbid_cnt;
INLINE bool proc_allowed(void)
{
#if CONFIG_KERN_PREEMPT
- extern cpuatomic_t _preempt_forbid_cnt;
+ extern cpu_atomic_t _preempt_forbid_cnt;
return (_preempt_forbid_cnt == 0);
#else
return true;
* usage.
*/
#define CONFIG_KERN_MINSTACKSIZE \
- (CPU_SAVED_REGS_CNT * 2 * sizeof(cpustack_t) \
+ (CPU_SAVED_REGS_CNT * 2 * sizeof(cpu_stack_t) \
+ 32 * sizeof(int))
#endif
#endif
#if CONFIG_KERN_MONITOR
#include <cpu/types.h>
#if (SIZEOF_CPUSTACK_T == 1)
- /* 8bit cpustack_t */
+ /* 8bit cpu_stack_t */
#define CONFIG_KERN_STACKFILLCODE 0xA5
#define CONFIG_KERN_MEMFILLCODE 0xDB
#elif (SIZEOF_CPUSTACK_T == 2)
- /* 16bit cpustack_t */
+ /* 16bit cpu_stack_t */
#define CONFIG_KERN_STACKFILLCODE 0xA5A5
#define CONFIG_KERN_MEMFILLCODE 0xDBDB
#elif (SIZEOF_CPUSTACK_T == 4)
- /* 32bit cpustack_t */
+ /* 32bit cpu_stack_t */
#define CONFIG_KERN_STACKFILLCODE 0xA5A5A5A5UL
#define CONFIG_KERN_MEMFILLCODE 0xDBDBDBDBUL
#elif (SIZEOF_CPUSTACK_T == 8)
- /* 64bit cpustack_t */
+ /* 64bit cpu_stack_t */
#define CONFIG_KERN_STACKFILLCODE 0xA5A5A5A5A5A5A5A5ULL
#define CONFIG_KERN_MEMFILLCODE 0xDBDBDBDBDBDBDBDBULL
#else
- #error No cpustack_t size supported!
+ #error No cpu_stack_t size supported!
#endif
#endif
#else
Node link; /**< Link Process into scheduler lists */
#endif
- cpustack_t *stack; /**< Per-process SP */
+ cpu_stack_t *stack; /**< Per-process SP */
iptr_t user_data; /**< Custom data passed to the process */
#if CONFIG_KERN_SIGNALS
#endif
#if CONFIG_KERN_HEAP | CONFIG_KERN_MONITOR | (ARCH & ARCH_EMUL)
- cpustack_t *stack_base; /**< Base of process stack */
+ cpu_stack_t *stack_base; /**< Base of process stack */
size_t stack_size; /**< Size of process stack */
#endif
}
}
-static cpustack_t proc_test1_stack[CONFIG_KERN_MINSTACKSIZE / sizeof(cpustack_t)];
-static cpustack_t proc_test2_stack[CONFIG_KERN_MINSTACKSIZE / sizeof(cpustack_t)];
+static cpu_stack_t proc_test1_stack[CONFIG_KERN_MINSTACKSIZE / sizeof(cpu_stack_t)];
+static cpu_stack_t proc_test2_stack[CONFIG_KERN_MINSTACKSIZE / sizeof(cpu_stack_t)];
/**
sigmask_t sig_check(sigmask_t sigs)
{
sigmask_t result;
- cpuflags_t flags;
+ cpu_flags_t flags;
IRQ_SAVE_DISABLE(flags);
result = CurrentProcess->sig_recv & sigs;
sigmask_t sig_wait(sigmask_t sigs)
{
sigmask_t result;
- cpuflags_t flags;
+ cpu_flags_t flags;
/* Sleeping with IRQs disabled or preemption forbidden is illegal */
IRQ_ASSERT_ENABLED();
{
Timer t;
sigmask_t res;
- cpuflags_t flags;
+ cpu_flags_t flags;
ASSERT(!sig_check(SIG_TIMEOUT));
ASSERT(!(sigs & SIG_TIMEOUT));
*/
void sig_signal(Process *proc, sigmask_t sigs)
{
- cpuflags_t flags;
+ cpu_flags_t flags;
/* See comment in sig_wait() for why this protection is necessary */
IRQ_SAVE_DISABLE(flags);
void observer_notify(Subject *subject, int event_id, void *param)
{
Observer *observer;
- cpuflags_t irqstate;
+ cpu_flags_t irqstate;
IRQ_SAVE_DISABLE(irqstate);
/*