summaryrefslogtreecommitdiffstats
path: root/src/host/osmocon
diff options
context:
space:
mode:
authorSteve Markgraf <steve@steve-m.de>2010-04-07 00:01:26 +0200
committerHarald Welte <laforge@gnumonks.org>2010-04-07 08:49:19 +0200
commit55d9b8058ab35b132fa14c47bd3181e0fdce0288 (patch)
treeb921ce9ea28edaa2f83d8298b125b98f76cb254f /src/host/osmocon
parent48dfd41e7cc065045b79bd45cc18751e9afd6de2 (diff)
osmocon: fix c140xor, fix compiler warnings due to unhandled cases, cleanup
Signed-off-by: Steve Markgraf <steve@steve-m.de>
Diffstat (limited to 'src/host/osmocon')
-rw-r--r--src/host/osmocon/osmocon.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/src/host/osmocon/osmocon.c b/src/host/osmocon/osmocon.c
index 557181f7..850e928c 100644
--- a/src/host/osmocon/osmocon.c
+++ b/src/host/osmocon/osmocon.c
@@ -55,7 +55,6 @@
#define ROMLOAD_DL_BAUDRATE B115200
#define ROMLOAD_BEACON_INTERVAL 50000
#define ROMLOAD_BLOCK_HDR_LEN 10
-#define ROMLOAD_BLOCKSIZE 0x200
#define ROMLOAD_ADDRESS 0x820000
struct tool_server *tool_server_for_dlci[256];
@@ -163,12 +162,12 @@ static const uint8_t romload_branch_ack[] = { 0x3e, 0x62 }; /* >b */
static const uint8_t romload_branch_nack[] = { 0x3e, 0x42 }; /* >B */
/* romload_param: {"<p", uint8_t baudrate, uint8_t dpll, uint16_t memory_config,
-* uint8_t strobe_af, uint32_t uart_timeout} */
+ * uint8_t strobe_af, uint32_t uart_timeout} */
static const uint8_t romload_param[] = { 0x3c, 0x70, 0x00, 0x00, 0x00, 0x04,
0x00, 0x00, 0x00, 0x00, 0x00 };
-/* The C123 has a hard-coded check inside the ramloder that requires the following
+/* The C123 has a hard-coded check inside the ramloader that requires the following
* bytes to be always the first four bytes of the image */
static const uint8_t data_hdr_c123[] = { 0xee, 0x4c, 0x9f, 0x63 };
@@ -508,14 +507,14 @@ static int handle_write_block(void)
printf("handle_write_block(): ");
- if (dnload.block_ptr >= dnload.block + dnload.block_len) { //FIXME
- printf("Block %i finished\n", dnload.block_number-1);
+ if (dnload.block_ptr >= dnload.block + dnload.block_len) {
+ printf("Block %i finished\n", dnload.block_number);
dnload.write_ptr = dnload.data;
dnload.serial_fd.when &= ~BSC_FD_WRITE;
if (dnload.romload_state == SENDING_LAST_BLOCK) {
dnload.romload_state = LAST_BLOCK_SENT;
printf("Finished, sent %i blocks in total\n",
- dnload.block_number-1);
+ dnload.block_number);
} else {
dnload.romload_state = WAITING_BLOCK_ACK;
}
@@ -548,16 +547,20 @@ static int handle_write_block(void)
static int handle_write_dnload(void)
{
int bytes_left, write_len, rc;
+ uint8_t xor_init = 0x02;
printf("handle_write(): ");
if (dnload.write_ptr == dnload.data) {
/* no bytes have been transferred yet */
- if (dnload.mode == MODE_C155 ||
- dnload.mode == MODE_C123xor) {
- uint8_t xor_init = 0x02;
+ switch (dnload.mode) {
+ case MODE_C155:
+ case MODE_C140xor:
+ case MODE_C123xor:
rc = write(dnload.serial_fd.fd, &xor_init, 1);
- } else
- usleep(1);
+ break;
+ default:
+ break;
+ }
} else if (dnload.write_ptr >= dnload.data + dnload.data_len) {
printf("finished\n");
dnload.write_ptr = dnload.data;
@@ -830,13 +833,13 @@ static int handle_read_romload(void)
/* using the max blocksize the phone tells us */
dnload.block_payload_size = ((buffer[3] << 8) + buffer[2]);
- printf("Used blocksize for download is %i bytes \n",
+ printf("Used blocksize for download is %i bytes\n",
dnload.block_payload_size);
dnload.block_payload_size -= ROMLOAD_BLOCK_HDR_LEN;
dnload.romload_state = SENDING_BLOCKS;
dnload.block_number = 0;
romload_prepare_block();
- bufptr = (bufptr - 2);
+ bufptr -= 2;
break;
case WAITING_BLOCK_ACK:
case LAST_BLOCK_SENT:
@@ -885,7 +888,7 @@ static int handle_read_romload(void)
sizeof(romload_branch_cmd));
rc = write(dnload.serial_fd.fd, &branch_address, 4);
dnload.romload_state = WAITING_BRANCH_ACK;
- bufptr = (bufptr - 1);
+ bufptr -= 1;
} else if (!memcmp(buffer, romload_checksum_nack,
sizeof(romload_checksum_nack))) {
printf("Checksum on phone side (0x%02x) doesn't "
@@ -894,7 +897,7 @@ static int handle_read_romload(void)
dnload.romload_state = WAITING_IDENTIFICATION;
usleep(ROMLOAD_BEACON_INTERVAL*2);
reload_beacon_timer();
- bufptr = (bufptr - 1);
+ bufptr -= 1;
}
break;
case WAITING_BRANCH_ACK:
@@ -914,6 +917,8 @@ static int handle_read_romload(void)
reload_beacon_timer();
}
break;
+ default:
+ break;
}
bufptr += nbytes;