summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/sparc/leon3/shmsupp/getcfg.c
blob: 7e35352e13f4d6e988258c86120f282fd71629f6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*  void Shm_Get_configuration( localnode, &shmcfg )
 *
 *  This routine initializes, if necessary, and returns a pointer
 *  to the Shared Memory Configuration Table for the XXX target.
 *
 *  INPUT PARAMETERS:
 *    localnode - local node number
 *    shmcfg    - address of pointer to SHM Config Table
 *
 *  OUTPUT PARAMETERS:
 *    *shmcfg   - pointer to SHM Config Table
 *
XXX: FIX THE COMMENTS BELOW WHEN THE CPU IS KNOWN
 *  NOTES:  The XYZ does not have an interprocessor interrupt.
 *
 *          The following table illustrates the configuration limitations:
 *
 *                                   BUS     MAX
 *                          MODE    ENDIAN  NODES
 *                        ========= ====== =======
 *                         POLLED    BIG    2+
 *                        INTERRUPT **** NOT SUPPORTED ****
 *
 *  COPYRIGHT (c) 1989-1999.
 *  On-Line Applications Research Corporation (OAR).
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.rtems.com/license/LICENSE.
 */

#include <rtems.h>
#include <bsp.h>
#include <shm_driver.h>

/* multiprocessor communications interface (MPCI) table */


extern rtems_mpci_entry Shm_Get_packet(
  rtems_packet_prefix **
);

rtems_mpci_entry Shm_Initialization( void );

extern rtems_mpci_entry Shm_Receive_packet(
  rtems_packet_prefix **
);

extern rtems_mpci_entry Shm_Return_packet(
  rtems_packet_prefix *
);

extern rtems_mpci_entry Shm_Send_packet(
  uint32_t,
  rtems_packet_prefix *
);


/* rtems_mpci_table MPCI_table  = { */
/*   100000,                     /\* default timeout value in ticks *\/ */
/*   MAX_PACKET_SIZE,            /\* maximum packet size *\/ */
/*   Shm_Initialization,         /\* initialization procedure   *\/ */
/*   Shm_Get_packet,             /\* get packet procedure       *\/ */
/*   Shm_Return_packet,          /\* return packet procedure    *\/ */
/*   Shm_Send_packet,            /\* packet send procedure      *\/ */
/*   Shm_Receive_packet          /\* packet receive procedure   *\/ */
/* }; */


/*
 *  configured if currently polling of interrupt driven
 */

#define INTERRUPT 0        /* XXX: */
#define POLLING   1        /* XXX: fix me -- is polling ONLY!!! */

/* Let user override this configuration by declaring this a weak variable */
shm_config_table BSP_shm_cfgtbl __attribute__((weak)) =
{
  (vol_u32 *)0x40000000,    /* USER OVERRIDABLE */
  0x00001000,               /* USER OVERRIDABLE */
  SHM_BIG,
  NULL_CONVERT,
  INTR_MODE,
  Shm_Cause_interrupt,
  {
    NULL,
    1 << LEON3_MP_IRQ,      /* USER OVERRIDABLE */
    4,
  },
};

void Shm_Get_configuration(
  uint32_t   localnode,
  shm_config_table **shmcfg
)
{
  extern rtems_configuration_table Configuration;
  int i;
  unsigned int tmp;

  BSP_shm_cfgtbl.format       = SHM_BIG;

  /*
   *  Override cause_intr or shm_isr if your target has
   *  special requirements.
   */

  BSP_shm_cfgtbl.cause_intr   = Shm_Cause_interrupt;

#ifdef NEUTRAL_BIG
  BSP_shm_cfgtbl.convert      = NULL_CONVERT;
#else
  BSP_shm_cfgtbl.convert      = CPU_swap_u32;
#endif

  BSP_shm_cfgtbl.poll_intr    = INTR_MODE;
  BSP_shm_cfgtbl.Intr.address =
     (vol_u32 *) &(LEON3_IrqCtrl_Regs->force[LEON3_Cpu_Index]);
  if (BSP_shm_cfgtbl.Intr.value == 0)
    BSP_shm_cfgtbl.Intr.value = 1 << LEON3_MP_IRQ; /* Use default MP-IRQ */
  BSP_shm_cfgtbl.Intr.length  = 4;

  if (LEON3_Cpu_Index == 0) {
    tmp = 0;
    for (i = 1;
         i < (Configuration.User_multiprocessing_table)->maximum_nodes; i++)
      tmp |= (1 << i);
    LEON3_IrqCtrl_Regs->mpstat = tmp;
  }

  *shmcfg = &BSP_shm_cfgtbl;
}