Enable entry of address limits greater than 4GB on 32-bit build.

This commit is contained in:
Martin Whitaker 2020-05-29 20:42:26 +01:00
parent e5fc5a0ed6
commit 808cd46582
3 changed files with 20 additions and 20 deletions

View File

@ -154,7 +154,7 @@ static bool add_or_remove_test(bool add)
{
display_input_message(POP_R+14, "Enter test #");
int n = read_value(POP_R+14, POP_C+2+12, 2);
int n = read_value(POP_R+14, POP_C+2+12, 2, 0);
if (n < 0 || n >= NUM_TEST_PATTERNS) {
display_error_message(POP_R+14, "Invalid test number");
return false;
@ -168,13 +168,13 @@ static bool add_or_remove_test(bool add)
static bool add_test_range()
{
display_input_message(POP_R+14, "Enter first test #");
int n1 = read_value(POP_R+14, POP_C+2+18, 2);
int n1 = read_value(POP_R+14, POP_C+2+18, 2, 0);
if (n1 < 0 || n1 >= NUM_TEST_PATTERNS) {
display_error_message(POP_R+14, "Invalid test number");
return false;
}
display_input_message(POP_R+14, "Enter last test #");
int n2 = read_value(POP_R+14, POP_C+2+17, 2);
int n2 = read_value(POP_R+14, POP_C+2+17, 2, 0);
if (n2 < n1 || n2 >= NUM_TEST_PATTERNS) {
display_error_message(POP_R+14, "Invalid test range");
return false;
@ -264,7 +264,7 @@ static void address_range_menu(void)
switch (get_key()) {
case '1': {
display_input_message(POP_R+10, "Enter lower limit: ");
uintptr_t page = read_value(POP_R+10, POP_C+2+19, 15) >> PAGE_SHIFT;
uintptr_t page = read_value(POP_R+10, POP_C+2+19, 15, -PAGE_SHIFT);
if (page < pm_limit_upper) {
clear_popup_row(POP_R+10);
pm_limit_lower = page;
@ -275,7 +275,7 @@ static void address_range_menu(void)
} break;
case '2': {
display_input_message(POP_R+10, "Enter upper limit: ");
uintptr_t page = read_value(POP_R+10, POP_C+2+19, 15) >> PAGE_SHIFT;
uintptr_t page = read_value(POP_R+10, POP_C+2+19, 15, -PAGE_SHIFT);
if (page > pm_limit_lower) {
clear_popup_row(POP_R+10);
pm_limit_upper = page;
@ -391,7 +391,7 @@ static bool add_or_remove_cpu(bool add)
{
display_input_message(POP_R+14, "Enter CPU #");
int n = read_value(POP_R+14, POP_C+2+11, 2);
int n = read_value(POP_R+14, POP_C+2+11, 2, 0);
if (n < 1 || n >= num_pcpus) {
display_error_message(POP_R+14, "Invalid CPU number");
return false;
@ -405,13 +405,13 @@ static bool add_or_remove_cpu(bool add)
static bool add_cpu_range()
{
display_input_message(POP_R+14, "Enter first CPU #");
int n1 = read_value(POP_R+14, POP_C+2+17, 2);
int n1 = read_value(POP_R+14, POP_C+2+17, 2, 0);
if (n1 < 1 || n1 >= num_pcpus) {
display_error_message(POP_R+14, "Invalid CPU number");
return false;
}
display_input_message(POP_R+14, "Enter last CPU #");
int n2 = read_value(POP_R+14, POP_C+2+16, 2);
int n2 = read_value(POP_R+14, POP_C+2+16, 2, 0);
if (n2 < n1 || n2 >= num_pcpus) {
display_error_message(POP_R+14, "Invalid CPU range");
return false;

View File

@ -22,7 +22,7 @@
// Public Functions
//------------------------------------------------------------------------------
uintptr_t read_value(int row, int col, int field_width)
uintptr_t read_value(int row, int col, int field_width, int shift)
{
char buffer[1 + field_width];
@ -105,14 +105,13 @@ uintptr_t read_value(int row, int col, int field_width)
}
}
int shift = 0;
if (got_suffix) {
switch (buffer[n-1]) {
case 'T': /* tera */ shift = 40; n--; break;
case 'G': /* gig */ shift = 30; n--; break;
case 'M': /* meg */ shift = 20; n--; break;
case 'P': /* page */ shift = 12; n--; break;
case 'K': /* kilo */ shift = 10; n--; break;
case 'T': /* tera */ shift += 40; n--; break;
case 'G': /* gig */ shift += 30; n--; break;
case 'M': /* meg */ shift += 20; n--; break;
case 'P': /* page */ shift += 12; n--; break;
case 'K': /* kilo */ shift += 10; n--; break;
}
}
@ -126,5 +125,5 @@ uintptr_t read_value(int row, int col, int field_width)
}
}
return value << shift;
return shift < 0 ? value >> shift : value << shift;
}

View File

@ -13,10 +13,11 @@
* Returns an unsigned numeric value entered on the keyboard. Echoes the
* input to the display field located at (row,col), limiting it to field_width
* characters. If the entered value is prefixed by "0x", assumes base 16,
* otherwise assumes base 10. If the value is suffixed by 'K', 'P', 'M', or
* 'G', the returned value will be scaled by 10^10, 10^12, 10^20, or 10^30
* accordingly.
* otherwise assumes base 10. If the value is suffixed by 'K', 'P', 'M',
* 'G', or 'T', the returned value will be scaled by 2^10, 2^12, 2^20,
* 2^30, or 2^40 accordingly. The returned value will also be scaled by
* 2^shift.
*/
uintptr_t read_value(int x, int y, int field_width);
uintptr_t read_value(int x, int y, int field_width, int shift);
#endif // READ_H