ADT
aaron-thesis
arm-eh
ast-experimental
cleanup-dtors
deferred_resn
demangler
enum
forall-pointer-decay
jacob/cs343-translation
jenkins-sandbox
new-ast
new-ast-unique-expr
new-env
no_list
persistent-indexer
pthread-emulation
qualifiedEnum
resolv-new
with_gc
|
Last change
on this file since eb2e723 was eb2e723, checked in by Thierry Delisle <tdelisle@…>, 9 years ago |
|
First prototype of kernel with proper startup and shutdown, not yet implemented for i386
|
-
Property mode
set to
100644
|
|
File size:
1.8 KB
|
| Line | |
|---|
| 1 | #include <stdbool.h>
|
|---|
| 2 | #include <stdint.h>
|
|---|
| 3 |
|
|---|
| 4 | #ifdef __CFORALL__
|
|---|
| 5 | extern "C" {
|
|---|
| 6 | #endif
|
|---|
| 7 |
|
|---|
| 8 | #if ! defined(__CFA_INVOKE_PRIVATE__)
|
|---|
| 9 | #ifndef _INVOKE_H_
|
|---|
| 10 | #define _INVOKE_H_
|
|---|
| 11 |
|
|---|
| 12 | #define unlikely(x) __builtin_expect(!!(x), 0)
|
|---|
| 13 |
|
|---|
| 14 | struct coStack_t {
|
|---|
| 15 | unsigned int size; // size of stack
|
|---|
| 16 | void *storage; // pointer to stack
|
|---|
| 17 | void *limit; // stack grows towards stack limit
|
|---|
| 18 | void *base; // base of stack
|
|---|
| 19 | void *context; // address of cfa_context_t
|
|---|
| 20 | void *top; // address of top of storage
|
|---|
| 21 | bool userStack;
|
|---|
| 22 | };
|
|---|
| 23 |
|
|---|
| 24 | enum coroutine_state { Start, Inactive, Active, Halt, Primed };
|
|---|
| 25 |
|
|---|
| 26 | struct coroutine {
|
|---|
| 27 | struct coStack_t stack;
|
|---|
| 28 | const char *name; // textual name for coroutine/task, initialized by uC++ generated code
|
|---|
| 29 | int errno_; // copy of global UNIX variable errno
|
|---|
| 30 | enum coroutine_state state; // current execution status for coroutine
|
|---|
| 31 | bool notHalted; // indicate if execuation state is not halted
|
|---|
| 32 |
|
|---|
| 33 | struct coroutine *starter; // first coroutine to resume this one
|
|---|
| 34 | struct coroutine *last; // last coroutine to resume this one
|
|---|
| 35 | };
|
|---|
| 36 |
|
|---|
| 37 | struct thread_h {
|
|---|
| 38 | struct coroutine c;
|
|---|
| 39 | };
|
|---|
| 40 |
|
|---|
| 41 | #endif //_INVOKE_H_
|
|---|
| 42 | #else //! defined(__CFA_INVOKE_PRIVATE__)
|
|---|
| 43 | #ifndef _INVOKE_PRIVATE_H_
|
|---|
| 44 | #define _INVOKE_PRIVATE_H_
|
|---|
| 45 |
|
|---|
| 46 | struct machine_context_t {
|
|---|
| 47 | void *SP;
|
|---|
| 48 | void *FP;
|
|---|
| 49 | void *PC;
|
|---|
| 50 | };
|
|---|
| 51 |
|
|---|
| 52 | // assembler routines that performs the context switch
|
|---|
| 53 | extern void CtxInvokeStub( void );
|
|---|
| 54 | void CtxSwitch( void * from, void * to ) asm ("CtxSwitch");
|
|---|
| 55 | void CtxGet( void * this ) asm ("CtxGet");
|
|---|
| 56 |
|
|---|
| 57 | #endif //_INVOKE_PRIVATE_H_
|
|---|
| 58 | #endif //! defined(__CFA_INVOKE_PRIVATE__)
|
|---|
| 59 | #ifdef __CFORALL__
|
|---|
| 60 | }
|
|---|
| 61 | #endif
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.