WizziLab / modem_ref_v5_3_217

Dependents:   modem_ref_helper_for_v5_3_217

Revision:
48:37bf104b3a39
Parent:
41:6f83174ffed4
Child:
49:7a2f4992ff90
diff -r 6f83174ffed4 -r 37bf104b3a39 src/modem_ref.cpp
--- a/src/modem_ref.cpp	Mon Nov 26 16:42:16 2018 +0000
+++ b/src/modem_ref.cpp	Mon Feb 04 17:34:17 2019 +0000
@@ -664,6 +664,37 @@
     DEALLOC_BUFFER(tmp);
 }
 
+public void modem_remote_read_file_root(u8* itf, u8 itf_length, void *istatus , u8 fid, void *data, u32 offset, u32 length, u8* root_key, u8 id)
+{
+    ALLOC_BUFFER(u8, tmp, ALP_ACTION_TAG_SIZE + ALP_ACTION_FORWARD_SIZE(itf_length) + ALP_ACTION_F_RD_DATA_SIZE_MAX);
+    u8* p = tmp;
+    u32 perm_offset;
+    
+    ASSERT(root_key != NULL, "Missing ROOT KEY\n");
+    
+    g_modem.user[id].data    = (u8*)data;
+    g_modem.user[id].istatus = (u8*)istatus;
+
+    REF_PRINT("RMT RD FILE (ROOT)[%d]@%d %d Bytes (itf %d Bytes)\n", fid, offset, length, itf_length);
+    ALP_ACTION_TAG(p, id, true);
+    ALP_ACTION_FORWARD(p, itf, itf_length);
+    
+    // Mark start of permission request
+    perm_offset = (u32)(p-tmp);
+    
+    // Actual Operation will take place after PERM_REQ
+    p = &tmp[perm_offset + ALP_ACTION_PERM_REQ_OFFSET];
+    ALP_ACTION_F_RD_DATA(p, true, fid, offset, length);
+    
+    modem_add_root_permission(&tmp[perm_offset], root_key,
+            &tmp[perm_offset + ALP_ACTION_PERM_REQ_OFFSET],
+            ALP_ACTION_F_RD_DATA_SIZE(offset, length));
+            
+    SERIAL_SEND(WC_FLOW_ALP_UNS, tmp, (u8)(p-tmp));
+    DEALLOC_BUFFER(tmp);
+}
+
+
 public void modem_remote_write_file(u8* itf, u8 itf_length, void *istatus , u8 fid, void *data, u32 offset, u32 length, u8 id)
 {
     ALLOC_BUFFER(u8,tmp,ALP_ACTION_TAG_SIZE + ALP_ACTION_FORWARD_SIZE(itf_length) + ALP_ACTION_F_WR_DATA_SIZE_MAX(length));
@@ -678,6 +709,35 @@
     DEALLOC_BUFFER(tmp);
 }
 
+public void modem_remote_write_file_root(u8* itf, u8 itf_length, void *istatus , u8 fid, void *data, u32 offset, u32 length, u8* root_key, u8 id)
+{
+    ALLOC_BUFFER(u8, tmp, ALP_ACTION_TAG_SIZE + ALP_ACTION_FORWARD_SIZE(itf_length) + ALP_ACTION_F_WR_DATA_SIZE_MAX(length));
+    u8* p = tmp;
+    u32 perm_offset;
+    
+    ASSERT(root_key != NULL, "Missing ROOT KEY\n");
+    
+    g_modem.user[id].istatus = (u8*)istatus;
+
+    REF_PRINT("RMT WR FILE (ROOT)[%d]@%d %d Bytes (itf %d Bytes)\n",fid,offset,length,itf_length);
+    ALP_ACTION_TAG(p, id, true);
+    ALP_ACTION_FORWARD(p, itf, itf_length);
+    
+    // Mark start of permission request
+    perm_offset = (u32)(p-tmp);
+    
+    // Actual Operation will take place after PERM_REQ
+    p = &tmp[perm_offset + ALP_ACTION_PERM_REQ_OFFSET];
+    ALP_ACTION_F_WR_DATA(p, true, fid, offset, length, data);
+    
+    modem_add_root_permission(&tmp[perm_offset], root_key,
+            &tmp[perm_offset + ALP_ACTION_PERM_REQ_OFFSET],
+            ALP_ACTION_F_WR_DATA_SIZE(offset, length));
+    
+    SERIAL_SEND(WC_FLOW_ALP_UNS,tmp, (u8)(p-tmp));
+    DEALLOC_BUFFER(tmp);
+}
+
 public void modem_enable_urc(u8 type, u8 ifid, u8 val, u8 enable, u8 id)
 {
     u8 tmp[ALP_ACTION_TAG_SIZE + ALP_ACTION_URCC_SIZE(ALP_URC_TYPE_LQUAL)];