57 lines
1.3 KiB
C
57 lines
1.3 KiB
C
#ifndef PROC_H
|
|
#define PROC_H
|
|
|
|
#include "stack.h"
|
|
#include "mmu.h"
|
|
#include "../common/opcode.h"
|
|
#include "../common/types.h"
|
|
|
|
typedef struct proc_t {
|
|
integral_t status;
|
|
integral_t intHandler;
|
|
integral_t subscribed;
|
|
integral_t lastAddress;
|
|
mmu_t mmu;
|
|
stack_t stack;
|
|
proc_object_t registers[256];
|
|
void* opaque;
|
|
} proc_t;
|
|
|
|
#include "decoder.h"
|
|
#include "executer.h"
|
|
|
|
//proc status
|
|
#define PROC_STATUS_running 1
|
|
#define PROC_STATUS_interrupt 2
|
|
#define PROC_STATUS_interrupted 4
|
|
#define PROC_STATUS_aborted 8
|
|
|
|
//proc error interrupts
|
|
#define INTERRUPT_illegal_read 1
|
|
#define INTERRUPT_illegal_jump 2
|
|
#define INTERRUPT_illegal_ext 3
|
|
#define INTERRUPT_illegal_instruction 4
|
|
#define INTERRUPT_illegal_write 5
|
|
#define INTERRUPT_illegal_arg 6
|
|
#define INTERRUPT_unknown 7
|
|
|
|
//proc hardware interrupts
|
|
#define INTERRUPT_hw_keydown 1
|
|
#define INTERRUPT_hw_keyup 2
|
|
#define INTERRUPT_hw_keyrepeat 3
|
|
#define INTERRUPT_hw_timer 4
|
|
|
|
//proc interrupt masks
|
|
#define INTERRUPT_user_mask 0x80000000
|
|
#define INTERRUPT_hw_mask 0x40000000
|
|
|
|
//proc hw interrupt subscriptions
|
|
#define PROC_SUBSCRIPTION_keyboard 0x00000001
|
|
#define PROC_SUBSCRIPTION_timer 0x00000002
|
|
|
|
void Proc_execute(proc_t *proc, int maxCycles);
|
|
void Proc_interrupt(proc_t *proc, integral_t code, integral_t data);
|
|
void initProc(proc_t *proc);
|
|
|
|
#endif
|