annotate runtime/context.h @ 65:1db811fa4744

Handle native Rhope functions and plain C functions separately as part of move to new C strategy
author Mike Pavone <pavone@retrodev.com>
date Tue, 01 Jun 2010 01:13:54 -0400
parents 04baa003de5a
children d4b44ae2e34a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8
8d74ef7fa357 Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
1 #ifndef _CONTEXT_H_
8d74ef7fa357 Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
2 #define _CONTEXT_H_
8d74ef7fa357 Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
3
8d74ef7fa357 Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
4 #include "thread.h"
8d74ef7fa357 Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
5 #include "plat_types.h"
8d74ef7fa357 Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
6 #include "func.h"
8d74ef7fa357 Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
7
8d74ef7fa357 Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
8 #define STACK_CHUNK_SIZE 4096-(sizeof(struct stackchunk *)*2+sizeof(uint32_t))
8d74ef7fa357 Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
9
8d74ef7fa357 Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
10 typedef struct stackchunk {
8d74ef7fa357 Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
11 struct stackchunk * next;
8d74ef7fa357 Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
12 struct stackchunk * prev;
8d74ef7fa357 Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
13 uint32_t used;
8d74ef7fa357 Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
14 char data[STACK_CHUNK_SIZE];
8d74ef7fa357 Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
15 } stackchunk;
8d74ef7fa357 Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
16
8d74ef7fa357 Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
17 typedef struct context {
8d74ef7fa357 Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
18 stackchunk *stack_begin;
8d74ef7fa357 Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
19 stackchunk *current_stack;
8d74ef7fa357 Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
20 } context;
8d74ef7fa357 Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
21
8d74ef7fa357 Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
22 stackchunk * new_stack();
8d74ef7fa357 Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
23 context * new_context();
8d74ef7fa357 Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
24 void * alloc_stack(context * ct, uint32_t size);
53
70af7fa155d0 Cleaned up some C warnings and added a simple compile script
Mike Pavone <pavone@retrodev.com>
parents: 52
diff changeset
25 calldata * alloc_cdata(context * ct, uint32_t num_params);
52
079200bc3e75 String literals almost working. Print moved out of C runtime.
Mike Pavone <pavone@retrodev.com>
parents: 8
diff changeset
26 void free_stack(context * ct, void * data);
079200bc3e75 String literals almost working. Print moved out of C runtime.
Mike Pavone <pavone@retrodev.com>
parents: 8
diff changeset
27 void free_context(context * c);
8
8d74ef7fa357 Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
28 #endif //_CONTEXT_H_