4 * Generic CPU definitions, primarily for providing information to the GUI.
6 * Copyright (c) 2005 Nathan Keynes.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
20 #define lxdream_cpu_H 1
32 * Disassembly function pointer typedef.
34 * @param pc Address to disassemble
35 * @param buffer String buffer to write disassembly into
36 * @param buflen Maximum length of buffer
37 * @return next address to disassemble
39 typedef uint32_t (*disasm_func_t)(uint32_t pc, char *buffer, int buflen, char *opcode );
41 #define REG_TYPE_INT 0
42 #define REG_TYPE_FLOAT 1
43 #define REG_TYPE_DOUBLE 2
44 #define REG_TYPE_NONE 3 /* Used for empty/separator field */
47 * Structure that defines a single register in a CPU for display purposes.
49 typedef struct reg_desc_struct {
56 * CPU definition structure - basic information and support functions. Most
57 * of this is for debugger use.
59 typedef struct cpu_desc_struct {
60 char *name; /* CPU Name */
62 * Single instruction disassembly
64 disasm_func_t disasm_func;
67 * Return a pointer to a register (indexed per the reg_desc table)
69 void * (*get_register)( int reg );
70 gboolean (*is_valid_page_func)(uint32_t); /* Test for valid memory page */
71 /* Access to memory addressed by the CPU - physical and virtual versions.
72 * Virtual access should account for the current CPU mode, privilege level,
74 * All functions return the number of bytes copied, which may be 0 if the
75 * address is unmapped.
77 size_t (*read_mem_phys)(unsigned char *buf, uint32_t addr, size_t length);
78 size_t (*write_mem_phys)(uint32_t addr, unsigned char *buf, size_t length);
79 size_t (*read_mem_vma)(unsigned char *buf, uint32_t addr, size_t length);
80 size_t (*write_mem_vma)(uint32_t addr, unsigned char *buf, size_t length);
81 gboolean (*step_func)(); /* Single step function */
82 void (*set_breakpoint)(uint32_t, breakpoint_type_t);
83 gboolean (*clear_breakpoint)(uint32_t, breakpoint_type_t);
84 int (*get_breakpoint)(uint32_t);
85 size_t instr_size; /* Size of instruction */
86 char *regs; /* Pointer to start of registers */
87 size_t regs_size; /* Size of register structure in bytes */
88 const struct reg_desc_struct *regs_info; /* Description of all registers */
89 unsigned int num_gpr_regs; /* Number of general purpose registers */
90 unsigned int num_gdb_regs; /* Total number of registers visible to gdb */
91 uint32_t *pc; /* Pointer to PC register */
98 gboolean gdb_init_server( const char *interface, int port, cpu_desc_t cpu, gboolean mmu );
99 void cpu_print_registers( FILE *out, cpu_desc_t cpu );
101 #endif /* !lxdream_cpu_H */
.