mirror of
https://github.com/rvtr/TwlIPL.git
synced 2025-10-31 06:01:12 -04:00
本体デバッグ用無線チェックプログラムを追加。
git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@2071 b08762b0-b915-fc4b-9d8c-17b2551a87ff
This commit is contained in:
parent
1744df9d72
commit
662dadd251
1
build/tests/WirelessChecker/@
Normal file
1
build/tests/WirelessChecker/@
Normal file
@ -0,0 +1 @@
|
||||
NINTENDO_RED_CONFIDENTIAL
|
||||
129
build/tests/WirelessChecker/Makefile
Normal file
129
build/tests/WirelessChecker/Makefile
Normal file
@ -0,0 +1,129 @@
|
||||
#! make -f
|
||||
#----------------------------------------------------------------------------
|
||||
# Project: TwlSDK - tools - Wireless Checker
|
||||
# File: Makefile
|
||||
#
|
||||
# Copyright 2008 Nintendo. All rights reserved.
|
||||
#
|
||||
# These coded instructions, statements, and computer programs contain
|
||||
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
# Company Ltd., and are protected by Federal copyright law. They may
|
||||
# not be disclosed to third parties or copied or duplicated in any form,
|
||||
# in whole or in part, without the prior written consent of Nintendo.
|
||||
#
|
||||
# $Date:: $
|
||||
# $Rev$
|
||||
# $Author$
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
override TARGET_PLATFORM = TWL
|
||||
override TWL_CODEGEN = ARM
|
||||
override TWL_ARCHGEN = LIMITED
|
||||
|
||||
SUBDIRS = libraries components rsf banner
|
||||
|
||||
RES_DIR = ./resources
|
||||
|
||||
SRCDIR = src
|
||||
INCDIR = include $(ROOT)/build/libraries/wm/common.TWL/inc \
|
||||
$(ROOT)/build/libraries/wm/ARM9.TWL/nwm/inc
|
||||
|
||||
ifeq ($(TWL_NANDAPP),TRUE)
|
||||
ROM_SPEC = rsf/wireless_checker_nand.rsf
|
||||
else
|
||||
ROM_SPEC = rsf/wireless_checker.rsf
|
||||
endif
|
||||
|
||||
BANNER_FILE = ./banner/000A_WLCK.bnr
|
||||
MAKEROM_FLAGS = -DBANNER_FILE='$(BANNER_FILE)'
|
||||
|
||||
#----------------------------------
|
||||
# Font
|
||||
|
||||
FONTCVTR_DIR = $(call empath,$(TWLSYSTEM_ROOT))/tools/fontcvtr
|
||||
FONT_BMP = $(RES_DIR)/ds_ipl10.bmp
|
||||
|
||||
TARGET_OBJ += $(FONT_O)
|
||||
EXT_OBJS += $(OBJDIR)/$(FONT_O)
|
||||
|
||||
|
||||
FONT_RES_LC = $(RES_DIR)/font.NFTR
|
||||
FONT_O_LC = font.o
|
||||
|
||||
FONT_RES = $(FONT_RES_LC)
|
||||
FONT_O = $(FONT_O_LC)
|
||||
|
||||
MACRO_FLAGS += -DTWLNMENU_USE_LC_FONT
|
||||
|
||||
|
||||
LDIRT_CLEAN += $(FONT_RES_LC) $(FONT_RES_NO_LC) *.rsf $(REVISION_C)
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
ifeq ($(TWL_NANDAPP),TRUE)
|
||||
TARGET_BIN = WirelessChecker.tad
|
||||
else
|
||||
TARGET_BIN = WirelessChecker.srl
|
||||
endif
|
||||
|
||||
SRCS = main.cpp \
|
||||
frame.cpp \
|
||||
test.cpp \
|
||||
test_wm.cpp \
|
||||
test_nwm.cpp \
|
||||
test_fatal.cpp \
|
||||
test_recovery.cpp \
|
||||
util/util.cpp \
|
||||
util/canvas.cpp \
|
||||
util/wprintf.cpp \
|
||||
util/memory.cpp
|
||||
|
||||
LINCLUDES = $(ROOT)/build/libraries/wm/ARM9.TWL/nwm/inc \
|
||||
$(ROOT)/build/libraries/wm/common.TWL/inc
|
||||
|
||||
LLIBRARY_DIRS =
|
||||
LLIBRARIES =
|
||||
|
||||
COMPONENT_NAME = racoon
|
||||
MAKEROM_ARM7_BASE = ./components/racoon_wckr/bin/$(TWL_BUILDTYPE_ARM7)/racoon
|
||||
MAKEROM_ARM7 = $(MAKEROM_ARM7_BASE).$(TWL_ELF_EXT)
|
||||
|
||||
include $(TWLSYSTEM_ROOT)/build/buildtools/commondefs
|
||||
include $(TWLSDK_ROOT)/build/buildtools/twl/commondefs.add-ins.nadk
|
||||
|
||||
LIBRARIES_UNLINK := libnwm$(TWL_LIBSUFFIX).a
|
||||
|
||||
LLIBRARY_DIRS += ./libraries/nwm/ARM9/lib/$(TWL_BUILDTYPE_ARM9)
|
||||
LLIBRARIES += libnwm.WCKR$(TWL_LIBSUFFIX).a
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# convert font
|
||||
|
||||
$(FONT_RES): $(FONT_BMP) $(FONT_FILTER)
|
||||
ifdef SILENT
|
||||
echo "make font:" $(notdir $<)
|
||||
endif
|
||||
$(FONTCVTR_DIR)/fontcvtrc.exe \
|
||||
-i bmp -if $< -io $(FONTCVTR_DIR)/xlor/ds_ipl.xlor -ib 1 \
|
||||
-o nitro -of $@ -oe utf16 -oa 0x23 $(FONT_OPTION)
|
||||
|
||||
$(OBJDIR)/$(FONT_O): $(FONT_RES)
|
||||
ifdef SILENT
|
||||
echo " b2o font:" $(notdir $<)
|
||||
endif
|
||||
$(BIN2OBJ) $< $@ --begin font_NFTR_begin --end font_NFTR_end --align 32
|
||||
|
||||
INSTALL_TARGETS = $(BINDIR)/$(TARGET_BIN)
|
||||
INSTALL_DIR = ./
|
||||
#$(TWLSDK_INSTALL_ROOT)/bin/$(CODEGEN_PROC)-$(TWL_PLATFORM)/$(TWL_BUILD_DIR)
|
||||
|
||||
do-build: $(TARGETS)
|
||||
ifneq ($(TWL_NANDAPP),TRUE)
|
||||
$(REMAKE) TWL_NANDAPP=TRUE SKIP_SUBDIR=TRUE
|
||||
endif
|
||||
|
||||
include $(TWLSYSTEM_ROOT)/build/buildtools/modulerules
|
||||
include $(TWLSDK_ROOT)/build/buildtools/twl/modulerules.add-ins.nadk
|
||||
|
||||
#===== End of Makefile =====
|
||||
BIN
build/tests/WirelessChecker/banner/000A_WLCK.bmp
Normal file
BIN
build/tests/WirelessChecker/banner/000A_WLCK.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 630 B |
BIN
build/tests/WirelessChecker/banner/000A_WLCK.bsf
Normal file
BIN
build/tests/WirelessChecker/banner/000A_WLCK.bsf
Normal file
Binary file not shown.
47
build/tests/WirelessChecker/banner/Makefile
Normal file
47
build/tests/WirelessChecker/banner/Makefile
Normal file
@ -0,0 +1,47 @@
|
||||
#! make -f
|
||||
#---------------------------------------------------------------------------
|
||||
# Project: NitroSDK - tools
|
||||
# File: Makefile
|
||||
#
|
||||
# Copyright 2003,2004 Nintendo. All rights reserved.
|
||||
#
|
||||
# These coded instructions, statements, and computer programs contain
|
||||
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
# Company Ltd., and are protected by Federal copyright law. They may
|
||||
# not be disclosed to third parties or copied or duplicated in any form,
|
||||
# in whole or in part, without the prior written consent of Nintendo.
|
||||
#
|
||||
# $Log: Makefile,v $
|
||||
# Revision 1.1 2004/11/01 08:25:59 ooe
|
||||
# (none)
|
||||
#
|
||||
# $NoKeywords: $
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||
|
||||
BANNER_ICON = 000A_WLCK.bmp
|
||||
BANNER_SPEC = 000A_WLCK.bsf
|
||||
|
||||
TARGETS = $(BANNER_SPEC:.bsf=.bnr)
|
||||
|
||||
BANNER_ICON_NAME = $(basename $(BANNER_ICON))
|
||||
|
||||
LDIRT_CLEAN = $(TARGETS) \
|
||||
$(BANNER_ICON_NAME).nbfs \
|
||||
$(BANNER_ICON_NAME).nbfc \
|
||||
$(BANNER_ICON_NAME).nbfp \
|
||||
$(TARGETS:.bnr=.srl)
|
||||
|
||||
include $(TWLSDK_ROOT)/build/buildtools/modulerules
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# build
|
||||
#----------------------------------------------------------------------------
|
||||
do-build: $(TARGETS)
|
||||
|
||||
$(TARGETS): $(BANNER_SPEC) $(BANNER_ICON_NAME).nbfc $(BANNER_ICON_NAME).nbfp
|
||||
$(MAKEBANNER) -N $(BANNER_ICON_NAME) $(BANNER_SPEC) $(TARGETS)
|
||||
|
||||
#
|
||||
31
build/tests/WirelessChecker/components/Makefile
Normal file
31
build/tests/WirelessChecker/components/Makefile
Normal file
@ -0,0 +1,31 @@
|
||||
#! make -f
|
||||
#----------------------------------------------------------------------------
|
||||
# Project: TWL WLAN - components
|
||||
# File: Makefile
|
||||
#
|
||||
# Copyright 2003 - 2008 Nintendo. All rights reserved.
|
||||
#
|
||||
# These coded instructions, statements, and computer programs contain
|
||||
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
# Company Ltd., and are protected by Federal copyright law. They may
|
||||
# not be disclosed to third parties or copied or duplicated in any form,
|
||||
# in whole or in part, without the prior written consent of Nintendo.
|
||||
#
|
||||
# $Log: Makefile,v $
|
||||
#
|
||||
#
|
||||
# $NoKeywords: $
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
||||
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
SUBDIRS_P += racoon_wckr
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
include $(TWLSDK_ROOT)/build/buildtools/modulerules
|
||||
|
||||
#===== End of Makefile =====
|
||||
56
build/tests/WirelessChecker/components/racoon_wckr/Makefile
Normal file
56
build/tests/WirelessChecker/components/racoon_wckr/Makefile
Normal file
@ -0,0 +1,56 @@
|
||||
#! make -f
|
||||
#----------------------------------------------------------------------------
|
||||
# Project: TwlSDK - components - racoon.TWL
|
||||
# File: Makefile
|
||||
#
|
||||
# Copyright 2007 Nintendo. All rights reserved.
|
||||
#
|
||||
# These coded instructions, statements, and computer programs contain
|
||||
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
# Company Ltd., and are protected by Federal copyright law. They may
|
||||
# not be disclosed to third parties or copied or duplicated in any form,
|
||||
# in whole or in part, without the prior written consent of Nintendo.
|
||||
#
|
||||
# $Date:: $
|
||||
# $Rev$
|
||||
# $Author$
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Definition to override for racoon_wckr
|
||||
#
|
||||
|
||||
LLIBRARIES += libnwm_sp.WCKR$(TWL_LIBSUFFIX).a
|
||||
LLIBRARY_DIRS += ../../libraries/nwm/ARM7/lib/$(TWL_BUILDTYPE)
|
||||
|
||||
COMPONENT_DIR += $(ROOT)/build/components/racoon.TWL
|
||||
COMPONENT_SRC_DIR += $(ROOT)/build/components/mongoose.TWL/src
|
||||
|
||||
override SRCS = $(COMPONENT_SRC_DIR)/main.c $(COMPONENT_SRC_DIR)/initScfg.c
|
||||
|
||||
override TARGET_NAME = racoon
|
||||
|
||||
# Generate my own lsf from original lsf of mongoose
|
||||
LSF_ORG = $(COMPONENT_DIR)/$(TARGET_NAME).lsf
|
||||
MAKE_LSF = make_lsf.pl
|
||||
AUTOGEN_LSF = $(TARGET_NAME)_wckr.lsf
|
||||
|
||||
LDIRT_CLEAN = $(AUTOGEN_LSF)
|
||||
|
||||
override TARGET_NEF = $(TARGET_NAME).tef
|
||||
override LCFILE_SPEC = $(AUTOGEN_LSF)
|
||||
override LCFILE_TEMPLATE = $(COMPONENT_DIR)/$(TARGET_NAME).lcf.template
|
||||
override LDRES_TEMPLATE = $(COMPONENT_DIR)/$(TARGET_NAME).response.template
|
||||
|
||||
override TWL_INSTALL_COMPONENTSDIR=
|
||||
override INSTALL_TARGETS =
|
||||
override INSTALL_DIR =
|
||||
|
||||
#
|
||||
|
||||
include $(TWLSDK_ROOT)/build/components/racoon.TWL/Makefile
|
||||
|
||||
$(AUTOGEN_LSF): $(LSF_ORG) $(MAKE_LSF)
|
||||
@echo " make:" $@
|
||||
@perl $(MAKE_LSF) $(TARGET_NAME)
|
||||
|
||||
#===== End of Makefile =====
|
||||
53
build/tests/WirelessChecker/components/racoon_wckr/make_lsf.pl
Executable file
53
build/tests/WirelessChecker/components/racoon_wckr/make_lsf.pl
Executable file
@ -0,0 +1,53 @@
|
||||
#!/bin/perl
|
||||
#----------------------------------------------------------------------------
|
||||
# Project: TwlWLAN - components - mongoose_sdlog.TWL
|
||||
# File: make_lsf.pl
|
||||
#
|
||||
# Copyright 2007 Nintendo. All rights reserved.
|
||||
#
|
||||
# These coded insructions, statements, and computer programs contain
|
||||
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
# Company Ltd., and are protected by Federal copyright law. They may
|
||||
# not be disclosed to third parties or copied or duplicated in any form,
|
||||
# in whole or in part, without the prior written consent of Nintendo.
|
||||
#
|
||||
# $Date:: $
|
||||
# $Rev$
|
||||
# $Author$
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
|
||||
my $ROOT;
|
||||
|
||||
my $COMPONENT = $ARGV[0];
|
||||
print $COMPONENT;
|
||||
# search TWLSDK_ROOT
|
||||
foreach ( sort keys ( %ENV ) ){
|
||||
if ($_ =~ m/TWLSDK_ROOT/s) {
|
||||
$ROOT = $ENV{$_};
|
||||
}
|
||||
}
|
||||
|
||||
my $src = sprintf("$ROOT/build/components/%s.TWL/%s.lsf", $COMPONENT, $COMPONENT);
|
||||
my $dst = sprintf("%s_wckr.lsf", $COMPONENT);
|
||||
|
||||
|
||||
my $rn = "\x0D\x0A";
|
||||
|
||||
open(F, $src) or die "cant open $src\n";
|
||||
my @lines = <F>;
|
||||
close(F);
|
||||
|
||||
|
||||
open(OUT, ">$dst") or die "cant open $dst\n";
|
||||
foreach my $line ( @lines )
|
||||
{
|
||||
if( $line =~ m/libnwm_sp/ )
|
||||
{
|
||||
$line =~ s/libnwm_sp/libnwm_sp\.WCKR/;
|
||||
}
|
||||
|
||||
print OUT $line;
|
||||
}
|
||||
close(OUT);
|
||||
30
build/tests/WirelessChecker/libraries/Makefile
Normal file
30
build/tests/WirelessChecker/libraries/Makefile
Normal file
@ -0,0 +1,30 @@
|
||||
#! make -f
|
||||
#----------------------------------------------------------------------------
|
||||
# Project: TwlIPL
|
||||
# File: Makefile
|
||||
#
|
||||
# Copyright 2007 Nintendo. All rights reserved.
|
||||
#
|
||||
# These coded instructions, statements, and computer programs contain
|
||||
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
# Company Ltd., and are protected by Federal copyright law. They may
|
||||
# not be disclosed to third parties or copied or duplicated in any form,
|
||||
# in whole or in part, without the prior written consent of Nintendo.
|
||||
#
|
||||
# $Date:: $
|
||||
# $Rev$
|
||||
# $Author$
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
SUBDIRS = nwm
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
include $(TWLSDK_ROOT)/build/buildtools/modulerules
|
||||
|
||||
|
||||
#===== End of Makefile =====
|
||||
126
build/tests/WirelessChecker/libraries/nwm/ARM7/Makefile
Normal file
126
build/tests/WirelessChecker/libraries/nwm/ARM7/Makefile
Normal file
@ -0,0 +1,126 @@
|
||||
#! make -f
|
||||
#----------------------------------------------------------------------------
|
||||
# Project: TwlSDK - WM - libraries
|
||||
# File: Makefile
|
||||
#
|
||||
# Copyright 2003 Nintendo. All rights reserved.
|
||||
#
|
||||
# These coded instructions, statements, and computer programs contain
|
||||
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
# Company Ltd., and are protected by Federal copyright law. They may
|
||||
# not be disclosed to third parties or copied or duplicated in any form,
|
||||
# in whole or in part, without the prior written consent of Nintendo.
|
||||
#
|
||||
# $Date:: $
|
||||
# $Rev$
|
||||
# $Author$
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
SUBDIRS =
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
override TARGET_PLATFORM = TWL
|
||||
|
||||
# Codegen for sub processer
|
||||
TWL_PROC = ARM7
|
||||
|
||||
# build ARM & THUMB libraries
|
||||
TWL_CODEGEN ?= ALL
|
||||
|
||||
MACRO_FLAGS = -DNWM_WRACK_FIRMWARE
|
||||
|
||||
NWM_SRCDIR = $(ROOT)/build/libraries/wm/ARM7.TWL/nwm
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# INCDIR 注意点:
|
||||
INCDIR = $(NWM_SRCDIR)/inc $(NWM_SRCDIR)/../../inc \
|
||||
$(NWM_SRCDIR)/../../ARM7/inc $(NWM_SRCDIR)/../../common.TWL/inc \
|
||||
$(NWM_SRCDIR)/../common/inc \
|
||||
$(NWM_SRCDIR)/../../../wpa/include \
|
||||
$(TWLWIRELESS_ROOT)/include \
|
||||
$(TWLWIRELESS_ROOT)/host/include \
|
||||
$(TWLWIRELESS_ROOT)/host/wlan/include \
|
||||
$(TWLWIRELESS_ROOT)/host/os/twl/include \
|
||||
$(TWLWIRELESS_ROOT)/host/os/twl/library/athioctl/include \
|
||||
$(TWLWIRELESS_ROOT)/host/os/nitro/include \
|
||||
$(TWLWIRELESS_ROOT)/host/os/nitro/library/athioctl/include \
|
||||
$(ROOT)/build/libraries/spi/ARM7/include
|
||||
|
||||
SRCDIR_ = ../../ARM7/src src ../../common.TWL/src
|
||||
|
||||
SRCDIR = $(addprefix $(NWM_SRCDIR)/, $(SRCDIR_))
|
||||
|
||||
SRCS_ARM7 = nwmsp_system.c \
|
||||
nwmsp_cmd.c \
|
||||
nwmsp_event.c \
|
||||
nwmsp_wlan_handler.c \
|
||||
nwmsp_event_handler.c \
|
||||
nwmsp_beaconinfo.c
|
||||
|
||||
SRCS_COMMON = nwm_loaddev.c \
|
||||
nwm_unloaddev.c \
|
||||
nwm_open.c \
|
||||
nwm_close.c \
|
||||
nwm_startscan.c \
|
||||
nwm_connect.c \
|
||||
nwm_disconnect.c \
|
||||
nwm_sendframe.c \
|
||||
nwm_recvframe.c \
|
||||
nwm_setwepkey.c \
|
||||
nwm_setpowersave.c \
|
||||
nwm_wpa.c \
|
||||
nwm_qos.c \
|
||||
nwm_reset.c
|
||||
|
||||
SRCS = $(addprefix $(NWM_SRCDIR)/src/, $(SRCS_ARM7)) \
|
||||
$(addprefix $(NWM_SRCDIR)/../../common.TWL/src/, $(SRCS_COMMON)) \
|
||||
../src/nwm_installfirm_autogen.c
|
||||
|
||||
TARGET_LIB = libnwm_sp.WCKR$(TWL_LIBSUFFIX).a
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# DEBUG版ビルドの場合、RELEASE版でビルドして
|
||||
# DEBUG版のライブラリを装います。
|
||||
|
||||
ifdef TARGET_DEBUG
|
||||
TWL_BUILD_TYPE = RELEASE
|
||||
else
|
||||
ifdef TWL_DEBUG
|
||||
TWL_BUILD_TYPE = RELEASE
|
||||
CCFLAGS += -DNWM_DEBUG
|
||||
else
|
||||
ifdef NITRO_DEBUG
|
||||
TWL_BUILD_TYPE = RELEASE
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Default では LIMITED のライブラリを作成します
|
||||
TWL_ARCHGEN ?= LIMITED
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# 新無線用のデバッグフラグなど
|
||||
|
||||
ifdef NWM_DEBUG
|
||||
CCFLAGS += -DNWM_DEBUG
|
||||
endif
|
||||
|
||||
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||
|
||||
#INSTALL_TARGETS = $(TARGETS)
|
||||
#INSTALL_DIR = $(SYSMENU_INSTALL_LIBDIR)
|
||||
#GDIRT_INSTALLED = $(addprefix $(INSTALL_DIR)/,$(notdir $(INSTALL_TARGETS)))
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
do-build: $(TARGETS)
|
||||
|
||||
include $(TWLSDK_ROOT)/build/buildtools/modulerules
|
||||
|
||||
|
||||
#===== End of Makefile =====
|
||||
|
||||
95
build/tests/WirelessChecker/libraries/nwm/ARM9/Makefile
Normal file
95
build/tests/WirelessChecker/libraries/nwm/ARM9/Makefile
Normal file
@ -0,0 +1,95 @@
|
||||
#! make -f
|
||||
#----------------------------------------------------------------------------
|
||||
# Project: TwlSDK - WM - libraries
|
||||
# File: Makefile
|
||||
#
|
||||
# Copyright 2003 Nintendo. All rights reserved.
|
||||
#
|
||||
# These coded instructions, statements, and computer programs contain
|
||||
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
# Company Ltd., and are protected by Federal copyright law. They may
|
||||
# not be disclosed to third parties or copied or duplicated in any form,
|
||||
# in whole or in part, without the prior written consent of Nintendo.
|
||||
#
|
||||
# $Date:: $
|
||||
# $Rev$
|
||||
# $Author$
|
||||
#----------------------------------------------------------------------------
|
||||
#SUBDIRS = wm_lib
|
||||
|
||||
override TARGET_PLATFORM = TWL
|
||||
|
||||
# Codegen for sub processer
|
||||
TWL_PROC = ARM9
|
||||
TWL_CODEGEN ?= ALL
|
||||
|
||||
MACRO_FLAGS = -DNWM_WRACK_FIRMWARE
|
||||
|
||||
NWM_SRCDIR = $(ROOT)/build/libraries/wm/ARM9.TWL/nwm
|
||||
|
||||
# HYBRID / LIMITED 両方のライブラリを作成します
|
||||
TWL_ARCHGEN ?= ALL
|
||||
|
||||
# LoadDeviceEx で転送するファームウェアのディレクトリ
|
||||
TWLWIRELESS_FW_DIR = $(ROOT)/add-ins/TwlWireless/$(TWLWIRELESS_PACKAGE)/binfile
|
||||
|
||||
SRCDIR = ./src ../../common.TWL/src
|
||||
INCDIR = $(NWM_SRCDIR)/inc $(NWM_SRCDIR)/../../inc $(NWM_SRCDIR)/../../ARM9/inc \
|
||||
$(NWM_SRCDIR)/../../common.TWL/inc $(NWM_SRCDIR)/../common/inc
|
||||
|
||||
SRCS_ARM9 = nwm_init.c \
|
||||
nwm_system.c \
|
||||
nwm_end.c \
|
||||
nwm_cmd.c \
|
||||
nwm_passphrase.c
|
||||
|
||||
SRCS_COMMON = nwm_loaddev.c \
|
||||
nwm_unloaddev.c \
|
||||
nwm_open.c \
|
||||
nwm_close.c \
|
||||
nwm_startscan.c \
|
||||
nwm_connect.c \
|
||||
nwm_disconnect.c \
|
||||
nwm_setwepkey.c \
|
||||
nwm_setpowersave.c \
|
||||
nwm_sendframe.c \
|
||||
nwm_recvframe.c \
|
||||
nwm_wpa.c \
|
||||
nwm_qos.c \
|
||||
nwm_reset.c
|
||||
|
||||
SRCS = $(addprefix $(NWM_SRCDIR)/src/, $(SRCS_ARM9)) \
|
||||
$(addprefix $(NWM_SRCDIR)/../../common.TWL/src/, $(SRCS_COMMON)) \
|
||||
../src/nwm_installfirm_autogen.c
|
||||
|
||||
EXT_OBJS = $(OBJDIR)/nwm_firm.o
|
||||
|
||||
TARGET_LIB = libnwm.WCKR$(TWL_LIBSUFFIX).a
|
||||
|
||||
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||
|
||||
#INSTALL_TARGETS = $(TARGETS)
|
||||
|
||||
#INSTALL_DIR = $(TWL_INSTALL_LIBDIR)
|
||||
|
||||
GDIRT_INSTALLED = $(addprefix $(INSTALL_DIR)/,$(notdir $(INSTALL_TARGETS)))
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# 新無線用のデバッグフラグなど
|
||||
|
||||
ifdef NWM_DEBUG
|
||||
CCFLAGS += -DNWM_DEBUG
|
||||
endif
|
||||
|
||||
CCFLAGS += -DENABLE_RXACK
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
do-build: $(TARGETS)
|
||||
|
||||
include $(TWLSDK_ROOT)/build/buildtools/modulerules
|
||||
|
||||
$(OBJDIR)/nwm_firm.o: $(TWLWIRELESS_FW_DIR)/nwm_firm.bin
|
||||
$(BIN2OBJ) $(call empath, $<) $@
|
||||
|
||||
#===== End of Makefile =====
|
||||
39
build/tests/WirelessChecker/libraries/nwm/Makefile
Normal file
39
build/tests/WirelessChecker/libraries/nwm/Makefile
Normal file
@ -0,0 +1,39 @@
|
||||
#! make -f
|
||||
#----------------------------------------------------------------------------
|
||||
# Project: TwlSDK - libraries - wm
|
||||
# File: Makefile
|
||||
#
|
||||
# Copyright 2003 Nintendo. All rights reserved.
|
||||
#
|
||||
# These coded instructions, statements, and computer programs contain
|
||||
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
# Company Ltd., and are protected by Federal copyright law. They may
|
||||
# not be disclosed to third parties or copied or duplicated in any form,
|
||||
# in whole or in part, without the prior written consent of Nintendo.
|
||||
#
|
||||
# $Date:: $
|
||||
# $Rev$
|
||||
# $Author$
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
||||
TARGET_PLATFORM := TWL
|
||||
|
||||
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
SUBDIRS = scripts
|
||||
|
||||
ifneq ($(filter TWL,$(TARGET_PLATFORM_LIST)),)
|
||||
SUBDIRS_P += ARM9
|
||||
ifeq ($(TWLSDK_PRIVATE),TRUE)
|
||||
SUBDIRS_P += ARM7
|
||||
endif
|
||||
endif
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
include $(TWLSDK_ROOT)/build/buildtools/modulerules
|
||||
|
||||
#===== End of Makefile =====
|
||||
42
build/tests/WirelessChecker/libraries/nwm/scripts/Makefile
Normal file
42
build/tests/WirelessChecker/libraries/nwm/scripts/Makefile
Normal file
@ -0,0 +1,42 @@
|
||||
#! make -f
|
||||
#----------------------------------------------------------------------------
|
||||
# Project: TwlSDK - libraries - wm
|
||||
# File: Makefile
|
||||
#
|
||||
# Copyright 2007 Nintendo. All rights reserved.
|
||||
#
|
||||
# These coded instructions, statements, and computer programs contain
|
||||
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
# Company Ltd., and are protected by Federal copyright law. They may
|
||||
# not be disclosed to third parties or copied or duplicated in any form,
|
||||
# in whole or in part, without the prior written consent of Nintendo.
|
||||
#
|
||||
# $Date:: $
|
||||
# $Rev$
|
||||
# $Author$
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
override TWL_CODEGEN := ARM
|
||||
override TWL_ARCHGEN := LIMITED
|
||||
|
||||
NWM_ORG = $(ROOT)/build/libraries/wm/common.TWL/src/nwm_installfirm.c
|
||||
MAKE_NWM = make_nwm_fw_wrack.pl
|
||||
AUTOGEN_NWM = src/nwm_installfirm_autogen.c
|
||||
LDIRT_CLEAN += $(AUTOGEN_NWM)
|
||||
|
||||
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
TARGETS = $(AUTOGEN_NWM)
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
do-build: $(TARGETS)
|
||||
|
||||
include $(TWLSDK_ROOT)/build/buildtools/modulerules
|
||||
|
||||
$(AUTOGEN_NWM): $(NWM_ORG) $(MAKE_NWM)
|
||||
@echo " make:" $@
|
||||
@perl $(MAKE_NWM)
|
||||
|
||||
#===== End of Makefile =====
|
||||
108
build/tests/WirelessChecker/libraries/nwm/scripts/make_nwm_fw_wrack.pl
Executable file
108
build/tests/WirelessChecker/libraries/nwm/scripts/make_nwm_fw_wrack.pl
Executable file
@ -0,0 +1,108 @@
|
||||
#!/bin/perl
|
||||
#----------------------------------------------------------------------------
|
||||
# Project: TwlIPL - tests -
|
||||
# File: make_nwm_fw_wrack.pl
|
||||
#
|
||||
# Copyright 2007 Nintendo. All rights reserved.
|
||||
#
|
||||
# These coded insructions, statements, and computer programs contain
|
||||
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
# Company Ltd., and are protected by Federal copyright law. They may
|
||||
# not be disclosed to third parties or copied or duplicated in any form,
|
||||
# in whole or in part, without the prior written consent of Nintendo.
|
||||
#
|
||||
# $Date:: $
|
||||
# $Rev$
|
||||
# $Author$
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
|
||||
my $rn = "\x0D\x0A";
|
||||
|
||||
my $SDKROOT;
|
||||
|
||||
# search TWLSDK_ROOT
|
||||
foreach ( sort keys ( %ENV ) ){
|
||||
if ($_ =~ m/TWLSDK_ROOT/s) {
|
||||
$SDKROOT = $ENV{$_};
|
||||
}
|
||||
}
|
||||
|
||||
my $src = "$SDKROOT/build/libraries/wm/common.TWL/src/nwm_installfirm.c";
|
||||
my $dst_dir = "../src";
|
||||
my $dst_file = "nwm_installfirm_autogen.c";
|
||||
|
||||
open(F, $src) or die "cant open $src\n";
|
||||
my @lines = <F>;
|
||||
close(F);
|
||||
|
||||
mkdir $dst_dir unless -e $dst_dir;
|
||||
|
||||
my $in_instfirm_count = 0;
|
||||
|
||||
open(OUT, ">$dst_dir/$dst_file") or die "cant open $dst_dir/$dst_file\n";
|
||||
foreach my $line ( @lines )
|
||||
{
|
||||
if ( $line =~ m/^NWMRetCode NWMi_InstallFirmware\(NWMCallbackFunc callback, void\* addr, u32 size, BOOL isColdstart\)/ )
|
||||
{
|
||||
print OUT <<__WRACK_FIRMWARE_API__;
|
||||
|
||||
\#ifdef NWM_WRACK_FIRMWARE
|
||||
NWMRetCode NWMi_WrackFirmware(NWMCallbackFunc callback);
|
||||
|
||||
NWMRetCode NWMi_WrackFirmware(NWMCallbackFunc callback)
|
||||
{
|
||||
NWMArm9Buf *sys = NWMi_GetSystemWork();
|
||||
NWMRetCode result;
|
||||
|
||||
// コールバック関数を登録
|
||||
NWMi_SetCallbackTable(NWM_APIID_INSTALL_FIRMWARE, callback);
|
||||
|
||||
// ARM7にFIFOで通知
|
||||
result = NWMi_SendCommand(NWM_APIID_INSTALL_FIRMWARE, 5,
|
||||
(u32)(sys->NWM7), (u32)(sys->status), (u32)(sys->fifo7to9), NULL, FALSE);
|
||||
|
||||
return NWM_RETCODE_OPERATING;
|
||||
}
|
||||
\#endif // NWM_WRACK_FIRMWARE
|
||||
|
||||
__WRACK_FIRMWARE_API__
|
||||
}
|
||||
|
||||
if ( $line =~ m/MCU_SetWifiLedBlinkingStatus\( FALSE \);/ )
|
||||
{
|
||||
print OUT "#ifndef NWM_WRACK_FIRMWARE", $rn;
|
||||
}
|
||||
|
||||
if( $line =~ m/^installfirm_err:/ )
|
||||
{
|
||||
print OUT <<__WRACK_FIRMWARE__;
|
||||
|
||||
\#else // NWM_WRACK_FIRMWARE
|
||||
\#pragma unused (err)
|
||||
// set WiFi_RST to disable WiFi
|
||||
NWMSPi_SetWiFiReset(FALSE);
|
||||
OS_Sleep(1); // wait 1msec
|
||||
// set WiFi_RST to enable WiFi
|
||||
NWMSPi_SetWiFiReset(TRUE);
|
||||
{
|
||||
NWMCallback *cb;
|
||||
|
||||
NWMSP_ClearAPIActiveFlag(NWM_APIID_INSTALL_FIRMWARE);
|
||||
// 正常終了
|
||||
cb = (NWMCallback *)NWMSP_GetBuffer4Callback2Nwm9();
|
||||
cb->apiid = NWM_APIID_INSTALL_FIRMWARE;
|
||||
cb->retcode = NWM_RETCODE_FATAL_ERROR;
|
||||
NWMSP_ReturnResult2Nwm9((void *)cb);
|
||||
return;
|
||||
}
|
||||
\#endif // NWM_WRACK_FIRMWARE
|
||||
__WRACK_FIRMWARE__
|
||||
}
|
||||
print OUT $line;
|
||||
|
||||
|
||||
}
|
||||
close(OUT);
|
||||
|
||||
62
build/tests/WirelessChecker/readme.txt
Normal file
62
build/tests/WirelessChecker/readme.txt
Normal file
@ -0,0 +1,62 @@
|
||||
* WirelessChecker - 本体デバッグ用 無線機能チェックプログラム
|
||||
|
||||
- 確認手順
|
||||
|
||||
1. 本体無線フラグの確認
|
||||
|
||||
上画面の「無線ON/OFF設定」および「無線強制OFF本体」の設定を確認してください。
|
||||
無線が使用できる状態は、以下の状態です。
|
||||
|
||||
無線ON/OFF設定[ON ]
|
||||
無線強制OFF本体[No ]
|
||||
|
||||
|
||||
2. DS無線の初期化テスト
|
||||
|
||||
DS無線の初期化→スキャン→終了をテストします。
|
||||
アクティブスキャン(電波を出すスキャン)を行います。
|
||||
LEDの点滅を確認することで無線が正常に動作していることを確認してください。
|
||||
また、無線ON/OFF設定をOFFにすることで、初期化が失敗することを確認してください。
|
||||
|
||||
3. TWL無線の初期化テスト
|
||||
|
||||
TWL無線の初期化→スキャン→終了をテストします。
|
||||
アクティブスキャン(電波を出すスキャン)を行います。
|
||||
LEDの点滅を確認することで無線が正常に動作していることを確認してください。
|
||||
また、無線ON/OFF設定をOFFにすることで、初期化が失敗することを確認してください。
|
||||
|
||||
4. FATALエラーリカバリテスト
|
||||
|
||||
TWL無線モジュールのファームウェア壊れをエミュレートし、それによるFATALエラー発生後、
|
||||
アプリジャンプによるハードウェアリセットで、ファームウェアがロードし直されていることを確認します。
|
||||
再起動後に自動的にTWL無線の初期化チェックを行います。初期化チェックが成功し、LEDが点滅していることを確認してください。
|
||||
|
||||
(以下の項目はオプションです。)
|
||||
|
||||
5. FATALエラーエミュレーション
|
||||
項目4.のFATALエラーを手動で起こします。この操作を行った後、「TWL無線の初期化テスト」が失敗することを確認してください。
|
||||
|
||||
|
||||
- TODO
|
||||
|
||||
・NOAとかのデバッグにむけて英語表示も対応(?)
|
||||
|
||||
- 変更履歴
|
||||
|
||||
- 080801
|
||||
NANDアプリに対応。
|
||||
バナー追加。
|
||||
ゲームコード追加。
|
||||
|
||||
- 080731
|
||||
FINALROMでビルド。
|
||||
テスト用のプリントデバッグが出ていたのを修正。
|
||||
コマンドログを日本語化。
|
||||
TwlSDK 5.0 RC1でビルド。
|
||||
|
||||
- 080730
|
||||
下画面に簡易ヘルプを表示。
|
||||
|
||||
- 080725
|
||||
最初のリリース
|
||||
|
||||
BIN
build/tests/WirelessChecker/resources/ds_ipl10.bmp
Normal file
BIN
build/tests/WirelessChecker/resources/ds_ipl10.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 900 KiB |
37
build/tests/WirelessChecker/rsf/Makefile
Normal file
37
build/tests/WirelessChecker/rsf/Makefile
Normal file
@ -0,0 +1,37 @@
|
||||
#! make -f
|
||||
#----------------------------------------------------------------------------
|
||||
# Project: NitroWiFi - demos - ps-ping
|
||||
# File: Makefile
|
||||
#
|
||||
# Copyright 2005 Nintendo. All rights reserved.
|
||||
#
|
||||
# These coded instructions, statements, and computer programs contain
|
||||
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
# Company Ltd., and are protected by Federal copyright law. They may
|
||||
# not be disclosed to third parties or copied or duplicated in any form,
|
||||
# in whole or in part, without the prior written consent of Nintendo.
|
||||
#
|
||||
# $Log: Makefile,v $
|
||||
#
|
||||
# $NoKeywords: $
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Generate my own lsf from original lsf of mongoose
|
||||
RSF_ORG = $(ROOT)/include/twl/specfiles/ROM-TS.rsf
|
||||
MAKE_RSF = make_rsf.pl
|
||||
|
||||
AUTOGEN_RSF = wireless_checker.rsf
|
||||
|
||||
LDIRT_CLEAN = $(AUTOGEN_RSF)
|
||||
|
||||
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||
|
||||
do-build: $(AUTOGEN_RSF)
|
||||
|
||||
include $(TWLSDK_ROOT)/build/buildtools/modulerules
|
||||
|
||||
$(AUTOGEN_RSF): $(RSF_ORG) $(MAKE_RSF)
|
||||
@echo " make:" $@
|
||||
perl $(MAKE_RSF) $(AUTOGEN_RSF)
|
||||
|
||||
#===== End of Makefile =====
|
||||
97
build/tests/WirelessChecker/rsf/make_rsf.pl
Executable file
97
build/tests/WirelessChecker/rsf/make_rsf.pl
Executable file
@ -0,0 +1,97 @@
|
||||
#!/bin/perl
|
||||
#----------------------------------------------------------------------------
|
||||
# Project: TwlWLAN - demos - wifi
|
||||
# File: make_rsf.pl
|
||||
#
|
||||
# Copyright 2007 Nintendo. All rights reserved.
|
||||
#
|
||||
# These coded insructions, statements, and computer programs contain
|
||||
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
# Company Ltd., and are protected by Federal copyright law. They may
|
||||
# not be disclosed to third parties or copied or duplicated in any form,
|
||||
# in whole or in part, without the prior written consent of Nintendo.
|
||||
#
|
||||
# $Date:: $
|
||||
# $Rev$
|
||||
# $Author$
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
|
||||
my $ROOT;
|
||||
|
||||
# search TWLSDK_ROOT
|
||||
foreach ( sort keys ( %ENV ) ){
|
||||
if ($_ =~ m/TWLSDK_ROOT/s) {
|
||||
$ROOT = $ENV{$_};
|
||||
}
|
||||
}
|
||||
|
||||
my $src1 = "$ROOT/include/twl/specfiles/ROM-TS.rsf";
|
||||
my $dst1 = "wireless_checker.rsf";
|
||||
|
||||
|
||||
my $rn = "\x0D\x0A";
|
||||
|
||||
open(F, $src1) or die "cant open $src1\n";
|
||||
my @lines = <F>;
|
||||
close(F);
|
||||
|
||||
|
||||
open(OUT, ">$dst1") or die "cant open $dst1\n";
|
||||
foreach my $line ( @lines )
|
||||
{
|
||||
if( $line =~ m/TitleName\t+/ )
|
||||
{
|
||||
$line =~ s/\t\#?TitleName.*\".*\"/\tTitleName\t\t\"WLAN CHECKER\"/;
|
||||
}
|
||||
|
||||
if( $line =~ m/^\tBannerFile/ )
|
||||
{
|
||||
print OUT "\tBannerFile\t\t\$(BANNER_FILE)", $rn;
|
||||
print OUT $rn, "\t#", $rn;
|
||||
print OUT "\t# Permit LandingNormalJump: for TWL \"ApplicationJump\" function [TRUE/FALSE]", $rn;
|
||||
print OUT "\t#", $rn;
|
||||
print OUT "\tPermitLandingNormalJump\tTRUE", $rn;
|
||||
next;
|
||||
}
|
||||
|
||||
print OUT $line;
|
||||
}
|
||||
close(OUT);
|
||||
|
||||
|
||||
my $src2 = "$ROOT/include/twl/specfiles/ROM-TS_nand.rsf";
|
||||
my $dst2 = "wireless_checker_nand.rsf";
|
||||
|
||||
open(F, $src2) or die "cant open $src2\n";
|
||||
my @lines = <F>;
|
||||
close(F);
|
||||
|
||||
|
||||
open(OUT, ">$dst2") or die "cant open $dst2\n";
|
||||
foreach my $line ( @lines )
|
||||
{
|
||||
if( $line =~ m/^\tBannerFile/ )
|
||||
{
|
||||
print OUT "\tBannerFile\t\t\$(BANNER_FILE)", $rn;
|
||||
next;
|
||||
}
|
||||
|
||||
if( $line =~ m/GameCode\t+/ )
|
||||
{
|
||||
$line =~ s/\t\#?GameCode.*[a-zA-Z0-9]{4}/\tGameCode\t\t\t\t000A/;
|
||||
}
|
||||
|
||||
if( $line =~ m/TitleName\t+/ )
|
||||
{
|
||||
$line =~ s/\t\#?TitleName.*\".*\"/\tTitleName\t\t\"WLAN CHECKER\"/;
|
||||
}
|
||||
|
||||
if( $line =~ m/PermitLandingNormalJump/ )
|
||||
{
|
||||
$line =~ s/\t\#?.*(TRUE|FALSE)/\tPermitLandingNormalJump\tTRUE/;
|
||||
}
|
||||
|
||||
print OUT $line;
|
||||
}
|
||||
148
build/tests/WirelessChecker/src/frame.cpp
Normal file
148
build/tests/WirelessChecker/src/frame.cpp
Normal file
@ -0,0 +1,148 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TwlSDK - Wireless Checker
|
||||
File: main.cpp
|
||||
|
||||
Copyright 2007 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Date:: $
|
||||
$Rev$
|
||||
$Author$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "util/util.h"
|
||||
#include "util/canvas.h"
|
||||
#include "frame.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CFrame::CFrame() : m_itemIndex(ITEM_TEST_WM)
|
||||
{
|
||||
OS_InitMessageQueue(&m_EntrMsgq, m_EntrMsg, sizeof(m_EntrMsg)/sizeof(m_EntrMsg[0]));
|
||||
|
||||
}
|
||||
|
||||
CFrame::CFrame(u8 item)
|
||||
{
|
||||
m_itemIndex = item;
|
||||
OS_InitMessageQueue(&m_EntrMsgq, m_EntrMsg, sizeof(m_EntrMsg)/sizeof(m_EntrMsg[0]));
|
||||
}
|
||||
|
||||
CFrame::~CFrame()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
CFrame::InitDisp()
|
||||
{
|
||||
util::CCanvas* pcm = util::GetMain1Canvas();
|
||||
util::CCanvas* pcs = util::GetSub1Canvas();
|
||||
|
||||
pcm->Clear(util::COLOR_BLACK);
|
||||
pcs->Clear(util::COLOR_BLACK);
|
||||
pcm->Printf(16*5, 0, util::COLOR_WHITE, L"無線機能確認ツール");
|
||||
pcm->Printf(96, 16*1, util::COLOR_WHITE, L"BUILD TIME: %s %s", L""__DATE__, L""__TIME__);
|
||||
|
||||
DrawBorder(pcm, 4, 16*2 + 4, 256 - 8, 192 - (16*2 + 4), util::COLOR_WHITE);
|
||||
pcm->Printf(16*1, 16*3, util::COLOR_WHITE, L"無線ON/OFF設定[ %s ]", TRUE == OS_IsAvailableWireless() ? L"ON ":L"OFF");
|
||||
pcm->Printf(16*8, 16*3, util::COLOR_WHITE, L"無線強制OFF本体[ %s ]", TRUE == OS_IsForceDisableWireless() ? L"Yes":L"No ");
|
||||
|
||||
pcm->Printf(16*2, 16*5, util::COLOR_WHITE, L"DS無線の初期化テスト");
|
||||
pcm->Printf(16*2, 16*6, util::COLOR_WHITE, L"TWL無線の初期化テスト");
|
||||
pcm->Printf(16*2, 16*7, util::COLOR_WHITE, L"FATALエラーエミュレーション");
|
||||
pcm->Printf(16*2, 16*8, util::COLOR_WHITE, L"FATALエラーリカバリテスト");
|
||||
|
||||
DrawBorder(pcs, 4, 16*9 + 4, 256 - 8, 192 - (16*9 + 4), util::COLOR_WHITE);
|
||||
}
|
||||
|
||||
void
|
||||
CFrame::CursorDisp(int xpos, int ystart, util::PaletteColor color)
|
||||
{
|
||||
util::CCanvas* pcm = util::GetMain1Canvas();
|
||||
pcm->Clear(xpos, ystart, 16, 16*ITEM_NUM, util::COLOR_BLACK);
|
||||
pcm->Print(xpos, ystart + 16*GetItemIndex(), color, L"■");
|
||||
}
|
||||
|
||||
void
|
||||
CFrame::HelpDisp(util::PaletteColor color)
|
||||
{
|
||||
util::CCanvas* pcs = util::GetSub1Canvas();
|
||||
pcs->Clear(8, 16*9 + 8, 256 - 16, 16*2, util::COLOR_BLACK);
|
||||
|
||||
wchar_t *pHelpString1, *pHelpString2;
|
||||
|
||||
switch (GetItemIndex())
|
||||
{
|
||||
case ITEM_TEST_WM:
|
||||
pHelpString1 = L"DS無線の初期化テストを行います。";
|
||||
pHelpString2 = L"LEDの点滅を確認してください。";
|
||||
break;
|
||||
case ITEM_TEST_NWM:
|
||||
pHelpString1 = L"TWL無線の初期化テストを行います。";
|
||||
pHelpString2 = L"LEDの点滅を確認してください。";
|
||||
break;
|
||||
case ITEM_TEST_FATAL:
|
||||
pHelpString1 = L"FATALエラーを発生させ、TWL無線を使えなくします";
|
||||
pHelpString2 = L"HWリセットで回復します。";
|
||||
break;
|
||||
case ITEM_TEST_RECOVERY:
|
||||
pHelpString1 = L"FATALエラーのリカバリーをテストします。";
|
||||
pHelpString2 = L"再起動後にTWL無線初期化を確認してください。";
|
||||
break;
|
||||
}
|
||||
pcs->Print(8, 16*9 + 8, color, pHelpString1);
|
||||
pcs->Print(8, 16*10 + 8, color, pHelpString2);
|
||||
}
|
||||
|
||||
BOOL
|
||||
CFrame::AutoEnter()
|
||||
{
|
||||
return OS_SendMessage(&m_EntrMsgq, (OSMessage)TRUE, OS_MESSAGE_NOBLOCK);
|
||||
}
|
||||
|
||||
void
|
||||
CFrame::ProcessButton()
|
||||
{
|
||||
if (util::IsPadTrigger(PAD_KEY_UP))
|
||||
{
|
||||
decRound();
|
||||
} else
|
||||
if (util::IsPadTrigger(PAD_KEY_DOWN))
|
||||
{
|
||||
incRound();
|
||||
}
|
||||
|
||||
if (util::IsPadTrigger(PAD_BUTTON_A))
|
||||
{
|
||||
if (FALSE == OS_SendMessage(&m_EntrMsgq, (OSMessage)TRUE, OS_MESSAGE_NOBLOCK))
|
||||
{
|
||||
// already entered
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOL
|
||||
CFrame::IsEnter()
|
||||
{
|
||||
OSMessage msg;
|
||||
return OS_ReceiveMessage(&m_EntrMsgq, &msg, OS_MESSAGE_NOBLOCK);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
CFrame::DrawBorder(util::CCanvas* pCanvas, int px, int py, int pw, int ph, util::PaletteColor color)
|
||||
{
|
||||
pCanvas->Clear(px, py, pw, 1, color);
|
||||
pCanvas->Clear(px, py + ph - 1, pw, 1, color);
|
||||
pCanvas->Clear(px, py + 1, 1, ph - 2, color);
|
||||
pCanvas->Clear(px + pw - 1, py + 1, 1, ph - 2, color);
|
||||
}
|
||||
72
build/tests/WirelessChecker/src/frame.h
Normal file
72
build/tests/WirelessChecker/src/frame.h
Normal file
@ -0,0 +1,72 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TwlSDK - Wireless Checher
|
||||
File: frame.h
|
||||
|
||||
Copyright 2007 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Date:: $
|
||||
$Rev$
|
||||
$Author$
|
||||
*---------------------------------------------------------------------------*/
|
||||
#ifndef WIRELESS_CHECHER_FRAME_H_
|
||||
#define WIRELESS_CHECHER_FRAME_H_
|
||||
|
||||
#include <twl.h>
|
||||
#include "util/util.h"
|
||||
#include <vector>
|
||||
|
||||
class CFrame
|
||||
{
|
||||
public:
|
||||
enum {
|
||||
ITEM_TEST_WM,
|
||||
ITEM_TEST_NWM,
|
||||
ITEM_TEST_FATAL,
|
||||
ITEM_TEST_RECOVERY,
|
||||
ITEM_NUM
|
||||
};
|
||||
private:
|
||||
u8 m_itemIndex;
|
||||
OSMessageQueue m_EntrMsgq;
|
||||
OSMessage m_EntrMsg[1];
|
||||
BOOL m_isEnter;
|
||||
|
||||
static const u8 m_itemNum = ITEM_NUM;
|
||||
void incRound()
|
||||
{
|
||||
if (m_itemNum)
|
||||
{
|
||||
m_itemIndex = (u8)((m_itemIndex + 1)%m_itemNum);
|
||||
}
|
||||
}
|
||||
void decRound()
|
||||
{
|
||||
if (m_itemNum)
|
||||
{
|
||||
m_itemIndex = (u8)((m_itemNum + m_itemIndex - 1)%m_itemNum);
|
||||
}
|
||||
}
|
||||
public:
|
||||
CFrame();
|
||||
CFrame(u8 item);
|
||||
virtual ~CFrame();
|
||||
void InitDisp();
|
||||
void CursorDisp(int xpos, int ystart, util::PaletteColor color);
|
||||
void HelpDisp(util::PaletteColor color);
|
||||
virtual void ProcessButton();
|
||||
u8 GetItemIndex()
|
||||
{
|
||||
return m_itemIndex;
|
||||
}
|
||||
BOOL IsEnter();
|
||||
BOOL AutoEnter();
|
||||
void DrawBorder(util::CCanvas* pCanvas, int px, int py, int pw, int ph, util::PaletteColor color);
|
||||
};
|
||||
|
||||
#endif // WIRELESS_CHECHER_TEST_NWM_H_
|
||||
135
build/tests/WirelessChecker/src/main.cpp
Normal file
135
build/tests/WirelessChecker/src/main.cpp
Normal file
@ -0,0 +1,135 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TwlSDK - Wireless Checker
|
||||
File: main.cpp
|
||||
|
||||
Copyright 2007 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Date:: $
|
||||
$Rev$
|
||||
$Author$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <twl/os/common/sharedFont.h>
|
||||
#include "util/util.h"
|
||||
#include "util/canvas.h"
|
||||
#include "frame.h"
|
||||
#include "test_wm.h"
|
||||
#include "test_nwm.h"
|
||||
#include "test_fatal.h"
|
||||
#include "test_recovery.h"
|
||||
#include <nnsys/gfd.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
}
|
||||
// end of anonymous namespace
|
||||
|
||||
|
||||
void
|
||||
TwlStartUp(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
TwlMain(void)
|
||||
{
|
||||
BOOL isFatalChecking = FALSE;
|
||||
util::Init();
|
||||
|
||||
OSDeliverArgInfo argInfo;
|
||||
if (TRUE == OS_IsValidDeliverArg())
|
||||
{
|
||||
OS_InitDeliverArgInfo(&argInfo, 0);
|
||||
OS_DecodeDeliverArg();
|
||||
if( (OS_GetDeliverArgc() > 0) && ( STD_CompareNString( (const char *)OS_GetDeliverArgv(1), "fatal", 3 ) == 0 ) )
|
||||
{
|
||||
isFatalChecking = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// display on
|
||||
util::WaitVBlankIntr();
|
||||
util::dispOn();
|
||||
|
||||
CFrame menu(isFatalChecking == TRUE ? CFrame::ITEM_TEST_RECOVERY:CFrame::ITEM_TEST_WM);
|
||||
if (isFatalChecking == TRUE)
|
||||
{
|
||||
menu.AutoEnter();
|
||||
}
|
||||
CTestWm wm;
|
||||
CTestNwm nwm;
|
||||
CTestFatal fatal;
|
||||
CTestRecovery rcv;
|
||||
menu.InitDisp();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
util::UpdateGamePad();
|
||||
menu.ProcessButton();
|
||||
menu.CursorDisp(16*1, 16*5, util::COLOR_LIMEGREEN);
|
||||
menu.HelpDisp(util::COLOR_WHITE);
|
||||
|
||||
if (menu.IsEnter())
|
||||
{
|
||||
BOOL result;
|
||||
u8 itemidx = menu.GetItemIndex();
|
||||
util::CCanvas* pcm = util::GetMain1Canvas();
|
||||
|
||||
switch (itemidx)
|
||||
{
|
||||
case CFrame::ITEM_TEST_WM:
|
||||
pcm->Clear(16*12, 16*5, 16*3, 16, util::COLOR_BLACK);
|
||||
pcm->Print(16*12, 16*5, util::COLOR_YELLOW, L"TESTING");
|
||||
util::WaitVBlankIntr();
|
||||
util::UpdateDisplay();
|
||||
result = wm.WirelessTest();
|
||||
pcm->Clear(16*12, 16*5, 16*3, 16, util::COLOR_BLACK);
|
||||
pcm->Print(16*12, 16*5, result == TRUE ? util::COLOR_TURQUOISE:util::COLOR_RED, result == TRUE ? L"SUCCESS":L"FAILURE");
|
||||
break;
|
||||
case CFrame::ITEM_TEST_NWM:
|
||||
pcm->Clear(16*12, 16*6, 16*3, 16, util::COLOR_BLACK);
|
||||
pcm->Print(16*12, 16*6, util::COLOR_YELLOW, L"TESTING");
|
||||
util::WaitVBlankIntr();
|
||||
util::UpdateDisplay();
|
||||
result = nwm.WirelessTest();
|
||||
pcm->Clear(16*12, 16*6, 16*3, 16, util::COLOR_BLACK);
|
||||
pcm->Print(16*12, 16*6, result == TRUE ? util::COLOR_TURQUOISE:util::COLOR_RED, result == TRUE ? L"SUCCESS":L"FAILURE");
|
||||
break;
|
||||
case CFrame::ITEM_TEST_FATAL:
|
||||
pcm->Clear(16*12, 16*7, 16*3, 16, util::COLOR_BLACK);
|
||||
pcm->Print(16*12, 16*7, util::COLOR_YELLOW, L"TESTING");
|
||||
result = fatal.WrackTest();
|
||||
pcm->Clear(16*12, 16*7, 16*3, 16, util::COLOR_BLACK);
|
||||
pcm->Print(16*12, 16*7, result == TRUE ? util::COLOR_TURQUOISE:util::COLOR_RED, result == TRUE ? L"SUCCESS":L"FAILURE");
|
||||
break;
|
||||
case CFrame::ITEM_TEST_RECOVERY:
|
||||
pcm->Clear(16*12, 16*8, 16*3, 16, util::COLOR_BLACK);
|
||||
pcm->Print(16*12, 16*8, util::COLOR_YELLOW, L"TESTING");
|
||||
if (isFatalChecking == FALSE)
|
||||
{
|
||||
result = rcv.RecoveryTest();
|
||||
} else {
|
||||
result = rcv.RecoveryTest2();
|
||||
isFatalChecking = FALSE;
|
||||
}
|
||||
pcm->Clear(16*12, 16*8, 16*3, 16, util::COLOR_BLACK);
|
||||
pcm->Print(16*12, 16*8, result == TRUE ? util::COLOR_TURQUOISE:util::COLOR_RED, result == TRUE ? L"SUCCESS":L"FAILURE");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
util::WaitVBlankIntr();
|
||||
util::UpdateDisplay();
|
||||
}
|
||||
|
||||
}
|
||||
96
build/tests/WirelessChecker/src/test.cpp
Normal file
96
build/tests/WirelessChecker/src/test.cpp
Normal file
@ -0,0 +1,96 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TwlSDK - Wireless Checker
|
||||
File: main.cpp
|
||||
|
||||
Copyright 2007 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Date:: $
|
||||
$Rev$
|
||||
$Author$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <twl.h>
|
||||
#include "util/canvas.h"
|
||||
#include "util/util.h"
|
||||
#include "util/wprintf.h"
|
||||
#include <nnsys/g2d/g2d_Font.h>
|
||||
#include <nnsys/g2d/g2d_CharCanvas.h>
|
||||
#include <nnsys/g2d/g2d_TextCanvas.h>
|
||||
#include <nnsys/gfd.h>
|
||||
//#include <wchar.h>
|
||||
#include <memory>
|
||||
#include "test.h"
|
||||
|
||||
CTest::CTest() : m_state(TEST_STATE_NONE)
|
||||
{
|
||||
m_pc = util::GetSub1Canvas();
|
||||
}
|
||||
|
||||
CTest::~CTest()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
BOOL
|
||||
CTest::Init(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CTest::Enable(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CTest::ScanTest(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CTest::Disable(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CTest::End(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
u8
|
||||
CTest::GetState(void)
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
||||
void CTest::LogClear(util::CCanvas* pc)
|
||||
{
|
||||
pc->Clear(0, 0, 256, 16*9, util::COLOR_BLACK);
|
||||
m_line = 0;
|
||||
util::WaitVBlankIntr();
|
||||
util::UpdateDisplay();
|
||||
}
|
||||
|
||||
void
|
||||
CTest::LogPrintf(util::CCanvas* pc, const NNSG2dChar* text, ...)
|
||||
{
|
||||
std::auto_ptr<wchar_t> pLocalBuffer(new wchar_t[LOCAL_BUFFER_LEN]);
|
||||
va_list args;
|
||||
|
||||
va_start(args, text);
|
||||
util::VSNWPrintf(pLocalBuffer.get(), LOCAL_BUFFER_LEN, text, args);
|
||||
va_end(args);
|
||||
pc->Print(16*1, 16*m_line++, util::COLOR_WHITE, pLocalBuffer.get());
|
||||
util::WaitVBlankIntr();
|
||||
util::UpdateDisplay();
|
||||
}
|
||||
54
build/tests/WirelessChecker/src/test.h
Normal file
54
build/tests/WirelessChecker/src/test.h
Normal file
@ -0,0 +1,54 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TwlSDK - Wireless Checher
|
||||
File: test.h
|
||||
|
||||
Copyright 2007 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Date:: $
|
||||
$Rev$
|
||||
$Author$
|
||||
*---------------------------------------------------------------------------*/
|
||||
#ifndef WIRELESS_CHECHER_TEST_H_
|
||||
#define WIRELESS_CHECHER_TEST_H_
|
||||
|
||||
#include <twl.h>
|
||||
#include "util/util.h"
|
||||
#include "util/canvas.h"
|
||||
#include <nnsys/g2d/g2d_Font.h>
|
||||
#include <nnsys/g2d/g2d_CharCanvas.h>
|
||||
#include <nnsys/g2d/g2d_TextCanvas.h>
|
||||
|
||||
class CTest
|
||||
|
||||
{
|
||||
private:
|
||||
u8 m_line;
|
||||
static const int LOCAL_BUFFER_LEN = 1024;
|
||||
public:
|
||||
enum {
|
||||
TEST_STATE_NONE,
|
||||
TEST_STATE_INITIALIZED,
|
||||
TEST_STATE_ENABLED,
|
||||
TEST_STATE_NUM
|
||||
};
|
||||
u8 m_state;
|
||||
util::CCanvas *m_pc;
|
||||
CTest();
|
||||
virtual ~CTest();
|
||||
virtual BOOL Init(void);
|
||||
virtual BOOL Enable(void);
|
||||
virtual BOOL ScanTest(void);
|
||||
virtual BOOL Disable(void);
|
||||
virtual BOOL End(void);
|
||||
u8 GetState(void);
|
||||
void LogClear(util::CCanvas* pc);
|
||||
void LogPrintf(util::CCanvas* pc, const NNSG2dChar* text, ...);
|
||||
};
|
||||
|
||||
#endif // WIRELESS_CHECHER_TEST_H_
|
||||
130
build/tests/WirelessChecker/src/test_fatal.cpp
Normal file
130
build/tests/WirelessChecker/src/test_fatal.cpp
Normal file
@ -0,0 +1,130 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TwlSDK - Wireless Checker
|
||||
File: test_fatal.cpp
|
||||
|
||||
Copyright 2007 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Date:: $
|
||||
$Rev$
|
||||
$Author$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "util/util.h"
|
||||
#include "util/canvas.h"
|
||||
#include "test_fatal.h"
|
||||
#include "nwm_arm9_private.h"
|
||||
#pragma exceptions on
|
||||
|
||||
extern "C" {
|
||||
extern NWMRetCode NWMi_WrackFirmware(NWMCallbackFunc callback);
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
OSMessageQueue m_AsyncMsgq;
|
||||
OSMessage m_AsyncMsg[1];
|
||||
|
||||
void m_WrackFirmCallback(void *arg)
|
||||
{
|
||||
NWMCallback *cb = (NWMCallback*)arg;
|
||||
|
||||
if (FALSE == OS_SendMessage(&m_AsyncMsgq, (OSMessage)(cb->retcode == NWM_RETCODE_FATAL_ERROR ? TRUE:FALSE), OS_MESSAGE_NOBLOCK))
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void m_InitMessage(void)
|
||||
{
|
||||
OS_InitMessageQueue(&m_AsyncMsgq, m_AsyncMsg, sizeof(m_AsyncMsg)/sizeof(m_AsyncMsg[0]));
|
||||
}
|
||||
|
||||
BOOL m_WaitCallback(void)
|
||||
{
|
||||
OSMessage msg;
|
||||
(void)OS_ReceiveMessage(&m_AsyncMsgq, &msg, OS_MESSAGE_BLOCK);
|
||||
return (BOOL)msg;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
CTestFatal::CTestFatal()
|
||||
{
|
||||
m_InitMessage();
|
||||
}
|
||||
|
||||
CTestFatal::~CTestFatal()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
BOOL
|
||||
CTestFatal::Wrack(void)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (m_state < TEST_STATE_INITIALIZED)
|
||||
{
|
||||
throw L"ステートが不正です.\n";
|
||||
}
|
||||
|
||||
if (NWM_RETCODE_OPERATING != NWMi_WrackFirmware(m_WrackFirmCallback))
|
||||
{
|
||||
throw L"WrackFirmware 失敗.\n";
|
||||
}
|
||||
if (m_WaitCallback() == FALSE)
|
||||
{
|
||||
throw L"WrackFirmware 非同期処理失敗.\n";
|
||||
}
|
||||
LogPrintf(m_pc, L"WrackFirmware 成功.\n");
|
||||
|
||||
}
|
||||
catch (const wchar_t* string)
|
||||
{
|
||||
LogPrintf(m_pc, L"%s", string);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CTestFatal::WrackTest(void)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (FALSE == Init())
|
||||
{
|
||||
throw L"Init() 失敗.\n";
|
||||
}
|
||||
|
||||
if (FALSE == Wrack())
|
||||
{
|
||||
End();
|
||||
throw L"Wrack() 失敗.\n";
|
||||
}
|
||||
|
||||
if (FALSE == End())
|
||||
{
|
||||
throw L"End() 失敗.\n";
|
||||
}
|
||||
}
|
||||
catch (const wchar_t* string)
|
||||
{
|
||||
LogPrintf(m_pc, L"%s", string);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LogPrintf(m_pc, L"テストが完了しました.\n");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
37
build/tests/WirelessChecker/src/test_fatal.h
Normal file
37
build/tests/WirelessChecker/src/test_fatal.h
Normal file
@ -0,0 +1,37 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TwlSDK - Wireless Checher
|
||||
File: test_fatal.h
|
||||
|
||||
Copyright 2007 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Date:: $
|
||||
$Rev$
|
||||
$Author$
|
||||
*---------------------------------------------------------------------------*/
|
||||
#ifndef WIRELESS_CHECHER_TEST_FATAL_H_
|
||||
#define WIRELESS_CHECHER_TEST_FATAL_H_
|
||||
|
||||
#include <twl.h>
|
||||
#include "test.h"
|
||||
#include "test_nwm.h"
|
||||
#include "util/canvas.h"
|
||||
|
||||
class CTestFatal
|
||||
: public CTestNwm
|
||||
{
|
||||
private:
|
||||
public:
|
||||
CTestFatal();
|
||||
virtual ~CTestFatal();
|
||||
BOOL Wrack(void);
|
||||
BOOL WrackTest(void);
|
||||
};
|
||||
|
||||
|
||||
#endif // WIRELESS_CHECHER_TEST_FATAL_H_
|
||||
355
build/tests/WirelessChecker/src/test_nwm.cpp
Normal file
355
build/tests/WirelessChecker/src/test_nwm.cpp
Normal file
@ -0,0 +1,355 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TwlSDK - Wireless Checker
|
||||
File: test_nwm.cpp
|
||||
|
||||
Copyright 2007 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Date:: $
|
||||
$Rev$
|
||||
$Author$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "util/util.h"
|
||||
#include "util/canvas.h"
|
||||
#include "test_nwm.h"
|
||||
#pragma exceptions on
|
||||
|
||||
namespace test_nwm
|
||||
{
|
||||
OSMessageQueue m_AsyncMsgq;
|
||||
OSMessage m_AsyncMsg[1];
|
||||
void m_InitMessage(void);
|
||||
|
||||
void m_LoadDeviceCallback(void *arg)
|
||||
{
|
||||
NWMCallback *cb = (NWMCallback*)arg;
|
||||
|
||||
// TODO: get FW ver and RegDomain?
|
||||
|
||||
if (FALSE == OS_SendMessage(&m_AsyncMsgq, (OSMessage)(cb->retcode == NWM_RETCODE_SUCCESS ? TRUE:FALSE), OS_MESSAGE_NOBLOCK))
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
void m_OpenCallback(void *arg)
|
||||
{
|
||||
NWMCallback *cb = (NWMCallback*)arg;
|
||||
|
||||
if (FALSE == OS_SendMessage(&m_AsyncMsgq, (OSMessage)(cb->retcode == NWM_RETCODE_SUCCESS ? TRUE:FALSE), OS_MESSAGE_NOBLOCK))
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void m_UnloadDeviceCallback(void *arg)
|
||||
{
|
||||
NWMCallback *cb = (NWMCallback*)arg;
|
||||
|
||||
if (FALSE == OS_SendMessage(&m_AsyncMsgq, (OSMessage)(cb->retcode == NWM_RETCODE_SUCCESS ? TRUE:FALSE), OS_MESSAGE_NOBLOCK))
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
void m_CloseCallback(void *arg)
|
||||
{
|
||||
NWMCallback *cb = (NWMCallback*)arg;
|
||||
|
||||
if (FALSE == OS_SendMessage(&m_AsyncMsgq, (OSMessage)(cb->retcode == NWM_RETCODE_SUCCESS ? TRUE:FALSE), OS_MESSAGE_NOBLOCK))
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void m_ScanCallback(void *arg)
|
||||
{
|
||||
NWMStartScanCallback *cb = (NWMStartScanCallback*)arg;
|
||||
|
||||
OS_TPrintf("Number of BSS: %d\n", cb->bssDescCount);
|
||||
|
||||
if (FALSE == OS_SendMessage(&m_AsyncMsgq, (OSMessage)(cb->retcode == NWM_RETCODE_SUCCESS ? TRUE:FALSE), OS_MESSAGE_NOBLOCK))
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void m_InitMessage(void)
|
||||
{
|
||||
OS_InitMessageQueue(&m_AsyncMsgq, m_AsyncMsg, sizeof(m_AsyncMsg)/sizeof(m_AsyncMsg[0]));
|
||||
}
|
||||
|
||||
BOOL m_WaitCallback(void)
|
||||
{
|
||||
OSMessage msg;
|
||||
(void)OS_ReceiveMessage(&m_AsyncMsgq, &msg, OS_MESSAGE_BLOCK);
|
||||
return (BOOL)msg;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
CTestNwm::CTestNwm() : m_pNwmBuffer(0), m_pScanBuffer(0)
|
||||
{
|
||||
test_nwm::m_InitMessage();
|
||||
}
|
||||
|
||||
CTestNwm::~CTestNwm()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
CTestNwm::Init(void)
|
||||
{
|
||||
LogClear(m_pc);
|
||||
|
||||
try
|
||||
{
|
||||
if (m_state != TEST_STATE_NONE)
|
||||
{
|
||||
throw L"ステートが不正です.\n";
|
||||
}
|
||||
if (m_pNwmBuffer)
|
||||
{
|
||||
delete [] m_pNwmBuffer;
|
||||
m_pNwmBuffer = 0;
|
||||
throw L"NWMバッファが不正です.\n";
|
||||
}
|
||||
|
||||
m_pNwmBuffer = new u8 [NWM_SYSTEM_BUF_SIZE + 0x20];
|
||||
|
||||
|
||||
if (NWM_RETCODE_SUCCESS != NWM_Init((void*)MATH_ROUNDUP((u32)m_pNwmBuffer, 32), NWM_SYSTEM_BUF_SIZE, m_DmaNo))
|
||||
{
|
||||
throw L"NWM_Init 失敗.\n";
|
||||
}
|
||||
|
||||
LogPrintf(m_pc, L"NWM_Init 成功.\n");
|
||||
}
|
||||
|
||||
catch (const wchar_t* string)
|
||||
{
|
||||
delete [] m_pNwmBuffer;
|
||||
m_pNwmBuffer = 0;
|
||||
LogPrintf(m_pc, L"%s", string);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
m_state = TEST_STATE_INITIALIZED;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CTestNwm::Enable(void)
|
||||
{
|
||||
try {
|
||||
if (m_state != TEST_STATE_INITIALIZED)
|
||||
{
|
||||
throw L"ステートが不正です.\n";
|
||||
}
|
||||
|
||||
if (NWM_RETCODE_OPERATING != NWM_LoadDevice(test_nwm::m_LoadDeviceCallback))
|
||||
{
|
||||
throw L"NWM_LoadDevice 失敗.\n";
|
||||
}
|
||||
|
||||
if (test_nwm::m_WaitCallback() == FALSE)
|
||||
{
|
||||
throw L"NWM_LoadDevice 非同期処理失敗.\n";
|
||||
}
|
||||
LogPrintf(m_pc, L"NWM_LoadDevice 成功.\n");
|
||||
|
||||
if (NWM_RETCODE_OPERATING != NWM_Open(test_nwm::m_OpenCallback))
|
||||
{
|
||||
throw L"NWM_Open 失敗.\n";
|
||||
}
|
||||
if (test_nwm::m_WaitCallback() == FALSE)
|
||||
{
|
||||
throw L"NWM_Open 非同期処理失敗.\n";
|
||||
}
|
||||
LogPrintf(m_pc, L"NWM_Open 成功.\n");
|
||||
}
|
||||
|
||||
catch (const wchar_t* string)
|
||||
{
|
||||
LogPrintf(m_pc, L"%s", string);
|
||||
return FALSE;
|
||||
}
|
||||
m_state = TEST_STATE_ENABLED;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CTestNwm::ScanTest(void)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (m_state != TEST_STATE_ENABLED)
|
||||
{
|
||||
throw L"ステートが不正です.\n";
|
||||
}
|
||||
|
||||
if (m_pScanBuffer)
|
||||
{
|
||||
throw L"Scanバッファが不正です.\n";
|
||||
}
|
||||
|
||||
m_pScanBuffer = new u8 [NWM_SIZE_SCANBUF_MAX + 0x20];
|
||||
|
||||
NWMScanParam param;
|
||||
|
||||
MI_CpuClear8(m_pScanBuffer, NWM_SIZE_SCANBUF_MAX + 0x20);
|
||||
DC_StoreRange(m_pScanBuffer, NWM_SIZE_SCANBUF_MAX + 0x20);
|
||||
param.scanBuf = (NWMBssDesc*)MATH_ROUNDUP((u32)m_pScanBuffer, 32);
|
||||
param.scanBufSize = NWM_SIZE_SCANBUF_MAX;
|
||||
param.channelList = (u16)(NWM_GetAllowedChannel() >> 1);
|
||||
param.channelDwellTime = NWM_GetDispersionScanPeriod(NWM_SCANTYPE_ACTIVE);
|
||||
param.scanType = NWM_SCANTYPE_ACTIVE;
|
||||
param.ssidLength = 0;
|
||||
MI_CpuFill8(param.ssid, 0xFF, sizeof(param.ssid));
|
||||
|
||||
if (NWM_RETCODE_OPERATING != NWM_StartScan(test_nwm::m_ScanCallback, ¶m))
|
||||
{
|
||||
throw L"NWM_StartScan 失敗.\n";
|
||||
}
|
||||
|
||||
if (test_nwm::m_WaitCallback() == FALSE)
|
||||
{
|
||||
throw L"NWM_StartScan 非同期処理失敗.\n";
|
||||
}
|
||||
|
||||
LogPrintf(m_pc, L"NWM_StartScan 成功.\n");
|
||||
|
||||
}
|
||||
|
||||
catch (const wchar_t* string)
|
||||
{
|
||||
LogPrintf(m_pc, L"%s", string);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
delete [] m_pScanBuffer;
|
||||
m_pScanBuffer = 0;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CTestNwm::Disable(void)
|
||||
{
|
||||
try {
|
||||
if (m_state != TEST_STATE_ENABLED)
|
||||
{
|
||||
throw L"ステートが不正です.\n";
|
||||
}
|
||||
|
||||
if (NWM_RETCODE_OPERATING != NWM_Close(test_nwm::m_CloseCallback))
|
||||
{
|
||||
throw L"NWM_Close 失敗.\n";
|
||||
}
|
||||
if (test_nwm::m_WaitCallback() == FALSE)
|
||||
{
|
||||
throw L"NWM_Close 非同期処理失敗.\n";
|
||||
}
|
||||
LogPrintf(m_pc, L"NWM_Close 成功.\n");
|
||||
|
||||
if (NWM_RETCODE_OPERATING != NWM_UnloadDevice(test_nwm::m_UnloadDeviceCallback))
|
||||
{
|
||||
throw L"NWM_UnloadDevice 失敗.\n";
|
||||
}
|
||||
if (test_nwm::m_WaitCallback() == FALSE)
|
||||
{
|
||||
throw L"NWM_UnloadDevice 非同期処理失敗.\n";
|
||||
}
|
||||
LogPrintf(m_pc, L"NWM_UnloadDevice 成功.\n");
|
||||
}
|
||||
|
||||
catch (const wchar_t* string)
|
||||
{
|
||||
LogPrintf(m_pc, L"%s", string);
|
||||
return FALSE;
|
||||
}
|
||||
m_state = TEST_STATE_INITIALIZED;
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
BOOL
|
||||
CTestNwm::End(void)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (m_state != TEST_STATE_INITIALIZED)
|
||||
{
|
||||
throw L"ステートが不正です.\n";
|
||||
}
|
||||
if (NWM_RETCODE_SUCCESS != NWM_End())
|
||||
{
|
||||
throw L"NWM_End 失敗.\n";
|
||||
}
|
||||
|
||||
LogPrintf(m_pc, L"NWM_End 成功.\n");
|
||||
}
|
||||
|
||||
catch (const wchar_t* string)
|
||||
{
|
||||
LogPrintf(m_pc, L"%s", string);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
m_state = TEST_STATE_NONE;
|
||||
delete [] m_pNwmBuffer;
|
||||
m_pNwmBuffer = 0;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CTestNwm::WirelessTest(void)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (FALSE == Init())
|
||||
{
|
||||
throw L"Init() 失敗.\n";
|
||||
}
|
||||
if (FALSE == Enable())
|
||||
{
|
||||
End();
|
||||
throw L"Enable() 失敗.\n";
|
||||
}
|
||||
if (FALSE == ScanTest())
|
||||
{
|
||||
Disable();
|
||||
End();
|
||||
throw L"ScanTest() 失敗.\n";
|
||||
}
|
||||
if (FALSE == Disable())
|
||||
{
|
||||
throw L"Disable() 失敗.\n";
|
||||
}
|
||||
if (FALSE == End())
|
||||
{
|
||||
throw L"End() 失敗.\n";
|
||||
}
|
||||
}
|
||||
catch (const wchar_t* string)
|
||||
{
|
||||
LogPrintf(m_pc, L"%s", string);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LogPrintf(m_pc, L"テストが完了しました.\n");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
52
build/tests/WirelessChecker/src/test_nwm.h
Normal file
52
build/tests/WirelessChecker/src/test_nwm.h
Normal file
@ -0,0 +1,52 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TwlSDK - Wireless Checher
|
||||
File: test_nwm.h
|
||||
|
||||
Copyright 2007 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Date:: $
|
||||
$Rev$
|
||||
$Author$
|
||||
*---------------------------------------------------------------------------*/
|
||||
#ifndef WIRELESS_CHECHER_TEST_NWM_H_
|
||||
#define WIRELESS_CHECHER_TEST_NWM_H_
|
||||
|
||||
#include <twl.h>
|
||||
#include "test.h"
|
||||
|
||||
namespace test_nwm
|
||||
{
|
||||
void m_LoadDeviceCallback(void *arg);
|
||||
void m_OpenCallback(void *arg);
|
||||
void m_UnloadDeviceCallback(void *arg);
|
||||
void m_CloseCallback(void *arg);
|
||||
void m_ScanCallback(void *arg);
|
||||
BOOL m_WaitCallback(void);
|
||||
}
|
||||
|
||||
class CTestNwm
|
||||
: public CTest
|
||||
{
|
||||
private:
|
||||
static const u8 m_DmaNo = 3;
|
||||
u8 *m_pNwmBuffer;
|
||||
u8 *m_pScanBuffer;
|
||||
public:
|
||||
CTestNwm();
|
||||
virtual ~CTestNwm();
|
||||
BOOL Init(void);
|
||||
BOOL Enable(void);
|
||||
BOOL ScanTest(void);
|
||||
BOOL Disable(void);
|
||||
BOOL End(void);
|
||||
BOOL WirelessTest(void);
|
||||
};
|
||||
|
||||
|
||||
#endif // WIRELESS_CHECHER_TEST_NWM_H_
|
||||
97
build/tests/WirelessChecker/src/test_recovery.cpp
Normal file
97
build/tests/WirelessChecker/src/test_recovery.cpp
Normal file
@ -0,0 +1,97 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TwlSDK - Wireless Checker
|
||||
File: test_recovery.cpp
|
||||
|
||||
Copyright 2007 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Date:: $
|
||||
$Rev$
|
||||
$Author$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "util/util.h"
|
||||
#include "util/canvas.h"
|
||||
#include "test_recovery.h"
|
||||
#include "nwm_arm9_private.h"
|
||||
#pragma exceptions on
|
||||
|
||||
|
||||
CTestRecovery::CTestRecovery()
|
||||
{
|
||||
}
|
||||
|
||||
CTestRecovery::~CTestRecovery()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
CTestRecovery::RecoveryTest(void)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (FALSE == Init())
|
||||
{
|
||||
throw L"Init() 失敗.\n";
|
||||
}
|
||||
|
||||
if (FALSE == Enable())
|
||||
{
|
||||
End();
|
||||
throw L"Enable() 失敗.\n";
|
||||
}
|
||||
|
||||
if (FALSE == Wrack())
|
||||
{
|
||||
Disable();
|
||||
End();
|
||||
throw L"Wrack() 失敗.\n";
|
||||
}
|
||||
|
||||
LogPrintf(m_pc, L"FATALエラーを待っています.\n");
|
||||
|
||||
if (TRUE == test_nwm::m_WaitCallback())
|
||||
{
|
||||
Disable();
|
||||
End();
|
||||
throw L"FATALエラーが起こりませんでした.\n";
|
||||
}
|
||||
|
||||
LogPrintf(m_pc, L"FATALエラーが発生しました.\n");
|
||||
}
|
||||
catch (const wchar_t* string)
|
||||
{
|
||||
LogPrintf(m_pc, L"%s", string);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
m_state = TEST_STATE_INITIALIZED;
|
||||
End();
|
||||
LogPrintf(m_pc, L"3秒後にHWリセットを行います.\n");
|
||||
OS_Sleep(3000);
|
||||
|
||||
OSDeliverArgInfo argInfo;
|
||||
OS_InitDeliverArgInfo(&argInfo, 0);
|
||||
OSi_SetDeliverArgState( OS_DELIVER_ARG_BUF_ACCESSIBLE | OS_DELIVER_ARG_BUF_WRITABLE );
|
||||
OS_SetStringToDeliverArg( "fatal" );
|
||||
OS_EncodeDeliverArg();
|
||||
OS_DoApplicationJump(
|
||||
*(const OSTitleId*)(HW_TWL_ROM_HEADER_BUF + 0x230),
|
||||
OS_APP_JUMP_NORMAL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CTestRecovery::RecoveryTest2(void)
|
||||
{
|
||||
return WirelessTest();
|
||||
}
|
||||
|
||||
37
build/tests/WirelessChecker/src/test_recovery.h
Normal file
37
build/tests/WirelessChecker/src/test_recovery.h
Normal file
@ -0,0 +1,37 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TwlSDK - Wireless Checher
|
||||
File: test_recovery.h
|
||||
|
||||
Copyright 2007 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Date:: $
|
||||
$Rev$
|
||||
$Author$
|
||||
*---------------------------------------------------------------------------*/
|
||||
#ifndef WIRELESS_CHECHER_TEST_RECOVERY_H_
|
||||
#define WIRELESS_CHECHER_TEST_RECOVERY_H_
|
||||
|
||||
#include <twl.h>
|
||||
#include "test.h"
|
||||
#include "test_fatal.h"
|
||||
#include "util/canvas.h"
|
||||
|
||||
class CTestRecovery
|
||||
: public CTestFatal
|
||||
{
|
||||
private:
|
||||
public:
|
||||
CTestRecovery();
|
||||
~CTestRecovery();
|
||||
BOOL RecoveryTest(void);
|
||||
BOOL RecoveryTest2(void);
|
||||
};
|
||||
|
||||
|
||||
#endif // WIRELESS_CHECHER_TEST_RECOVERY_H_
|
||||
376
build/tests/WirelessChecker/src/test_wm.cpp
Normal file
376
build/tests/WirelessChecker/src/test_wm.cpp
Normal file
@ -0,0 +1,376 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TwlSDK - Wireless Checker
|
||||
File: test_nwm.cpp
|
||||
|
||||
Copyright 2007 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Date:: $
|
||||
$Rev$
|
||||
$Author$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "util/util.h"
|
||||
#include "util/canvas.h"
|
||||
#include "test_wm.h"
|
||||
#pragma exceptions on
|
||||
|
||||
namespace
|
||||
{
|
||||
OSMessageQueue m_AsyncMsgq;
|
||||
OSMessage m_AsyncMsg[1];
|
||||
|
||||
void m_EnableCallback(void *arg)
|
||||
{
|
||||
WMCallback *cb = (WMCallback*)arg;
|
||||
|
||||
// TODO: get FW ver and RegDomain?
|
||||
|
||||
if (FALSE == OS_SendMessage(&m_AsyncMsgq, (OSMessage)(cb->errcode == WM_ERRCODE_SUCCESS ? TRUE:FALSE), OS_MESSAGE_NOBLOCK))
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
void m_PowerOnCallback(void *arg)
|
||||
{
|
||||
WMCallback *cb = (WMCallback*)arg;
|
||||
|
||||
if (FALSE == OS_SendMessage(&m_AsyncMsgq, (OSMessage)(cb->errcode == WM_ERRCODE_SUCCESS ? TRUE:FALSE), OS_MESSAGE_NOBLOCK))
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void m_DisableCallback(void *arg)
|
||||
{
|
||||
WMCallback *cb = (WMCallback*)arg;
|
||||
|
||||
if (FALSE == OS_SendMessage(&m_AsyncMsgq, (OSMessage)(cb->errcode == WM_ERRCODE_SUCCESS ? TRUE:FALSE), OS_MESSAGE_NOBLOCK))
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
void m_PowerOffCallback(void *arg)
|
||||
{
|
||||
WMCallback *cb = (WMCallback*)arg;
|
||||
|
||||
if (FALSE == OS_SendMessage(&m_AsyncMsgq, (OSMessage)(cb->errcode == WM_ERRCODE_SUCCESS ? TRUE:FALSE), OS_MESSAGE_NOBLOCK))
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void m_ScanCallback(void *arg)
|
||||
{
|
||||
WMStartScanExCallback *cb = (WMStartScanExCallback*)arg;
|
||||
|
||||
OS_TPrintf("Number of BSS: %d\n", cb->bssDescCount);
|
||||
|
||||
if (FALSE == OS_SendMessage(&m_AsyncMsgq, (OSMessage)(cb->errcode == WM_ERRCODE_SUCCESS ? TRUE:FALSE), OS_MESSAGE_NOBLOCK))
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void m_EndScanCallback(void *arg)
|
||||
{
|
||||
WMCallback *cb = (WMCallback*)arg;
|
||||
|
||||
if (FALSE == OS_SendMessage(&m_AsyncMsgq, (OSMessage)(cb->errcode == WM_ERRCODE_SUCCESS ? TRUE:FALSE), OS_MESSAGE_NOBLOCK))
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void m_InitMessage(void)
|
||||
{
|
||||
OS_InitMessageQueue(&m_AsyncMsgq, m_AsyncMsg, sizeof(m_AsyncMsg)/sizeof(m_AsyncMsg[0]));
|
||||
}
|
||||
|
||||
BOOL m_WaitCallback(void)
|
||||
{
|
||||
OSMessage msg;
|
||||
(void)OS_ReceiveMessage(&m_AsyncMsgq, &msg, OS_MESSAGE_BLOCK);
|
||||
return (BOOL)msg;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
CTestWm::CTestWm() : m_pWmBuffer(0), m_pScanBuffer(0)
|
||||
{
|
||||
m_InitMessage();
|
||||
m_pc = util::GetSub1Canvas();
|
||||
}
|
||||
|
||||
CTestWm::~CTestWm()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
CTestWm::Init(void)
|
||||
{
|
||||
LogClear(m_pc);
|
||||
|
||||
try
|
||||
{
|
||||
if (m_state != TEST_STATE_NONE)
|
||||
{
|
||||
throw L"ステートが不正です.\n";
|
||||
}
|
||||
if (m_pWmBuffer)
|
||||
{
|
||||
delete [] m_pWmBuffer;
|
||||
m_pWmBuffer = 0;
|
||||
throw L"WM用バッファが不正です.\n";
|
||||
}
|
||||
|
||||
m_pWmBuffer = new u8 [WM_SYSTEM_BUF_SIZE + 0x20];
|
||||
|
||||
|
||||
if (WM_ERRCODE_SUCCESS != WM_Init((void*)MATH_ROUNDUP((u32)m_pWmBuffer, 32), m_DmaNo))
|
||||
{
|
||||
throw L"WM_Init 失敗.\n";
|
||||
}
|
||||
|
||||
LogPrintf(m_pc, L"WM_Init 成功.\n");
|
||||
|
||||
}
|
||||
|
||||
catch (const wchar_t* string)
|
||||
{
|
||||
delete [] m_pWmBuffer;
|
||||
m_pWmBuffer = 0;
|
||||
LogPrintf(m_pc, L"%s", string);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
m_state = TEST_STATE_INITIALIZED;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CTestWm::Enable(void)
|
||||
{
|
||||
try {
|
||||
|
||||
if (m_state != TEST_STATE_INITIALIZED)
|
||||
{
|
||||
throw L"ステートが不正です.\n";
|
||||
}
|
||||
|
||||
if (WM_ERRCODE_OPERATING != WM_Enable(m_EnableCallback))
|
||||
{
|
||||
throw L"WM_Enable 失敗.\n";
|
||||
}
|
||||
if (m_WaitCallback() == FALSE)
|
||||
{
|
||||
throw L"WM_Enable 非同期処理失敗.\n";
|
||||
}
|
||||
LogPrintf(m_pc, L"WM_Enable 成功.\n");
|
||||
if (WM_ERRCODE_OPERATING != WM_PowerOn(m_PowerOnCallback))
|
||||
{
|
||||
throw L"WM_PowerOn 失敗.\n";
|
||||
}
|
||||
if (m_WaitCallback() == FALSE)
|
||||
{
|
||||
throw L"WM_PowerOn 非同期処理失敗.\n";
|
||||
}
|
||||
LogPrintf(m_pc, L"WM_PowerOn 成功.\n");
|
||||
}
|
||||
|
||||
catch (const wchar_t* string)
|
||||
{
|
||||
LogPrintf(m_pc, L"%s", string);
|
||||
return FALSE;
|
||||
}
|
||||
m_state = TEST_STATE_ENABLED;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CTestWm::ScanTest(void)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (m_state != TEST_STATE_ENABLED)
|
||||
{
|
||||
throw L"ステートが不正です.\n";
|
||||
}
|
||||
|
||||
if (m_pScanBuffer)
|
||||
{
|
||||
throw L"Scanバッファが不正です.\n";
|
||||
}
|
||||
|
||||
m_pScanBuffer = new u8 [WM_SIZE_SCAN_EX_BUF + 0x20];
|
||||
|
||||
WMScanExParam param;
|
||||
|
||||
MI_CpuClear8(m_pScanBuffer, WM_SIZE_SCAN_EX_BUF + 0x20);
|
||||
DC_StoreRange(m_pScanBuffer, WM_SIZE_SCAN_EX_BUF + 0x20);
|
||||
param.scanBuf = (WMBssDesc*)MATH_ROUNDUP((u32)m_pScanBuffer, 32);
|
||||
param.scanBufSize = WM_SIZE_SCAN_EX_BUF;
|
||||
param.channelList = (u16)WM_GetAllowedChannel();
|
||||
param.maxChannelTime = WM_GetDispersionScanPeriod();
|
||||
param.scanType = WM_SCANTYPE_ACTIVE;
|
||||
param.ssidLength = 0;
|
||||
MI_CpuFill8(param.ssid, 0xFF, sizeof(param.ssid));
|
||||
param.ssidMatchLength = 0;
|
||||
|
||||
if (WM_ERRCODE_OPERATING != WM_StartScanEx(m_ScanCallback, ¶m))
|
||||
{
|
||||
throw L"WM_StartScanEx 失敗.\n";
|
||||
}
|
||||
|
||||
if (m_WaitCallback() == FALSE)
|
||||
{
|
||||
throw L"WM_StartScanEx 非同期処理失敗.\n";
|
||||
}
|
||||
LogPrintf(m_pc, L"WM_StartScanEx 成功.\n");
|
||||
|
||||
if (WM_ERRCODE_OPERATING != WM_EndScan(m_EndScanCallback))
|
||||
{
|
||||
throw L"WM_EndScan 失敗.\n";
|
||||
}
|
||||
|
||||
if (m_WaitCallback() == FALSE)
|
||||
{
|
||||
throw L"WM_EndScan 非同期処理失敗.\n";
|
||||
}
|
||||
LogPrintf(m_pc, L"WM_EndScan 成功.\n");
|
||||
|
||||
}
|
||||
|
||||
catch (const wchar_t* string)
|
||||
{
|
||||
LogPrintf(m_pc, L"%s", string);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
delete [] m_pScanBuffer;
|
||||
m_pScanBuffer = 0;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CTestWm::Disable(void)
|
||||
{
|
||||
try {
|
||||
if (m_state != TEST_STATE_ENABLED)
|
||||
{
|
||||
throw L"ステートが不正です.\n";
|
||||
}
|
||||
|
||||
if (WM_ERRCODE_OPERATING != WM_PowerOff(m_PowerOffCallback))
|
||||
{
|
||||
throw L"WM_PowerOff 失敗.\n";
|
||||
}
|
||||
if (m_WaitCallback() == FALSE)
|
||||
{
|
||||
throw L"WM_PowerOff 非同期処理失敗.\n";
|
||||
}
|
||||
LogPrintf(m_pc, L"WM_PowerOff 成功.\n");
|
||||
|
||||
if (WM_ERRCODE_OPERATING != WM_Disable(m_DisableCallback))
|
||||
{
|
||||
throw L"WM_Disable 失敗.\n";
|
||||
}
|
||||
if (m_WaitCallback() == FALSE)
|
||||
{
|
||||
throw L"WM_Disable 非同期処理失敗.\n";
|
||||
}
|
||||
LogPrintf(m_pc, L"WM_Disable 成功.\n");
|
||||
}
|
||||
|
||||
catch (const wchar_t* string)
|
||||
{
|
||||
LogPrintf(m_pc, L"%s", string);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
m_state = TEST_STATE_INITIALIZED;
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
BOOL
|
||||
CTestWm::End(void)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (m_state != TEST_STATE_INITIALIZED)
|
||||
{
|
||||
throw L"ステートが不正です\n";
|
||||
}
|
||||
if (WM_ERRCODE_SUCCESS != WM_Finish())
|
||||
{
|
||||
throw L"WM_Finish 失敗.\n";
|
||||
}
|
||||
LogPrintf(m_pc, L"WM_Finish 成功.\n");
|
||||
}
|
||||
|
||||
catch (const wchar_t* string)
|
||||
{
|
||||
LogPrintf(m_pc, L"%s", string);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
m_state = TEST_STATE_NONE;
|
||||
delete [] m_pWmBuffer;
|
||||
m_pWmBuffer = 0;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CTestWm::WirelessTest(void)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (FALSE == Init())
|
||||
{
|
||||
throw L"Init() 失敗.\n";
|
||||
}
|
||||
if (FALSE == Enable())
|
||||
{
|
||||
End();
|
||||
throw L"Enable() 失敗.\n";
|
||||
}
|
||||
if (FALSE == ScanTest())
|
||||
{
|
||||
Disable();
|
||||
End();
|
||||
throw L"ScanTest() 失敗.\n";
|
||||
}
|
||||
if (FALSE == Disable())
|
||||
{
|
||||
throw L"Disable() 失敗.\n";
|
||||
}
|
||||
if (FALSE == End())
|
||||
{
|
||||
throw L"End() 失敗.\n";
|
||||
}
|
||||
}
|
||||
catch (const wchar_t* string)
|
||||
{
|
||||
LogPrintf(m_pc, L"%s", string);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LogPrintf(m_pc, L"テストが完了しました.\n");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
43
build/tests/WirelessChecker/src/test_wm.h
Normal file
43
build/tests/WirelessChecker/src/test_wm.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TwlSDK - Wireless Checher
|
||||
File: test_wm.h
|
||||
|
||||
Copyright 2007 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Date:: $
|
||||
$Rev$
|
||||
$Author$
|
||||
*---------------------------------------------------------------------------*/
|
||||
#ifndef WIRELESS_CHECHER_TEST_WM_H_
|
||||
#define WIRELESS_CHECHER_TEST_WM_H_
|
||||
|
||||
#include <twl.h>
|
||||
#include "test.h"
|
||||
#include "util/canvas.h"
|
||||
|
||||
class CTestWm
|
||||
: public CTest
|
||||
{
|
||||
private:
|
||||
static const u8 m_DmaNo = 3;
|
||||
u8 *m_pWmBuffer;
|
||||
u8 *m_pScanBuffer;
|
||||
public:
|
||||
CTestWm();
|
||||
virtual ~CTestWm();
|
||||
BOOL Init(void);
|
||||
BOOL Enable(void);
|
||||
BOOL ScanTest(void);
|
||||
BOOL Disable(void);
|
||||
BOOL End(void);
|
||||
BOOL WirelessTest(void);
|
||||
};
|
||||
|
||||
|
||||
#endif // WIRELESS_CHECHER_TEST_WM_H_
|
||||
175
build/tests/WirelessChecker/src/util/canvas.cpp
Normal file
175
build/tests/WirelessChecker/src/util/canvas.cpp
Normal file
@ -0,0 +1,175 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TwlSDK - Nmenu
|
||||
File: Canvas.cpp
|
||||
|
||||
Copyright 2007 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Date:: $
|
||||
$Rev$
|
||||
$Author$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <twl.h>
|
||||
#include "util/canvas.h"
|
||||
#include "util/util.h"
|
||||
#include "util/wprintf.h"
|
||||
#include <nnsys/g2d/g2d_Font.h>
|
||||
#include <nnsys/g2d/g2d_CharCanvas.h>
|
||||
#include <nnsys/g2d/g2d_TextCanvas.h>
|
||||
#include <nnsys/gfd.h>
|
||||
//#include <wchar.h>
|
||||
#include <memory>
|
||||
|
||||
namespace util
|
||||
{
|
||||
|
||||
CCanvas::CCanvas()
|
||||
: m_pFont(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
CCanvas::~CCanvas()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CCanvas::Init(NNS_GFD_DST_TYPE type, u32 offset, void* pScrBase, const NNSG2dFont* pFont)
|
||||
{
|
||||
m_transType = type;
|
||||
m_transOffset = offset;
|
||||
m_pFont = pFont;
|
||||
|
||||
NNS_G2dCharCanvasInitForBG(
|
||||
&m_cc,
|
||||
m_offscreen,
|
||||
CANVAS_WIDTH,
|
||||
CANVAS_HEIGHT,
|
||||
NNS_G2D_CHARA_COLORMODE_16 );
|
||||
|
||||
NNS_G2dTextCanvasInit(
|
||||
&m_txn,
|
||||
&m_cc,
|
||||
m_pFont,
|
||||
TEXT_HSPACE,
|
||||
TEXT_VSPACE );
|
||||
|
||||
NNS_G2dMapScrToCharText(
|
||||
pScrBase,
|
||||
CANVAS_WIDTH,
|
||||
CANVAS_HEIGHT,
|
||||
CANVAS_LEFT,
|
||||
CANVAS_TOP,
|
||||
NNS_G2D_TEXT_BG_WIDTH_256,
|
||||
CANVAS_CHARACTER_OFFSET,
|
||||
DEFAULT_COLOR_PALETTE );
|
||||
}
|
||||
|
||||
void
|
||||
CCanvas::Clear(PaletteColor c)
|
||||
{
|
||||
NNS_G2dCharCanvasClear(&m_cc, c);
|
||||
RegisterTransferTask();
|
||||
}
|
||||
|
||||
void
|
||||
CCanvas::Clear(int x, int y, int w, int h, PaletteColor c)
|
||||
{
|
||||
const int px = MATH_CLAMP(x, 0, HW_LCD_WIDTH);
|
||||
const int py = MATH_CLAMP(y, 0, HW_LCD_HEIGHT);
|
||||
const int pw = MATH_CLAMP(x + w, px, HW_LCD_WIDTH) - px;
|
||||
const int ph = MATH_CLAMP(y + h, py, HW_LCD_HEIGHT) - py;
|
||||
|
||||
if( pw > 0 && ph > 0 )
|
||||
{
|
||||
NNS_G2dCharCanvasClearArea(&m_cc, c, px, py, pw, ph);
|
||||
RegisterTransferTask();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CCanvas::Print(int x, int y, PaletteColor c, const NNSG2dChar* text)
|
||||
{
|
||||
NNS_G2dTextCanvasDrawText(
|
||||
&m_txn,
|
||||
x,
|
||||
y,
|
||||
c,
|
||||
DRAWTEXT_FLAG_DEFAULT,
|
||||
text );
|
||||
|
||||
RegisterTransferTask();
|
||||
}
|
||||
|
||||
void
|
||||
CCanvas::Printf(int x, int y, PaletteColor c, const NNSG2dChar* text, ...)
|
||||
{
|
||||
std::auto_ptr<wchar_t> pLocalBuffer(new wchar_t[LOCAL_BUFFER_LEN]);
|
||||
va_list args;
|
||||
|
||||
va_start(args, text);
|
||||
VSNWPrintf(pLocalBuffer.get(), LOCAL_BUFFER_LEN, text, args);
|
||||
va_end(args);
|
||||
|
||||
Print(x, y, c, pLocalBuffer.get());
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CCanvas::RegisterTransferTask()
|
||||
{
|
||||
if( ! m_bTransferRegsitered )
|
||||
{
|
||||
NNS_GfdRegisterNewVramTransferTask(
|
||||
m_transType,
|
||||
m_transOffset,
|
||||
m_offscreen,
|
||||
sizeof(m_offscreen) );
|
||||
|
||||
m_bTransferRegsitered = true;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CCanvas::ResetTransferTask()
|
||||
{
|
||||
m_bTransferRegsitered = false;
|
||||
}
|
||||
|
||||
|
||||
std::wstring
|
||||
CCanvas::WrapText(std::wstring text, int width)
|
||||
{
|
||||
int textWidth = 0;
|
||||
|
||||
for( u32 i = 0; i < text.length(); ++i )
|
||||
{
|
||||
const int charWidth = NNS_G2dFontGetCharWidth(m_pFont, text[i]);
|
||||
|
||||
if( text[i] == L'\n' )
|
||||
{
|
||||
textWidth = 0;
|
||||
}
|
||||
else if( (textWidth > 0) && ((textWidth + charWidth) > width) )
|
||||
{
|
||||
text.insert(i - 1, 1, L'\n');
|
||||
textWidth = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
textWidth += charWidth + TEXT_HSPACE;
|
||||
}
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
// end of namespace tlib
|
||||
78
build/tests/WirelessChecker/src/util/canvas.h
Normal file
78
build/tests/WirelessChecker/src/util/canvas.h
Normal file
@ -0,0 +1,78 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TwlSDK - Nmenu
|
||||
File: Canvas.h
|
||||
|
||||
Copyright 2007 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Date:: $
|
||||
$Rev$
|
||||
$Author$
|
||||
*---------------------------------------------------------------------------*/
|
||||
#ifndef TLIB_CONTROL_CANVAS_H_
|
||||
#define TLIB_CONTROL_CANVAS_H_
|
||||
|
||||
#define NNS_G2D_UNICODE
|
||||
#include <nnsys/g2d/g2di_Char.h>
|
||||
#include <nnsys/g2d/g2d_TextCanvas.h>
|
||||
#include <nnsys/gfd.h>
|
||||
#include <string>
|
||||
#include "util.h"
|
||||
|
||||
namespace util
|
||||
{
|
||||
|
||||
class CCanvas
|
||||
{
|
||||
private:
|
||||
static const int CANVAS_WIDTH = 32;
|
||||
static const int CANVAS_HEIGHT = 24;
|
||||
static const int CANVAS_LEFT = 0;
|
||||
static const int CANVAS_TOP = 0;
|
||||
static const int TEXT_HSPACE = 1;
|
||||
static const int TEXT_VSPACE = 1;
|
||||
static const int CANVAS_CHARACTER_OFFSET = 1;
|
||||
|
||||
static const int LOCAL_BUFFER_LEN = 1024;
|
||||
|
||||
static const u32 DRAWTEXT_FLAG_DEFAULT = ( NNS_G2D_VERTICALORIGIN_TOP
|
||||
| NNS_G2D_HORIZONTALORIGIN_LEFT
|
||||
| NNS_G2D_HORIZONTALALIGN_LEFT );
|
||||
|
||||
private:
|
||||
NNSG2dCharCanvas m_cc;
|
||||
NNSG2dTextCanvas m_txn;
|
||||
GXCharFmt16 m_offscreen[32 * 24];
|
||||
const NNSG2dFont* m_pFont;
|
||||
NNS_GFD_DST_TYPE m_transType;
|
||||
u32 m_transOffset;
|
||||
bool m_bTransferRegsitered;
|
||||
|
||||
public:
|
||||
CCanvas();
|
||||
~CCanvas();
|
||||
|
||||
public:
|
||||
void Init(NNS_GFD_DST_TYPE type, u32 offset, void* pScrBase, const NNSG2dFont* pFont);
|
||||
void Clear (PaletteColor c);
|
||||
void Clear (int x, int y, int w, int h, PaletteColor c);
|
||||
void Print (int x, int y, PaletteColor c, const NNSG2dChar* text);
|
||||
void Printf(int x, int y, PaletteColor c, const NNSG2dChar* text, ...);
|
||||
std::wstring WrapText(std::wstring text, int width);
|
||||
|
||||
void ResetTransferTask();
|
||||
|
||||
protected:
|
||||
void RegisterTransferTask();
|
||||
};
|
||||
|
||||
}
|
||||
// end of namespace tlib
|
||||
|
||||
|
||||
#endif // TLIB_CONTROL_CANVAS_H_
|
||||
122
build/tests/WirelessChecker/src/util/memory.cpp
Normal file
122
build/tests/WirelessChecker/src/util/memory.cpp
Normal file
@ -0,0 +1,122 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TwlSDK - Nmenu
|
||||
File: Memory.cpp
|
||||
|
||||
Copyright 2007 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Date:: $
|
||||
$Rev$
|
||||
$Author$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "util/memory.h"
|
||||
|
||||
|
||||
namespace util
|
||||
{
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
NNSFndHeapHandle shHeap;
|
||||
NNSFndAllocator sAllocator;
|
||||
OSMutex sLock;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InitMemory()
|
||||
{
|
||||
u32 arenaLow = MATH_ROUNDUP ((u32)OS_GetMainArenaLo(), 16);
|
||||
u32 arenaHigh = MATH_ROUNDDOWN((u32)OS_GetMainArenaHi(), 16);
|
||||
u32 heapSize = arenaHigh - arenaLow;
|
||||
void* heapMemory = OS_AllocFromMainArenaLo(heapSize, 16);
|
||||
|
||||
shHeap = NNS_FndCreateExpHeap(heapMemory, heapSize);
|
||||
SDK_ASSERT( shHeap != NNS_FND_HEAP_INVALID_HANDLE );
|
||||
|
||||
NNS_FndInitAllocatorForExpHeap(&sAllocator, shHeap, 4);
|
||||
|
||||
OS_InitMutex(&sLock);
|
||||
}
|
||||
|
||||
NNSFndHeapHandle
|
||||
GetHeapHandle()
|
||||
{
|
||||
return shHeap;
|
||||
}
|
||||
|
||||
NNSFndAllocator*
|
||||
GetAllocator()
|
||||
{
|
||||
return &sAllocator;
|
||||
}
|
||||
|
||||
void*
|
||||
Alloc(size_t size, int align)
|
||||
{
|
||||
OS_LockMutex(&sLock);
|
||||
SDK_ASSERT(NNS_FndCheckExpHeap(shHeap, NNS_FND_HEAP_ERROR_PRINT));
|
||||
void* p = NNS_FndAllocFromExpHeapEx(shHeap, size, align);
|
||||
OS_UnlockMutex(&sLock);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
void
|
||||
Free(void* ptr)
|
||||
{
|
||||
OS_LockMutex(&sLock);
|
||||
SDK_ASSERT(NNS_FndCheckExpHeap(shHeap, NNS_FND_HEAP_ERROR_PRINT));
|
||||
SDK_ASSERT(NNS_FndCheckForMBlockExpHeap(ptr, shHeap, NNS_FND_HEAP_ERROR_PRINT));
|
||||
NNS_FndFreeToExpHeap(shHeap, ptr);
|
||||
OS_UnlockMutex(&sLock);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// end of namespace util
|
||||
|
||||
|
||||
|
||||
|
||||
//------------ global namespace ------------------------------------
|
||||
|
||||
void*
|
||||
operator new(size_t size)
|
||||
{
|
||||
// operator new[] で 32 byte アライメントを保証できないので
|
||||
// operator new でも 32 byte アライメントは行わない。
|
||||
return util::Alloc(size, 4);
|
||||
}
|
||||
|
||||
void*
|
||||
operator new[](size_t size)
|
||||
{
|
||||
// operator new[] では 32 byteアライメントを保証できない。
|
||||
return util::Alloc(size, 4);
|
||||
}
|
||||
|
||||
void
|
||||
operator delete(void* ptr)
|
||||
{
|
||||
if( ptr != NULL )
|
||||
{
|
||||
util::Free(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
operator delete[](void* ptr)
|
||||
{
|
||||
if( ptr != NULL )
|
||||
{
|
||||
util::Free(ptr);
|
||||
}
|
||||
}
|
||||
38
build/tests/WirelessChecker/src/util/memory.h
Normal file
38
build/tests/WirelessChecker/src/util/memory.h
Normal file
@ -0,0 +1,38 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TwlSDK - Nmenu
|
||||
File: Memory.h
|
||||
|
||||
Copyright 2007 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Date:: $
|
||||
$Rev$
|
||||
$Author$
|
||||
*---------------------------------------------------------------------------*/
|
||||
#ifndef TLIB_SYSTEM_MEMORY_H_
|
||||
#define TLIB_SYSTEM_MEMORY_H_
|
||||
|
||||
#include <new>
|
||||
#include <nnsys/fnd.h>
|
||||
|
||||
namespace util
|
||||
{
|
||||
|
||||
void InitMemory();
|
||||
|
||||
NNSFndAllocator* GetAllocator();
|
||||
NNSFndHeapHandle GetHeapHandle();
|
||||
void* Alloc(size_t size, int align=32);
|
||||
void Free(void* ptr);
|
||||
|
||||
}
|
||||
// end of namespace tlib
|
||||
|
||||
|
||||
|
||||
#endif // TLIB_SYSTEM_MEMORY_H_
|
||||
276
build/tests/WirelessChecker/src/util/util.cpp
Normal file
276
build/tests/WirelessChecker/src/util/util.cpp
Normal file
@ -0,0 +1,276 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TwlSDK - Wireless Checker
|
||||
File: util.cpp
|
||||
|
||||
Copyright 2008 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Date:: $
|
||||
$Rev$
|
||||
$Author$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "util/util.h"
|
||||
#include "util/canvas.h"
|
||||
#include "util/memory.h"
|
||||
#include <nnsys/gfd.h>
|
||||
#include <nnsys/g2d/g2d_Font.h>
|
||||
|
||||
extern u8 font_NFTR_begin[];
|
||||
extern u8 font_NFTR_end[];
|
||||
|
||||
namespace util
|
||||
{
|
||||
GamePad System_GamePadState;
|
||||
int System_BaseWidth;
|
||||
int System_LineHeight;
|
||||
|
||||
namespace
|
||||
{
|
||||
const int REPEAT_START_FRAME = 15;
|
||||
const int REPEAT_INTERVAL = 30;
|
||||
const u32 TASK_ARRAY_NUM = 4;
|
||||
const int CANVAS_CHARACTER_OFFSET = 1;
|
||||
|
||||
GXRgb COLOR_PALETTE[18] =
|
||||
{
|
||||
GX_RGB(26, 26, 26),
|
||||
GX_RGB(31, 31, 31),
|
||||
GX_RGB( 0, 0, 0),
|
||||
|
||||
GX_RGB(31, 0, 3),
|
||||
GX_RGB(30, 28, 0),
|
||||
GX_RGB(21, 31, 0),
|
||||
GX_RGB( 6, 23, 30),
|
||||
GX_RGB( 0, 11, 30),
|
||||
GX_RGB(25, 23, 1),
|
||||
GX_RGB(22, 22, 22),
|
||||
GX_RGB(16, 16, 16),
|
||||
|
||||
GX_RGB(29, 31, 31)
|
||||
};
|
||||
NNSG2dFont sFont;
|
||||
CCanvas sCanvasMain1;
|
||||
CCanvas sCanvasMain3;
|
||||
CCanvas sCanvasSub1;
|
||||
CCanvas sCanvasSub3;
|
||||
|
||||
NNSGfdVramTransferTask sTaskArray[TASK_ARRAY_NUM];
|
||||
|
||||
void ClearVram( void )
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
// All VRAM banks to LCDC
|
||||
//---------------------------------------------------------------------------
|
||||
GX_SetBankForLCDC(GX_VRAM_LCDC_ALL);
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Clear all LCDC space
|
||||
//---------------------------------------------------------------------------
|
||||
MI_CpuClearFast((void *)HW_LCDC_VRAM, HW_LCDC_VRAM_SIZE);
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Disable the banks on LCDC
|
||||
//---------------------------------------------------------------------------
|
||||
(void)GX_DisableBankForLCDC();
|
||||
|
||||
MI_CpuFillFast((void *)HW_OAM, 192, HW_OAM_SIZE); // clear OAM
|
||||
MI_CpuClearFast((void *)HW_PLTT, HW_PLTT_SIZE); // clear the standard palette
|
||||
|
||||
MI_CpuFillFast((void*)HW_DB_OAM, 192, HW_DB_OAM_SIZE); // clear OAM
|
||||
MI_CpuClearFast((void *)HW_DB_PLTT, HW_DB_PLTT_SIZE); // clear the standard palette
|
||||
}
|
||||
|
||||
void InitFont(void* pNFTR)
|
||||
{
|
||||
NNS_G2dFontInitUTF16(&sFont, pNFTR);
|
||||
|
||||
System_BaseWidth = NNS_G2dFontGetCellWidth(&sFont) / 2;
|
||||
System_LineHeight = NNS_G2dFontGetLineFeed(&sFont);
|
||||
}
|
||||
|
||||
void VBlankIntr(void)
|
||||
{
|
||||
OS_SetIrqCheckFlag( OS_IE_V_BLANK );
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
void WaitVBlankIntr(void)
|
||||
{
|
||||
SVC_WaitVBlankIntr();
|
||||
}
|
||||
|
||||
void dispOn(void)
|
||||
{
|
||||
GX_DispOn();
|
||||
GXS_DispOn();
|
||||
}
|
||||
|
||||
CCanvas* GetMain1Canvas() { return &sCanvasMain1; }
|
||||
CCanvas* GetMain3Canvas() { return &sCanvasMain3; }
|
||||
CCanvas* GetSub1Canvas() { return &sCanvasSub1; }
|
||||
CCanvas* GetSub3Canvas() { return &sCanvasSub3; }
|
||||
|
||||
void UpdateGamePad(void)
|
||||
{
|
||||
u16 status = PAD_Read();
|
||||
|
||||
System_GamePadState.repeatTrigger = false;
|
||||
|
||||
if( status != 0 )
|
||||
{
|
||||
if( System_GamePadState.button == 0 )
|
||||
{
|
||||
System_GamePadState.beginPress = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
System_GamePadState.beginPress++;
|
||||
const int lapse = System_GamePadState.beginPress - REPEAT_START_FRAME;
|
||||
|
||||
if( lapse >= 0 )
|
||||
{
|
||||
if( (lapse % REPEAT_INTERVAL) == 0 )
|
||||
{
|
||||
System_GamePadState.repeatTrigger = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System_GamePadState.trigger = (u16)(status & (status ^ System_GamePadState.button));
|
||||
System_GamePadState.release = (u16)(System_GamePadState.button & (status ^ System_GamePadState.button));
|
||||
System_GamePadState.button = status;
|
||||
}
|
||||
|
||||
void UpdateDisplay(void)
|
||||
{
|
||||
sCanvasMain1.ResetTransferTask();
|
||||
sCanvasMain3.ResetTransferTask();
|
||||
sCanvasSub1 .ResetTransferTask();
|
||||
sCanvasSub3 .ResetTransferTask();
|
||||
NNS_GfdDoVramTransfer();
|
||||
}
|
||||
|
||||
void Init()
|
||||
{
|
||||
OS_Init();
|
||||
FX_Init();
|
||||
GX_Init();
|
||||
|
||||
OS_InitTick();
|
||||
OS_InitAlarm();
|
||||
|
||||
GX_DispOff();
|
||||
GXS_DispOff();
|
||||
|
||||
RTC_Init();
|
||||
|
||||
OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr);
|
||||
(void)OS_EnableIrqMask(OS_IE_V_BLANK);
|
||||
(void)GX_VBlankIntr(TRUE);
|
||||
(void)OS_EnableIrq();
|
||||
(void)OS_EnableInterrupts();
|
||||
|
||||
ClearVram();
|
||||
|
||||
InitMemory();
|
||||
|
||||
// assign vram banks
|
||||
GX_SetBankForBG(GX_VRAM_BG_128_A);
|
||||
GX_SetBankForOBJ(GX_VRAM_OBJ_16_F);
|
||||
GX_SetBankForSubBG(GX_VRAM_SUB_BG_128_C);
|
||||
GX_SetBankForSubOBJ(GX_VRAM_SUB_OBJ_16_I);
|
||||
GX_SetBankForLCDC(GX_VRAM_LCDC_B);
|
||||
|
||||
// init screen
|
||||
// BG 1 を設定
|
||||
G2_SetBG1Control(
|
||||
GX_BG_SCRSIZE_TEXT_256x256, // スクリーンサイズ 256x256
|
||||
GX_BG_COLORMODE_16, // カラーモード 16色
|
||||
GX_BG_SCRBASE_0x0000, // スクリーンベース
|
||||
GX_BG_CHARBASE_0x04000, // キャラクタベース
|
||||
GX_BG_EXTPLTT_01 ); // 拡張パレットスロット
|
||||
|
||||
G2S_SetBG1Control(
|
||||
GX_BG_SCRSIZE_TEXT_256x256, // スクリーンサイズ 256x256
|
||||
GX_BG_COLORMODE_16, // カラーモード 16色
|
||||
GX_BG_SCRBASE_0x0000, // スクリーンベース
|
||||
GX_BG_CHARBASE_0x04000, // キャラクタベース
|
||||
GX_BG_EXTPLTT_01 ); // 拡張パレットスロット
|
||||
|
||||
// BG 2 を設定
|
||||
G2_SetBG2ControlText(
|
||||
GX_BG_SCRSIZE_TEXT_256x256, // スクリーンサイズ 256x256
|
||||
GX_BG_COLORMODE_16, // カラーモード 16色
|
||||
GX_BG_SCRBASE_0x0800, // スクリーンベース
|
||||
GX_BG_CHARBASE_0x0c000 ); // キャラクタベース
|
||||
|
||||
G2S_SetBG2ControlText(
|
||||
GX_BG_SCRSIZE_TEXT_256x256, // スクリーンサイズ 256x256
|
||||
GX_BG_COLORMODE_16, // カラーモード 16色
|
||||
GX_BG_SCRBASE_0x0800, // スクリーンベース
|
||||
GX_BG_CHARBASE_0x0c000 ); // キャラクタベース
|
||||
|
||||
// BG 3 を設定
|
||||
G2_SetBG3ControlText(
|
||||
GX_BG_SCRSIZE_TEXT_256x256, // スクリーンサイズ 256x256
|
||||
GX_BG_COLORMODE_16, // カラーモード 16色
|
||||
GX_BG_SCRBASE_0x1000, // スクリーンベース
|
||||
GX_BG_CHARBASE_0x14000 ); // キャラクタベース
|
||||
|
||||
G2S_SetBG3ControlText(
|
||||
GX_BG_SCRSIZE_TEXT_256x256, // スクリーンサイズ 256x256
|
||||
GX_BG_COLORMODE_16, // カラーモード 16色
|
||||
GX_BG_SCRBASE_0x1000, // スクリーンベース
|
||||
GX_BG_CHARBASE_0x14000 ); // キャラクタベース
|
||||
|
||||
// BG1/3 を可視に
|
||||
GX_SetVisiblePlane ( GX_PLANEMASK_BG1 | GX_PLANEMASK_BG3 );
|
||||
GXS_SetVisiblePlane( GX_PLANEMASK_BG1 | GX_PLANEMASK_BG3 );
|
||||
|
||||
// BG1/2/3 の優先順位設定
|
||||
G2_SetBG1Priority(3);
|
||||
G2_SetBG2Priority(2);
|
||||
G2_SetBG3Priority(1);
|
||||
G2S_SetBG1Priority(3);
|
||||
G2S_SetBG2Priority(2);
|
||||
G2S_SetBG3Priority(1);
|
||||
|
||||
GX_LoadBGPltt(COLOR_PALETTE, 0, sizeof(COLOR_PALETTE));
|
||||
GXS_LoadBGPltt(COLOR_PALETTE, 0, sizeof(COLOR_PALETTE));
|
||||
|
||||
GX_SetGraphicsMode(GX_DISPMODE_GRAPHICS, GX_BGMODE_0, GX_BG0_AS_2D);
|
||||
GXS_SetGraphicsMode(GX_BGMODE_0);
|
||||
GX_SetBGScrOffset(GX_BGSCROFFSET_0x00000);
|
||||
GX_SetBGCharOffset(GX_BGCHAROFFSET_0x00000);
|
||||
|
||||
InitFont(font_NFTR_begin);
|
||||
|
||||
{
|
||||
const u32 chrOffset = CANVAS_CHARACTER_OFFSET * sizeof(GXCharFmt16);
|
||||
sCanvasMain1.Init(NNS_GFD_DST_2D_BG1_CHAR_MAIN, chrOffset, G2_GetBG1ScrPtr(), &sFont);
|
||||
sCanvasMain3.Init(NNS_GFD_DST_2D_BG3_CHAR_MAIN, chrOffset, G2_GetBG3ScrPtr(), &sFont);
|
||||
sCanvasSub1 .Init(NNS_GFD_DST_2D_BG1_CHAR_SUB, chrOffset, G2S_GetBG1ScrPtr(), &sFont);
|
||||
sCanvasSub3 .Init(NNS_GFD_DST_2D_BG3_CHAR_SUB, chrOffset, G2S_GetBG3ScrPtr(), &sFont);
|
||||
|
||||
NNS_GfdInitVramTransferManager(sTaskArray, TASK_ARRAY_NUM);
|
||||
}
|
||||
|
||||
PAD_Read();
|
||||
}
|
||||
|
||||
u16 GetPadTrigger()
|
||||
{
|
||||
return static_cast<u16>(System_GamePadState.button);
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
|
||||
103
build/tests/WirelessChecker/src/util/util.h
Normal file
103
build/tests/WirelessChecker/src/util/util.h
Normal file
@ -0,0 +1,103 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TwlSDK - Wireless Checher
|
||||
File: util.h
|
||||
|
||||
Copyright 2007 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Date:: $
|
||||
$Rev$
|
||||
$Author$
|
||||
*---------------------------------------------------------------------------*/
|
||||
#ifndef WIRELESS_CHECHER_UTIL_H_
|
||||
#define WIRELESS_CHECHER_UTIL_H_
|
||||
|
||||
#include <twl.h>
|
||||
|
||||
namespace util
|
||||
{
|
||||
|
||||
const int DEFAULT_COLOR_PALETTE = 0;
|
||||
|
||||
enum PaletteColor
|
||||
{
|
||||
COLOR_NULL=0,
|
||||
COLOR_WHITE,
|
||||
COLOR_BLACK,
|
||||
|
||||
COLOR_RED,
|
||||
COLOR_YELLOW,
|
||||
COLOR_LIMEGREEN,
|
||||
COLOR_TURQUOISE,
|
||||
COLOR_BLUE,
|
||||
COLOR_BROWN,
|
||||
COLOR_LIGHTGRAY,
|
||||
COLOR_DARKGRAY,
|
||||
|
||||
COLOR_GUIDE_BG
|
||||
};
|
||||
|
||||
struct GamePad
|
||||
{
|
||||
u16 trigger;
|
||||
u16 release;
|
||||
u16 button;
|
||||
bool repeatTrigger;
|
||||
u8 padding0;
|
||||
int beginPress;
|
||||
};
|
||||
|
||||
void Init(void);
|
||||
void WaitVBlankIntr(void);
|
||||
void dispOn(void);
|
||||
void UpdateGamePad(void);
|
||||
void UpdateDisplay(void);
|
||||
|
||||
class CCanvas;
|
||||
CCanvas* GetMain1Canvas();
|
||||
CCanvas* GetMain3Canvas();
|
||||
CCanvas* GetSub1Canvas();
|
||||
CCanvas* GetSub3Canvas();
|
||||
|
||||
inline u16
|
||||
IsPadDown(u16 key)
|
||||
{
|
||||
extern GamePad System_GamePadState;
|
||||
return static_cast<u16>(System_GamePadState.trigger & key);
|
||||
}
|
||||
inline u16
|
||||
IsPadUp(u16 key)
|
||||
{
|
||||
extern GamePad System_GamePadState;
|
||||
return static_cast<u16>(System_GamePadState.release & key);
|
||||
}
|
||||
inline u16
|
||||
IsPadPress(u16 key)
|
||||
{
|
||||
extern GamePad System_GamePadState;
|
||||
return static_cast<u16>(System_GamePadState.button & key);
|
||||
}
|
||||
inline u16
|
||||
IsPadTrigger(u16 key)
|
||||
{
|
||||
extern GamePad System_GamePadState;
|
||||
if( System_GamePadState.repeatTrigger )
|
||||
{
|
||||
return IsPadPress(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
return IsPadDown(key);
|
||||
}
|
||||
}
|
||||
|
||||
u16 GetPadTrigger();
|
||||
|
||||
} // namespace util
|
||||
|
||||
#endif // WIRELESS_CHECHER_UTIL_H_
|
||||
387
build/tests/WirelessChecker/src/util/wprintf.cpp
Normal file
387
build/tests/WirelessChecker/src/util/wprintf.cpp
Normal file
@ -0,0 +1,387 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TwlSDK - Nmenu
|
||||
File: WPrintf.cpp
|
||||
|
||||
Copyright 2007 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Date:: $
|
||||
$Rev$
|
||||
$Author$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "util/wprintf.h"
|
||||
|
||||
namespace util
|
||||
{
|
||||
namespace
|
||||
{
|
||||
/* inner function for sized-buffer output */
|
||||
|
||||
typedef struct dst_string_tag
|
||||
{
|
||||
size_t len;
|
||||
wchar_t *cur;
|
||||
wchar_t *base;
|
||||
} dst_string;
|
||||
|
||||
void
|
||||
string_put_char(dst_string *p, wchar_t c)
|
||||
{
|
||||
if(p->len > 0) *p->cur = c, --p->len;
|
||||
++p->cur;
|
||||
}
|
||||
|
||||
void
|
||||
string_fill_char(dst_string *p, wchar_t c, int n)
|
||||
{
|
||||
if(n > 0) {
|
||||
size_t i, k = p->len;
|
||||
if(k > (size_t)n) k = (size_t)n;
|
||||
for( i = 0 ; i < k ; ++i )
|
||||
p->cur[i] = c;
|
||||
p->len -= k;
|
||||
p->cur += n;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
string_put_string(dst_string *p, const wchar_t *s, int n)
|
||||
{
|
||||
if(n > 0) {
|
||||
size_t i, k = p->len;
|
||||
if(k > (size_t)n) k = (size_t)n;
|
||||
for( i = 0 ; i < k ; ++i )
|
||||
p->cur[i] = s[i];
|
||||
p->len -= k;
|
||||
p->cur += n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// based on OS_VSNPrintf
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: OS_VSNPrintf
|
||||
|
||||
Description: small-size vsnprintf which is similar to 'vsnprintf'
|
||||
without following supports.
|
||||
* CodeWarrior Extensions (#s)
|
||||
* MSL AltiVec Extensions (v, vh, vl, hv, lv, @)
|
||||
* indexed argments (%m$, *m$)
|
||||
* floating-point
|
||||
* wchar_t
|
||||
|
||||
Note: '+' and '#' do not work, MSL's sprintf().
|
||||
to keep same result, they are no implement.
|
||||
{ // exsample
|
||||
wchar_t buf[5];
|
||||
sprintf(buf, "%-i\n", 45); // "45" (OK)
|
||||
sprintf(buf, "%0i\n", 45); // "45" (OK)
|
||||
sprintf(buf, "% i\n", 45); // " 45" (OK)
|
||||
sprintf(buf, "%+i\n", 45); // "%+i" ("+45" expected)
|
||||
sprintf(buf, "%#x\n", 45); // "%#x" ("0x2d" expected)
|
||||
// but, this works correctly!
|
||||
sprintf(buf, "% +i\n", 45); // "+45" (OK)
|
||||
}
|
||||
|
||||
Arguments: dst : destination buffer.
|
||||
len : destination buffer size.
|
||||
fmt : format string.
|
||||
vlist : parameters.
|
||||
|
||||
Returns: length of the generated string. (except '\0')
|
||||
if(result < len),
|
||||
put NUL in dst[result].
|
||||
else if(len > 0),
|
||||
put NUL in dst[len - 1].
|
||||
else,
|
||||
do nothing.
|
||||
*---------------------------------------------------------------------------*/
|
||||
int
|
||||
VSNWPrintf(wchar_t *dst, size_t len, const wchar_t *fmt, va_list vlist)
|
||||
{
|
||||
wchar_t buf[24];
|
||||
int n_buf;
|
||||
wchar_t prefix[2];
|
||||
int n_prefix;
|
||||
|
||||
const wchar_t *s = fmt;
|
||||
|
||||
dst_string str;
|
||||
str.len = len, str.cur = str.base = dst;
|
||||
|
||||
while(*s) {
|
||||
if(*s != L'%') {
|
||||
/* normal character */
|
||||
string_put_char(&str, *s++);
|
||||
} else {
|
||||
/* output with format */
|
||||
enum {
|
||||
flag_blank = 000001, /* L' ' */
|
||||
flag_plus = 000002, /* L'+' */
|
||||
flag_sharp = 000004, /* L'#' */
|
||||
flag_minus = 000010, /* L'-' */
|
||||
flag_zero = 000020, /* L'0' */
|
||||
flag_l1 = 000040, /* "l" */
|
||||
flag_h1 = 000100, /* "h" */
|
||||
flag_l2 = 000200, /* "ll" */
|
||||
flag_h2 = 000400, /* "hh" */
|
||||
flag_unsigned = 010000, /* L'o', L'u', ... */
|
||||
flag_end } ;
|
||||
int flag = 0, width = 0, precision = -1, radix = 10;
|
||||
wchar_t hex_char = L'a' - 10;
|
||||
const wchar_t *p_start = s;
|
||||
/* flags */
|
||||
for( ; ; ) {
|
||||
switch(*++s) {
|
||||
case L'+':if(s[-1] != L' ') break;
|
||||
flag |= flag_plus; continue;
|
||||
case L' ':flag |= flag_blank;continue;
|
||||
case L'-':flag |= flag_minus;continue;
|
||||
case L'0':flag |= flag_zero; continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
/* width */
|
||||
if(*s == L'*') {
|
||||
++s, width = va_arg(vlist, int);
|
||||
if(width < 0)
|
||||
width = -width, flag |= flag_minus;
|
||||
} else {
|
||||
while((*s >= L'0') && (*s <= L'9'))
|
||||
width = (width * 10) + *s++ - L'0';
|
||||
}
|
||||
/* precision */
|
||||
if(*s == L'.') {
|
||||
++s, precision = 0;
|
||||
if(*s == L'*') {
|
||||
++s, precision = va_arg(vlist, int);
|
||||
if(precision < 0) precision = -1;
|
||||
} else {
|
||||
while((*s >= L'0') && (*s <= L'9'))
|
||||
precision = (precision * 10) + *s++ - L'0';
|
||||
}
|
||||
}
|
||||
/* option */
|
||||
switch(*s) {
|
||||
case L'h':
|
||||
if(*++s != L'h') flag |= flag_h1;
|
||||
else ++s, flag |= flag_h2;
|
||||
break;
|
||||
case L'l':
|
||||
if(*++s != L'l') flag |= flag_l1;
|
||||
else ++s, flag |= flag_l2;
|
||||
break;
|
||||
}
|
||||
|
||||
/* type */
|
||||
switch(*s) {
|
||||
case L'd': /* signed decimal */
|
||||
case L'i': /* signed decimal */
|
||||
goto put_integer;
|
||||
case L'o': /* unsigned octal */
|
||||
radix = 8;
|
||||
flag |= flag_unsigned;
|
||||
goto put_integer;
|
||||
case L'u': /* unsigned decimal */
|
||||
flag |= flag_unsigned;
|
||||
goto put_integer;
|
||||
case L'X': /* unsigned hexadecimal */
|
||||
hex_char = L'A' - 10;
|
||||
goto put_hexadecimal;
|
||||
case L'x': /* unsigned hexadecimal */
|
||||
goto put_hexadecimal;
|
||||
case L'p': /* pointer */
|
||||
/* equal to code warrior */
|
||||
flag |= flag_sharp;
|
||||
precision = 8;
|
||||
goto put_hexadecimal;
|
||||
|
||||
case L'c': /* character */
|
||||
if(precision >= 0)
|
||||
goto put_invalid;
|
||||
{
|
||||
int c = va_arg(vlist, int);
|
||||
width -= 1;
|
||||
if(flag & flag_minus) {
|
||||
string_put_char(&str, (wchar_t)c);
|
||||
string_fill_char(&str, L' ', width);
|
||||
} else {
|
||||
wchar_t pad = (wchar_t)(
|
||||
(flag & flag_zero) ? L'0' : L' ');
|
||||
string_fill_char(&str, pad, width);
|
||||
string_put_char(&str, (wchar_t)c);
|
||||
}
|
||||
++s;
|
||||
}
|
||||
break;
|
||||
|
||||
case L's': /* string */
|
||||
{
|
||||
int n_buf = 0;
|
||||
const wchar_t *p_buf = va_arg(vlist, const wchar_t*);
|
||||
if(precision < 0) {
|
||||
while(p_buf[n_buf])
|
||||
++n_buf;
|
||||
} else {
|
||||
while((n_buf < precision) && p_buf[n_buf])
|
||||
++n_buf;
|
||||
}
|
||||
width -= n_buf;
|
||||
if(flag & flag_minus) {
|
||||
string_put_string(&str, p_buf, n_buf);
|
||||
string_fill_char(&str, L' ', width);
|
||||
} else {
|
||||
wchar_t pad = (wchar_t)(
|
||||
(flag & flag_zero) ? L'0' : L' ');
|
||||
string_fill_char(&str, pad, width);
|
||||
string_put_string(&str, p_buf, n_buf);
|
||||
}
|
||||
++s;
|
||||
}
|
||||
break;
|
||||
|
||||
case L'n': /* store the number of output */
|
||||
{
|
||||
int pos = str.cur - str.base;
|
||||
if(flag & flag_h2)
|
||||
;
|
||||
else if(flag & flag_h1)
|
||||
*va_arg(vlist, signed short*) = (signed short)pos;
|
||||
else if(flag & flag_l2)
|
||||
*va_arg(vlist, u64*) = (u64)pos;
|
||||
else
|
||||
*va_arg(vlist, signed int*) = (signed int)pos;
|
||||
}
|
||||
++s;
|
||||
break;
|
||||
|
||||
case L'%': /* output L'%' */
|
||||
if(p_start + 1 != s)
|
||||
goto put_invalid;
|
||||
string_put_char(&str, *s++);
|
||||
break;
|
||||
|
||||
default: /* invalid type */
|
||||
goto put_invalid;
|
||||
|
||||
put_invalid:
|
||||
string_put_string(&str, p_start, s - p_start);
|
||||
break;
|
||||
|
||||
put_hexadecimal:
|
||||
radix = 16;
|
||||
flag |= flag_unsigned;
|
||||
put_integer:
|
||||
{
|
||||
u64 val = 0;
|
||||
n_prefix = 0;
|
||||
|
||||
if(flag & flag_minus)
|
||||
flag &= ~flag_zero;
|
||||
if(precision < 0) precision = 1;
|
||||
else flag &= ~flag_zero;
|
||||
|
||||
if(flag & flag_unsigned) {
|
||||
if(flag & flag_h2)
|
||||
val = va_arg(vlist, wchar_t);
|
||||
else if(flag & flag_h1)
|
||||
val = va_arg(vlist, unsigned short);
|
||||
else if(flag & flag_l2)
|
||||
val = va_arg(vlist, u64);
|
||||
else
|
||||
val = va_arg(vlist, unsigned long);
|
||||
flag &= ~(flag_plus | flag_blank);
|
||||
if(flag & flag_sharp) {
|
||||
if(radix == 16) {
|
||||
if(val != 0) {
|
||||
prefix[0] = (wchar_t)(hex_char + (10 + L'x' - L'a'));
|
||||
prefix[1] = L'0';
|
||||
n_prefix = 2;
|
||||
}
|
||||
} else if(radix == 8) {
|
||||
prefix[0] = L'0';
|
||||
n_prefix = 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(flag & flag_h2)
|
||||
val = va_arg(vlist, wchar_t);
|
||||
else if(flag & flag_h1)
|
||||
val = va_arg(vlist, short);
|
||||
else if(flag & flag_l2)
|
||||
val = va_arg(vlist, u64);
|
||||
else
|
||||
val = va_arg(vlist, long);
|
||||
if((val >> 32) & 0x80000000) {
|
||||
val = ~val + 1;
|
||||
prefix[0] = L'-';
|
||||
n_prefix = 1;
|
||||
} else {
|
||||
if(val || precision) {
|
||||
if(flag & flag_plus) {
|
||||
prefix[0] = L'+';
|
||||
n_prefix = 1;
|
||||
} else
|
||||
if(flag & flag_blank) {
|
||||
prefix[0] = L' ';
|
||||
n_prefix = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
n_buf = 0;
|
||||
while(val != 0) {
|
||||
int d = (int)(val % radix);
|
||||
val /= radix;
|
||||
buf[n_buf++] = (wchar_t)((d < 10) ?
|
||||
(d + L'0') : (d + hex_char));
|
||||
}
|
||||
if((n_prefix > 0) && (prefix[0] == L'0')) {
|
||||
n_prefix = 0;
|
||||
buf[n_buf++] = L'0';
|
||||
}
|
||||
}
|
||||
goto put_to_stream;
|
||||
|
||||
put_to_stream:
|
||||
{
|
||||
int n_pad = precision - n_buf;
|
||||
if(flag & flag_zero) {
|
||||
if(n_pad < width - n_buf - n_prefix)
|
||||
n_pad = width - n_buf - n_prefix;
|
||||
}
|
||||
if(n_pad > 0) width -= n_pad;
|
||||
width -= n_prefix + n_buf;
|
||||
if(!(flag & flag_minus))
|
||||
string_fill_char(&str, L' ', width);
|
||||
while(n_prefix > 0)
|
||||
string_put_char(&str, prefix[--n_prefix]);
|
||||
string_fill_char(&str, L'0', n_pad);
|
||||
while(n_buf > 0)
|
||||
string_put_char(&str, buf[--n_buf]);
|
||||
if(flag & flag_minus)
|
||||
string_fill_char(&str, L' ', width);
|
||||
++s;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(str.len > 0)
|
||||
*str.cur = '\0';
|
||||
else if(len > 0)
|
||||
str.base[len - 1] = '\0';
|
||||
return str.cur - str.base;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// end of namespace tlib
|
||||
100
build/tests/WirelessChecker/src/util/wprintf.h
Normal file
100
build/tests/WirelessChecker/src/util/wprintf.h
Normal file
@ -0,0 +1,100 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TwlSDK - Nmenu
|
||||
File: WPrintf.h
|
||||
|
||||
Copyright 2007 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Date:: $
|
||||
$Rev$
|
||||
$Author$
|
||||
*---------------------------------------------------------------------------*/
|
||||
#ifndef TLIB_SYSTEM_WPRINTF_H_
|
||||
#define TLIB_SYSTEM_WPRINTF_H_
|
||||
|
||||
|
||||
|
||||
namespace util
|
||||
{
|
||||
|
||||
int VSNWPrintf(wchar_t *dst, size_t len, const wchar_t *fmt, va_list vlist);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: OS_SNPrintf
|
||||
|
||||
Description: equal to 'OS_VSNPrintf' except argument style.
|
||||
|
||||
Arguments: dst : destination buffer.
|
||||
len : destination buffer size.
|
||||
fmt : format string.
|
||||
|
||||
Returns: length of the generated string. (except '\0')
|
||||
if(result < len),
|
||||
put NUL in dst[result].
|
||||
else if(len > 0),
|
||||
put NUL in dst[len - 1].
|
||||
else,
|
||||
do nothing.
|
||||
*---------------------------------------------------------------------------*/
|
||||
inline int
|
||||
SNWPrintf(wchar_t *dst, size_t len, const wchar_t *fmt, ...)
|
||||
{
|
||||
int ret;
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
ret = VSNWPrintf(dst, len, fmt, va);
|
||||
va_end(va);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: OS_VSPrintf
|
||||
|
||||
Description: equal to 'OS_VSNPrintf' except buffer size argument.
|
||||
|
||||
Arguments: dst : destination buffer.
|
||||
fmt : format string.
|
||||
vlist : parameters.
|
||||
|
||||
Returns: length of the generated string.
|
||||
*---------------------------------------------------------------------------*/
|
||||
inline int
|
||||
VSWPrintf(wchar_t *dst, const wchar_t *fmt, va_list vlist)
|
||||
{
|
||||
return VSNWPrintf(dst, 0x7FFFFFFF, fmt, vlist);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: OS_SPrintf
|
||||
|
||||
Description: equal to 'OS_VSPrintf' except argument style.
|
||||
|
||||
Arguments: dst : destination buffer.
|
||||
fmt : format string.
|
||||
|
||||
Returns: length of the generated string.
|
||||
*---------------------------------------------------------------------------*/
|
||||
inline int
|
||||
SWPrintf(wchar_t *dst, const wchar_t *fmt, ...)
|
||||
{
|
||||
int ret;
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
ret = VSWPrintf(dst, fmt, va);
|
||||
va_end(va);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// end of namespace tlib
|
||||
|
||||
|
||||
|
||||
#endif // TLIB_SYSTEM_WPRINTF_H_
|
||||
Loading…
Reference in New Issue
Block a user