2015-06-19 22:32:52 +08:00
|
|
|
/* k_move_data.c */
|
2015-04-11 07:44:37 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1997-2014 Wind River Systems, Inc.
|
|
|
|
*
|
2015-10-07 00:00:37 +08:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2015-04-11 07:44:37 +08:00
|
|
|
*
|
2015-10-07 00:00:37 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2015-04-11 07:44:37 +08:00
|
|
|
*
|
2015-10-07 00:00:37 +08:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2015-04-11 07:44:37 +08:00
|
|
|
*/
|
|
|
|
|
2015-06-19 22:56:52 +08:00
|
|
|
#include <micro_private.h>
|
2015-05-23 03:19:28 +08:00
|
|
|
#include <string.h>
|
2015-04-11 07:44:37 +08:00
|
|
|
#include <toolchain.h>
|
|
|
|
#include <sections.h>
|
|
|
|
#include <misc/__assert.h>
|
|
|
|
|
2015-07-02 05:22:39 +08:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* mvdreq_docont -
|
|
|
|
*
|
2015-07-02 05:29:04 +08:00
|
|
|
* @return N/A
|
2015-07-02 05:22:39 +08:00
|
|
|
*/
|
2015-04-21 04:11:03 +08:00
|
|
|
static void mvdreq_docont(struct k_args *Cont)
|
|
|
|
{
|
2015-08-25 01:08:13 +08:00
|
|
|
struct k_args *next;
|
2015-04-11 07:44:37 +08:00
|
|
|
|
2015-04-21 04:11:03 +08:00
|
|
|
while (Cont) {
|
2015-08-25 01:08:13 +08:00
|
|
|
next = Cont;
|
2015-08-24 22:29:21 +08:00
|
|
|
Cont = Cont->next;
|
2015-08-25 01:08:13 +08:00
|
|
|
SENDARGS(next);
|
2015-04-21 04:11:03 +08:00
|
|
|
}
|
|
|
|
}
|
2015-04-11 07:44:37 +08:00
|
|
|
|
2015-07-02 05:22:39 +08:00
|
|
|
/**
|
|
|
|
*
|
2015-07-02 05:51:40 +08:00
|
|
|
* @brief Perform movedata request
|
2015-07-02 05:22:39 +08:00
|
|
|
*
|
2015-07-02 05:29:04 +08:00
|
|
|
* @return N/A
|
2015-07-02 05:22:39 +08:00
|
|
|
*/
|
2015-04-21 04:11:03 +08:00
|
|
|
static void mvdreq_copy(struct moved_req *ReqArgs)
|
|
|
|
{
|
2015-05-26 01:18:47 +08:00
|
|
|
memcpy(ReqArgs->destination, ReqArgs->source,
|
2015-08-26 04:10:59 +08:00
|
|
|
OCTET_TO_SIZEOFUNIT(ReqArgs->total_size));
|
2015-04-21 04:11:03 +08:00
|
|
|
|
2015-08-26 04:08:53 +08:00
|
|
|
if (ReqArgs->action & MVDACT_SNDACK)
|
2015-08-26 04:15:12 +08:00
|
|
|
mvdreq_docont(ReqArgs->extra.setup.continuation_send);
|
2015-08-26 04:08:53 +08:00
|
|
|
if (ReqArgs->action & MVDACT_RCVACK)
|
2015-08-26 04:15:12 +08:00
|
|
|
mvdreq_docont(ReqArgs->extra.setup.continuation_receive);
|
2015-04-21 04:11:03 +08:00
|
|
|
}
|
2015-04-11 07:44:37 +08:00
|
|
|
|
2015-07-02 05:22:39 +08:00
|
|
|
/**
|
|
|
|
*
|
2015-07-02 05:51:40 +08:00
|
|
|
* @brief Process a movedata request
|
2015-07-02 05:22:39 +08:00
|
|
|
*
|
2015-07-02 05:29:04 +08:00
|
|
|
* @return N/A
|
2015-07-02 05:22:39 +08:00
|
|
|
*/
|
2015-04-29 02:35:52 +08:00
|
|
|
void _k_movedata_request(struct k_args *Req)
|
2015-04-11 07:44:37 +08:00
|
|
|
{
|
|
|
|
struct moved_req *ReqArgs;
|
|
|
|
|
2015-08-26 04:17:05 +08:00
|
|
|
ReqArgs = &(Req->args.moved_req);
|
2015-04-11 07:44:37 +08:00
|
|
|
|
|
|
|
__ASSERT_NO_MSG(0 ==
|
2015-08-26 04:10:59 +08:00
|
|
|
(ReqArgs->total_size %
|
2015-04-11 07:44:37 +08:00
|
|
|
SIZEOFUNIT_TO_OCTET(1))); /* must be a multiple of size_t */
|
2015-08-26 04:08:53 +08:00
|
|
|
__ASSERT_NO_MSG(!(ReqArgs->action & MVDACT_INVALID));
|
2015-04-11 07:44:37 +08:00
|
|
|
|
2015-10-21 00:42:33 +08:00
|
|
|
/*
|
|
|
|
* If no data is to be transferred, just execute the continuation
|
|
|
|
* packet, if any, and get out:
|
2015-04-11 07:44:37 +08:00
|
|
|
*/
|
2015-08-26 04:10:59 +08:00
|
|
|
if (0 == ReqArgs->total_size) {
|
2015-08-26 04:08:53 +08:00
|
|
|
if (ReqArgs->action & MVDACT_SNDACK)
|
2015-10-21 00:42:33 +08:00
|
|
|
/* Send ack continuation */
|
2015-04-11 07:44:37 +08:00
|
|
|
mvdreq_docont(
|
2015-10-21 00:42:33 +08:00
|
|
|
ReqArgs->extra.setup.continuation_send);
|
2015-08-26 04:08:53 +08:00
|
|
|
if (ReqArgs->action & MVDACT_RCVACK)
|
2015-10-21 00:42:33 +08:00
|
|
|
/* Recv ack continuation */
|
2015-04-11 07:44:37 +08:00
|
|
|
mvdreq_docont(
|
2015-10-21 00:42:33 +08:00
|
|
|
ReqArgs->extra.setup.continuation_receive);
|
2015-04-11 07:44:37 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-04-21 04:07:26 +08:00
|
|
|
mvdreq_copy(ReqArgs);
|
2015-04-11 07:44:37 +08:00
|
|
|
}
|