mirror of
https://github.com/Polprzewodnikowy/SummerCart64.git
synced 2025-02-16 12:19:11 +01:00
fixed cfg_translate_address use
This commit is contained in:
parent
e7bce4df53
commit
60592dca3a
@ -89,18 +89,20 @@ static void cfg_set_usb_output_ready (void) {
|
|||||||
p.usb_output_ready = true;
|
p.usb_output_ready = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool cfg_translate_address (uint32_t *args) {
|
static bool cfg_translate_address (uint32_t *address, uint32_t length, bool with_flash) {
|
||||||
uint32_t address = args[0];
|
if (length == 0) {
|
||||||
uint32_t length = args[1];
|
return true;
|
||||||
if (address >= 0x10000000 && address < 0x14000000) {
|
}
|
||||||
if ((address + length) <= 0x14000000) {
|
uint32_t rom_end = (with_flash ? 0x15000000 : 0x14000000);
|
||||||
args[0] = address - 0x10000000 + 0x00000000;
|
if (*address >= 0x10000000 && *address < rom_end) {
|
||||||
|
if ((*address + length) <= rom_end) {
|
||||||
|
*address = *address - 0x10000000 + 0x00000000;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (address >= 0x1FFE0000 && address < 0x1FFE2000) {
|
if (*address >= 0x1FFE0000 && *address < 0x1FFE2000) {
|
||||||
if ((address + length) <= 0x1FFE2000) {
|
if ((*address + length) <= 0x1FFE2000) {
|
||||||
args[0] = address - 0x1FFE0000 + 0x05000000;
|
*address = *address - 0x1FFE0000 + 0x05000000;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -359,7 +361,7 @@ void cfg_process (void) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'm':
|
case 'm':
|
||||||
if (cfg_translate_address(args)) {
|
if (cfg_translate_address(&args[0], args[1], false)) {
|
||||||
cfg_set_error(CFG_ERROR_BAD_ADDRESS);
|
cfg_set_error(CFG_ERROR_BAD_ADDRESS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -369,7 +371,7 @@ void cfg_process (void) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'M':
|
case 'M':
|
||||||
if (cfg_translate_address(args)) {
|
if (cfg_translate_address(&args[0], args[1], false)) {
|
||||||
cfg_set_error(CFG_ERROR_BAD_ADDRESS);
|
cfg_set_error(CFG_ERROR_BAD_ADDRESS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -407,8 +409,7 @@ void cfg_process (void) {
|
|||||||
args[1] = sd_card_get_status();
|
args[1] = sd_card_get_status();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
args[1] = 32;
|
if (cfg_translate_address(&args[0], 32, false)) {
|
||||||
if (cfg_translate_address(args)) {
|
|
||||||
cfg_set_error(CFG_ERROR_BAD_ADDRESS);
|
cfg_set_error(CFG_ERROR_BAD_ADDRESS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -428,7 +429,11 @@ void cfg_process (void) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
if (cfg_translate_address(args)) {
|
if (args[1] >= 0x800000) {
|
||||||
|
cfg_set_error(CFG_ERROR_BAD_ARGUMENT);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (cfg_translate_address(&args[0], args[1] * 512, true)) {
|
||||||
cfg_set_error(CFG_ERROR_BAD_ADDRESS);
|
cfg_set_error(CFG_ERROR_BAD_ADDRESS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -439,7 +444,11 @@ void cfg_process (void) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'S':
|
case 'S':
|
||||||
if (cfg_translate_address(args)) {
|
if (args[1] >= 0x800000) {
|
||||||
|
cfg_set_error(CFG_ERROR_BAD_ARGUMENT);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (cfg_translate_address(&args[0], args[1] * 512, true)) {
|
||||||
cfg_set_error(CFG_ERROR_BAD_ADDRESS);
|
cfg_set_error(CFG_ERROR_BAD_ADDRESS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user