Skip to content

Commit

Permalink
- Prevent autobooting previous releases.
Browse files Browse the repository at this point in the history
  • Loading branch information
Extrems committed Sep 14, 2024
1 parent 7031468 commit 69f408d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
10 changes: 8 additions & 2 deletions cube/swiss/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ INCLUDES := include $(SOURCES) ..
# options for code generation
#---------------------------------------------------------------------------------

CFLAGS = -g -O2 -Wall -Wno-format-truncation -fno-strict-aliasing -D_GNU_SOURCE $(MACHDEP) $(INCLUDE) -D'GITREVISION="$(shell git rev-parse --short HEAD)"' -D'GITVERSION="$(shell git rev-list HEAD | wc -l)"'
CFLAGS = -g -O2 -Wall -Wno-format-truncation -fno-strict-aliasing -D_GNU_SOURCE $(MACHDEP) $(INCLUDE) -D'GIT_COMMIT="$(shell git rev-parse --short HEAD)"' -D'GIT_REVISION="$(shell git rev-list HEAD | wc -l)"'
CXXFLAGS = $(CFLAGS)

ASFLAGS = $(MACHDEP) -mregnames -D_LANGUAGE_ASSEMBLY $(INCLUDE)
Expand Down Expand Up @@ -110,7 +110,7 @@ export OFILES_BIN := $(addsuffix .o,$(BINFILES)) $(addsuffix .o,$(TPLFILES))
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(sFILES:.s=.o) $(SFILES:.S=.o)
export OFILES := $(OFILES_BIN) $(OFILES_SOURCES)

export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) $(addsuffix .h,$(subst .,_,$(TPLFILES)))
export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) $(addsuffix .h,$(subst .,_,$(TPLFILES))) tags.h

#---------------------------------------------------------------------------------
# build a list of include paths
Expand Down Expand Up @@ -165,6 +165,12 @@ $(OFILES_SOURCES) : $(HFILES)
$(SILENTMSG) $(notdir $<)
$(bin2o)

#---------------------------------------------------------------------------------
tags.h :
#---------------------------------------------------------------------------------
$(SILENTMSG) $(notdir $@)
$(SILENTCMD)git for-each-ref --format='"%(objectname:short)",' refs/tags > $@

-include $(DEPENDS)

#---------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion cube/swiss/source/gui/FrameBufferMagic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1459,7 +1459,7 @@ static void _DrawTitleBar(uiDrawObj_t *evt) {
_DrawSimpleBox(19, 17, 602, 62, 0, fillColor, noColor);

drawString(40, 28, "Swiss v0.6", 1.5f, false, defaultColor);
sprintf(fbTextBuffer, "commit: %s rev: %s", GITREVISION, GITVERSION);
sprintf(fbTextBuffer, "commit: %s rev: %s", GIT_COMMIT, GIT_REVISION);
drawString(412, 50, fbTextBuffer, 0.55f, false, defaultColor);

s8 cputemp = SYS_GetCoreTemperature();
Expand Down
2 changes: 1 addition & 1 deletion cube/swiss/source/gui/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ uiDrawObj_t * info_draw_page(int page_num) {
DrawAddChild(container, DrawLabel(30, 55, "Version Info (3/4):"));
DrawAddChild(container, DrawStyledLabel(640/2, 115, "Swiss version 0.6", 1.0f, true, defaultColor));
DrawAddChild(container, DrawStyledLabel(640/2, 140, "by emu_kidid & Extrems, 2024", 0.75f, true, defaultColor));
sprintf(topStr, "Commit %s Revision %s", GITREVISION, GITVERSION);
sprintf(topStr, "Commit %s Revision %s", GIT_COMMIT, GIT_REVISION);
DrawAddChild(container, DrawStyledLabel(640/2, 165, topStr, 0.75f, true, defaultColor));
DrawAddChild(container, DrawStyledLabel(640/2, 220, "Source/Updates/Issues", 0.75f, true, defaultColor));
DrawAddChild(container, DrawStyledLabel(640/2, 244, "github.com/emukidid/swiss-gc", 0.64f, true, defaultColor));
Expand Down
4 changes: 2 additions & 2 deletions cube/swiss/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ int main(int argc, char *argv[])
}
print_gecko("Arena Size: %iKb\r\n",(SYS_GetArena1Hi()-SYS_GetArena1Lo())/1024);
print_gecko("DVD Drive Present? %s\r\n",swissSettings.hasDVDDrive?"Yes":"No");
print_gecko("GIT Commit: %s\r\n", GITREVISION);
print_gecko("GIT Revision: %s\r\n", GITVERSION);
print_gecko("GIT Commit: %s\r\n", GIT_COMMIT);
print_gecko("GIT Revision: %s\r\n", GIT_REVISION);
}

// Go through all devices with FEAT_BOOT_DEVICE feature and set it as current if one is available
Expand Down
12 changes: 8 additions & 4 deletions cube/swiss/source/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,13 @@ char *stripInvalidChars(char *str)
return stripbuffer;
}

static const char git_tags[][sizeof(GIT_COMMIT)] = {
#include "tags.h"
};
/* Autoboot DOL from the current device, from the current autoboot_dols list */
char *autoboot_dols[] = {"*/boot.dol", "*/boot2.dol", "*/swiss_r[1-9]*.dol"}; // Keep this list sorted
void load_auto_dol() {
u8 rev_buf[sizeof(GITREVISION) - 1]; // Don't include the NUL termination in the comparison
char trailer[sizeof(GIT_COMMIT) - 1]; // Don't include the NUL termination in the comparison

memcpy(&curDir, devices[DEVICE_CUR]->initial, sizeof(file_handle));
scanFiles();
Expand All @@ -170,9 +173,10 @@ void load_auto_dol() {
// Official Swiss releases have the short commit hash appended to
// the end of the DOL, compare it to our own to make sure we don't
// bootloop the same version
devices[DEVICE_CUR]->seekFile(dirEntries[i], -sizeof(rev_buf), DEVICE_HANDLER_SEEK_END);
devices[DEVICE_CUR]->readFile(dirEntries[i], rev_buf, sizeof(rev_buf));
if (memcmp(GITREVISION, rev_buf, sizeof(rev_buf)) != 0) {
devices[DEVICE_CUR]->seekFile(dirEntries[i], -sizeof(trailer), DEVICE_HANDLER_SEEK_END);
devices[DEVICE_CUR]->readFile(dirEntries[i], trailer, sizeof(trailer));
if (memcmp(GIT_COMMIT, trailer, sizeof(trailer)) != 0 &&
memmem(git_tags, sizeof(git_tags), trailer, sizeof(trailer)) == NULL) {
// Emulate some of the menu's behavior to satisfy boot_dol
curSelection = i;
memcpy(&curFile, dirEntries[i], sizeof(file_handle));
Expand Down

0 comments on commit 69f408d

Please sign in to comment.