summaryrefslogtreecommitdiff
path: root/source/config/commands_marshal_cpp.xsl
blob: 4addd398c10e68c1133dcc4a4aa29e3fb6880032 (plain)
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<?xml version="1.0" encoding="utf-8"?>
<!--
* Copyright (C) ST-Ericsson SA 2011
* License terms: 3-clause BSD license
-->
<stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform">

<import href="common.xsl"/>

<output method="text"/>
<strip-space elements="*"/>
<param name="target"/>

<template match="group/documentation" mode="marshal">
<if test="../interface/@name != 'ADbg'">
/*
 * <value-of select="normalize-space(.)"/>
 */
</if>
</template>

<template match="group/documentation" mode="unmarshal">
<if test="../interface/@name != 'ADbg'">
  /*
   * <value-of select="normalize-space(.)"/>
   */
</if>
</template>

<template name="unmarshal">
 <param name="name"/>
 <param name="direction"/>

 <choose>
  <when test="name($direction)='output'">
    /* Command <value-of select="../@name"/> / <value-of select="@name"/> (<value-of select="../@number"/> / <value-of select="@number"/>) */ 
    case COMMAND(FALSE, <call-template name="groupid"><with-param name="path" select=".."/></call-template>, <call-template name="commandid"/>):
    {
<apply-templates select="input/value" mode="deserialize_size" /><apply-templates select="input/value" mode="deserialize" />      ReturnValue = <value-of select="$name" />(Session<apply-templates select="input/value" mode="call" />);<apply-templates select="input/value" mode="clean"/>
    }
    break;
  </when>
  <when test="name($direction)='input'">
    /* Response to <value-of select="../@name"/> / <value-of select="@name"/> (<value-of select="../@number"/> / <value-of select="@number"/>) */ 
    case COMMAND(TRUE, <call-template name="groupid"><with-param name="path" select=".."/></call-template>, <call-template name="commandid"/>):
    {
<apply-templates select="output/value" mode="deserialize_size" />      ResponseStatus = (ErrorCode_e)Serialization::get_uint32_le(&amp;Data_p);<if test="count(output/value) > 0">
      if (E_SUCCESS == ResponseStatus)
      {
<apply-templates select="output/value" mode="deserialize" />      }</if>
      ReturnValue = <value-of select="$name" />(Session, ResponseStatus<apply-templates select="output/value" mode="call"><with-param name="continue" select="'true'" /></apply-templates>);<apply-templates select="output/value" mode="clean"/>
    }
    break;
  </when>
 </choose>
</template>

<template match="/commandspec">/* $Copyright ST-Ericsson 2010$ */
/* NOTE: This is an automatically generated file. DO NOT EDIT! */
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;

#include "t_command_protocol.h"
#include "commands.h"
//#include "custom_commands.h" // when customer commands will be implemented
#include "command_ids.h"
#include "commands_impl.h"
#include "error_codes.h"
#include "Serialization.h"
#include "t_r15_network_layer.h"
#include "Event.h"
#include "LCDriverMethods.h"

#define COMMAND(response, group, id) ((((int)(response)) &lt;&lt; 30) | (((int)(group)) &lt;&lt; 16) | ((int)(id))) 
#define COMMANDDATA(TypeP,ApplicationP,CommandP,SessionP,SizeP) \
  memset((uint8*)&amp;CmdData, 0x00, sizeof(CommandData_t)); \
  CmdData.Type             = TypeP; \
  CmdData.ApplicationNr    = ApplicationP; \
  CmdData.CommandNr        = CommandP; \
  CmdData.SessionNr        = SessionP; \
  CmdData.Payload.Size     = SizeP; \
  CmdData.Payload.Data_p   = NULL; \
  if(SizeP != 0)\
  {\
    CmdData.Payload.Data_p = (uint8 *)malloc(sizeof(ErrorCode_e)+SizeP); \
    if(NULL == CmdData.Payload.Data_p) \
    { \
      return E_ALLOCATE_FAILED; \
    }\
  }

#define COMMANDDATAOUT(TypeP,ApplicationP,CommandP,SessionP,SizeP) \
  memset((uint8*)&amp;CmdData, 0x00, sizeof(CommandData_t)); \
  CmdData.Type                    = TypeP; \
  CmdData.ApplicationNr           = ApplicationP; \
  CmdData.CommandNr               = CommandP; \
  CmdData.SessionNr               = SessionP; \
  CmdData.Payload.Size            = SizeP; \
  CmdData.Payload.Data_p          = NULL; \
  if(SizeP != 0)\
  {\
    CmdData.Payload.Data_p = (uint8 *)malloc( SizeP); \
    if(NULL == CmdData.Payload.Data_p) \
    { \
      return E_ALLOCATE_FAILED; \
    }\
  }

  ErrorCode_e LoaderRpcInterfaceImpl::Do_CEH_Callback(CommandData_t *CmdData_p)
  {
    ErrorCode_e ReturnValue = E_GENERAL_FATAL_ERROR;
    ErrorCode_e ResponseStatus = E_GENERAL_FATAL_ERROR;
    boolean response = FALSE;
    const void *Data_p = CmdData_p-&gt;Payload.Data_p;
    uint16 Session = CmdData_p-&gt;SessionNr;
  
    if (CmdData_p-&gt;Type == GENERAL_RESPONSE_PACKAGE)
    {
      response = TRUE;
    }
    else
    {
      response = FALSE;
    }

    Session = CmdData_p-&gt;SessionNr;

    switch(COMMAND(response, CmdData_p-&gt;ApplicationNr, CmdData_p-&gt;CommandNr))
    {
<apply-templates select="group" mode="unmarshal"/>
    default:
      {
        return E_COMMAND_NO_ERROR; // Do_CustomCEH_Call(CmdData_p); // when customer commands will be implemented
      }
    }

    if (response)
    {
      lcdMethods_-&gt;AddEvent(new Event(EVENT_GR_RECEIVED, ResponseStatus, CmdData_p-&gt;ApplicationNr, CmdData_p-&gt;CommandNr));
    }
    else
    {
      lcdMethods_-&gt;AddEvent(new Event(EVENT_CMD_RECEIVED, 0, CmdData_p-&gt;ApplicationNr, CmdData_p-&gt;CommandNr));
    }

    return ReturnValue;
  }
<apply-templates select="group" mode="marshal"/>
</template>

<template match="group/command" mode="marshal">
<if test="(contains(@source, &apos;PC&apos;)) and (@ADbg!='true')">
ErrorCode_e <value-of select="concat('LoaderRpcInterface::DoRPC_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />(uint16 SessionOut<apply-templates select="input/value" mode="declare" />)
{
  ErrorCode_e Answer;
  CommandData_t CmdData;
  void *Data_p;
  uint32 PLSize = 0;
<apply-templates select="input/value" mode="serialize_size_declaration" />
<apply-templates select="input/value" mode="serialize_size"/>
  COMMANDDATAOUT(COMMAND_TYPE, <call-template name="groupidmain"/>, <call-template name="commandid"/>, SessionOut, PLSize);
  (void)(Data_p);
  Data_p = CmdData.Payload.Data_p;
<apply-templates select="input/value" mode="serialize"/>
  Answer = lcmInterface_->CommandSend(&amp;CmdData);

  if(NULL != CmdData.Payload.Data_p)
    free(CmdData.Payload.Data_p);
  return Answer;    
}
</if>
<if test="(contains(@source, &apos;ME&apos;)) and (@ADbg!='true')">
ErrorCode_e <value-of select="concat('LoaderRpcInterface::DoneRPC_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />(uint16 Session, ErrorCode_e Status<apply-templates select="output/value" mode="declare"><with-param name="continue" select="'true'" /></apply-templates>)
{
  ErrorCode_e Answer;
  CommandData_t CmdData;
  void *Data_p;
  uint32 PLSize = 0;
<apply-templates select="output/value" mode="serialize_size_declaration" />
  PLSize += sizeof(ErrorCode_e);
<apply-templates select="output/value" mode="serialize_size"/>
  COMMANDDATA(GENERAL_RESPONSE, <call-template name="groupidmain"/>, <call-template name="commandid"/>, Session, PLSize);
  Data_p = CmdData.Payload.Data_p;
  
  Serialization::put_uint32_le(&amp;Data_p, Status);
<apply-templates select="output/value" mode="serialize"/>
  Answer = lcmInterface_->CommandSend(&amp;CmdData);

  if(NULL != CmdData.Payload.Data_p)
    free(CmdData.Payload.Data_p);
  return Answer;    
}
</if>
</template>
  
<template match="group/command" mode="unmarshal">
  <if test="(contains(@source, &apos;PC&apos;)) and (@ADbg!='true')">
    <call-template name="unmarshal">
      <with-param name="name" select="concat('DoneRPC_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name, 'Impl')" />
      <with-param name="direction" select="input"/>
    </call-template>
  </if>
  <if test="(contains(@source, &apos;ME&apos;)) and (@ADbg!='true')">
    <call-template name="unmarshal">
      <with-param name="name" select="concat('DoRPC_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name, 'Impl')" />
      <with-param name="direction" select="output"/>
    </call-template>
  </if>
</template>
  
</stylesheet>