From 72d558d894611a7ddebdd304e428deb64745aa77 Mon Sep 17 00:00:00 2001 From: Nomi Date: Mon, 18 Dec 2023 18:40:28 +0100 Subject: [PATCH 1/4] Add NotImplemented error code --- include/result/result_os.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/result/result_os.hpp b/include/result/result_os.hpp index 35d1f378f..77ad72f00 100644 --- a/include/result/result_os.hpp +++ b/include/result/result_os.hpp @@ -5,10 +5,11 @@ DEFINE_HORIZON_RESULT_MODULE(Result::OS, OS); namespace Result::OS { DEFINE_HORIZON_RESULT(PortNameTooLong, 30, InvalidArgument, Usage); - DEFINE_HORIZON_RESULT(InvalidHandle, 1015, WrongArgument, Permanent); DEFINE_HORIZON_RESULT(InvalidCombination, 1006, InvalidArgument, Usage); DEFINE_HORIZON_RESULT(MisalignedAddress, 1009, InvalidArgument, Usage); DEFINE_HORIZON_RESULT(MisalignedSize, 1010, InvalidArgument, Usage); + DEFINE_HORIZON_RESULT(NotImplemented, 1012, InvalidArgument, Usage); + DEFINE_HORIZON_RESULT(InvalidHandle, 1015, WrongArgument, Permanent); DEFINE_HORIZON_RESULT(OutOfRange, 1021, InvalidArgument, Usage); DEFINE_HORIZON_RESULT(Timeout, 1022, StatusChanged, Info); }; // namespace Result::OS From 99a2e2d7fce867cb869a79c1da5eb80b2d195924 Mon Sep 17 00:00:00 2001 From: Nomi Date: Mon, 18 Dec 2023 18:41:09 +0100 Subject: [PATCH 2/4] Add proper handling of SetAppCpuTimeLimit with invalid params Set default time limit to 0 --- src/core/services/apt.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/core/services/apt.cpp b/src/core/services/apt.cpp index 9d02bf94d..830b83777 100644 --- a/src/core/services/apt.cpp +++ b/src/core/services/apt.cpp @@ -34,8 +34,8 @@ namespace APTCommands { } void APTService::reset() { - // Set the default CPU time limit to 30%. Seems safe, as this is what Metroid 2 uses by default - cpuTimeLimit = 30; + // Set the default CPU time limit to 0%. Appears to be the default value on hardware + cpuTimeLimit = 0; // Reset the handles for the various service objects lockHandle = std::nullopt; @@ -311,15 +311,16 @@ void APTService::setApplicationCpuTimeLimit(u32 messagePointer) { u32 percentage = mem.read32(messagePointer + 8); // CPU time percentage between 5% and 89% log("APT::SetApplicationCpuTimeLimit (percentage = %d%%)\n", percentage); + mem.write32(messagePointer, IPC::responseHeader(0x4F, 1, 0)); + + // If called with invalid parameters, the current time limit is left unchanged, and OS::NotImplemented is returned if (percentage < 5 || percentage > 89 || fixed != 1) { Helpers::warn("Invalid parameter passed to APT::SetApplicationCpuTimeLimit: (percentage, fixed) = (%d, %d)\n", percentage, fixed); - // TODO: Does the clamp operation happen? Verify with getApplicationCpuTimeLimit on hardware - percentage = std::clamp(percentage, 5, 89); + mem.write32(messagePointer + 4, Result::OS::NotImplemented); + } else { + mem.write32(messagePointer + 4, Result::Success); + cpuTimeLimit = percentage; } - - mem.write32(messagePointer, IPC::responseHeader(0x4F, 1, 0)); - mem.write32(messagePointer + 4, Result::Success); - cpuTimeLimit = percentage; } void APTService::getApplicationCpuTimeLimit(u32 messagePointer) { From c1eaa0de9245d2230b74c4fbbfd2e7905c68a5cf Mon Sep 17 00:00:00 2001 From: Nomi Date: Mon, 18 Dec 2023 18:43:30 +0100 Subject: [PATCH 3/4] Add AppCpuTimeLimit tests --- tests/AppCpuTimeLimit/Makefile | 258 ++++++++++++++++++++++++++++ tests/AppCpuTimeLimit/o3ds.png | Bin 0 -> 11121 bytes tests/AppCpuTimeLimit/source/main.c | 55 ++++++ 3 files changed, 313 insertions(+) create mode 100644 tests/AppCpuTimeLimit/Makefile create mode 100644 tests/AppCpuTimeLimit/o3ds.png create mode 100644 tests/AppCpuTimeLimit/source/main.c diff --git a/tests/AppCpuTimeLimit/Makefile b/tests/AppCpuTimeLimit/Makefile new file mode 100644 index 000000000..9fc3a849e --- /dev/null +++ b/tests/AppCpuTimeLimit/Makefile @@ -0,0 +1,258 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") +endif + +TOPDIR ?= $(CURDIR) +include $(DEVKITARM)/3ds_rules + +#--------------------------------------------------------------------------------- +# TARGET is the name of the output +# BUILD is the directory where object files & intermediate files will be placed +# SOURCES is a list of directories containing source code +# DATA is a list of directories containing data files +# INCLUDES is a list of directories containing header files +# GRAPHICS is a list of directories containing graphics files +# GFXBUILD is the directory where converted graphics files will be placed +# If set to $(BUILD), it will statically link in the converted +# files as if they were data files. +# +# NO_SMDH: if set to anything, no SMDH file is generated. +# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional) +# APP_TITLE is the name of the app stored in the SMDH file (Optional) +# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional) +# APP_AUTHOR is the author of the app stored in the SMDH file (Optional) +# ICON is the filename of the icon (.png), relative to the project folder. +# If not set, it attempts to use one of the following (in this order): +# - .png +# - icon.png +# - /default_icon.png +#--------------------------------------------------------------------------------- +TARGET := AppCpuTimeLimit +BUILD := build +SOURCES := source +DATA := data +INCLUDES := include +GRAPHICS := gfx +GFXBUILD := $(BUILD) +#ROMFS := romfs +#GFXBUILD := $(ROMFS)/gfx +APP_TITLE := AppCpuTimeLimit +APP_DESCRIPTION := Tests Set/GetAppCpuTimeLimit +APP_AUTHOR := noumidev + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft + +CFLAGS := -g -Wall -O2 -mword-relocations \ + -ffunction-sections \ + $(ARCH) + +CFLAGS += $(INCLUDE) -D__3DS__ + +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11 + +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +LIBS := -lctru -lm + +#--------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level containing +# include and lib +#--------------------------------------------------------------------------------- +LIBDIRS := $(CTRULIB) + + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) +export TOPDIR := $(CURDIR) + +export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ + $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) \ + $(foreach dir,$(DATA),$(CURDIR)/$(dir)) + +export DEPSDIR := $(CURDIR)/$(BUILD) + +CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) +CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) +SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) +PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica))) +SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist))) +GFXFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.t3s))) +BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) + +#--------------------------------------------------------------------------------- +# use CXX for linking C++ projects, CC for standard C +#--------------------------------------------------------------------------------- +ifeq ($(strip $(CPPFILES)),) +#--------------------------------------------------------------------------------- + export LD := $(CC) +#--------------------------------------------------------------------------------- +else +#--------------------------------------------------------------------------------- + export LD := $(CXX) +#--------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------- + +#--------------------------------------------------------------------------------- +ifeq ($(GFXBUILD),$(BUILD)) +#--------------------------------------------------------------------------------- +export T3XFILES := $(GFXFILES:.t3s=.t3x) +#--------------------------------------------------------------------------------- +else +#--------------------------------------------------------------------------------- +export ROMFS_T3XFILES := $(patsubst %.t3s, $(GFXBUILD)/%.t3x, $(GFXFILES)) +export T3XHFILES := $(patsubst %.t3s, $(BUILD)/%.h, $(GFXFILES)) +#--------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------- + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES_BIN := $(addsuffix .o,$(BINFILES)) \ + $(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \ + $(addsuffix .o,$(T3XFILES)) + +export OFILES := $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PICAFILES:.v.pica=_shbin.h) $(SHLISTFILES:.shlist=_shbin.h) \ + $(addsuffix .h,$(subst .,_,$(BINFILES))) \ + $(GFXFILES:.t3s=.h) + +export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + -I$(CURDIR)/$(BUILD) + +export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) + +export _3DSXDEPS := $(if $(NO_SMDH),,$(OUTPUT).smdh) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.png) + ifneq (,$(findstring $(TARGET).png,$(icons))) + export APP_ICON := $(TOPDIR)/$(TARGET).png + else + ifneq (,$(findstring icon.png,$(icons))) + export APP_ICON := $(TOPDIR)/icon.png + endif + endif +else + export APP_ICON := $(TOPDIR)/$(ICON) +endif + +ifeq ($(strip $(NO_SMDH)),) + export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh +endif + +ifneq ($(ROMFS),) + export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS) +endif + +.PHONY: all clean + +#--------------------------------------------------------------------------------- +all: $(BUILD) $(GFXBUILD) $(DEPSDIR) $(ROMFS_T3XFILES) $(T3XHFILES) + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile + +$(BUILD): + @mkdir -p $@ + +ifneq ($(GFXBUILD),$(BUILD)) +$(GFXBUILD): + @mkdir -p $@ +endif + +ifneq ($(DEPSDIR),$(BUILD)) +$(DEPSDIR): + @mkdir -p $@ +endif + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf $(GFXBUILD) + +#--------------------------------------------------------------------------------- +$(GFXBUILD)/%.t3x $(BUILD)/%.h : %.t3s +#--------------------------------------------------------------------------------- + @echo $(notdir $<) + @tex3ds -i $< -H $(BUILD)/$*.h -d $(DEPSDIR)/$*.d -o $(GFXBUILD)/$*.t3x + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).3dsx : $(OUTPUT).elf $(_3DSXDEPS) + +$(OFILES_SOURCES) : $(HFILES) + +$(OUTPUT).elf : $(OFILES) + +#--------------------------------------------------------------------------------- +# you need a rule like this for each extension you use as binary data +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.bin +#--------------------------------------------------------------------------------- + @echo $(notdir $<) + @$(bin2o) + +#--------------------------------------------------------------------------------- +.PRECIOUS : %.t3x +#--------------------------------------------------------------------------------- +%.t3x.o %_t3x.h : %.t3x +#--------------------------------------------------------------------------------- + @echo $(notdir $<) + @$(bin2o) + +#--------------------------------------------------------------------------------- +# rules for assembling GPU shaders +#--------------------------------------------------------------------------------- +define shader-as + $(eval CURBIN := $*.shbin) + $(eval DEPSFILE := $(DEPSDIR)/$*.shbin.d) + echo "$(CURBIN).o: $< $1" > $(DEPSFILE) + echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h + echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h + echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h + picasso -o $(CURBIN) $1 + bin2s $(CURBIN) | $(AS) -o $*.shbin.o +endef + +%.shbin.o %_shbin.h : %.v.pica %.g.pica + @echo $(notdir $^) + @$(call shader-as,$^) + +%.shbin.o %_shbin.h : %.v.pica + @echo $(notdir $<) + @$(call shader-as,$<) + +%.shbin.o %_shbin.h : %.shlist + @echo $(notdir $<) + @$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)$(file))) + +#--------------------------------------------------------------------------------- +%.t3x %.h : %.t3s +#--------------------------------------------------------------------------------- + @echo $(notdir $<) + @tex3ds -i $< -H $*.h -d $*.d -o $*.t3x + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/tests/AppCpuTimeLimit/o3ds.png b/tests/AppCpuTimeLimit/o3ds.png new file mode 100644 index 0000000000000000000000000000000000000000..b3da7ce7b18d022d4036af813cfa339c437cb897 GIT binary patch literal 11121 zcmch730zY7+J9wfi_&6FWuneF6BUi+n4^M%O*2|kNo9hmNMkd(-AvqYLo-XuQft)F zOr^3iMIcAX1r^sUP0a-9LEIehNe zv1Pk~uU7+q!9Pt_vCEbrHy-}_z$w4wBPrLT_Z)UV$Pee%T;z6M45@V(tqMI|7-@n3 zekyj==1;!byz4WL#c5+Z)42HCjek@}AurxbaaP;XKj! zmeB?!rjg{lySDOXMg2kK7EY|Fu*K71i`TsOVjPBl1>+>Mw$D~qa=Ow`z?2aD5gX~om5t=&t;W$Cbjlxm@VA+~=X~X2Ff?(Fy9{oAaB2hoj#5w!mdnhLZZs+_kww5h+Ka6o7BE z4+9S=h1(dw5A7-4>)F+h{o!ZX!JpMi#z!ub3R=dozI0>#ce`mpuK7>*_4K(&lVL1l zRAA}^vX!h>iv)kW=Q9Xp&p_YJ3w~kv2YiQ~%@9>kX z)`Zq?1#C{+wJPuuFioL(3u>*duNb;raf`XZe9{&>DS4Fz?M|hdyJs(W(X?)}xs_kI zT|Qt~b6Ta8Gn0l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K0e9KyFK{zyh2gLYG{=do!dxsFnD4hy^u!G!;EArS2`t608QiMz)h zLr!_a*Qm}FdsK0@B$dCW%)>b9X~8@TrTLuJhS9Uu+=^>2tfs`WydH{Cc8aX8UuVW3jb!KrV&k#VY2Pl^_N&1sgk9|gUoTcAjg_4m{FXtKGYR=E&6!(@ok?d= zvDk7o0rehfqBtVbXYdxRfFSJ}VbW!A%YUTjS?kU`7Qhg`4;K!FJj~8qg=tdK;w@(d zjawMazPIb*0$Jh#6* zHfFJIVUjnNSdr9qFtQwJ?xNK~mf?5I5Z)qj5pTM3(HJ%_U3s7MWOR#&L;8YWDILzD zQhl8yJ;wTQCsz>|HHT42EI*ad6`s-UsRot-=2x>ZEYVdY7!f1qWd|m zqu}cPOrHCANr}Rutf7Fy-9Wri`=%^T#Py4}YH)67C0f?eop^~=LuGRmSbl3#@9U1h z0P{ThG0TXu?Z7RD^k=)Gbx}+~)pMuMB623w?7Ah-10%S#4}aoc_h~!tA7b6WG_lw}Q5V&HE)bb3b%@;fyV;PjQ?btU0^` z+>%PpYXDR8cK&gbGc+}B#^BV*{2$zbrY4UJOwEOfv~Savrlud98qwe_cW7z^&%mjv ki`g9oIr@^H6c&{l5>8$ke{92E2K+hvjpf(Oug+ZhA0N}&LjV8( literal 0 HcmV?d00001 diff --git a/tests/AppCpuTimeLimit/source/main.c b/tests/AppCpuTimeLimit/source/main.c new file mode 100644 index 000000000..e61dc498f --- /dev/null +++ b/tests/AppCpuTimeLimit/source/main.c @@ -0,0 +1,55 @@ +#include <3ds.h> + +#include + +int main(int argc, char **argv) { + gfxInitDefault(); + + consoleInit(GFX_TOP, NULL); + + printf("--- APT::SetAppCpuTimeLimit ---\n\n"); + + // Get initial percentage + u32 percentage; + APT_GetAppCpuTimeLimit(&percentage); + + printf("Initial percentage: %lu\n\n", percentage); + + // Try all percentages from 0-100%, print failed calls + for (int i = 0; i <= 100; i++) { + const Result res = APT_SetAppCpuTimeLimit(i); + + if (R_FAILED(res)) { + APT_GetAppCpuTimeLimit(&percentage); + + printf("[%d:%lu:%lX]\n", i, percentage, res); + } + } + + // Send command with invalid fixed value + u32 aptcmdbuf[16]; + aptcmdbuf[0] = 0x004F0080; + aptcmdbuf[1] = 0; + aptcmdbuf[2] = 20; + + aptSendCommand(aptcmdbuf); + + printf("\nWith fixed = 0: [%08lX:%08lX]\n", aptcmdbuf[0], aptcmdbuf[1]); + + while (aptMainLoop()) { + hidScanInput(); + + if ((hidKeysDown() & KEY_START) != 0) { + break; + } + + gfxFlushBuffers(); + gfxSwapBuffers(); + + gspWaitForVBlank(); + } + + gfxExit(); + + return 0; +} From d8a2dd69b272299e971a7f80392d89443c2a5fb4 Mon Sep 17 00:00:00 2001 From: noumidev <139501014+noumidev@users.noreply.github.com> Date: Mon, 18 Dec 2023 19:29:50 +0100 Subject: [PATCH 4/4] Replace spaces with tab --- include/result/result_os.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/result/result_os.hpp b/include/result/result_os.hpp index 77ad72f00..92025366d 100644 --- a/include/result/result_os.hpp +++ b/include/result/result_os.hpp @@ -8,7 +8,7 @@ namespace Result::OS { DEFINE_HORIZON_RESULT(InvalidCombination, 1006, InvalidArgument, Usage); DEFINE_HORIZON_RESULT(MisalignedAddress, 1009, InvalidArgument, Usage); DEFINE_HORIZON_RESULT(MisalignedSize, 1010, InvalidArgument, Usage); - DEFINE_HORIZON_RESULT(NotImplemented, 1012, InvalidArgument, Usage); + DEFINE_HORIZON_RESULT(NotImplemented, 1012, InvalidArgument, Usage); DEFINE_HORIZON_RESULT(InvalidHandle, 1015, WrongArgument, Permanent); DEFINE_HORIZON_RESULT(OutOfRange, 1021, InvalidArgument, Usage); DEFINE_HORIZON_RESULT(Timeout, 1022, StatusChanged, Info);