Search
lxdream.org :: lxdream/src/cpu.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/cpu.h
changeset 998:1754a8c6a9cf
prev736:a02d1475ccfd
next1065:bc1cc0c54917
author nkeynes
date Tue Mar 24 11:15:57 2009 +0000 (13 years ago)
permissions -rw-r--r--
last change Add preliminary implementation of the GDB remote debugging server - attaches to
either or both the SH4 and ARM
file annotate diff log raw
nkeynes@30
     1
/**
nkeynes@586
     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@586
    22
#include "lxdream.h"
nkeynes@586
    23
#include "mem.h"
nkeynes@9
    24
nkeynes@9
    25
#ifdef __cplusplus
nkeynes@9
    26
extern "C" {
nkeynes@9
    27
#endif
nkeynes@9
    28
nkeynes@9
    29
/**
nkeynes@9
    30
 * Disassembly function pointer typedef.
nkeynes@9
    31
 *
nkeynes@9
    32
 * @param pc Address to disassemble
nkeynes@9
    33
 * @param buffer String buffer to write disassembly into
nkeynes@9
    34
 * @param buflen Maximum length of buffer
nkeynes@9
    35
 * @return next address to disassemble
nkeynes@9
    36
 */
nkeynes@11
    37
typedef uint32_t (*disasm_func_t)(uint32_t pc, char *buffer, int buflen, char *opcode );
nkeynes@11
    38
nkeynes@9
    39
#define REG_INT 0
nkeynes@998
    40
#define REG_FLOAT 1
nkeynes@998
    41
#define REG_DOUBLE 2
nkeynes@998
    42
#define REG_NONE 3 /* Used for empty/separator field */
nkeynes@9
    43
nkeynes@9
    44
/**
nkeynes@9
    45
 * Structure that defines a single register in a CPU for display purposes.
nkeynes@9
    46
 */
nkeynes@9
    47
typedef struct reg_desc_struct {
nkeynes@9
    48
    char *name;
nkeynes@9
    49
    int type;
nkeynes@9
    50
    void *value;
nkeynes@9
    51
} reg_desc_t;
nkeynes@9
    52
nkeynes@30
    53
/**
nkeynes@998
    54
 * CPU definition structure - basic information and support functions. Most
nkeynes@998
    55
 * of this is for debugger use.
nkeynes@30
    56
 */
nkeynes@9
    57
typedef struct cpu_desc_struct {
nkeynes@43
    58
    char *name; /* CPU Name */
nkeynes@998
    59
    /**
nkeynes@998
    60
     * Single instruction disassembly 
nkeynes@998
    61
     **/
nkeynes@998
    62
    disasm_func_t disasm_func;
nkeynes@998
    63
    
nkeynes@998
    64
    /**
nkeynes@998
    65
     * Return a pointer to a register (indexed per the reg_desc table)
nkeynes@998
    66
     */
nkeynes@998
    67
    void * (*get_register)( int reg );
nkeynes@998
    68
    gboolean (*is_valid_page_func)(uint32_t); /* Test for valid memory page */
nkeynes@998
    69
    /* Access to memory addressed by the CPU - physical and virtual versions.
nkeynes@998
    70
     * Virtual access should account for the current CPU mode, privilege level,
nkeynes@998
    71
     * etc.
nkeynes@998
    72
     * All functions return the number of bytes copied, which may be 0 if the
nkeynes@998
    73
     * address is unmapped.
nkeynes@998
    74
     */
nkeynes@998
    75
    size_t (*read_mem_phys)(unsigned char *buf, uint32_t addr, size_t length);
nkeynes@998
    76
    size_t (*write_mem_phys)(uint32_t addr, unsigned char *buf, size_t length);
nkeynes@998
    77
    size_t (*read_mem_vma)(unsigned char *buf, uint32_t addr, size_t length);
nkeynes@998
    78
    size_t (*write_mem_vma)(uint32_t addr, unsigned char *buf, size_t length);
nkeynes@43
    79
    gboolean (*step_func)(); /* Single step function */
nkeynes@586
    80
    void (*set_breakpoint)(uint32_t, breakpoint_type_t);
nkeynes@586
    81
    gboolean (*clear_breakpoint)(uint32_t, breakpoint_type_t);
nkeynes@43
    82
    int (*get_breakpoint)(uint32_t);
nkeynes@43
    83
    size_t instr_size; /* Size of instruction */
nkeynes@43
    84
    char *regs; /* Pointer to start of registers */
nkeynes@43
    85
    size_t regs_size; /* Size of register structure in bytes */
nkeynes@43
    86
    const struct reg_desc_struct *regs_info; /* Description of all registers */
nkeynes@998
    87
    unsigned int num_gpr_regs; /* Number of general purpose registers */
nkeynes@998
    88
    unsigned int num_gdb_regs; /* Total number of registers visible to gdb */
nkeynes@43
    89
    uint32_t *pc; /* Pointer to PC register */
nkeynes@429
    90
} const *cpu_desc_t;
nkeynes@9
    91
nkeynes@9
    92
#ifdef __cplusplus
nkeynes@9
    93
}
nkeynes@9
    94
#endif
nkeynes@9
    95
nkeynes@998
    96
gboolean gdb_init_server( const char *interface, int port, cpu_desc_t cpu, gboolean mmu );
nkeynes@998
    97
nkeynes@736
    98
#endif /* !lxdream_cpu_H */
.