Search
lxdream.org :: lxdream/src/cpu.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/cpu.h
changeset 1091:186558374345
prev1065:bc1cc0c54917
author nkeynes
date Tue Dec 15 08:46:37 2009 +1000 (11 years ago)
permissions -rw-r--r--
last change Add side-by-side x86+sh4 disassembly output
Print SH4 state information and disassembly of the current block when
crashing.
Fix delay slot instruction in conditional branch not being marked as a
delay-slot instruction in the branch-not-taken path.
Rename REG_* defines in cpu.h to avoid conflict with translation defs
file annotate diff log raw
nkeynes@30
     1
/**
nkeynes@561
     2
 * $Id$
nkeynes@30
     3
 * 
nkeynes@30
     4
 * Generic CPU definitions, primarily for providing information to the GUI.
nkeynes@30
     5
 *
nkeynes@30
     6
 * Copyright (c) 2005 Nathan Keynes.
nkeynes@30
     7
 *
nkeynes@30
     8
 * This program is free software; you can redistribute it and/or modify
nkeynes@30
     9
 * it under the terms of the GNU General Public License as published by
nkeynes@30
    10
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@30
    11
 * (at your option) any later version.
nkeynes@30
    12
 *
nkeynes@30
    13
 * This program is distributed in the hope that it will be useful,
nkeynes@30
    14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@30
    15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@30
    16
 * GNU General Public License for more details.
nkeynes@30
    17
 */
nkeynes@9
    18
nkeynes@736
    19
#ifndef lxdream_cpu_H
nkeynes@736
    20
#define lxdream_cpu_H 1
nkeynes@9
    21
nkeynes@1091
    22
#include <stdio.h>
nkeynes@1091
    23
nkeynes@566
    24
#include "lxdream.h"
nkeynes@566
    25
#include "mem.h"
nkeynes@9
    26
nkeynes@9
    27
#ifdef __cplusplus
nkeynes@9
    28
extern "C" {
nkeynes@9
    29
#endif
nkeynes@9
    30
nkeynes@9
    31
/**
nkeynes@9
    32
 * Disassembly function pointer typedef.
nkeynes@9
    33
 *
nkeynes@9
    34
 * @param pc Address to disassemble
nkeynes@9
    35
 * @param buffer String buffer to write disassembly into
nkeynes@9
    36
 * @param buflen Maximum length of buffer
nkeynes@9
    37
 * @return next address to disassemble
nkeynes@9
    38
 */
nkeynes@11
    39
typedef uint32_t (*disasm_func_t)(uint32_t pc, char *buffer, int buflen, char *opcode );
nkeynes@11
    40
nkeynes@1091
    41
#define REG_TYPE_INT 0
nkeynes@1091
    42
#define REG_TYPE_FLOAT 1
nkeynes@1091
    43
#define REG_TYPE_DOUBLE 2
nkeynes@1091
    44
#define REG_TYPE_NONE 3 /* Used for empty/separator field */
nkeynes@9
    45
nkeynes@9
    46
/**
nkeynes@9
    47
 * Structure that defines a single register in a CPU for display purposes.
nkeynes@9
    48
 */
nkeynes@9
    49
typedef struct reg_desc_struct {
nkeynes@9
    50
    char *name;
nkeynes@9
    51
    int type;
nkeynes@9
    52
    void *value;
nkeynes@9
    53
} reg_desc_t;
nkeynes@9
    54
nkeynes@30
    55
/**
nkeynes@998
    56
 * CPU definition structure - basic information and support functions. Most
nkeynes@998
    57
 * of this is for debugger use.
nkeynes@30
    58
 */
nkeynes@9
    59
typedef struct cpu_desc_struct {
nkeynes@43
    60
    char *name; /* CPU Name */
nkeynes@998
    61
    /**
nkeynes@998
    62
     * Single instruction disassembly 
nkeynes@998
    63
     **/
nkeynes@998
    64
    disasm_func_t disasm_func;
nkeynes@998
    65
    
nkeynes@998
    66
    /**
nkeynes@998
    67
     * Return a pointer to a register (indexed per the reg_desc table)
nkeynes@998
    68
     */
nkeynes@998
    69
    void * (*get_register)( int reg );
nkeynes@998
    70
    gboolean (*is_valid_page_func)(uint32_t); /* Test for valid memory page */
nkeynes@998
    71
    /* Access to memory addressed by the CPU - physical and virtual versions.
nkeynes@998
    72
     * Virtual access should account for the current CPU mode, privilege level,
nkeynes@998
    73
     * etc.
nkeynes@998
    74
     * All functions return the number of bytes copied, which may be 0 if the
nkeynes@998
    75
     * address is unmapped.
nkeynes@998
    76
     */
nkeynes@998
    77
    size_t (*read_mem_phys)(unsigned char *buf, uint32_t addr, size_t length);
nkeynes@998
    78
    size_t (*write_mem_phys)(uint32_t addr, unsigned char *buf, size_t length);
nkeynes@998
    79
    size_t (*read_mem_vma)(unsigned char *buf, uint32_t addr, size_t length);
nkeynes@998
    80
    size_t (*write_mem_vma)(uint32_t addr, unsigned char *buf, size_t length);
nkeynes@43
    81
    gboolean (*step_func)(); /* Single step function */
nkeynes@566
    82
    void (*set_breakpoint)(uint32_t, breakpoint_type_t);
nkeynes@566
    83
    gboolean (*clear_breakpoint)(uint32_t, breakpoint_type_t);
nkeynes@43
    84
    int (*get_breakpoint)(uint32_t);
nkeynes@43
    85
    size_t instr_size; /* Size of instruction */
nkeynes@43
    86
    char *regs; /* Pointer to start of registers */
nkeynes@43
    87
    size_t regs_size; /* Size of register structure in bytes */
nkeynes@43
    88
    const struct reg_desc_struct *regs_info; /* Description of all registers */
nkeynes@998
    89
    unsigned int num_gpr_regs; /* Number of general purpose registers */
nkeynes@998
    90
    unsigned int num_gdb_regs; /* Total number of registers visible to gdb */
nkeynes@43
    91
    uint32_t *pc; /* Pointer to PC register */
nkeynes@429
    92
} const *cpu_desc_t;
nkeynes@9
    93
nkeynes@9
    94
#ifdef __cplusplus
nkeynes@9
    95
}
nkeynes@9
    96
#endif
nkeynes@9
    97
nkeynes@998
    98
gboolean gdb_init_server( const char *interface, int port, cpu_desc_t cpu, gboolean mmu );
nkeynes@1091
    99
void cpu_print_registers( FILE *out, cpu_desc_t cpu );
nkeynes@998
   100
nkeynes@736
   101
#endif /* !lxdream_cpu_H */
.