annotate src/condat3/com/include/cl_imei.h @ 516:1ed9de6c90bd

src/g23m-gsm/sms/sms_for.c: bogus malloc removed The new error handling code that was not present in TCS211 blob version contains a malloc call that is bogus for 3 reasons: 1) The memory allocation in question is not needed in the first place; 2) libc malloc is used instead of one of the firmware's proper ways; 3) The memory allocation is made inside a function and then never freed, i.e., a memory leak. This bug was caught in gcc-built FreeCalypso fw projects (Citrine and Selenite) because our gcc environment does not allow any use of libc malloc (any reference to malloc produces a link failure), but this code from TCS3.2 is wrong even for Magnetite: if this code path is executed repeatedly over a long time, the many small allocations made by this malloc call without a subsequent free will eventually exhaust the malloc heap provided by the TMS470 environment, malloc will start returning NULL, and the bogus code will treat it as an error. Because the memory allocation in question is not needed at all, the fix entails simply removing it.
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 22 Jul 2018 06:04:49 +0000
parents c8bd5a927942
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 +-----------------------------------------------------------------------------
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 | Project : COMLIB
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 | Modul : cl_imei
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 +-----------------------------------------------------------------------------
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 | Copyright 2002 Texas Instruments Berlin, AG
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 | All rights reserved.
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 |
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 | This file is confidential and a trade secret of Texas
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 | Instruments Berlin, AG
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 | The receipt of or possession of this file does not convey
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 | any rights to reproduce or disclose its contents or to
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 | manufacture, use, or sell anything it may describe, in
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 | whole, or in part, without the specific written consent of
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 | Texas Instruments Berlin, AG.
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 +-----------------------------------------------------------------------------
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 | Purpose : Definitions of global types used by common library functions
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 | and the prototypes of those functions.
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 +-----------------------------------------------------------------------------
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 */
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 /*
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 * Version 1.0
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 */
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 /**********************************************************************************/
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 #ifndef CL_IMEI_H
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 #define CL_IMEI_H
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 /**********************************************************************************/
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 /*
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 * Compiler switches
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 */
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 /* Chipset Type Value Value name
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 * Gemini/Pole Star 0 _ge
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 * Hercules 2 _he
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 * Ulysse 3 _ul
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 * Samson 4 _sa
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 * Ulysse G1 13MHz 5 _g1_13
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 * Ulysse G1 26MHz 6 _g1_26
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 * Calypso C05 (rev. A) 7 _cal
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 * Calypso C05 (rev. B) 8 _calb
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 * Ulysse C035 9 _ul35
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 * Calypso C035 10 _cal35
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 * Calypso C035 Lite 11 _lite
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 * Calypso+ 12 _cplus
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 */
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 /******************************************************************************
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 * DIE ID and Platform settings
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 *****************************************************************************/
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 /* DIE ID register
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 #define MEM_DEV_ID0 0xFFFEF000
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 #define MEM_DEV_ID1 0xFFFEF002
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 */
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 /* For D-Sample: $CHIPSET = 7 or 8 (=10 for D-sample AMR). */
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 #ifdef _SIMULATION_
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 #undef FF_PROTECTED_IMEI
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 #endif
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 #ifdef FF_PROTECTED_IMEI
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 #ifdef CL_IMEI_CALYPSO_PLATFORM
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 #define CL_IMEI_DIE_ID_REG (MEM_DEV_ID0 | 0xF010) //+ 0xFFFEF010 for Calypso
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 #endif
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 #if !defined (CL_IMEI_CALYPSO_PLUS_PLATFORM) && !defined (CL_IMEI_CALYPSO_PLATFORM)
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 #define CL_IMEI_OTHER_PLATFORM
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 #endif
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 #endif /* FF_PROTECTED_IMEI */
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 /* DIE ID SIZE is 4 words (16 bits)long */
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 #define CL_IMEI_SIZE 8
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 #define CL_IMEI_ISDID_SIZE 16
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 #define CL_IMEI_DIE_ID_SIZE 4
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 /* Return values */
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 #define CL_IMEI_OK 0
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 #define CL_IMEI_ERROR -1
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 #define CL_IMEI_INVALID_DIE_ID -2
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 #define CL_IMEI_READ_IMEI_FAILED -3
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 /* Possible values for imeiType */
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 #define CL_IMEI_GET_SECURE_IMEI 0
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 #define CL_IMEI_GET_STORED_IMEI 1
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 #define CL_IMEI_CONTROL_IMEI 2
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 /*
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 +------------------------------------------------------------------------------
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 | Function : cl_get_imeisv
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 +------------------------------------------------------------------------------
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 | Description : Common IMEI getter function
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 |
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 | Parameters : imeiBufSize - size of buffer where to store IMEI, min 8 BYTEs
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 | *imeiBufPtr - pointer to buffer where to store the IMEI
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 | imeiType - indicates, if the IMEI should be read from
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 | FFS/Secure ROM (value=CL_IMEI_GET_SECURE_IMEI) or
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 | if the already read and stored IMEI (if available)
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 | should be delivered (value=CL_IMEI_GET_STORED_IMEI)
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 | The second option should be used only by ACI or
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 | BMI to show the IMEISV on mobile's display or
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 | in terminal window, e.g. if user calls *#06#.
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 | For IMEI Control reason (user by ACI), the value
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 | has to be CL_IMEI_CONTROL_IMEI
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 | Return : OK - 0
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 | ERROR - negative values
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 +------------------------------------------------------------------------------
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 */
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 extern BYTE cl_get_imeisv(USHORT imeiBufSize, UBYTE *imeiBufPtr, UBYTE imeiType);
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 /**********************************************************************************/
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113
c8bd5a927942 src/condat3: import of "condat" tree from TCS3.2, pruned
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 #endif /* CL_IMEI_H */