libducky/include/arch/ducky.h.in

Summary

Maintainability
Test Coverage
#ifndef __DUCKY_DUCKY_H__
#define __DUCKY_DUCKY_H__

#include <types.h>

<%
  import ducky.mm
  import ducky.cpu.instructions
%>

/*
 * Instruction set
 */

#define DUCKY_INST_SET ${X4(ducky.cpu.instructions.DuckyInstructionSet.instruction_set_id)}


/*
 * Data types
 */


#define WORD_BITS     32
#define INT_BITS      32
#define SHORT_BITS    16
#define BYTE_BITS      8

#define WORD_SIZE     4
#define INT_SIZE      4
#define SHORT_SIZE    2
#define BYTE_SIZE     1


/*
 * Memory
 */

#define PAGE_SHIFT    ${ducky.mm.PAGE_SHIFT}
#define PAGE_SIZE     ${ducky.mm.PAGE_SIZE}
#define PAGE_MASK     ${X8(ducky.mm.u32_t(ducky.mm.PAGE_MASK).value)}


#define PTE_READ      ${X2(ducky.mm.PageTableEntry.READ)}
#define PTE_WRITE     ${X2(ducky.mm.PageTableEntry.WRITE)}
#define PTE_EXECUTE   ${X2(ducky.mm.PageTableEntry.EXECUTE)}
#define PTE_DIRTY     ${X2(ducky.mm.PageTableEntry.DIRTY)}


/*
 * Exceptions
 */

<%
  from ducky.errors import ExceptionList
%>

#define EXCEPTION_INVALID_OPCODE    ${X2(ExceptionList.InvalidOpcode)}
#define EXCEPTION_INVALID_INST_SET  ${X2(ExceptionList.InvalidInstSet)}
#define EXCEPTION_DIVIDE_BY_ZERO    ${X2(ExceptionList.DivideByZero)}
#define EXCEPTION_UNALIGNED_ACCESS  ${X2(ExceptionList.UnalignedAccess)}
#define EXCEPTION_PRIVILEGED_INST   ${X2(ExceptionList.PrivilegedInstr)}
#define EXCEPTION_DOUBLE_FAULT      ${X2(ExceptionList.DoubleFault)}
#define EXCEPTION_MEMORY_ACCESS     ${X2(ExceptionList.MemoryAccess)}
#define EXCEPTION_REGISTER_ACCESS   ${X2(ExceptionList.RegisterAccess)}
#define EXCEPTION_INVALID_EXCEPTION ${X2(ExceptionList.InvalidException)}
#define EXCEPTION_COPROCESSOR_ERROR ${X2(ExceptionList.CoprocessorError)}

#define EXCEPTION_COUNT             ${X2(ExceptionList.COUNT)}

#ifndef __DUCKY_PURE_ASM__

typedef struct {
  u32_t e_ip;
  u32_t e_sp;
} evt_entry_t;

#define EVT_ENTRY(_ip, _sp) { .e_ip = (u32_t)_ip, .e_sp = (u32_t)_sp }

#endif // __DUCKY_PURE_ASM__

#endif // __DUCKY_DUCKY_H__