OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [or1ksim/] [peripheral/] [generic.c] - Blame information for rev 294

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jeremybenn
/* generic.c -- Generic external peripheral
2
 
3
   Copyright (C) 2008 Embecosm Limited
4
 
5
   Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
6
 
7
   This file is part of OpenRISC 1000 Architectural Simulator.
8
 
9
   This program is free software; you can redistribute it and/or modify it
10
   under the terms of the GNU General Public License as published by the Free
11
   Software Foundation; either version 3 of the License, or (at your option)
12
   any later version.
13
 
14
   This program is distributed in the hope that it will be useful, but WITHOUT
15
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
17
   more details.
18
 
19
   You should have received a copy of the GNU General Public License along
20
   with this program.  If not, see <http://www.gnu.org/licenses/>. */
21
 
22
/* This program is commented throughout in a fashion suitable for processing
23
   with Doxygen. */
24
 
25
 
26
/* This is functional simulation of any external peripheral. It's job is to
27
 * trap accesses in a specific range, so that the simulator can drive an
28
 * external device.
29
 *
30
 * A note on endianess. All external communication is done using HOST
31
 * endianess. A set of functions are provided to convert between host and
32
 * model endianess (htoml, htoms, mtohl, mtohs).
33
 */
34
 
35
/* Autoconf and/or portability configuration */
36
#include "config.h"
37
 
38
/* System includes */
39
#include <stdlib.h>
40
#include <stdio.h>
41
 
42
/* Package includes */
43
#include "arch.h"
44
#include "sim-config.h"
45
#include "abstract.h"
46
#include "toplevel-support.h"
47
#include "sim-cmd.h"
48
 
49
 
50
/*! State associated with the generic device. */
51
struct dev_generic
52
{
53
 
54
  /* Info about a particular transaction */
55
 
56
  enum
57
  {                             /* Direction of the access */
58
    GENERIC_READ,
59
    GENERIC_WRITE
60
  } trans_direction;
61
 
62
  enum
63
  {                             /* Size of the access */
64
    GENERIC_BYTE,
65
    GENERIC_HW,
66
    GENERIC_WORD
67
  } trans_size;
68
 
69
  uint32_t value;               /* The value to read/write */
70
 
71
  /* Configuration */
72
 
73
  int enabled;                  /* Device enabled */
74
  int byte_enabled;             /* Byte R/W allowed */
75
  int hw_enabled;               /* Half word R/W allowed */
76
  int word_enabled;             /* Full word R/W allowed */
77
  char *name;                   /* Name of the device */
78
  oraddr_t baseaddr;            /* Base address of device */
79
  uint32_t size;                /* Address space size (bytes) */
80
 
81
};
82
 
83
 
84 93 jeremybenn
/* --------------------------------------------------------------------------*/
85
/*!Read a byte from an external device
86 19 jeremybenn
 
87 93 jeremybenn
   To model Wishbone accurately, we always do this as a 4-byte access, with a
88
   mask for the bytes we don't want.
89 19 jeremybenn
 
90 93 jeremybenn
   Since this is only a byte, the endianess of the result is irrelevant.
91 19 jeremybenn
 
92 93 jeremybenn
   @note We are passed the device address, but we must convert it to a full
93
         address for external use, to allow the single upcall handler to
94
         decode multiple generic devices.
95 19 jeremybenn
 
96 93 jeremybenn
   @param[in] addr  The device address to read from (host endian).
97
   @param[in] dat   The device data structure
98 19 jeremybenn
 
99 93 jeremybenn
   @return  The byte read.                                                   */
100
/* --------------------------------------------------------------------------*/
101 19 jeremybenn
static uint8_t
102 93 jeremybenn
generic_read_byte (oraddr_t  addr,
103
                   void     *dat)
104 19 jeremybenn
{
105
  struct dev_generic *dev = (struct dev_generic *) dat;
106
 
107 93 jeremybenn
  if (!config.ext.read_up)
108 19 jeremybenn
    {
109
      fprintf (stderr, "Byte read from disabled generic device\n");
110
      return 0;
111
    }
112
  else if (addr >= dev->size)
113
    {
114
      fprintf (stderr, "Byte read  out of range for generic device %s "
115
               "(addr %" PRIxADDR ")\n", dev->name, addr);
116
      return 0;
117
    }
118
  else
119
    {
120 93 jeremybenn
      unsigned long int  fulladdr = (unsigned long int) (addr + dev->baseaddr);
121
      unsigned long int  wordaddr = fulladdr & 0xfffffffc;
122
      int                bytenum  = fulladdr & 0x00000003;
123 19 jeremybenn
 
124 93 jeremybenn
      unsigned char      mask[4];
125
      unsigned char      res[4];
126 19 jeremybenn
 
127 93 jeremybenn
      /* Set the mask, read and get the result */
128
      memset (mask, 0, sizeof (mask));
129
      mask[bytenum] = 0xff;
130 19 jeremybenn
 
131 101 jeremybenn
      if (0 != config.ext.read_up (config.ext.class_ptr, wordaddr, mask, res,
132
                                   4))
133 93 jeremybenn
        {
134
          fprintf (stderr, "Warning: external byte read failed.\n");
135
          return  0;
136
        }
137 19 jeremybenn
 
138 93 jeremybenn
      return  res[bytenum];
139 19 jeremybenn
    }
140 93 jeremybenn
}       /* generic_read_byte() */
141 19 jeremybenn
 
142
 
143 93 jeremybenn
/* --------------------------------------------------------------------------*/
144
/*!Write a byte to an external device
145
 
146
   To model Wishbone accurately, we always do this as a 4-byte access, with a
147
   mask for the bytes we don't want.
148
 
149
   Since this is only a byte, the endianess of the value is irrelevant.
150
 
151
   @note We are passed the device address, but we must convert it to a full
152
         address for external use, to allow the single upcall handler to
153
         decode multiple generic devices.
154
 
155
   @param[in] addr  The device address to write to (host endian)
156
   @param[in] value The byte value to write
157
   @param[in] dat   The device data structure                                */
158
/* --------------------------------------------------------------------------*/
159 19 jeremybenn
static void
160 93 jeremybenn
generic_write_byte (oraddr_t  addr,
161
                    uint8_t   value,
162
                    void     *dat)
163 19 jeremybenn
{
164
  struct dev_generic *dev = (struct dev_generic *) dat;
165
 
166 93 jeremybenn
  if (!config.ext.write_up)
167 19 jeremybenn
    {
168
      fprintf (stderr, "Byte write to disabled generic device\n");
169
    }
170
  else if (addr >= dev->size)
171
    {
172
      fprintf (stderr, "Byte written out of range for generic device %s "
173
               "(addr %" PRIxADDR ")\n", dev->name, addr);
174
    }
175
  else
176
    {
177 93 jeremybenn
      unsigned long int  fulladdr = (unsigned long int) (addr + dev->baseaddr);
178
      unsigned long int  wordaddr = fulladdr & 0xfffffffc;
179
      int                bytenum  = fulladdr & 0x00000003;
180 19 jeremybenn
 
181 93 jeremybenn
      unsigned char      mask[4];
182
      unsigned char      val[4];
183 19 jeremybenn
 
184 93 jeremybenn
      /* Set the mask and write data do the write. */
185
      memset (mask, 0, sizeof (mask));
186
      mask[bytenum] = 0xff;
187
      val[bytenum]  = value;
188 19 jeremybenn
 
189 101 jeremybenn
      if (0 != config.ext.write_up (config.ext.class_ptr, wordaddr, mask, val,
190
                                    4))
191 93 jeremybenn
        {
192
          fprintf (stderr, "Warning: external byte write failed.\n");
193
        }
194 19 jeremybenn
    }
195 93 jeremybenn
}       /* generic_write_byte() */
196 19 jeremybenn
 
197
 
198 93 jeremybenn
/* --------------------------------------------------------------------------*/
199
/*!Read a half word from an external device
200
 
201
   To model Wishbone accurately, we always do this as a 4-byte access, with a
202
   mask for the bytes we don't want.
203
 
204
   Since this is a half word, the result must be converted to host endianess.
205
 
206
   @note We are passed the device address, but we must convert it to a full
207
         address for external use, to allow the single upcall handler to
208
         decode multiple generic devices.
209
 
210
   @param[in] addr  The device address to read from (host endian).
211
   @param[in] dat   The device data structure.
212
 
213
   @return  The half word read (host endian).                                */
214
/* --------------------------------------------------------------------------*/
215 19 jeremybenn
static uint16_t
216 93 jeremybenn
generic_read_hw (oraddr_t  addr,
217
                 void     *dat)
218 19 jeremybenn
{
219
  struct dev_generic *dev = (struct dev_generic *) dat;
220
 
221 93 jeremybenn
  if (!config.ext.read_up)
222 19 jeremybenn
    {
223
      fprintf (stderr, "Half word read from disabled generic device\n");
224
      return 0;
225
    }
226
  else if (addr >= dev->size)
227
    {
228
      fprintf (stderr, "Half-word read  out of range for generic device %s "
229
               "(addr %" PRIxADDR ")\n", dev->name, addr);
230
      return 0;
231
    }
232
  else if (addr & 0x1)
233
    {
234 93 jeremybenn
      /* This should be trapped elsewhere - here for safety. */
235 19 jeremybenn
      fprintf (stderr,
236
               "Unaligned half word read from 0x%" PRIxADDR " ignored\n",
237
               addr);
238
      return 0;
239
    }
240
  else
241
    {
242 93 jeremybenn
      unsigned long int  fulladdr = (unsigned long int) (addr + dev->baseaddr);
243
      unsigned long int  wordaddr = fulladdr & 0xfffffffc;
244
      int                hwnum    = fulladdr & 0x00000002;
245 19 jeremybenn
 
246 93 jeremybenn
      unsigned char      mask[4];
247
      unsigned char      res[4];
248 19 jeremybenn
 
249 93 jeremybenn
      /* Set the mask, read and get the result */
250
      memset (mask, 0, sizeof (mask));
251
      mask[hwnum    ] = 0xff;
252
      mask[hwnum + 1] = 0xff;
253 19 jeremybenn
 
254 101 jeremybenn
      if (0 != config.ext.read_up (config.ext.class_ptr, wordaddr, mask, res,
255
                                   4))
256 93 jeremybenn
        {
257
          fprintf (stderr, "Warning: external half word read failed.\n");
258
          return  0;
259
        }
260 19 jeremybenn
 
261 93 jeremybenn
      /* Result converted according to endianess */
262
#ifdef OR32_BIG_ENDIAN
263
      return  (unsigned short int) res[hwnum    ] << 8 |
264
              (unsigned short int) res[hwnum + 1];
265
#else
266
      return  (unsigned short int) res[hwnum + 1] << 8 |
267
              (unsigned short int) res[hwnum    ];
268
#endif
269 19 jeremybenn
    }
270 93 jeremybenn
}       /* generic_read_hw() */
271 19 jeremybenn
 
272
 
273 93 jeremybenn
/* --------------------------------------------------------------------------*/
274
/*!Write a half word to an external device
275
 
276
   To model Wishbone accurately, we always do this as a 4-byte access, with a
277
   mask for the bytes we don't want.
278
 
279
   Since this is a half word, the value must be converted from host endianess.
280
 
281
   @note We are passed the device address, but we must convert it to a full
282
         address for external use, to allow the single upcall handler to
283
         decode multiple generic devices.
284
 
285
   @param[in] addr  The device address to write to (host endian).
286
   @param[in] value The half word value to write (model endian).
287
   @param[in] dat   The device data structure.                               */
288
/* --------------------------------------------------------------------------*/
289 19 jeremybenn
static void
290 93 jeremybenn
generic_write_hw (oraddr_t  addr,
291
                  uint16_t  value,
292
                  void     *dat)
293 19 jeremybenn
{
294
  struct dev_generic *dev = (struct dev_generic *) dat;
295
 
296 93 jeremybenn
  if (!config.ext.write_up)
297 19 jeremybenn
    {
298
      fprintf (stderr, "Half word write to disabled generic device\n");
299
    }
300
  else if (addr >= dev->size)
301
    {
302
      fprintf (stderr, "Half-word written  out of range for generic device %s "
303
               "(addr %" PRIxADDR ")\n", dev->name, addr);
304
    }
305
  else if (addr & 0x1)
306
    {
307
      fprintf (stderr,
308
               "Unaligned half word write to 0x%" PRIxADDR " ignored\n", addr);
309
    }
310
  else
311
    {
312 93 jeremybenn
      unsigned long int  fulladdr = (unsigned long int) (addr + dev->baseaddr);
313
      unsigned long int  wordaddr = fulladdr & 0xfffffffc;
314
      int                hwnum    = fulladdr & 0x00000002;
315 19 jeremybenn
 
316 93 jeremybenn
      unsigned char      mask[4];
317
      unsigned char      val[4];
318 19 jeremybenn
 
319 93 jeremybenn
      /* Set the mask and write data do the write. */
320
      memset (mask, 0, sizeof (mask));
321
      mask[hwnum    ] = 0xff;
322
      mask[hwnum + 1] = 0xff;
323 19 jeremybenn
 
324 93 jeremybenn
      /* Value converted according to endianess */
325
#ifdef OR32_BIG_ENDIAN
326
      val[hwnum    ] = (unsigned char) (value >> 8);
327
      val[hwnum + 1] = (unsigned char) (value     );
328
#else
329
      val[hwnum + 1] = (unsigned char) (value >> 8);
330
      val[hwnum    ] = (unsigned char) (value     );
331
#endif
332 19 jeremybenn
 
333 101 jeremybenn
      if (0 != config.ext.write_up (config.ext.class_ptr, wordaddr, mask, val,
334
                                    4))
335 93 jeremybenn
        {
336
          fprintf (stderr, "Warning: external half word write failed.\n");
337
        }
338 19 jeremybenn
    }
339 93 jeremybenn
}       /* generic_write_hw() */
340 19 jeremybenn
 
341
 
342 93 jeremybenn
/* --------------------------------------------------------------------------*/
343
/*!Read a full word from an external device
344
 
345
   Since this is a full word, the result must be converted to host endianess.
346
 
347
   @note We are passed the device address, but we must convert it to a full
348
         address for external use, to allow the single upcall handler to
349
         decode multiple generic devices.
350
 
351
   @param[in] addr  The device address to read from (host endian).
352
   @param[in] dat   The device data structure.
353
 
354
   @return  The full word read (host endian).                                */
355
/* --------------------------------------------------------------------------*/
356 19 jeremybenn
static uint32_t
357 93 jeremybenn
generic_read_word (oraddr_t  addr,
358
                   void     *dat)
359 19 jeremybenn
{
360
  struct dev_generic *dev = (struct dev_generic *) dat;
361
 
362 93 jeremybenn
  if (!config.ext.read_up)
363 19 jeremybenn
    {
364
      fprintf (stderr, "Full word read from disabled generic device\n");
365
      return 0;
366
    }
367
  else if (addr >= dev->size)
368
    {
369
      fprintf (stderr, "Full word read  out of range for generic device %s "
370
               "(addr %" PRIxADDR ")\n", dev->name, addr);
371
      return 0;
372
    }
373
  else if (0 != (addr & 0x3))
374
    {
375
      fprintf (stderr,
376
               "Unaligned full word read from 0x%" PRIxADDR " ignored\n",
377
               addr);
378
      return 0;
379
    }
380
  else
381
    {
382 93 jeremybenn
      unsigned long int  wordaddr = (unsigned long int) (addr + dev->baseaddr);
383 19 jeremybenn
 
384 93 jeremybenn
      unsigned char      mask[4];
385
      unsigned char      res[4];
386
 
387
      /* Set the mask, read and get the result */
388
      memset (mask, 0xff, sizeof (mask));
389
 
390 101 jeremybenn
      if (0 != config.ext.read_up (config.ext.class_ptr, wordaddr, mask, res,
391
                                   4))
392 93 jeremybenn
        {
393
          fprintf (stderr, "Warning: external full word read failed.\n");
394
          return  0;
395
        }
396
 
397
      /* Result converted according to endianess */
398
#ifdef OR32_BIG_ENDIAN
399
      return  (unsigned long int) res[0] << 24 |
400
              (unsigned long int) res[1] << 16 |
401
              (unsigned long int) res[2] <<  8 |
402
              (unsigned long int) res[3];
403
#else
404
      return  (unsigned long int) res[3] << 24 |
405
              (unsigned long int) res[2] << 16 |
406
              (unsigned long int) res[1] <<  8 |
407
              (unsigned long int) res[0];
408
#endif
409 19 jeremybenn
    }
410 93 jeremybenn
}       /* generic_read_word() */
411 19 jeremybenn
 
412
 
413 93 jeremybenn
/* --------------------------------------------------------------------------*/
414
/*!Write a full word to an external device
415
 
416
   Since this is a half word, the value must be converted from host endianess.
417
 
418
   @note We are passed the device address, but we must convert it to a full
419
         address for external use, to allow the single upcall handler to
420
         decode multiple generic devices.
421
 
422
   @param[in] addr  The device address to write to (host endian).
423
   @param[in] value The full word value to write (host endian).
424
   @param[in] dat   The device data structure.                               */
425
/* --------------------------------------------------------------------------*/
426 19 jeremybenn
static void
427 93 jeremybenn
generic_write_word (oraddr_t  addr,
428
                    uint32_t  value,
429
                    void     *dat)
430 19 jeremybenn
{
431
  struct dev_generic *dev = (struct dev_generic *) dat;
432
 
433 93 jeremybenn
  if (!config.ext.write_up)
434 19 jeremybenn
    {
435
      fprintf (stderr, "Full word write to disabled generic device\n");
436
    }
437
  else if (addr >= dev->size)
438
    {
439
      fprintf (stderr, "Full word written  out of range for generic device %s "
440
               "(addr %" PRIxADDR ")\n", dev->name, addr);
441
    }
442
  else if (0 != (addr & 0x3))
443
    {
444
      fprintf (stderr,
445
               "Unaligned full word write to 0x%" PRIxADDR " ignored\n", addr);
446
    }
447
  else
448
    {
449 93 jeremybenn
      unsigned long int  wordaddr = (unsigned long int) (addr + dev->baseaddr);
450 19 jeremybenn
 
451 93 jeremybenn
      unsigned char      mask[4];
452
      unsigned char      val[4];
453
 
454
      /* Set the mask and write data do the write. */
455
      memset (mask, 0xff, sizeof (mask));
456
 
457
      /* Value converted according to endianess */
458
#ifdef OR32_BIG_ENDIAN
459
      val[0] = (unsigned char) (value >> 24);
460
      val[1] = (unsigned char) (value >> 16);
461
      val[2] = (unsigned char) (value >>  8);
462
      val[3] = (unsigned char) (value      );
463
#else
464
      val[3] = (unsigned char) (value >> 24);
465
      val[2] = (unsigned char) (value >> 16);
466
      val[1] = (unsigned char) (value >>  8);
467
      val[0] = (unsigned char) (value      );
468
#endif
469
 
470 101 jeremybenn
      if (0 != config.ext.write_up (config.ext.class_ptr, wordaddr, mask, val,
471
                                    4))
472 93 jeremybenn
        {
473
          fprintf (stderr, "Warning: external full word write failed.\n");
474
        }
475 19 jeremybenn
    }
476 93 jeremybenn
}       /* generic_write_word() */
477 19 jeremybenn
 
478
 
479
/* Reset is a null operation */
480
 
481
static void
482
generic_reset (void *dat)
483
{
484
  return;
485
 
486
}                               /* generic_reset() */
487
 
488
 
489
/* Status report can only advise of configuration. */
490
 
491
static void
492
generic_status (void *dat)
493
{
494
  struct dev_generic *dev = (struct dev_generic *) dat;
495
 
496
  PRINTF ("\nGeneric device \"%s\" at 0x%" PRIxADDR ":\n", dev->name,
497
          dev->baseaddr);
498
  PRINTF ("  Size 0x%" PRIx32 "\n", dev->size);
499
 
500
  if (dev->byte_enabled)
501
    {
502
      PRINTF ("  Byte R/W enabled\n");
503
    }
504
 
505
  if (dev->hw_enabled)
506
    {
507
      PRINTF ("  Half word R/W enabled\n");
508
    }
509
 
510
  if (dev->word_enabled)
511
    {
512
      PRINTF ("  Full word R/W enabled\n");
513
    }
514
 
515
  PRINTF ("\n");
516
 
517
}                               /* generic_status() */
518
 
519
 
520
/* Functions to set configuration */
521
 
522
static void
523
generic_enabled (union param_val val, void *dat)
524
{
525
  ((struct dev_generic *) dat)->enabled = val.int_val;
526
 
527
}                               /* generic_enabled() */
528
 
529
 
530
static void
531
generic_byte_enabled (union param_val val, void *dat)
532
{
533
  ((struct dev_generic *) dat)->byte_enabled = val.int_val;
534
 
535
}                               /* generic_byte_enabled() */
536
 
537
 
538
static void
539
generic_hw_enabled (union param_val val, void *dat)
540
{
541
  ((struct dev_generic *) dat)->hw_enabled = val.int_val;
542
 
543
}                               /* generic_hw_enabled() */
544
 
545
 
546
static void
547
generic_word_enabled (union param_val val, void *dat)
548
{
549
  ((struct dev_generic *) dat)->word_enabled = val.int_val;
550
 
551
}                               /* generic_word_enabled() */
552
 
553
 
554
static void
555
generic_name (union param_val val, void *dat)
556
{
557
  ((struct dev_generic *) dat)->name = strdup (val.str_val);
558
 
559
  if (!((struct dev_generic *) dat)->name)
560
    {
561
      fprintf (stderr, "Peripheral 16450: name \"%s\": Run out of memory\n",
562
               val.str_val);
563
      exit (-1);
564
    }
565
}                               /* generic_name() */
566
 
567
 
568
static void
569
generic_baseaddr (union param_val val, void *dat)
570
{
571
  ((struct dev_generic *) dat)->baseaddr = val.addr_val;
572
 
573
}                               /* generic_baseaddr() */
574
 
575
 
576
static void
577
generic_size (union param_val val, void *dat)
578
{
579
  ((struct dev_generic *) dat)->size = val.int_val;
580
 
581
}                               /* generic_size() */
582
 
583
 
584
/* Start of new generic section */
585
 
586
static void *
587
generic_sec_start ()
588
{
589
  struct dev_generic *new =
590
    (struct dev_generic *) malloc (sizeof (struct dev_generic));
591
 
592
  if (0 == new)
593
    {
594
      fprintf (stderr, "Generic peripheral: Run out of memory\n");
595
      exit (-1);
596
    }
597
 
598
  /* Default names */
599
 
600
  new->enabled = 1;
601
  new->byte_enabled = 1;
602
  new->hw_enabled = 1;
603
  new->word_enabled = 1;
604
  new->name = "anonymous external peripheral";
605
  new->baseaddr = 0;
606
  new->size = 0;
607
 
608
  return new;
609
 
610
}                               /* generic_sec_start() */
611
 
612
 
613
/* End of new generic section */
614
 
615
static void
616
generic_sec_end (void *dat)
617
{
618
  struct dev_generic *generic = (struct dev_generic *) dat;
619
  struct mem_ops ops;
620
 
621
  /* Give up if not enabled, or if size is zero, or if no access size is
622
     enabled. */
623
 
624
  if (!generic->enabled)
625
    {
626
      free (dat);
627
      return;
628
    }
629
 
630
  if (0 == generic->size)
631
    {
632
      fprintf (stderr, "Generic peripheral \"%s\" has size 0: ignoring",
633
               generic->name);
634
      free (dat);
635
      return;
636
    }
637
 
638
  if (!generic->byte_enabled &&
639
      !generic->hw_enabled && !generic->word_enabled)
640
    {
641
      fprintf (stderr, "Generic peripheral \"%s\" has no access: ignoring",
642
               generic->name);
643
      free (dat);
644
      return;
645
    }
646
 
647
  /* Zero all the ops, then set the ones we care about. Read/write delays will
648
   * come from the peripheral if desired.
649
   */
650
 
651
  memset (&ops, 0, sizeof (struct mem_ops));
652
 
653
  if (generic->byte_enabled)
654
    {
655
      ops.readfunc8 = generic_read_byte;
656
      ops.writefunc8 = generic_write_byte;
657
      ops.read_dat8 = dat;
658
      ops.write_dat8 = dat;
659
    }
660
 
661
  if (generic->hw_enabled)
662
    {
663
      ops.readfunc16 = generic_read_hw;
664
      ops.writefunc16 = generic_write_hw;
665
      ops.read_dat16 = dat;
666
      ops.write_dat16 = dat;
667
    }
668
 
669
  if (generic->word_enabled)
670
    {
671
      ops.readfunc32 = generic_read_word;
672
      ops.writefunc32 = generic_write_word;
673
      ops.read_dat32 = dat;
674
      ops.write_dat32 = dat;
675
    }
676
 
677
  /* Register everything */
678
 
679
  reg_mem_area (generic->baseaddr, generic->size, 0, &ops);
680
 
681
  reg_sim_reset (generic_reset, dat);
682
  reg_sim_stat (generic_status, dat);
683
 
684
}                               /* generic_sec_end() */
685
 
686
 
687
/* Register a generic section. */
688
 
689
void
690
reg_generic_sec (void)
691
{
692
  struct config_section *sec = reg_config_sec ("generic",
693
                                               generic_sec_start,
694
                                               generic_sec_end);
695
 
696 224 jeremybenn
  reg_config_param (sec, "enabled",      PARAMT_INT, generic_enabled);
697
  reg_config_param (sec, "byte_enabled", PARAMT_INT, generic_byte_enabled);
698
  reg_config_param (sec, "hw_enabled",   PARAMT_INT, generic_hw_enabled);
699
  reg_config_param (sec, "word_enabled", PARAMT_INT, generic_word_enabled);
700
  reg_config_param (sec, "name",         PARAMT_STR, generic_name);
701
  reg_config_param (sec, "baseaddr",     PARAMT_ADDR, generic_baseaddr);
702
  reg_config_param (sec, "size",         PARAMT_INT, generic_size);
703 19 jeremybenn
 
704
}                               /* reg_generic_sec */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.