1169695Skan/* The common simulator framework for GDB, the GNU Debugger. 2169695Skan 3169695Skan Copyright 2002, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. 4169695Skan 5169695Skan Contributed by Andrew Cagney and Red Hat. 6169695Skan 7169695Skan This file is part of GDB. 8169695Skan 9169695Skan This program is free software; you can redistribute it and/or modify 10169695Skan it under the terms of the GNU General Public License as published by 11169695Skan the Free Software Foundation; either version 3 of the License, or 12169695Skan (at your option) any later version. 13169695Skan 14169695Skan This program is distributed in the hope that it will be useful, 15169695Skan but WITHOUT ANY WARRANTY; without even the implied warranty of 16169695Skan MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17169695Skan GNU General Public License for more details. 18169695Skan 19169695Skan You should have received a copy of the GNU General Public License 20169695Skan along with this program. If not, see <http://www.gnu.org/licenses/>. */ 21169695Skan 22169695Skan 23169695Skan#include "sim-main.h" 24169695Skan#include "hw-main.h" 25169695Skan 26169695Skan/* DEVICE 27169695Skan 28169695Skan core - root of the device tree 29169695Skan 30169695Skan DESCRIPTION 31169695Skan 32169695Skan The core device, positioned at the root of the device tree appears 33169695Skan to its child devices as a normal device just like every other 34169695Skan device in the tree. 35169695Skan 36169695Skan Internally it is implemented using a core object. Requests to 37169695Skan attach (or detach) address spaces are passed to that core object. 38169695Skan Requests to transfer (DMA) data are reflected back down the device 39169695Skan tree using the core_map data transfer methods. 40169695Skan 41169695Skan PROPERTIES 42169695Skan 43169695Skan None. 44169695Skan 45169695Skan */ 46169695Skan 47169695Skan 48169695Skanstatic void 49169695Skandv_core_attach_address_callback (struct hw *me, 50169695Skan int level, 51169695Skan int space, 52169695Skan address_word addr, 53169695Skan address_word nr_bytes, 54169695Skan struct hw *client) 55169695Skan{ 56169695Skan HW_TRACE ((me, "attach - level=%d, space=%d, addr=0x%lx, nr_bytes=%ld, client=%s", 57169695Skan level, space, (unsigned long) addr, (unsigned long) nr_bytes, hw_path (client))); 58169695Skan /* NOTE: At preset the space is assumed to be zero. Perhaphs the 59169695Skan space should be mapped onto something for instance: space0 - 60169695Skan unified memory; space1 - IO memory; ... */ 61 sim_core_attach (hw_system (me), 62 NULL, /*cpu*/ 63 level, 64 access_read_write_exec, 65 space, addr, 66 nr_bytes, 67 0, /* modulo */ 68 client, 69 NULL); 70} 71 72 73static unsigned 74dv_core_dma_read_buffer_callback (struct hw *me, 75 void *dest, 76 int space, 77 unsigned_word addr, 78 unsigned nr_bytes) 79{ 80 return sim_core_read_buffer (hw_system (me), 81 NULL, /*CPU*/ 82 space, /*???*/ 83 dest, 84 addr, 85 nr_bytes); 86} 87 88 89static unsigned 90dv_core_dma_write_buffer_callback (struct hw *me, 91 const void *source, 92 int space, 93 unsigned_word addr, 94 unsigned nr_bytes, 95 int violate_read_only_section) 96{ 97 return sim_core_write_buffer (hw_system (me), 98 NULL, /*cpu*/ 99 space, /*???*/ 100 source, 101 addr, 102 nr_bytes); 103} 104 105 106static void 107dv_core_finish (struct hw *me) 108{ 109 set_hw_attach_address (me, dv_core_attach_address_callback); 110 set_hw_dma_write_buffer (me, dv_core_dma_write_buffer_callback); 111 set_hw_dma_read_buffer (me, dv_core_dma_read_buffer_callback); 112} 113 114const struct hw_descriptor dv_core_descriptor[] = { 115 { "core", dv_core_finish, }, 116 { NULL, NULL }, 117}; 118