Search
lxdream.org :: lxdream/src/cpu.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/cpu.h
changeset 561:533f6b478071
prev429:e581b90c3fb3
next566:59be465e5f01
author nkeynes
date Tue Jan 01 05:08:38 2008 +0000 (12 years ago)
branchlxdream-mmu
permissions -rw-r--r--
last change Enable Id keyword on all source files
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@30
    19
#ifndef dream_cpu_H
nkeynes@30
    20
#define dream_cpu_H 1
nkeynes@9
    21
nkeynes@30
    22
#include <stdint.h>
nkeynes@9
    23
#include <stdlib.h>
nkeynes@30
    24
#include <glib/gtypes.h>
nkeynes@9
    25
nkeynes@9
    26
#ifdef __cplusplus
nkeynes@9
    27
extern "C" {
nkeynes@9
    28
#endif
nkeynes@9
    29
nkeynes@9
    30
/**
nkeynes@9
    31
 * Disassembly function pointer typedef.
nkeynes@9
    32
 *
nkeynes@9
    33
 * @param pc Address to disassemble
nkeynes@9
    34
 * @param buffer String buffer to write disassembly into
nkeynes@9
    35
 * @param buflen Maximum length of buffer
nkeynes@9
    36
 * @return next address to disassemble
nkeynes@9
    37
 */
nkeynes@11
    38
typedef uint32_t (*disasm_func_t)(uint32_t pc, char *buffer, int buflen, char *opcode );
nkeynes@11
    39
nkeynes@9
    40
#define REG_INT 0
nkeynes@9
    41
#define REG_FLT 1
nkeynes@9
    42
#define REG_SPECIAL 2
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@30
    54
 * CPU definition structure - basic information and support functions.
nkeynes@30
    55
 */
nkeynes@9
    56
typedef struct cpu_desc_struct {
nkeynes@43
    57
    char *name; /* CPU Name */
nkeynes@43
    58
    disasm_func_t disasm_func; /* Disassembly function */
nkeynes@43
    59
    gboolean (*step_func)(); /* Single step function */
nkeynes@43
    60
    int (*is_valid_page_func)(uint32_t); /* Test for valid memory page */
nkeynes@43
    61
    void (*set_breakpoint)(uint32_t, int);
nkeynes@43
    62
    gboolean (*clear_breakpoint)(uint32_t, int);
nkeynes@43
    63
    int (*get_breakpoint)(uint32_t);
nkeynes@43
    64
    size_t instr_size; /* Size of instruction */
nkeynes@43
    65
    char *regs; /* Pointer to start of registers */
nkeynes@43
    66
    size_t regs_size; /* Size of register structure in bytes */
nkeynes@43
    67
    const struct reg_desc_struct *regs_info; /* Description of all registers */
nkeynes@43
    68
    uint32_t *pc; /* Pointer to PC register */
nkeynes@429
    69
} const *cpu_desc_t;
nkeynes@9
    70
nkeynes@9
    71
#ifdef __cplusplus
nkeynes@9
    72
}
nkeynes@9
    73
#endif
nkeynes@9
    74
nkeynes@30
    75
#endif /* !dream_cpu_H */
.