mirror of
https://gitlab.com/Nanolx/homebrewfilter.git
synced 2024-11-24 10:09:21 +01:00
allow to boot into neek2o
This commit is contained in:
parent
758d3f4b1f
commit
9bcb2fa968
25
Makefile
25
Makefile
@ -18,20 +18,21 @@ include $(DEVKITPPC)/wii_rules
|
||||
TARGET := boot
|
||||
BUILD := build
|
||||
SOURCES := source \
|
||||
source/BootHomebrew \
|
||||
source/DiskOperations \
|
||||
source/libwiigui \
|
||||
source/Prompts \
|
||||
source/Menus \
|
||||
source/Network \
|
||||
source/Tools \
|
||||
svnrev
|
||||
source/BootHomebrew \
|
||||
source/DiskOperations \
|
||||
source/libwiigui \
|
||||
source/Prompts \
|
||||
source/Menus \
|
||||
source/Network \
|
||||
source/Tools \
|
||||
source/Neek \
|
||||
svnrev
|
||||
INCLUDES := source
|
||||
DATA := data/fonts \
|
||||
data/sounds \
|
||||
data/images \
|
||||
data/images/design \
|
||||
data/binary
|
||||
data/sounds \
|
||||
data/images \
|
||||
data/images/design \
|
||||
data/binary
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
|
Binary file not shown.
@ -15,7 +15,7 @@
|
||||
#include "Tools/load_channel.h"
|
||||
#include "Tools/parser.h"
|
||||
#include "Tools/SelectIos.h"
|
||||
#include "uneek_fs.h"
|
||||
#include "Neek/uneek_fs.h"
|
||||
#include "gecko.h"
|
||||
#include "ahbfix.h"
|
||||
|
||||
|
2230
source/Neek/armboot.h
Normal file
2230
source/Neek/armboot.h
Normal file
File diff suppressed because it is too large
Load Diff
205
source/Neek/boot_neek2o.c
Normal file
205
source/Neek/boot_neek2o.c
Normal file
@ -0,0 +1,205 @@
|
||||
/******************************************************************************************
|
||||
*** ***
|
||||
*** nswitch - Simple neek/realnand switcher to embed in a channel ***
|
||||
*** ***
|
||||
*** Copyright (C) 2011 OverjoY ***
|
||||
*** ***
|
||||
*** This program is free software; you can redistribute it and/or ***
|
||||
*** modify it under the terms of the GNU General Public License ***
|
||||
*** as published by the Free Software Foundation version 2. ***
|
||||
*** ***
|
||||
*** This program is distributed in the hope that it will be useful, ***
|
||||
*** but WITHOUT ANY WARRANTY; without even the implied warranty of ***
|
||||
*** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ***
|
||||
*** GNU General Public License for more details. ***
|
||||
*** ***
|
||||
*** You should have received a copy of the GNU General Public License ***
|
||||
*** along with this program; if not, write to the Free Software ***
|
||||
*** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ***
|
||||
*** ***
|
||||
*******************************************************************************************/
|
||||
|
||||
#include <gccore.h>
|
||||
#include <fat.h>
|
||||
#include <sdcard/wiisd_io.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "armboot.h"
|
||||
|
||||
#define le32(i) (((((u32) i) & 0xFF) << 24) | ((((u32) i) & 0xFF00) << 8) | \
|
||||
((((u32) i) & 0xFF0000) >> 8) | ((((u32) i) & 0xFF000000) >> 24))
|
||||
|
||||
enum
|
||||
{
|
||||
SD = 0,
|
||||
USB1,
|
||||
USB2,
|
||||
USB3,
|
||||
USB4,
|
||||
MAXDEV
|
||||
};
|
||||
|
||||
static const char dev[MAXDEV][6] =
|
||||
{
|
||||
"sd",
|
||||
"usb1",
|
||||
"usb2",
|
||||
"usb3",
|
||||
"usb4"
|
||||
};
|
||||
|
||||
typedef struct _PR
|
||||
{
|
||||
u8 state;
|
||||
u8 chs_st[3];
|
||||
u8 type;
|
||||
u8 chs_e[3];
|
||||
u32 lba;
|
||||
u32 bc;
|
||||
} __attribute__((__packed__)) _pr;
|
||||
|
||||
typedef struct _MBR
|
||||
{
|
||||
u8 ca[446];
|
||||
_pr part[4];
|
||||
u16 sig;
|
||||
} __attribute__((__packed__)) _mbr;
|
||||
|
||||
bool check_neek2o() {
|
||||
|
||||
if(fopen("sd1:/sneek/kernel.bin", "rb") || fopen("usb1:/sneek/kernel.bin", "rb"))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
int boot_neek2o() {
|
||||
|
||||
u32 b2;
|
||||
ES_GetBoot2Version( &b2 );
|
||||
if( b2 < 5 )
|
||||
{
|
||||
int tr = 10;
|
||||
bool USBMounted = false, SDMounted = false;
|
||||
while( tr )
|
||||
{
|
||||
if( __io_usbstorage.startup() && __io_usbstorage.isInserted() )
|
||||
{
|
||||
_mbr mbr;
|
||||
char buffer[512];
|
||||
|
||||
__io_usbstorage.readSectors( 0, 1, &mbr );
|
||||
for( tr = 0; tr < 4; ++tr)
|
||||
{
|
||||
if(mbr.part[tr].type == 0)
|
||||
continue;
|
||||
|
||||
__io_usbstorage.readSectors( le32( mbr.part[tr].lba ), 1, buffer );
|
||||
|
||||
if( *( (u16 *)( buffer + 0x1FE ) ) == 0x55AA )
|
||||
{
|
||||
if( memcmp( buffer + 0x36, "FAT", 3 ) == 0 || memcmp( buffer + 0x52, "FAT", 3 ) == 0 )
|
||||
{
|
||||
fatMount( dev[USB1+tr], &__io_usbstorage, le32( mbr.part[tr].lba ), 8, 64 );
|
||||
USBMounted = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
usleep( 150000 );
|
||||
}
|
||||
|
||||
if( __io_wiisd.startup() || !__io_wiisd.isInserted() )
|
||||
if( fatMount( dev[SD], &__io_wiisd, 0, 8, 64 ) )
|
||||
SDMounted = true;
|
||||
|
||||
|
||||
FILE *f = NULL;
|
||||
long fsize;
|
||||
size_t fres;
|
||||
char path[40];
|
||||
if( USBMounted )
|
||||
{
|
||||
for( tr = USB1; tr < MAXDEV; ++tr )
|
||||
{
|
||||
sprintf( path, "%s:/sneek/kernel.bin", dev[tr] );
|
||||
if( !f )
|
||||
f = fopen( path, "rb" );
|
||||
}
|
||||
}
|
||||
|
||||
if( !f && SDMounted )
|
||||
f = fopen( "sd:/sneek/kernel.bin", "rb" );
|
||||
|
||||
|
||||
if( f )
|
||||
{
|
||||
fseek( f , 0 , SEEK_END );
|
||||
fsize = ftell( f );
|
||||
rewind( f );
|
||||
fres = fread ( (void *)0x91000000, 1, fsize, f );
|
||||
DCFlushRange( (void *)0x91000000, fsize );
|
||||
}
|
||||
else
|
||||
{
|
||||
fclose( f );
|
||||
|
||||
for( tr = SD; tr < MAXDEV; ++tr )
|
||||
{
|
||||
char d[40];
|
||||
sprintf( d, "%s:", dev[tr] );
|
||||
fatUnmount( d );
|
||||
}
|
||||
__io_usbstorage.shutdown();
|
||||
__io_wiisd.shutdown();
|
||||
SYS_ResetSystem( SYS_RETURNTOMENU, 0, 0 );
|
||||
}
|
||||
|
||||
fclose( f );
|
||||
|
||||
for( tr = SD; tr < MAXDEV; ++tr )
|
||||
{
|
||||
char d[40];
|
||||
sprintf( d, "%s:", dev[tr] );
|
||||
fatUnmount( d );
|
||||
}
|
||||
__io_usbstorage.shutdown();
|
||||
__io_wiisd.shutdown();
|
||||
|
||||
/*** Boot mini from mem code by giantpune ***/
|
||||
void *mini = memalign( 32, armboot_size );
|
||||
if( !mini )
|
||||
return 0;
|
||||
|
||||
memcpy( mini, armboot, armboot_size );
|
||||
DCFlushRange( mini, armboot_size );
|
||||
|
||||
*(u32*)0xc150f000 = 0x424d454d;
|
||||
asm volatile( "eieio" );
|
||||
|
||||
*(u32*)0xc150f004 = MEM_VIRTUAL_TO_PHYSICAL( mini );
|
||||
asm volatile( "eieio" );
|
||||
|
||||
IOS_ReloadIOS( 0xfe );
|
||||
|
||||
free( mini );
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
SYS_ResetSystem( SYS_RESTART,0,0 );
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
10
source/Neek/boot_neek2o.h
Normal file
10
source/Neek/boot_neek2o.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif //__cplusplus
|
||||
|
||||
bool check_neek2o();
|
||||
int boot_neek2o();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif //__cplusplus
|
@ -5,7 +5,8 @@
|
||||
#include "main.h"
|
||||
#include "menu.h"
|
||||
#include "Tools/SelectIos.h"
|
||||
#include "uneek_fs.h"
|
||||
#include "Neek/boot_neek2o.h"
|
||||
#include "Neek/uneek_fs.h"
|
||||
|
||||
/*** Extern variables ***/
|
||||
extern GuiWindow * mainWindow;
|
||||
@ -13,6 +14,7 @@ extern GuiWindow * mainWindow;
|
||||
/*** Extern functions ***/
|
||||
extern void ResumeGui();
|
||||
extern void HaltGui();
|
||||
extern bool goneek2o;
|
||||
|
||||
int priicheck = 0;
|
||||
|
||||
@ -22,6 +24,7 @@ loaderPrompt()
|
||||
bool stop = false;
|
||||
int menu = 0;
|
||||
listIOS();
|
||||
|
||||
if( ! priicheck )
|
||||
{
|
||||
priicheck = 1;
|
||||
@ -48,12 +51,14 @@ loaderPrompt()
|
||||
// Buttons data
|
||||
GuiImageData btn(Theme.button);
|
||||
GuiImage nandemuImg(&btn);
|
||||
GuiImage neek2oImg(&btn);
|
||||
GuiImage priiloaderImg(&btn);
|
||||
GuiImage backImg(&btn);
|
||||
|
||||
// Buttons over data
|
||||
GuiImageData btn_over(Theme.button_focus);
|
||||
GuiImage nandemuImgOver(&btn_over);
|
||||
GuiImage neek2oImgOver(&btn_over);
|
||||
GuiImage priiloaderImgOver(&btn_over);
|
||||
GuiImage backImgOver(&btn_over);
|
||||
|
||||
@ -66,11 +71,24 @@ loaderPrompt()
|
||||
nandemu.SetImageOver(&nandemuImgOver);
|
||||
nandemu.SetTrigger(&trigA);
|
||||
|
||||
GuiText neek2oTxt(tr("Launch Neek2o"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
|
||||
GuiButton neek2o(btn.GetWidth(), btn.GetHeight());
|
||||
neek2o.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
||||
neek2o.SetPosition(0, 90);
|
||||
if(get_nandemu())
|
||||
neek2o.SetPosition(0, 140);
|
||||
neek2o.SetLabel(&neek2oTxt);
|
||||
neek2o.SetImage(&neek2oImg);
|
||||
neek2o.SetImageOver(&neek2oImgOver);
|
||||
neek2o.SetTrigger(&trigA);
|
||||
|
||||
GuiText priiloaderTxt(tr("Launch Priiloader"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
|
||||
GuiButton priiloader(btn.GetWidth(), btn.GetHeight());
|
||||
priiloader.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
||||
priiloader.SetPosition(0, 90);
|
||||
if(get_nandemu())
|
||||
if(get_nandemu() && check_neek2o())
|
||||
priiloader.SetPosition(0, 190);
|
||||
else if (get_nandemu() || check_neek2o())
|
||||
priiloader.SetPosition(0, 140);
|
||||
priiloader.SetLabel(&priiloaderTxt);
|
||||
priiloader.SetImage(&priiloaderImg);
|
||||
@ -94,6 +112,8 @@ loaderPrompt()
|
||||
promptWindow.Append(&titleTxt);
|
||||
if(get_nandemu() && ! check_uneek_fs())
|
||||
promptWindow.Append(&nandemu);
|
||||
if(check_neek2o())
|
||||
promptWindow.Append(&neek2o);
|
||||
if(get_priiloader() == 1)
|
||||
promptWindow.Append(&priiloader);
|
||||
promptWindow.Append(&back);
|
||||
@ -116,6 +136,13 @@ loaderPrompt()
|
||||
stop = true;
|
||||
}
|
||||
|
||||
if(neek2o.GetState() == STATE_CLICKED)
|
||||
{
|
||||
goneek2o = true;
|
||||
menu = MENU_EXIT;
|
||||
stop = true;
|
||||
}
|
||||
|
||||
if(priiloader.GetState() == STATE_CLICKED)
|
||||
{
|
||||
set_priiloader(2);
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <vector>
|
||||
#include "main.h"
|
||||
#include "filelist.h"
|
||||
#include "uneek_fs.h"
|
||||
#include "Neek/uneek_fs.h"
|
||||
#include "gecko.h"
|
||||
|
||||
using namespace std;
|
||||
|
@ -37,7 +37,8 @@
|
||||
#include "DiskOperations/di2.h"
|
||||
#include "gecko.h"
|
||||
#include "Network/wiiload_gecko.h"
|
||||
#include "uneek_fs.h"
|
||||
#include "Neek/uneek_fs.h"
|
||||
#include "Neek/boot_neek2o.h"
|
||||
|
||||
#define HAVE_AHBPROT ((*(vu32*)0xcd800064 == 0xFFFFFFFF) ? 1 : 0)
|
||||
|
||||
@ -61,6 +62,7 @@ s8 PowerOff = -1;
|
||||
bool boothomebrew = false;
|
||||
bool boot_buffer = false;
|
||||
bool wiiload = false;
|
||||
bool goneek2o = false;
|
||||
bool runaway = false;
|
||||
bool gecko_connected;
|
||||
|
||||
@ -280,6 +282,12 @@ main(int argc, char *argv[])
|
||||
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
}
|
||||
|
||||
if(goneek2o)
|
||||
{
|
||||
//ExitApp();
|
||||
boot_neek2o();
|
||||
}
|
||||
|
||||
if(PowerOff == SYS_RETURNTOMENU)
|
||||
{
|
||||
*(vu32*)0x8132FFFB = 0x50756E65;
|
||||
|
2
updates
2
updates
@ -18,6 +18,8 @@
|
||||
halted or started accordingly [obcd]
|
||||
- BUGFIX: only show 'launch priiloader' in external loaders prompt,
|
||||
if priiloader is really installed
|
||||
- external loaders menu now allows to boot into neek2o
|
||||
using overjoy's `nswitch' code
|
||||
- changed loading address from 0x81230000 to 0x81330000
|
||||
- removed all sound related code
|
||||
- support for neek2o [obcd]
|
||||
|
Loading…
Reference in New Issue
Block a user