mirror of
https://github.com/xenia-project/xell-reloaded.git
synced 2024-11-27 05:40:22 +00:00
Added: USB Devices are now mounted and can be used to look for stuff to launch etc. even after the loop has already begun... along with that i've also added a MMC file filter (nand files can't be used anyways!)
Signed-off-by: Swizzy <swizzy@hotmail.co.uk>
This commit is contained in:
parent
9a07abe24c
commit
5b588251a1
@ -169,7 +169,7 @@ int try_load_file(char *filename, int filetype)
|
||||
}
|
||||
|
||||
wait_and_cleanup_line();
|
||||
printf("Trying %s...",filename);
|
||||
printf("Trying %s...\r",filename);
|
||||
|
||||
int f = open(filename, O_RDONLY);
|
||||
if (f < 0)
|
||||
@ -214,27 +214,45 @@ void fileloop() {
|
||||
for (i = 3; i < 16; i++) {
|
||||
if (devoptab_list[i]->structSize) {
|
||||
do{
|
||||
sprintf(filepath, "%s:/%s", devoptab_list[i]->name,filelist[j].filename);
|
||||
try_load_file(filepath,filelist[j].filetype);
|
||||
j++;
|
||||
usb_do_poll();
|
||||
} while(strcmp(filelist[j].filename, " "));
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
sprintf(filepath, "%s:/%s", devoptab_list[i]->name,filelist[j].filename);
|
||||
if ((filelist[j].filetype == TYPE_UPDXELL || filelist[j].filetype == TYPE_NANDIMAGE) && (xenon_get_console_type() == REV_CORONA_PHISON))
|
||||
{
|
||||
wait_and_cleanup_line();
|
||||
printf("MMC Console Detected! Skipping %s...\r", filepath);
|
||||
j++;
|
||||
}
|
||||
else
|
||||
{
|
||||
try_load_file(filepath,filelist[j].filetype);
|
||||
j++;
|
||||
}
|
||||
usb_do_poll();
|
||||
} while(strcmp(filelist[j].filename, " "));
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void tftp_loop() {
|
||||
int i=0;
|
||||
do{
|
||||
wait_and_cleanup_line();
|
||||
printf("Trying TFTP %s:%s... ",boot_server_name(),filelist[i].filename);
|
||||
boot_tftp(boot_server_name(), filelist[i].filename, filelist[i].filetype);
|
||||
i++;
|
||||
network_poll();
|
||||
} while(strcmp(filelist[i].filename, " "));
|
||||
if ((filelist[i].filetype == TYPE_UPDXELL || filelist[i].filetype == TYPE_NANDIMAGE) && (xenon_get_console_type() == REV_CORONA_PHISON))
|
||||
{
|
||||
wait_and_cleanup_line();
|
||||
printf("Skipping TFTP %s:%s... MMC Detected!\r", boot_server_name(),filelist[i].filename);
|
||||
i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
wait_and_cleanup_line();
|
||||
printf("Trying TFTP %s:%s... \r",boot_server_name(),filelist[i].filename);
|
||||
boot_tftp(boot_server_name(), filelist[i].filename, filelist[i].filetype);
|
||||
i++;
|
||||
}
|
||||
network_poll();
|
||||
} while(strcmp(filelist[i].filename, " "));
|
||||
wait_and_cleanup_line();
|
||||
printf("Trying TFTP %s:%s... ",boot_server_name(),boot_file_name());
|
||||
printf("Trying TFTP %s:%s...\r",boot_server_name(),boot_file_name());
|
||||
/* Assume that bootfile delivered via DHCP is an ELF */
|
||||
boot_tftp(boot_server_name(),boot_file_name(),TYPE_ELF);
|
||||
}
|
||||
|
@ -201,6 +201,8 @@ int main(){
|
||||
for(;;){
|
||||
tftp_loop();
|
||||
fileloop();
|
||||
console_clrline();
|
||||
mount_all_devices();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -468,60 +468,68 @@ static int FindPartitions(int device) {
|
||||
return devnum;
|
||||
}
|
||||
|
||||
//static void UnmountPartitions(int device) {
|
||||
// char mount[11];
|
||||
// int i;
|
||||
// for (i = 0; i < MAX_DEVICES; i++) {
|
||||
// switch (part[device][i].type) {
|
||||
//#ifdef FS_FAT
|
||||
// case T_FAT:
|
||||
// part[device][i].type = 0;
|
||||
// sprintf(mount, "%s:", part[device][i].mount);
|
||||
// fatUnmount(mount);
|
||||
// break;
|
||||
//#endif
|
||||
//#ifdef FS_NTFS
|
||||
// case T_NTFS:
|
||||
// part[device][i].type = 0;
|
||||
// ntfsUnmount(part[device][i].mount, false);
|
||||
// break;
|
||||
//#endif
|
||||
//#ifdef FS_EXT2FS
|
||||
// case T_EXT2:
|
||||
// part[device][i].type = 0;
|
||||
// ext2Unmount(part[device][i].mount);
|
||||
// break;
|
||||
//#endif
|
||||
//#ifdef FS_ISO9660
|
||||
// case T_ISO9660:
|
||||
// part[device][i].type = 0;
|
||||
// sprintf(mount, "%s:", part[device][i].mount);
|
||||
// ISO9660_Unmount(mount);
|
||||
// break;
|
||||
//#endif
|
||||
// }
|
||||
// part[device][i].name[0] = 0;
|
||||
// part[device][i].mount[0] = 0;
|
||||
// part[device][i].sector = 0;
|
||||
// part[device][i].interface = NULL;
|
||||
// }
|
||||
//}
|
||||
static void UnmountPartitions(int device) {
|
||||
char mount[11];
|
||||
int i;
|
||||
for (i = 0; i < MAX_DEVICES; i++) {
|
||||
switch (part[device][i].type) {
|
||||
#ifdef FS_FAT
|
||||
case T_FAT:
|
||||
part[device][i].type = 0;
|
||||
sprintf(mount, "%s:", part[device][i].mount);
|
||||
fatUnmount(mount);
|
||||
break;
|
||||
#endif
|
||||
#ifdef FS_NTFS
|
||||
case T_NTFS:
|
||||
part[device][i].type = 0;
|
||||
ntfsUnmount(part[device][i].mount, false);
|
||||
break;
|
||||
#endif
|
||||
#ifdef FS_EXT2FS
|
||||
case T_EXT2:
|
||||
part[device][i].type = 0;
|
||||
ext2Unmount(part[device][i].mount);
|
||||
break;
|
||||
#endif
|
||||
#ifdef FS_ISO9660
|
||||
case T_ISO9660:
|
||||
part[device][i].type = 0;
|
||||
sprintf(mount, "%s:", part[device][i].mount);
|
||||
ISO9660_Unmount(mount);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
part[device][i].name[0] = 0;
|
||||
part[device][i].mount[0] = 0;
|
||||
part[device][i].sector = 0;
|
||||
part[device][i].interface = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse mbr for filesystem
|
||||
*/
|
||||
|
||||
int hdd_dvd_mounted = 0; //Prevent mounting the DVD and HDD again...
|
||||
|
||||
void mount_all_devices() {
|
||||
UnmountPartitions(DEVICE_USB); // Unmount first to prevent stack overflow ;)
|
||||
FindPartitions(DEVICE_USB);
|
||||
|
||||
if (xenon_atapi_ops.isInserted()) {
|
||||
FindPartitions(DEVICE_ATAPI);
|
||||
}
|
||||
|
||||
if (xenon_ata_ops.isInserted()) {
|
||||
|
||||
if (hdd_dvd_mounted == 0) //Prevent mounting the DVD and HDD again...
|
||||
{
|
||||
if (xenon_atapi_ops.isInserted()) {
|
||||
FindPartitions(DEVICE_ATAPI);
|
||||
}
|
||||
|
||||
if (xenon_ata_ops.isInserted()) {
|
||||
#ifdef FS_XTAF
|
||||
if (XTAFMount() == 0)
|
||||
if (XTAFMount() == 0)
|
||||
#endif
|
||||
FindPartitions(DEVICE_ATA);
|
||||
FindPartitions(DEVICE_ATA);
|
||||
}
|
||||
hdd_dvd_mounted = 1; //Prevent mounting the DVD and HDD again...
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ static unsigned char *base;
|
||||
static int image_maxlen;
|
||||
|
||||
extern char *kboot_tftp;
|
||||
extern void console_clrline();
|
||||
|
||||
static void tftp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port)
|
||||
{
|
||||
@ -73,6 +74,7 @@ static void tftp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_
|
||||
}
|
||||
} else
|
||||
{
|
||||
console_clrline();
|
||||
printf("tftp: out of sequence block! (got %d, expected %d)\n", this_block, current_block + 1);
|
||||
if (this_block == current_block)
|
||||
{
|
||||
@ -89,6 +91,7 @@ static void tftp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_
|
||||
//printf("TFTP got ERROR\n");
|
||||
tftp_state = TFTP_STATE_FINISH;
|
||||
/* please don't overflow this. */
|
||||
console_clrline();
|
||||
printf("tftp error %d: %s", (d[2] << 8) | d[3], d + 4);
|
||||
tftp_result = -2;
|
||||
break;
|
||||
@ -172,11 +175,15 @@ int do_tftp(void *target, int maxlen, struct ip_addr server, const char *file)
|
||||
if (tb_diff_msec(now, start) > 500)
|
||||
{
|
||||
if (tftp_state == TFTP_STATE_RRQ_SEND)
|
||||
{
|
||||
console_clrline();
|
||||
printf("TFTP: no answer from server");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!current_block)
|
||||
tftp_state = TFTP_STATE_RRQ_SEND;
|
||||
console_clrline();
|
||||
printf("TFTP: packet lost (%d)\n", current_block);
|
||||
}
|
||||
tries++;
|
||||
@ -221,7 +228,10 @@ int do_tftp(void *target, int maxlen, struct ip_addr server, const char *file)
|
||||
d += 6;
|
||||
|
||||
if (udp_sendto(pcb, p, &server, 69))
|
||||
{
|
||||
console_clrline();
|
||||
printf("TFTP: packet send error.");
|
||||
}
|
||||
pbuf_free(p);
|
||||
send = 0;
|
||||
break;
|
||||
@ -253,6 +263,7 @@ int do_tftp(void *target, int maxlen, struct ip_addr server, const char *file)
|
||||
}
|
||||
uint64_t end;
|
||||
end=mftb();
|
||||
console_clrline();
|
||||
printf("%d packets (%d bytes, %d packet size), received in %dms, %d kb/s\n",
|
||||
current_block, ptr, last_size, (int)tb_diff_msec(end, ts),
|
||||
(int)(ptr / 1024 * 1000 / tb_diff_msec(end, ts)));
|
||||
@ -277,12 +288,14 @@ int boot_tftp(const char *server_addr, const char *tftp_bootfile, int filetype)
|
||||
//printf(server_addr);
|
||||
if (!ipaddr_aton(server_addr, &server_address))
|
||||
{
|
||||
console_clrline();
|
||||
printf("no server address given");
|
||||
server_address.addr = 0;
|
||||
}
|
||||
|
||||
if (!server_address.addr)
|
||||
{
|
||||
console_clrline();
|
||||
printf("no tftp server address");
|
||||
//printf(msg);
|
||||
return -1;
|
||||
@ -290,6 +303,7 @@ int boot_tftp(const char *server_addr, const char *tftp_bootfile, int filetype)
|
||||
|
||||
if (!(tftp_bootfile && *tftp_bootfile))
|
||||
{
|
||||
console_clrline();
|
||||
printf("no tftp bootfile name");
|
||||
//printf(msg);
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user