source: rtems/c/src/lib/libbsp/sparc/leon3/shmsupp/getcfg.c @ 39e8aa9

4.115
Last change on this file since 39e8aa9 was 39e8aa9, checked in by Joel Sherrill <joel.sherrill@…>, on 02/17/12 at 20:28:19

PR 2015 - LEON3: make SHM driver configurable using weak

PR 2015/bsps

Since the configuration struct is always present one can let
DATA initialize it to reduce footprint, at the same time it
is made weak to let the user able to configure the SHM driver
without editing the driver code.

Signed-off-by: Daniel Hellstrom <daniel@…>

  • Property mode set to 100644
File size: 3.6 KB
Line 
1/*  void Shm_Get_configuration( localnode, &shmcfg )
2 *
3 *  This routine initializes, if necessary, and returns a pointer
4 *  to the Shared Memory Configuration Table for the XXX target.
5 *
6 *  INPUT PARAMETERS:
7 *    localnode - local node number
8 *    shmcfg    - address of pointer to SHM Config Table
9 *
10 *  OUTPUT PARAMETERS:
11 *    *shmcfg   - pointer to SHM Config Table
12 *
13XXX: FIX THE COMMENTS BELOW WHEN THE CPU IS KNOWN
14 *  NOTES:  The XYZ does not have an interprocessor interrupt.
15 *
16 *          The following table illustrates the configuration limitations:
17 *
18 *                                   BUS     MAX
19 *                          MODE    ENDIAN  NODES
20 *                        ========= ====== =======
21 *                         POLLED    BIG    2+
22 *                        INTERRUPT **** NOT SUPPORTED ****
23 *
24 *  COPYRIGHT (c) 1989-1999.
25 *  On-Line Applications Research Corporation (OAR).
26 *
27 *  The license and distribution terms for this file may be
28 *  found in the file LICENSE in this distribution or at
29 *  http://www.rtems.com/license/LICENSE.
30 *
31 *  getcfg.c,v 1.7.8.1 2003/09/04 18:44:56 joel Exp
32 */
33
34#include <rtems.h>
35#include <bsp.h>
36#include <shm_driver.h>
37
38/* multiprocessor communications interface (MPCI) table */
39
40
41extern rtems_mpci_entry Shm_Get_packet(
42  rtems_packet_prefix **
43);
44
45rtems_mpci_entry Shm_Initialization( void );
46
47extern rtems_mpci_entry Shm_Receive_packet(
48  rtems_packet_prefix **
49);
50
51extern rtems_mpci_entry Shm_Return_packet(
52  rtems_packet_prefix *
53);
54
55extern rtems_mpci_entry Shm_Send_packet(
56  uint32_t,
57  rtems_packet_prefix *
58);
59
60
61/* rtems_mpci_table MPCI_table  = { */
62/*   100000,                     /\* default timeout value in ticks *\/ */
63/*   MAX_PACKET_SIZE,            /\* maximum packet size *\/ */
64/*   Shm_Initialization,         /\* initialization procedure   *\/ */
65/*   Shm_Get_packet,             /\* get packet procedure       *\/ */
66/*   Shm_Return_packet,          /\* return packet procedure    *\/ */
67/*   Shm_Send_packet,            /\* packet send procedure      *\/ */
68/*   Shm_Receive_packet          /\* packet receive procedure   *\/ */
69/* }; */
70
71
72/*
73 *  configured if currently polling of interrupt driven
74 */
75
76#define INTERRUPT 0        /* XXX: */
77#define POLLING   1        /* XXX: fix me -- is polling ONLY!!! */
78
79/* Let user override this configuration by declaring this a weak variable */
80shm_config_table BSP_shm_cfgtbl __attribute__((weak)) =
81{
82  (vol_u32 *)0x40000000,    /* USER OVERRIDABLE */
83  0x00001000,               /* USER OVERRIDABLE */
84  SHM_BIG,
85  NULL_CONVERT,
86  INTR_MODE,
87  Shm_Cause_interrupt,
88  {
89    NULL,
90    1 << LEON3_MP_IRQ,      /* USER OVERRIDABLE */
91    4,
92  },
93};
94
95void Shm_Get_configuration(
96  uint32_t   localnode,
97  shm_config_table **shmcfg
98)
99{
100  extern rtems_configuration_table Configuration;
101  int i;
102  unsigned int tmp;
103
104  BSP_shm_cfgtbl.format       = SHM_BIG;
105
106  /*
107   *  Override cause_intr or shm_isr if your target has
108   *  special requirements.
109   */
110
111  BSP_shm_cfgtbl.cause_intr   = Shm_Cause_interrupt;
112
113#ifdef NEUTRAL_BIG
114  BSP_shm_cfgtbl.convert      = NULL_CONVERT;
115#else
116  BSP_shm_cfgtbl.convert      = CPU_swap_u32;
117#endif
118
119  BSP_shm_cfgtbl.poll_intr    = INTR_MODE;
120  BSP_shm_cfgtbl.Intr.address =
121     (vol_u32 *) &(LEON3_IrqCtrl_Regs->force[LEON3_Cpu_Index]);
122  if (BSP_shm_cfgtbl.Intr.value == 0)
123    BSP_shm_cfgtbl.Intr.value = 1 << LEON3_MP_IRQ; /* Use default MP-IRQ */
124  BSP_shm_cfgtbl.Intr.length  = 4;
125
126  if (LEON3_Cpu_Index == 0) {
127    tmp = 0;
128    for (i = 1;
129         i < (Configuration.User_multiprocessing_table)->maximum_nodes; i++)
130      tmp |= (1 << i);
131    LEON3_IrqCtrl_Regs->mpstat = tmp;
132  }
133
134  *shmcfg = &BSP_shm_cfgtbl;
135}
Note: See TracBrowser for help on using the repository browser.