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
30 * Disassembly function pointer typedef.
32 * @param pc Address to disassemble
33 * @param buffer String buffer to write disassembly into
34 * @param buflen Maximum length of buffer
35 * @return next address to disassemble
37 typedef uint32_t (*disasm_func_t)(uint32_t pc, char *buffer, int buflen, char *opcode );
42 #define REG_NONE 3 /* Used for empty/separator field */
45 * Structure that defines a single register in a CPU for display purposes.
47 typedef struct reg_desc_struct {
54 * CPU definition structure - basic information and support functions. Most
55 * of this is for debugger use.
57 typedef struct cpu_desc_struct {
58 char *name; /* CPU Name */
60 * Single instruction disassembly
62 disasm_func_t disasm_func;
65 * Return a pointer to a register (indexed per the reg_desc table)
67 void * (*get_register)( int reg );
68 gboolean (*is_valid_page_func)(uint32_t); /* Test for valid memory page */
69 /* Access to memory addressed by the CPU - physical and virtual versions.
70 * Virtual access should account for the current CPU mode, privilege level,
72 * All functions return the number of bytes copied, which may be 0 if the
73 * address is unmapped.
75 size_t (*read_mem_phys)(unsigned char *buf, uint32_t addr, size_t length);
76 size_t (*write_mem_phys)(uint32_t addr, unsigned char *buf, size_t length);
77 size_t (*read_mem_vma)(unsigned char *buf, uint32_t addr, size_t length);
78 size_t (*write_mem_vma)(uint32_t addr, unsigned char *buf, size_t length);
79 gboolean (*step_func)(); /* Single step function */
80 void (*set_breakpoint)(uint32_t, breakpoint_type_t);
81 gboolean (*clear_breakpoint)(uint32_t, breakpoint_type_t);
82 int (*get_breakpoint)(uint32_t);
83 size_t instr_size; /* Size of instruction */
84 char *regs; /* Pointer to start of registers */
85 size_t regs_size; /* Size of register structure in bytes */
86 const struct reg_desc_struct *regs_info; /* Description of all registers */
87 unsigned int num_gpr_regs; /* Number of general purpose registers */
88 unsigned int num_gdb_regs; /* Total number of registers visible to gdb */
89 uint32_t *pc; /* Pointer to PC register */
96 gboolean gdb_init_server( const char *interface, int port, cpu_desc_t cpu, gboolean mmu );
98 #endif /* !lxdream_cpu_H */
.