projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altos: Stop doing pointer arith on void *
[fw/altos]
/
src
/
kernel
/
ao_storage.c
diff --git
a/src/kernel/ao_storage.c
b/src/kernel/ao_storage.c
index 400751de03ca5d8a95debcac49403fa32b681b61..cfd116f9791bc536ae2e5709ddc066a3d84f3d8e 100644
(file)
--- a/
src/kernel/ao_storage.c
+++ b/
src/kernel/ao_storage.c
@@
-20,11
+20,9
@@
#include <ao_storage.h>
uint8_t
#include <ao_storage.h>
uint8_t
-ao_storage_read(ao_pos_t pos,
__xdata void *buf, uint16_t len) __reentrant
+ao_storage_read(ao_pos_t pos,
void *v_buf, uint16_t len)
{
{
-#ifdef CC1111
- return ao_storage_device_read(pos, buf, len);
-#else
+ uint8_t *buf = v_buf;
uint16_t this_len;
uint16_t this_off;
uint16_t this_len;
uint16_t this_off;
@@
-50,15
+48,12
@@
ao_storage_read(ao_pos_t pos, __xdata void *buf, uint16_t len) __reentrant
pos += this_len;
}
return 1;
pos += this_len;
}
return 1;
-#endif
}
uint8_t
}
uint8_t
-ao_storage_write(ao_pos_t pos,
__xdata void *buf, uint16_t len) __reentrant
+ao_storage_write(ao_pos_t pos,
void *v_buf, uint16_t len)
{
{
-#ifdef CC1111
- return ao_storage_device_write(pos, buf, len);
-#else
+ uint8_t *buf = v_buf;
uint16_t this_len;
uint16_t this_off;
uint16_t this_len;
uint16_t this_off;
@@
-84,23
+79,23
@@
ao_storage_write(ao_pos_t pos, __xdata void *buf, uint16_t len) __reentrant
pos += this_len;
}
return 1;
pos += this_len;
}
return 1;
-#endif
}
}
-static
__xdata
uint8_t storage_data[128];
+static uint8_t storage_data[128];
static void
static void
-ao_storage_dump(void)
__reentrant
+ao_storage_dump(void)
{
{
+ uint32_t block;
uint8_t i, j;
uint8_t i, j;
- ao_cmd_hex();
+
block =
ao_cmd_hex();
if (ao_cmd_status != ao_cmd_success)
return;
for (i = 0; ; i += 8) {
if (ao_cmd_status != ao_cmd_success)
return;
for (i = 0; ; i += 8) {
- if (ao_storage_read((
(uint32_t) (ao_cmd_lex_i)
<< 8) + i,
- storage_data,
- 8)) {
+ if (ao_storage_read((
block
<< 8) + i,
+
storage_data,
+
8)) {
ao_cmd_put16((uint16_t) i);
for (j = 0; j < 8; j++) {
putchar(' ');
ao_cmd_put16((uint16_t) i);
for (j = 0; j < 8; j++) {
putchar(' ');
@@
-118,45
+113,41
@@
ao_storage_dump(void) __reentrant
/* not enough space for this today
*/
static void
/* not enough space for this today
*/
static void
-ao_storage_store(void)
__reentrant
+ao_storage_store(void)
{
uint16_t block;
uint8_t i;
uint16_t len;
{
uint16_t block;
uint8_t i;
uint16_t len;
-
static __xdata
uint8_t b;
+ uint8_t b;
uint32_t addr;
uint32_t addr;
- ao_cmd_hex();
- block = ao_cmd_lex_i;
- ao_cmd_hex();
- i = ao_cmd_lex_i;
+ block = ao_cmd_hex();
+ i = ao_cmd_hex();
addr = ((uint32_t) block << 8) | i;
addr = ((uint32_t) block << 8) | i;
- ao_cmd_hex();
- len = ao_cmd_lex_i;
+ len = ao_cmd_hex();
if (ao_cmd_status != ao_cmd_success)
return;
while (len--) {
if (ao_cmd_status != ao_cmd_success)
return;
while (len--) {
-
ao_cmd_hex
();
+
b = ao_cmd_hexbyte
();
if (ao_cmd_status != ao_cmd_success)
return;
if (ao_cmd_status != ao_cmd_success)
return;
- b = ao_cmd_lex_i;
ao_storage_write(addr, &b, 1);
addr++;
}
}
#endif
ao_storage_write(addr, &b, 1);
addr++;
}
}
#endif
-void
-ao_storage_zap(void)
__reentrant
+
static
void
+ao_storage_zap(void)
{
{
- ao_cmd_hex();
+
uint32_t v =
ao_cmd_hex();
if (ao_cmd_status != ao_cmd_success)
return;
if (ao_cmd_status != ao_cmd_success)
return;
- ao_storage_erase((uint32_t)
ao_cmd_lex_i
<< 8);
+ ao_storage_erase((uint32_t)
v
<< 8);
}
}
-void
-ao_storage_zapall(void)
__reentrant
+
static
void
+ao_storage_zapall(void)
{
uint32_t pos;
{
uint32_t pos;
@@
-272,7
+263,7
@@
ao_storage_incr_check_block(uint32_t pos)
}
static uint8_t
}
static uint8_t
-ao_storage_test_block(uint32_t pos)
__reentrant
+ao_storage_test_block(uint32_t pos)
{
ao_storage_erase(pos);
printf(" erase"); flush();
{
ao_storage_erase(pos);
printf(" erase"); flush();
@@
-299,7
+290,7
@@
ao_storage_test_block(uint32_t pos) __reentrant
}
static void
}
static void
-ao_storage_test(void)
__reentrant
+ao_storage_test(void)
{
uint32_t pos;
{
uint32_t pos;
@@
-315,8
+306,8
@@
ao_storage_test(void) __reentrant
}
#endif /* AO_STORAGE_TEST */
}
#endif /* AO_STORAGE_TEST */
-void
-ao_storage_info(void)
__reentrant
+
static
void
+ao_storage_info(void)
{
ao_storage_setup();
printf("Storage size: %ld\n", (long) ao_storage_total);
{
ao_storage_setup();
printf("Storage size: %ld\n", (long) ao_storage_total);
@@
-324,7
+315,7
@@
ao_storage_info(void) __reentrant
ao_storage_device_info();
}
ao_storage_device_info();
}
-
__code
struct ao_cmds ao_storage_cmds[] = {
+
const
struct ao_cmds ao_storage_cmds[] = {
{ ao_storage_info, "f\0Show storage" },
{ ao_storage_dump, "e <block>\0Dump flash" },
#if HAS_STORAGE_DEBUG
{ ao_storage_info, "f\0Show storage" },
{ ao_storage_dump, "e <block>\0Dump flash" },
#if HAS_STORAGE_DEBUG