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
|
#include <linux/module.h>
#include <linux/device.h>
#include <linux/cdev.h>
#include <linux/semaphore.h>
#include <linux/firmware.h>
#include <linux/io.h>
#include <linux/wait.h>
#include <linux/interrupt.h>
#include <linux/dma-mapping.h>
#include <linux/fs.h>
#include <linux/syscalls.h>
#include <linux/timer.h>
#include <asm/atomic.h>
#include <mach/mt_boot.h>
#include "eemcs_md.h"
#include "eemcs_ccci.h"
#include "eemcs_debug.h"
#define MDLOGGER_FILE_PATH "/data/mdlog/mdlog5_config"
/*
* @brief Configure the modem runtime data structure.
* @param
* buffer [in] The buffer containing modem runtime data.
* @return Size of the modem runtime data structure is returned always.
*/
KAL_INT32 eemcs_md_runtime_cfg(void *buffer)
{
struct file *filp = NULL;
LOGGING_MODE mdlog_flag = MODE_IDLE;
struct MODEM_RUNTIME_st *runtime = NULL;
int ret = 0;
KAL_ASSERT(buffer != NULL);
runtime = (struct MODEM_RUNTIME_st *)buffer;
memset(runtime, 0, sizeof(struct MODEM_RUNTIME_st));
runtime->Prefix = 0x46494343; //"CCIF"
runtime->Postfix = 0x46494343; //"CCIF"
runtime->BootChannel = CH_CTRL_RX;
runtime->DriverVersion = 0x20110118;
filp = filp_open(MDLOGGER_FILE_PATH, O_RDONLY, 0777);
if (!IS_ERR(filp)) {
ret = kernel_read(filp, 0, (char*)&mdlog_flag, sizeof(int));
if (ret != sizeof(int))
mdlog_flag = MODE_IDLE;
} else {
DBGLOG(BOOT, ERR, "open %s fail: %ld", MDLOGGER_FILE_PATH, PTR_ERR(filp));
filp = NULL;
}
if (filp != NULL) {
filp_close(filp, NULL);
}
if (is_meta_mode() || is_advanced_meta_mode())
runtime->BootingStartID = ((char)mdlog_flag << 8 | META_BOOT_ID);
else
runtime->BootingStartID = ((char)mdlog_flag << 8 | NORMAL_BOOT_ID);
DBGLOG(BOOT, INF, "send /data/mdlog/mdlog5_config =%d to modem!", mdlog_flag);
#if defined (_RUNTIME_MISC_INFO_SUPPORT_)
// misc region, little endian for string
runtime->misc_prefix = 0x4353494D; // "MISC"
runtime->misc_postfix = 0x4353494D; // "MISC"
runtime->index = 0;
runtime->next = 0;
DBGLOG(BOOT, INF, "misc_info_support =0x%x, feature_4_val[0]-(SBP)=0x%x ", \
runtime->support_mask, runtime->feature_4_val[0]);
runtime->support_mask |= (FEATURE_SUPPORT<<(MISC_MD_CCCI_DEBUG*2));
runtime->feature_5_val[0] = 0;
#if defined (DBG_FEATURE_ADD_CCCI_SEQNO)
runtime->feature_5_val[0] |= 1<< CCCI_DBG_ADD_CCCI_SEQNO;
#endif
#if defined (DBG_FEATURE_POLL_MD_STA)
runtime->feature_5_val[0] |= 1<< CCCI_DBG_POLL_MD_STA;
#endif
DBGLOG(BOOT, INF, "misc_info_support =0x%x, feature_val=0x%x ", \
runtime->support_mask, runtime->feature_5_val[0]);
#endif
return sizeof(struct MODEM_RUNTIME_st);
}
/*
* @brief Generate a modem runtime data structure.
* @param
* data [out] A pointer to receive the allocated memory address
* of modem runtime data.
* @return Size of the allocated memory.
*/
KAL_UINT32 eemcs_md_gen_runtime_data(void **data)
{
void *runtime_data = NULL;
RUNTIME_BUFF *buf = NULL;
runtime_data = kmalloc(sizeof(struct MODEM_RUNTIME_st) + sizeof(KAL_UINT32), GFP_KERNEL);
if (unlikely(runtime_data == NULL)) {
DBGLOG(BOOT, ERR, "MODEM_RUNTIME_st allocation failed !!");
return 0;
}
*data = runtime_data;
buf = runtime_data;
buf->len = sizeof(struct MODEM_RUNTIME_st);
eemcs_md_runtime_cfg(runtime_data + sizeof(KAL_UINT32));
return sizeof(struct MODEM_RUNTIME_st) + sizeof(KAL_UINT32);
}
/*
* @brief Free a modem runtime data structure.
* @param
* runtime_data [in] The modem runtime data structure returned from eemcs_md_gen_runtime_data().
* @return None.
*/
void eemcs_md_destroy_runtime_data(void *runtime_data)
{
if (runtime_data != NULL) {
kfree(runtime_data);
}
}
|