summaryrefslogtreecommitdiff
path: root/hle/src/hle.c
diff options
context:
space:
mode:
authorlaranjeiro2008-02-22 13:00:58 +0000
committerlaranjeiro2008-02-22 13:00:58 +0000
commit20692649bbbc93f8d9c34141d3df46857fee4422 (patch)
treee341837a635301e3350d8ede991aea93ce1056a2 /hle/src/hle.c
parent5b6ea2a99dbefa0cdcb29050028bfbd48e878c28 (diff)
Replace the length of the buffer with the ETH_PACKET_SIZE define.
Replace the construction of the ipmbox message with the BF_ lib. Added defines in the hal/hle/ipmbox.h to construct the messages. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1452 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'hle/src/hle.c')
-rw-r--r--hle/src/hle.c53
1 files changed, 31 insertions, 22 deletions
diff --git a/hle/src/hle.c b/hle/src/hle.c
index a7545c10b6..ef9b8febe2 100644
--- a/hle/src/hle.c
+++ b/hle/src/hle.c
@@ -12,6 +12,7 @@
*
*/
#include "common/std.h"
+#include "common/defs/ethernet.h"
#include "hal/hle/defs.h"
#include "hal/hle/ipmbox.h"
@@ -89,7 +90,7 @@ void hle_data_send (hle_t *hle, u8 *buffer, uint length)
{
dbg_assert (hle);
dbg_assert (buffer);
- dbg_assert (length >= 60 && length <= 1518);
+ dbg_assert (length >= ETH_PACKET_MIN_SIZE && length <= ETH_PACKET_MAX_SIZE);
/* tracing data */
HLE_TRACE(DATA_SEND, mac_ntb(), length, buffer);
@@ -114,9 +115,11 @@ void hle_data_send_done (hle_t *hle, u8 *buffer)
uint word[2];
/* Tracing data. */
- HLE_TRACE (DATA_SEND_DONE, mac_ntb(), buffer);
+ HLE_TRACE (DATA_SEND_DONE, mac_ntb(), buffer);
+
+ word[0] = BF_FILL (IPMBOX_REG, (MSG_TYPE, HLE_MSG_TYPE_SEND_DONE),
+ (MSG_LENGTH, 1), (PARAM_BUFFER_TYPE, 0));
- word[0] = HLE_MSG_TYPE_SEND_DONE | (1 << 8);
word[1] = (uint) buffer;
ipmbox_tx (hle->ipmbox, word, 2);
@@ -131,16 +134,20 @@ void hle_data_send_done (hle_t *hle, u8 *buffer)
*/
void hle_data_recv (hle_t *hle, u8 *buffer, uint length)
{
+ uint word[2];
+
dbg_assert (hle);
dbg_assert (buffer);
- dbg_assert (60 <= length && length <= 1518);
+ dbg_assert (ETH_PACKET_MIN_SIZE <= length && length <=
+ ETH_PACKET_MAX_SIZE);
- uint word[2];
-
/* Tracing data. */
HLE_TRACE (DATA_RECV, mac_ntb(), length, buffer);
- word[0] = HLE_MSG_TYPE_DATA | (1 << 8) | (length << 13);
+ word[0] = BF_FILL (IPMBOX_REG, (MSG_TYPE, HLE_MSG_TYPE_DATA),
+ (MSG_LENGTH, 1), (PARAM_MSG_TYPE, 0),
+ (PARAM_MSG_LENGTH, length));
+
word[1] = (uint) buffer;
ipmbox_tx (hle->ipmbox, word, 2);
@@ -175,7 +182,7 @@ void hle_mme_send (hle_t *hle, u8 *buffer, uint length)
{
dbg_assert (hle);
dbg_assert (buffer);
- dbg_assert (60 <= length && length <= 1518);
+ dbg_assert (ETH_PACKET_MIN_SIZE <= length && length <= ETH_PACKET_MAX_SIZE);
/* Tracing data. */
HLE_TRACE (MME_BUFFER_ADD, mac_ntb(), buffer);
@@ -202,7 +209,8 @@ void hle_mme_send_done (hle_t *hle, u8 *buffer)
/* Tracing data. */
HLE_TRACE (MME_SEND_DONE, mac_ntb(), buffer);
- word[0] = HLE_MSG_TYPE_SEND_DONE | (1 << 8);
+ word[0] = BF_FILL (IPMBOX_REG, (MSG_TYPE, HLE_MSG_TYPE_SEND_DONE),
+ (MSG_LENGTH, 1), (PARAM_BUFFER_TYPE, 1));
word[1] = (uint) buffer;
ipmbox_tx (hle->ipmbox, word, 2);
@@ -226,7 +234,9 @@ void hle_mme_recv (hle_t *hle, u8 *buffer, uint length)
/* Tracing data. */
HLE_TRACE (MME_RECV, mac_ntb(), length, buffer);
- word[0] = HLE_MSG_TYPE_DATA | (1 << 8) | (1 << 12) | (length << 13);
+ word[0] = BF_FILL (IPMBOX_REG, (MSG_TYPE, HLE_MSG_TYPE_DATA),
+ (MSG_LENGTH, 1), (PARAM_MSG_TYPE, 1),
+ (PARAM_MSG_LENGTH, length));
word[1] = (uint) buffer;
ipmbox_tx (hle->ipmbox, word, 2);
@@ -273,39 +283,38 @@ bool hle_ipmbox_recv (hle_t *ctx, u32 *msg_buffer, uint length)
while (length_processed < length)
{
msg = read_u32_from_word ((u8 *) (msg_buffer + length_processed));
- length_processed ++;
- type = msg & 0xFF;
+ type = BF_GET (IPMBOX_REG__MSG_TYPE, msg);
switch (type)
{
case HLE_MSG_TYPE_DATA /* Data type */:
- data_type = (msg >> 12) & 0x1; /* data type MME or DATA */
- data_length = (msg >> 13) & 0x7FF;
+ data_type = BF_GET(IPMBOX_REG__PARAM_MSG_TYPE, msg); /* data type MME or DATA */
+ data_length = BF_GET (IPMBOX_REG__PARAM_MSG_LENGTH, msg);
if (data_type == 0) /* Data */
hle_data_send (ctx,
- (u8 *) msg_buffer[length_processed], data_length);
+ (u8 *) msg_buffer[length_processed + 1], data_length);
else
hle_mme_send (ctx,
- (u8 *) msg_buffer[length_processed], data_length);
- length_processed ++;
+ (u8 *) msg_buffer[length_processed + 1], data_length);
break;
case HLE_MSG_TYPE_BUFFER_ADD /* Buffer ADD */ :
- data_type = (msg >> 12) & 0x1; /* buffer type, MME or DATA */
-
+ data_type = BF_GET (IPMBOX_REG__PARAM_BUFFER_TYPE, msg);
if (data_type) /* 0 MME buffer, 1 data buffer*/
{
hle_mme_buffer_add (ctx, (u8 *) *(msg_buffer
- + length_processed));
+ + length_processed + 1));
}
else
{
hle_data_buffer_add (ctx, (u8 *) *(msg_buffer
- + length_processed));
+ + length_processed + 1));
}
- length_processed ++;
break;
}
+
+ /** Message length + the message header. */
+ length_processed += BF_GET (IPMBOX_REG__MSG_LENGTH, msg) + 1;
}
return true;