]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ipc/ipcdev.git/blob - linux/src/utils/MultiProc.c
Linux IPC: Resticted KERNEL dir config variable to omap54xx_smp builds
[ipc/ipcdev.git] / linux / src / utils / MultiProc.c
1 /*
2  * Copyright (c) 2012, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * *  Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * *  Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * *  Neither the name of Texas Instruments Incorporated nor the names of
17  *    its contributors may be used to endorse or promote products derived
18  *    from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 /*
33  *  ======== MultiProc.c ========
34  *
35  *  Implementation of functions to access processor IDs configured on BIOS side.
36  */
38 #include <Std.h>
40 #include <assert.h>
41 #include <string.h>
43 #include <ti/ipc/MultiProc.h>
44 #include <_MultiProc.h>
46 /*
47  *  ======== MultiProc_getId ========
48  */
49 UInt16 MultiProc_getId(String name)
50 {
51     Int    i;
52     UInt16 id;
54     assert(name != NULL);
56     id = MultiProc_INVALIDID;
57     for (i = 0; i < _MultiProc_cfg.numProcessors; i++) {
58         if ((_MultiProc_cfg.nameList[i] != NULL) &&
59                 (strcmp(name, _MultiProc_cfg.nameList[i]) == 0)) {
60             id = i;
61         }
62     }
63     return (id);
64 }
66 /*
67  *  ======== MultiProc_getName ========
68  */
69 String MultiProc_getName(UInt16 id)
70 {
71     assert(id < _MultiProc_cfg.numProcessors);
73     return (_MultiProc_cfg.nameList[id]);
74 }
76 /*
77  *  ======== MultiProc_getNumProcessors ========
78  */
79 UInt16 MultiProc_getNumProcessors()
80 {
81     return (_MultiProc_cfg.numProcessors);
82 }
85 /*
86  *  ======== MultiProc_self ========
87  */
88 UInt16 MultiProc_self()
89 {
90     return (_MultiProc_cfg.id);
91 }
93 /*
94  *  ======== MultiProc_setLocalId ========
95  */
96 Int MultiProc_setLocalId(UInt16 id)
97 {
98     /* id must be less than the number of processors */
99     assert(id < _MultiProc_cfg.numProcessors);
101     /*
102      *  Check the following
103      *  1. Make sure the statically configured constant was invalid.
104      *     To call setLocalId, the id must have been set to invalid.
105      *  2. Make sure the call is made before module startup
106      */
107     if ((_MultiProc_cfg.id == MultiProc_INVALIDID) /* &&
108         (Startup_rtsDone() == FALSE) */  )  {
109         /* It is ok to set the id */
110         _MultiProc_cfg.id = id;
111         return (MultiProc_S_SUCCESS);
112     }
114     return (MultiProc_E_FAIL);