summaryrefslogtreecommitdiff
path: root/apps/settings.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/settings.c')
-rw-r--r--apps/settings.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/apps/settings.c b/apps/settings.c
index 5a42b17651..6fedf66669 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -20,6 +20,7 @@
20#include <stdio.h> 20#include <stdio.h>
21#include <stddef.h> 21#include <stddef.h>
22#include <limits.h> 22#include <limits.h>
23#include "inttypes.h"
23#include "config.h" 24#include "config.h"
24#include "kernel.h" 25#include "kernel.h"
25#include "thread.h" 26#include "thread.h"
@@ -557,14 +558,14 @@ static const struct bit_entry hd_bits[] =
557 558
558/* helper function to extract n (<=32) bits from an arbitrary position 559/* helper function to extract n (<=32) bits from an arbitrary position
559 * counting from LSB to MSB */ 560 * counting from LSB to MSB */
560static unsigned long get_bits( 561static uint32_t get_bits(
561 const unsigned long* p, /* the start of the bitfield array */ 562 const uint32_t *p, /* the start of the bitfield array */
562 unsigned int from, /* bit no. to start reading from */ 563 unsigned int from, /* bit no. to start reading from */
563 unsigned int size) /* how many bits to read */ 564 unsigned int size) /* how many bits to read */
564{ 565{
565 unsigned int long_index = from / 32; 566 unsigned int long_index = from / 32;
566 unsigned int bit_index = from % 32; 567 unsigned int bit_index = from % 32;
567 unsigned long result; 568 uint32_t result;
568 569
569 result = p[long_index] >> bit_index; 570 result = p[long_index] >> bit_index;
570 571
@@ -579,14 +580,14 @@ static unsigned long get_bits(
579/* helper function to set n (<=32) bits to an arbitrary position, 580/* helper function to set n (<=32) bits to an arbitrary position,
580 * counting from LSB to MSB */ 581 * counting from LSB to MSB */
581static void set_bits( 582static void set_bits(
582 unsigned long* p, /* the start of the bitfield array */ 583 uint32_t *p, /* the start of the bitfield array */
583 unsigned int from, /* bit no. to start writing into */ 584 unsigned int from, /* bit no. to start writing into */
584 unsigned int size, /* how many bits to change */ 585 unsigned int size, /* how many bits to change */
585 unsigned long value) /* content (LSBs will be taken) */ 586 uint32_t value) /* content (LSBs will be taken) */
586{ 587{
587 unsigned int long_index = from / 32; 588 unsigned int long_index = from / 32;
588 unsigned int bit_index = from % 32; 589 unsigned int bit_index = from % 32;
589 unsigned long mask; 590 uint32_t mask;
590 591
591 mask = 0xFFFFFFFF >> (32 - size); 592 mask = 0xFFFFFFFF >> (32 - size);
592 value &= mask; 593 value &= mask;
@@ -783,8 +784,8 @@ static int load_config_buffer(int which)
783 as described per table */ 784 as described per table */
784static void save_bit_table(const struct bit_entry* p_table, int count, int bitstart) 785static void save_bit_table(const struct bit_entry* p_table, int count, int bitstart)
785{ 786{
786 unsigned long* p_bitfield = (unsigned long*)config_block; /* 32 bit addr. */ 787 uint32_t *p_bitfield = (uint32_t *)config_block; /* 32 bit addr. */
787 unsigned long value; /* 32 bit content */ 788 uint32_t value; /* 32 bit content */
788 int i; 789 int i;
789 const struct bit_entry* p_run = p_table; /* start after the size info */ 790 const struct bit_entry* p_run = p_table; /* start after the size info */
790 int curr_bit = bitstart + p_table->bit_size; 791 int curr_bit = bitstart + p_table->bit_size;
@@ -797,16 +798,16 @@ static void save_bit_table(const struct bit_entry* p_table, int count, int bitst
797 switch(p_run->byte_size) 798 switch(p_run->byte_size)
798 { 799 {
799 case 1: 800 case 1:
800 value = ((unsigned char*)&global_settings)[p_run->settings_offset]; 801 value = ((uint8_t *)&global_settings)[p_run->settings_offset];
801 break; 802 break;
802 case 2: 803 case 2:
803 value = ((unsigned short*)&global_settings)[p_run->settings_offset/2]; 804 value = ((uint16_t *)&global_settings)[p_run->settings_offset/2];
804 break; 805 break;
805 case 4: 806 case 4:
806 value = ((unsigned int*)&global_settings)[p_run->settings_offset/4]; 807 value = ((uint32_t *)&global_settings)[p_run->settings_offset/4];
807 break; 808 break;
808 default: 809 default:
809 DEBUGF( "illegal size!" ); 810 DEBUGF( "save_bit_table: illegal size!\n" );
810 continue; 811 continue;
811 } 812 }
812 set_bits(p_bitfield, curr_bit, p_run->bit_size & 0x3F, value); 813 set_bits(p_bitfield, curr_bit, p_run->bit_size & 0x3F, value);
@@ -1115,8 +1116,8 @@ void settings_apply(void)
1115/* helper to load global_settings from a bitfield, as described per table */ 1116/* helper to load global_settings from a bitfield, as described per table */
1116static void load_bit_table(const struct bit_entry* p_table, int count, int bitstart) 1117static void load_bit_table(const struct bit_entry* p_table, int count, int bitstart)
1117{ 1118{
1118 unsigned long* p_bitfield = (unsigned long*)config_block; /* 32 bit addr. */ 1119 uint32_t *p_bitfield = (uint32_t *)config_block; /* 32 bit addr. */
1119 unsigned long value; /* 32 bit content */ 1120 uint32_t value; /* 32 bit content */
1120 int i; 1121 int i;
1121 int maxbit; /* how many bits are valid in the saved part */ 1122 int maxbit; /* how many bits are valid in the saved part */
1122 const struct bit_entry* p_run = p_table; /* start after the size info */ 1123 const struct bit_entry* p_run = p_table; /* start after the size info */
@@ -1146,19 +1147,19 @@ static void load_bit_table(const struct bit_entry* p_table, int count, int bitst
1146 switch(p_run->byte_size) 1147 switch(p_run->byte_size)
1147 { 1148 {
1148 case 1: 1149 case 1:
1149 ((unsigned char*)&global_settings)[p_run->settings_offset] = 1150 ((uint8_t *)&global_settings)[p_run->settings_offset] =
1150 (unsigned char)value; 1151 (unsigned char)value;
1151 break; 1152 break;
1152 case 2: 1153 case 2:
1153 ((unsigned short*)&global_settings)[p_run->settings_offset/2] = 1154 ((uint16_t *)&global_settings)[p_run->settings_offset/2] =
1154 (unsigned short)value; 1155 (unsigned short)value;
1155 break; 1156 break;
1156 case 4: 1157 case 4:
1157 ((unsigned int*)&global_settings)[p_run->settings_offset/4] = 1158 ((uint32_t *)&global_settings)[p_run->settings_offset/4] =
1158 (unsigned int)value; 1159 (unsigned int)value;
1159 break; 1160 break;
1160 default: 1161 default:
1161 DEBUGF( "illegal size!" ); 1162 DEBUGF( "load_bit_table: illegal size!\n" );
1162 continue; 1163 continue;
1163 } 1164 }
1164 } 1165 }