]> git.karo-electronics.de Git - oswald.git/blob - ui/embedvm.h
Shorten charger plug "tail"
[oswald.git] / ui / embedvm.h
1 /*
2  *  EmbedVM - Embedded Virtual Machine for uC Applications
3  *
4  *  Copyright (C) 2011  Clifford Wolf <clifford@clifford.at>
5  *  
6  *  Permission to use, copy, modify, and/or distribute this software for any
7  *  purpose with or without fee is hereby granted, provided that the above
8  *  copyright notice and this permission notice appear in all copies.
9  *  
10  *  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  *  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  *  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  *  ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  *  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  *  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  *  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  *
18  */
19
20 #ifndef EMBEDVM_H
21 #define EMBEDVM_H
22
23 #include <stdint.h>
24 #include <stdbool.h>
25
26 #ifdef  __cplusplus
27 extern "C" {
28 #endif
29
30 struct embedvm_s
31 {
32         uint16_t ip, sp, sfp;
33         void *user_ctx;
34
35         int16_t (*mem_read)(uint16_t addr, bool is16bit, void *ctx);
36         void (*mem_write)(uint16_t addr, int16_t value, bool is16bit, void *ctx);
37         int16_t (*call_user)(uint8_t funcid, uint8_t argc, int16_t *argv, void *ctx);
38 };
39
40 extern void embedvm_exec(struct embedvm_s *vm);
41 extern void embedvm_interrupt(struct embedvm_s *vm, uint16_t addr);
42
43 int16_t embedvm_pop(struct embedvm_s *vm);
44 void embedvm_push(struct embedvm_s *vm, int16_t value);
45
46 int16_t embedvm_local_read(struct embedvm_s *vm, int8_t sfa);
47 void embedvm_local_write(struct embedvm_s *vm, int8_t sfa, int16_t value);
48
49 #ifdef __cplusplus
50 }
51 #endif
52
53 #endif