home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / gdb-4.16-base.tgz / gdb-4.16-base.tar / fsf / gdb / sim / ppc / device_table.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-22  |  7.1 KB  |  253 lines

  1. /*  This file is part of the program psim.
  2.  
  3.     Copyright (C) 1994-1996, Andrew Cagney <cagney@highland.com.au>
  4.  
  5.     This program is free software; you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation; either version 2 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18.  
  19.     */
  20.  
  21.  
  22. #ifndef _DEVICE_TABLE_H_
  23. #define _DEVICE_TABLE_H_
  24.  
  25. #include <stdarg.h>
  26.  
  27. #include "basics.h"
  28. #include "device.h"
  29.  
  30. typedef void (device_init_callback)
  31.      (device *me,
  32.       psim *system);
  33.      
  34. typedef void (device_config_address_callback)
  35.      (device *me,
  36.       const char *name,
  37.       attach_type attach,
  38.       int space,
  39.       unsigned_word addr,
  40.       unsigned nr_bytes,
  41.       access_type access,
  42.       device *who); /*callback/default*/
  43.  
  44. typedef unsigned (device_io_read_buffer_callback)
  45.      (device *me,
  46.       void *dest,
  47.       int space,
  48.       unsigned_word addr,
  49.       unsigned nr_bytes,
  50.       cpu *processor,
  51.       unsigned_word cia);
  52.  
  53. typedef unsigned (device_io_write_buffer_callback)
  54.      (device *me,
  55.       const void *source,
  56.       int space,
  57.       unsigned_word addr,
  58.       unsigned nr_bytes,
  59.       cpu *processor,
  60.       unsigned_word cia);
  61.  
  62. typedef unsigned (device_dma_read_buffer_callback)
  63.      (device *me,
  64.       void *dest,
  65.       int space,
  66.       unsigned_word addr,
  67.       unsigned nr_bytes);
  68.  
  69. typedef unsigned (device_dma_write_buffer_callback)
  70.      (device *me,
  71.       const void *source,
  72.       int space,
  73.       unsigned_word addr,
  74.       unsigned nr_bytes,
  75.       int violate_read_only_section);
  76.  
  77.  
  78. /* Interrupts */
  79.  
  80. typedef void (device_interrupt_event_callback)
  81.      (device *me,
  82.       int my_port,
  83.       device *source,
  84.       int source_port,
  85.       int level,
  86.       cpu *processor,
  87.       unsigned_word cia);
  88.  
  89. typedef void (device_child_interrupt_event_callback)
  90.      (device *me,
  91.       device *parent,
  92.       device *source,
  93.       int source_port,
  94.       int level,
  95.       cpu *processor,
  96.       unsigned_word cia);
  97.       
  98.  
  99. /* bus address decoding */
  100.  
  101. typedef int (device_unit_decode_callback)
  102.      (device *me,
  103.       const char *unit,
  104.       device_unit *address);
  105.  
  106. typedef int (device_unit_encode_callback)
  107.      (device *me,
  108.       const device_unit *unit_address,
  109.       char *buf,
  110.       int sizeof_buf);
  111.  
  112.  
  113. /* instances */
  114.  
  115. typedef void *(device_instance_create_callback)
  116.      (device *me,
  117.       const char *args);
  118.  
  119. typedef void (device_instance_delete_callback)
  120.      (device_instance *instance);
  121.  
  122. typedef int (device_instance_read_callback)
  123.      (device_instance *instance,
  124.       void *buf,
  125.       unsigned_word len);
  126.  
  127. typedef int (device_instance_write_callback)
  128.      (device_instance *instance,
  129.       const void *buf,
  130.       unsigned_word len);
  131.  
  132. typedef int (device_instance_seek_callback)
  133.      (device_instance *instance,
  134.       unsigned_word pos_hi,
  135.       unsigned_word pos_lo);
  136.  
  137.  
  138. /* all else fails */
  139.  
  140. typedef void (device_ioctl_callback)
  141.      (device *me,
  142.       psim *system,
  143.       cpu *processor,
  144.       unsigned_word cia,
  145.       va_list ap);
  146.  
  147. typedef void (device_usage_callback)
  148.      (int verbose);
  149.  
  150.  
  151. /* the callbacks */
  152.  
  153. struct _device_callbacks {
  154.  
  155.   /* initialization */
  156.   device_init_callback *init_address;
  157.   device_init_callback *init_data;
  158.  
  159.   /* address/data config - from child */
  160.   device_config_address_callback *attach_address;
  161.   device_config_address_callback *detach_address;
  162.  
  163.   /* address/data transfer - to child */
  164.   device_io_read_buffer_callback *io_read_buffer;
  165.   device_io_write_buffer_callback *io_write_buffer;
  166.  
  167.   /* address/data transfer - from child */
  168.   device_dma_read_buffer_callback *dma_read_buffer;
  169.   device_dma_write_buffer_callback *dma_write_buffer;
  170.  
  171.   /* interrupt signalling */
  172.   device_interrupt_event_callback *interrupt_event;
  173.   device_child_interrupt_event_callback *child_interrupt_event;
  174.  
  175.   /* bus address decoding */
  176.   device_unit_decode_callback *decode_unit;
  177.   device_unit_encode_callback *encode_unit;
  178.  
  179.   /* instances */
  180.   device_instance_create_callback *instance_create;
  181.   device_instance_delete_callback *instance_delete;
  182.   device_instance_read_callback *instance_read;
  183.   device_instance_write_callback *instance_write;
  184.   device_instance_seek_callback *instance_seek;
  185.  
  186.   /* back door to anything we've forgot */
  187.   device_ioctl_callback *ioctl;
  188.   device_usage_callback *usage;
  189. };
  190.  
  191.  
  192. /* Table of all the devices and a function to lookup/create a device
  193.    from its name */
  194.  
  195. typedef void *(device_creator)
  196.      (const char *name,
  197.       const device_unit *unit_address,
  198.       const char *args,
  199.       device *parent);
  200.  
  201. typedef struct _device_descriptor device_descriptor;
  202. struct _device_descriptor {
  203.   const char *name;
  204.   device_creator *creator;
  205.   const device_callbacks *callbacks;
  206. };
  207.  
  208. extern device_descriptor device_table[];
  209.  
  210.  
  211. /* Unimplemented call back functions.  These abort the simulation */
  212.  
  213. extern device_init_callback unimp_device_init;
  214. extern device_config_address_callback unimp_device_attach_address;
  215. extern device_config_address_callback unimp_device_detach_address;
  216. extern device_io_read_buffer_callback unimp_device_io_read_buffer;
  217. extern device_io_write_buffer_callback unimp_device_io_write_buffer;
  218. extern device_dma_read_buffer_callback unimp_device_dma_read_buffer;
  219. extern device_dma_write_buffer_callback unimp_device_dma_write_buffer;
  220. extern device_interrupt_event_callback unimp_device_interrupt_event;
  221. extern device_child_interrupt_event_callback unimp_device_child_interrupt_event;
  222. extern device_unit_decode_callback unimp_device_unit_decode;
  223. extern device_unit_encode_callback unimp_device_unit_encode;
  224. extern device_instance_create_callback unimp_device_instance_create;
  225. extern device_instance_delete_callback unimp_device_instance_delete;
  226. extern device_instance_read_callback unimp_device_instance_read;
  227. extern device_instance_write_callback unimp_device_instance_write;
  228. extern device_instance_seek_callback unimp_device_instance_seek;
  229. extern device_ioctl_callback unimp_device_ioctl;
  230.  
  231.  
  232. /* Pass through, ignore and generic callback functions.  A call going
  233.    towards the root device are passed on up, local calls are ignored
  234.    and call downs abort */
  235.  
  236. extern device_config_address_callback passthrough_device_attach_address;
  237. extern device_config_address_callback passthrough_device_detach_address;
  238. extern device_dma_read_buffer_callback passthrough_device_dma_read_buffer;
  239. extern device_dma_write_buffer_callback passthrough_device_dma_write_buffer;
  240.  
  241. extern device_init_callback ignore_device_init;
  242. extern device_unit_decode_callback ignore_device_unit_decode;
  243.  
  244. extern device_init_callback generic_device_init_address;
  245. extern device_unit_decode_callback generic_device_unit_decode;
  246. extern device_unit_encode_callback generic_device_unit_encode;
  247.  
  248.  
  249. extern const device_callbacks passthrough_device_callbacks;
  250.  
  251.  
  252. #endif /* _DEVICE_TABLE_H_ */
  253.