diff options
| author | Derek Hensley <hensley.derek58@gmail.com> | 2023-07-31 17:42:21 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-31 20:42:21 -0400 |
| commit | 33ec543467f17900516d93dd4b7964b8f49d1951 (patch) | |
| tree | 426bd326b52d2a609d6f45cdf17a50162cbdc01b /lib | |
| parent | 6d0c9276e8fc93e679d295b4e5f968da4b966a9b (diff) | |
Libultra OK (#20)
* Identify last 2 libultra files
* BSS left
* Update not built files
* libultra OK
* Makefile formating
* Identify last couple data files
* libultra section headers
* Paddings
* Fix one padding
* move non_shared to CLFAGS and ASFLAGS
* git subrepo pull --force lib/ultralib
subrepo:
subdir: "lib/ultralib"
merged: "b376559"
upstream:
origin: "git@github.com:decompals/ultralib.git"
branch: "main"
commit: "b376559"
git-subrepo:
version: "0.4.6"
origin: "https://github.com/ingydotnet/git-subrepo"
commit: "110b9eb"
* Remove duplicate -non_shared
* .hasm
* Jenkins
* GBIDEFINE
Diffstat (limited to 'lib')
359 files changed, 9995 insertions, 5684 deletions
diff --git a/lib/Makefile b/lib/Makefile new file mode 100644 index 0000000..e5670cc --- /dev/null +++ b/lib/Makefile @@ -0,0 +1,137 @@ +MAKEFLAGS += --no-builtin-rules + + +# Set prefix to mips binutils binaries (mips-linux-gnu-ld => 'mips-linux-gnu-') - Change at your own risk! +# In nearly all cases, not having 'mips-linux-gnu-*' binaries on the PATH is indicative of missing dependencies +MIPS_BINUTILS_PREFIX ?= mips-linux-gnu- + +### Output ### + +BUILD_DIR := ../build/lib + + +#### Setup #### + +MAKE = make + +UNAME_S := $(shell uname -s) +ifeq ($(OS),Windows_NT) +$(error Native Windows is currently unsupported for building this repository, use WSL instead c:) +else ifeq ($(UNAME_S),Linux) + DETECTED_OS := linux +else ifeq ($(UNAME_S),Darwin) + DETECTED_OS := macos + MAKE := gmake +endif + +#### Tools #### +ifneq ($(shell type $(MIPS_BINUTILS_PREFIX)ld >/dev/null 2>/dev/null; echo $$?), 0) + $(error Please install or build $(MIPS_BINUTILS_PREFIX)) +endif + +export COMPILER_PATH := ../tools/ido/$(DETECTED_OS)/5.3 +CC := ../tools/ido/$(DETECTED_OS)/5.3/cc + + +IINC := -Iultralib/include -Iultralib/include/ido -Iultralib/include/PR -Iultralib/src + +OPTFLAGS := -O2 +ASOPTFLAGS := -O1 +MIPS_VERSION := -mips2 -32 +CFLAGS := -Wab,-r4300_mul -G 0 -nostdinc -Xcpluscomm -fullwarn -non_shared +ASFLAGS := -Wab,-r4300_mul -G 0 -nostdinc -non_shared +WARNINGS := -woff 516,649,838,712 +COMMON_DEFINES := -D_MIPS_SZLONG=32 +GBI_DEFINES := -DF3DEX_GBI_2 +RELEASE_DEFINES := -DNDEBUG -D_FINALROM + +#### Files #### + +SRC_DIRS := $(shell find ultralib/src -type d \ + -not -path "ultralib/src/audio" \ + -not -path "ultralib/src/error" \ + -not -path "ultralib/src/gio" \ + -not -path "ultralib/src/gt" \ + -not -path "ultralib/src/host" \ + -not -path "ultralib/src/log" \ + -not -path "ultralib/src/rg" \ + -not -path "ultralib/src/rmon" \ + -not -path "ultralib/src/sched" \ + -not -path "ultralib/src/voice") + +C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c)) +S_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.s)) +O_FILES := $(foreach f,$(C_FILES:.c=.o),$(BUILD_DIR)/$f) \ + $(foreach f,$(S_FILES:.s=.o),$(BUILD_DIR)/$f) + +# create build directories +$(shell mkdir -p $(foreach dir,$(SRC_DIRS),$(BUILD_DIR)/$(dir))) + +$(BUILD_DIR)/ultralib/src/debug/%.o: OPTFLAGS := -O1 +$(BUILD_DIR)/ultralib/src/host/%.o: OPTFLAGS := -O1 +$(BUILD_DIR)/ultralib/src/os/%.o: OPTFLAGS := -O1 +$(BUILD_DIR)/ultralib/src/rmon/%.o: OPTFLAGS := -O1 +$(BUILD_DIR)/ultralib/src/libc/ll.o: OPTFLAGS := -O1 +$(BUILD_DIR)/ultralib/src/libc/llbit.o: OPTFLAGS := -O1 +$(BUILD_DIR)/ultralib/src/libc/llcvt.o: OPTFLAGS := -O1 +$(BUILD_DIR)/ultralib/src/log/%.o: OPTFLAGS := -O1 + +$(BUILD_DIR)/ultralib/src/libc/%.o: ASOPTFLAGS := -O2 +$(BUILD_DIR)/ultralib/src/mgu/%.o: ASOPTFLAGS := -O2 + +$(BUILD_DIR)/ultralib/src/libc/ll.o: MIPS_VERSION := -mips3 -32 +$(BUILD_DIR)/ultralib/src/libc/llbit.o: MIPS_VERSION := -mips3 -32 +$(BUILD_DIR)/ultralib/src/libc/llcvt.o: MIPS_VERSION := -mips3 -32 +$(BUILD_DIR)/ultralib/src/os/exceptasm.o: MIPS_VERSION := -mips3 -32 + +$(BUILD_DIR)/src/gu/parse_gbi.marker: GBIDEFINE := -DF3D_GBI +$(BUILD_DIR)/src/gu/us2dex_emu.marker: GBIDEFINE := +$(BUILD_DIR)/src/gu/us2dex2_emu.marker: GBIDEFINE := +$(BUILD_DIR)/src/sp/sprite.marker: GBIDEFINE := -DF3D_GBI +$(BUILD_DIR)/src/sp/spriteex.marker: GBIDEFINE := +$(BUILD_DIR)/src/sp/spriteex2.marker: GBIDEFINE := + +#### Main Targets ### + +all: $(O_FILES) + +clean: + $(RM) -r $(BUILD_DIR) + +distclean: clean + +.PHONY: all clean distclean +.DEFAULT_GOAL := all +# Prevent removing intermediate files +.SECONDARY: + +$(BUILD_DIR)/%.o: %.s + $(CC) -c $(ASFLAGS) $(IINC) -I $(dir $*) $(WARNINGS) $(MIPS_VERSION) $(COMMON_DEFINES) $(RELEASE_DEFINES) $(GBI_DEFINES) $(ASOPTFLAGS) -o $@ $< + $(MIPS_BINUTILS_PREFIX)objcopy --remove-section .mdebug $(@:.marker=.o) + +$(BUILD_DIR)/%.o: %.c + $(CC) -c $(CFLAGS) $(IINC) -I $(dir $*) $(WARNINGS) $(MIPS_VERSION) $(COMMON_DEFINES) $(RELEASE_DEFINES) $(GBI_DEFINES) $(OPTFLAGS) -o $@ $< + $(MIPS_BINUTILS_PREFIX)objcopy --remove-section .mdebug $(@:.marker=.o) + +$(BUILD_DIR)/ultralib/src/libc/ll.o: ultralib/src/libc/ll.c + $(CC) -c $(CFLAGS) $(IINC) -I $(dir $*) $(WARNINGS) $(MIPS_VERSION) $(COMMON_DEFINES) $(RELEASE_DEFINES) $(GBI_DEFINES) $(OPTFLAGS) -o $@ $< + python3 ../tools/set_o32abi_bit.py $@ + $(MIPS_BINUTILS_PREFIX)objcopy --remove-section .mdebug $(@:.marker=.o) + +$(BUILD_DIR)/ultralib/src/libc/llbit.o: ultralib/src/libc/llbit.c + $(CC) -c $(CFLAGS) $(IINC) -I $(dir $*) $(WARNINGS) $(MIPS_VERSION) $(COMMON_DEFINES) $(RELEASE_DEFINES) $(GBI_DEFINES) $(OPTFLAGS) -o $@ $< + python3 ../tools/set_o32abi_bit.py $@ + $(MIPS_BINUTILS_PREFIX)objcopy --remove-section .mdebug $(@:.marker=.o) + +$(BUILD_DIR)/ultralib/src/libc/llcvt.o: ultralib/src/libc/llcvt.c + $(CC) -c $(CFLAGS) $(IINC) -I $(dir $*) $(WARNINGS) $(MIPS_VERSION) $(COMMON_DEFINES) $(RELEASE_DEFINES) $(GBI_DEFINES) $(OPTFLAGS) -o $@ $< + python3 ../tools/set_o32abi_bit.py $@ + $(MIPS_BINUTILS_PREFIX)objcopy --remove-section .mdebug $(@:.marker=.o) + +$(BUILD_DIR)/ultralib/src/os/exceptasm.o: ultralib/src/os/exceptasm.s + $(CC) -c $(ASFLAGS) $(IINC) -I $(dir $*) $(WARNINGS) $(MIPS_VERSION) $(COMMON_DEFINES) $(RELEASE_DEFINES) $(GBI_DEFINES) $(ASOPTFLAGS) -o $@ $< + python3 ../tools/set_o32abi_bit.py $@ + $(MIPS_BINUTILS_PREFIX)objcopy --remove-section .mdebug $(@:.marker=.o) + +# Print target for debugging +print-% : ; $(info $* is a $(flavor $*) variable set to [$($*)]) @true diff --git a/lib/ultralib/.github/workflows/ci_egcs.txt b/lib/ultralib/.github/workflows/ci_egcs.txt index f903a0a..b6d8fe7 100644 --- a/lib/ultralib/.github/workflows/ci_egcs.txt +++ b/lib/ultralib/.github/workflows/ci_egcs.txt @@ -15,10 +15,10 @@ jobs: fail-fast: false matrix: version: [ique_v1.5] - suffix: [_rom] # [, _d, _rom] + suffix: [_rom] # [~, _d, _rom] steps: - - name: Checkout reposistory + - name: Checkout repository uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.head.sha }} diff --git a/lib/ultralib/.github/workflows/ci_gcc.yml b/lib/ultralib/.github/workflows/ci_gcc.yml index 1ea1413..054270a 100644 --- a/lib/ultralib/.github/workflows/ci_gcc.yml +++ b/lib/ultralib/.github/workflows/ci_gcc.yml @@ -14,10 +14,10 @@ jobs: fail-fast: false matrix: version: [L] # [H, I, I_patch, J, K, L] - suffix: [_rom] # [, _d, _rom] + suffix: [~, _d, _rom] steps: - - name: Checkout reposistory + - name: Checkout repository uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.head.sha }} diff --git a/lib/ultralib/.github/workflows/ci_ido.txt b/lib/ultralib/.github/workflows/ci_ido.yml index 36896a9..4d7f8dc 100644 --- a/lib/ultralib/.github/workflows/ci_ido.txt +++ b/lib/ultralib/.github/workflows/ci_ido.yml @@ -1,5 +1,4 @@ # CI file for IDO builds -# TODO: rename to `ci_ido.yml` when the repo has IDO support name: Build IDO libultra @@ -15,16 +14,16 @@ jobs: fail-fast: false matrix: version: [L] # [E, F, G, H, I, I_patch, J, K, L] - suffix: [_rom] # [, _d, _rom] + suffix: [~, _rom] # [~, _d, _rom] steps: - - name: Checkout reposistory + - name: Checkout repository uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.head.sha }} - name: Install package requirements - run: sudo apt-get install -y build-essential python3 + run: sudo apt-get install -y build-essential python3 binutils-mips-linux-gnu - name: Get extra dependencies uses: actions/checkout@v3 diff --git a/lib/ultralib/.gitignore b/lib/ultralib/.gitignore index 669011d..d4c09ae 100644 --- a/lib/ultralib/.gitignore +++ b/lib/ultralib/.gitignore @@ -17,6 +17,7 @@ build/ expected/ notes/ tools/gcc +tools/ido *.elf *.o *.a diff --git a/lib/ultralib/.gitrepo b/lib/ultralib/.gitrepo index 8f49f28..6ec8337 100644 --- a/lib/ultralib/.gitrepo +++ b/lib/ultralib/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = git@github.com:decompals/ultralib.git branch = main - commit = d03b2a3afbec0baabc2263b8e9087f50d22ef85c - parent = cbdbee54db4b971b070d3c78ec1361849150040d + commit = b3765592967e61da705d6ee5553b0baead4361a5 + parent = f0428d490c5cb995719b291d4c960f54cae64638 method = merge - cmdver = 0.4.3 + cmdver = 0.4.6 diff --git a/lib/ultralib/Makefile b/lib/ultralib/Makefile index 3700641..cf87da4 100644 --- a/lib/ultralib/Makefile +++ b/lib/ultralib/Makefile @@ -1,32 +1,38 @@ NON_MATCHING ?= 0 -TARGET := libgultra_rom +# One of: +# libgultra_rom, libgultra_d, libgultra +# libultra_rom, libultra_d, libultra +TARGET ?= libgultra_rom +CROSS ?= mips-linux-gnu- + BASE_DIR := base_$(TARGET) BASE_AR := $(TARGET).a -BUILD_DIR := build +BUILD_ROOT := build +BUILD_DIR := $(BUILD_ROOT)/$(TARGET) BUILD_AR := $(BUILD_DIR)/$(TARGET).a WORKING_DIR := $(shell pwd) CPP := cpp -P AR := ar -AS := tools/gcc/as -CC := tools/gcc/gcc -AR_OLD := tools/gcc/ar - -export COMPILER_PATH := $(WORKING_DIR)/tools/gcc -CFLAGS := -w -nostdinc -c -G 0 -mgp32 -mfp32 -mips3 -D_LANGUAGE_C -ASFLAGS := -w -nostdinc -c -G 0 -mgp32 -mfp32 -mips3 -DMIPSEB -D_LANGUAGE_ASSEMBLY -D_MIPS_SIM=1 -D_ULTRA64 -x assembler-with-cpp -GBIDEFINE := -DF3DEX_GBI_2 -CPPFLAGS = -D_MIPS_SZLONG=32 -D__USE_ISOC99 -I $(WORKING_DIR)/include -I $(WORKING_DIR)/include/gcc -I $(WORKING_DIR)/include/PR $(GBIDEFINE) +ifeq ($(findstring libgultra,$(TARGET)),libgultra) +-include Makefile.gcc +else ifeq ($(findstring libultra,$(TARGET)),libultra) +-include Makefile.ido +else +$(error Invalid Target) +endif ifeq ($(findstring _d,$(TARGET)),_d) CPPFLAGS += -D_DEBUG -OPTFLAGS := -O0 else -CPPFLAGS += -DNDEBUG -D_FINALROM -OPTFLAGS := -O3 +CPPFLAGS += -DNDEBUG +endif + +ifeq ($(findstring _rom,$(TARGET)),_rom) +CPPFLAGS += -D_FINALROM endif SRC_DIRS := $(shell find src -type d) @@ -43,6 +49,11 @@ MARKER_FILES := $(O_FILES:.o=.marker) ifneq ($(NON_MATCHING),1) COMPARE_OBJ = cmp $(BASE_DIR)/$(@F:.marker=.o) $(@:.marker=.o) && echo "$(@:.marker=.o): OK" COMPARE_AR = cmp $(BASE_AR) $@ && echo "$@: OK" +ifeq ($(COMPILER),ido) +COMPARE_OBJ = $(CROSS)objcopy -p --strip-debug $(WORKING_DIR)/$(@:.marker=.o) $(WORKING_DIR)/$(@:.marker=.cmp.o) && \ + cmp $(BASE_DIR)/.cmp/$(@F:.marker=.cmp.o) $(WORKING_DIR)/$(@:.marker=.cmp.o) && echo "$(@:.marker=.o): OK" +COMPARE_AR = echo "$@: Cannot compare archive currently" +endif else COMPARE_OBJ := COMPARE_AR := @@ -51,7 +62,7 @@ endif BASE_OBJS := $(wildcard $(BASE_DIR)/*.o) # Try to find a file corresponding to an archive file in any of src/ asm/ or the base directory, prioritizing src then asm then the original file -AR_ORDER = $(foreach f,$(shell $(AR) t $(BASE_AR)),$(shell find $(BUILD_DIR)/src $(BUILD_DIR)/asm $(BUILD_DIR)/$(BASE_DIR) -name $f -type f -print -quit)) +AR_ORDER = $(foreach f,$(shell $(AR) t $(BASE_AR)),$(shell find $(BUILD_DIR)/src $(BUILD_DIR)/asm $(BUILD_DIR)/$(BASE_DIR) -iname $f -type f -print -quit)) MATCHED_OBJS = $(filter-out $(BUILD_DIR)/$(BASE_DIR)/%,$(AR_ORDER)) UNMATCHED_OBJS = $(filter-out $(MATCHED_OBJS),$(AR_ORDER)) NUM_OBJS = $(words $(AR_ORDER)) @@ -68,13 +79,13 @@ $(BUILD_AR): $(MARKER_FILES) ifneq ($(NON_MATCHING),1) # patch archive creation time and individual files' ownership & permissions dd bs=1 skip=24 seek=24 count=12 conv=notrunc if=$(BASE_AR) of=$@ status=none - python3 tools/patch_ar_meta.py $@ + python3 tools/patch_ar_meta.py $@ $(BASE_AR) $(PATCH_AR_FLAGS) @$(COMPARE_AR) @echo "Matched: $(NUM_OBJS_MATCHED)/$(NUM_OBJS)" endif clean: - $(RM) -rf $(BUILD_DIR) + $(RM) -rf $(BUILD_ROOT) distclean: clean $(MAKE) -C tools distclean @@ -84,73 +95,71 @@ setup: $(MAKE) -C tools cd $(BASE_DIR) && $(AR) xo ../$(BASE_AR) chmod -R +rw $(BASE_DIR) - -# KMC gcc has a custom flag, N64ALIGN, which forces 8 byte alignment on arrays. This can be used to match, but -# an explicit aligned(8) attribute can be used instead. We opted for the latter for better compatibilty with -# other versions of GCC that do not have this flag. -# export N64ALIGN := ON -export VR4300MUL := ON +ifeq ($(COMPILER),ido) + export CROSS=$(CROSS) && ./tools/strip_debug.sh $(BASE_DIR) +endif $(BUILD_DIR)/$(BASE_DIR)/%.marker: $(BASE_DIR)/%.o cp $< $(@:.marker=.o) ifneq ($(NON_MATCHING),1) -# @$(COMPARE_OBJ) # change file timestamps to match original @touch -r $(BASE_DIR)/$(@F:.marker=.o) $(@:.marker=.o) @$(COMPARE_OBJ) @touch $@ endif -ifeq ($(findstring _d,$(TARGET)),_d) -$(BUILD_DIR)/src/rmon/%.marker: OPTFLAGS := -O0 -endif +GBIDEFINE := -DF3DEX_GBI_2 -STRIP = - -$(BUILD_DIR)/src/os/initialize_isv.marker: OPTFLAGS := -O2 -$(BUILD_DIR)/src/os/initialize_isv.marker: STRIP = && tools/gcc/strip-2.7 -N initialize_isv.c $(WORKING_DIR)/$(@:.marker=.o) $(WORKING_DIR)/$(@:.marker=.o) -$(BUILD_DIR)/src/os/assert.marker: OPTFLAGS := -O0 -$(BUILD_DIR)/src/os/ackramromread.marker: OPTFLAGS := -O0 -$(BUILD_DIR)/src/os/ackramromwrite.marker: OPTFLAGS := -O0 -$(BUILD_DIR)/src/os/exit.marker: OPTFLAGS := -O0 -$(BUILD_DIR)/src/os/seterrorhandler.marker: OPTFLAGS := -O0 -$(BUILD_DIR)/src/gu/us2dex_emu.marker: GBIDEFINE := -DF3DEX_GBI -$(BUILD_DIR)/src/sp/sprite.marker: GBIDEFINE := -$(BUILD_DIR)/src/sp/spriteex.marker: GBIDEFINE := -$(BUILD_DIR)/src/sp/spriteex2.marker: GBIDEFINE := -$(BUILD_DIR)/src/sp/spriteex2.marker: GBIDEFINE := -$(BUILD_DIR)/src/mgu/%.marker: export VR4300MUL := OFF -$(BUILD_DIR)/src/mgu/rotate.marker: export VR4300MUL := ON -$(BUILD_DIR)/src/os/%.marker: ASFLAGS += -P -$(BUILD_DIR)/src/gu/%.marker: ASFLAGS += -P -$(BUILD_DIR)/src/libc/%.marker: ASFLAGS += -P -$(BUILD_DIR)/src/rmon/%.marker: ASFLAGS += -P +$(BUILD_DIR)/src/gu/parse_gbi.marker: GBIDEFINE := -DF3D_GBI +$(BUILD_DIR)/src/gu/us2dex_emu.marker: GBIDEFINE := +$(BUILD_DIR)/src/gu/us2dex2_emu.marker: GBIDEFINE := +$(BUILD_DIR)/src/sp/sprite.marker: GBIDEFINE := -DF3D_GBI +$(BUILD_DIR)/src/sp/spriteex.marker: GBIDEFINE := +$(BUILD_DIR)/src/sp/spriteex2.marker: GBIDEFINE := $(BUILD_DIR)/src/voice/%.marker: OPTFLAGS += -DLANG_JAPANESE -I$(WORKING_DIR)/src -I$(WORKING_DIR)/src/voice -$(BUILD_DIR)/src/voice/%.marker: CC := tools/compile_sjis.py -D__CC=$(WORKING_DIR)/$(CC) +$(BUILD_DIR)/src/voice/%.marker: CC := tools/compile_sjis.py -D__CC=$(WORKING_DIR)/$(CC) -D__BUILD_DIR=$(BUILD_DIR) $(BUILD_DIR)/%.marker: %.c - cd $(<D) && $(WORKING_DIR)/$(CC) $(CFLAGS) $(CPPFLAGS) $(OPTFLAGS) $(<F) -o $(WORKING_DIR)/$(@:.marker=.o) + cd $(<D) && $(WORKING_DIR)/$(CC) $(CFLAGS) $(MIPS_VERSION) $(CPPFLAGS) $(OPTFLAGS) $(<F) $(IINC) -o $(WORKING_DIR)/$(@:.marker=.o) ifneq ($(NON_MATCHING),1) # check if this file is in the archive; patch corrupted bytes and change file timestamps to match original if so - $(if $(findstring $(BASE_DIR)/$(@F:.marker=.o), $(BASE_OBJS)), \ + @$(if $(findstring $(BASE_DIR)/$(@F:.marker=.o), $(BASE_OBJS)), \ python3 tools/fix_objfile.py $(@:.marker=.o) $(BASE_DIR)/$(@F:.marker=.o) $(STRIP) && \ $(COMPARE_OBJ) && \ touch -r $(BASE_DIR)/$(@F:.marker=.o) $(@:.marker=.o), \ - echo "Object file $(<F:.marker=.o) is not in the current archive" \ + echo "Object file $(@F:.marker=.o) is not in the current archive" \ ) # create or update the marker file @touch $@ endif $(BUILD_DIR)/%.marker: %.s - cd $(<D) && $(WORKING_DIR)/$(CC) $(ASFLAGS) $(CPPFLAGS) -I. $(OPTFLAGS) $(<F) -o $(WORKING_DIR)/$(@:.marker=.o) + cd $(<D) && $(WORKING_DIR)/$(CC) $(ASFLAGS) $(MIPS_VERSION) $(CPPFLAGS) $(ASOPTFLAGS) $(<F) $(IINC) -o $(WORKING_DIR)/$(@:.marker=.o) +ifneq ($(NON_MATCHING),1) +# check if this file is in the archive; patch corrupted bytes and change file timestamps to match original if so + @$(if $(findstring $(BASE_DIR)/$(@F:.marker=.o), $(BASE_OBJS)), \ + python3 tools/fix_objfile.py $(@:.marker=.o) $(BASE_DIR)/$(@F:.marker=.o) $(STRIP) && \ + $(COMPARE_OBJ) && \ + touch -r $(BASE_DIR)/$(@F:.marker=.o) $(@:.marker=.o), \ + echo "Object file $(@F:.marker=.o) is not in the current archive" \ + ) +# create or update the marker file + @touch $@ +endif + +# Rule for building files that require specific file paths in the mdebug section +$(MDEBUG_FILES): $(BUILD_DIR)/src/%.marker: src/%.s + cp $(<:.marker=.s) $(dir $@) + mkdir -p $(@:.marker=) + export USR_INCLUDE=$(WORKING_DIR)/include && cd $(@:.marker=) && $(WORKING_DIR)/$(CC) $(ASFLAGS) $(CPPFLAGS) ../$(<F) -I/usr/include -o $(notdir $(<:.s=.o)) + mv $(@:.marker=)/$(<F:.s=.o) $(@:.marker=)/.. ifneq ($(NON_MATCHING),1) # check if this file is in the archive; patch corrupted bytes and change file timestamps to match original if so @$(if $(findstring $(BASE_DIR)/$(@F:.marker=.o), $(BASE_OBJS)), \ python3 tools/fix_objfile.py $(@:.marker=.o) $(BASE_DIR)/$(@F:.marker=.o) && \ $(COMPARE_OBJ) && \ touch -r $(BASE_DIR)/$(@F:.marker=.o) $(@:.marker=.o), \ - echo "Object file $(<F:.marker=.o) is not in the current archive" \ + echo "Object file $(@F:.marker=.o) is not in the current archive" \ ) # create or update the marker file @touch $@ diff --git a/lib/ultralib/Makefile.gcc b/lib/ultralib/Makefile.gcc new file mode 100644 index 0000000..dce908b --- /dev/null +++ b/lib/ultralib/Makefile.gcc @@ -0,0 +1,50 @@ +COMPILER := gcc +AS := tools/gcc/as +CC := tools/gcc/gcc +AR_OLD := tools/gcc/ar +PATCH_AR_FLAGS := 0 0 37777700 +STRIP = + +export COMPILER_PATH := $(WORKING_DIR)/tools/gcc + +CFLAGS := -w -nostdinc -c -G 0 -mgp32 -mfp32 -D_LANGUAGE_C +ASFLAGS := -w -nostdinc -c -G 0 -mgp32 -mfp32 -DMIPSEB -D_LANGUAGE_ASSEMBLY -D_MIPS_SIM=1 -D_ULTRA64 -x assembler-with-cpp +CPPFLAGS = -D_MIPS_SZLONG=32 -D__USE_ISOC99 $(GBIDEFINE) +IINC = -I . -I $(WORKING_DIR)/include -I $(WORKING_DIR)/include/gcc -I $(WORKING_DIR)/include/PR +MIPS_VERSION := -mips3 +ASOPTFLAGS := + +ifeq ($(findstring _d,$(TARGET)),_d) +OPTFLAGS := -O0 +else +OPTFLAGS := -O3 +endif + +ifeq ($(findstring _d,$(TARGET)),_d) +$(BUILD_DIR)/src/rmon/%.marker: OPTFLAGS := -O0 +endif + +# KMC gcc has a custom flag, N64ALIGN, which forces 8 byte alignment on arrays. This can be used to match, but +# an explicit aligned(8) attribute can be used instead. We opted for the latter for better compatibilty with +# other versions of GCC that do not have this flag. +# export N64ALIGN := ON +export VR4300MUL := ON + +$(BUILD_DIR)/src/os/initialize_isv.marker: OPTFLAGS := -O2 +$(BUILD_DIR)/src/os/initialize_isv.marker: STRIP = && tools/gcc/strip-2.7 -N initialize_isv.c $(WORKING_DIR)/$(@:.marker=.o) +$(BUILD_DIR)/src/os/assert.marker: OPTFLAGS := -O0 +$(BUILD_DIR)/src/os/seterrorhandler.marker: OPTFLAGS := -O0 +$(BUILD_DIR)/src/mgu/%.marker: export VR4300MUL := OFF +$(BUILD_DIR)/src/mgu/rotate.marker: export VR4300MUL := ON +$(BUILD_DIR)/src/debug/%.marker: ASFLAGS += -P +$(BUILD_DIR)/src/error/%.marker: ASFLAGS += -P +$(BUILD_DIR)/src/log/%.marker: ASFLAGS += -P +$(BUILD_DIR)/src/os/%.marker: ASFLAGS += -P +$(BUILD_DIR)/src/gu/%.marker: ASFLAGS += -P +$(BUILD_DIR)/src/libc/%.marker: ASFLAGS += -P +$(BUILD_DIR)/src/rmon/%.marker: ASFLAGS += -P +$(BUILD_DIR)/src/host/host_ptn64.marker: CFLAGS += -fno-builtin # Probably a better way to solve this + +MDEBUG_FILES := $(BUILD_DIR)/src/monutil.marker +$(BUILD_DIR)/src/monutil.marker: CC := tools/ido/cc +$(BUILD_DIR)/src/monutil.marker: ASFLAGS := -non_shared -mips2 -fullwarn -verbose -Xcpluscomm -G 0 -woff 516,649,838,712 -Wab,-r4300_mul -nostdinc -o32 -c diff --git a/lib/ultralib/Makefile.ido b/lib/ultralib/Makefile.ido new file mode 100644 index 0000000..54c8ff7 --- /dev/null +++ b/lib/ultralib/Makefile.ido @@ -0,0 +1,45 @@ +COMPILER := ido +AS := tools/ido/cc +CC := tools/ido/cc +AR_OLD := tools/ar.py +PATCH_AR_FLAGS := 40001 110 100644 +STRIP = + +export COMPILER_PATH := $(WORKING_DIR)/tools/ido + +CFLAGS := -c -Wab,-r4300_mul -G 0 -nostdinc -Xcpluscomm -fullwarn -woff 516,649,838,712 +ASFLAGS := -c -Wab,-r4300_mul -G 0 -nostdinc -woff 516,649,838,712 +CPPFLAGS = -D_MIPS_SZLONG=32 $(GBIDEFINE) $(PICFLAGS) +IINC = -I $(WORKING_DIR)/include -I $(WORKING_DIR)/include/ido -I $(WORKING_DIR)/include/PR +MIPS_VERSION := -mips2 -o32 +PICFLAGS := -non_shared + +ifeq ($(findstring _d,$(TARGET)),_d) +OPTFLAGS := -O1 -g2 +ASOPTFLAGS := -O0 -g2 +else +OPTFLAGS := -O2 +ASOPTFLAGS := -O1 +endif + +ifneq ($(findstring _d,$(TARGET)),_d) +$(BUILD_DIR)/src/debug/%.marker: OPTFLAGS := -O1 +$(BUILD_DIR)/src/host/%.marker: OPTFLAGS := -O1 +$(BUILD_DIR)/src/os/%.marker: OPTFLAGS := -O1 +$(BUILD_DIR)/src/rmon/%.marker: OPTFLAGS := -O1 +$(BUILD_DIR)/src/libc/ll.marker: OPTFLAGS := -O1 +$(BUILD_DIR)/src/libc/llbit.marker: OPTFLAGS := -O1 +$(BUILD_DIR)/src/libc/llcvt.marker: OPTFLAGS := -O1 +$(BUILD_DIR)/src/log/%.marker: OPTFLAGS := -O1 + +$(BUILD_DIR)/src/libc/%.marker: ASOPTFLAGS := -O2 +$(BUILD_DIR)/src/mgu/%.marker: ASOPTFLAGS := -O2 +endif + +$(BUILD_DIR)/src/os/initialize_isv.marker: OPTFLAGS := -O2 +$(BUILD_DIR)/src/libc/ll.marker: MIPS_VERSION := -mips3 -32 +$(BUILD_DIR)/src/libc/llbit.marker: MIPS_VERSION := -mips3 -32 +$(BUILD_DIR)/src/libc/llcvt.marker: MIPS_VERSION := -mips3 -32 +$(BUILD_DIR)/src/os/exceptasm.marker: MIPS_VERSION := -mips3 -32 +$(BUILD_DIR)/src/log/delay.marker: MIPS_VERSION := -mips1 -o32 +$(BUILD_DIR)/src/log/delay.marker: PICFLAGS := -KPIC diff --git a/lib/ultralib/README.md b/lib/ultralib/README.md index 8e33dc0..ce88d5c 100644 --- a/lib/ultralib/README.md +++ b/lib/ultralib/README.md @@ -16,7 +16,7 @@ Currently this repo supports building the following versions: | 2.0I_patch | :x: / :x: | :x: / :x: | :x: / :x: | | 2.0J | :x: / :x: | :x: / :x: | :x: / :x: | | 2.0K | :x: / :x: | :x: / :x: | :x: / :x: | -| 2.0L | :x: / :x: | :x: / :x: | :x: / :heavy_check_mark: | +| 2.0L | :heavy_check_mark: / :heavy_check_mark: | :x: / :heavy_check_mark: | :heavy_check_mark: / :heavy_check_mark: | | ique_v1.5 | :x: | :x: | :x: | ## Preparation @@ -29,6 +29,7 @@ The build process requires the following packages: - build-essential - python3 +- binutils-mips-linux-gnu (libultra* only) Under Debian / Ubunutu you can install them with the following commands: @@ -37,6 +38,12 @@ sudo apt update sudo apt install build-essential python3 ``` +If building any libultra you can install binutils-mips-linux-gnu with: + +```bash +sudo apt install binutils-mips-linux-gnu +``` + ## Building - `make setup` diff --git a/lib/ultralib/include/PR/R4300.h b/lib/ultralib/include/PR/R4300.h index 8bd562b..fd70d07 100644 --- a/lib/ultralib/include/PR/R4300.h +++ b/lib/ultralib/include/PR/R4300.h @@ -1,453 +1,453 @@ -/**************************************************************************
- * *
- * Copyright (C) 1995, Silicon Graphics, Inc. *
- * *
- * These coded instructions, statements, and computer programs contain *
- * unpublished proprietary information of Silicon Graphics, Inc., 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 Silicon Graphics, Inc. *
- * *
- **************************************************************************/
-
-/**************************************************************************
- *
- * $Revision: 1.13 $
- * $Date: 1997/02/11 08:15:34 $
- * $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/R4300.h,v $
- *
- **************************************************************************/
-
-#ifndef __R4300_H__
-#define __R4300_H__
-
-#include <PR/ultratypes.h>
-
-/*
- * Segment base addresses and sizes
- */
-#define KUBASE 0
-#define KUSIZE 0x80000000
-#define K0BASE 0x80000000
-#define K0SIZE 0x20000000
-#define K1BASE 0xA0000000
-#define K1SIZE 0x20000000
-#define K2BASE 0xC0000000
-#define K2SIZE 0x20000000
-
-/*
- * Exception vectors
- */
-#define SIZE_EXCVEC 0x80 /* Size of an exc. vec */
-#define UT_VEC K0BASE /* utlbmiss vector */
-#define R_VEC (K1BASE+0x1fc00000) /* reset vector */
-#define XUT_VEC (K0BASE+0x80) /* extended address tlbmiss */
-#define ECC_VEC (K0BASE+0x100) /* Ecc exception vector */
-#define E_VEC (K0BASE+0x180) /* Gen. exception vector */
-
-/*
- * Address conversion macros
- */
-#ifdef _LANGUAGE_ASSEMBLY
-
-#define K0_TO_K1(x) ((x)|0xA0000000) /* kseg0 to kseg1 */
-#define K1_TO_K0(x) ((x)&0x9FFFFFFF) /* kseg1 to kseg0 */
-#define K0_TO_PHYS(x) ((x)&0x1FFFFFFF) /* kseg0 to physical */
-#define K1_TO_PHYS(x) ((x)&0x1FFFFFFF) /* kseg1 to physical */
-#define KDM_TO_PHYS(x) ((x)&0x1FFFFFFF) /* direct mapped to physical */
-#define PHYS_TO_K0(x) ((x)|0x80000000) /* physical to kseg0 */
-#define PHYS_TO_K1(x) ((x)|0xA0000000) /* physical to kseg1 */
-
-#else /* _LANGUAGE_C */
-
-#define K0_TO_K1(x) ((u32)(x)|0xA0000000) /* kseg0 to kseg1 */
-#define K1_TO_K0(x) ((u32)(x)&0x9FFFFFFF) /* kseg1 to kseg0 */
-#define K0_TO_PHYS(x) ((u32)(x)&0x1FFFFFFF) /* kseg0 to physical */
-#define K1_TO_PHYS(x) ((u32)(x)&0x1FFFFFFF) /* kseg1 to physical */
-#define KDM_TO_PHYS(x) ((u32)(x)&0x1FFFFFFF) /* direct mapped to physical */
-#define PHYS_TO_K0(x) ((u32)(x)|0x80000000) /* physical to kseg0 */
-#define PHYS_TO_K1(x) ((u32)(x)|0xA0000000) /* physical to kseg1 */
-
-#endif /* _LANGUAGE_ASSEMBLY */
-
-/*
- * Address predicates
- */
-#define IS_KSEG0(x) ((u32)(x) >= K0BASE && (u32)(x) < K1BASE)
-#define IS_KSEG1(x) ((u32)(x) >= K1BASE && (u32)(x) < K2BASE)
-#define IS_KSEGDM(x) ((u32)(x) >= K0BASE && (u32)(x) < K2BASE)
-#define IS_KSEG2(x) ((u32)(x) >= K2BASE && (u32)(x) < KPTE_SHDUBASE)
-#define IS_KPTESEG(x) ((u32)(x) >= KPTE_SHDUBASE)
-#define IS_KUSEG(x) ((u32)(x) < K0BASE)
-
-/*
- * TLB size constants
- */
-
-#define NTLBENTRIES 31 /* entry 31 is reserved by rdb */
-
-#define TLBHI_VPN2MASK 0xffffe000
-#define TLBHI_VPN2SHIFT 13
-#define TLBHI_PIDMASK 0xff
-#define TLBHI_PIDSHIFT 0
-#define TLBHI_NPID 255 /* 255 to fit in 8 bits */
-
-#define TLBLO_PFNMASK 0x3fffffc0
-#define TLBLO_PFNSHIFT 6
-#define TLBLO_CACHMASK 0x38 /* cache coherency algorithm */
-#define TLBLO_CACHSHIFT 3
-#define TLBLO_UNCACHED 0x10 /* not cached */
-#define TLBLO_NONCOHRNT 0x18 /* Cacheable non-coherent */
-#define TLBLO_EXLWR 0x28 /* Exclusive write */
-#define TLBLO_D 0x4 /* writeable */
-#define TLBLO_V 0x2 /* valid bit */
-#define TLBLO_G 0x1 /* global access bit */
-
-#define TLBINX_PROBE 0x80000000
-#define TLBINX_INXMASK 0x3f
-#define TLBINX_INXSHIFT 0
-
-#define TLBRAND_RANDMASK 0x3f
-#define TLBRAND_RANDSHIFT 0
-
-#define TLBWIRED_WIREDMASK 0x3f
-
-#define TLBCTXT_BASEMASK 0xff800000
-#define TLBCTXT_BASESHIFT 23
-#define TLBCTXT_BASEBITS 9
-
-#define TLBCTXT_VPNMASK 0x7ffff0
-#define TLBCTXT_VPNSHIFT 4
-
-#define TLBPGMASK_4K 0x0
-#define TLBPGMASK_16K 0x6000
-#define TLBPGMASK_64K 0x1e000
-
-/*
- * Status register
- */
-#define SR_CUMASK 0xf0000000 /* coproc usable bits */
-
-#define SR_CU3 0x80000000 /* Coprocessor 3 usable */
-#define SR_CU2 0x40000000 /* Coprocessor 2 usable */
-#define SR_CU1 0x20000000 /* Coprocessor 1 usable */
-#define SR_CU0 0x10000000 /* Coprocessor 0 usable */
-#define SR_RP 0x08000000 /* Reduced power (quarter speed) */
-#define SR_FR 0x04000000 /* MIPS III FP register mode */
-#define SR_RE 0x02000000 /* Reverse endian */
-#define SR_ITS 0x01000000 /* Instruction trace support */
-#define SR_BEV 0x00400000 /* Use boot exception vectors */
-#define SR_TS 0x00200000 /* TLB shutdown */
-#define SR_SR 0x00100000 /* Soft reset occured */
-#define SR_CH 0x00040000 /* Cache hit for last 'cache' op */
-#define SR_CE 0x00020000 /* Create ECC */
-#define SR_DE 0x00010000 /* ECC of parity does not cause error */
-
-/*
- * Interrupt enable bits
- * (NOTE: bits set to 1 enable the corresponding level interrupt)
- */
-#define SR_IMASK 0x0000ff00 /* Interrupt mask */
-#define SR_IMASK8 0x00000000 /* mask level 8 */
-#define SR_IMASK7 0x00008000 /* mask level 7 */
-#define SR_IMASK6 0x0000c000 /* mask level 6 */
-#define SR_IMASK5 0x0000e000 /* mask level 5 */
-#define SR_IMASK4 0x0000f000 /* mask level 4 */
-#define SR_IMASK3 0x0000f800 /* mask level 3 */
-#define SR_IMASK2 0x0000fc00 /* mask level 2 */
-#define SR_IMASK1 0x0000fe00 /* mask level 1 */
-#define SR_IMASK0 0x0000ff00 /* mask level 0 */
-
-#define SR_IBIT8 0x00008000 /* bit level 8 */
-#define SR_IBIT7 0x00004000 /* bit level 7 */
-#define SR_IBIT6 0x00002000 /* bit level 6 */
-#define SR_IBIT5 0x00001000 /* bit level 5 */
-#define SR_IBIT4 0x00000800 /* bit level 4 */
-#define SR_IBIT3 0x00000400 /* bit level 3 */
-#define SR_IBIT2 0x00000200 /* bit level 2 */
-#define SR_IBIT1 0x00000100 /* bit level 1 */
-
-#define SR_IMASKSHIFT 8
-
-#define SR_KX 0x00000080 /* extended-addr TLB vec in kernel */
-#define SR_SX 0x00000040 /* xtended-addr TLB vec supervisor */
-#define SR_UX 0x00000020 /* xtended-addr TLB vec in user mode */
-#define SR_KSU_MASK 0x00000018 /* mode mask */
-#define SR_KSU_USR 0x00000010 /* user mode */
-#define SR_KSU_SUP 0x00000008 /* supervisor mode */
-#define SR_KSU_KER 0x00000000 /* kernel mode */
-#define SR_ERL 0x00000004 /* Error level, 1=>cache error */
-#define SR_EXL 0x00000002 /* Exception level, 1=>exception */
-#define SR_IE 0x00000001 /* interrupt enable, 1=>enable */
-
-/*
- * Cause Register
- */
-#define CAUSE_BD 0x80000000 /* Branch delay slot */
-#define CAUSE_CEMASK 0x30000000 /* coprocessor error */
-#define CAUSE_CESHIFT 28
-
-/* Interrupt pending bits */
-#define CAUSE_IP8 0x00008000 /* External level 8 pending - COMPARE */
-#define CAUSE_IP7 0x00004000 /* External level 7 pending - INT4 */
-#define CAUSE_IP6 0x00002000 /* External level 6 pending - INT3 */
-#define CAUSE_IP5 0x00001000 /* External level 5 pending - INT2 */
-#define CAUSE_IP4 0x00000800 /* External level 4 pending - INT1 */
-#define CAUSE_IP3 0x00000400 /* External level 3 pending - INT0 */
-#define CAUSE_SW2 0x00000200 /* Software level 2 pending */
-#define CAUSE_SW1 0x00000100 /* Software level 1 pending */
-
-#define CAUSE_IPMASK 0x0000FF00 /* Pending interrupt mask */
-#define CAUSE_IPSHIFT 8
-
-#define CAUSE_EXCMASK 0x0000007C /* Cause code bits */
-
-#define CAUSE_EXCSHIFT 2
-
-/* Cause register exception codes */
-
-#define EXC_CODE(x) ((x)<<2)
-
-/* Hardware exception codes */
-#define EXC_INT EXC_CODE(0) /* interrupt */
-#define EXC_MOD EXC_CODE(1) /* TLB mod */
-#define EXC_RMISS EXC_CODE(2) /* Read TLB Miss */
-#define EXC_WMISS EXC_CODE(3) /* Write TLB Miss */
-#define EXC_RADE EXC_CODE(4) /* Read Address Error */
-#define EXC_WADE EXC_CODE(5) /* Write Address Error */
-#define EXC_IBE EXC_CODE(6) /* Instruction Bus Error */
-#define EXC_DBE EXC_CODE(7) /* Data Bus Error */
-#define EXC_SYSCALL EXC_CODE(8) /* SYSCALL */
-#define EXC_BREAK EXC_CODE(9) /* BREAKpoint */
-#define EXC_II EXC_CODE(10) /* Illegal Instruction */
-#define EXC_CPU EXC_CODE(11) /* CoProcessor Unusable */
-#define EXC_OV EXC_CODE(12) /* OVerflow */
-#define EXC_TRAP EXC_CODE(13) /* Trap exception */
-#define EXC_VCEI EXC_CODE(14) /* Virt. Coherency on Inst. fetch */
-#define EXC_FPE EXC_CODE(15) /* Floating Point Exception */
-#define EXC_WATCH EXC_CODE(23) /* Watchpoint reference */
-#define EXC_VCED EXC_CODE(31) /* Virt. Coherency on data read */
-
-/* C0_PRID Defines */
-#define C0_IMPMASK 0xff00
-#define C0_IMPSHIFT 8
-#define C0_REVMASK 0xff
-#define C0_MAJREVMASK 0xf0
-#define C0_MAJREVSHIFT 4
-#define C0_MINREVMASK 0xf
-
-/*
- * Coprocessor 0 operations
- */
-#define C0_READI 0x1 /* read ITLB entry addressed by C0_INDEX */
-#define C0_WRITEI 0x2 /* write ITLB entry addressed by C0_INDEX */
-#define C0_WRITER 0x6 /* write ITLB entry addressed by C0_RAND */
-#define C0_PROBE 0x8 /* probe for ITLB entry addressed by TLBHI */
-#define C0_RFE 0x10 /* restore for exception */
-
-/*
- * 'cache' instruction definitions
- */
-
-/* Target cache */
-#define CACH_PI 0x0 /* specifies primary inst. cache */
-#define CACH_PD 0x1 /* primary data cache */
-#define CACH_SI 0x2 /* secondary instruction cache */
-#define CACH_SD 0x3 /* secondary data cache */
-
-/* Cache operations */
-#define C_IINV 0x0 /* index invalidate (inst, 2nd inst) */
-#define C_IWBINV 0x0 /* index writeback inval (d, sd) */
-#define C_ILT 0x4 /* index load tag (all) */
-#define C_IST 0x8 /* index store tag (all) */
-#define C_CDX 0xc /* create dirty exclusive (d, sd) */
-#define C_HINV 0x10 /* hit invalidate (all) */
-#define C_HWBINV 0x14 /* hit writeback inv. (d, sd) */
-#define C_FILL 0x14 /* fill (i) */
-#define C_HWB 0x18 /* hit writeback (i, d, sd) */
-#define C_HSV 0x1c /* hit set virt. (si, sd) */
-
-/*
- * Cache size definitions
- */
-#define ICACHE_SIZE 0x4000 /* 16K */
-#define ICACHE_LINESIZE 32 /* 8 words */
-#define ICACHE_LINEMASK (ICACHE_LINESIZE-1)
-
-#define DCACHE_SIZE 0x2000 /* 8K */
-#define DCACHE_LINESIZE 16 /* 4 words */
-#define DCACHE_LINEMASK (DCACHE_LINESIZE-1)
-
-/*
- * C0_CONFIG register definitions
- */
-#define CONFIG_CM 0x80000000 /* 1 == Master-Checker enabled */
-#define CONFIG_EC 0x70000000 /* System Clock ratio */
-#define CONFIG_EC_1_1 0x6 /* System Clock ratio 1 :1 */
-#define CONFIG_EC_3_2 0x7 /* System Clock ratio 1.5 :1 */
-#define CONFIG_EC_2_1 0x0 /* System Clock ratio 2 :1 */
-#define CONFIG_EC_3_1 0x1 /* System Clock ratio 3 :1 */
-#define CONFIG_EP 0x0f000000 /* Transmit Data Pattern */
-#define CONFIG_SB 0x00c00000 /* Secondary cache block size */
-
-#define CONFIG_SS 0x00200000 /* Split scache: 0 == I&D combined */
-#define CONFIG_SW 0x00100000 /* scache port: 0==128, 1==64 */
-#define CONFIG_EW 0x000c0000 /* System Port width: 0==64, 1==32 */
-#define CONFIG_SC 0x00020000 /* 0 -> 2nd cache present */
-#define CONFIG_SM 0x00010000 /* 0 -> Dirty Shared Coherency enabled*/
-#define CONFIG_BE 0x00008000 /* Endian-ness: 1 --> BE */
-#define CONFIG_EM 0x00004000 /* 1 -> ECC mode, 0 -> parity */
-#define CONFIG_EB 0x00002000 /* Block order:1->sequent,0->subblock */
-
-#define CONFIG_IC 0x00000e00 /* Primary Icache size */
-#define CONFIG_DC 0x000001c0 /* Primary Dcache size */
-#define CONFIG_IB 0x00000020 /* Icache block size */
-#define CONFIG_DB 0x00000010 /* Dcache block size */
-#define CONFIG_CU 0x00000008 /* Update on Store-conditional */
-#define CONFIG_K0 0x00000007 /* K0SEG Coherency algorithm */
-
-#define CONFIG_UNCACHED 0x00000002 /* K0 is uncached */
-#define CONFIG_NONCOHRNT 0x00000003
-#define CONFIG_COHRNT_EXLWR 0x00000005
-#define CONFIG_SB_SHFT 22 /* shift SB to bit position 0 */
-#define CONFIG_IC_SHFT 9 /* shift IC to bit position 0 */
-#define CONFIG_DC_SHFT 6 /* shift DC to bit position 0 */
-#define CONFIG_BE_SHFT 15 /* shift BE to bit position 0 */
-
-/*
- * C0_TAGLO definitions for setting/getting cache states and physaddr bits
- */
-#define SADDRMASK 0xFFFFE000 /* 31..13 -> scache paddr bits 35..17 */
-#define SVINDEXMASK 0x00000380 /* 9..7: prim virt index bits 14..12 */
-#define SSTATEMASK 0x00001c00 /* bits 12..10 hold scache line state */
-#define SINVALID 0x00000000 /* invalid --> 000 == state 0 */
-#define SCLEANEXCL 0x00001000 /* clean exclusive --> 100 == state 4 */
-#define SDIRTYEXCL 0x00001400 /* dirty exclusive --> 101 == state 5 */
-#define SECC_MASK 0x0000007f /* low 7 bits are ecc for the tag */
-#define SADDR_SHIFT 4 /* shift STagLo (31..13) to 35..17 */
-
-#define PADDRMASK 0xFFFFFF00 /* PTagLo31..8->prim paddr bits35..12 */
-#define PADDR_SHIFT 4 /* roll bits 35..12 down to 31..8 */
-#define PSTATEMASK 0x00C0 /* bits 7..6 hold primary line state */
-#define PINVALID 0x0000 /* invalid --> 000 == state 0 */
-#define PCLEANEXCL 0x0080 /* clean exclusive --> 10 == state 2 */
-#define PDIRTYEXCL 0x00C0 /* dirty exclusive --> 11 == state 3 */
-#define PPARITY_MASK 0x0001 /* low bit is parity bit (even). */
-
-/*
- * C0_CACHE_ERR definitions.
- */
-#define CACHERR_ER 0x80000000 /* 0: inst ref, 1: data ref */
-#define CACHERR_EC 0x40000000 /* 0: primary, 1: secondary */
-#define CACHERR_ED 0x20000000 /* 1: data error */
-#define CACHERR_ET 0x10000000 /* 1: tag error */
-#define CACHERR_ES 0x08000000 /* 1: external ref, e.g. snoop*/
-#define CACHERR_EE 0x04000000 /* error on SysAD bus */
-#define CACHERR_EB 0x02000000 /* complicated, see spec. */
-#define CACHERR_EI 0x01000000 /* complicated, see spec. */
-#define CACHERR_SIDX_MASK 0x003ffff8 /* secondary cache index */
-#define CACHERR_PIDX_MASK 0x00000007 /* primary cache index */
-#define CACHERR_PIDX_SHIFT 12 /* bits 2..0 are paddr14..12 */
-
-/* R4000 family supports hardware watchpoints:
- * C0_WATCHLO:
- * bits 31..3 are bits 31..3 of physaddr to watch
- * bit 2: reserved; must be written as 0.
- * bit 1: when set causes a watchpoint trap on load accesses to paddr.
- * bit 0: when set traps on stores to paddr;
- * C0_WATCHHI
- * bits 31..4 are reserved and must be written as zeros.
- * bits 3..0 are bits 35..32 of the physaddr to watch
- */
-#define WATCHLO_WTRAP 0x00000001
-#define WATCHLO_RTRAP 0x00000002
-#define WATCHLO_ADDRMASK 0xfffffff8
-#define WATCHLO_VALIDMASK 0xfffffffb
-#define WATCHHI_VALIDMASK 0x0000000f
-
-/*
- * Coprocessor 0 registers
- */
-#ifdef _LANGUAGE_ASSEMBLY
-#define C0_INX $0
-#define C0_RAND $1
-#define C0_ENTRYLO0 $2
-#define C0_ENTRYLO1 $3
-#define C0_CONTEXT $4
-#define C0_PAGEMASK $5 /* page mask */
-#define C0_WIRED $6 /* # wired entries in tlb */
-#define C0_BADVADDR $8
-#define C0_COUNT $9 /* free-running counter */
-#define C0_ENTRYHI $10
-#define C0_SR $12
-#define C0_CAUSE $13
-#define C0_EPC $14
-#define C0_PRID $15 /* revision identifier */
-#define C0_COMPARE $11 /* counter comparison reg. */
-#define C0_CONFIG $16 /* hardware configuration */
-#define C0_LLADDR $17 /* load linked address */
-#define C0_WATCHLO $18 /* watchpoint */
-#define C0_WATCHHI $19 /* watchpoint */
-#define C0_ECC $26 /* S-cache ECC and primary parity */
-#define C0_CACHE_ERR $27 /* cache error status */
-#define C0_TAGLO $28 /* cache operations */
-#define C0_TAGHI $29 /* cache operations */
-#define C0_ERROR_EPC $30 /* ECC error prg. counter */
-
-# else /* ! _LANGUAGE_ASSEMBLY */
-
-#define C0_INX 0
-#define C0_RAND 1
-#define C0_ENTRYLO0 2
-#define C0_ENTRYLO1 3
-#define C0_CONTEXT 4
-#define C0_PAGEMASK 5 /* page mask */
-#define C0_WIRED 6 /* # wired entries in tlb */
-#define C0_BADVADDR 8
-#define C0_COUNT 9 /* free-running counter */
-#define C0_ENTRYHI 10
-#define C0_SR 12
-#define C0_CAUSE 13
-#define C0_EPC 14
-#define C0_PRID 15 /* revision identifier */
-#define C0_COMPARE 11 /* counter comparison reg. */
-#define C0_CONFIG 16 /* hardware configuration */
-#define C0_LLADDR 17 /* load linked address */
-#define C0_WATCHLO 18 /* watchpoint */
-#define C0_WATCHHI 19 /* watchpoint */
-#define C0_ECC 26 /* S-cache ECC and primary parity */
-#define C0_CACHE_ERR 27 /* cache error status */
-#define C0_TAGLO 28 /* cache operations */
-#define C0_TAGHI 29 /* cache operations */
-#define C0_ERROR_EPC 30 /* ECC error prg. counter */
-
-#endif /* _LANGUAGE_ASSEMBLY */
-
-/*
- * floating-point status register
- */
-#define FPCSR_FS 0x01000000 /* flush denorm to zero */
-#define FPCSR_C 0x00800000 /* condition bit */
-#define FPCSR_CE 0x00020000 /* cause: unimplemented operation */
-#define FPCSR_CV 0x00010000 /* cause: invalid operation */
-#define FPCSR_CZ 0x00008000 /* cause: division by zero */
-#define FPCSR_CO 0x00004000 /* cause: overflow */
-#define FPCSR_CU 0x00002000 /* cause: underflow */
-#define FPCSR_CI 0x00001000 /* cause: inexact operation */
-#define FPCSR_EV 0x00000800 /* enable: invalid operation */
-#define FPCSR_EZ 0x00000400 /* enable: division by zero */
-#define FPCSR_EO 0x00000200 /* enable: overflow */
-#define FPCSR_EU 0x00000100 /* enable: underflow */
-#define FPCSR_EI 0x00000080 /* enable: inexact operation */
-#define FPCSR_FV 0x00000040 /* flag: invalid operation */
-#define FPCSR_FZ 0x00000020 /* flag: division by zero */
-#define FPCSR_FO 0x00000010 /* flag: overflow */
-#define FPCSR_FU 0x00000008 /* flag: underflow */
-#define FPCSR_FI 0x00000004 /* flag: inexact operation */
-#define FPCSR_RM_MASK 0x00000003 /* rounding mode mask */
-#define FPCSR_RM_RN 0x00000000 /* round to nearest */
-#define FPCSR_RM_RZ 0x00000001 /* round to zero */
-#define FPCSR_RM_RP 0x00000002 /* round to positive infinity */
-#define FPCSR_RM_RM 0x00000003 /* round to negative infinity */
-
-#endif /* __R4300_H */
+/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., 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 Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/************************************************************************** + * + * $Revision: 1.13 $ + * $Date: 1997/02/11 08:15:34 $ + * $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/R4300.h,v $ + * + **************************************************************************/ + +#ifndef __R4300_H__ +#define __R4300_H__ + +#include <PR/ultratypes.h> + +/* + * Segment base addresses and sizes + */ +#define KUBASE 0 +#define KUSIZE 0x80000000 +#define K0BASE 0x80000000 +#define K0SIZE 0x20000000 +#define K1BASE 0xA0000000 +#define K1SIZE 0x20000000 +#define K2BASE 0xC0000000 +#define K2SIZE 0x20000000 + +/* + * Exception vectors + */ +#define SIZE_EXCVEC 0x80 /* Size of an exc. vec */ +#define UT_VEC K0BASE /* utlbmiss vector */ +#define R_VEC (K1BASE+0x1fc00000) /* reset vector */ +#define XUT_VEC (K0BASE+0x80) /* extended address tlbmiss */ +#define ECC_VEC (K0BASE+0x100) /* Ecc exception vector */ +#define E_VEC (K0BASE+0x180) /* Gen. exception vector */ + +/* + * Address conversion macros + */ +#ifdef _LANGUAGE_ASSEMBLY + +#define K0_TO_K1(x) ((x)|0xA0000000) /* kseg0 to kseg1 */ +#define K1_TO_K0(x) ((x)&0x9FFFFFFF) /* kseg1 to kseg0 */ +#define K0_TO_PHYS(x) ((x)&0x1FFFFFFF) /* kseg0 to physical */ +#define K1_TO_PHYS(x) ((x)&0x1FFFFFFF) /* kseg1 to physical */ +#define KDM_TO_PHYS(x) ((x)&0x1FFFFFFF) /* direct mapped to physical */ +#define PHYS_TO_K0(x) ((x)|0x80000000) /* physical to kseg0 */ +#define PHYS_TO_K1(x) ((x)|0xA0000000) /* physical to kseg1 */ + +#else /* _LANGUAGE_C */ + +#define K0_TO_K1(x) ((u32)(x)|0xA0000000) /* kseg0 to kseg1 */ +#define K1_TO_K0(x) ((u32)(x)&0x9FFFFFFF) /* kseg1 to kseg0 */ +#define K0_TO_PHYS(x) ((u32)(x)&0x1FFFFFFF) /* kseg0 to physical */ +#define K1_TO_PHYS(x) ((u32)(x)&0x1FFFFFFF) /* kseg1 to physical */ +#define KDM_TO_PHYS(x) ((u32)(x)&0x1FFFFFFF) /* direct mapped to physical */ +#define PHYS_TO_K0(x) ((u32)(x)|0x80000000) /* physical to kseg0 */ +#define PHYS_TO_K1(x) ((u32)(x)|0xA0000000) /* physical to kseg1 */ + +#endif /* _LANGUAGE_ASSEMBLY */ + +/* + * Address predicates + */ +#define IS_KSEG0(x) ((u32)(x) >= K0BASE && (u32)(x) < K1BASE) +#define IS_KSEG1(x) ((u32)(x) >= K1BASE && (u32)(x) < K2BASE) +#define IS_KSEGDM(x) ((u32)(x) >= K0BASE && (u32)(x) < K2BASE) +#define IS_KSEG2(x) ((u32)(x) >= K2BASE && (u32)(x) < KPTE_SHDUBASE) +#define IS_KPTESEG(x) ((u32)(x) >= KPTE_SHDUBASE) +#define IS_KUSEG(x) ((u32)(x) < K0BASE) + +/* + * TLB size constants + */ + +#define NTLBENTRIES 31 /* entry 31 is reserved by rdb */ + +#define TLBHI_VPN2MASK 0xffffe000 +#define TLBHI_VPN2SHIFT 13 +#define TLBHI_PIDMASK 0xff +#define TLBHI_PIDSHIFT 0 +#define TLBHI_NPID 255 /* 255 to fit in 8 bits */ + +#define TLBLO_PFNMASK 0x3fffffc0 +#define TLBLO_PFNSHIFT 6 +#define TLBLO_CACHMASK 0x38 /* cache coherency algorithm */ +#define TLBLO_CACHSHIFT 3 +#define TLBLO_UNCACHED 0x10 /* not cached */ +#define TLBLO_NONCOHRNT 0x18 /* Cacheable non-coherent */ +#define TLBLO_EXLWR 0x28 /* Exclusive write */ +#define TLBLO_D 0x4 /* writeable */ +#define TLBLO_V 0x2 /* valid bit */ +#define TLBLO_G 0x1 /* global access bit */ + +#define TLBINX_PROBE 0x80000000 +#define TLBINX_INXMASK 0x3f +#define TLBINX_INXSHIFT 0 + +#define TLBRAND_RANDMASK 0x3f +#define TLBRAND_RANDSHIFT 0 + +#define TLBWIRED_WIREDMASK 0x3f + +#define TLBCTXT_BASEMASK 0xff800000 +#define TLBCTXT_BASESHIFT 23 +#define TLBCTXT_BASEBITS 9 + +#define TLBCTXT_VPNMASK 0x7ffff0 +#define TLBCTXT_VPNSHIFT 4 + +#define TLBPGMASK_4K 0x0 +#define TLBPGMASK_16K 0x6000 +#define TLBPGMASK_64K 0x1e000 + +/* + * Status register + */ +#define SR_CUMASK 0xf0000000 /* coproc usable bits */ + +#define SR_CU3 0x80000000 /* Coprocessor 3 usable */ +#define SR_CU2 0x40000000 /* Coprocessor 2 usable */ +#define SR_CU1 0x20000000 /* Coprocessor 1 usable */ +#define SR_CU0 0x10000000 /* Coprocessor 0 usable */ +#define SR_RP 0x08000000 /* Reduced power (quarter speed) */ +#define SR_FR 0x04000000 /* MIPS III FP register mode */ +#define SR_RE 0x02000000 /* Reverse endian */ +#define SR_ITS 0x01000000 /* Instruction trace support */ +#define SR_BEV 0x00400000 /* Use boot exception vectors */ +#define SR_TS 0x00200000 /* TLB shutdown */ +#define SR_SR 0x00100000 /* Soft reset occured */ +#define SR_CH 0x00040000 /* Cache hit for last 'cache' op */ +#define SR_CE 0x00020000 /* Create ECC */ +#define SR_DE 0x00010000 /* ECC of parity does not cause error */ + +/* + * Interrupt enable bits + * (NOTE: bits set to 1 enable the corresponding level interrupt) + */ +#define SR_IMASK 0x0000ff00 /* Interrupt mask */ +#define SR_IMASK8 0x00000000 /* mask level 8 */ +#define SR_IMASK7 0x00008000 /* mask level 7 */ +#define SR_IMASK6 0x0000c000 /* mask level 6 */ +#define SR_IMASK5 0x0000e000 /* mask level 5 */ +#define SR_IMASK4 0x0000f000 /* mask level 4 */ +#define SR_IMASK3 0x0000f800 /* mask level 3 */ +#define SR_IMASK2 0x0000fc00 /* mask level 2 */ +#define SR_IMASK1 0x0000fe00 /* mask level 1 */ +#define SR_IMASK0 0x0000ff00 /* mask level 0 */ + +#define SR_IBIT8 0x00008000 /* bit level 8 */ +#define SR_IBIT7 0x00004000 /* bit level 7 */ +#define SR_IBIT6 0x00002000 /* bit level 6 */ +#define SR_IBIT5 0x00001000 /* bit level 5 */ +#define SR_IBIT4 0x00000800 /* bit level 4 */ +#define SR_IBIT3 0x00000400 /* bit level 3 */ +#define SR_IBIT2 0x00000200 /* bit level 2 */ +#define SR_IBIT1 0x00000100 /* bit level 1 */ + +#define SR_IMASKSHIFT 8 + +#define SR_KX 0x00000080 /* extended-addr TLB vec in kernel */ +#define SR_SX 0x00000040 /* xtended-addr TLB vec supervisor */ +#define SR_UX 0x00000020 /* xtended-addr TLB vec in user mode */ +#define SR_KSU_MASK 0x00000018 /* mode mask */ +#define SR_KSU_USR 0x00000010 /* user mode */ +#define SR_KSU_SUP 0x00000008 /* supervisor mode */ +#define SR_KSU_KER 0x00000000 /* kernel mode */ +#define SR_ERL 0x00000004 /* Error level, 1=>cache error */ +#define SR_EXL 0x00000002 /* Exception level, 1=>exception */ +#define SR_IE 0x00000001 /* interrupt enable, 1=>enable */ + +/* + * Cause Register + */ +#define CAUSE_BD 0x80000000 /* Branch delay slot */ +#define CAUSE_CEMASK 0x30000000 /* coprocessor error */ +#define CAUSE_CESHIFT 28 + +/* Interrupt pending bits */ +#define CAUSE_IP8 0x00008000 /* External level 8 pending - COMPARE */ +#define CAUSE_IP7 0x00004000 /* External level 7 pending - INT4 */ +#define CAUSE_IP6 0x00002000 /* External level 6 pending - INT3 */ +#define CAUSE_IP5 0x00001000 /* External level 5 pending - INT2 */ +#define CAUSE_IP4 0x00000800 /* External level 4 pending - INT1 */ +#define CAUSE_IP3 0x00000400 /* External level 3 pending - INT0 */ +#define CAUSE_SW2 0x00000200 /* Software level 2 pending */ +#define CAUSE_SW1 0x00000100 /* Software level 1 pending */ + +#define CAUSE_IPMASK 0x0000FF00 /* Pending interrupt mask */ +#define CAUSE_IPSHIFT 8 + +#define CAUSE_EXCMASK 0x0000007C /* Cause code bits */ + +#define CAUSE_EXCSHIFT 2 + +/* Cause register exception codes */ + +#define EXC_CODE(x) ((x)<<2) + +/* Hardware exception codes */ +#define EXC_INT EXC_CODE(0) /* interrupt */ +#define EXC_MOD EXC_CODE(1) /* TLB mod */ +#define EXC_RMISS EXC_CODE(2) /* Read TLB Miss */ +#define EXC_WMISS EXC_CODE(3) /* Write TLB Miss */ +#define EXC_RADE EXC_CODE(4) /* Read Address Error */ +#define EXC_WADE EXC_CODE(5) /* Write Address Error */ +#define EXC_IBE EXC_CODE(6) /* Instruction Bus Error */ +#define EXC_DBE EXC_CODE(7) /* Data Bus Error */ +#define EXC_SYSCALL EXC_CODE(8) /* SYSCALL */ +#define EXC_BREAK EXC_CODE(9) /* BREAKpoint */ +#define EXC_II EXC_CODE(10) /* Illegal Instruction */ +#define EXC_CPU EXC_CODE(11) /* CoProcessor Unusable */ +#define EXC_OV EXC_CODE(12) /* OVerflow */ +#define EXC_TRAP EXC_CODE(13) /* Trap exception */ +#define EXC_VCEI EXC_CODE(14) /* Virt. Coherency on Inst. fetch */ +#define EXC_FPE EXC_CODE(15) /* Floating Point Exception */ +#define EXC_WATCH EXC_CODE(23) /* Watchpoint reference */ +#define EXC_VCED EXC_CODE(31) /* Virt. Coherency on data read */ + +/* C0_PRID Defines */ +#define C0_IMPMASK 0xff00 +#define C0_IMPSHIFT 8 +#define C0_REVMASK 0xff +#define C0_MAJREVMASK 0xf0 +#define C0_MAJREVSHIFT 4 +#define C0_MINREVMASK 0xf + +/* + * Coprocessor 0 operations + */ +#define C0_READI 0x1 /* read ITLB entry addressed by C0_INDEX */ +#define C0_WRITEI 0x2 /* write ITLB entry addressed by C0_INDEX */ +#define C0_WRITER 0x6 /* write ITLB entry addressed by C0_RAND */ +#define C0_PROBE 0x8 /* probe for ITLB entry addressed by TLBHI */ +#define C0_RFE 0x10 /* restore for exception */ + +/* + * 'cache' instruction definitions + */ + +/* Target cache */ +#define CACH_PI 0x0 /* specifies primary inst. cache */ +#define CACH_PD 0x1 /* primary data cache */ +#define CACH_SI 0x2 /* secondary instruction cache */ +#define CACH_SD 0x3 /* secondary data cache */ + +/* Cache operations */ +#define C_IINV 0x0 /* index invalidate (inst, 2nd inst) */ +#define C_IWBINV 0x0 /* index writeback inval (d, sd) */ +#define C_ILT 0x4 /* index load tag (all) */ +#define C_IST 0x8 /* index store tag (all) */ +#define C_CDX 0xc /* create dirty exclusive (d, sd) */ +#define C_HINV 0x10 /* hit invalidate (all) */ +#define C_HWBINV 0x14 /* hit writeback inv. (d, sd) */ +#define C_FILL 0x14 /* fill (i) */ +#define C_HWB 0x18 /* hit writeback (i, d, sd) */ +#define C_HSV 0x1c /* hit set virt. (si, sd) */ + +/* + * Cache size definitions + */ +#define ICACHE_SIZE 0x4000 /* 16K */ +#define ICACHE_LINESIZE 32 /* 8 words */ +#define ICACHE_LINEMASK (ICACHE_LINESIZE-1) + +#define DCACHE_SIZE 0x2000 /* 8K */ +#define DCACHE_LINESIZE 16 /* 4 words */ +#define DCACHE_LINEMASK (DCACHE_LINESIZE-1) + +/* + * C0_CONFIG register definitions + */ +#define CONFIG_CM 0x80000000 /* 1 == Master-Checker enabled */ +#define CONFIG_EC 0x70000000 /* System Clock ratio */ +#define CONFIG_EC_1_1 0x6 /* System Clock ratio 1 :1 */ +#define CONFIG_EC_3_2 0x7 /* System Clock ratio 1.5 :1 */ +#define CONFIG_EC_2_1 0x0 /* System Clock ratio 2 :1 */ +#define CONFIG_EC_3_1 0x1 /* System Clock ratio 3 :1 */ +#define CONFIG_EP 0x0f000000 /* Transmit Data Pattern */ +#define CONFIG_SB 0x00c00000 /* Secondary cache block size */ + +#define CONFIG_SS 0x00200000 /* Split scache: 0 == I&D combined */ +#define CONFIG_SW 0x00100000 /* scache port: 0==128, 1==64 */ +#define CONFIG_EW 0x000c0000 /* System Port width: 0==64, 1==32 */ +#define CONFIG_SC 0x00020000 /* 0 -> 2nd cache present */ +#define CONFIG_SM 0x00010000 /* 0 -> Dirty Shared Coherency enabled*/ +#define CONFIG_BE 0x00008000 /* Endian-ness: 1 --> BE */ +#define CONFIG_EM 0x00004000 /* 1 -> ECC mode, 0 -> parity */ +#define CONFIG_EB 0x00002000 /* Block order:1->sequent,0->subblock */ + +#define CONFIG_IC 0x00000e00 /* Primary Icache size */ +#define CONFIG_DC 0x000001c0 /* Primary Dcache size */ +#define CONFIG_IB 0x00000020 /* Icache block size */ +#define CONFIG_DB 0x00000010 /* Dcache block size */ +#define CONFIG_CU 0x00000008 /* Update on Store-conditional */ +#define CONFIG_K0 0x00000007 /* K0SEG Coherency algorithm */ + +#define CONFIG_UNCACHED 0x00000002 /* K0 is uncached */ +#define CONFIG_NONCOHRNT 0x00000003 +#define CONFIG_COHRNT_EXLWR 0x00000005 +#define CONFIG_SB_SHFT 22 /* shift SB to bit position 0 */ +#define CONFIG_IC_SHFT 9 /* shift IC to bit position 0 */ +#define CONFIG_DC_SHFT 6 /* shift DC to bit position 0 */ +#define CONFIG_BE_SHFT 15 /* shift BE to bit position 0 */ + +/* + * C0_TAGLO definitions for setting/getting cache states and physaddr bits + */ +#define SADDRMASK 0xFFFFE000 /* 31..13 -> scache paddr bits 35..17 */ +#define SVINDEXMASK 0x00000380 /* 9..7: prim virt index bits 14..12 */ +#define SSTATEMASK 0x00001c00 /* bits 12..10 hold scache line state */ +#define SINVALID 0x00000000 /* invalid --> 000 == state 0 */ +#define SCLEANEXCL 0x00001000 /* clean exclusive --> 100 == state 4 */ +#define SDIRTYEXCL 0x00001400 /* dirty exclusive --> 101 == state 5 */ +#define SECC_MASK 0x0000007f /* low 7 bits are ecc for the tag */ +#define SADDR_SHIFT 4 /* shift STagLo (31..13) to 35..17 */ + +#define PADDRMASK 0xFFFFFF00 /* PTagLo31..8->prim paddr bits35..12 */ +#define PADDR_SHIFT 4 /* roll bits 35..12 down to 31..8 */ +#define PSTATEMASK 0x00C0 /* bits 7..6 hold primary line state */ +#define PINVALID 0x0000 /* invalid --> 000 == state 0 */ +#define PCLEANEXCL 0x0080 /* clean exclusive --> 10 == state 2 */ +#define PDIRTYEXCL 0x00C0 /* dirty exclusive --> 11 == state 3 */ +#define PPARITY_MASK 0x0001 /* low bit is parity bit (even). */ + +/* + * C0_CACHE_ERR definitions. + */ +#define CACHERR_ER 0x80000000 /* 0: inst ref, 1: data ref */ +#define CACHERR_EC 0x40000000 /* 0: primary, 1: secondary */ +#define CACHERR_ED 0x20000000 /* 1: data error */ +#define CACHERR_ET 0x10000000 /* 1: tag error */ +#define CACHERR_ES 0x08000000 /* 1: external ref, e.g. snoop*/ +#define CACHERR_EE 0x04000000 /* error on SysAD bus */ +#define CACHERR_EB 0x02000000 /* complicated, see spec. */ +#define CACHERR_EI 0x01000000 /* complicated, see spec. */ +#define CACHERR_SIDX_MASK 0x003ffff8 /* secondary cache index */ +#define CACHERR_PIDX_MASK 0x00000007 /* primary cache index */ +#define CACHERR_PIDX_SHIFT 12 /* bits 2..0 are paddr14..12 */ + +/* R4000 family supports hardware watchpoints: + * C0_WATCHLO: + * bits 31..3 are bits 31..3 of physaddr to watch + * bit 2: reserved; must be written as 0. + * bit 1: when set causes a watchpoint trap on load accesses to paddr. + * bit 0: when set traps on stores to paddr; + * C0_WATCHHI + * bits 31..4 are reserved and must be written as zeros. + * bits 3..0 are bits 35..32 of the physaddr to watch + */ +#define WATCHLO_WTRAP 0x00000001 +#define WATCHLO_RTRAP 0x00000002 +#define WATCHLO_ADDRMASK 0xfffffff8 +#define WATCHLO_VALIDMASK 0xfffffffb +#define WATCHHI_VALIDMASK 0x0000000f + +/* + * Coprocessor 0 registers + */ +#ifdef _LANGUAGE_ASSEMBLY +#define C0_INX $0 +#define C0_RAND $1 +#define C0_ENTRYLO0 $2 +#define C0_ENTRYLO1 $3 +#define C0_CONTEXT $4 +#define C0_PAGEMASK $5 /* page mask */ +#define C0_WIRED $6 /* # wired entries in tlb */ +#define C0_BADVADDR $8 +#define C0_COUNT $9 /* free-running counter */ +#define C0_ENTRYHI $10 +#define C0_SR $12 +#define C0_CAUSE $13 +#define C0_EPC $14 +#define C0_PRID $15 /* revision identifier */ +#define C0_COMPARE $11 /* counter comparison reg. */ +#define C0_CONFIG $16 /* hardware configuration */ +#define C0_LLADDR $17 /* load linked address */ +#define C0_WATCHLO $18 /* watchpoint */ +#define C0_WATCHHI $19 /* watchpoint */ +#define C0_ECC $26 /* S-cache ECC and primary parity */ +#define C0_CACHE_ERR $27 /* cache error status */ +#define C0_TAGLO $28 /* cache operations */ +#define C0_TAGHI $29 /* cache operations */ +#define C0_ERROR_EPC $30 /* ECC error prg. counter */ + +# else /* ! _LANGUAGE_ASSEMBLY */ + +#define C0_INX 0 +#define C0_RAND 1 +#define C0_ENTRYLO0 2 +#define C0_ENTRYLO1 3 +#define C0_CONTEXT 4 +#define C0_PAGEMASK 5 /* page mask */ +#define C0_WIRED 6 /* # wired entries in tlb */ +#define C0_BADVADDR 8 +#define C0_COUNT 9 /* free-running counter */ +#define C0_ENTRYHI 10 +#define C0_SR 12 +#define C0_CAUSE 13 +#define C0_EPC 14 +#define C0_PRID 15 /* revision identifier */ +#define C0_COMPARE 11 /* counter comparison reg. */ +#define C0_CONFIG 16 /* hardware configuration */ +#define C0_LLADDR 17 /* load linked address */ +#define C0_WATCHLO 18 /* watchpoint */ +#define C0_WATCHHI 19 /* watchpoint */ +#define C0_ECC 26 /* S-cache ECC and primary parity */ +#define C0_CACHE_ERR 27 /* cache error status */ +#define C0_TAGLO 28 /* cache operations */ +#define C0_TAGHI 29 /* cache operations */ +#define C0_ERROR_EPC 30 /* ECC error prg. counter */ + +#endif /* _LANGUAGE_ASSEMBLY */ + +/* + * floating-point status register + */ +#define FPCSR_FS 0x01000000 /* flush denorm to zero */ +#define FPCSR_C 0x00800000 /* condition bit */ +#define FPCSR_CE 0x00020000 /* cause: unimplemented operation */ +#define FPCSR_CV 0x00010000 /* cause: invalid operation */ +#define FPCSR_CZ 0x00008000 /* cause: division by zero */ +#define FPCSR_CO 0x00004000 /* cause: overflow */ +#define FPCSR_CU 0x00002000 /* cause: underflow */ +#define FPCSR_CI 0x00001000 /* cause: inexact operation */ +#define FPCSR_EV 0x00000800 /* enable: invalid operation */ +#define FPCSR_EZ 0x00000400 /* enable: division by zero */ +#define FPCSR_EO 0x00000200 /* enable: overflow */ +#define FPCSR_EU 0x00000100 /* enable: underflow */ +#define FPCSR_EI 0x00000080 /* enable: inexact operation */ +#define FPCSR_FV 0x00000040 /* flag: invalid operation */ +#define FPCSR_FZ 0x00000020 /* flag: division by zero */ +#define FPCSR_FO 0x00000010 /* flag: overflow */ +#define FPCSR_FU 0x00000008 /* flag: underflow */ +#define FPCSR_FI 0x00000004 /* flag: inexact operation */ +#define FPCSR_RM_MASK 0x00000003 /* rounding mode mask */ +#define FPCSR_RM_RN 0x00000000 /* round to nearest */ +#define FPCSR_RM_RZ 0x00000001 /* round to zero */ +#define FPCSR_RM_RP 0x00000002 /* round to positive infinity */ +#define FPCSR_RM_RM 0x00000003 /* round to negative infinity */ + +#endif /* __R4300_H */ diff --git a/lib/ultralib/include/PR/os_internal.h b/lib/ultralib/include/PR/os_internal.h index d094a57..754d1ee 100644 --- a/lib/ultralib/include/PR/os_internal.h +++ b/lib/ultralib/include/PR/os_internal.h @@ -39,7 +39,6 @@ extern "C" { #include "os_internal_thread.h" #include "os_internal_debug.h" #include "os_internal_host.h" -#include "os_internal_flash.h" #endif /* _LANGUAGE_C */ diff --git a/lib/ultralib/include/PR/os_internal_flash.h b/lib/ultralib/include/PR/os_internal_flash.h index d8681d7..1c6f780 100644 --- a/lib/ultralib/include/PR/os_internal_flash.h +++ b/lib/ultralib/include/PR/os_internal_flash.h @@ -28,11 +28,11 @@ /* set read mode */ #define FLASH_CMD_READ_ARRAY 0xF0000000 -extern s32 __osFlashVersion; -extern OSPiHandle __osFlashHandler; +extern OSIoMesg __osFlashMsg; extern OSMesgQueue __osFlashMessageQ; +extern OSPiHandle __osFlashHandler; extern OSMesg __osFlashMsgBuf[1]; -extern OSIoMesg __osFlashMsg; +extern s32 __osFlashVersion; extern u32 __osFlashID[4]; u32 __osFlashGetAddr(u32 page_num); diff --git a/lib/ultralib/include/PR/os_system.h b/lib/ultralib/include/PR/os_system.h index 682c9cf..1179189 100644 --- a/lib/ultralib/include/PR/os_system.h +++ b/lib/ultralib/include/PR/os_system.h @@ -1,118 +1,118 @@ -
-/*====================================================================
- * os_system.h
- *
- * Copyright 1995, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
- * Inc.; the contents of this file may not be disclosed to third
- * parties, copied or duplicated in any form, in whole or in part,
- * without the prior written permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to
- * restrictions as set forth in subdivision (c)(1)(ii) of the Rights
- * in Technical Data and Computer Software clause at DFARS
- * 252.227-7013, and/or in similar or successor clauses in the FAR,
- * DOD or NASA FAR Supplement. Unpublished - rights reserved under the
- * Copyright Laws of the United States.
- *====================================================================*/
-
-/*---------------------------------------------------------------------*
- Copyright (C) 1998 Nintendo. (Originated by SGI)
-
- $RCSfile: os_system.h,v $
- $Revision: 1.1 $
- $Date: 1998/10/09 08:01:18 $
- *---------------------------------------------------------------------*/
-
-#ifndef _OS_SYSTEM_H_
-#define _OS_SYSTEM_H_
-
-#ifdef _LANGUAGE_C_PLUS_PLUS
-extern "C" {
-#endif
-
-#include <PR/ultratypes.h>
-
-#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
-
-/**************************************************************************
- *
- * Type definitions
- *
- */
-
-
-#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
-
-/**************************************************************************
- *
- * Global definitions
- *
- */
-
-/*
- * Values for osTvType
- */
-#define OS_TV_PAL 0
-#define OS_TV_NTSC 1
-#define OS_TV_MPAL 2
-
-/*
- * Size of buffer the retains contents after NMI
- */
-#define OS_APP_NMI_BUFSIZE 64
-
-
-#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
-
-/**************************************************************************
- *
- * Macro definitions
- *
- */
-
-
-/**************************************************************************
- *
- * Extern variables
- *
- */
-
-extern s32 osRomType; /* Bulk or cartridge ROM. 0=cartridge 1=bulk */
-extern void *osRomBase; /* Rom base address of the game image */
-extern s32 osTvType; /* 0 = PAL, 1 = NTSC, 2 = MPAL */
-extern s32 osResetType; /* 0 = cold reset, 1 = NMI */
-extern s32 osCicId;
-extern s32 osVersion;
-extern u32 osMemSize; /* Memory Size */
-extern s32 osAppNMIBuffer[];
-
-extern u64 osClockRate;
-
-extern OSIntMask __OSGlobalIntMask; /* global interrupt mask */
-
-
-/**************************************************************************
- *
- * Function prototypes
- *
- */
-
-extern void osInitialize(void);
-extern void osExit(void);
-extern u32 osGetMemSize(void);
-
-/* pre-NMI */
-extern s32 osAfterPreNMI(void);
-
-
-#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
-
-#ifdef _LANGUAGE_C_PLUS_PLUS
-}
-#endif
-
-#endif /* !_OS_SYSTEM_H_ */
+ +/*==================================================================== + * os_system.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_system.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:18 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_SYSTEM_H_ +#define _OS_SYSTEM_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include <PR/ultratypes.h> + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + +/* + * Values for osTvType + */ +#define OS_TV_PAL 0 +#define OS_TV_NTSC 1 +#define OS_TV_MPAL 2 + +/* + * Size of buffer the retains contents after NMI + */ +#define OS_APP_NMI_BUFSIZE 64 + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + +extern s32 osRomType; /* Bulk or cartridge ROM. 0=cartridge 1=bulk */ +extern void *osRomBase; /* Rom base address of the game image */ +extern s32 osTvType; /* 0 = PAL, 1 = NTSC, 2 = MPAL */ +extern s32 osResetType; /* 0 = cold reset, 1 = NMI */ +extern s32 osCicId; +extern s32 osVersion; +extern u32 osMemSize; /* Memory Size */ +extern s32 osAppNMIBuffer[]; + +extern u64 osClockRate; + +extern OSIntMask __OSGlobalIntMask; /* global interrupt mask */ + + +/************************************************************************** + * + * Function prototypes + * + */ + +extern void osInitialize(void); +extern void osExit(void); +extern u32 osGetMemSize(void); + +/* pre-NMI */ +extern s32 osAfterPreNMI(void); + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_SYSTEM_H_ */ diff --git a/lib/ultralib/include/PR/rcp.h b/lib/ultralib/include/PR/rcp.h index 56cb236..47c4b34 100644 --- a/lib/ultralib/include/PR/rcp.h +++ b/lib/ultralib/include/PR/rcp.h @@ -156,31 +156,31 @@ #define SP_BASE_REG 0x04040000 -//! SP memory address (R/W): [11:0] DMEM/IMEM address, [12] 0=DMEM,1=IMEM +/* SP memory address (R/W): [11:0] DMEM/IMEM address, [12] 0=DMEM,1=IMEM */ #define SP_MEM_ADDR_REG (SP_BASE_REG + 0x00) -//! SP DRAM DMA address (R/W): [23:0] RDRAM address +/* SP DRAM DMA address (R/W): [23:0] RDRAM address */ #define SP_DRAM_ADDR_REG (SP_BASE_REG + 0x04) -//! SP read DMA length (R/W): [11:0] length, [19:12] count, [31:20] skip; RDRAM -> I/DMEM +/* SP read DMA length (R/W): [11:0] length, [19:12] count, [31:20] skip; RDRAM -> I/DMEM */ #define SP_RD_LEN_REG (SP_BASE_REG + 0x08) -//! SP write DMA length (R/W): [11:0] length, [19:12] count, [31:20] skip; I/DMEM -> RDRAM +/* SP write DMA length (R/W): [11:0] length, [19:12] count, [31:20] skip; I/DMEM -> RDRAM */ #define SP_WR_LEN_REG (SP_BASE_REG + 0x0C) -//! SP status (R/W): [14:0] valid bits; see below for write/read mode +/* SP status (R/W): [14:0] valid bits; see below for write/read mode */ #define SP_STATUS_REG (SP_BASE_REG + 0x10) -//! SP DMA full (R): [0] dma full +/* SP DMA full (R): [0] dma full */ #define SP_DMA_FULL_REG (SP_BASE_REG + 0x14) -//! SP DMA busy (R): [0] dma busy +/* SP DMA busy (R): [0] dma busy */ #define SP_DMA_BUSY_REG (SP_BASE_REG + 0x18) -//! SP semaphore (R/W): Read: [0] acquire semaphore; Write: [] release semaphore +/* SP semaphore (R/W): Read: [0] acquire semaphore; Write: [] release semaphore */ #define SP_SEMAPHORE_REG (SP_BASE_REG + 0x1C) -//! SP PC (R/W): [11:0] program counter +/* SP PC (R/W): [11:0] program counter */ #define SP_PC_REG 0x04080000 /** @@ -192,31 +192,31 @@ /** * SP_STATUS_REG: write bits */ -#define SP_CLR_HALT (1 << 0) // clear halt -#define SP_SET_HALT (1 << 1) // set halt -#define SP_CLR_BROKE (1 << 2) // clear broke -#define SP_CLR_INTR (1 << 3) // clear interrupt -#define SP_SET_INTR (1 << 4) // set interrupt -#define SP_CLR_SSTEP (1 << 5) // clear sstep -#define SP_SET_SSTEP (1 << 6) // set sstep -#define SP_CLR_INTR_BREAK (1 << 7) // clear interrupt on break -#define SP_SET_INTR_BREAK (1 << 8) // set interrupt on break -#define SP_CLR_SIG0 (1 << 9) // clear signal 0 -#define SP_SET_SIG0 (1 << 10) // set signal 0 -#define SP_CLR_SIG1 (1 << 11) // clear signal 1 -#define SP_SET_SIG1 (1 << 12) // set signal 1 -#define SP_CLR_SIG2 (1 << 13) // clear signal 2 -#define SP_SET_SIG2 (1 << 14) // set signal 2 -#define SP_CLR_SIG3 (1 << 15) // clear signal 3 -#define SP_SET_SIG3 (1 << 16) // set signal 3 -#define SP_CLR_SIG4 (1 << 17) // clear signal 4 -#define SP_SET_SIG4 (1 << 18) // set signal 4 -#define SP_CLR_SIG5 (1 << 19) // clear signal 5 -#define SP_SET_SIG5 (1 << 20) // set signal 5 -#define SP_CLR_SIG6 (1 << 21) // clear signal 6 -#define SP_SET_SIG6 (1 << 22) // set signal 6 -#define SP_CLR_SIG7 (1 << 23) // clear signal 7 -#define SP_SET_SIG7 (1 << 24) // set signal 7 +#define SP_CLR_HALT (1 << 0) /* clear halt */ +#define SP_SET_HALT (1 << 1) /* set halt */ +#define SP_CLR_BROKE (1 << 2) /* clear broke */ +#define SP_CLR_INTR (1 << 3) /* clear interrupt */ +#define SP_SET_INTR (1 << 4) /* set interrupt */ +#define SP_CLR_SSTEP (1 << 5) /* clear sstep */ +#define SP_SET_SSTEP (1 << 6) /* set sstep */ +#define SP_CLR_INTR_BREAK (1 << 7) /* clear interrupt on break */ +#define SP_SET_INTR_BREAK (1 << 8) /* set interrupt on break */ +#define SP_CLR_SIG0 (1 << 9) /* clear signal 0 */ +#define SP_SET_SIG0 (1 << 10) /* set signal 0 */ +#define SP_CLR_SIG1 (1 << 11) /* clear signal 1 */ +#define SP_SET_SIG1 (1 << 12) /* set signal 1 */ +#define SP_CLR_SIG2 (1 << 13) /* clear signal 2 */ +#define SP_SET_SIG2 (1 << 14) /* set signal 2 */ +#define SP_CLR_SIG3 (1 << 15) /* clear signal 3 */ +#define SP_SET_SIG3 (1 << 16) /* set signal 3 */ +#define SP_CLR_SIG4 (1 << 17) /* clear signal 4 */ +#define SP_SET_SIG4 (1 << 18) /* set signal 4 */ +#define SP_CLR_SIG5 (1 << 19) /* clear signal 5 */ +#define SP_SET_SIG5 (1 << 20) /* set signal 5 */ +#define SP_CLR_SIG6 (1 << 21) /* clear signal 6 */ +#define SP_SET_SIG6 (1 << 22) /* set signal 6 */ +#define SP_CLR_SIG7 (1 << 23) /* clear signal 7 */ +#define SP_SET_SIG7 (1 << 24) /* set signal 7 */ /* * SP_STATUS_REG: read bits @@ -264,44 +264,44 @@ /* * SP_IBIST_REG: write bits */ -#define SP_IBIST_CHECK (1 << 0) // BIST check -#define SP_IBIST_GO (1 << 1) // BIST go -#define SP_IBIST_CLEAR (1 << 2) // BIST clear +#define SP_IBIST_CHECK (1 << 0) /* BIST check */ +#define SP_IBIST_GO (1 << 1) /* BIST go */ +#define SP_IBIST_CLEAR (1 << 2) /* BIST clear */ /* * SP_BIST_REG: read bits * First 2 bits are same as in write mode */ #define SP_IBIST_DONE (1 << 2) -#define SP_IBIST_FAILED 0x78 // bits [6:3], BIST fail +#define SP_IBIST_FAILED 0x78 /* bits [6:3], BIST fail */ /** * Display Processor Command (DPC) Registers */ #define DPC_BASE_REG 0x04100000 -//! DP CMD DMA start (R/W): [23:0] DMEM/RDRAM start address +/* DP CMD DMA start (R/W): [23:0] DMEM/RDRAM start address */ #define DPC_START_REG (DPC_BASE_REG + 0x00) -//! DP CMD DMA end (R/W): [23:0] DMEM/RDRAM end address +/* DP CMD DMA end (R/W): [23:0] DMEM/RDRAM end address */ #define DPC_END_REG (DPC_BASE_REG + 0x04) -//! DP CMD DMA end (R): [23:0] DMEM/RDRAM current address +/* DP CMD DMA end (R): [23:0] DMEM/RDRAM current address */ #define DPC_CURRENT_REG (DPC_BASE_REG + 0x08) -//! DP CMD status (R/W): [9:0] valid bits - see below for definitions +/* DP CMD status (R/W): [9:0] valid bits - see below for definitions */ #define DPC_STATUS_REG (DPC_BASE_REG + 0x0C) -//! DP clock counter (R): [23:0] clock counter +/* DP clock counter (R): [23:0] clock counter */ #define DPC_CLOCK_REG (DPC_BASE_REG + 0x10) -//! DP buffer busy counter (R): [23:0] clock counter +/* DP buffer busy counter (R): [23:0] clock counter */ #define DPC_BUFBUSY_REG (DPC_BASE_REG + 0x14) -//! DP pipe busy counter (R): [23:0] clock counter +/* DP pipe busy counter (R): [23:0] clock counter */ #define DPC_PIPEBUSY_REG (DPC_BASE_REG + 0x18) -//! DP TMEM load counter (R): [23:0] clock counter +/* DP TMEM load counter (R): [23:0] clock counter */ #define DPC_TMEM_REG (DPC_BASE_REG + 0x1C) /** @@ -338,16 +338,16 @@ */ #define DPS_BASE_REG 0x04200000 -//! DP tmem built-in self-test (R/W): [10:0] BIST status bits +/* DP tmem built-in self-test (R/W): [10:0] BIST status bits */ #define DPS_TBIST_REG (DPS_BASE_REG + 0x00) -//! DP span test mode (R/W): [0] Span buffer test access enable +/* DP span test mode (R/W): [0] Span buffer test access enable */ #define DPS_TEST_MODE_REG (DPS_BASE_REG + 0x04) -//! DP span buffer test address (R/W): [6:0] bits +/* DP span buffer test address (R/W): [6:0] bits */ #define DPS_BUFTEST_ADDR_REG (DPS_BASE_REG + 0x08) -//! DP span buffer test data (R/W): [31:0] span buffer data +/* DP span buffer test data (R/W): [31:0] span buffer data */ #define DPS_BUFTEST_DATA_REG (DPS_BASE_REG + 0x0C) /* @@ -362,7 +362,7 @@ * First 2 bits are same as in write mode */ #define DPS_TBIST_DONE (1 << 2) -#define DPS_TBIST_FAILED 0x7F8 // bits [10:3], BIST fail +#define DPS_TBIST_FAILED 0x7F8 /* bits [10:3], BIST fail */ /** * MIPS Interface (MI) Registers @@ -395,11 +395,11 @@ #define MI_MODE_EBUS (1 << 8) /* ebus test mode */ #define MI_MODE_RDRAM (1 << 9) /* RDRAM reg mode */ -//! MI version (R): [7:0] io, [15:8] rac, [23:16] rdp, [31:24] rsp +/* MI version (R): [7:0] io, [15:8] rac, [23:16] rdp, [31:24] rsp */ #define MI_VERSION_REG (MI_BASE_REG + 0x04) #define MI_NOOP_REG MI_VERSION_REG -//! MI interrupt (R): [5:0] valid bits - see below for bit patterns +/* MI interrupt (R): [5:0] valid bits - see below for bit patterns */ #define MI_INTR_REG (MI_BASE_REG + 0x08) /* @@ -792,27 +792,27 @@ */ #define SI_BASE_REG 0x04800000 -//! SI DRAM address (R/W): [23:0] starting RDRAM address +/* SI DRAM address (R/W): [23:0] starting RDRAM address */ #define SI_DRAM_ADDR_REG (SI_BASE_REG + 0x00) -//! SI address read 64B (W): [] write begins a 64B DMA write PIF RAM -> RDRAM +/* SI address read 64B (W): [] write begins a 64B DMA write PIF RAM -> RDRAM */ #define SI_PIF_ADDR_RD64B_REG (SI_BASE_REG + 0x04) -//! Address SI_BASE_REG + (0x08, 0x0C, 0x14) are reserved +/* Address SI_BASE_REG + (0x08, 0x0C, 0x14) are reserved */ -//! SI address write 64B (W): [] write begins a 64B DMA read RDRAM -> PIF RAM */ +/* SI address write 64B (W): [] write begins a 64B DMA read RDRAM -> PIF RAM */ #define SI_PIF_ADDR_WR64B_REG (SI_BASE_REG + 0x10) -//! SI status (R/W): [] any write clears interrupt +/* SI status (R/W): [] any write clears interrupt */ #define SI_STATUS_REG (SI_BASE_REG + 0x18) /* * SI_STATUS_REG: read bits */ -#define SI_STATUS_DMA_BUSY (1 << 0) // DMA in progress -#define SI_STATUS_RD_BUSY (1 << 1) // IO access in progress -#define SI_STATUS_DMA_ERROR (1 << 3) // Overlapping DMA requests -#define SI_STATUS_INTERRUPT (1 << 12) // Interrupt is set +#define SI_STATUS_DMA_BUSY (1 << 0) /* DMA in progress */ +#define SI_STATUS_RD_BUSY (1 << 1) /* IO access in progress */ +#define SI_STATUS_DMA_ERROR (1 << 3) /* Overlapping DMA requests */ +#define SI_STATUS_INTERRUPT (1 << 12) /* Interrupt is set */ /** * Development Board GIO Control Registers diff --git a/lib/ultralib/include/PR/region.h b/lib/ultralib/include/PR/region.h index 0ac8a25..0ac8a25 100755..100644 --- a/lib/ultralib/include/PR/region.h +++ b/lib/ultralib/include/PR/region.h diff --git a/lib/ultralib/include/asm.h b/lib/ultralib/include/asm.h new file mode 100644 index 0000000..1de9f0a --- /dev/null +++ b/lib/ultralib/include/asm.h @@ -0,0 +1 @@ +#include <sys/asm.h> diff --git a/lib/ultralib/include/assert.h b/lib/ultralib/include/assert.h index 7f1989a..bfbf255 100644 --- a/lib/ultralib/include/assert.h +++ b/lib/ultralib/include/assert.h @@ -6,7 +6,7 @@ #define assert(EX) ((void)0) #else extern void __assert(const char *, const char *, int); -#define assert(EX) ((EX)?((void)0):__assert( # EX , __FILE__, __LINE__)) +#define assert(EX) ((EX)?((void)0):__assert("EX", __FILE__, __LINE__)) #endif /* NDEBUG */ #endif /* !__ASSERT_H__ */ diff --git a/lib/ultralib/include/fpregdef.h b/lib/ultralib/include/fpregdef.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/lib/ultralib/include/fpregdef.h diff --git a/lib/ultralib/include/gcc/stdarg.h b/lib/ultralib/include/gcc/stdarg.h index af337f6..af337f6 100755..100644 --- a/lib/ultralib/include/gcc/stdarg.h +++ b/lib/ultralib/include/gcc/stdarg.h diff --git a/lib/ultralib/include/gcc/string.h b/lib/ultralib/include/gcc/string.h index d82e1f1..d82e1f1 100755..100644 --- a/lib/ultralib/include/gcc/string.h +++ b/lib/ultralib/include/gcc/string.h diff --git a/lib/ultralib/include/ido/math.h b/lib/ultralib/include/ido/math.h new file mode 100644 index 0000000..3e93ceb --- /dev/null +++ b/lib/ultralib/include/ido/math.h @@ -0,0 +1 @@ +// Nothing needed here diff --git a/lib/ultralib/include/ido/memory.h b/lib/ultralib/include/ido/memory.h new file mode 100644 index 0000000..edfff5e --- /dev/null +++ b/lib/ultralib/include/ido/memory.h @@ -0,0 +1,23 @@ +#ifndef _MEMORY_H +#define _MEMORY_H +/* + memory.h +*/ + +#ifndef _SIZE_T_DEF +#define _SIZE_T_DEF +typedef unsigned size_t; +#endif + +void *memccpy(void *,void *,int,size_t); +void *memchr(void *,int,size_t); +int memcmp(const void *,const void *,size_t); +void *memcpy(void *,const void *,size_t); +int memicmp(void *,void *,size_t); +void *memmove(void *,void *,size_t); +void *memset(void *,int,size_t); + +void movmem(void *,void *,unsigned); +void setmem(void *,unsigned,int); + +#endif diff --git a/lib/ultralib/include/ido/stdarg.h b/lib/ultralib/include/ido/stdarg.h new file mode 100644 index 0000000..62f68e0 --- /dev/null +++ b/lib/ultralib/include/ido/stdarg.h @@ -0,0 +1,33 @@ +#ifndef _STDARG_H +#define _STDARG_H + +typedef char *va_list; +#define _FP 1 +#define _INT 0 +#define _STRUCT 2 + +#define _VA_FP_SAVE_AREA 0x10 +#define _VA_ALIGN(p, a) (((unsigned int)(((char *)p) + ((a) > 4 ? (a) : 4) - 1)) & -((a) > 4 ? (a) : 4)) +#define va_start(vp, parmN) (vp = ((va_list)&parmN + sizeof(parmN))) + +#define __va_stack_arg(list, mode) \ + ( \ + ((list) = (char *)_VA_ALIGN(list, __builtin_alignof(mode)) + \ + _VA_ALIGN(sizeof(mode), 4)), \ + (((char *)list) - (_VA_ALIGN(sizeof(mode), 4) - sizeof(mode)))) + +#define __va_double_arg(list, mode) \ + ( \ + (((long)list & 0x1) /* 1 byte aligned? */ \ + ? (list = (char *)((long)list + 7), (char *)((long)list - 6 - _VA_FP_SAVE_AREA)) \ + : (((long)list & 0x2) /* 2 byte aligned? */ \ + ? (list = (char *)((long)list + 10), (char *)((long)list - 24 - _VA_FP_SAVE_AREA)) \ + : __va_stack_arg(list, mode)))) + +#define va_arg(list, mode) ((mode *)(((__builtin_classof(mode) == _FP && \ + __builtin_alignof(mode) == sizeof(double)) \ + ? __va_double_arg(list, mode) \ + : __va_stack_arg(list, mode))))[-1] +#define va_end(__list) + +#endif /* STDARG_H */ diff --git a/lib/ultralib/include/ido/stdio.h b/lib/ultralib/include/ido/stdio.h new file mode 100644 index 0000000..3e93ceb --- /dev/null +++ b/lib/ultralib/include/ido/stdio.h @@ -0,0 +1 @@ +// Nothing needed here diff --git a/lib/ultralib/include/ido/stdlib.h b/lib/ultralib/include/ido/stdlib.h new file mode 100644 index 0000000..98f8a2e --- /dev/null +++ b/lib/ultralib/include/ido/stdlib.h @@ -0,0 +1,81 @@ +#ifndef _STDLIB_H +#define _STDLIB_H +/* + stdlib.h +*/ + +#ifndef _SIZE_T_DEF +#define _SIZE_T_DEF +typedef unsigned size_t; +#endif + +#ifndef _DIV_T_DEF +#define _DIV_T_DEF +typedef struct DIV_T { + int quot; + int rem; +} div_t; +#endif + +#ifndef _LDIV_T_DEF +#define _LDIV_T_DEF +typedef struct LDIV_T { + long quot; + long rem; +} ldiv_t; +#endif + +#ifndef _LLDIV_T_DEF +#define _LLDIV_T_DEF +typedef struct lldiv_t +{ + long long quot; + long long rem; +} lldiv_t; +#endif + +#ifndef NULL +#define NULL 0 +#endif + +#define _max(a,b) (((a) > (b)) ? (a) : (b)) +#define _min(a,b) (((a) < (b)) ? (a) : (b)) + +#define RAND_MAX 32767 + +int rand(void); +void srand(unsigned); + +int abs(int); +long labs(long); + +div_t div(int,int); +ldiv_t ldiv(long,long); +lldiv_t lldiv(long long, long long); + +int atoi(const char *); +long atol(const char *); + +long strtol(const char *,char **,int); +unsigned long strtoul(const char *,char **,int); + +char *itoa(int,char *,int); +char *ltoa(long,char *,int); +char *ultoa(unsigned long,char *,int); + +double atof(const char *); +double strtod(const char *,char **); + +void qsort(void *,size_t,size_t,int (*)(const void *,const void *)); +void *bsearch(const void *,const void *,size_t,size_t,int (*)(const void *,const void *)); + +void *malloc(size_t); +void *calloc(size_t,size_t); +void *realloc(void *,size_t); +void free(void *); + +void exit(int); + +void abort(void); + +#endif diff --git a/lib/ultralib/include/ido/string.h b/lib/ultralib/include/ido/string.h new file mode 100644 index 0000000..d82e1f1 --- /dev/null +++ b/lib/ultralib/include/ido/string.h @@ -0,0 +1,42 @@ +#ifndef _STRING_H +#define _STRING_H +/* + string.h +*/ + +#ifndef _SIZE_T_DEF +#define _SIZE_T_DEF +typedef unsigned size_t; +#endif + +#include "memory.h" + +char *stpcpy(char *,const char *); +char *strcat(char *,const char *); +char *strchr(const char *,int); +int strcmp(const char *,const char *); +char *strcpy(char *,const char *); +size_t strcspn(const char *,const char *); +char *strdup(const char *); +char *strerror(int); +int stricmp(const char *,const char *); +size_t strlen(const char *); +char *strlwr(char *); +char *strncat(char *,const char *,size_t); +int strncmp(const char *,const char *,size_t); +char *strncpy(char *,const char *,size_t); +int strnicmp(const char *,const char *,size_t); +char *strnset(char *,int,size_t); +char *strpbrk(const char *,const char *); +char *strrchr(const char *,int); +char *strrev(char *); +char *strset(char *,int); +size_t strspn(const char *,const char *); +char *strstr(const char *,const char *); +char *strtok(char *,const char *); +char *strupr(char *); + +#define strcmpi(s1,s2) stricmp(s1,s2) +#define strncmpi(s1,s2,n) strnicmp(s1,s2,n) + +#endif diff --git a/lib/ultralib/include/macros.h b/lib/ultralib/include/macros.h index f726659..3057fc8 100644 --- a/lib/ultralib/include/macros.h +++ b/lib/ultralib/include/macros.h @@ -5,7 +5,7 @@ #define ARRLEN(x) ((s32)(sizeof(x) / sizeof(x[0]))) -#define STUBBED_PRINTF(x) +#define STUBBED_PRINTF(x) ((void)(x)) #define UNUSED __attribute__((unused)) diff --git a/lib/ultralib/include/regdef.h b/lib/ultralib/include/regdef.h new file mode 100644 index 0000000..c29cc69 --- /dev/null +++ b/lib/ultralib/include/regdef.h @@ -0,0 +1,3 @@ +#include <sys/regdef.h> +#include <sgidefs.h> +#include <sys/fpregdef.h> diff --git a/lib/ultralib/include/sgidefs.h b/lib/ultralib/include/sgidefs.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/lib/ultralib/include/sgidefs.h diff --git a/lib/ultralib/include/sys/asm.h b/lib/ultralib/include/sys/asm.h index 445a2bf..97f8fb2 100644 --- a/lib/ultralib/include/sys/asm.h +++ b/lib/ultralib/include/sys/asm.h @@ -1,7 +1,7 @@ /************************************************************************ Copyright (C) 1998,1999 NINTENDO Co,Ltd, Copyright (C) 1998,1999 MONEGI CORPORATION, - All Rights Reserved + All Rights Reserved This program is a trade secret of NINTENDO Co,Ltd and MONEGI Corp. and it is not to be reproduced, published, disclosed to others, copied, adapted, distributed, or displayed without the prior authorization of @@ -22,48 +22,92 @@ modified versions thereof. extern "C" { #endif -#define _MIPS_ISA_MIPS1 1 /* R2/3K */ -#define _MIPS_ISA_MIPS2 2 /* R4K/6K */ -#define _MIPS_ISA_MIPS3 3 /* R4K */ -#define _MIPS_ISA_MIPS4 4 /* TFP */ - -#define _MIPS_SIM_ABI32 1 /* MIPS MSIG calling convention */ -#define _MIPS_SIM_NABI32 2 /* MIPS new 32-bit abi */ - /* NABI32 is 64bit calling convention but 32bit type sizes) */ -#define _MIPS_SIM_ABI64 3 /* MIPS 64 calling convention */ - -#define LEAF(x) \ - .globl x; \ - .ent x,0; \ -x:; \ - .frame sp,0,ra - -#define XLEAF(x) \ - .global x; - -#define END(proc) \ - .end proc - -#define ABS(x, y) \ - .globl x; \ - x = y - -#define EXPORT(x) \ - .globl x; \ -x: -/* -#define WEAK(x, y) \ - .weak x; \ - .set x,y; -*/ +#define _MIPS_ISA_MIPS1 1 /* R2/3K */ +#define _MIPS_ISA_MIPS2 2 /* R4K/6K */ +#define _MIPS_ISA_MIPS3 3 /* R4K */ +#define _MIPS_ISA_MIPS4 4 /* TFP */ +#define _MIPS_SIM_ABI32 1 /* MIPS MSIG calling convention */ +#define _MIPS_SIM_NABI32 2 /* MIPS new 32-bit abi */ + /* NABI32 is 64bit calling convention but 32bit type sizes) */ +#define _MIPS_SIM_ABI64 3 /* MIPS 64 calling convention */ + + +/* libgultra doesn't match with the .type directive but iQue sdk asm.h uses it */ +#ifdef BBPLAYER +#define ASM_TYPE_FUNC(x) .type x, @function +#else +#define ASM_TYPE_FUNC(x) +#endif + +#define LEAF(x) \ + .globl x ;\ + .align 2 ;\ + ASM_TYPE_FUNC(x) ;\ + .ent x,0 ;\ + x: ;\ + .frame sp,0,ra + +#if defined(BBPLAYER) || defined(__sgi) +#define XLEAF(x) \ + .globl x ;\ + .aent x,0 ;\ + x: +#else +#define XLEAF(x) \ + .globl x +#endif + +#ifdef BBPLAYER +#define END(proc) \ + .end proc ;\ + .size proc, . - proc +#else +#define END(proc) \ + .end proc +#endif + +#define ABS(x, y) \ + .globl x ;\ + x = y + +#define EXPORT(x) \ + .globl x ;\ + x: + +#if defined(BBPLAYER) || defined(__sgi) +#define WEAK(x, y) \ + .weakext x, y +#else #define WEAK(x, y) +#endif + + + +#define STAY1(stmnt) \ + .set noreorder ;\ + stmnt ;\ + .set reorder + +#define STAY2(stmnt, arg1) \ + .set noreorder ;\ + stmnt, arg1 ;\ + .set reorder + +#define STAY3(stmnt, arg1, arg2) \ + .set noreorder ;\ + stmnt, arg1, arg2 ;\ + .set reorder + +#define NOP \ + .set noreorder ;\ + nop ;\ + .set reorder -#define STAY1(stmnt) .set noreorder; stmnt; .set reorder; -#define STAY2(stmnt, arg1) .set noreorder; stmnt, arg1; .set reorder; -#define STAY3(stmnt, arg1, arg2) .set noreorder; stmnt, arg1, arg2; .set reorder; -#define NOP .set noreorder; nop; .set reorder; -#define CACHE(op, reg) .set noreorder; cache op, reg; .set reorder; +#define CACHE(op, reg) \ + .set noreorder ;\ + cache op, reg ;\ + .set reorder #ifdef __cplusplus } diff --git a/lib/ultralib/include/sys/fpregdef.h b/lib/ultralib/include/sys/fpregdef.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/lib/ultralib/include/sys/fpregdef.h diff --git a/lib/ultralib/src/audio/csplayer.c b/lib/ultralib/src/audio/csplayer.c index 621ce02..66999f7 100644 --- a/lib/ultralib/src/audio/csplayer.c +++ b/lib/ultralib/src/audio/csplayer.c @@ -43,11 +43,8 @@ #include "seqp.h" #include "cseqp.h" #include "cseq.h" - // TODO: this comes from a header #ident "$Revision: 1.17 $" - - static ALMicroTime __CSPVoiceHandler(void *node); static void __CSPHandleNextSeqEvent(ALCSPlayer *seqp); static void __CSPHandleMIDIMsg(ALCSPlayer *seqp, ALEvent *event); diff --git a/lib/ultralib/src/audio/drvrnew.c b/lib/ultralib/src/audio/drvrnew.c index ef9e27f..7ca2e10 100644 --- a/lib/ultralib/src/audio/drvrnew.c +++ b/lib/ultralib/src/audio/drvrnew.c @@ -17,16 +17,13 @@ * DOD or NASA FAR Supplement. Unpublished - rights reserved under the * Copyright Laws of the United States. *====================================================================*/ - #include <libaudio.h> #include "synthInternals.h" #include <os.h> #include <stdio.h> #include "initfx.h" - // TODO: this comes from a header #ident "$Revision: 1.49 $" - /* * WARNING: THE FOLLOWING CONSTANT MUST BE KEPT IN SYNC * WITH SCALING IN MICROCODE!!! diff --git a/lib/ultralib/src/audio/env.c b/lib/ultralib/src/audio/env.c index bc7369a..9a11e23 100644 --- a/lib/ultralib/src/audio/env.c +++ b/lib/ultralib/src/audio/env.c @@ -17,24 +17,20 @@ * DOD or NASA FAR Supplement. Unpublished - rights reserved under the * Copyright Laws of the United States. *====================================================================*/ - #include <libaudio.h> #include "synthInternals.h" #include <os.h> #include <stdio.h> #include <math.h> #include <assert.h> - // TODO: these come from headers #ident "$Revision: 1.49 $" #ident "$Revision: 1.17 $" - #ifdef AUD_PROFILE extern u32 cnt_index, env_num, env_cnt, env_max, env_min, lastCnt[]; extern u32 rate_num, rate_cnt, rate_max, rate_min; extern u32 vol_num, vol_cnt, vol_max, vol_min; #endif - #define EQPOWER_LENGTH 128 static s16 eqpower[ EQPOWER_LENGTH ] = { 32767, 32764, 32757, 32744, 32727, 32704, diff --git a/lib/ultralib/src/audio/reverb.c b/lib/ultralib/src/audio/reverb.c index 292ed0f..8558169 100644 --- a/lib/ultralib/src/audio/reverb.c +++ b/lib/ultralib/src/audio/reverb.c @@ -8,7 +8,6 @@ * Inc.; the contents of this file may not be disclosed to third * parties, copied or duplicated in any form, in whole or in part, * without the prior written permission of Silicon Graphics, Inc. - * * RESTRICTED RIGHTS LEGEND: * Use, duplication or disclosure by the Government is subject to * restrictions as set forth in subdivision (c)(1)(ii) of the Rights @@ -17,7 +16,6 @@ * DOD or NASA FAR Supplement. Unpublished - rights reserved under the * Copyright Laws of the United States. *====================================================================*/ - #include <libaudio.h> #include <ultraerror.h> #include "synthInternals.h" @@ -26,11 +24,9 @@ #include <stdio.h> #include <assert.h> #include "initfx.h" - // TODO: these come from headers #ident "$Revision: 1.49 $" #ident "$Revision: 1.17 $" - #define RANGE 2.0 extern ALGlobals *alGlobals; diff --git a/lib/ultralib/src/audio/save.c b/lib/ultralib/src/audio/save.c index bc15294..ec6a0bf 100644 --- a/lib/ultralib/src/audio/save.c +++ b/lib/ultralib/src/audio/save.c @@ -3,7 +3,6 @@ * * Copyright 1993, Silicon Graphics, Inc. * All Rights Reserved. - * * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, * Inc.; the contents of this file may not be disclosed to third * parties, copied or duplicated in any form, in whole or in part, @@ -17,12 +16,10 @@ * DOD or NASA FAR Supplement. Unpublished - rights reserved under the * Copyright Laws of the United States. *====================================================================*/ - #include <libaudio.h> #include "synthInternals.h" #include <os.h> #include <assert.h> - // TODO: this comes from a header #ident "$Revision: 1.17 $" diff --git a/lib/ultralib/src/audio/seqpdelete.c b/lib/ultralib/src/audio/seqpdelete.c index b4f11fd..8e283b1 100644 --- a/lib/ultralib/src/audio/seqpdelete.c +++ b/lib/ultralib/src/audio/seqpdelete.c @@ -1,8 +1,6 @@ /*==================================================================== * seqpdelete.c * - * Synopsis: - * * Copyright 1995, Silicon Graphics, Inc. * All Rights Reserved. * @@ -22,7 +20,6 @@ #include <libaudio.h> #include <assert.h> - // TODO: this comes from a header #ident "$Revision: 1.17 $" diff --git a/lib/ultralib/src/audio/seqplayer.c b/lib/ultralib/src/audio/seqplayer.c index 3b83257..a25d624 100644 --- a/lib/ultralib/src/audio/seqplayer.c +++ b/lib/ultralib/src/audio/seqplayer.c @@ -3,12 +3,10 @@ * * Copyright 1993, Silicon Graphics, Inc. * All Rights Reserved. - * * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, * Inc.; the contents of this file may not be disclosed to third * parties, copied or duplicated in any form, in whole or in part, * without the prior written permission of Silicon Graphics, Inc. - * * RESTRICTED RIGHTS LEGEND: * Use, duplication or disclosure by the Government is subject to * restrictions as set forth in subdivision (c)(1)(ii) of the Rights @@ -17,7 +15,6 @@ * DOD or NASA FAR Supplement. Unpublished - rights reserved under the * Copyright Laws of the United States. *====================================================================*/ - /* * Notes: * diff --git a/lib/ultralib/src/audio/sndplayer.c b/lib/ultralib/src/audio/sndplayer.c index 391e6ac..8f44b43 100644 --- a/lib/ultralib/src/audio/sndplayer.c +++ b/lib/ultralib/src/audio/sndplayer.c @@ -3,12 +3,10 @@ * * Copyright 1993, Silicon Graphics, Inc. * All Rights Reserved. - * * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, * Inc.; the contents of this file may not be disclosed to third * parties, copied or duplicated in any form, in whole or in part, * without the prior written permission of Silicon Graphics, Inc. - * * RESTRICTED RIGHTS LEGEND: * Use, duplication or disclosure by the Government is subject to * restrictions as set forth in subdivision (c)(1)(ii) of the Rights diff --git a/lib/ultralib/src/audio/synthesizer.c b/lib/ultralib/src/audio/synthesizer.c index d42a21a..e499691 100644 --- a/lib/ultralib/src/audio/synthesizer.c +++ b/lib/ultralib/src/audio/synthesizer.c @@ -3,12 +3,10 @@ * * Copyright 1993, Silicon Graphics, Inc. * All Rights Reserved. - * * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, * Inc.; the contents of this file may not be disclosed to third * parties, copied or duplicated in any form, in whole or in part, * without the prior written permission of Silicon Graphics, Inc. - * * RESTRICTED RIGHTS LEGEND: * Use, duplication or disclosure by the Government is subject to * restrictions as set forth in subdivision (c)(1)(ii) of the Rights @@ -17,7 +15,6 @@ * DOD or NASA FAR Supplement. Unpublished - rights reserved under the * Copyright Laws of the United States. *====================================================================*/ - #include "synthInternals.h" #include <assert.h> diff --git a/lib/ultralib/src/debug/assert.c b/lib/ultralib/src/debug/assert.c new file mode 100644 index 0000000..4bf6f1e --- /dev/null +++ b/lib/ultralib/src/debug/assert.c @@ -0,0 +1,10 @@ +#include "os.h" +#include "../os/osint.h" +#include "osint_debug.h" + +void __assertBreak(void); + +void __assert(const char* exp, const char* filename, int line) { + osSyncPrintf("\nASSERTION FAULT: %s, %d: \"%s\"\n", filename, line, exp); + __assertBreak; // Doesn't actually do anything, but is needed for matching +} diff --git a/lib/ultralib/src/debug/assertbreak.s b/lib/ultralib/src/debug/assertbreak.s new file mode 100644 index 0000000..2837980 --- /dev/null +++ b/lib/ultralib/src/debug/assertbreak.s @@ -0,0 +1,12 @@ +#ifndef _FINALROM +#include "sys/asm.h" +#include "sys/regdef.h" + +.set noreorder + +LEAF(__assertBreak) + break 0 + j ra +END(__assertBreak) + +#endif diff --git a/lib/ultralib/src/debug/atomic.c b/lib/ultralib/src/debug/atomic.c new file mode 100644 index 0000000..a0bd8fe --- /dev/null +++ b/lib/ultralib/src/debug/atomic.c @@ -0,0 +1,16 @@ +#include "PR/os_internal.h" + +int __osAtomicDec(unsigned int* p) { + u32 mask; + int result; + + mask = __osDisableInt(); + if (*p) { + (*p)--; + result = 1; + } else { + result = 0; + } + __osRestoreInt(mask); + return result; +} diff --git a/lib/ultralib/src/os/kdebugserver.c b/lib/ultralib/src/debug/kdebugserver.c index 85dc172..948a460 100644 --- a/lib/ultralib/src/os/kdebugserver.c +++ b/lib/ultralib/src/debug/kdebugserver.c @@ -1,13 +1,13 @@ #include "PR/os_internal.h" #include "PR/rcp.h" #include "PR/rdb.h" -#include "osint.h" - -extern u32 __osRdb_IP6_Empty; // not included in final rom, but __osThreadSave is here for some reason OSThread __osThreadSave; +extern OSThread *__osRunningThread; +extern u32 __osRdb_IP6_Empty; + #ifndef _FINALROM static u8 buffer[12]; @@ -34,14 +34,14 @@ static void send_packet(u8* s, u32 n) { for (i = 0; i < n; i++) { packet.buf[i] = s[i]; } - *(rdbPacket*)RDB_BASE_REG = packet; + *(vu32*)RDB_BASE_REG = *(u32*)&packet; } static void clear_IP6(void) { while (!(__osGetCause() & CAUSE_IP6)) { ; } - *(u32*)RDB_READ_INTR_REG = 0; + *(vu32*)RDB_READ_INTR_REG = 0; while (__osGetCause() & CAUSE_IP6) { ; diff --git a/lib/ultralib/src/debug/osint_debug.h b/lib/ultralib/src/debug/osint_debug.h index b493035..6d644f2 100644 --- a/lib/ultralib/src/debug/osint_debug.h +++ b/lib/ultralib/src/debug/osint_debug.h @@ -4,8 +4,8 @@ extern s32 __osThprofFlag; extern void (*__osThprofFunc)(OSThread*); extern u32 __osThprofLastTimer; extern u32 __osThprofCount; -extern __OSThreadprofile_s thprof[THPROF_IDMAX]; -extern u64 __osThprofHeap[THPROF_STACKSIZE]; +extern __OSThreadprofile_s thprof[]; +extern u64 __osThprofHeap[]; extern void* __osThprofStack; void osThreadProfileCallback(OSThread*); diff --git a/lib/ultralib/src/debug/profile.c b/lib/ultralib/src/debug/profile.c new file mode 100644 index 0000000..e98d192 --- /dev/null +++ b/lib/ultralib/src/debug/profile.c @@ -0,0 +1,176 @@ +#include "PR/rdb.h" +#include "PR/ultratypes.h" +#include "PR/os.h" +#include "PR/ultraerror.h" +#include "PR/ultralog.h" +#include "PR/sptask.h" +#include "../os/osint.h" +#include "macros.h" +#include "osint_debug.h" + +#ifndef _FINALROM + +OSTimer __osProfTimer; +OSMesg __osProfTimerMsg; + +OSMesgQueue __osProfFlushMQ ALIGNED(8); +OSMesg __osProfFlushMesg; + +OSMesgQueue __osProfAckMQ ALIGNED(8); +OSMesg __osProfAckMesg; + +u32 __osProfTimerPeriod; + +u32 __osProfNumSections; + +static u32 __osProfileActive = FALSE; +static u32 __osProfileIOActive = FALSE; + +unsigned char __osProfileIOStack[2400] ALIGNED(16); + +static OSThread __osProfileIOThread; + +void osProfSendWord(u32 word); + +void __osProfileIO(void* arg) { + s32 totalBytes; + u32 bytesThisBlock; + u32 ct; + u8* sendPtr; + OSProf* t; + + while (TRUE) { + osRecvMesg(&__osProfFlushMQ, NULL, OS_MESG_BLOCK); + osProfSendWord(__osProfNumSections); + osProfSendWord(__osProfTimerPeriod); + osProfSendWord(__osProfileOverflowBin); + + for (t = __osProfileList; t < __osProfileListEnd; t++) { + osProfSendWord(t->text_start); + osProfSendWord(t->histo_size); + osRecvMesg(&__osProfAckMQ, NULL, OS_MESG_BLOCK); + + totalBytes = t->histo_size * 2; + sendPtr = t->histo_base; + while (totalBytes > 0) { + bytesThisBlock = (totalBytes < 0x800U) ? totalBytes : 0x800U; + + ct = 0; + while (ct < bytesThisBlock) { + ct += __osRdbSend(sendPtr + ct, bytesThisBlock - ct, RDB_TYPE_GtoH_PROF_DATA); + } + + sendPtr += bytesThisBlock; + totalBytes -= bytesThisBlock; + osRecvMesg(&__osProfAckMQ, NULL, OS_MESG_BLOCK); + } + } + } +} + +void osProfSendWord(u32 word) { + u32 ct = 0; + u8* sendPtr = &word; + + while (ct < sizeof(word)) { + ct += __osRdbSend(sendPtr + ct, sizeof(word) - ct, RDB_TYPE_GtoH_PROF_DATA); + } +} + +void osProfileFlush(void) { + osSendMesg(&__osProfFlushMQ, NULL, OS_MESG_BLOCK); +} + +void osProfileInit(OSProf* profp, u32 profcnt) { + u32 i; + OSProf* t; + +#ifndef NDEBUG + if (__osProfileActive) { + __osError(ERR_OSPROFILEINIT_STR, 0); + return; + } + + if (profcnt == 0) { + __osError(ERR_OSPROFILEINIT_CNT, 1, profcnt); + return; + } +#endif + + for (t = profp; t < profp + profcnt; t++) { +#ifndef NDEBUG + if ((u32)t->histo_base & 1) { + __osError(ERR_OSPROFILEINIT_ALN, 1, t->histo_base); + return; + } + + if (t->text_start >= t->text_end) { + __osError(ERR_OSPROFILEINIT_ORD, 2, t->text_start, t->text_end); + return; + } + + if (((u32)(t->text_end - t->text_start) / 4) > t->histo_size) { + __osError(ERR_OSPROFILEINIT_SIZ, 1, t->histo_size); + return; + } +#endif + + for (i = 0; i < t->histo_size; i++) { + t->histo_base[i] = 0; + } + } + + __osProfileActive = FALSE; + __osProfileOverflowBin = 0; + __osProfileList = profp; + __osProfileListEnd = profp + profcnt; + __osProfNumSections = profcnt; + if (!__osProfileIOActive) { + osCreateMesgQueue(&__osProfFlushMQ, &__osProfFlushMesg, 1); + osSetEventMesg(OS_EVENT_RDB_FLUSH_PROF, &__osProfFlushMQ, 0); + osCreateMesgQueue(&__osProfAckMQ, &__osProfAckMesg, 1); + osSetEventMesg(OS_EVENT_RDB_ACK_PROF, &__osProfAckMQ, 0); + osCreateThread(&__osProfileIOThread, 0, __osProfileIO, NULL, &__osProfileIOStack[2400], 0x81); + osStartThread(&__osProfileIOThread); + __osProfileIOActive = TRUE; + } +} + +void osProfileStart(u32 microseconds) { +#ifndef NDEBUG + if (microseconds < 50) { + __osError(ERR_OSPROFILESTART_TIME, 1, microseconds); + return; + } + + if (__osProfileActive) { + __osError(ERR_OSPROFILESTART_FLAG, 0); + return; + } +#endif + + osCreateMesgQueue(&__osProfTimerQ, &__osProfTimerMsg, 1); + osSetTimer(&__osProfTimer, 0, OS_USEC_TO_CYCLES(microseconds), &__osProfTimerQ, NULL); + __osProfTimerPeriod = microseconds; + __osProfileActive = TRUE; +} + +void osProfileStop(void) { +#ifndef NDEBUG + if (!__osProfileActive) { + __osError(ERR_OSPROFILESTOP_FLAG, 0); + return; + } +#endif + + if (osStopTimer(&__osProfTimer) < 0) { +#ifndef NDEBUG + __osError(ERR_OSPROFILESTOP_TIMER, 0); + return; +#endif + } + + __osProfileActive = FALSE; +} + +#endif diff --git a/lib/ultralib/src/debug/threadprofilereadcount.c b/lib/ultralib/src/debug/threadprofilereadcount.c index c12d313..3237987 100644 --- a/lib/ultralib/src/debug/threadprofilereadcount.c +++ b/lib/ultralib/src/debug/threadprofilereadcount.c @@ -1,13 +1,17 @@ #include "osint_debug.h" u32 osThreadProfileReadCount(OSId id) { +#ifndef NDEBUG if (!__osThprofFlag) { __osError(139, 0); return 0; } +#endif if (id >= THPROF_IDMAX) { +#ifndef NDEBUG __osError(143, 1, id); +#endif return 0; } return thprof[id].count; @@ -16,15 +20,19 @@ u32 osThreadProfileReadCount(OSId id) { u32 osThreadProfileReadCountTh(OSThread* thread) { OSId id; +#ifndef NDEBUG if (!__osThprofFlag) { __osError(141, 0); return 0; } +#endif id = osGetThreadId(thread); if (id >= THPROF_IDMAX) { +#ifndef NDEBUG __osError(145, 1, id); +#endif return 0; } return thprof[id].count; diff --git a/lib/ultralib/src/debug/threadprofilereadtime.c b/lib/ultralib/src/debug/threadprofilereadtime.c index c5c4cca..9930cac 100644 --- a/lib/ultralib/src/debug/threadprofilereadtime.c +++ b/lib/ultralib/src/debug/threadprofilereadtime.c @@ -4,12 +4,16 @@ OSTime osThreadProfileReadTime(OSId id) { OSTime adjust = 0; u32 now_time = osGetCount(); +#ifndef NDEBUG if (!__osThprofFlag) { __osError(140, 0); return 0; } +#endif if (id >= THPROF_IDMAX) { +#ifndef NDEBUG __osError(144, 1, id); +#endif return 0; } @@ -24,15 +28,19 @@ OSTime osThreadProfileReadTimeTh(OSThread* thread) { OSTime adjust = 0; u32 now_time = osGetCount(); +#ifndef NDEBUG if (!__osThprofFlag) { __osError(142, 0); return 0; } +#endif id = osGetThreadId(thread); if (id >= THPROF_IDMAX) { +#ifndef NDEBUG __osError(146, 1, id); +#endif return 0; } diff --git a/lib/ultralib/src/debug/threadprofilestart.c b/lib/ultralib/src/debug/threadprofilestart.c index 0891ad7..3ef8fa7 100644 --- a/lib/ultralib/src/debug/threadprofilestart.c +++ b/lib/ultralib/src/debug/threadprofilestart.c @@ -2,7 +2,8 @@ void osThreadProfileStart(void) { register u32 saveMask; - + +#ifndef NDEBUG if (!__osThprofFlag) { __osError(136, 0); return; @@ -11,6 +12,7 @@ void osThreadProfileStart(void) { __osError(137, 0); return; } +#endif saveMask = __osDisableInt(); diff --git a/lib/ultralib/src/debug/threadprofilestop.c b/lib/ultralib/src/debug/threadprofilestop.c index 666d7cd..7cc20e7 100644 --- a/lib/ultralib/src/debug/threadprofilestop.c +++ b/lib/ultralib/src/debug/threadprofilestop.c @@ -8,11 +8,13 @@ void osThreadProfileStop(void) { saveMask = __osDisableInt(); +#ifndef NDEBUG if (__osThprofFlag == 0) { __osRestoreInt(saveMask); __osError(138, 0); return; } +#endif if (__osThprofFunc != NULL) { id = osGetThreadId(0); @@ -20,9 +22,11 @@ void osThreadProfileStop(void) { if (id < THPROF_IDMAX) { thprof[id].time += now_time - __osThprofLastTimer; } else { +#ifndef NDEBUG __osRestoreInt(saveMask); __osError(147, 1, id); saveMask = __osDisableInt(); +#endif } } __osThprofFunc = NULL; diff --git a/lib/ultralib/src/error/commonerror.c b/lib/ultralib/src/error/commonerror.c new file mode 100644 index 0000000..53cca55 --- /dev/null +++ b/lib/ultralib/src/error/commonerror.c @@ -0,0 +1,185 @@ +#include "PR/os.h" +#include "PR/os_internal.h" +#include "PR/sptask.h" +#include "PR/ultraerror.h" +#include "PR/ultralog.h" +#include "macros.h" +#include "stdarg.h" + +#ifndef _FINALROM + +static u32 errorLogData[19] ALIGNED(8); +static OSLog errorLog = { OS_ERROR_MAGIC, 76, errorLogData, 0, 0 }; + +static void __commonErrorHandler(s16 code, s16 numArgs, ...); +OSErrorHandler __osCommonHandler = __commonErrorHandler; + +char NULSTR[] = { '\0' }; + +const char* __os_error_message[] = { + NULSTR, + "osCreateThread: stack pointer not aligned to 8 bytes (0x%x)", + "osCreateThread: priority not in range [0-255] (%d)", + "osStartThread: thread has bad state (running/runnable/other)", + "osSetThreadPri: priority not in range [0-255] (%d)", + "osCreateMesgQueue: message count not > 0 (%d)", + "osSendMesg: flag not OS_MESG_NOBLOCK or OS_MESG_BLOCK (%d)", + "osJamMesg: flag not OS_MESG_NOBLOCK or OS_MESG_BLOCK (%d)", + "osRecvMesg: flag not OS_MESG_NOBLOCK or OS_MESG_BLOCK (%d)", + "osSetEventMesg: unknown event type (%d)", + "osMapTLB: index not in range [0-30] (%d)", + "osMapTLB: asid argument not -1 or in range [0-255] (%d)", + "osUnmapTLB: index not in range [0-30] (%d)", + "osSetTLBASID: asid not in range [0-255] (%d)", + "osAiSetFrequency: freq not in range [%d-%d] (%d)", + "osAiSetNextBuffer: address not aligned to 8 bytes (0x%x)", + "osAiSetNextBuffer: size not aligned to 8 bytes (0x%x)", + "osDpSetNextBuffer: address not aligned to 8 bytes (0x%x)", + "osDpSetNextBuffer: size not aligned to 8 bytes (0x%x)", + "osPiRawReadIo: address not aligned to 4 bytes (0x%x)", + "osPiRawWriteIo: address not aligned to 4 bytes (0x%x)", + "osPiRawStartDma: direction not OS_READ or OS_WRITE (%d)", + "osPiRawStartDma: device address not aligned to 2 bytes (0x%x)", + "osPiRawStartDma: DRAM address not aligned to 8 bytes (0x%x)", + "osPiRawStartDma: size not aligned to 2 bytes (%d)", + "osPiRawStartDma: size not in range [0,16777216] (%d)", + "osPiReadIo: address not aligned to 4 bytes (0x%x)", + "osPiWriteIo: address not aligned to 4 bytes (0x%x)", + "osPiStartDma: PI Manager not yet begun by osCreatePiManager", + "osPiStartDma: priority not OS_MESG_PRI_[NORMAL|HIGH] (%d)", + "osPiStartDma: direction not OS_READ or OS_WRITE (%d)", + "osPiStartDma: device address not aligned to 2 bytes (0x%x)", + "osPiStartDma: DRAM address not aligned to 8 bytes (0x%x)", + "osPiStartDma: size not aligned to 2 bytes (%d)", + "osPiStartDma: size not in range [0,16777216] (%d)", + "osCreatePiManager: priority not in range [0-255] (%d)", + "osViGetCurrentMode: VI Manager not yet begun", + "osViGetCurrentFramebuffer: VI Manager not yet begun", + "osViGetNextFramebuffer: VI Manager not yet begun", + "osViSetXScale: value not in range [0.25,1.0] (%f)", + "osViSetXScale: VI Manager not yet begun by osCreateViManager", + "osViSetYScale: value not in range [0.05,1.0] (%f)", + "osViSetYScale: VI Manager not yet begun by osCreateViManager", + "osViSetSpecialFeatures: not a known feature value (%d)", + "osViSetSpecialFeatures: VI Manager not yet begun", + "osViSetMode: VI Manager not yet begun by osCreateViManager", + "osViSetEvent: VI Manager not yet begun by osCreateViManager", + "osViSwapBuffer: frame buffer not aligned to 64 bytes (0x%x)", + "osViSwapBuffer: VI Manager not yet begun", + "osCreateViManager: priority not in range [0-255] (%d)", + "osCreateRegion: not a known alignment (%d)", + "osCreateRegion: length (%d) too small for buffer size (%d)", + "osMalloc: invalid or corrupt region (0x%x)", + "osFree: invalid or corrupt region (0x%x)", + "osFree: invalid address (0x%x) or\n corrupt region (0x%x)", + "osGetRegionBufCount: invalid or corrupt region (0x%x)", + "osGetRegionBufSize: invalid or corrupt region (0x%x)", + "osSpTaskLoad: dram_stack not aligned to 16 bytes (0x%x)", + "osSpTaskLoad: output_buff not aligned to 16 bytes (0x%x)", + "osSpTaskLoad: output_buff_size not aligned to 16 bytes (0x%x)", + "osSpTaskLoad: yield_data_ptr not aligned to 16 bytes (0x%x)", + "osProfileInit: profile counter is running, call osProfileStop before init", + "osProfileInit: profcnt is %d", + "osProfileInit: histo_base pointer must be 32-bit aligned (%x)", + "osProfileInit: text_start (%x) >= text_end (%x)", + "osProfileInit: histo_size is an illegal size (%d)", + "osProfileStart: microseconds is < PROF_MIN_INTERVAL (%d)", + "osProfileStart: profiling has already been started", + "osProfileStop: profiling has already been stopped", + "osProfileStop: no profile timer to stop", + "osReadHost: address not aligned to 8 bytes (0x%x)", + "osReadHost: size either 0 or not aligned to 4 bytes (0x%x)", + "osWriteHost: address not aligned to 8 bytes (0x%x)", + "osWriteHost: size either 0 or not aligned to 4 bytes (0x%x)", + "osGetTime: VI manager not yet begun by osCreateViManager", + "osSetTime: VI manager not yet begun by osCreateViManager", + "osSetTimer: VI manager not yet begun by osCreateViManager", + "osStopTimer: VI manager not yet begun by osCreateViManager", + NULSTR, + NULSTR, + NULSTR, + NULSTR, + NULSTR, + NULSTR, + NULSTR, + NULSTR, + NULSTR, + NULSTR, + NULSTR, + NULSTR, + NULSTR, + NULSTR, + NULSTR, + NULSTR, + NULSTR, + NULSTR, + NULSTR, + NULSTR, + NULSTR, + NULSTR, + "_handleMIDIMsg: no sound mapped", + "_handleMIDIMsg: no free voices", + "_handleMIDIMsg: couldn't map voice", + "_handleMIDIMsg: note off - couldn't find voice", + "_handleMIDIMsg: poly pressure - couldn't find voice", + "_handleEvent: no free voices", + "Synthesizer: no free updates", + "alSndPDeallocate: attempt to deallocate a sound which is playing", + "alSndpDelete: attempt to delete player with playing sounds", + "alSndpPlay: attempt to play a sound which is playing", + "alSndpSetSound: sound id (%d) out of range (0 - %d)", + "alSndpSetPriority: sound id (%d) out of range (0 - %d)", + "alSndpSet Parameter: target (%d) out of range (0 - %d)", + "alBnkfNew: bank file out of date", + "alSeqNew: 0x%x is not a midi file", + "alSeqNew: 0x%x is not a type 0 midi file", + "alSeqNew: 0x%x has more than 1 track", + "alSeqNew: SMPTE delta times not supported", + "alSeqNew: Error parsing file 0x%x (no track header)", + "alSeqNextEvent: Unsupported system exclusive", + "alSeqNextEvent: Unsupported midi meta event 0x%x", + "_handleMIDIMsg: Invalid program change to %d, max instruments %d", + "_handleMIDIMsg: Unknown midi message 0x%x", + "_unmapVoice: Couldn't unmap voice 0x%x", + "alEvtqPostEvent: Out of free events", + "alHeapAlloc: Can't allocate %d bytes", + "alHeapCheck: Heap corrupt", + "alHeapCheck: Heap corrupt - first block is bad", + "alCSeqGetTrackEvent: Running status of zero on track %d", + "alCSeqGetTrackEvent: Note on velocity of zero on track %d", + "alCSPVoiceHandler: Stopping sequence but voice not free chan %d, key %d", + "alSeqNextEvent: Read past end of sequence", + "osAiSetNextBuffer: DMA buffer location may cause audio clicks (0x%x)", + "_loadOutputBuffer: Modulated delay greater than total delay by %d samples", + "osViExtendVStart: VI Manager not yet begun by osCreateViManager", + "osViExtendVStart: value not in range [0-48] %d", + "osThreadProfileStart: thread profiler is not initialized", + "osThreadProfileStart: profiling has already been started", + "osThreadProfileStop: thread profiler is not initialized", + "osThreadProfileReadCount: thread profiler is not initialized", + "osThreadProfileReadCountTh: thread profiler is not initialized", + "osThreadProfileReadTime: thread profiler is not initialized", + "osThreadProfileReadTimeTh: thread profiler is not initialized", + "osThreadProfileReadCount: thread ID is too large(%d)", + "osThreadProfileReadTime: thread ID is too large(%d)", + "osThreadProfileReadCountTh: thread ID is too large(%d)", + "osThreadProfileReadTimeTh: thread ID is too large(%d)", + "osThreadProfileStop: current thread ID is too large(%d)", + NULSTR, +}; + +void __commonErrorHandler(s16 code, s16 numArgs, ...) { + va_list argPtr; + const char* fmt; + + fmt = __os_error_message[code]; + va_start(argPtr, numArgs); + + osSyncPrintf("0x%08X (%04d):", osGetCount(), code); + __osSyncVPrintf(fmt, argPtr); + osSyncPrintf("\n"); + + va_end(argPtr); +} + +#endif diff --git a/lib/ultralib/src/error/errorasm.s b/lib/ultralib/src/error/errorasm.s new file mode 100644 index 0000000..c3e3120 --- /dev/null +++ b/lib/ultralib/src/error/errorasm.s @@ -0,0 +1,13 @@ +#ifndef _FINALROM +#include "sys/asm.h" +#include "sys/regdef.h" + +LEAF(__osError) + lw t0,__osCommonHandler + beqz t0,1f + jr t0 +1: + j ra +END(__osError) + +#endif diff --git a/lib/ultralib/src/flash/flashallerase.c b/lib/ultralib/src/flash/flashallerase.c index c66dbd6..0e982a5 100644 --- a/lib/ultralib/src/flash/flashallerase.c +++ b/lib/ultralib/src/flash/flashallerase.c @@ -1,4 +1,6 @@ -#include "PR/os_internal.h" +#include "ultra64.h" +#include "PR/os_internal_flash.h" + s32 osFlashAllErase(void) { u32 status; diff --git a/lib/ultralib/src/flash/flashallerasethrough.c b/lib/ultralib/src/flash/flashallerasethrough.c index 9e52b97..1c3c1dd 100644 --- a/lib/ultralib/src/flash/flashallerasethrough.c +++ b/lib/ultralib/src/flash/flashallerasethrough.c @@ -1,4 +1,5 @@ -#include "PR/os_internal.h" +#include "ultra64.h" +#include "PR/os_internal_flash.h" void osFlashAllEraseThrough(void) { // start chip erase operation, no waiting for completion diff --git a/lib/ultralib/src/flash/flashchange.c b/lib/ultralib/src/flash/flashchange.c index e667668..d92ff7b 100644 --- a/lib/ultralib/src/flash/flashchange.c +++ b/lib/ultralib/src/flash/flashchange.c @@ -1,5 +1,5 @@ -#include "PR/os_internal.h" -#include "PR/R4300.h" +#include "ultra64.h" +#include "PR/os_internal_flash.h" void osFlashChange(u32 flash_num) { __osFlashHandler.baseAddress = PHYS_TO_K1((FLASH_START_ADDR + flash_num * FLASH_SIZE)); diff --git a/lib/ultralib/src/flash/flashcheckeraseend.c b/lib/ultralib/src/flash/flashcheckeraseend.c index 47faf5c..c87876b 100644 --- a/lib/ultralib/src/flash/flashcheckeraseend.c +++ b/lib/ultralib/src/flash/flashcheckeraseend.c @@ -1,21 +1,23 @@ -#include "PR/os_internal.h" +#include "ultra64.h" +#include "PR/os_internal_flash.h" s32 osFlashCheckEraseEnd(void) { u8 status; osFlashReadStatus(&status); - if (!(status & FLASH_STATUS_ERASE_BUSY)) { + if ((status & FLASH_STATUS_ERASE_BUSY) == FLASH_STATUS_ERASE_BUSY) { + return FLASH_STATUS_ERASE_BUSY; + } else { // not busy, read and clear status osFlashReadStatus(&status); - osFlashClearStatus(); + } + osFlashClearStatus(); - // check for success - if (((status & 0xFF) == 8) || ((status & 0xFF) == 0x48) || ((status & 8) == 8)) { - return FLASH_STATUS_ERASE_OK; - } else { - return FLASH_STATUS_ERASE_ERROR; - } + // check for success + if (((status & 0xFF) == 8) || ((status & 0xFF) == 0x48) || ((status & 8) == 8)) { + return FLASH_STATUS_ERASE_OK; + } else { + return FLASH_STATUS_ERASE_ERROR; } - return FLASH_STATUS_ERASE_BUSY; } diff --git a/lib/ultralib/src/flash/flashclearstatus.c b/lib/ultralib/src/flash/flashclearstatus.c index 7622f9c..86165d6 100644 --- a/lib/ultralib/src/flash/flashclearstatus.c +++ b/lib/ultralib/src/flash/flashclearstatus.c @@ -1,10 +1,10 @@ -#include "PR/os_internal.h" +#include "ultra64.h" +#include "PR/os_internal_flash.h" void osFlashClearStatus(void) { // select status mode osEPiWriteIo(&__osFlashHandler, __osFlashHandler.baseAddress | FLASH_CMD_REG, FLASH_CMD_STATUS); // clear status osEPiWriteIo(&__osFlashHandler, __osFlashHandler.baseAddress, 0); - return; } diff --git a/lib/ultralib/src/flash/flashgetaddr.c b/lib/ultralib/src/flash/flashgetaddr.c index 3fe2e37..dafcab1 100644 --- a/lib/ultralib/src/flash/flashgetaddr.c +++ b/lib/ultralib/src/flash/flashgetaddr.c @@ -1,7 +1,14 @@ -#include "PR/os_internal.h" +#include "ultra64.h" +#include "PR/os_internal_flash.h" u32 __osFlashGetAddr(u32 page_num) { - u32 devAddr = (__osFlashVersion == OLD_FLASH) ? page_num << 6 : page_num << 7; + u32 devAddr; + + if (__osFlashVersion == OLD_FLASH) { + devAddr = page_num * 64; + } else { + devAddr = page_num * 128; + } return devAddr; } diff --git a/lib/ultralib/src/flash/flashinit.c b/lib/ultralib/src/flash/flashinit.c index 9b51a25..33c7dc3 100644 --- a/lib/ultralib/src/flash/flashinit.c +++ b/lib/ultralib/src/flash/flashinit.c @@ -1,13 +1,13 @@ -#include "PR/os_internal.h" -#include "PR/R4300.h" +#include "ultra64.h" +#include "PR/os_internal_flash.h" #include "macros.h" +u32 __osFlashID[4] ALIGNED(8); +OSIoMesg __osFlashMsg ALIGNED(8); OSMesgQueue __osFlashMessageQ ALIGNED(8); -OSMesg __osFlashMsgBuf[1]; OSPiHandle __osFlashHandler ALIGNED(8); +OSMesg __osFlashMsgBuf[1]; s32 __osFlashVersion; -OSIoMesg __osFlashMsg ALIGNED(8); -u32 __osFlashID[4] ALIGNED(8); OSPiHandle* osFlashInit(void) { u32 flash_type; @@ -33,7 +33,8 @@ OSPiHandle* osFlashInit(void) { osEPiLinkHandle(&__osFlashHandler); osFlashReadId(&flash_type, &flash_maker); - if (flash_maker == FLASH_VERSION_MX_C || flash_maker == FLASH_VERSION_MX_A || flash_maker == FLASH_VERSION_MX_PROTO_A) { + if (flash_maker == FLASH_VERSION_MX_C || flash_maker == FLASH_VERSION_MX_A || + flash_maker == FLASH_VERSION_MX_PROTO_A) { __osFlashVersion = OLD_FLASH; } else { __osFlashVersion = NEW_FLASH; diff --git a/lib/ultralib/src/flash/flashreadarray.c b/lib/ultralib/src/flash/flashreadarray.c index 6134d33..543f236 100644 --- a/lib/ultralib/src/flash/flashreadarray.c +++ b/lib/ultralib/src/flash/flashreadarray.c @@ -1,4 +1,6 @@ -#include "PR/os_internal.h" +#include "ultra64.h" +#include "PR/os_internal_flash.h" + s32 osFlashReadArray(OSIoMesg* mb, s32 priority, u32 page_num, void* dramAddr, u32 n_pages, OSMesgQueue* mq) { u32 ret; diff --git a/lib/ultralib/src/flash/flashreadid.c b/lib/ultralib/src/flash/flashreadid.c index 7c8a2c0..3112d74 100644 --- a/lib/ultralib/src/flash/flashreadid.c +++ b/lib/ultralib/src/flash/flashreadid.c @@ -1,4 +1,5 @@ -#include "PR/os_internal.h" +#include "ultra64.h" +#include "PR/os_internal_flash.h" void osFlashReadId(u32* flash_type, u32* flash_maker) { u8 tmp; @@ -22,6 +23,5 @@ void osFlashReadId(u32* flash_type, u32* flash_maker) { *flash_type = __osFlashID[0]; *flash_maker = __osFlashID[1]; - return; } diff --git a/lib/ultralib/src/flash/flashreadstatus.c b/lib/ultralib/src/flash/flashreadstatus.c index 6bb582b..6ff5560 100644 --- a/lib/ultralib/src/flash/flashreadstatus.c +++ b/lib/ultralib/src/flash/flashreadstatus.c @@ -1,4 +1,5 @@ -#include "PR/os_internal.h" +#include "ultra64.h" +#include "PR/os_internal_flash.h" void osFlashReadStatus(u8* flash_status) { u32 status; @@ -12,6 +13,5 @@ void osFlashReadStatus(u8* flash_status) { osEPiReadIo(&__osFlashHandler, __osFlashHandler.baseAddress, &status); *flash_status = status & 0xFF; - return; } diff --git a/lib/ultralib/src/flash/flashreinit.c b/lib/ultralib/src/flash/flashreinit.c index deb6070..b2ab93d 100644 --- a/lib/ultralib/src/flash/flashreinit.c +++ b/lib/ultralib/src/flash/flashreinit.c @@ -1,5 +1,5 @@ -#include "PR/os_internal.h" -#include "PR/R4300.h" +#include "ultra64.h" +#include "PR/os_internal_flash.h" OSPiHandle* osFlashReInit(u8 latency, u8 pulse, u8 page_size, u8 rel_duration, u32 start) { __osFlashHandler.baseAddress = PHYS_TO_K1(start); diff --git a/lib/ultralib/src/flash/flashsectorerase.c b/lib/ultralib/src/flash/flashsectorerase.c index fcccc6e..14a0583 100644 --- a/lib/ultralib/src/flash/flashsectorerase.c +++ b/lib/ultralib/src/flash/flashsectorerase.c @@ -1,4 +1,5 @@ -#include "PR/os_internal.h" +#include "ultra64.h" +#include "PR/os_internal_flash.h" s32 osFlashSectorErase(u32 page_num) { u32 status; diff --git a/lib/ultralib/src/flash/flashsectorerasethrough.c b/lib/ultralib/src/flash/flashsectorerasethrough.c index 52097e1..474ee96 100644 --- a/lib/ultralib/src/flash/flashsectorerasethrough.c +++ b/lib/ultralib/src/flash/flashsectorerasethrough.c @@ -1,4 +1,5 @@ -#include "PR/os_internal.h" +#include "ultra64.h" +#include "PR/os_internal_flash.h" void osFlashSectorEraseThrough(u32 page_num) { // start sector erase operation diff --git a/lib/ultralib/src/flash/flashwritearray.c b/lib/ultralib/src/flash/flashwritearray.c index 555f1df..d5f56a0 100644 --- a/lib/ultralib/src/flash/flashwritearray.c +++ b/lib/ultralib/src/flash/flashwritearray.c @@ -1,4 +1,5 @@ -#include "PR/os_internal.h" +#include "ultra64.h" +#include "PR/os_internal_flash.h" s32 osFlashWriteArray(u32 page_num) { u32 status; @@ -6,7 +7,7 @@ s32 osFlashWriteArray(u32 page_num) { OSMesgQueue timerMesgQueue; OSMesg dummy; - if (__osFlashVersion == NEW_FLASH) { + if ((u32)__osFlashVersion == NEW_FLASH) { osEPiWriteIo(&__osFlashHandler, __osFlashHandler.baseAddress | FLASH_CMD_REG, FLASH_CMD_PAGE_PROGRAM); } diff --git a/lib/ultralib/src/flash/flashwritebuffer.c b/lib/ultralib/src/flash/flashwritebuffer.c index 8cbd0c9..ad3f790 100644 --- a/lib/ultralib/src/flash/flashwritebuffer.c +++ b/lib/ultralib/src/flash/flashwritebuffer.c @@ -1,4 +1,5 @@ -#include "PR/os_internal.h" +#include "ultra64.h" +#include "PR/os_internal_flash.h" s32 osFlashWriteBuffer(OSIoMesg* mb, s32 priority, void* dramAddr, OSMesgQueue* mq) { s32 ret; diff --git a/lib/ultralib/src/gio/giorawinterrupt.c b/lib/ultralib/src/gio/giorawinterrupt.c index 64652d3..2fdc909 100644 --- a/lib/ultralib/src/gio/giorawinterrupt.c +++ b/lib/ultralib/src/gio/giorawinterrupt.c @@ -1,18 +1,13 @@ #include "PR/os_internal.h" #include "PR/rcp.h" +#include "../io/piint.h" void __osGIORawInterrupt(s32 value) { register u32 stat; - stat = IO_READ(PI_STATUS_REG); - while (stat & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) { - stat = IO_READ(PI_STATUS_REG); - } + WAIT_ON_IOBUSY(stat); IO_WRITE(GIO_GIO_INTR_REG, value); - stat = IO_READ(PI_STATUS_REG); - while (stat & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) { - stat = IO_READ(PI_STATUS_REG); - } + WAIT_ON_IOBUSY(stat); } diff --git a/lib/ultralib/src/gt/dumpturbo.c b/lib/ultralib/src/gt/dumpturbo.c index 095c8a4..59930bc 100644 --- a/lib/ultralib/src/gt/dumpturbo.c +++ b/lib/ultralib/src/gt/dumpturbo.c @@ -18,13 +18,14 @@ #include <ultra64.h> #include <gt.h> +#include "macros.h" #undef PRINTF #define PRINTF rmonPrintf #define TX_MAX 100 -static u32 textures[TX_MAX]; +static u32 textures[TX_MAX] ALIGNED(8); static u32 numtextures; #define UNSEG_ADDR(sa) ((u32 *) (((globp)? \ diff --git a/lib/ultralib/src/gu/loadtextureblockmipmap.c b/lib/ultralib/src/gu/loadtextureblockmipmap.c index 786f64a..30ffc65 100644 --- a/lib/ultralib/src/gu/loadtextureblockmipmap.c +++ b/lib/ultralib/src/gu/loadtextureblockmipmap.c @@ -16,6 +16,7 @@ #include "guint.h" #include <stdio.h> #include "ultra64.h" +#include "macros.h" // TODO: this comes from a header #ident "$Revision: 1.49 $" @@ -43,7 +44,7 @@ struct Tile }; /* tram mipmaps */ -static struct Tile mipmap[MM_MAX_LEVEL+1]; +static struct Tile mipmap[MM_MAX_LEVEL+1] ALIGNED(8); static struct texelSizeParams sizeParams[4] = { 16, 3, 1, 0, 8, 2, 2, 1, diff --git a/lib/ultralib/src/host/host_ptn64.c b/lib/ultralib/src/host/host_ptn64.c index 9e6fbd6..6b33c4e 100644 --- a/lib/ultralib/src/host/host_ptn64.c +++ b/lib/ultralib/src/host/host_ptn64.c @@ -1,6 +1,6 @@ #include "PR/os_internal.h" #include "PR/rcp.h" -#include "../io/piint.h" +#include "memory.h" #include "macros.h" @@ -9,10 +9,13 @@ static volatile unsigned int* ptstat = (unsigned*)0xbff08004; static volatile unsigned int* ptport = (unsigned*)0xbff08000; static volatile unsigned int* n64piok = (unsigned*)PHYS_TO_K1(PI_STATUS_REG); -static OSMesgQueue waitPtQueue; +static OSMesgQueue waitPtQueue ALIGNED(8); static OSMesg waitPtQueueBuf; static u32 isWaitPtQueueCreated = FALSE; +void __osPiRelAccess(void); +void __osPiGetAccess(void); + static void createWaitPtQueue(void) { osCreateMesgQueue(&waitPtQueue, &waitPtQueueBuf, 1); isWaitPtQueueCreated = TRUE; @@ -61,9 +64,9 @@ static u32 getPT(void) { } void osReadHost_pt(void* dramAddr, u32 nbytes) { - u8 * tPtr; + u8* tPtr; u32 buf[256]; - u32 * bp; + u32* bp; u32 data; u32 ct; u32 ct1; @@ -103,14 +106,13 @@ void osReadHost_pt(void* dramAddr, u32 nbytes) { while (ct != 0) { if (ct > 0x100) { - ct1 = 0x100; - ct1_bak = 0x100; + ct1_bak = ct1 = 0x100; ct -= 0x100; } else { ct1_bak = ct1 = ct; ct = 0; } - bp = &buf; + bp = (u32*)&buf; while (ct1 != 0) { *(bp++) = getPT(); @@ -140,9 +142,9 @@ osReadHost_ret: } void osWriteHost_pt(void* dramAddr, u32 nbytes) { - u8 *tPtr; + u8* tPtr; u32 buf[256]; - u32 *bp; + u32* bp; u32 ct; u32 ct1; u32 ct1_bak; @@ -179,8 +181,7 @@ void osWriteHost_pt(void* dramAddr, u32 nbytes) { while (ct != 0) { if (ct > 0x100) { - ct1 = 0x100; - ct1_bak = 0x100; + ct1_bak = ct1 = 0x100; ct -= 0x100; } else { ct1_bak = ct1 = ct; diff --git a/lib/ultralib/src/host/readhost.c b/lib/ultralib/src/host/readhost.c index 5cc1974..ed6402d 100644 --- a/lib/ultralib/src/host/readhost.c +++ b/lib/ultralib/src/host/readhost.c @@ -5,13 +5,13 @@ #include "macros.h" -u32 __osRdb_Read_Data_Buf; -u32 __osRdb_Read_Data_Ct; - static int readHostInitialized = FALSE; -static OSMesgQueue readHostMesgQueue; +static OSMesgQueue readHostMesgQueue ALIGNED(8); static OSMesg readHostMesgBuf[1]; +u32 __osRdb_Read_Data_Buf; +u32 __osRdb_Read_Data_Ct; + void osReadHost(void* dramAddr, u32 nbytes) { char tstr[4]; u32 sent = 0; diff --git a/lib/ultralib/src/host/writehost.c b/lib/ultralib/src/host/writehost.c index 92e9587..c7477e6 100644 --- a/lib/ultralib/src/host/writehost.c +++ b/lib/ultralib/src/host/writehost.c @@ -2,25 +2,28 @@ #include "PR/os_internal.h" #include "PR/rdb.h" +#include "PR/ultraerror.h" #include "macros.h" static int writeHostInitialized = FALSE; -static OSMesgQueue writeHostMesgQueue; +static OSMesgQueue writeHostMesgQueue ALIGNED(8); static OSMesg writeHostMesgBuf[1]; -#define MIN(a,b) (((a)<(b)) ? (a) : (b)) +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) -void osWriteHost(void * dramAddr, u32 nbytes) { +void osWriteHost(void* dramAddr, u32 nbytes) { u8* tPtr = dramAddr; u32 sent; u8 dCount[3]; u32 count; +#ifndef NDEBUG if (nbytes == 0) { - __osError(73, 1, nbytes); + __osError(ERR_OSWRITEHOST_SIZE, 1, nbytes); return; } +#endif if (writeHostInitialized == FALSE) { osCreateMesgQueue(&writeHostMesgQueue, writeHostMesgBuf, ARRLEN(writeHostMesgBuf)); diff --git a/lib/ultralib/src/io/ai.c b/lib/ultralib/src/io/ai.c index 5e345dc..4ece0f1 100755..100644 --- a/lib/ultralib/src/io/ai.c +++ b/lib/ultralib/src/io/ai.c @@ -6,10 +6,10 @@ s32 __osAiDeviceBusy(void) { register s32 status = IO_READ(AI_STATUS_REG); - + if (status & AI_STATUS_FIFO_FULL) { return TRUE; + } else { + return FALSE; } - - return FALSE; } diff --git a/lib/ultralib/src/io/aigetlen.c b/lib/ultralib/src/io/aigetlen.c index 6b83682..6b83682 100755..100644 --- a/lib/ultralib/src/io/aigetlen.c +++ b/lib/ultralib/src/io/aigetlen.c diff --git a/lib/ultralib/src/io/aigetstat.c b/lib/ultralib/src/io/aigetstat.c index c7a3cf7..c7a3cf7 100755..100644 --- a/lib/ultralib/src/io/aigetstat.c +++ b/lib/ultralib/src/io/aigetstat.c diff --git a/lib/ultralib/src/io/aisetfreq.c b/lib/ultralib/src/io/aisetfreq.c index 52cd8c3..55cf2af 100755..100644 --- a/lib/ultralib/src/io/aisetfreq.c +++ b/lib/ultralib/src/io/aisetfreq.c @@ -1,5 +1,8 @@ #include "PR/rcp.h" +#include "PR/ultraerror.h" #include "../os/osint.h" +// TODO: not sure if this should be here +extern s32 osViClock; // TODO: this comes from a header #ident "$Revision: 1.17 $" @@ -9,21 +12,39 @@ s32 osAiSetFrequency(u32 frequency) { register unsigned char bitRate; register float f; +#ifdef _DEBUG + if (osViClock == VI_PAL_CLOCK) { + if (frequency < AI_PAL_MIN_FREQ || frequency > AI_PAL_MAX_FREQ) { + __osError(ERR_OSAISETFREQUENCY, 3, AI_PAL_MIN_FREQ, AI_PAL_MAX_FREQ, frequency); + return -1; + } + } else if (osViClock == VI_MPAL_CLOCK) { + if (frequency < AI_MPAL_MIN_FREQ || frequency > AI_MPAL_MAX_FREQ) { + __osError(ERR_OSAISETFREQUENCY, 3, AI_MPAL_MIN_FREQ, AI_MPAL_MAX_FREQ, frequency); + return -1; + } + } else { + if (frequency < AI_NTSC_MIN_FREQ || frequency > AI_NTSC_MAX_FREQ) { + __osError(ERR_OSAISETFREQUENCY, 3, AI_NTSC_MIN_FREQ, AI_NTSC_MAX_FREQ, frequency); + return -1; + } + } +#endif + f = osViClock / (float)frequency + .5f; dacRate = f; - + if (dacRate < AI_MIN_DAC_RATE) { return -1; } - + bitRate = dacRate / 66; - + if (bitRate > AI_MAX_BIT_RATE) { bitRate = AI_MAX_BIT_RATE; } IO_WRITE(AI_DACRATE_REG, dacRate - 1); IO_WRITE(AI_BITRATE_REG, bitRate - 1); - // IO_WRITE(AI_CONTROL_REG, AI_CONTROL_DMA_ON); return osViClock / (s32)dacRate; } diff --git a/lib/ultralib/src/io/aisetnextbuf.c b/lib/ultralib/src/io/aisetnextbuf.c index d4295d3..23fd81b 100755..100644 --- a/lib/ultralib/src/io/aisetnextbuf.c +++ b/lib/ultralib/src/io/aisetnextbuf.c @@ -1,31 +1,44 @@ #include "PR/os_internal.h" +#include "PR/ultraerror.h" #include "PR/rcp.h" #include "../os/osint.h" // TODO: this comes from a header #ident "$Revision: 1.17 $" -s32 osAiSetNextBuffer(void *bufPtr, u32 size) { - static u8 hdwrBugFlag = FALSE; - char *bptr; +s32 osAiSetNextBuffer(void* bufPtr, u32 size) { + static u8 hdwrBugFlag = FALSE; + char* bptr; - if (__osAiDeviceBusy()) { - return -1; - } + if (__osAiDeviceBusy()) { + return -1; + } + +#ifdef _DEBUG + if ((u32)bufPtr & (8 - 1)) { + __osError(ERR_OSAISETNEXTBUFFER_ADDR, 1, bufPtr); + return -1; + } + + if ((u32)size & (8 - 1)) { + __osError(ERR_OSAISETNEXTBUFFER_SIZE, 1, size); + return -1; + } +#endif bptr = bufPtr; - if (hdwrBugFlag) { - bptr -= 0x2000; - } + if (hdwrBugFlag) { + bptr = (u8*)bufPtr - 0x2000; + } - if ((((u32)bufPtr + size) & 0x1fff) == 0) { - hdwrBugFlag = TRUE; - } else { - hdwrBugFlag = FALSE; - } + if ((((u32)bufPtr + size) & 0x1fff) == 0) { + hdwrBugFlag = TRUE; + } else { + hdwrBugFlag = FALSE; + } - IO_WRITE(AI_DRAM_ADDR_REG, osVirtualToPhysical(bptr)); - IO_WRITE(AI_LEN_REG, size); - return 0; + IO_WRITE(AI_DRAM_ADDR_REG, osVirtualToPhysical(bptr)); + IO_WRITE(AI_LEN_REG, size); + return 0; } diff --git a/lib/ultralib/src/io/cartrominit.c b/lib/ultralib/src/io/cartrominit.c index 9cd1617..9651878 100644 --- a/lib/ultralib/src/io/cartrominit.c +++ b/lib/ultralib/src/io/cartrominit.c @@ -2,37 +2,35 @@ #include "PR/os_internal.h" #include "PR/R4300.h" #include "PR/rcp.h" +#include "piint.h" OSPiHandle __CartRomHandle ALIGNED(8); -OSPiHandle *osCartRomInit(void) -{ - u32 value; - u32 saveMask; - static int first = 1; - register u32 stat; - u32 latency; - u32 pulse; - u32 pageSize; - u32 relDuration; +OSPiHandle* osCartRomInit(void) { + u32 value = 0; + u32 saveMask; + static int first = 1; + register u32 stat; + u32 latency; + u32 pulse; + u32 pageSize; + u32 relDuration; __osPiGetAccess(); - if (!first) { + if (!first) { __osPiRelAccess(); - return &__CartRomHandle; + return &__CartRomHandle; } first = 0; - __CartRomHandle.type = DEVICE_TYPE_CART; - __CartRomHandle.baseAddress = PHYS_TO_K1(PI_DOM1_ADDR2); - __CartRomHandle.domain = PI_DOMAIN1; - __CartRomHandle.speed = 0; + __CartRomHandle.type = DEVICE_TYPE_CART; + __CartRomHandle.baseAddress = PHYS_TO_K1(PI_DOM1_ADDR2); + __CartRomHandle.domain = PI_DOMAIN1; + __CartRomHandle.speed = 0; - bzero(&__CartRomHandle.transferInfo, sizeof(__OSTranxInfo)); + bzero(&__CartRomHandle.transferInfo, sizeof(__OSTranxInfo)); - while (stat = IO_READ(PI_STATUS_REG), stat & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) { - ; - } + WAIT_ON_IOBUSY(stat); latency = IO_READ(PI_BSD_DOM1_LAT_REG); pageSize = IO_READ(PI_BSD_DOM1_PGS_REG); @@ -55,11 +53,11 @@ OSPiHandle *osCartRomInit(void) IO_WRITE(PI_BSD_DOM1_RLS_REG, relDuration); IO_WRITE(PI_BSD_DOM1_PWD_REG, pulse); - saveMask = __osDisableInt(); - __CartRomHandle.next = __osPiTable; - __osPiTable = &__CartRomHandle; - __osRestoreInt(saveMask); + saveMask = __osDisableInt(); + __CartRomHandle.next = __osPiTable; + __osPiTable = &__CartRomHandle; + __osRestoreInt(saveMask); __osPiRelAccess(); - - return &__CartRomHandle; + + return &__CartRomHandle; } diff --git a/lib/ultralib/src/io/contchannelreset.c b/lib/ultralib/src/io/contchannelreset.c index d209ffc..f6ed8a2 100644 --- a/lib/ultralib/src/io/contchannelreset.c +++ b/lib/ultralib/src/io/contchannelreset.c @@ -1,5 +1,6 @@ #include "PR/os_internal.h" #include "controller.h" +#include "siint.h" s32 __osContChannelReset(OSMesgQueue* mq, int channel) { s32 i; diff --git a/lib/ultralib/src/io/conteeplongread.c b/lib/ultralib/src/io/conteeplongread.c index 15af27c..d8d59f6 100755..100644 --- a/lib/ultralib/src/io/conteeplongread.c +++ b/lib/ultralib/src/io/conteeplongread.c @@ -1,7 +1,7 @@ #include "PR/os_internal.h" #include "controller.h" -s32 osEepromLongRead(OSMesgQueue *mq, u8 address, u8 *buffer, int length) { +s32 osEepromLongRead(OSMesgQueue* mq, u8 address, u8* buffer, int length) { s32 ret = 0; while (length > 0) { @@ -10,6 +10,6 @@ s32 osEepromLongRead(OSMesgQueue *mq, u8 address, u8 *buffer, int length) { address++; buffer += EEPROM_BLOCK_SIZE; } - + return ret; } diff --git a/lib/ultralib/src/io/conteeplongwrite.c b/lib/ultralib/src/io/conteeplongwrite.c index ea92431..c38acf8 100755..100644 --- a/lib/ultralib/src/io/conteeplongwrite.c +++ b/lib/ultralib/src/io/conteeplongwrite.c @@ -1,7 +1,7 @@ #include "PR/os_internal.h" #include "controller.h" -s32 osEepromLongWrite(OSMesgQueue *mq, u8 address, u8 *buffer, int length) { +s32 osEepromLongWrite(OSMesgQueue* mq, u8 address, u8* buffer, int length) { s32 ret = 0; while (length > 0) { @@ -12,6 +12,6 @@ s32 osEepromLongWrite(OSMesgQueue *mq, u8 address, u8 *buffer, int length) { osSetTimer(&__osEepromTimer, 562500, 0, &__osEepromTimerQ, &__osEepromTimerMsg); osRecvMesg(&__osEepromTimerQ, NULL, OS_MESG_BLOCK); } - + return ret; } diff --git a/lib/ultralib/src/io/conteepprobe.c b/lib/ultralib/src/io/conteepprobe.c index d24ff06..5bee6a4 100755..100644 --- a/lib/ultralib/src/io/conteepprobe.c +++ b/lib/ultralib/src/io/conteepprobe.c @@ -1,7 +1,7 @@ #include "controller.h" #include "siint.h" -s32 osEepromProbe(OSMesgQueue *mq) { +s32 osEepromProbe(OSMesgQueue* mq) { s32 ret = 0; u16 type; OSContStatus sdata; diff --git a/lib/ultralib/src/io/conteepread.c b/lib/ultralib/src/io/conteepread.c index 887ada6..708a976 100755..100644 --- a/lib/ultralib/src/io/conteepread.c +++ b/lib/ultralib/src/io/conteepread.c @@ -3,98 +3,93 @@ #include "controller.h" #include "siint.h" -static void __osPackEepReadData(u8 address); OSPifRam __osEepPifRam ALIGNED(16); s32 __osEepromRead16K; +static void __osPackEepReadData(u8 address); -s32 osEepromRead(OSMesgQueue *mq, u8 address, u8 *buffer) -{ - s32 ret = 0; - int i = 0; - u16 type; - u8 *ptr; - OSContStatus sdata; - __OSContEepromFormat eepromformat; - - ptr = (u8 *)&__osEepPifRam.ramarray; - __osSiGetAccess(); - ret = __osEepStatus(mq, &sdata); - type = sdata.type & (CONT_EEPROM | CONT_EEP16K); +s32 osEepromRead(OSMesgQueue* mq, u8 address, u8* buffer) { + s32 ret = 0; + int i = 0; + u16 type; + u8* ptr; + OSContStatus sdata; + __OSContEepromFormat eepromformat; - if (ret != 0) { - __osSiRelAccess(); - return ret; - } + ptr = (u8*)&__osEepPifRam.ramarray; + __osSiGetAccess(); + ret = __osEepStatus(mq, &sdata); + type = sdata.type & (CONT_EEPROM | CONT_EEP16K); - switch (type) { - case CONT_EEPROM: - if (address >= EEPROM_MAXBLOCKS) { - ret = CONT_RANGE_ERROR; - } - break; - case CONT_EEPROM | CONT_EEP16K: - __osEepromRead16K = 1; - if (address >= EEP16K_MAXBLOCKS) { - //not technically possible - ret = CONT_RANGE_ERROR; - } - break; - default: - ret = CONT_NO_RESPONSE_ERROR; - break; - } + if (ret == 0) { + switch (type) { + case CONT_EEPROM: + if (address >= EEPROM_MAXBLOCKS) { + ret = CONT_RANGE_ERROR; + } + break; + case CONT_EEPROM | CONT_EEP16K: + if (address >= EEP16K_MAXBLOCKS) { + // not technically possible + ret = CONT_RANGE_ERROR; + } else { + __osEepromRead16K = 1; + } + break; + default: + ret = CONT_NO_RESPONSE_ERROR; + } + } if (ret != 0) { __osSiRelAccess(); return ret; } - while (sdata.status & CONT_EEPROM_BUSY) { - __osEepStatus(mq, &sdata); - } - - __osPackEepReadData(address); - ret = __osSiRawStartDma(OS_WRITE, &__osEepPifRam); //send command to pif - osRecvMesg(mq, NULL, OS_MESG_BLOCK); - ret = __osSiRawStartDma(OS_READ, &__osEepPifRam); //recv response - __osContLastCmd = CONT_CMD_READ_EEPROM; - osRecvMesg(mq, NULL, OS_MESG_BLOCK); - - for (i = 0; i < MAXCONTROLLERS; i++) { - //skip the first 4 bytes - ptr++; - } + while (sdata.status & CONT_EEPROM_BUSY) { + __osEepStatus(mq, &sdata); + } + + __osPackEepReadData(address); + ret = __osSiRawStartDma(OS_WRITE, &__osEepPifRam); // send command to pif + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + ret = __osSiRawStartDma(OS_READ, &__osEepPifRam); // recv response + __osContLastCmd = CONT_CMD_READ_EEPROM; + osRecvMesg(mq, NULL, OS_MESG_BLOCK); - eepromformat = *(__OSContEepromFormat *)ptr; - ret = CHNL_ERR(eepromformat); + for (i = 0; i < MAXCONTROLLERS; i++) { + // skip the first 4 bytes + ptr++; + } - if (ret == 0) { - for (i = 0; i < ARRLEN(eepromformat.data); i++) { - *buffer++ = eepromformat.data[i]; - } - } + eepromformat = *(__OSContEepromFormat*)ptr; + ret = CHNL_ERR(eepromformat); - __osSiRelAccess(); - return ret; + if (ret == 0) { + for (i = 0; i < ARRLEN(eepromformat.data); i++) { + *buffer++ = eepromformat.data[i]; + } + } + __osSiRelAccess(); + return ret; } static void __osPackEepReadData(u8 address) { - u8 *ptr = (u8 *)&__osEepPifRam.ramarray; - __OSContEepromFormat eepromformat; - int i; + u8* ptr = (u8*)&__osEepPifRam.ramarray; + __OSContEepromFormat eepromformat; + int i; - __osEepPifRam.pifstatus = CONT_CMD_EXE; + __osEepPifRam.pifstatus = CONT_CMD_EXE; - eepromformat.txsize = CONT_CMD_READ_EEPROM_TX; - eepromformat.rxsize = CONT_CMD_READ_EEPROM_RX; - eepromformat.cmd = CONT_CMD_READ_EEPROM; - eepromformat.address = address; + eepromformat.txsize = CONT_CMD_READ_EEPROM_TX; + eepromformat.rxsize = CONT_CMD_READ_EEPROM_RX; + eepromformat.cmd = CONT_CMD_READ_EEPROM; + eepromformat.address = address; + + for (i = 0; i < MAXCONTROLLERS; i++) { + *ptr++ = 0; + } - for (i = 0; i < MAXCONTROLLERS; i++) { - *ptr++ = 0; - } - - *(__OSContEepromFormat *)(ptr) = eepromformat; - ptr += sizeof(__OSContEepromFormat); - ptr[0] = CONT_CMD_END; + *(__OSContEepromFormat*)(ptr) = eepromformat; + ptr += sizeof(__OSContEepromFormat); + ptr[0] = CONT_CMD_END; } diff --git a/lib/ultralib/src/io/conteepwrite.c b/lib/ultralib/src/io/conteepwrite.c index aa351fd..5c4f4e2 100755..100644 --- a/lib/ultralib/src/io/conteepwrite.c +++ b/lib/ultralib/src/io/conteepwrite.c @@ -3,12 +3,11 @@ #include "controller.h" #include "siint.h" -static void __osPackEepWriteData(u8 address, u8 *buffer); -s32 osEepromWrite(OSMesgQueue *mq, u8 address, u8 *buffer) -{ +static void __osPackEepWriteData(u8 address, u8* buffer); +s32 osEepromWrite(OSMesgQueue* mq, u8 address, u8* buffer) { s32 ret = 0; u16 type; - u8 *ptr = (u8 *)&__osEepPifRam.ramarray; + u8* ptr = (u8*)&__osEepPifRam.ramarray; __OSContEepromFormat eepromformat; OSContStatus sdata; u8 temp[8]; @@ -18,33 +17,27 @@ s32 osEepromWrite(OSMesgQueue *mq, u8 address, u8 *buffer) type = sdata.type & (CONT_EEPROM | CONT_EEP16K); - if (ret != 0) { - __osSiRelAccess(); - return ret; - } - - switch (type) { - case CONT_EEPROM: - if (address >= EEPROM_MAXBLOCKS) { - ret = CONT_RANGE_ERROR; - } - break; - case CONT_EEPROM | CONT_EEP16K: - if (address >= EEP16K_MAXBLOCKS) { - //not technically possible - ret = CONT_RANGE_ERROR; - } - if (__osEepromRead16K) - { - __osEepromRead16K = 0; - __osSiRelAccess(); - osEepromRead(mq, (address ^ 1), temp); - __osSiGetAccess(); - } - break; - default: - ret = CONT_NO_RESPONSE_ERROR; - break; + if (ret == 0) { + switch (type) { + case CONT_EEPROM: + if (address >= EEPROM_MAXBLOCKS) { + ret = CONT_RANGE_ERROR; + } + break; + case CONT_EEPROM | CONT_EEP16K: + if (address >= EEP16K_MAXBLOCKS) { + // not technically possible + ret = CONT_RANGE_ERROR; + } else if (__osEepromRead16K) { + __osEepromRead16K = 0; + __osSiRelAccess(); + osEepromRead(mq, (address ^ 1), temp); + __osSiGetAccess(); + } + break; + default: + ret = CONT_NO_RESPONSE_ERROR; + } } if (ret != 0) { @@ -55,18 +48,18 @@ s32 osEepromWrite(OSMesgQueue *mq, u8 address, u8 *buffer) while (sdata.status & CONT_EEPROM_BUSY) { __osEepStatus(mq, &sdata); } - + __osPackEepWriteData(address, buffer); - ret = __osSiRawStartDma(OS_WRITE, &__osEepPifRam); //send command to pif + ret = __osSiRawStartDma(OS_WRITE, &__osEepPifRam); // send command to pif osRecvMesg(mq, NULL, OS_MESG_BLOCK); - ret = __osSiRawStartDma(OS_READ, &__osEepPifRam); //recv response + ret = __osSiRawStartDma(OS_READ, &__osEepPifRam); // recv response __osContLastCmd = CONT_CMD_WRITE_EEPROM; osRecvMesg(mq, NULL, OS_MESG_BLOCK); - //skip the first 4 bytes + // skip the first 4 bytes ptr += 4; - - eepromformat = *(__OSContEepromFormat *)ptr; + + eepromformat = *(__OSContEepromFormat*)ptr; ret = CHNL_ERR(eepromformat); @@ -74,8 +67,8 @@ s32 osEepromWrite(OSMesgQueue *mq, u8 address, u8 *buffer) return ret; } -static void __osPackEepWriteData(u8 address, u8 *buffer) { - u8 *ptr = (u8 *)&__osEepPifRam.ramarray; +static void __osPackEepWriteData(u8 address, u8* buffer) { + u8* ptr = (u8*)&__osEepPifRam.ramarray; __OSContEepromFormat eepromformat; int i; @@ -85,7 +78,7 @@ static void __osPackEepWriteData(u8 address, u8 *buffer) { eepromformat.rxsize = CONT_CMD_WRITE_EEPROM_RX; eepromformat.cmd = CONT_CMD_WRITE_EEPROM; eepromformat.address = address; - + for (i = 0; i < ARRLEN(eepromformat.data); i++) { eepromformat.data[i] = *buffer++; } @@ -93,30 +86,29 @@ static void __osPackEepWriteData(u8 address, u8 *buffer) { for (i = 0; i < MAXCONTROLLERS; i++) { *ptr++ = 0; } - - *(__OSContEepromFormat *)(ptr) = eepromformat; + + *(__OSContEepromFormat*)(ptr) = eepromformat; ptr += sizeof(__OSContEepromFormat); ptr[0] = CONT_CMD_END; } - -s32 __osEepStatus(OSMesgQueue *mq, OSContStatus *data) { +s32 __osEepStatus(OSMesgQueue* mq, OSContStatus* data) { s32 ret = 0; int i; - u8 *ptr = (u8 *)__osEepPifRam.ramarray; + u8* ptr = (u8*)__osEepPifRam.ramarray; __OSContRequesFormat requestformat; - + for (i = 0; i < ARRLEN(__osEepPifRam.ramarray) + 1; i++) { __osEepPifRam.ramarray[i] = 0; } __osEepPifRam.pifstatus = CONT_CMD_EXE; - ptr = (u8 *)__osEepPifRam.ramarray; - + ptr = (u8*)__osEepPifRam.ramarray; + for (i = 0; i < MAXCONTROLLERS; i++) { *ptr++ = CONT_CMD_REQUEST_STATUS; } - + requestformat.dummy = CONT_CMD_NOP; requestformat.txsize = CONT_CMD_REQUEST_STATUS_TX; requestformat.rxsize = CONT_CMD_REQUEST_STATUS_RX; @@ -125,7 +117,7 @@ s32 __osEepStatus(OSMesgQueue *mq, OSContStatus *data) { requestformat.typel = CONT_CMD_NOP; requestformat.status = CONT_CMD_NOP; requestformat.dummy1 = CONT_CMD_NOP; - *(__OSContRequesFormat *)ptr = requestformat; + *(__OSContRequesFormat*)ptr = requestformat; ptr += sizeof(__OSContRequesFormat); *ptr = CONT_CMD_END; @@ -139,20 +131,20 @@ s32 __osEepStatus(OSMesgQueue *mq, OSContStatus *data) { return ret; } - ptr = (u8 *)&__osEepPifRam; - + ptr = (u8*)&__osEepPifRam; + for (i = 0; i < MAXCONTROLLERS; i++) { *ptr++ = 0; } - requestformat = *(__OSContRequesFormat *)ptr; + requestformat = *(__OSContRequesFormat*)ptr; data->errno = CHNL_ERR(requestformat); data->type = (requestformat.typel << 8) | requestformat.typeh; data->status = requestformat.status; - + if (data->errno != 0) { return data->errno; } - + return 0; } diff --git a/lib/ultralib/src/io/contpfs.c b/lib/ultralib/src/io/contpfs.c index 5121426..5f3854d 100755..100644 --- a/lib/ultralib/src/io/contpfs.c +++ b/lib/ultralib/src/io/contpfs.c @@ -1,32 +1,32 @@ #include "macros.h" #include "PR/os_internal.h" #include "controller.h" +#include "PR/rmon.h" __OSInode __osPfsInodeCache ALIGNED(8); s32 __osPfsInodeCacheChannel = -1; u8 __osPfsInodeCacheBank = 250; -u16 __osSumcalc(u8 *ptr, int length) { +u16 __osSumcalc(u8* ptr, int length) { int i; u32 sum = 0; - u8 *tmp = ptr; + u8* tmp = ptr; for (i = 0; i < length; i++) { sum += *tmp++; } - return sum; + return sum & 0xFFFF; } -s32 __osIdCheckSum(u16 *ptr, u16 *csum, u16 *icsum) { +s32 __osIdCheckSum(u16* ptr, u16* csum, u16* icsum) { u16 data = 0; u32 j; - - *icsum = 0; - *csum = *icsum; + + *csum = *icsum = 0; for (j = 0; j < ((sizeof(__OSPackId) - sizeof(u32)) / sizeof(u8)); j += 2) { - data = *(u16 *)((u8 *)ptr + j); + data = *(u16*)((u32)ptr + j); *csum += data; *icsum += ~data; } @@ -34,7 +34,7 @@ s32 __osIdCheckSum(u16 *ptr, u16 *csum, u16 *icsum) { return 0; } -s32 __osRepairPackId(OSPfs *pfs, __OSPackId *badid, __OSPackId *newid) { +s32 __osRepairPackId(OSPfs* pfs, __OSPackId* badid, __OSPackId* newid) { s32 ret = 0; u8 temp[BLOCKSIZE]; u8 comp[BLOCKSIZE]; @@ -47,13 +47,13 @@ s32 __osRepairPackId(OSPfs *pfs, __OSPackId *badid, __OSPackId *newid) { newid->random = osGetCount(); newid->serial_mid = badid->serial_mid; newid->serial_low = badid->serial_low; - + SET_ACTIVEBANK_TO_ZERO; do { ERRCK(__osPfsSelectBank(pfs, j)); ERRCK(__osContRamRead(pfs->queue, pfs->channel, 0, temp)); - + temp[0] = j | 0x80; for (i = 1; i < BLOCKSIZE; i++) { @@ -76,7 +76,7 @@ s32 __osRepairPackId(OSPfs *pfs, __OSPackId *badid, __OSPackId *newid) { if (j > 0) { ERRCK(__osPfsSelectBank(pfs, 0)); ERRCK(__osContRamRead(pfs->queue, pfs->channel, 0, (u8*)temp)); - + if (temp[0] != 0x80) { break; } @@ -84,14 +84,10 @@ s32 __osRepairPackId(OSPfs *pfs, __OSPackId *badid, __OSPackId *newid) { j++; } while (j < PFS_MAX_BANKS); - + SET_ACTIVEBANK_TO_ZERO; - - if (j > 0) { - mask = 1; - } else { - mask = 0; - } + + mask = (j > 0) ? 1 : 0; newid->deviceid = (badid->deviceid & (u16)~1) | mask; newid->banks = j; @@ -105,25 +101,25 @@ s32 __osRepairPackId(OSPfs *pfs, __OSPackId *badid, __OSPackId *newid) { for (i = 0; i < ARRLEN(index); i++) { ERRCK(__osContRamWrite(pfs->queue, pfs->channel, index[i], (u8*)newid, TRUE)); } - + ERRCK(__osContRamRead(pfs->queue, pfs->channel, PFS_ID_0AREA, (u8*)temp)); - + for (i = 0; i < BLOCKSIZE; i++) { - if (temp[i] != ((u8 *)newid)[i]) { + if (temp[i] != ((u8*)newid)[i]) { return PFS_ERR_DEVICE; } } return 0; } -s32 __osCheckPackId(OSPfs *pfs, __OSPackId *temp) { +s32 __osCheckPackId(OSPfs* pfs, __OSPackId* temp) { u16 index[4]; s32 ret = 0; u16 sum; u16 isum; int i; int j; - + SET_ACTIVEBANK_TO_ZERO; index[0] = PFS_ID_0AREA; index[1] = PFS_ID_1AREA; @@ -131,7 +127,7 @@ s32 __osCheckPackId(OSPfs *pfs, __OSPackId *temp) { index[3] = PFS_ID_3AREA; for (i = 1; i < ARRLEN(index); i++) { ERRCK(__osContRamRead(pfs->queue, pfs->channel, index[i], (u8*)temp)); - __osIdCheckSum((u16 *)temp, &sum, &isum); + __osIdCheckSum((u16*)temp, &sum, &isum); if (temp->checksum == sum && temp->inverted_checksum == isum) { break; } @@ -150,14 +146,13 @@ s32 __osCheckPackId(OSPfs *pfs, __OSPackId *temp) { return 0; } -s32 __osGetId(OSPfs *pfs) { - int k; +s32 __osGetId(OSPfs* pfs) { u16 sum; u16 isum; u8 temp[BLOCKSIZE]; __OSPackId newid; s32 ret; - __OSPackId *id; + __OSPackId* id; SET_ACTIVEBANK_TO_ZERO; ERRCK(__osContRamRead(pfs->queue, pfs->channel, PFS_ID_0AREA, (u8*)temp)); @@ -166,7 +161,7 @@ s32 __osGetId(OSPfs *pfs) { if (id->checksum != sum || id->inverted_checksum != isum) { ret = __osCheckPackId(pfs, id); - + if (ret == PFS_ERR_ID_FATAL) { ERRCK(__osRepairPackId(pfs, id, &newid)); id = &newid; @@ -178,7 +173,7 @@ s32 __osGetId(OSPfs *pfs) { if ((id->deviceid & 1) == 0) { ERRCK(__osRepairPackId(pfs, id, &newid)); id = &newid; - + if ((id->deviceid & 1) == 0) { return PFS_ERR_DEVICE; } @@ -196,13 +191,13 @@ s32 __osGetId(OSPfs *pfs) { return 0; } -s32 __osCheckId(OSPfs *pfs) { +s32 __osCheckId(OSPfs* pfs) { u8 temp[BLOCKSIZE]; s32 ret; if (pfs->activebank != 0) { ret = __osPfsSelectBank(pfs, 0); - + if (ret == PFS_ERR_NEW_PACK) { ret = __osPfsSelectBank(pfs, 0); } @@ -213,13 +208,12 @@ s32 __osCheckId(OSPfs *pfs) { } ret = __osContRamRead(pfs->queue, pfs->channel, PFS_ID_0AREA, (u8*)temp); - + if (ret != 0) { if (ret != PFS_ERR_NEW_PACK) { return ret; - } else { - ERRCK(__osContRamRead(pfs->queue, pfs->channel, PFS_ID_0AREA, (u8*)temp)); } + ERRCK(__osContRamRead(pfs->queue, pfs->channel, PFS_ID_0AREA, (u8*)temp)); } if (bcmp(pfs->id, temp, BLOCKSIZE) != 0) { @@ -229,12 +223,12 @@ s32 __osCheckId(OSPfs *pfs) { return 0; } -s32 __osPfsRWInode(OSPfs *pfs, __OSInode *inode, u8 flag, u8 bank) { +s32 __osPfsRWInode(OSPfs* pfs, __OSInode* inode, u8 flag, u8 bank) { u8 sum; int j; s32 ret; int offset; - u8 *addr; + u8* addr; if (flag == PFS_READ && bank == __osPfsInodeCacheBank && (pfs->channel == __osPfsInodeCacheChannel)) { bcopy(&__osPfsInodeCache, inode, sizeof(__OSInode)); @@ -243,19 +237,16 @@ s32 __osPfsRWInode(OSPfs *pfs, __OSInode *inode, u8 flag, u8 bank) { SET_ACTIVEBANK_TO_ZERO; - if (bank > 0) { - offset = 1; - } else { - offset = pfs->inode_start_page; - } + offset = (bank > 0) ? 1 : pfs->inode_start_page; if (flag == PFS_WRITE) { - inode->inode_page[0].inode_t.page = __osSumcalc((u8*)&inode->inode_page[offset], (PFS_INODE_SIZE_PER_PAGE - offset) * 2); + inode->inode_page[0].inode_t.page = + __osSumcalc((u8*)&inode->inode_page[offset], (PFS_INODE_SIZE_PER_PAGE - offset) * 2); } for (j = 0; j < PFS_ONE_PAGE; j++) { - addr = ((u8 *)inode->inode_page + j * BLOCKSIZE); - + addr = ((u8*)inode->inode_page + j * BLOCKSIZE); + if (flag == PFS_WRITE) { ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->inode_table + bank * PFS_ONE_PAGE + j, addr, FALSE); ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->minode_table + bank * PFS_ONE_PAGE + j, addr, FALSE); @@ -267,31 +258,54 @@ s32 __osPfsRWInode(OSPfs *pfs, __OSInode *inode, u8 flag, u8 bank) { return ret; } } - + if (flag == PFS_READ) { - sum = __osSumcalc((u8*)&inode->inode_page[offset], (PFS_INODE_SIZE_PER_PAGE - offset) * 2); + sum = __osSumcalc((u8*)&inode->inode_page[offset], (PFS_INODE_SIZE_PER_PAGE - offset) * 2); if (sum != inode->inode_page[0].inode_t.page) { for (j = 0; j < PFS_ONE_PAGE; j++) { - addr = ((u8 *)inode->inode_page + j * BLOCKSIZE); + addr = ((u8*)inode->inode_page + j * BLOCKSIZE); ret = __osContRamRead(pfs->queue, pfs->channel, pfs->minode_table + bank * PFS_ONE_PAGE + j, addr); } - sum = __osSumcalc((u8*)&inode->inode_page[offset], (PFS_INODE_SIZE_PER_PAGE - offset) * 2); - + sum = __osSumcalc((u8*)&inode->inode_page[offset], (PFS_INODE_SIZE_PER_PAGE - offset) * 2); + if (sum != inode->inode_page[0].inode_t.page) { return PFS_ERR_INCONSISTENT; } - + for (j = 0; j < PFS_ONE_PAGE; j++) { - addr = ((u8 *)inode->inode_page + j * BLOCKSIZE); - ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->inode_table + bank * PFS_ONE_PAGE + j, addr, FALSE); + addr = ((u8*)inode->inode_page + j * BLOCKSIZE); + ret = + __osContRamWrite(pfs->queue, pfs->channel, pfs->inode_table + bank * PFS_ONE_PAGE + j, addr, FALSE); } } } - + __osPfsInodeCacheBank = bank; bcopy(inode, &__osPfsInodeCache, sizeof(__OSInode)); __osPfsInodeCacheChannel = pfs->channel; return 0; } + +#ifdef _DEBUG +s32 __osDumpId(OSPfs* pfs) { + u8 id[BLOCKSIZE]; + __OSPackId* temp; + s32 ret; + + ERRCK(__osContRamRead(pfs->queue, pfs->channel, PFS_ID_0AREA, id)); + + temp = (__OSPackId*)id; + rmonPrintf("repaired %x\n", temp->repaired); + rmonPrintf("random %x\n", temp->random); + rmonPrintf("serial_mid %llu\n", temp->serial_mid); + rmonPrintf("serial_low %llu\n", temp->serial_low); + rmonPrintf("deviceid %x\n", temp->deviceid); + rmonPrintf("banks %x\n", temp->banks); + rmonPrintf("version %x\n", temp->version); + rmonPrintf("checksum %x\n", temp->checksum); + rmonPrintf("inverted_checksum %x\n", temp->inverted_checksum); + return 0; +} +#endif diff --git a/lib/ultralib/src/io/contquery.c b/lib/ultralib/src/io/contquery.c index d042ecf..df038ce 100755..100644 --- a/lib/ultralib/src/io/contquery.c +++ b/lib/ultralib/src/io/contquery.c @@ -2,7 +2,7 @@ #include "controller.h" #include "siint.h" -s32 osContStartQuery(OSMesgQueue *mq) { +s32 osContStartQuery(OSMesgQueue* mq) { s32 ret = 0; __osSiGetAccess(); @@ -12,14 +12,14 @@ s32 osContStartQuery(OSMesgQueue *mq) { ret = __osSiRawStartDma(OS_WRITE, __osContPifRam.ramarray); osRecvMesg(mq, NULL, OS_MESG_BLOCK); } - + ret = __osSiRawStartDma(OS_READ, __osContPifRam.ramarray); __osContLastCmd = CONT_CMD_REQUEST_STATUS; __osSiRelAccess(); return ret; } -void osContGetQuery(OSContStatus *data) { +void osContGetQuery(OSContStatus* data) { u8 pattern; __osContGetInitData(&pattern, data); } diff --git a/lib/ultralib/src/io/contramread.c b/lib/ultralib/src/io/contramread.c index 0afa93a..b0346e1 100644 --- a/lib/ultralib/src/io/contramread.c +++ b/lib/ultralib/src/io/contramread.c @@ -8,7 +8,7 @@ s32 __osPfsLastChannel = -1; #define READFORMAT(ptr) ((__OSContRamReadFormat*)(ptr)) s32 __osContRamRead(OSMesgQueue* mq, int channel, u16 address, u8* buffer) { - s32 ret; + s32 ret = 0; s32 i; u8* ptr; s32 retry = 2; @@ -18,13 +18,11 @@ s32 __osContRamRead(OSMesgQueue* mq, int channel, u16 address, u8* buffer) { do { ptr = (u8*)&__osPfsPifRam; - if (__osContLastCmd != CONT_CMD_READ_PAK || __osPfsLastChannel != channel) { + if (__osContLastCmd != CONT_CMD_READ_PAK || (u32)__osPfsLastChannel != channel) { __osContLastCmd = CONT_CMD_READ_PAK; __osPfsLastChannel = channel; - for (i = 0; i < channel; i++) { - *ptr++ = CONT_CMD_REQUEST_STATUS; - } + for (i = 0; i < channel; i++) { *ptr++ = CONT_CMD_REQUEST_STATUS; } __osPfsPifRam.pifstatus = CONT_CMD_EXE; @@ -40,36 +38,32 @@ s32 __osContRamRead(OSMesgQueue* mq, int channel, u16 address, u8* buffer) { } READFORMAT(ptr)->addrh = address >> 3; - READFORMAT(ptr)->addrl = (u8)(__osContAddressCrc(address) | (address << 5)); + READFORMAT(ptr)->addrl = (u8)((address << 5) | __osContAddressCrc(address)); - __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); + ret = __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); osRecvMesg(mq, NULL, OS_MESG_BLOCK); - __osSiRawStartDma(OS_READ, &__osPfsPifRam); + ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam); osRecvMesg(mq, NULL, OS_MESG_BLOCK); ret = CHNL_ERR(*READFORMAT(ptr)); if (!ret) { - if (__osContDataCrc(&READFORMAT(ptr)->data) != READFORMAT(ptr)->datacrc) { + if (__osContDataCrc(READFORMAT(ptr)->data) != READFORMAT(ptr)->datacrc) { ret = __osPfsGetStatus(mq, channel); if (ret) { break; + } else { + ret = PFS_ERR_CONTRFAIL; } - - ret = PFS_ERR_CONTRFAIL; } else { - bcopy(&READFORMAT(ptr)->data, buffer, BLOCKSIZE); + bcopy(READFORMAT(ptr)->data, buffer, BLOCKSIZE); } } else { ret = PFS_ERR_NOPACK; } - if (ret != PFS_ERR_CONTRFAIL) { - break; - } - } while (0 <= retry--); + } while ((ret == PFS_ERR_CONTRFAIL) && (retry-- >= 0)); __osSiRelAccess(); - return ret; } diff --git a/lib/ultralib/src/io/contramwrite.c b/lib/ultralib/src/io/contramwrite.c index 1478480..8960c90 100644 --- a/lib/ultralib/src/io/contramwrite.c +++ b/lib/ultralib/src/io/contramwrite.c @@ -21,15 +21,13 @@ s32 __osContRamWrite(OSMesgQueue* mq, int channel, u16 address, u8* buffer, int __osSiGetAccess(); do { - ptr = __osPfsPifRam.ramarray; + ptr = (u8*)__osPfsPifRam.ramarray; - if (__osContLastCmd != CONT_CMD_WRITE_PAK || __osPfsLastChannel != channel) { + if (__osContLastCmd != CONT_CMD_WRITE_PAK || (u32)__osPfsLastChannel != channel) { __osContLastCmd = CONT_CMD_WRITE_PAK; __osPfsLastChannel = channel; - for (i = 0; i < channel; i++) { - *ptr++ = CONT_CMD_REQUEST_STATUS; - } + for (i = 0; i < channel; i++) { *ptr++ = CONT_CMD_REQUEST_STATUS; } __osPfsPifRam.pifstatus = CONT_CMD_EXE; @@ -74,4 +72,4 @@ s32 __osContRamWrite(OSMesgQueue* mq, int channel, u16 address, u8* buffer, int __osSiRelAccess(); return ret; -}
\ No newline at end of file +} diff --git a/lib/ultralib/src/io/contreaddata.c b/lib/ultralib/src/io/contreaddata.c index 60b9493..da0cac3 100644 --- a/lib/ultralib/src/io/contreaddata.c +++ b/lib/ultralib/src/io/contreaddata.c @@ -23,14 +23,14 @@ s32 osContStartReadData(OSMesgQueue* mq) { } void osContGetReadData(OSContPad* data) { - u8* ptr = __osContPifRam.ramarray; + u8* ptr = (u8*)__osContPifRam.ramarray; __OSContReadFormat readformat; int i; for (i = 0; i < __osMaxControllers; i++, ptr += sizeof(__OSContReadFormat), data++) { readformat = *(__OSContReadFormat*)ptr; data->errno = CHNL_ERR(readformat); - + if (data->errno != 0) { continue; } @@ -42,7 +42,7 @@ void osContGetReadData(OSContPad* data) { } static void __osPackReadData(void) { - u8* ptr = __osContPifRam.ramarray; + u8* ptr = (u8*)__osContPifRam.ramarray; __OSContReadFormat readformat; int i; @@ -63,6 +63,6 @@ static void __osPackReadData(void) { *(__OSContReadFormat*)ptr = readformat; ptr += sizeof(__OSContReadFormat); } - + *ptr = CONT_CMD_END; } diff --git a/lib/ultralib/src/io/contreset.c b/lib/ultralib/src/io/contreset.c index ab30a47..140088a 100644 --- a/lib/ultralib/src/io/contreset.c +++ b/lib/ultralib/src/io/contreset.c @@ -4,48 +4,48 @@ void __osPackResetData(void); -s32 osContReset(OSMesgQueue *mq, OSContStatus *data) { +s32 osContReset(OSMesgQueue* mq, OSContStatus* data) { u8 pattern; s32 ret; - + __osSiGetAccess(); if (__osContLastCmd != CONT_CMD_RESET) { __osPackResetData(); - + ret = __osSiRawStartDma(OS_WRITE, __osContPifRam.ramarray); osRecvMesg(mq, NULL, OS_MESG_BLOCK); ret = __osSiRawStartDma(OS_READ, __osContPifRam.ramarray); osRecvMesg(mq, NULL, OS_MESG_BLOCK); - + __osPackRequestData(CONT_CMD_RESET); - + ret = __osSiRawStartDma(OS_WRITE, __osContPifRam.ramarray); osRecvMesg(mq, NULL, OS_MESG_BLOCK); - + __osContLastCmd = CONT_CMD_RESET; } ret = __osSiRawStartDma(OS_READ, __osContPifRam.ramarray); osRecvMesg(mq, NULL, OS_MESG_BLOCK); - + __osContGetInitData(&pattern, data); __osSiRelAccess(); - + return ret; } void __osPackResetData(void) { - u8 *ptr; + u8* ptr; int i; __osContPifRam.pifstatus = CONT_CMD_EXE; - ptr = __osContPifRam.ramarray; + ptr = (u8*)__osContPifRam.ramarray; for (i = 0; i < MAXCONTROLLERS; i++) { *ptr++ = CONT_CMD_CHANNEL_RESET; } - + *ptr = CONT_CMD_END; } diff --git a/lib/ultralib/src/io/controller.c b/lib/ultralib/src/io/controller.c index db9b769..728c207 100644 --- a/lib/ultralib/src/io/controller.c +++ b/lib/ultralib/src/io/controller.c @@ -1,8 +1,7 @@ #include "macros.h" #include "PR/os_internal.h" #include "controller.h" - -s32 __osContinitialized = 0; +#include "siint.h" OSPifRam __osContPifRam ALIGNED(16); u8 __osContLastCmd; @@ -12,6 +11,8 @@ OSTimer __osEepromTimer; OSMesgQueue __osEepromTimerQ ALIGNED(8); OSMesg __osEepromTimerMsg; +s32 __osContinitialized = 0; + s32 osContInit(OSMesgQueue* mq, u8* bitpattern, OSContStatus* data) { OSMesg dummy; s32 ret = 0; @@ -53,20 +54,21 @@ s32 osContInit(OSMesgQueue* mq, u8* bitpattern, OSContStatus* data) { void __osContGetInitData(u8* pattern, OSContStatus* data) { u8* ptr; __OSContRequesFormat requestHeader; - s32 i; - u8 bits; + int i; + u8 bits = 0; - bits = 0; - ptr = __osContPifRam.ramarray; + ptr = (u8*)__osContPifRam.ramarray; for (i = 0; i < __osMaxControllers; i++, ptr += sizeof(requestHeader), data++) { requestHeader = *(__OSContRequesFormat*)ptr; data->errno = CHNL_ERR(requestHeader); - if (data->errno == 0) { - data->type = requestHeader.typel << 8 | requestHeader.typeh; - data->status = requestHeader.status; - bits |= 1 << i; + if (data->errno != 0) { + continue; } + + data->type = requestHeader.typel << 8 | requestHeader.typeh; + data->status = requestHeader.status; + bits |= 1 << i; } *pattern = bits; } @@ -81,7 +83,7 @@ void __osPackRequestData(u8 cmd) { } __osContPifRam.pifstatus = CONT_CMD_EXE; - ptr = __osContPifRam.ramarray; + ptr = (u8*)__osContPifRam.ramarray; requestHeader.dummy = CONT_CMD_NOP; requestHeader.txsize = CONT_CMD_RESET_TX; requestHeader.rxsize = CONT_CMD_RESET_RX; diff --git a/lib/ultralib/src/io/controller.h b/lib/ultralib/src/io/controller.h index efce970..ef67aa4 100755..100644 --- a/lib/ultralib/src/io/controller.h +++ b/lib/ultralib/src/io/controller.h @@ -231,27 +231,27 @@ extern u8 __osMaxControllers; #define ERRCK(fn) \ ret = fn; \ if (ret != 0) \ - return ret; + return ret #define SET_ACTIVEBANK_TO_ZERO \ if (pfs->activebank != 0) \ { \ - ERRCK(__osPfsSelectBank(pfs, 0)) \ - } + ERRCK(__osPfsSelectBank(pfs, 0)); \ + } (void)0 #define PFS_CHECK_ID \ if (__osCheckId(pfs) == PFS_ERR_NEW_PACK) \ - return PFS_ERR_NEW_PACK; + return PFS_ERR_NEW_PACK #define PFS_CHECK_STATUS \ if ((pfs->status & PFS_INITIALIZED) == 0) \ - return PFS_ERR_INVALID; + return PFS_ERR_INVALID #define PFS_GET_STATUS \ __osSiGetAccess(); \ ret = __osPfsGetStatus(queue, channel); \ __osSiRelAccess(); \ if (ret != 0) \ - return ret; + return ret #endif diff --git a/lib/ultralib/src/io/controller_voice.h b/lib/ultralib/src/io/controller_voice.h index 7223d06..1b9dee6 100644 --- a/lib/ultralib/src/io/controller_voice.h +++ b/lib/ultralib/src/io/controller_voice.h @@ -1,7 +1,7 @@ #ifndef CONTROLLER_VOICE_H #define CONTROLLER_VOICE_H -#include <PR/ultratypes.h> +#include "PR/ultratypes.h" typedef struct { /* 0x0 */ u8 dummy; diff --git a/lib/ultralib/src/io/contsetch.c b/lib/ultralib/src/io/contsetch.c index eff63a6..0cababd 100644 --- a/lib/ultralib/src/io/contsetch.c +++ b/lib/ultralib/src/io/contsetch.c @@ -16,4 +16,4 @@ s32 osContSetCh(u8 ch) { __osContLastCmd = CONT_CMD_END; __osSiRelAccess(); return ret; -}
\ No newline at end of file +} diff --git a/lib/ultralib/src/io/crc.c b/lib/ultralib/src/io/crc.c index e266152..05f2698 100644 --- a/lib/ultralib/src/io/crc.c +++ b/lib/ultralib/src/io/crc.c @@ -2,12 +2,12 @@ u8 __osContAddressCrc(u16 addr) { u32 temp = 0; - u32 i; + u32 i = 0x400; - for (i = 0x400; i != 0;) { + do { temp <<= 1; - if (addr & i) { + if ((u32)addr & i) { if (temp & 0x20) { temp ^= 0x14; } else { @@ -16,21 +16,23 @@ u8 __osContAddressCrc(u16 addr) { } else if (temp & 0x20) { temp ^= 0x15; } - + i >>= 1; - } + } while (i != 0); - for (i = 5; i != 0; --i) { + i = 5; + + do { temp <<= 1; if (temp & 0x20) { temp ^= 0x15; } - } + } while (--i != 0); return temp & 0x1F; } -u8 __osContDataCrc(u8 *data) { +u8 __osContDataCrc(u8* data) { u32 temp = 0; u32 i; u32 j; diff --git a/lib/ultralib/src/io/devmgr.c b/lib/ultralib/src/io/devmgr.c index 2d22774..616dee5 100644 --- a/lib/ultralib/src/io/devmgr.c +++ b/lib/ultralib/src/io/devmgr.c @@ -2,32 +2,32 @@ #include "PR/rcp.h" #include "piint.h" -void __osDevMgrMain(void *args) -{ - OSIoMesg *mb = NULL; +void __osDevMgrMain(void* args) { + OSIoMesg* mb; OSMesg em; OSMesg dummy; - s32 ret = 0; - OSDevMgr *dm = (OSDevMgr *)args; + s32 ret; + OSDevMgr* dm; s32 messageSend = 0; - while (TRUE) - { + dm = (OSDevMgr*)args; + mb = NULL; + ret = 0; + + while (TRUE) { osRecvMesg(dm->cmdQueue, (OSMesg)&mb, OS_MESG_BLOCK); - if (mb->piHandle != NULL && - mb->piHandle->type == DEVICE_TYPE_64DD && + if (mb->piHandle != NULL && mb->piHandle->type == DEVICE_TYPE_64DD && (mb->piHandle->transferInfo.cmdType == LEO_CMD_TYPE_0 || - mb->piHandle->transferInfo.cmdType == LEO_CMD_TYPE_1)) - { - __OSBlockInfo *blockInfo; - __OSTranxInfo *info; + mb->piHandle->transferInfo.cmdType == LEO_CMD_TYPE_1)) { + __OSBlockInfo* blockInfo; + __OSTranxInfo* info; info = &mb->piHandle->transferInfo; blockInfo = &info->block[info->blockNum]; info->sectorNum = -1; if (info->transferMode != LEO_SECTOR_MODE) { - blockInfo->dramAddr = (void *)((u32)blockInfo->dramAddr - blockInfo->sectorSize); + blockInfo->dramAddr = (void*)((u32)blockInfo->dramAddr - blockInfo->sectorSize); } if (info->transferMode == LEO_TRACK_MODE && mb->piHandle->transferInfo.cmdType == LEO_CMD_TYPE_0) { @@ -40,33 +40,33 @@ void __osDevMgrMain(void *args) __osResetGlobalIntMask(OS_IM_PI); __osEPiRawWriteIo(mb->piHandle, LEO_BM_CTL, (info->bmCtlShadow | 0x80000000)); -readblock1: - osRecvMesg(dm->evtQueue, &em, OS_MESG_BLOCK); - info = &mb->piHandle->transferInfo; - blockInfo = &info->block[info->blockNum]; + readblock1: + osRecvMesg(dm->evtQueue, &em, OS_MESG_BLOCK); + info = &mb->piHandle->transferInfo; + blockInfo = &info->block[info->blockNum]; - if (blockInfo->errStatus == LEO_ERROR_29) { - u32 stat; - __osEPiRawWriteIo(mb->piHandle, LEO_BM_CTL, info->bmCtlShadow | LEO_BM_CTL_RESET); - __osEPiRawWriteIo(mb->piHandle, LEO_BM_CTL, info->bmCtlShadow); - __osEPiRawReadIo(mb->piHandle, LEO_STATUS, &stat); + if (blockInfo->errStatus == LEO_ERROR_29) { + u32 stat; + __osEPiRawWriteIo(mb->piHandle, LEO_BM_CTL, info->bmCtlShadow | LEO_BM_CTL_RESET); + __osEPiRawWriteIo(mb->piHandle, LEO_BM_CTL, info->bmCtlShadow); + __osEPiRawReadIo(mb->piHandle, LEO_STATUS, &stat); - if (stat & LEO_STATUS_MECHANIC_INTERRUPT) { - __osEPiRawWriteIo(mb->piHandle, LEO_BM_CTL, info->bmCtlShadow | LEO_BM_CTL_CLR_MECHANIC_INTR); - } - - blockInfo->errStatus = LEO_ERROR_4; - IO_WRITE(PI_STATUS_REG, PI_CLR_INTR); - __osSetGlobalIntMask(OS_IM_PI | SR_IBIT4); + if (stat & LEO_STATUS_MECHANIC_INTERRUPT) { + __osEPiRawWriteIo(mb->piHandle, LEO_BM_CTL, info->bmCtlShadow | LEO_BM_CTL_CLR_MECHANIC_INTR); } - osSendMesg(mb->hdr.retQueue, mb, OS_MESG_NOBLOCK); + blockInfo->errStatus = LEO_ERROR_4; + IO_WRITE(PI_STATUS_REG, PI_CLR_INTR); + __osSetGlobalIntMask(OS_IM_PI | SR_IBIT4); + } + + osSendMesg(mb->hdr.retQueue, mb, OS_MESG_NOBLOCK); + + if (messageSend == 1 && mb->piHandle->transferInfo.block[0].errStatus == LEO_ERROR_GOOD) { + messageSend = 0; + goto readblock1; + } - if (messageSend == 1 && mb->piHandle->transferInfo.block[0].errStatus == LEO_ERROR_GOOD) { - messageSend = 0; - goto readblock1; - } - osSendMesg(dm->acsQueue, NULL, OS_MESG_NOBLOCK); if (mb->piHandle->transferInfo.blockNum == 1) { osYieldThread(); @@ -83,13 +83,11 @@ readblock1: break; case OS_MESG_TYPE_EDMAREAD: osRecvMesg(dm->acsQueue, &dummy, OS_MESG_BLOCK); - ret = dm->edma(mb->piHandle, OS_READ, mb->devAddr, mb->dramAddr, - mb->size); + ret = dm->edma(mb->piHandle, OS_READ, mb->devAddr, mb->dramAddr, mb->size); break; case OS_MESG_TYPE_EDMAWRITE: osRecvMesg(dm->acsQueue, &dummy, OS_MESG_BLOCK); - ret = dm->edma(mb->piHandle, OS_WRITE, mb->devAddr, mb->dramAddr, - mb->size); + ret = dm->edma(mb->piHandle, OS_WRITE, mb->devAddr, mb->dramAddr, mb->size); break; case OS_MESG_TYPE_LOOPBACK: osSendMesg(mb->hdr.retQueue, mb, OS_MESG_NOBLOCK); diff --git a/lib/ultralib/src/io/dp.c b/lib/ultralib/src/io/dp.c index e4d0254..e636217 100755..100644 --- a/lib/ultralib/src/io/dp.c +++ b/lib/ultralib/src/io/dp.c @@ -9,7 +9,7 @@ int __osDpDeviceBusy(void) { if (stat & DPC_STATUS_DMA_BUSY) { return TRUE; + } else { + return FALSE; } - - return FALSE; } diff --git a/lib/ultralib/src/io/dpctr.c b/lib/ultralib/src/io/dpctr.c index 0c2164b..a53b030 100755..100644 --- a/lib/ultralib/src/io/dpctr.c +++ b/lib/ultralib/src/io/dpctr.c @@ -1,7 +1,7 @@ #include "PR/os_internal.h" #include "PR/rcp.h" -void osDpGetCounters(u32 *array) { +void osDpGetCounters(u32* array) { *array++ = IO_READ(DPC_CLOCK_REG); *array++ = IO_READ(DPC_BUFBUSY_REG); *array++ = IO_READ(DPC_PIPEBUSY_REG); diff --git a/lib/ultralib/src/io/dpgetstat.c b/lib/ultralib/src/io/dpgetstat.c index af3ccee..af3ccee 100755..100644 --- a/lib/ultralib/src/io/dpgetstat.c +++ b/lib/ultralib/src/io/dpgetstat.c diff --git a/lib/ultralib/src/io/dpsetnextbuf.c b/lib/ultralib/src/io/dpsetnextbuf.c index fa9a0d4..6314472 100755..100644 --- a/lib/ultralib/src/io/dpsetnextbuf.c +++ b/lib/ultralib/src/io/dpsetnextbuf.c @@ -1,23 +1,38 @@ #include "PR/os_internal.h" +#include "PR/ultraerror.h" #include "PR/rcp.h" #include "../os/osint.h" // TODO: this comes from a header #ident "$Revision: 1.17 $" -s32 osDpSetNextBuffer(void *bufPtr, u64 size) { +s32 osDpSetNextBuffer(void* bufPtr, u64 size) { register u32 stat; +#ifdef _DEBUG + if ((u32)bufPtr & 0x7) { + __osError(ERR_OSDPSETNEXTBUFFER_ADDR, 1, bufPtr); + return -1; + } + if (size & 0x7) { + __osError(ERR_OSDPSETNEXTBUFFER_SIZE, 1, size); + return -1; + } +#endif + if (__osDpDeviceBusy()) { return -1; } IO_WRITE(DPC_STATUS_REG, DPC_CLR_XBUS_DMEM_DMA); - - do { + + while (TRUE) { stat = IO_READ(DPC_STATUS_REG); - } while (stat & DPC_STATUS_XBUS_DMEM_DMA); - + if ((stat & DPC_STATUS_XBUS_DMEM_DMA) == 0) { + break; + } + } + IO_WRITE(DPC_START_REG, osVirtualToPhysical(bufPtr)); IO_WRITE(DPC_END_REG, osVirtualToPhysical(bufPtr) + size); return 0; diff --git a/lib/ultralib/src/io/dpsetstat.c b/lib/ultralib/src/io/dpsetstat.c index 5b53867..5b53867 100755..100644 --- a/lib/ultralib/src/io/dpsetstat.c +++ b/lib/ultralib/src/io/dpsetstat.c diff --git a/lib/ultralib/src/io/epidma.c b/lib/ultralib/src/io/epidma.c index d122791..06a9f69 100644 --- a/lib/ultralib/src/io/epidma.c +++ b/lib/ultralib/src/io/epidma.c @@ -1,11 +1,48 @@ #include "piint.h" +#include "PR/ultraerror.h" s32 osEPiStartDma(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) { - s32 ret; + register s32 ret; if (!__osPiDevMgr.active) { +#ifdef _DEBUG + __osError(ERR_OSPISTARTDMA_PIMGR, 0); +#endif return -1; } + +#ifdef _DEBUG + if ((mb->hdr.pri != OS_MESG_PRI_NORMAL) && (mb->hdr.pri != OS_MESG_PRI_HIGH)) { + __osError(ERR_OSPISTARTDMA_PRI, 1, mb->hdr.pri); + return -1; + } + + if ((direction != OS_READ) && (direction != OS_WRITE)) { + __osError(ERR_OSPISTARTDMA_DIR, 1, direction); + return -1; + } + + if (mb->devAddr & 0x1) { + __osError(ERR_OSPISTARTDMA_DEVADDR, 1, mb->devAddr); + return -1; + } + + if ((u32)mb->dramAddr & 0x7) { + __osError(ERR_OSPISTARTDMA_ADDR, 1, mb->dramAddr); + return -1; + } + + if (mb->size & 0x1) { + __osError(ERR_OSPISTARTDMA_SIZE, 1, mb->size); + return -1; + } + + if ((mb->size == 0) || (mb->size > (16 * 1024 * 1024))) { + __osError(ERR_OSPISTARTDMA_RANGE, 1, mb->size); + return -1; + } +#endif + mb->piHandle = pihandle; if (direction == OS_READ) { diff --git a/lib/ultralib/src/io/epigettype.c b/lib/ultralib/src/io/epigettype.c index ef749ea..c94012c 100644 --- a/lib/ultralib/src/io/epigettype.c +++ b/lib/ultralib/src/io/epigettype.c @@ -1,7 +1,6 @@ #include "piint.h" -s32 osEPiGetDeviceType(OSPiHandle *pihandle, OSPiInfo *info) -{ +s32 osEPiGetDeviceType(OSPiHandle* pihandle, OSPiInfo* info) { info->type = pihandle->type; info->address = pihandle->baseAddress; return 0; diff --git a/lib/ultralib/src/io/epilinkhandle.c b/lib/ultralib/src/io/epilinkhandle.c index 8785bdb..5f51854 100644 --- a/lib/ultralib/src/io/epilinkhandle.c +++ b/lib/ultralib/src/io/epilinkhandle.c @@ -1,8 +1,7 @@ #include "piint.h" -s32 osEPiLinkHandle(OSPiHandle *EPiHandle) -{ - register s32 saveMask = __osDisableInt(); +s32 osEPiLinkHandle(OSPiHandle* EPiHandle) { + u32 saveMask = __osDisableInt(); EPiHandle->next = __osPiTable; __osPiTable = EPiHandle; diff --git a/lib/ultralib/src/io/epirawdma.c b/lib/ultralib/src/io/epirawdma.c index 63ad6cf..69a404d 100644 --- a/lib/ultralib/src/io/epirawdma.c +++ b/lib/ultralib/src/io/epirawdma.c @@ -1,19 +1,45 @@ #include "piint.h" +#include "PR/ultraerror.h" // TODO: this comes from a header #ident "$Revision: 1.17 $" -s32 __osEPiRawStartDma(OSPiHandle *pihandle, s32 direction, u32 devAddr, void *dramAddr, u32 size) -{ +s32 __osEPiRawStartDma(OSPiHandle* pihandle, s32 direction, u32 devAddr, void* dramAddr, u32 size) { u32 stat; u32 domain; +#ifdef _DEBUG + if ((direction != OS_READ) && (direction != OS_WRITE)) { + __osError(ERR_OSPIRAWSTARTDMA_DIR, 1, direction); + return -1; + } + + if (devAddr & 0x1) { + __osError(ERR_OSPIRAWSTARTDMA_DEVADDR, 1, devAddr); + return -1; + } + + if ((u32)dramAddr & 0x7) { + __osError(ERR_OSPIRAWSTARTDMA_ADDR, 1, dramAddr); + return -1; + } + + if (size & 0x1) { + __osError(ERR_OSPIRAWSTARTDMA_SIZE, 1, size); + return -1; + } + + if ((size == 0) || (size > (16 * 1024 * 1024))) { + __osError(ERR_OSPIRAWSTARTDMA_RANGE, 1, size); + return -1; + } +#endif + EPI_SYNC(pihandle, stat, domain); IO_WRITE(PI_DRAM_ADDR_REG, osVirtualToPhysical(dramAddr)); IO_WRITE(PI_CART_ADDR_REG, K1_TO_PHYS(pihandle->baseAddress | devAddr)); - switch (direction) - { + switch (direction) { case OS_READ: IO_WRITE(PI_WR_LEN_REG, size - 1); break; diff --git a/lib/ultralib/src/io/epirawread.c b/lib/ultralib/src/io/epirawread.c index 7871f56..7794eb8 100644 --- a/lib/ultralib/src/io/epirawread.c +++ b/lib/ultralib/src/io/epirawread.c @@ -1,11 +1,46 @@ #include "piint.h" +#include "PR/ultraerror.h" +#include "assert.h" + + + + + + + + + + + + + + + + + + + + + + + + // TODO: this comes from a header #ident "$Revision: 1.17 $" s32 __osEPiRawReadIo(OSPiHandle* pihandle, u32 devAddr, u32* data) { - u32 stat; - u32 domain; + register u32 stat; + register u32 domain; + +#ifdef _DEBUG + if (devAddr & 0x3) { + __osError(ERR_OSPIRAWREADIO, 1, devAddr); + return -1; + } + + assert(data != NULL); +#endif EPI_SYNC(pihandle, stat, domain); *data = IO_READ(pihandle->baseAddress | devAddr); diff --git a/lib/ultralib/src/io/epirawwrite.c b/lib/ultralib/src/io/epirawwrite.c index 5cc1752..79fba31 100644 --- a/lib/ultralib/src/io/epirawwrite.c +++ b/lib/ultralib/src/io/epirawwrite.c @@ -1,11 +1,19 @@ #include "piint.h" +#include "PR/ultraerror.h" // TODO: this comes from a header #ident "$Revision: 1.17 $" s32 __osEPiRawWriteIo(OSPiHandle* pihandle, u32 devAddr, u32 data) { - u32 stat; - u32 domain; + register u32 stat; + register u32 domain; + +#ifdef _DEBUG + if (devAddr & 0x3) { + __osError(ERR_OSPIRAWWRITEIO, 1, devAddr); + return -1; + } +#endif EPI_SYNC(pihandle, stat, domain); IO_WRITE(pihandle->baseAddress | devAddr, data); diff --git a/lib/ultralib/src/io/epiread.c b/lib/ultralib/src/io/epiread.c index 3918c5f..08cd0be 100644 --- a/lib/ultralib/src/io/epiread.c +++ b/lib/ultralib/src/io/epiread.c @@ -1,10 +1,16 @@ #include "piint.h" - -s32 __osEPiRawReadIo(OSPiHandle*, u32, u32*); +#include "PR/ultraerror.h" s32 osEPiReadIo(OSPiHandle* pihandle, u32 devAddr, u32* data) { register s32 ret; +#ifdef _DEBUG + if (devAddr & 0x3) { + __osError(ERR_OSPIREADIO, 1, devAddr); + return -1; + } +#endif + __osPiGetAccess(); ret = __osEPiRawReadIo(pihandle, devAddr, data); __osPiRelAccess(); diff --git a/lib/ultralib/src/io/epiwrite.c b/lib/ultralib/src/io/epiwrite.c index 1a4c462..42a239e 100644 --- a/lib/ultralib/src/io/epiwrite.c +++ b/lib/ultralib/src/io/epiwrite.c @@ -1,10 +1,16 @@ #include "piint.h" - -s32 __osEPiRawWriteIo(OSPiHandle*, u32, u32); +#include "PR/ultraerror.h" s32 osEPiWriteIo(OSPiHandle* pihandle, u32 devAddr, u32 data) { register s32 ret; +#ifdef _DEBUG + if (devAddr & 0x3) { + __osError(ERR_OSPIWRITEIO, 1, devAddr); + return -1; + } +#endif + __osPiGetAccess(); ret = __osEPiRawWriteIo(pihandle, devAddr, data); __osPiRelAccess(); diff --git a/lib/ultralib/src/io/gbpakcheckconnector.c b/lib/ultralib/src/io/gbpakcheckconnector.c index 7fbef18..8eb3298 100644 --- a/lib/ultralib/src/io/gbpakcheckconnector.c +++ b/lib/ultralib/src/io/gbpakcheckconnector.c @@ -27,7 +27,7 @@ s32 osGbpakCheckConnector(OSPfs* pfs, u8* status) { } bzero(buf_status, sizeof(buf_status)); - + for (address = 0x80; address <= 0x4000; address <<= 1) { num = 0; daddr = 0; @@ -49,7 +49,7 @@ s32 osGbpakCheckConnector(OSPfs* pfs, u8* status) { if (bcmp(buf[bufn][num], buf[oldbufn][num], BLOCKSIZE) != 0) { num = 0; break; - } + } daddr += BLOCKSIZE; } while (num++ < ARRLEN(buf[0]) - 1); @@ -81,7 +81,7 @@ s32 osGbpakCheckConnector(OSPfs* pfs, u8* status) { num = 0; break; } - + daddr += BLOCKSIZE; } while (num++ < ARRLEN(buf_status[0]) - 1); } @@ -89,7 +89,7 @@ s32 osGbpakCheckConnector(OSPfs* pfs, u8* status) { if (num != 0) { return PFS_ERR_CONTRFAIL; } - + if (oldbufn != 0) { bzero(buf_status[oldbufn], ARRLEN(buf_status[oldbufn])); } @@ -106,7 +106,7 @@ s32 osGbpakCheckConnector(OSPfs* pfs, u8* status) { do { ERRCK(osGbpakReadWrite(pfs, OS_READ, daddr + 0xA000, buf[bufn][num], BLOCKSIZE)); ERRCK(osGbpakReadWrite(pfs, OS_READ, daddr + 0x2000, buf[oldbufn][num], BLOCKSIZE)); - + if (bcmp(buf[bufn][num], buf[oldbufn][num], BLOCKSIZE)) { num = 0; break; @@ -119,7 +119,7 @@ s32 osGbpakCheckConnector(OSPfs* pfs, u8* status) { return PFS_ERR_CONTRFAIL; } } - + ret = osGbpakGetStatus(pfs, status); if (ret == PFS_ERR_NEW_GBCART) { diff --git a/lib/ultralib/src/io/gbpakgetbank.c b/lib/ultralib/src/io/gbpakgetbank.c index 622e707..a2e5f38 100644 --- a/lib/ultralib/src/io/gbpakgetbank.c +++ b/lib/ultralib/src/io/gbpakgetbank.c @@ -23,6 +23,6 @@ s32 __osGbpakGetBank(OSPfs* pfs, u8* bank) { *bank = ((u8*)temp)[0]; pfs->banks = *bank; } - + return ret; } diff --git a/lib/ultralib/src/io/gbpakinit.c b/lib/ultralib/src/io/gbpakinit.c index 604bafa..d3f19b1 100644 --- a/lib/ultralib/src/io/gbpakinit.c +++ b/lib/ultralib/src/io/gbpakinit.c @@ -4,8 +4,8 @@ #include "controller_gbpak.h" OSTimer __osGbpakTimer; -OSMesg __osGbpakTimerMsg; OSMesgQueue __osGbpakTimerQ ALIGNED(8); +OSMesg __osGbpakTimerMsg; s32 osGbpakInit(OSMesgQueue* mq, OSPfs* pfs, int channel) { int i; @@ -13,10 +13,10 @@ s32 osGbpakInit(OSMesgQueue* mq, OSPfs* pfs, int channel) { u8 temp[BLOCKSIZE]; pfs->status = 0; - + // Turn off the transfer pak - for (i = 0; i < BLOCKSIZE; i++) { - temp[i] = GB_POWER_OFF; + for (i = 0; i < BLOCKSIZE; temp[i++] = GB_POWER_OFF) { + ; } ret = __osContRamWrite(mq, channel, CONT_BLOCK_GB_POWER, temp, FALSE); @@ -44,8 +44,8 @@ s32 osGbpakInit(OSMesgQueue* mq, OSPfs* pfs, int channel) { } // Turn on the transfer pak - for (i = 0; i < BLOCKSIZE; i++) { - temp[i] = GB_POWER_ON; + for (i = 0; i < BLOCKSIZE; temp[i++] = GB_POWER_ON) { + ; } ret = __osContRamWrite(mq, channel, CONT_BLOCK_GB_POWER, temp, FALSE); diff --git a/lib/ultralib/src/io/gbpakpower.c b/lib/ultralib/src/io/gbpakpower.c index c0b78cb..3d4a8f4 100644 --- a/lib/ultralib/src/io/gbpakpower.c +++ b/lib/ultralib/src/io/gbpakpower.c @@ -7,8 +7,8 @@ s32 osGbpakPower(OSPfs* pfs, s32 flag) { s32 ret; u8 temp[BLOCKSIZE]; - for (i = 0; i < BLOCKSIZE; i++) { - temp[i] = (u8) flag; + for (i = 0; i < BLOCKSIZE; temp[i++] = (u8)flag) { + ; } ret = __osContRamWrite(pfs->queue, pfs->channel, CONT_BLOCK_GB_STATUS, temp, 0); @@ -18,13 +18,13 @@ s32 osGbpakPower(OSPfs* pfs, s32 flag) { if (ret == 0) { ret = __osContRamWrite(pfs->queue, pfs->channel, CONT_BLOCK_GB_STATUS, temp, 0); - + if (ret == PFS_ERR_NEW_PACK) { ret = PFS_ERR_CONTRFAIL; } } } - + if (flag != OS_GBPAK_POWER_OFF) { osSetTimer(&__osGbpakTimer, OS_USEC_TO_CYCLES(120000), 0, &__osGbpakTimerQ, &__osGbpakTimerMsg); osRecvMesg(&__osGbpakTimerQ, NULL, OS_MESG_BLOCK); diff --git a/lib/ultralib/src/io/gbpakreadid.c b/lib/ultralib/src/io/gbpakreadid.c index d0cf467..f35ef25 100644 --- a/lib/ultralib/src/io/gbpakreadid.c +++ b/lib/ultralib/src/io/gbpakreadid.c @@ -8,11 +8,15 @@ s32 osGbpakReadId(OSPfs* pfs, OSGbpakId* id, u8* status) { u8 isum; u8 buf[96]; u8 temp[32]; - static u8 nintendo[] = {0xCE, 0xED, 0x66, 0x66, 0xCC, 0x0D, 0x00, 0x0B, 0x03, 0x73, 0x00, 0x83, 0x00, 0x0C, 0x00, 0x0D, 0x00, 0x08, 0x11, 0x1F, 0x88, 0x89, 0x00, 0x0E, 0xDC, 0xCC, 0x6E, 0xE6, 0xDD, 0xDD, 0xD9, 0x99, 0xBB, 0xBB, 0x67, 0x63, 0x6E, 0x0E, 0xEC, 0xCC, 0xDD, 0xDC, 0x99, 0x9F, 0xBB, 0xB9, 0x33, 0x3E}; - static u8 mmc_type[] = {0x00, 0x01, 0x01, 0x01, 0xFF, 0x02, 0x02, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03}; + static u8 nintendo[] = { 0xCE, 0xED, 0x66, 0x66, 0xCC, 0x0D, 0x00, 0x0B, 0x03, 0x73, 0x00, 0x83, + 0x00, 0x0C, 0x00, 0x0D, 0x00, 0x08, 0x11, 0x1F, 0x88, 0x89, 0x00, 0x0E, + 0xDC, 0xCC, 0x6E, 0xE6, 0xDD, 0xDD, 0xD9, 0x99, 0xBB, 0xBB, 0x67, 0x63, + 0x6E, 0x0E, 0xEC, 0xCC, 0xDD, 0xDC, 0x99, 0x9F, 0xBB, 0xB9, 0x33, 0x3E }; + static u8 mmc_type[] = { 0x00, 0x01, 0x01, 0x01, 0xFF, 0x02, 0x02, 0xFF, 0x00, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03 }; ret = osGbpakGetStatus(pfs, status); - + if (ret == PFS_ERR_NEW_GBCART) { ret = osGbpakGetStatus(pfs, status); } @@ -28,7 +32,7 @@ s32 osGbpakReadId(OSPfs* pfs, OSGbpakId* id, u8* status) { ret = osGbpakGetStatus(pfs, status); - if (ret == 0xD) { + if (ret == PFS_ERR_NEW_GBCART) { ret = PFS_ERR_CONTRFAIL; } @@ -41,24 +45,24 @@ s32 osGbpakReadId(OSPfs* pfs, OSGbpakId* id, u8* status) { } if (bcmp(nintendo, buf + 4, ARRLEN(nintendo))) { - for (i = 0; i < ARRLEN(temp); i++) { - temp[i] = 0; + for (i = 0; i < ARRLEN(temp); temp[i++] = 0) { + ; } - ERRCK(osGbpakReadWrite(pfs, OS_WRITE, 0x6000U, temp, ARRLEN(temp))); + ERRCK(osGbpakReadWrite(pfs, OS_WRITE, 0x6000U, temp, ARRLEN(temp))); ret = osGbpakReadWrite(pfs, OS_READ, 0x100U, buf, ARRLEN(buf)); ERRCK(osGbpakReadWrite(pfs, OS_READ, 0x100U, buf, ARRLEN(buf))); - + ret = osGbpakGetStatus(pfs, status); - + if (ret == PFS_ERR_NEW_GBCART) { ret = PFS_ERR_CONTRFAIL; } - + if (ret != 0) { return ret; } - + if (bcmp(nintendo, buf + 4, ARRLEN(nintendo))) { return 4; } @@ -70,13 +74,13 @@ s32 osGbpakReadId(OSPfs* pfs, OSGbpakId* id, u8* status) { if ((isum + 0x19) & 0xFF) { return 4; } - + bcopy(buf, id, 0x50); - + if (id->cart_type < 0x14) { pfs->version = (int)mmc_type[id->cart_type]; } - + pfs->dir_size = (int)id->ram_size; } diff --git a/lib/ultralib/src/io/gbpakreadwrite.c b/lib/ultralib/src/io/gbpakreadwrite.c index 5fac5ce..c73b536 100644 --- a/lib/ultralib/src/io/gbpakreadwrite.c +++ b/lib/ultralib/src/io/gbpakreadwrite.c @@ -1,28 +1,30 @@ #include "PR/os_internal.h" #include "controller.h" +s32 __osGbpakSetBank(OSPfs* pfs, u8 bank); + s32 osGbpakReadWrite(OSPfs* pfs, u16 flag, u16 address, u8* buffer, u16 size) { s32 i; s32 ret; u8 bank; - bank = (u8) (address >> 0xE); + bank = (u8)(address >> 0xE); if (bank != pfs->banks) { ret = __osGbpakSetBank(pfs, bank); - + if (ret != 0) { return ret; } } - + if (size == 0) { return 0; } size = (u16)(size >> 5); address = (u16)((address | 0xC000) >> 5); - + if (flag == 1) { for (i = 0; i < (s32)size; i++, buffer += BLOCKSIZE) { ret = __osContRamWrite(pfs->queue, pfs->channel, address, buffer, 0); diff --git a/lib/ultralib/src/io/gbpaksetbank.c b/lib/ultralib/src/io/gbpaksetbank.c index 134cad8..7a08646 100644 --- a/lib/ultralib/src/io/gbpaksetbank.c +++ b/lib/ultralib/src/io/gbpaksetbank.c @@ -10,8 +10,8 @@ s32 __osGbpakSetBank(OSPfs* pfs, u8 bank) { return PFS_ERR_INVALID; } - for (i = 0; i < BLOCKSIZE; i++) { - temp[i] = bank; + for (i = 0; i < BLOCKSIZE; temp[i++] = bank) { + ; } ret = __osContRamWrite(pfs->queue, pfs->channel, CONT_BLOCK_GB_BANK, temp, FALSE); diff --git a/lib/ultralib/src/io/motor.c b/lib/ultralib/src/io/motor.c index df36414..8ad1b08 100644 --- a/lib/ultralib/src/io/motor.c +++ b/lib/ultralib/src/io/motor.c @@ -3,7 +3,7 @@ #include "controller.h" #include "siint.h" -static OSPifRam __MotorDataBuf[MAXCONTROLLERS]; +static OSPifRam __MotorDataBuf[MAXCONTROLLERS] ALIGNED(8); #define READFORMAT(ptr) ((__OSContRamReadFormat*)(ptr)) @@ -27,7 +27,7 @@ s32 __osMotorAccess(OSPfs* pfs, s32 flag) { __osContLastCmd = CONT_CMD_END; __osSiRawStartDma(OS_WRITE, &__MotorDataBuf[pfs->channel]); osRecvMesg(pfs->queue, NULL, OS_MESG_BLOCK); - __osSiRawStartDma(OS_READ, &__MotorDataBuf[pfs->channel]); + ret = __osSiRawStartDma(OS_READ, &__MotorDataBuf[pfs->channel]); osRecvMesg(pfs->queue, NULL, OS_MESG_BLOCK); ret = READFORMAT(ptr)->rxsize & CHNL_ERR_MASK; @@ -48,8 +48,8 @@ s32 __osMotorAccess(OSPfs* pfs, s32 flag) { return ret; } -static void _MakeMotorData(int channel, OSPifRam *mdata) { - u8 *ptr = (u8 *)mdata->ramarray; +static void __osMakeMotorData(int channel, OSPifRam* mdata) { + u8* ptr = (u8*)mdata->ramarray; __OSContRamReadFormat ramreadformat; int i; @@ -59,7 +59,7 @@ static void _MakeMotorData(int channel, OSPifRam *mdata) { ramreadformat.cmd = CONT_CMD_WRITE_PAK; ramreadformat.addrh = CONT_BLOCK_RUMBLE >> 3; ramreadformat.addrl = (u8)(__osContAddressCrc(CONT_BLOCK_RUMBLE) | (CONT_BLOCK_RUMBLE << 5)); - + if (channel != 0) { for (i = 0; i < channel; i++) { *ptr++ = CONT_CMD_REQUEST_STATUS; @@ -71,8 +71,7 @@ static void _MakeMotorData(int channel, OSPifRam *mdata) { ptr[0] = CONT_CMD_END; } -s32 osMotorInit(OSMesgQueue *mq, OSPfs *pfs, int channel) -{ +s32 osMotorInit(OSMesgQueue* mq, OSPfs* pfs, int channel) { s32 ret; u8 temp[32]; @@ -82,7 +81,7 @@ s32 osMotorInit(OSMesgQueue *mq, OSPfs *pfs, int channel) pfs->status = 0; ret = __osPfsSelectBank(pfs, 0xFE); - + if (ret == PFS_ERR_NEW_PACK) { ret = __osPfsSelectBank(pfs, 0x80); } @@ -99,9 +98,7 @@ s32 osMotorInit(OSMesgQueue *mq, OSPfs *pfs, int channel) if (ret != 0) { return ret; - } - - if (temp[31] == 254) { + } else if (temp[31] == 254) { return PFS_ERR_DEVICE; } @@ -109,7 +106,7 @@ s32 osMotorInit(OSMesgQueue *mq, OSPfs *pfs, int channel) if (ret == PFS_ERR_NEW_PACK) { ret = PFS_ERR_CONTRFAIL; } - + if (ret != 0) { return ret; } @@ -118,17 +115,15 @@ s32 osMotorInit(OSMesgQueue *mq, OSPfs *pfs, int channel) if (ret == PFS_ERR_NEW_PACK) { ret = PFS_ERR_CONTRFAIL; } - + if (ret != 0) { return ret; - } - - if (temp[31] != 0x80) { + } else if (temp[31] != 0x80) { return PFS_ERR_DEVICE; } if (!(pfs->status & PFS_MOTOR_INITIALIZED)) { - _MakeMotorData(channel, &__MotorDataBuf[channel]); + __osMakeMotorData(channel, &__MotorDataBuf[channel]); } pfs->status = PFS_MOTOR_INITIALIZED; diff --git a/lib/ultralib/src/io/pfsallocatefile.c b/lib/ultralib/src/io/pfsallocatefile.c index 84ef32f..5e1a85f 100644 --- a/lib/ultralib/src/io/pfsallocatefile.c +++ b/lib/ultralib/src/io/pfsallocatefile.c @@ -1,9 +1,11 @@ #include "PR/os_internal.h" #include "controller.h" +#include "PR/rmon.h" -#define ROUND_UP_DIVIDE(numerator, denominator) (((numerator) + (denominator) - 1) / (denominator)) +#define ROUND_UP_DIVIDE(numerator, denominator) (((numerator) + (denominator)-1) / (denominator)) -s32 osPfsAllocateFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, u8 *ext_name, int file_size_in_bytes, s32 *file_no) { +s32 osPfsAllocateFile(OSPfs* pfs, u16 company_code, u32 game_code, u8* game_name, u8* ext_name, int file_size_in_bytes, + s32* file_no) { int start_page; int decleared; int last_page; @@ -25,12 +27,9 @@ s32 osPfsAllocateFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name file_size_in_pages = ROUND_UP_DIVIDE(file_size_in_bytes, BLOCKSIZE * PFS_ONE_PAGE); - ret = osPfsFindFile(pfs, company_code, game_code, game_name, ext_name, file_no); - - if (ret != 0) { - if (ret != PFS_ERR_INVALID) { - return ret; - } + if (((ret = osPfsFindFile(pfs, company_code, game_code, game_name, ext_name, file_no)) != 0) && + ret != PFS_ERR_INVALID) { + return ret; } if (*file_no != -1) { @@ -38,7 +37,7 @@ s32 osPfsAllocateFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name } ret = osPfsFreeBlocks(pfs, &bytes); - + if (file_size_in_bytes > bytes) { return PFS_DATA_FULL; } @@ -47,19 +46,16 @@ s32 osPfsAllocateFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name return PFS_ERR_INVALID; } - ret = osPfsFindFile(pfs, 0, 0, NULL, NULL, file_no); - if (ret != 0) { - if (ret != PFS_ERR_INVALID) { - return ret; - } + if (((ret = osPfsFindFile(pfs, 0, 0, NULL, NULL, file_no)) != 0) && ret != PFS_ERR_INVALID) { + return ret; } - + if (*file_no == -1) { return PFS_DIR_FULL; } for (bank = 0; bank < pfs->banks; bank++) { - ERRCK(__osPfsRWInode(pfs, &inode, OS_READ, bank)); + ERRCK(__osPfsRWInode(pfs, &inode, PFS_READ, bank)); ERRCK(__osPfsDeclearPage(pfs, &inode, file_size_in_pages, &start_page, bank, &decleared, &last_page)); if (start_page != -1) { @@ -69,7 +65,7 @@ s32 osPfsAllocateFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name } else { backup_inode.inode_page[old_last_page].inode_t.bank = bank; backup_inode.inode_page[old_last_page].inode_t.page = start_page; - ERRCK(__osPfsRWInode(pfs, &backup_inode, OS_WRITE, old_bank)); + ERRCK(__osPfsRWInode(pfs, &backup_inode, PFS_WRITE, old_bank)); } if (file_size_in_pages > decleared) { @@ -97,16 +93,16 @@ s32 osPfsAllocateFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name bcopy(game_name, dir.game_name, PFS_FILE_NAME_LEN); bcopy(ext_name, dir.ext_name, PFS_FILE_EXT_LEN); - - return __osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + *file_no, (u8*)&dir, FALSE); + + ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + *file_no, (u8*)&dir, FALSE); + return ret; } -s32 __osPfsDeclearPage(OSPfs *pfs, __OSInode *inode, int file_size_in_pages, int *first_page, u8 bank, int *decleared, int *last_page) -{ +s32 __osPfsDeclearPage(OSPfs* pfs, __OSInode* inode, int file_size_in_pages, int* first_page, u8 bank, int* decleared, + int* last_page) { int j; int spage; int old_page; - int i; s32 ret = 0; int offset = bank > 0 ? 1 : pfs->inode_start_page; @@ -123,8 +119,9 @@ s32 __osPfsDeclearPage(OSPfs *pfs, __OSInode *inode, int file_size_in_pages, int spage = j; *decleared = 1; - old_page = j++; - + old_page = j; + j++; + while (file_size_in_pages > *decleared && j < ARRLEN(inode->inode_page)) { if (inode->inode_page[j].ipage == 3) { inode->inode_page[old_page].inode_t.bank = bank; @@ -143,6 +140,37 @@ s32 __osPfsDeclearPage(OSPfs *pfs, __OSInode *inode, int file_size_in_pages, int inode->inode_page[old_page].ipage = 1; *last_page = 0; } - + + return ret; +} + +#ifdef _DEBUG +s32 __osDumpInode(OSPfs* pfs) { + int j; + __OSInode inode; + s32 ret = 0; + __OSDir dir; + u8 bank; + u8 startbank = PFS_ID_BANK_256K; + + rmonPrintf("INODE:\n"); + + for (bank = startbank; bank < pfs->banks; bank++) { + rmonPrintf("\nBank %d:\n", bank); + ret = __osPfsRWInode(pfs, &inode, PFS_READ, bank); + for (j = 0; j < PFS_INODE_SIZE_PER_PAGE; j++) { + rmonPrintf("%x ", inode.inode_page[j].ipage); + } + } + + rmonPrintf("dir_size %d %d\n", pfs->dir_size, pfs->inode_start_page); + + for (j = 0; j < pfs->dir_size; j++) { + __osContRamRead(pfs->queue, pfs->channel, (u16)(pfs->dir_table + (int)j), (u8*)&dir); + rmonPrintf("file %d game_code %d page %x c_code %d sum %d\n", j, dir.game_code, dir.start_page.ipage, + dir.company_code, dir.data_sum); + } + rmonPrintf("End of Dump\n"); return ret; } +#endif diff --git a/lib/ultralib/src/io/pfschecker.c b/lib/ultralib/src/io/pfschecker.c index ee71830..6830c0e 100644 --- a/lib/ultralib/src/io/pfschecker.c +++ b/lib/ultralib/src/io/pfschecker.c @@ -1,14 +1,14 @@ #include "PR/os_internal.h" #include "controller.h" -s32 corrupted_init(OSPfs *pfs, __OSInodeCache *cache); -s32 corrupted(OSPfs *pfs, __OSInodeUnit fpage, __OSInodeCache *cache); +s32 corrupted_init(OSPfs* pfs, __OSInodeCache* cache); +s32 corrupted(OSPfs* pfs, __OSInodeUnit fpage, __OSInodeCache* cache); -#define CHECK_IPAGE(p) \ +#define CHECK_IPAGE(p) \ (((p).ipage >= pfs->inode_start_page) && ((p).inode_t.bank < pfs->banks) && ((p).inode_t.page >= 0x01) && \ ((p).inode_t.page < 0x80)) -s32 osPfsChecker(OSPfs *pfs) { +s32 osPfsChecker(OSPfs* pfs) { int j; s32 ret; __OSInodeUnit next_page; @@ -50,7 +50,7 @@ s32 osPfsChecker(OSPfs *pfs) { while (CHECK_IPAGE(next_page)) { if (bank != next_page.inode_t.bank) { bank = next_page.inode_t.bank; - + if (oldbank != bank) { ret = __osPfsRWInode(pfs, &tmp_inode, OS_READ, bank); oldbank = bank; @@ -61,12 +61,10 @@ s32 osPfsChecker(OSPfs *pfs) { } } - cc = corrupted(pfs, next_page, &cache) - cl; - - if (cc != 0) { + if ((cc = corrupted(pfs, next_page, &cache) - cl) != 0) { break; } - + cl = 1; next_page = tmp_inode.inode_page[next_page.inode_t.page]; } @@ -127,7 +125,7 @@ s32 osPfsChecker(OSPfs *pfs) { return 0; } -s32 corrupted_init(OSPfs *pfs, __OSInodeCache *cache) { +s32 corrupted_init(OSPfs* pfs, __OSInodeCache* cache) { int i; int n; int offset; @@ -145,7 +143,7 @@ s32 corrupted_init(OSPfs *pfs, __OSInodeCache *cache) { offset = bank > 0 ? 1 : pfs->inode_start_page; ret = __osPfsRWInode(pfs, &tmp_inode, OS_READ, bank); - + if (ret != 0 && ret != PFS_ERR_INCONSISTENT) { return ret; } @@ -154,7 +152,8 @@ s32 corrupted_init(OSPfs *pfs, __OSInodeCache *cache) { tpage = tmp_inode.inode_page[i]; if (tpage.ipage >= pfs->inode_start_page && tpage.inode_t.bank != bank) { - n = ((tpage.inode_t.page & 0x7F) / PFS_SECTOR_SIZE) + ((tpage.inode_t.bank % PFS_BANK_LAPPED_BY) * BLOCKSIZE); + n = ((tpage.inode_t.page & 0x7F) / PFS_SECTOR_SIZE) + + ((tpage.inode_t.bank % PFS_BANK_LAPPED_BY) * BLOCKSIZE); cache->map[n] |= 1 << (bank % PFS_BANK_LAPPED_BY); } } @@ -162,7 +161,7 @@ s32 corrupted_init(OSPfs *pfs, __OSInodeCache *cache) { return 0; } -s32 corrupted(OSPfs *pfs, __OSInodeUnit fpage, __OSInodeCache *cache) { +s32 corrupted(OSPfs* pfs, __OSInodeUnit fpage, __OSInodeCache* cache) { int j; int n; int hit; @@ -180,7 +179,7 @@ s32 corrupted(OSPfs *pfs, __OSInodeUnit fpage, __OSInodeCache *cache) { if (bank == fpage.inode_t.bank || cache->map[n] & (1 << (bank % PFS_BANK_LAPPED_BY))) { if (bank != cache->bank) { ret = __osPfsRWInode(pfs, &cache->inode, 0, bank); - + if (ret != 0 && ret != PFS_ERR_INCONSISTENT) { return ret; } diff --git a/lib/ultralib/src/io/pfsdeletefile.c b/lib/ultralib/src/io/pfsdeletefile.c index 6ca88eb..a55b09d 100644 --- a/lib/ultralib/src/io/pfsdeletefile.c +++ b/lib/ultralib/src/io/pfsdeletefile.c @@ -1,8 +1,7 @@ #include "PR/os_internal.h" #include "controller.h" -s32 osPfsDeleteFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, - u8 *ext_name) { +s32 osPfsDeleteFile(OSPfs* pfs, u16 company_code, u32 game_code, u8* game_name, u8* ext_name) { s32 file_no; s32 ret; __OSInode inode; @@ -45,7 +44,7 @@ s32 osPfsDeleteFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, return ret; } -s32 __osPfsReleasePages(OSPfs *pfs, __OSInode *inode, u8 start_page, u8 bank, __OSInodeUnit *last_page) { +s32 __osPfsReleasePages(OSPfs* pfs, __OSInode* inode, u8 start_page, u8 bank, __OSInodeUnit* last_page) { __OSInodeUnit next_page; __OSInodeUnit old_page; s32 ret = 0; diff --git a/lib/ultralib/src/io/pfsfilestate.c b/lib/ultralib/src/io/pfsfilestate.c index 7f5cb8b..e617887 100644 --- a/lib/ultralib/src/io/pfsfilestate.c +++ b/lib/ultralib/src/io/pfsfilestate.c @@ -1,7 +1,7 @@ #include "PR/os_internal.h" #include "controller.h" -s32 osPfsFileState(OSPfs *pfs, s32 file_no, OSPfsState *state) { +s32 osPfsFileState(OSPfs* pfs, s32 file_no, OSPfsState* state) { s32 ret; int pages; __OSInode inode; @@ -18,25 +18,23 @@ s32 osPfsFileState(OSPfs *pfs, s32 file_no, OSPfsState *state) { SET_ACTIVEBANK_TO_ZERO; ERRCK(__osContRamRead(pfs->queue, pfs->channel, pfs->dir_table + file_no, (u8*)&dir)); - + if (dir.company_code == 0 || dir.game_code == 0) { return PFS_ERR_INVALID; } - - next_page = dir.start_page; + pages = 0; + next_page = dir.start_page; bank = 0xFF; - + while (TRUE) { if (next_page.ipage < pfs->inode_start_page) { break; - } - - if (next_page.inode_t.bank != bank) { + } else if (next_page.inode_t.bank != bank) { bank = next_page.inode_t.bank; ERRCK(__osPfsRWInode(pfs, &inode, PFS_READ, bank)); } - + pages++; next_page = inode.inode_page[next_page.inode_t.page]; } @@ -45,11 +43,12 @@ s32 osPfsFileState(OSPfs *pfs, s32 file_no, OSPfsState *state) { return PFS_ERR_INCONSISTENT; } - state->file_size = pages * PFS_ONE_PAGE * BLOCKSIZE; + state->file_size = pages * (PFS_ONE_PAGE * BLOCKSIZE); state->company_code = dir.company_code; state->game_code = dir.game_code; bcopy(&dir.game_name, state->game_name, PFS_FILE_NAME_LEN); bcopy(&dir.ext_name, state->ext_name, PFS_FILE_EXT_LEN); - return __osPfsGetStatus(pfs->queue, pfs->channel); + ret = __osPfsGetStatus(pfs->queue, pfs->channel); + return ret; } diff --git a/lib/ultralib/src/io/pfsfreeblocks.c b/lib/ultralib/src/io/pfsfreeblocks.c index a1fd848..ad01f4f 100644 --- a/lib/ultralib/src/io/pfsfreeblocks.c +++ b/lib/ultralib/src/io/pfsfreeblocks.c @@ -1,7 +1,7 @@ #include "PR/os_internal.h" #include "controller.h" -s32 osPfsFreeBlocks(OSPfs *pfs, s32 *bytes_not_used) { +s32 osPfsFreeBlocks(OSPfs* pfs, s32* bytes_not_used) { int j; int pages = 0; __OSInode inode; diff --git a/lib/ultralib/src/io/pfsgetlabel.c b/lib/ultralib/src/io/pfsgetlabel.c index 960bd30..e8a62fd 100644 --- a/lib/ultralib/src/io/pfsgetlabel.c +++ b/lib/ultralib/src/io/pfsgetlabel.c @@ -1,21 +1,21 @@ #include "PR/os_internal.h" #include "controller.h" -s32 osPfsGetLabel(OSPfs *pfs, u8 *label, int *len) { +s32 osPfsGetLabel(OSPfs* pfs, u8* label, int* len) { int i; - + if (label == NULL) { return PFS_ERR_INVALID; } - + PFS_CHECK_ID; for (i = 0; i < ARRLEN(pfs->label); i++) { - if(*(pfs->label + i) == 0) { + if (*(u8*)(u32)(i + pfs->label) == 0) { break; } - *label++ = *(pfs->label + i); + *label++ = *(u8*)(u32)(i + pfs->label); } *len = i; diff --git a/lib/ultralib/src/io/pfsgetstatus.c b/lib/ultralib/src/io/pfsgetstatus.c index 6640728..0fdcdaa 100644 --- a/lib/ultralib/src/io/pfsgetstatus.c +++ b/lib/ultralib/src/io/pfsgetstatus.c @@ -3,9 +3,9 @@ #include "siint.h" void __osPfsRequestOneChannel(int channel, u8 cmd); -void __osPfsGetOneChannelData(int channel, OSContStatus *data); +void __osPfsGetOneChannelData(int channel, OSContStatus* data); -s32 __osPfsGetStatus(OSMesgQueue *queue, int channel) { +s32 __osPfsGetStatus(OSMesgQueue* queue, int channel) { s32 ret = 0; OSMesg dummy; OSContStatus data; @@ -29,19 +29,19 @@ s32 __osPfsGetStatus(OSMesgQueue *queue, int channel) { } else if ((data.status & CONT_ADDR_CRC_ER) != 0) { return PFS_ERR_CONTRFAIL; } - + return ret; } void __osPfsRequestOneChannel(int channel, u8 cmd) { - u8 *ptr; + u8* ptr; __OSContRequesFormatShort requestformat; int i; __osContLastCmd = CONT_CMD_END; __osPfsPifRam.pifstatus = CONT_CMD_READ_BUTTON; - - ptr = (u8 *)&__osPfsPifRam; + + ptr = (u8*)&__osPfsPifRam; requestformat.txsize = CONT_CMD_REQUEST_STATUS_TX; requestformat.rxsize = CONT_CMD_REQUEST_STATUS_RX; @@ -54,25 +54,27 @@ void __osPfsRequestOneChannel(int channel, u8 cmd) { *ptr++ = CONT_CMD_REQUEST_STATUS; } - *(__OSContRequesFormatShort *)ptr = requestformat; + *(__OSContRequesFormatShort*)ptr = requestformat; ptr += sizeof(__OSContRequesFormatShort); *ptr = CONT_CMD_END; } -void __osPfsGetOneChannelData(int channel, OSContStatus *data) { - u8 *ptr = (u8*)&__osPfsPifRam; +void __osPfsGetOneChannelData(int channel, OSContStatus* data) { + u8* ptr = (u8*)&__osPfsPifRam; __OSContRequesFormatShort requestformat; int i; - + for (i = 0; i < channel; i++) { ptr++; } - requestformat = *(__OSContRequesFormatShort *)ptr; + requestformat = *(__OSContRequesFormatShort*)ptr; data->errno = CHNL_ERR(requestformat); - if (data->errno == 0) { - data->type = (requestformat.typel << 8) | (requestformat.typeh); - data->status = requestformat.status; + if (data->errno != 0) { + return; } + + data->type = (requestformat.typel << 8) | (requestformat.typeh); + data->status = requestformat.status; } diff --git a/lib/ultralib/src/io/pfsinit.c b/lib/ultralib/src/io/pfsinit.c index e290cda..5633c78 100644 --- a/lib/ultralib/src/io/pfsinit.c +++ b/lib/ultralib/src/io/pfsinit.c @@ -2,13 +2,13 @@ #include "controller.h" #include "siint.h" -s32 osPfsInit(OSMesgQueue *queue, OSPfs *pfs, int channel) { +s32 osPfsInit(OSMesgQueue* queue, OSPfs* pfs, int channel) { s32 ret = 0; - + __osSiGetAccess(); ret = __osPfsGetStatus(queue, channel); __osSiRelAccess(); - + if (ret != 0) { return ret; } diff --git a/lib/ultralib/src/io/pfsinitpak.c b/lib/ultralib/src/io/pfsinitpak.c index 927636f..68fa5db 100644 --- a/lib/ultralib/src/io/pfsinitpak.c +++ b/lib/ultralib/src/io/pfsinitpak.c @@ -1,10 +1,11 @@ #include "PR/os_internal.h" #include "controller.h" +#include "siint.h" static s32 __osPfsCheckRamArea(OSPfs* pfs); s32 osPfsInitPak(OSMesgQueue* queue, OSPfs* pfs, int channel) { - s32 ret; + s32 ret = 0; u16 sum; u16 isum; u8 temp[BLOCKSIZE]; @@ -77,13 +78,13 @@ s32 osPfsInitPak(OSMesgQueue* queue, OSPfs* pfs, int channel) { } static s32 __osPfsCheckRamArea(OSPfs* pfs) { - s32 i = 0; + s32 i; s32 ret = 0; u8 temp1[BLOCKSIZE]; u8 temp2[BLOCKSIZE]; u8 save[BLOCKSIZE]; - ERRCK(__osPfsSelectBank(pfs, 0)); + ERRCK(__osPfsSelectBank(pfs, PFS_ID_BANK_256K)); ERRCK(__osContRamRead(pfs->queue, pfs->channel, 0, save)); for (i = 0; i < BLOCKSIZE; i++) { @@ -97,5 +98,6 @@ static s32 __osPfsCheckRamArea(OSPfs* pfs) { return PFS_ERR_DEVICE; } - return __osContRamWrite(pfs->queue, pfs->channel, 0, save, FALSE); + ret = __osContRamWrite(pfs->queue, pfs->channel, 0, save, FALSE); + return ret; } diff --git a/lib/ultralib/src/io/pfsisplug.c b/lib/ultralib/src/io/pfsisplug.c index 71a18d9..9607907 100644 --- a/lib/ultralib/src/io/pfsisplug.c +++ b/lib/ultralib/src/io/pfsisplug.c @@ -1,6 +1,7 @@ #include "macros.h" #include "PR/os_internal.h" #include "controller.h" +#include "siint.h" OSPifRam __osPfsPifRam ALIGNED(16); @@ -84,7 +85,7 @@ void __osPfsGetInitData(u8* pattern, OSContStatus* data) { requestformat = *((__OSContRequesFormat*)ptr); data->errno = CHNL_ERR(requestformat); - if (data->errno) { + if (data->errno != 0) { continue; } diff --git a/lib/ultralib/src/io/pfsnumfiles.c b/lib/ultralib/src/io/pfsnumfiles.c index e4480bd..9f52fb4 100644 --- a/lib/ultralib/src/io/pfsnumfiles.c +++ b/lib/ultralib/src/io/pfsnumfiles.c @@ -1,7 +1,7 @@ #include "PR/os_internal.h" #include "controller.h" -s32 osPfsNumFiles(OSPfs *pfs, s32 *max_files, s32 *files_used) { +s32 osPfsNumFiles(OSPfs* pfs, s32* max_files, s32* files_used) { int j; s32 ret; __OSDir dir; @@ -10,7 +10,7 @@ s32 osPfsNumFiles(OSPfs *pfs, s32 *max_files, s32 *files_used) { PFS_CHECK_STATUS; ERRCK(__osCheckId(pfs)); SET_ACTIVEBANK_TO_ZERO; - + for (j = 0; j < pfs->dir_size; j++) { ERRCK(__osContRamRead(pfs->queue, pfs->channel, pfs->dir_table + j, (u8*)&dir)); @@ -20,5 +20,7 @@ s32 osPfsNumFiles(OSPfs *pfs, s32 *max_files, s32 *files_used) { } *files_used = files; *max_files = pfs->dir_size; - return __osPfsGetStatus(pfs->queue, pfs->channel); + + ret = __osPfsGetStatus(pfs->queue, pfs->channel); + return ret; } diff --git a/lib/ultralib/src/io/pfsreadwritefile.c b/lib/ultralib/src/io/pfsreadwritefile.c index 14a6e45..7a6e691 100644 --- a/lib/ultralib/src/io/pfsreadwritefile.c +++ b/lib/ultralib/src/io/pfsreadwritefile.c @@ -1,21 +1,19 @@ #include "PR/os_internal.h" #include "controller.h" -static s32 __osPfsGetNextPage(OSPfs *pfs, u8 *bank, __OSInode *inode, __OSInodeUnit *page) { +static s32 __osPfsGetNextPage(OSPfs* pfs, u8* bank, __OSInode* inode, __OSInodeUnit* page) { s32 ret; if (page->inode_t.bank != *bank) { *bank = page->inode_t.bank; ERRCK(__osPfsRWInode(pfs, inode, 0, *bank)); } - + *page = inode->inode_page[page->inode_t.page]; - - if (page->ipage < pfs->inode_start_page || - page->inode_t.bank >= pfs->banks || - page->inode_t.page <= 0 || + + if (page->ipage < pfs->inode_start_page || page->inode_t.bank >= pfs->banks || page->inode_t.page <= 0 || page->inode_t.page >= ARRLEN(inode->inode_page)) { - + if (page->ipage == 1) { return PFS_ERR_INVALID; } @@ -24,26 +22,26 @@ static s32 __osPfsGetNextPage(OSPfs *pfs, u8 *bank, __OSInode *inode, __OSInodeU } return 0; } -s32 osPfsReadWriteFile(OSPfs *pfs, s32 file_no, u8 flag, int offset, int size_in_bytes, u8 *data_buffer) { +s32 osPfsReadWriteFile(OSPfs* pfs, s32 file_no, u8 flag, int offset, int size_in_bytes, u8* data_buffer) { s32 ret; __OSDir dir; __OSInode inode; __OSInodeUnit cur_page; int cur_block; int siz_block; - u8 *buffer; + u8* buffer; u8 bank; u16 blockno; - - if (file_no >= pfs->dir_size || file_no < 0) { + + if ((file_no >= (s32)pfs->dir_size) || (file_no < 0)) { return PFS_ERR_INVALID; } - if (size_in_bytes <= 0 || ((size_in_bytes & (BLOCKSIZE - 1)) != 0)) { + if ((size_in_bytes <= 0) || ((size_in_bytes % BLOCKSIZE) != 0)) { return PFS_ERR_INVALID; } - - if (offset < 0 || ((offset & (BLOCKSIZE - 1)) != 0)) { + + if ((offset < 0) || ((offset % BLOCKSIZE) != 0)) { return PFS_ERR_INVALID; } @@ -51,26 +49,24 @@ s32 osPfsReadWriteFile(OSPfs *pfs, s32 file_no, u8 flag, int offset, int size_in PFS_CHECK_ID; SET_ACTIVEBANK_TO_ZERO; ERRCK(__osContRamRead(pfs->queue, pfs->channel, pfs->dir_table + file_no, (u8*)&dir)); - + if (dir.company_code == 0 || dir.game_code == 0) { return PFS_ERR_INVALID; } - if (dir.start_page.ipage < pfs->inode_start_page || - dir.start_page.inode_t.bank >= pfs->banks || - dir.start_page.inode_t.page <= 0 || - dir.start_page.inode_t.page >= ARRLEN(inode.inode_page)) { + if (dir.start_page.ipage < pfs->inode_start_page || dir.start_page.inode_t.bank >= pfs->banks || + dir.start_page.inode_t.page <= 0 || dir.start_page.inode_t.page >= ARRLEN(inode.inode_page)) { if ((dir.start_page.ipage == 1)) { return PFS_ERR_INVALID; } return PFS_ERR_INCONSISTENT; } - + if (flag == PFS_READ && (dir.status & DIR_STATUS_OCCUPIED) == 0) { return PFS_ERR_BAD_DATA; } - + bank = -1; cur_block = offset / BLOCKSIZE; cur_page = dir.start_page; @@ -100,7 +96,7 @@ s32 osPfsReadWriteFile(OSPfs *pfs, s32 file_no, u8 flag, int offset, int size_in } else { ret = __osContRamWrite(pfs->queue, pfs->channel, blockno, buffer, FALSE); } - + if (ret != 0) { return ret; } @@ -115,5 +111,6 @@ s32 osPfsReadWriteFile(OSPfs *pfs, s32 file_no, u8 flag, int offset, int size_in ERRCK(__osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + file_no, (u8*)&dir, FALSE)); } - return __osPfsGetStatus(pfs->queue, pfs->channel); + ret = __osPfsGetStatus(pfs->queue, pfs->channel); + return ret; } diff --git a/lib/ultralib/src/io/pfsreformat.c b/lib/ultralib/src/io/pfsreformat.c index cbd4b6a..7cd6391 100644 --- a/lib/ultralib/src/io/pfsreformat.c +++ b/lib/ultralib/src/io/pfsreformat.c @@ -2,12 +2,12 @@ #include "controller.h" #include "siint.h" -s32 osPfsReFormat(OSPfs *pfs, OSMesgQueue *queue, int channel) { +s32 osPfsReFormat(OSPfs* pfs, OSMesgQueue* queue, int channel) { int j; int i; __OSInode inode; u8 tmp_data[32]; - u8 *ptr; + u8* ptr; s32 ret; __osSiGetAccess(); ret = __osPfsGetStatus(queue, channel); @@ -24,28 +24,27 @@ s32 osPfsReFormat(OSPfs *pfs, OSMesgQueue *queue, int channel) { ERRCK(__osGetId(pfs)); SET_ACTIVEBANK_TO_ZERO; - + for (j = 0; j < ARRLEN(tmp_data); j++) { tmp_data[j] = 0; } - for (j = 0; j < pfs->dir_size; j++) - { + for (j = 0; j < pfs->dir_size; j++) { ERRCK(__osContRamWrite(queue, channel, pfs->dir_table + j, tmp_data, FALSE)); } for (j = 0; j < pfs->inode_start_page; j++) { inode.inode_page[j].ipage = 0; } - + for (j = pfs->inode_start_page; j < ARRLEN(inode.inode_page); j++) { inode.inode_page[j].ipage = 3; } - + inode.inode_page[0].ipage = __osSumcalc((u8*)(inode.inode_page + pfs->inode_start_page), (ARRLEN(inode.inode_page) - pfs->inode_start_page) * sizeof(__OSInodeUnit)); - ptr = (u8 *)&inode; - + ptr = (u8*)&inode; + for (j = 0; j < PFS_ONE_PAGE; j++) { ERRCK(__osContRamWrite(queue, channel, pfs->inode_table + j, ptr + j * BLOCKSIZE, FALSE)); ERRCK(__osContRamWrite(queue, channel, pfs->minode_table + j, ptr + j * BLOCKSIZE, FALSE)); @@ -56,13 +55,15 @@ s32 osPfsReFormat(OSPfs *pfs, OSMesgQueue *queue, int channel) { inode.inode_page[j].ipage = 3; } - inode.inode_page[0].ipage = __osSumcalc((u8*)(inode.inode_page + 1), - (ARRLEN(inode.inode_page) - 1) * sizeof(__OSInodeUnit)); - ptr = (u8 *)&inode; + inode.inode_page[0].ipage = + __osSumcalc((u8*)(inode.inode_page + 1), (ARRLEN(inode.inode_page) - 1) * sizeof(__OSInodeUnit)); + ptr = (u8*)&inode; for (j = 0; j < PFS_ONE_PAGE; j++) { - ERRCK(__osContRamWrite(queue, channel, pfs->inode_table + i * PFS_ONE_PAGE + j, ptr + j * BLOCKSIZE, FALSE)); - ERRCK(__osContRamWrite(queue, channel, pfs->minode_table + i * PFS_ONE_PAGE + j, ptr + j * BLOCKSIZE, FALSE)); + ERRCK( + __osContRamWrite(queue, channel, pfs->inode_table + i * PFS_ONE_PAGE + j, ptr + j * BLOCKSIZE, FALSE)); + ERRCK( + __osContRamWrite(queue, channel, pfs->minode_table + i * PFS_ONE_PAGE + j, ptr + j * BLOCKSIZE, FALSE)); } } diff --git a/lib/ultralib/src/io/pfsrepairid.c b/lib/ultralib/src/io/pfsrepairid.c index f29590a..01b5567 100644 --- a/lib/ultralib/src/io/pfsrepairid.c +++ b/lib/ultralib/src/io/pfsrepairid.c @@ -1,7 +1,7 @@ #include "PR/os_internal.h" #include "controller.h" -s32 osPfsRepairId(OSPfs *pfs) { +s32 osPfsRepairId(OSPfs* pfs) { s32 ret = 0; if ((pfs->status & (PFS_INITIALIZED | PFS_ID_BROKEN))) { diff --git a/lib/ultralib/src/io/pfssearchfile.c b/lib/ultralib/src/io/pfssearchfile.c index 04a4155..a107852 100644 --- a/lib/ultralib/src/io/pfssearchfile.c +++ b/lib/ultralib/src/io/pfssearchfile.c @@ -1,7 +1,7 @@ #include "PR/os_internal.h" #include "controller.h" -s32 osPfsFindFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, u8 *ext_name, s32 *file_no) { +s32 osPfsFindFile(OSPfs* pfs, u16 company_code, u32 game_code, u8* game_name, u8* ext_name, s32* file_no) { s32 j; int i; __OSDir dir; diff --git a/lib/ultralib/src/io/pfssetlabel.c b/lib/ultralib/src/io/pfssetlabel.c index a0584cf..9724598 100644 --- a/lib/ultralib/src/io/pfssetlabel.c +++ b/lib/ultralib/src/io/pfssetlabel.c @@ -1,7 +1,7 @@ #include "PR/os_internal.h" #include "controller.h" -s32 osPfsSetLabel(OSPfs *pfs, u8 *label) { +s32 osPfsSetLabel(OSPfs* pfs, u8* label) { int i; s32 ret; diff --git a/lib/ultralib/src/io/pi.c b/lib/ultralib/src/io/pi.c index 1c350c5..3e67ddb 100644 --- a/lib/ultralib/src/io/pi.c +++ b/lib/ultralib/src/io/pi.c @@ -7,7 +7,9 @@ int __osPiDeviceBusy() { register u32 stat = IO_READ(PI_STATUS_REG); - if (stat & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) - return 1; - return 0; + if (stat & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) { + return TRUE; + } else { + return FALSE; + } } diff --git a/lib/ultralib/src/io/piacs.c b/lib/ultralib/src/io/piacs.c index 03ab11e..c95147f 100644 --- a/lib/ultralib/src/io/piacs.c +++ b/lib/ultralib/src/io/piacs.c @@ -3,22 +3,23 @@ #define PI_Q_BUF_LEN 1 u32 __osPiAccessQueueEnabled = 0; -OSMesgQueue __osPiAccessQueue ALIGNED(8); static OSMesg piAccessBuf[PI_Q_BUF_LEN]; +OSMesgQueue __osPiAccessQueue ALIGNED(8); void __osPiCreateAccessQueue(void) { - __osPiAccessQueueEnabled = 1; - osCreateMesgQueue(&__osPiAccessQueue, piAccessBuf, PI_Q_BUF_LEN); - osSendMesg(&__osPiAccessQueue, NULL, OS_MESG_NOBLOCK); + __osPiAccessQueueEnabled = 1; + osCreateMesgQueue(&__osPiAccessQueue, piAccessBuf, PI_Q_BUF_LEN); + osSendMesg(&__osPiAccessQueue, NULL, OS_MESG_NOBLOCK); } void __osPiGetAccess(void) { - OSMesg dummyMesg; - if (!__osPiAccessQueueEnabled) - __osPiCreateAccessQueue(); - osRecvMesg(&__osPiAccessQueue, &dummyMesg, OS_MESG_BLOCK); + OSMesg dummyMesg; + if (!__osPiAccessQueueEnabled) { + __osPiCreateAccessQueue(); + } + osRecvMesg(&__osPiAccessQueue, &dummyMesg, OS_MESG_BLOCK); } void __osPiRelAccess(void) { - osSendMesg(&__osPiAccessQueue, NULL, OS_MESG_NOBLOCK); + osSendMesg(&__osPiAccessQueue, NULL, OS_MESG_NOBLOCK); } diff --git a/lib/ultralib/src/io/pidma.c b/lib/ultralib/src/io/pidma.c index 077f13a..0584e12 100644 --- a/lib/ultralib/src/io/pidma.c +++ b/lib/ultralib/src/io/pidma.c @@ -1,12 +1,48 @@ #include "PR/os_internal.h" +#include "PR/ultraerror.h" #include "piint.h" -s32 osPiStartDma(OSIoMesg *mb, s32 priority, s32 direction, u32 devAddr, void *dramAddr, u32 size, OSMesgQueue *mq) { +s32 osPiStartDma(OSIoMesg* mb, s32 priority, s32 direction, u32 devAddr, void* dramAddr, u32 size, OSMesgQueue* mq) { register s32 ret; if (!__osPiDevMgr.active) { +#ifdef _DEBUG + __osError(ERR_OSPISTARTDMA_PIMGR, 0); +#endif return -1; } +#ifdef _DEBUG + if ((priority != OS_MESG_PRI_NORMAL) && (priority != OS_MESG_PRI_HIGH)) { + __osError(ERR_OSPISTARTDMA_PRI, 1, priority); + return -1; + } + + if ((direction != OS_READ) && (direction != OS_WRITE)) { + __osError(ERR_OSPISTARTDMA_DIR, 1, direction); + return -1; + } + + if (devAddr & 0x1) { + __osError(ERR_OSPISTARTDMA_DEVADDR, 1, devAddr); + return -1; + } + + if ((u32)dramAddr & 0x7) { + __osError(ERR_OSPISTARTDMA_ADDR, 1, dramAddr); + return -1; + } + + if (size & 0x1) { + __osError(ERR_OSPISTARTDMA_SIZE, 1, size); + return -1; + } + + if ((size == 0) || (size > (16 * 1024 * 1024))) { + __osError(ERR_OSPISTARTDMA_RANGE, 1, size); + return -1; + } +#endif + if (direction == OS_READ) { mb->hdr.type = OS_MESG_TYPE_DMAREAD; } else { @@ -19,12 +55,12 @@ s32 osPiStartDma(OSIoMesg *mb, s32 priority, s32 direction, u32 devAddr, void *d mb->devAddr = devAddr; mb->size = size; mb->piHandle = NULL; - + if (priority == OS_MESG_PRI_HIGH) { ret = osJamMesg(osPiGetCmdQueue(), (OSMesg)mb, OS_MESG_NOBLOCK); } else { ret = osSendMesg(osPiGetCmdQueue(), (OSMesg)mb, OS_MESG_NOBLOCK); } - + return ret; } diff --git a/lib/ultralib/src/io/pigetcmdq.c b/lib/ultralib/src/io/pigetcmdq.c index 809cdb2..4724301 100644 --- a/lib/ultralib/src/io/pigetcmdq.c +++ b/lib/ultralib/src/io/pigetcmdq.c @@ -1,10 +1,10 @@ #include "PR/os_internal.h" #include "piint.h" -OSMesgQueue *osPiGetCmdQueue(void) { +OSMesgQueue* osPiGetCmdQueue(void) { if (!__osPiDevMgr.active) { return NULL; + } else { + return __osPiDevMgr.cmdQueue; } - - return __osPiDevMgr.cmdQueue; } diff --git a/lib/ultralib/src/io/piint.h b/lib/ultralib/src/io/piint.h index 734fdde..5551c4b 100644 --- a/lib/ultralib/src/io/piint.h +++ b/lib/ultralib/src/io/piint.h @@ -94,7 +94,7 @@ #define LEO_ERROR_29 29 // extern OSDevMgr __osPiDevMgr; -extern OSPiHandle *__osCurrentHandle[2]; +extern OSPiHandle *__osCurrentHandle[]; extern OSPiHandle CartRomHandle; extern OSPiHandle LeoDiskHandle; extern OSMesgQueue __osPiAccessQueue; @@ -114,9 +114,11 @@ s32 __osEPiRawStartDma(OSPiHandle *, s32 , u32 , void *, u32 ); OSMesgQueue *osPiGetCmdQueue(void); #define WAIT_ON_IOBUSY(stat) \ - while (stat = IO_READ(PI_STATUS_REG), stat & (PI_STATUS_IO_BUSY | PI_STATUS_DMA_BUSY)) \ - ; \ - (void)0 + { \ + stat = IO_READ(PI_STATUS_REG); \ + while (stat & (PI_STATUS_IO_BUSY | PI_STATUS_DMA_BUSY)) \ + stat = IO_READ(PI_STATUS_REG); \ + } (void)0 #define UPDATE_REG(pihandle, reg, var) \ if (cHandle->var != pihandle->var) \ diff --git a/lib/ultralib/src/io/pimgr.c b/lib/ultralib/src/io/pimgr.c index c757532..56a92ad 100644 --- a/lib/ultralib/src/io/pimgr.c +++ b/lib/ultralib/src/io/pimgr.c @@ -1,53 +1,108 @@ #include "macros.h" #include "PR/os_internal.h" +#include "PR/ultraerror.h" #include "piint.h" +#include "PR/rdb.h" -OSDevMgr __osPiDevMgr = {0}; -OSPiHandle *__osPiTable = NULL; +static OSThread piThread ALIGNED(8); +static char piThreadStack[OS_PIM_STACKSIZE] ALIGNED(16); + +#ifndef _FINALROM +static OSThread ramromThread ALIGNED(8); +static char ramromThreadStack[1024] ALIGNED(16); +static OSMesgQueue getRamromQ ALIGNED(8); +static OSMesg getRamromBuf[1]; +static OSMesgQueue freeRamromQ ALIGNED(8); +static OSMesg freeRamromBuf[1]; +static void ramromMain(void*); +#endif + +static OSMesgQueue piEventQueue ALIGNED(8); +static OSMesg piEventBuf[1]; + +OSDevMgr __osPiDevMgr = { 0 }; +OSPiHandle* __osPiTable = NULL; OSPiHandle __Dom1SpeedParam ALIGNED(8); OSPiHandle __Dom2SpeedParam ALIGNED(8); -OSPiHandle *__osCurrentHandle[2] ALIGNED(8) = {&__Dom1SpeedParam, &__Dom2SpeedParam}; -static OSThread piThread; -static char piThreadStack[OS_PIM_STACKSIZE]; -static OSMesgQueue piEventQueue; -static OSMesg piEventBuf[1]; +OSPiHandle* __osCurrentHandle[2] ALIGNED(8) = { &__Dom1SpeedParam, &__Dom2SpeedParam }; -void osCreatePiManager(OSPri pri, OSMesgQueue *cmdQ, OSMesg *cmdBuf, s32 cmdMsgCnt) { +void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgCnt) { u32 savedMask; OSPri oldPri; OSPri myPri; - if (!__osPiDevMgr.active) { - osCreateMesgQueue(cmdQ, cmdBuf, cmdMsgCnt); - osCreateMesgQueue(&piEventQueue, (OSMesg*)piEventBuf, 1); - - if (!__osPiAccessQueueEnabled) { - __osPiCreateAccessQueue(); - } - - osSetEventMesg(OS_EVENT_PI, &piEventQueue, (OSMesg)0x22222222); - oldPri = -1; - myPri = osGetThreadPri(NULL); - - if (myPri < pri) { - oldPri = myPri; - osSetThreadPri(NULL, pri); - } +#ifdef _DEBUG + if ((pri < OS_PRIORITY_IDLE) || (pri > OS_PRIORITY_MAX)) { + __osError(ERR_OSCREATEPIMANAGER, 1, pri); + return; + } +#endif + + if (__osPiDevMgr.active) { + return; + } + osCreateMesgQueue(cmdQ, cmdBuf, cmdMsgCnt); + osCreateMesgQueue(&piEventQueue, (OSMesg*)piEventBuf, 1); - savedMask = __osDisableInt(); - __osPiDevMgr.active = 1; - __osPiDevMgr.thread = &piThread; - __osPiDevMgr.cmdQueue = cmdQ; - __osPiDevMgr.evtQueue = &piEventQueue; - __osPiDevMgr.acsQueue = &__osPiAccessQueue; - __osPiDevMgr.dma = __osPiRawStartDma; - __osPiDevMgr.edma = __osEPiRawStartDma; - osCreateThread(&piThread, 0, __osDevMgrMain, &__osPiDevMgr, &piThreadStack[OS_PIM_STACKSIZE], pri); - osStartThread(&piThread); - __osRestoreInt(savedMask); - - if (oldPri != -1) { - osSetThreadPri(NULL, oldPri); + if (!__osPiAccessQueueEnabled) { + __osPiCreateAccessQueue(); + } + + osSetEventMesg(OS_EVENT_PI, &piEventQueue, (OSMesg)0x22222222); + oldPri = -1; + myPri = osGetThreadPri(NULL); + + if (myPri < pri) { + oldPri = myPri; + osSetThreadPri(NULL, pri); + } + + savedMask = __osDisableInt(); + __osPiDevMgr.active = 1; + __osPiDevMgr.thread = &piThread; + __osPiDevMgr.cmdQueue = cmdQ; + __osPiDevMgr.evtQueue = &piEventQueue; + __osPiDevMgr.acsQueue = &__osPiAccessQueue; + __osPiDevMgr.dma = __osPiRawStartDma; + __osPiDevMgr.edma = __osEPiRawStartDma; + osCreateThread(&piThread, 0, __osDevMgrMain, &__osPiDevMgr, &piThreadStack[OS_PIM_STACKSIZE], pri); + osStartThread(&piThread); + +#ifndef _FINALROM + osCreateThread(&ramromThread, 0, ramromMain, NULL, ramromThreadStack + 1024, (OSPri)pri - 1); + osStartThread(&ramromThread); +#endif + __osRestoreInt(savedMask); + + if (oldPri != -1) { + osSetThreadPri(NULL, oldPri); + } +} + +#ifndef _FINALROM +static void ramromMain(void* arg) { + u32 sent; + u8 tmp[3]; + + osCreateMesgQueue(&getRamromQ, getRamromBuf, 1); + osCreateMesgQueue(&freeRamromQ, freeRamromBuf, 1); + osSetEventMesg(OS_EVENT_RDB_REQ_RAMROM, &getRamromQ, NULL); + osSetEventMesg(OS_EVENT_RDB_FREE_RAMROM, &freeRamromQ, NULL); + + while (TRUE) { + osRecvMesg(&getRamromQ, NULL, OS_MESG_BLOCK); + + __osPiGetAccess(); + + sent = 0; + + while (sent < 1) { + sent += __osRdbSend(tmp, 1, RDB_TYPE_GtoH_RAMROM); } + + osRecvMesg(&freeRamromQ, NULL, OS_MESG_BLOCK); + + __osPiRelAccess(); } } +#endif diff --git a/lib/ultralib/src/io/pirawdma.c b/lib/ultralib/src/io/pirawdma.c index d766064..d5ea8c3 100644 --- a/lib/ultralib/src/io/pirawdma.c +++ b/lib/ultralib/src/io/pirawdma.c @@ -1,4 +1,5 @@ #include "piint.h" +#include "PR/ultraerror.h" // TODO: this comes from a header #ident "$Revision: 1.17 $" @@ -6,6 +7,33 @@ s32 __osPiRawStartDma(s32 direction, u32 devAddr, void* dramAddr, u32 size) { register u32 stat; +#ifdef _DEBUG + if ((direction != OS_READ) && (direction != OS_WRITE)) { + __osError(ERR_OSPIRAWSTARTDMA_DIR, 1, direction); + return -1; + } + + if (devAddr & 0x1) { + __osError(ERR_OSPIRAWSTARTDMA_DEVADDR, 1, devAddr); + return -1; + } + + if ((u32)dramAddr & 0x7) { + __osError(ERR_OSPIRAWSTARTDMA_ADDR, 1, dramAddr); + return -1; + } + + if (size & 0x1) { + __osError(ERR_OSPIRAWSTARTDMA_SIZE, 1, size); + return -1; + } + + if ((size == 0) || (size > (16 * 1024 * 1024))) { + __osError(ERR_OSPIRAWSTARTDMA_RANGE, 1, size); + return -1; + } +#endif + WAIT_ON_IOBUSY(stat); IO_WRITE(PI_DRAM_ADDR_REG, osVirtualToPhysical(dramAddr)); diff --git a/lib/ultralib/src/io/pirawread.c b/lib/ultralib/src/io/pirawread.c index 8531d17..0fd6a2e 100644 --- a/lib/ultralib/src/io/pirawread.c +++ b/lib/ultralib/src/io/pirawread.c @@ -1,4 +1,49 @@ #include "piint.h" +#include "assert.h" +#include "PR/ultraerror.h" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + // TODO: this comes from a header #ident "$Revision: 1.17 $" @@ -6,6 +51,15 @@ s32 __osPiRawReadIo(u32 devAddr, u32* data) { register u32 stat; +#ifdef _DEBUG + if (devAddr & 0x3) { + __osError(ERR_OSPIRAWREADIO, 1, devAddr); + return -1; + } + + assert(data != NULL); +#endif + WAIT_ON_IOBUSY(stat); *data = IO_READ((u32)osRomBase | devAddr); diff --git a/lib/ultralib/src/io/pirawwrite.c b/lib/ultralib/src/io/pirawwrite.c index 5e9d7c5..92eba84 100644 --- a/lib/ultralib/src/io/pirawwrite.c +++ b/lib/ultralib/src/io/pirawwrite.c @@ -1,4 +1,5 @@ #include "piint.h" +#include "PR/ultraerror.h" // TODO: this comes from a header #ident "$Revision: 1.17 $" @@ -6,6 +7,13 @@ s32 __osPiRawWriteIo(u32 devAddr, u32 data) { register u32 stat; +#ifdef _DEBUG + if (devAddr & 0x3) { + __osError(ERR_OSPIRAWWRITEIO, 1, devAddr); + return -1; + } +#endif + WAIT_ON_IOBUSY(stat); IO_WRITE((u32)osRomBase | devAddr, data); diff --git a/lib/ultralib/src/io/piread.c b/lib/ultralib/src/io/piread.c index 2fed7a6..42bcf3e 100644 --- a/lib/ultralib/src/io/piread.c +++ b/lib/ultralib/src/io/piread.c @@ -1,10 +1,16 @@ #include "piint.h" - -s32 __osPiRawReadIo(u32, u32*); +#include "PR/ultraerror.h" s32 osPiReadIo(u32 devAddr, u32* data) { register s32 ret; +#ifdef _DEBUG + if (devAddr & 0x3) { + __osError(ERR_OSPIREADIO, 1, devAddr); + return -1; + } +#endif + __osPiGetAccess(); ret = __osPiRawReadIo(devAddr, data); __osPiRelAccess(); diff --git a/lib/ultralib/src/io/piwrite.c b/lib/ultralib/src/io/piwrite.c index 9935331..75c00d1 100644 --- a/lib/ultralib/src/io/piwrite.c +++ b/lib/ultralib/src/io/piwrite.c @@ -1,10 +1,16 @@ #include "piint.h" - -s32 __osPiRawWriteIo(u32, u32); +#include "PR/ultraerror.h" s32 osPiWriteIo(u32 devAddr, u32 data) { register s32 ret; +#ifdef _DEBUG + if (devAddr & 0x3) { + __osError(ERR_OSPIWRITEIO, 1, devAddr); + return -1; + } +#endif + __osPiGetAccess(); ret = __osPiRawWriteIo(devAddr, data); __osPiRelAccess(); diff --git a/lib/ultralib/src/io/si.c b/lib/ultralib/src/io/si.c index f97691b..0188927 100644 --- a/lib/ultralib/src/io/si.c +++ b/lib/ultralib/src/io/si.c @@ -9,7 +9,7 @@ int __osSiDeviceBusy() { if (stat & (SI_STATUS_DMA_BUSY | SI_STATUS_RD_BUSY)) { return TRUE; + } else { + return FALSE; } - - return FALSE; } diff --git a/lib/ultralib/src/io/siacs.c b/lib/ultralib/src/io/siacs.c index f515c49..8ef5b3f 100644 --- a/lib/ultralib/src/io/siacs.c +++ b/lib/ultralib/src/io/siacs.c @@ -7,18 +7,19 @@ OSMesgQueue __osSiAccessQueue ALIGNED(8); u32 __osSiAccessQueueEnabled = 0; void __osSiCreateAccessQueue(void) { - __osSiAccessQueueEnabled = 1; - osCreateMesgQueue(&__osSiAccessQueue, siAccessBuf, SI_Q_BUF_LEN); - osSendMesg(&__osSiAccessQueue, NULL, OS_MESG_NOBLOCK); + __osSiAccessQueueEnabled = 1; + osCreateMesgQueue(&__osSiAccessQueue, siAccessBuf, SI_Q_BUF_LEN); + osSendMesg(&__osSiAccessQueue, NULL, OS_MESG_NOBLOCK); } void __osSiGetAccess(void) { - OSMesg dummyMesg; - if (!__osSiAccessQueueEnabled) - __osSiCreateAccessQueue(); - osRecvMesg(&__osSiAccessQueue, &dummyMesg, OS_MESG_BLOCK); + OSMesg dummyMesg; + if (!__osSiAccessQueueEnabled) { + __osSiCreateAccessQueue(); + } + osRecvMesg(&__osSiAccessQueue, &dummyMesg, OS_MESG_BLOCK); } void __osSiRelAccess(void) { - osSendMesg(&__osSiAccessQueue, NULL, OS_MESG_NOBLOCK); + osSendMesg(&__osSiAccessQueue, NULL, OS_MESG_NOBLOCK); } diff --git a/lib/ultralib/src/io/siint.h b/lib/ultralib/src/io/siint.h index 636a87f..636a87f 100755..100644 --- a/lib/ultralib/src/io/siint.h +++ b/lib/ultralib/src/io/siint.h diff --git a/lib/ultralib/src/io/sirawdma.c b/lib/ultralib/src/io/sirawdma.c index e27ff10..e2dd03f 100644 --- a/lib/ultralib/src/io/sirawdma.c +++ b/lib/ultralib/src/io/sirawdma.c @@ -1,10 +1,60 @@ #include "PR/os_internal.h" +#include "assert.h" #include "siint.h" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + // TODO: this comes from a header #ident "$Revision: 1.17 $" -s32 __osSiRawStartDma(s32 direction, void *dramAddr) { +s32 __osSiRawStartDma(s32 direction, void* dramAddr) { +#ifdef _DEBUG + assert(((u32)dramAddr & 0x3) == 0); +#endif if (IO_READ(SI_STATUS_REG) & (SI_STATUS_DMA_BUSY | SI_STATUS_RD_BUSY)) { return -1; } diff --git a/lib/ultralib/src/io/sirawread.c b/lib/ultralib/src/io/sirawread.c index 5381cf1..0b605db 100644 --- a/lib/ultralib/src/io/sirawread.c +++ b/lib/ultralib/src/io/sirawread.c @@ -1,14 +1,62 @@ #include "PR/os_internal.h" +#include "assert.h" #include "siint.h" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + // TODO: this comes from a header #ident "$Revision: 1.17 $" s32 __osSiRawReadIo(u32 devAddr, u32* data) { +#ifdef _DEBUG + assert((devAddr & 0x3) == 0); + assert(data != NULL); +#endif if (__osSiDeviceBusy()) { return -1; } - + *data = IO_READ(devAddr); return 0; } diff --git a/lib/ultralib/src/io/sirawwrite.c b/lib/ultralib/src/io/sirawwrite.c index 9967c1d..0a50ace 100644 --- a/lib/ultralib/src/io/sirawwrite.c +++ b/lib/ultralib/src/io/sirawwrite.c @@ -1,14 +1,61 @@ #include "PR/os_internal.h" #include "siint.h" +#include "assert.h" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + // TODO: this comes from a header #ident "$Revision: 1.17 $" s32 __osSiRawWriteIo(u32 devAddr, u32 data) { +#ifdef _DEBUG + assert((devAddr & 0x3) == 0); +#endif if (__osSiDeviceBusy()) { return -1; } - + IO_WRITE(devAddr, data); return 0; } diff --git a/lib/ultralib/src/io/sp.c b/lib/ultralib/src/io/sp.c index 95d5b20..3ad9076 100755..100644 --- a/lib/ultralib/src/io/sp.c +++ b/lib/ultralib/src/io/sp.c @@ -11,7 +11,7 @@ int __osSpDeviceBusy() { if (stat & (SP_STATUS_DMA_BUSY | SP_STATUS_DMA_FULL | SP_STATUS_IO_FULL)) { return TRUE; + } else { + return FALSE; } - - return FALSE; } diff --git a/lib/ultralib/src/io/spgetstat.c b/lib/ultralib/src/io/spgetstat.c index 0cdfda6..0cdfda6 100755..100644 --- a/lib/ultralib/src/io/spgetstat.c +++ b/lib/ultralib/src/io/spgetstat.c diff --git a/lib/ultralib/src/io/sprawdma.c b/lib/ultralib/src/io/sprawdma.c index 41239b1..6224b1f 100755..100644 --- a/lib/ultralib/src/io/sprawdma.c +++ b/lib/ultralib/src/io/sprawdma.c @@ -3,12 +3,59 @@ #include "../os/osint.h" #include "assert.h" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + // TODO: this comes from a header #ident "$Revision: 1.17 $" -s32 __osSpRawStartDma(s32 direction, u32 devAddr, void *dramAddr, u32 size) { - // These asserts are present in debug builds, but the line numbers won't match as-is - // TODO Add an assert spoofing macro that lets you specify a line number +s32 __osSpRawStartDma(s32 direction, u32 devAddr, void* dramAddr, u32 size) { assert(((u32)devAddr & 0x7) == 0); assert(((u32)dramAddr & 0x7) == 0); assert(((u32)size & 0x7) == 0); @@ -16,10 +63,10 @@ s32 __osSpRawStartDma(s32 direction, u32 devAddr, void *dramAddr, u32 size) { if (__osSpDeviceBusy()) { return -1; } - + IO_WRITE(SP_MEM_ADDR_REG, devAddr); IO_WRITE(SP_DRAM_ADDR_REG, osVirtualToPhysical(dramAddr)); - + if (direction == OS_READ) { IO_WRITE(SP_WR_LEN_REG, size - 1); } else { diff --git a/lib/ultralib/src/io/sprawread.c b/lib/ultralib/src/io/sprawread.c index affc78b..4609ebc 100755..100644 --- a/lib/ultralib/src/io/sprawread.c +++ b/lib/ultralib/src/io/sprawread.c @@ -1,16 +1,61 @@ #include "PR/os_internal.h" #include "PR/rcp.h" #include "../os/osint.h" +#include "assert.h" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + // TODO: this comes from a header #ident "$Revision: 1.17 $" -s32 __osSpRawReadIo(u32 devAddr, u32 *data) { +s32 __osSpRawReadIo(u32 devAddr, u32* data) { +#ifdef _DEBUG + assert((devAddr & 0x3) == 0); + assert(data != NULL); +#endif if (__osSpDeviceBusy()) { return -1; } - + *data = IO_READ(devAddr); return 0; } - diff --git a/lib/ultralib/src/io/sprawwrite.c b/lib/ultralib/src/io/sprawwrite.c index f6451ae..66510d1 100755..100644 --- a/lib/ultralib/src/io/sprawwrite.c +++ b/lib/ultralib/src/io/sprawwrite.c @@ -1,11 +1,57 @@ #include "PR/os_internal.h" #include "PR/rcp.h" #include "../os/osint.h" +#include "assert.h" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + // TODO: this comes from a header #ident "$Revision: 1.17 $" s32 __osSpRawWriteIo(u32 devAddr, u32 data) { +#ifdef _DEBUG + assert((devAddr & 0x3) == 0); +#endif if (__osSpDeviceBusy()) { return -1; } diff --git a/lib/ultralib/src/io/spsetstat.c b/lib/ultralib/src/io/spsetstat.c index 2ab47e0..2ab47e0 100755..100644 --- a/lib/ultralib/src/io/spsetstat.c +++ b/lib/ultralib/src/io/spsetstat.c diff --git a/lib/ultralib/src/io/sptask.c b/lib/ultralib/src/io/sptask.c index 13d6f00..6b5e903 100755..100644 --- a/lib/ultralib/src/io/sptask.c +++ b/lib/ultralib/src/io/sptask.c @@ -1,63 +1,78 @@ #include "PR/os_internal.h" +#include "PR/ultraerror.h" #include "PR/sptask.h" #include "PR/rcp.h" #include "../os/osint.h" -#define _osVirtualToPhysical(ptr) \ - if (ptr != NULL) \ - { \ - ptr = (void *)osVirtualToPhysical(ptr); \ - } +#define _osVirtualToPhysical(ptr) \ + if (ptr != NULL) { \ + ptr = (void*)osVirtualToPhysical(ptr); \ + } static OSTask tmp_task; -static OSTask *_VirtualToPhysicalTask(OSTask *intp) { - OSTask *tp; - tp = &tmp_task; - bcopy(intp, tp, sizeof(OSTask)); - - _osVirtualToPhysical(tp->t.ucode); - _osVirtualToPhysical(tp->t.ucode_data); - _osVirtualToPhysical(tp->t.dram_stack); - _osVirtualToPhysical(tp->t.output_buff); - _osVirtualToPhysical(tp->t.output_buff_size); - _osVirtualToPhysical(tp->t.data_ptr); - _osVirtualToPhysical(tp->t.yield_data_ptr); - return tp; +static OSTask* _VirtualToPhysicalTask(OSTask* intp) { + OSTask* tp; + tp = &tmp_task; + bcopy(intp, tp, sizeof(OSTask)); + + _osVirtualToPhysical(tp->t.ucode); + _osVirtualToPhysical(tp->t.ucode_data); + _osVirtualToPhysical(tp->t.dram_stack); + _osVirtualToPhysical(tp->t.output_buff); + _osVirtualToPhysical(tp->t.output_buff_size); + _osVirtualToPhysical(tp->t.data_ptr); + _osVirtualToPhysical(tp->t.yield_data_ptr); + return tp; } -void osSpTaskLoad(OSTask *intp) { - OSTask *tp; +void osSpTaskLoad(OSTask* intp) { + OSTask* tp; + +#ifdef _DEBUG + if ((intp->t.dram_stack != 0x0) && ((u32)intp->t.dram_stack & 0xf)) { + __osError(ERR_OSSPTASKLOAD_DRAM, 1, intp->t.dram_stack); + return; + } + if ((intp->t.output_buff != 0x0) && ((u32)intp->t.output_buff & 0xf)) { + __osError(ERR_OSSPTASKLOAD_OUT, 1, intp->t.output_buff); + return; + } + if ((intp->t.output_buff_size != 0x0) && ((u32)intp->t.output_buff_size & 0xf)) { + __osError(ERR_OSSPTASKLOAD_OUTSIZE, 1, intp->t.output_buff_size); + return; + } + if ((intp->t.yield_data_ptr != 0x0) && ((u32)intp->t.yield_data_ptr & 0xf)) { + __osError(ERR_OSSPTASKLOAD_YIELD, 1, intp->t.yield_data_ptr); + return; + } +#endif - tp = _VirtualToPhysicalTask(intp); + tp = _VirtualToPhysicalTask(intp); - if (tp->t.flags & OS_TASK_YIELDED) { - tp->t.ucode_data = tp->t.yield_data_ptr; - tp->t.ucode_data_size = tp->t.yield_data_size; - intp->t.flags &= ~OS_TASK_YIELDED; - if (tp->t.flags & OS_TASK_LOADABLE) - tp->t.ucode = (u64 *)IO_READ((u32)intp->t.yield_data_ptr + OS_YIELD_DATA_SIZE - 4); - } + if (tp->t.flags & OS_TASK_YIELDED) { + tp->t.ucode_data = tp->t.yield_data_ptr; + tp->t.ucode_data_size = tp->t.yield_data_size; + intp->t.flags &= ~OS_TASK_YIELDED; + if (tp->t.flags & OS_TASK_LOADABLE) { + tp->t.ucode = (u64*)IO_READ((u32)intp->t.yield_data_ptr + OS_YIELD_DATA_SIZE - 4); + } + } - osWritebackDCache(tp, sizeof(OSTask)); - __osSpSetStatus(SP_CLR_YIELD | SP_CLR_YIELDED | SP_CLR_TASKDONE | SP_SET_INTR_BREAK); + osWritebackDCache(tp, sizeof(OSTask)); + __osSpSetStatus(SP_CLR_YIELD | SP_CLR_YIELDED | SP_CLR_TASKDONE | SP_SET_INTR_BREAK); - while (__osSpSetPc(SP_IMEM_START) == -1) { - } + while (__osSpSetPc(SP_IMEM_START) == -1) {} - while (__osSpRawStartDma(1, (SP_IMEM_START - sizeof(*tp)), tp, sizeof(OSTask)) == -1) { - } + while (__osSpRawStartDma(1, (SP_IMEM_START - sizeof(*tp)), tp, sizeof(OSTask)) == -1) {} - while (__osSpDeviceBusy()) { - } + while (__osSpDeviceBusy()) {} - while (__osSpRawStartDma(1, SP_IMEM_START, tp->t.ucode_boot, tp->t.ucode_boot_size) == -1) { - } + while (__osSpRawStartDma(1, SP_IMEM_START, tp->t.ucode_boot, tp->t.ucode_boot_size) == -1) {} } -void osSpTaskStartGo(OSTask *tp) { - while (__osSpDeviceBusy()) { - } +void osSpTaskStartGo(OSTask* tp) { + while (__osSpDeviceBusy()) {} - __osSpSetStatus(SP_SET_INTR_BREAK | SP_CLR_SSTEP | SP_CLR_BROKE | SP_CLR_HALT); + __osSpSetStatus(SP_SET_INTR_BREAK | SP_CLR_SSTEP | SP_CLR_BROKE | SP_CLR_HALT); } diff --git a/lib/ultralib/src/io/sptaskyield.c b/lib/ultralib/src/io/sptaskyield.c index 78bacae..78bacae 100755..100644 --- a/lib/ultralib/src/io/sptaskyield.c +++ b/lib/ultralib/src/io/sptaskyield.c diff --git a/lib/ultralib/src/io/sptaskyielded.c b/lib/ultralib/src/io/sptaskyielded.c index 6c18c21..3ecab55 100755..100644 --- a/lib/ultralib/src/io/sptaskyielded.c +++ b/lib/ultralib/src/io/sptaskyielded.c @@ -2,17 +2,17 @@ #include "PR/sptask.h" #include "PR/rcp.h" -OSYieldResult osSpTaskYielded(OSTask *tp) { +OSYieldResult osSpTaskYielded(OSTask* tp) { u32 status; OSYieldResult result; - + status = __osSpGetStatus(); - result = status >> 8; - result &= 1; + result = (status & SP_STATUS_YIELDED) ? OS_TASK_YIELDED : 0; if (status & SP_STATUS_YIELD) { - tp->t.flags = ~(OS_TASK_DP_WAIT) & (tp->t.flags | result); + tp->t.flags |= result; + tp->t.flags &= ~(OS_TASK_DP_WAIT); } - + return result; } diff --git a/lib/ultralib/src/io/vi.c b/lib/ultralib/src/io/vi.c index bffed92..246f01f 100644 --- a/lib/ultralib/src/io/vi.c +++ b/lib/ultralib/src/io/vi.c @@ -1,39 +1,39 @@ -#include <macros.h> -#include <PR/os_internal.h> -#include <PR/R4300.h> -#include <PR/rcp.h> +#include "macros.h" +#include "PR/os_internal.h" +#include "PR/R4300.h" +#include "PR/rcp.h" #include "viint.h" // TODO: this comes from a header #ident "$Revision: 1.17 $" -static __OSViContext vi[2] ALIGNED(8) = {0}; -__OSViContext *__osViCurr = &vi[0]; -__OSViContext *__osViNext = &vi[1]; +static __OSViContext vi[2] ALIGNED(8) = { 0 }; +__OSViContext* __osViCurr = &vi[0]; +__OSViContext* __osViNext = &vi[1]; void __osViInit(void) { - bzero(vi, sizeof(vi)); - __osViCurr = &vi[0]; - __osViNext = &vi[1]; - __osViNext->retraceCount = 1; - __osViCurr->retraceCount = 1; - __osViNext->framep = (void*)K0BASE; - __osViCurr->framep = (void*)K0BASE; + bzero(vi, sizeof(vi)); + __osViCurr = &vi[0]; + __osViNext = &vi[1]; + __osViNext->retraceCount = 1; + __osViCurr->retraceCount = 1; + __osViNext->framep = (void*)K0BASE; + __osViCurr->framep = (void*)K0BASE; - if (osTvType == OS_TV_TYPE_PAL) { - __osViNext->modep = &osViModePalLan1; - } else if (osTvType == OS_TV_TYPE_MPAL) { - __osViNext->modep = &osViModeMpalLan1; - } else { - __osViNext->modep = &osViModeNtscLan1; - } - - __osViNext->state = VI_STATE_BLACK; - __osViNext->control = __osViNext->modep->comRegs.ctrl; - - while (IO_READ(VI_CURRENT_REG) > 10) { //wait for vsync? - } + if (osTvType == OS_TV_TYPE_PAL) { + __osViNext->modep = &osViModePalLan1; + } else if (osTvType == OS_TV_TYPE_MPAL) { + __osViNext->modep = &osViModeMpalLan1; + } else { + __osViNext->modep = &osViModeNtscLan1; + } - IO_WRITE(VI_CONTROL_REG, 0); //pixel size blank (no data, no sync) - __osViSwapContext(); + __osViNext->state = VI_STATE_BLACK; + __osViNext->control = __osViNext->modep->comRegs.ctrl; + + while (IO_READ(VI_CURRENT_REG) > 10) { // wait for vsync? + } + + IO_WRITE(VI_CONTROL_REG, 0); // pixel size blank (no data, no sync) + __osViSwapContext(); } diff --git a/lib/ultralib/src/io/viblack.c b/lib/ultralib/src/io/viblack.c index 7e8ea81..30dd85c 100644 --- a/lib/ultralib/src/io/viblack.c +++ b/lib/ultralib/src/io/viblack.c @@ -1,4 +1,4 @@ -#include <PR/os_internal.h> +#include "PR/os_internal.h" #include "viint.h" // TODO: this comes from a header @@ -6,7 +6,7 @@ void osViBlack(u8 active) { register u32 saveMask = __osDisableInt(); - + if (active) { __osViNext->state |= VI_STATE_BLACK; } else { diff --git a/lib/ultralib/src/io/viextendvstart.c b/lib/ultralib/src/io/viextendvstart.c index 8fa8074..7ee06d3 100644 --- a/lib/ultralib/src/io/viextendvstart.c +++ b/lib/ultralib/src/io/viextendvstart.c @@ -1,6 +1,19 @@ -#include <PR/os_internal.h> +#include "PR/os_internal.h" +#include "PR/ultraerror.h" #include "viint.h" void osViExtendVStart(u32 value) { +#ifdef _DEBUG + if (!__osViDevMgr.active) { + __osError(134, 0); + return; + } + + if (value > 48) { + __osError(135, 1, value); + return; + } +#endif __additional_scanline = value; + return; } diff --git a/lib/ultralib/src/io/vifade.c b/lib/ultralib/src/io/vifade.c index 2812860..6766871 100644 --- a/lib/ultralib/src/io/vifade.c +++ b/lib/ultralib/src/io/vifade.c @@ -1,4 +1,4 @@ -#include <PR/os_internal.h> +#include "PR/os_internal.h" #include "viint.h" // TODO: this comes from a header diff --git a/lib/ultralib/src/io/vigetcurrcontext.c b/lib/ultralib/src/io/vigetcurrcontext.c index 729d902..7b1df9b 100644 --- a/lib/ultralib/src/io/vigetcurrcontext.c +++ b/lib/ultralib/src/io/vigetcurrcontext.c @@ -1,9 +1,9 @@ -#include <PR/os_internal.h> +#include "PR/os_internal.h" #include "viint.h" // TODO: this comes from a header #ident "$Revision: 1.17 $" -__OSViContext *__osViGetCurrentContext(void) { +__OSViContext* __osViGetCurrentContext(void) { return __osViCurr; } diff --git a/lib/ultralib/src/io/vigetcurrframebuf.c b/lib/ultralib/src/io/vigetcurrframebuf.c index 987e86b..de36712 100644 --- a/lib/ultralib/src/io/vigetcurrframebuf.c +++ b/lib/ultralib/src/io/vigetcurrframebuf.c @@ -1,10 +1,20 @@ -#include <PR/os_internal.h> +#include "PR/os_internal.h" +#include "PR/ultraerror.h" #include "viint.h" -void *osViGetCurrentFramebuffer(void) { - register u32 saveMask = __osDisableInt(); - void *framep = __osViCurr->framep; +void* osViGetCurrentFramebuffer(void) { + register u32 saveMask; + void* framep; +#ifdef _DEBUG + if (!__osViDevMgr.active) { + __osError(ERR_OSVIGETCURRENTFRAMEBUFFER, 0); + return NULL; + } +#endif + + saveMask = __osDisableInt(); + framep = __osViCurr->framep; __osRestoreInt(saveMask); return framep; } diff --git a/lib/ultralib/src/io/vigetfield.c b/lib/ultralib/src/io/vigetfield.c index 395e912..9dcb7fc 100644 --- a/lib/ultralib/src/io/vigetfield.c +++ b/lib/ultralib/src/io/vigetfield.c @@ -1,5 +1,5 @@ -#include <PR/os_internal.h> -#include <PR/rcp.h> +#include "PR/os_internal.h" +#include "PR/rcp.h" u32 osViGetCurrentField(void) { return IO_READ(VI_CURRENT_REG) & 1; diff --git a/lib/ultralib/src/io/vigetline.c b/lib/ultralib/src/io/vigetline.c index 1eed3cd..5667d61 100644 --- a/lib/ultralib/src/io/vigetline.c +++ b/lib/ultralib/src/io/vigetline.c @@ -1,5 +1,5 @@ -#include <PR/os_internal.h> -#include <PR/rcp.h> +#include "PR/os_internal.h" +#include "PR/rcp.h" u32 osViGetCurrentLine(void) { return IO_READ(VI_CURRENT_REG); diff --git a/lib/ultralib/src/io/vigetmode.c b/lib/ultralib/src/io/vigetmode.c index bb3fcd0..2507372 100644 --- a/lib/ultralib/src/io/vigetmode.c +++ b/lib/ultralib/src/io/vigetmode.c @@ -1,10 +1,21 @@ -#include <PR/os_internal.h> +#include "PR/os_internal.h" +#include "PR/ultraerror.h" #include "viint.h" u32 osViGetCurrentMode(void) { - register u32 savedMask = __osDisableInt(); - register u32 modeType = __osViCurr->modep->type; + register u32 saveMask; + register u32 modeType; - __osRestoreInt(savedMask); +#ifdef _DEBUG + if (!__osViDevMgr.active) { + __osError(ERR_OSVIGETCURRENTMODE, 0); + return -1; + } +#endif + + saveMask = __osDisableInt(); + modeType = (u32)__osViCurr->modep->type; + + __osRestoreInt(saveMask); return modeType; } diff --git a/lib/ultralib/src/io/vigetnextcontext.c b/lib/ultralib/src/io/vigetnextcontext.c index 5692890..bb6012a 100644 --- a/lib/ultralib/src/io/vigetnextcontext.c +++ b/lib/ultralib/src/io/vigetnextcontext.c @@ -1,6 +1,6 @@ -#include <PR/os_internal.h> +#include "PR/os_internal.h" #include "viint.h" -__OSViContext *__osViGetNextContext(void) { +__OSViContext* __osViGetNextContext(void) { return __osViNext; } diff --git a/lib/ultralib/src/io/vigetnextframebuf.c b/lib/ultralib/src/io/vigetnextframebuf.c index 9158281..2985358 100644 --- a/lib/ultralib/src/io/vigetnextframebuf.c +++ b/lib/ultralib/src/io/vigetnextframebuf.c @@ -1,10 +1,20 @@ -#include <PR/os_internal.h> +#include "PR/os_internal.h" +#include "PR/ultraerror.h" #include "viint.h" -void *osViGetNextFramebuffer(void) { - register u32 saveMask = __osDisableInt(); - void *framep = __osViNext->framep; - +void* osViGetNextFramebuffer(void) { + register u32 saveMask; + void* framep; + +#ifdef _DEBUG + if (!__osViDevMgr.active) { + __osError(ERR_OSVIGETNEXTFRAMEBUFFER, 0); + return NULL; + } +#endif + + saveMask = __osDisableInt(); + framep = __osViNext->framep; __osRestoreInt(saveMask); return framep; } diff --git a/lib/ultralib/src/io/vigetstat.c b/lib/ultralib/src/io/vigetstat.c index eea94a7..8fc6f38 100644 --- a/lib/ultralib/src/io/vigetstat.c +++ b/lib/ultralib/src/io/vigetstat.c @@ -1,5 +1,5 @@ -#include <PR/os_internal.h> -#include <PR/rcp.h> +#include "PR/os_internal.h" +#include "PR/rcp.h" u32 osViGetStatus(void) { return IO_READ(VI_STATUS_REG); diff --git a/lib/ultralib/src/io/viint.h b/lib/ultralib/src/io/viint.h index 3ae94c8..ffe0927 100644 --- a/lib/ultralib/src/io/viint.h +++ b/lib/ultralib/src/io/viint.h @@ -24,17 +24,17 @@ #define VI_SUBPIXEL_SH 0x10 #define BURST(hsync_width, color_width, vsync_width, color_start) \ - (hsync_width | (color_width << 8) | (vsync_width << 16) | (color_start << 20)) -#define WIDTH(v) v -#define VSYNC(v) v -#define HSYNC(duration, leap) (duration | (leap << 16)) -#define LEAP(upper, lower) ((upper << 16) | lower) -#define START(start, end) ((start << 16) | end) + (((u32)(hsync_width) & 0xFF) | (((u32)(color_width) & 0xFF) << 8) | (((u32)(vsync_width) & 0xF) << 16) | (((u32)(color_start) & 0xFFFF) << 20)) +#define WIDTH(v) (v) +#define VSYNC(v) (v) +#define HSYNC(duration, leap) (((u32)(leap) << 16) | ((u32)(duration) & 0xFFFF)) +#define LEAP(upper, lower) (((u32)(upper) << 16) | ((u32)(lower) & 0xFFFF)) +#define START(start, end) (((u32)(start) << 16) | ((u32)(end) & 0xFFFF)) -#define FTOFIX(val, i, f) ((u32)(val * (f32)(1 << f)) & ((1 << (i + f)) - 1)) +#define FTOFIX(val, i, f) ((u32)((val) * (f32)(1 << (f))) & ((1 << ((i) + (f))) - 1)) #define F210(val) FTOFIX(val, 2, 10) -#define SCALE(scaleup, off) (F210((1.0f / (f32)scaleup)) | (F210((f32)off) << 16)) +#define SCALE(scaleup, off) (F210((1.0f / (f32)(scaleup))) | (F210((f32)(off)) << 16)) #define VCURRENT(v) v //seemingly unused #define ORIGIN(v) v @@ -67,4 +67,5 @@ extern __OSViContext *__osViNext; extern u32 __additional_scanline; __OSViContext *__osViGetCurrentContext(void); void __osViInit(void); +extern OSDevMgr __osViDevMgr; #endif diff --git a/lib/ultralib/src/io/vimgr.c b/lib/ultralib/src/io/vimgr.c index d4766b5..1f2e5e8 100644 --- a/lib/ultralib/src/io/vimgr.c +++ b/lib/ultralib/src/io/vimgr.c @@ -1,68 +1,76 @@ -#include <macros.h> -#include <PR/os_internal.h> -#include <PR/rcp.h> +#include "macros.h" +#include "PR/os_internal.h" +#include "PR/ultraerror.h" +#include "PR/rcp.h" #include "viint.h" #include "../os/osint.h" - -OSDevMgr __osViDevMgr = {0}; + +OSDevMgr __osViDevMgr = { 0 }; u32 __additional_scanline = 0; static OSThread viThread; static unsigned char viThreadStack[OS_VIM_STACKSIZE] ALIGNED(16); -static OSMesgQueue viEventQueue; +static OSMesgQueue viEventQueue ALIGNED(8); static OSMesg viEventBuf[5] ALIGNED(8); static OSIoMesg viRetraceMsg ALIGNED(8); static OSIoMesg viCounterMsg ALIGNED(8); -static void viMgrMain(void *arg); -void osCreateViManager(OSPri pri) -{ +static void viMgrMain(void* arg); +void osCreateViManager(OSPri pri) { u32 savedMask; - OSPri myPri; OSPri oldPri; + OSPri myPri; - if (!__osViDevMgr.active) { - __osTimerServicesInit(); - __additional_scanline = 0; - osCreateMesgQueue(&viEventQueue, viEventBuf, ARRLEN(viEventBuf)); - viRetraceMsg.hdr.type = OS_MESG_TYPE_VRETRACE; - viRetraceMsg.hdr.pri = OS_MESG_PRI_NORMAL; - viRetraceMsg.hdr.retQueue = NULL; - viCounterMsg.hdr.type = OS_MESG_TYPE_COUNTER; - viCounterMsg.hdr.pri = OS_MESG_PRI_NORMAL; - viCounterMsg.hdr.retQueue = NULL; - osSetEventMesg(OS_EVENT_VI, &viEventQueue, &viRetraceMsg); - osSetEventMesg(OS_EVENT_COUNTER, &viEventQueue, &viCounterMsg); - oldPri = -1; - myPri = osGetThreadPri(NULL); +#ifdef _DEBUG + if ((pri < OS_PRIORITY_IDLE) || (pri > OS_PRIORITY_MAX)) { + __osError(ERR_OSCREATEVIMANAGER, 1, pri); + return; + } +#endif - if (myPri < pri) { - oldPri = myPri; - osSetThreadPri(NULL, pri); - } + if (__osViDevMgr.active) { + return; + } + __osTimerServicesInit(); + __additional_scanline = 0; + osCreateMesgQueue(&viEventQueue, viEventBuf, ARRLEN(viEventBuf)); + viRetraceMsg.hdr.type = OS_MESG_TYPE_VRETRACE; + viRetraceMsg.hdr.pri = OS_MESG_PRI_NORMAL; + viRetraceMsg.hdr.retQueue = NULL; + viCounterMsg.hdr.type = OS_MESG_TYPE_COUNTER; + viCounterMsg.hdr.pri = OS_MESG_PRI_NORMAL; + viCounterMsg.hdr.retQueue = NULL; + osSetEventMesg(OS_EVENT_VI, &viEventQueue, &viRetraceMsg); + osSetEventMesg(OS_EVENT_COUNTER, &viEventQueue, &viCounterMsg); + oldPri = -1; + myPri = osGetThreadPri(NULL); - savedMask = __osDisableInt(); - __osViDevMgr.active = TRUE; - __osViDevMgr.thread = &viThread; - __osViDevMgr.cmdQueue = &viEventQueue; - __osViDevMgr.evtQueue = &viEventQueue; - __osViDevMgr.acsQueue = NULL; - __osViDevMgr.dma = NULL; - __osViDevMgr.edma = NULL; - osCreateThread(&viThread, 0, viMgrMain, &__osViDevMgr, &viThreadStack[OS_VIM_STACKSIZE], pri); - __osViInit(); - osStartThread(&viThread); - __osRestoreInt(savedMask); + if (myPri < pri) { + oldPri = myPri; + osSetThreadPri(NULL, pri); + } - if (oldPri != -1) { - osSetThreadPri(0, oldPri); - } + savedMask = __osDisableInt(); + __osViDevMgr.active = TRUE; + __osViDevMgr.thread = &viThread; + __osViDevMgr.cmdQueue = &viEventQueue; + __osViDevMgr.evtQueue = &viEventQueue; + __osViDevMgr.acsQueue = NULL; + __osViDevMgr.dma = NULL; + __osViDevMgr.edma = NULL; + osCreateThread(&viThread, 0, viMgrMain, &__osViDevMgr, &viThreadStack[OS_VIM_STACKSIZE], pri); + __osViInit(); + osStartThread(&viThread); + __osRestoreInt(savedMask); + + if (oldPri != -1) { + osSetThreadPri(NULL, oldPri); } } -static void viMgrMain(void *arg) { - __OSViContext *vc; - OSDevMgr *dm; - OSIoMesg *mb; +static void viMgrMain(void* arg) { + __OSViContext* vc; + OSDevMgr* dm; + OSIoMesg* mb; static u16 retrace; s32 first; u32 count; @@ -71,9 +79,10 @@ static void viMgrMain(void *arg) { first = 0; vc = __osViGetCurrentContext(); retrace = vc->retraceCount; - if (retrace == 0) + if (retrace == 0) { retrace = 1; - dm = (OSDevMgr *)arg; + } + dm = (OSDevMgr*)arg; while (TRUE) { osRecvMesg(dm->evtQueue, (OSMesg)&mb, OS_MESG_BLOCK); @@ -84,13 +93,14 @@ static void viMgrMain(void *arg) { if (retrace == 0) { vc = __osViGetCurrentContext(); - if (vc->msgq != NULL) + if (vc->msgq != NULL) { osSendMesg(vc->msgq, vc->msg, OS_MESG_NOBLOCK); + } retrace = vc->retraceCount; } __osViIntrCount++; - + if (first) { count = osGetCount(); __osCurrentTime = count; @@ -105,6 +115,8 @@ static void viMgrMain(void *arg) { case OS_MESG_TYPE_COUNTER: __osTimerInterrupt(); break; + default: + break; } } } diff --git a/lib/ultralib/src/io/virepeatline.c b/lib/ultralib/src/io/virepeatline.c index 905538e..1bc4984 100644 --- a/lib/ultralib/src/io/virepeatline.c +++ b/lib/ultralib/src/io/virepeatline.c @@ -1,4 +1,4 @@ -#include <PR/os_internal.h> +#include "PR/os_internal.h" #include "viint.h" // TODO: this comes from a header @@ -12,6 +12,6 @@ void osViRepeatLine(u8 active) { } else { __osViNext->state &= ~VI_STATE_REPEATLINE; } - + __osRestoreInt(saveMask); } diff --git a/lib/ultralib/src/io/visetevent.c b/lib/ultralib/src/io/visetevent.c index 589647a..f741a0e 100644 --- a/lib/ultralib/src/io/visetevent.c +++ b/lib/ultralib/src/io/visetevent.c @@ -1,11 +1,67 @@ -#include <PR/os_internal.h> +#include "PR/os_internal.h" +#include "PR/ultraerror.h" +#include "assert.h" #include "viint.h" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + // TODO: this comes from a header #ident "$Revision: 1.17 $" -void osViSetEvent(OSMesgQueue *mq, OSMesg m, u32 retraceCount) { - register u32 saveMask = __osDisableInt(); +void osViSetEvent(OSMesgQueue* mq, OSMesg m, u32 retraceCount) { + register u32 saveMask; + +#ifdef _DEBUG + if (!__osViDevMgr.active) { + __osError(ERR_OSVISETEVENT, 0); + return; + } + + assert(mq != NULL); +#endif + + saveMask = __osDisableInt(); __osViNext->msgq = mq; __osViNext->msg = m; diff --git a/lib/ultralib/src/io/visetmode.c b/lib/ultralib/src/io/visetmode.c index 655cba6..5ab2094 100644 --- a/lib/ultralib/src/io/visetmode.c +++ b/lib/ultralib/src/io/visetmode.c @@ -1,11 +1,64 @@ -#include <PR/os_internal.h> +#include "PR/os_internal.h" +#include "PR/ultraerror.h" +#include "assert.h" #include "viint.h" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + // TODO: this comes from a header #ident "$Revision: 1.17 $" -void osViSetMode(OSViMode *modep) { - register u32 saveMask = __osDisableInt(); +void osViSetMode(OSViMode* modep) { + register u32 saveMask; + +#ifdef _DEBUG + if (!__osViDevMgr.active) { + __osError(ERR_OSVISETMODE, 0); + return; + } + + assert(modep != NULL); +#endif + + saveMask = __osDisableInt(); __osViNext->modep = modep; __osViNext->state = VI_STATE_MODE_UPDATED; diff --git a/lib/ultralib/src/io/visetspecial.c b/lib/ultralib/src/io/visetspecial.c index e8f90b8..f3bd773 100644 --- a/lib/ultralib/src/io/visetspecial.c +++ b/lib/ultralib/src/io/visetspecial.c @@ -1,12 +1,31 @@ -#include <PR/os_internal.h> -#include <PR/rcp.h> +#include "PR/os_internal.h" +#include "PR/ultraerror.h" +#include "PR/rcp.h" #include "viint.h" // TODO: this comes from a header #ident "$Revision: 1.17 $" +#define OS_VI_SPECIAL_MAX \ + (OS_VI_GAMMA_ON | OS_VI_GAMMA_OFF | OS_VI_GAMMA_DITHER_ON | OS_VI_GAMMA_DITHER_OFF | OS_VI_DIVOT_ON | \ + OS_VI_DIVOT_OFF | OS_VI_DITHER_FILTER_ON | OS_VI_DITHER_FILTER_OFF) + void osViSetSpecialFeatures(u32 func) { - register u32 saveMask = __osDisableInt(); + register u32 saveMask; + +#ifdef _DEBUG + if (!__osViDevMgr.active) { + __osError(ERR_OSVISETSPECIAL_VIMGR, 0); + return; + } + + if ((func < OS_VI_GAMMA_ON) || (func > OS_VI_SPECIAL_MAX)) { + __osError(ERR_OSVISETSPECIAL_VALUE, 1, func); + return; + } +#endif + + saveMask = __osDisableInt(); if ((func & OS_VI_GAMMA_ON) != 0) { __osViNext->control |= VI_CTRL_GAMMA_ON; @@ -15,33 +34,33 @@ void osViSetSpecialFeatures(u32 func) { if ((func & OS_VI_GAMMA_OFF) != 0) { __osViNext->control &= ~VI_CTRL_GAMMA_ON; } - + if ((func & OS_VI_GAMMA_DITHER_ON) != 0) { __osViNext->control |= VI_CTRL_GAMMA_DITHER_ON; } - + if ((func & OS_VI_GAMMA_DITHER_OFF) != 0) { __osViNext->control &= ~VI_CTRL_GAMMA_DITHER_ON; } - + if ((func & OS_VI_DIVOT_ON) != 0) { __osViNext->control |= VI_CTRL_DIVOT_ON; } - + if ((func & OS_VI_DIVOT_OFF) != 0) { __osViNext->control &= ~VI_CTRL_DIVOT_ON; } - + if ((func & OS_VI_DITHER_FILTER_ON) != 0) { __osViNext->control |= VI_CTRL_DITHER_FILTER_ON; __osViNext->control &= ~VI_CTRL_ANTIALIAS_MASK; } - + if ((func & OS_VI_DITHER_FILTER_OFF) != 0) { __osViNext->control &= ~VI_CTRL_DITHER_FILTER_ON; __osViNext->control |= __osViNext->modep->comRegs.ctrl & VI_CTRL_ANTIALIAS_MASK; } - + __osViNext->state |= VI_STATE_CTRL_UPDATED; __osRestoreInt(saveMask); diff --git a/lib/ultralib/src/io/visetxscale.c b/lib/ultralib/src/io/visetxscale.c index 328987c..6af6535 100644 --- a/lib/ultralib/src/io/visetxscale.c +++ b/lib/ultralib/src/io/visetxscale.c @@ -1,4 +1,6 @@ -#include <PR/os_internal.h> +#include "PR/os_internal.h" +#include "PR/ultraerror.h" +#include "PR/ultralog.h" #include "viint.h" // TODO: this comes from a header @@ -6,8 +8,27 @@ void osViSetXScale(f32 value) { register u32 nomValue; - register u32 saveMask = __osDisableInt(); - + register u32 saveMask; + +#ifdef _DEBUG + if (!__osViDevMgr.active) { + __osError(ERR_OSVISETXSCALE_VIMGR, 0); + return; + } + + if ((value < 0.25f) || (value > 1.0f)) { + __osError(ERR_OSVISETXSCALE_VALUE, 1, OS_LOG_FLOAT(value)); + + if (value < 0.25f) { + value = 0.25f; + } else { + value = 1.0f; + } + } +#endif + + saveMask = __osDisableInt(); + __osViNext->x.factor = value; __osViNext->state |= VI_STATE_XSCALE_UPDATED; nomValue = __osViNext->modep->comRegs.xScale & VI_SCALE_MASK; diff --git a/lib/ultralib/src/io/visetyscale.c b/lib/ultralib/src/io/visetyscale.c index 525e0eb..c1c96f4 100644 --- a/lib/ultralib/src/io/visetyscale.c +++ b/lib/ultralib/src/io/visetyscale.c @@ -1,11 +1,32 @@ -#include <PR/os_internal.h> +#include "PR/os_internal.h" +#include "PR/ultraerror.h" +#include "PR/ultralog.h" #include "viint.h" // TODO: this comes from a header #ident "$Revision: 1.17 $" void osViSetYScale(f32 value) { - register u32 saveMask = __osDisableInt(); + register u32 saveMask; + +#ifdef _DEBUG + if (!__osViDevMgr.active) { + __osError(ERR_OSVISETYSCALE_VIMGR, 0); + return; + } + + if ((value < 0.05f) || (value > 1.0f)) { + __osError(ERR_OSVISETYSCALE_VALUE, 1, OS_LOG_FLOAT(value)); + + if (value < 0.05f) { + value = 0.05f; + } else { + value = 1.0f; + } + } +#endif + + saveMask = __osDisableInt(); __osViNext->y.factor = value; __osViNext->state |= VI_STATE_YSCALE_UPDATED; diff --git a/lib/ultralib/src/io/viswapbuf.c b/lib/ultralib/src/io/viswapbuf.c index 327ed60..aa077cd 100644 --- a/lib/ultralib/src/io/viswapbuf.c +++ b/lib/ultralib/src/io/viswapbuf.c @@ -1,11 +1,73 @@ -#include <PR/os_internal.h> +#include "PR/os_internal.h" +#include "PR/ultraerror.h" +#include "assert.h" #include "viint.h" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + // TODO: this comes from a header #ident "$Revision: 1.17 $" void osViSwapBuffer(void* frameBufPtr) { - u32 saveMask = __osDisableInt(); + u32 saveMask; + +#ifdef _DEBUG + if (!__osViDevMgr.active) { + __osError(ERR_OSVISWAPBUFFER_VIMGR, 0); + return; + } + + assert(frameBufPtr != NULL); + + if ((u32)frameBufPtr & 0x3f) { + __osError(ERR_OSVISWAPBUFFER_ADDR, 1, frameBufPtr); + return; + } +#endif + + saveMask = __osDisableInt(); __osViNext->framep = frameBufPtr; __osViNext->state |= VI_STATE_BUFFER_UPDATED; diff --git a/lib/ultralib/src/io/viswapcontext.c b/lib/ultralib/src/io/viswapcontext.c index 3095d51..aac7cd9 100644 --- a/lib/ultralib/src/io/viswapcontext.c +++ b/lib/ultralib/src/io/viswapcontext.c @@ -1,16 +1,16 @@ -#include <PR/os_internal.h> -#include <PR/rcp.h> +#include "PR/os_internal.h" +#include "PR/rcp.h" #include "viint.h" // TODO: this comes from a header #ident "$Revision: 1.17 $" void __osViSwapContext() { - register OSViMode *vm; - register __OSViContext *vc; + register OSViMode* vm; + register __OSViContext* vc; u32 origin; - u32 vStart; u32 hStart; + u32 vStart; u32 nomValue; u32 field; @@ -18,7 +18,7 @@ void __osViSwapContext() { vc = __osViNext; vm = vc->modep; - field = IO_READ(VI_CURRENT_REG) & 1; //field num + field = IO_READ(VI_CURRENT_REG) & 1; // field num origin = osVirtualToPhysical(vc->framep) + (vm->fldRegs[field].origin); if (vc->state & VI_STATE_XSCALE_UPDATED) { diff --git a/lib/ultralib/src/io/vitbl.c b/lib/ultralib/src/io/vitbl.c index 89e57e7..24dc787 100644 --- a/lib/ultralib/src/io/vitbl.c +++ b/lib/ultralib/src/io/vitbl.c @@ -1,1742 +1,1738 @@ -#include <PR/os.h> -#include <PR/rcp.h> +#include "PR/os.h" +#include "PR/rcp.h" #include "../io/viint.h" OSViMode osViModeTable[56] = { - { - OS_VI_NTSC_LPN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 34, 5, 62), // burst - VSYNC(525), // vSync - HSYNC(3093, 0), // hSync - LEAP(3093, 3093), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { OS_VI_NTSC_LPN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 34, 5, 62), // burst + VSYNC(525), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_NTSC_LPF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 34, 5, 62), // burst - VSYNC(524), // vSync - HSYNC(3093, 0), // hSync - LEAP(3093, 3093), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_NTSC_LPF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 34, 5, 62), // burst + VSYNC(524), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0.25), // yScale + HSTART(35, 509), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0.25), // yScale - HSTART(35, 509), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0.75), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_NTSC_LAN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_1 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 34, 5, 62), // burst - VSYNC(525), // vSync - HSYNC(3093, 0), // hSync - LEAP(3093, 3093), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0.75), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_NTSC_LAN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_1 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 34, 5, 62), // burst + VSYNC(525), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_NTSC_LAF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 34, 5, 62), // burst - VSYNC(524), // vSync - HSYNC(3093, 0), // hSync - LEAP(3093, 3093), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_NTSC_LAF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 34, 5, 62), // burst + VSYNC(524), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0.25), // yScale + HSTART(35, 509), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0.25), // yScale - HSTART(35, 509), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0.75), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_NTSC_LPN2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_ANTIALIAS_MODE_3 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 34, 5, 62), // burst - VSYNC(525), // vSync - HSYNC(3093, 0), // hSync - LEAP(3093, 3093), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0.75), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_NTSC_LPN2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_ANTIALIAS_MODE_3 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 34, 5, 62), // burst + VSYNC(525), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_NTSC_LPF2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 34, 5, 62), // burst - VSYNC(524), // vSync - HSYNC(3093, 0), // hSync - LEAP(3093, 3093), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_NTSC_LPF2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 34, 5, 62), // burst + VSYNC(524), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0.25), // yScale + HSTART(35, 509), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0.25), // yScale - HSTART(35, 509), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0.75), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_NTSC_LAN2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 34, 5, 62), // burst - VSYNC(525), // vSync - HSYNC(3093, 0), // hSync - LEAP(3093, 3093), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0.75), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_NTSC_LAN2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 34, 5, 62), // burst + VSYNC(525), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_NTSC_LAF2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 34, 5, 62), // burst - VSYNC(524), // vSync - HSYNC(3093, 0), // hSync - LEAP(3093, 3093), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_NTSC_LAF2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 34, 5, 62), // burst + VSYNC(524), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0.25), // yScale + HSTART(35, 509), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0.25), // yScale - HSTART(35, 509), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0.75), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_NTSC_HPN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(1280), // width - BURST(57, 34, 5, 62), // burst - VSYNC(524), // vSync - HSYNC(3093, 0), // hSync - LEAP(3093, 3093), // leap - HSTART(108, 748), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0.75), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_NTSC_HPN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(1280), // width + BURST(57, 34, 5, 62), // burst + VSYNC(524), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(35, 509), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(35, 509), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(2560), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_NTSC_HPF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(640), // width - BURST(57, 34, 5, 62), // burst - VSYNC(524), // vSync - HSYNC(3093, 0), // hSync - LEAP(3093, 3093), // leap - HSTART(108, 748), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(2560), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_NTSC_HPF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(640), // width + BURST(57, 34, 5, 62), // burst + VSYNC(524), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(0.5, 0.5), // yScale + HSTART(35, 509), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(0.5, 0.5), // yScale - HSTART(35, 509), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(2560), // origin - SCALE(0.5, 0.5), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_NTSC_HAN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(1280), // width - BURST(57, 34, 5, 62), // burst - VSYNC(524), // vSync - HSYNC(3093, 0), // hSync - LEAP(3093, 3093), // leap - HSTART(108, 748), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(2560), // origin + SCALE(0.5, 0.5), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_NTSC_HAN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(1280), // width + BURST(57, 34, 5, 62), // burst + VSYNC(524), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(35, 509), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(35, 509), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(2560), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_NTSC_HAF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(640), // width - BURST(57, 34, 5, 62), // burst - VSYNC(524), // vSync - HSYNC(3093, 0), // hSync - LEAP(3093, 3093), // leap - HSTART(108, 748), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(2560), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_NTSC_HAF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(640), // width + BURST(57, 34, 5, 62), // burst + VSYNC(524), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(0.5, 0.5), // yScale + HSTART(35, 509), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(0.5, 0.5), // yScale - HSTART(35, 509), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(2560), // origin - SCALE(0.5, 0.5), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_NTSC_HPN2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_3 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(1280), // width - BURST(57, 34, 5, 62), // burst - VSYNC(524), // vSync - HSYNC(3093, 0), // hSync - LEAP(3093, 3093), // leap - HSTART(108, 748), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(2560), // origin + SCALE(0.5, 0.5), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_NTSC_HPN2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_3 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(1280), // width + BURST(57, 34, 5, 62), // burst + VSYNC(524), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(2560), // origin + SCALE(1, 0), // yScale + HSTART(35, 509), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(2560), // origin - SCALE(1, 0), // yScale - HSTART(35, 509), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(5120), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_NTSC_HPF2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(640), // width - BURST(57, 34, 5, 62), // burst - VSYNC(524), // vSync - HSYNC(3093, 0), // hSync - LEAP(3093, 3093), // leap - HSTART(108, 748), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(5120), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_NTSC_HPF2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(640), // width + BURST(57, 34, 5, 62), // burst + VSYNC(524), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(2560), // origin + SCALE(0.5, 0.5), // yScale + HSTART(35, 509), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(2560), // origin - SCALE(0.5, 0.5), // yScale - HSTART(35, 509), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(5120), // origin - SCALE(0.5, 0.5), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_PAL_LPN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(625), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(5120), // origin + SCALE(0.5, 0.5), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_PAL_LPN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(625), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(95, 569), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(95, 569), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(95, 569), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_PAL_LPF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(95, 569), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_PAL_LPF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0.25), // yScale + HSTART(93, 567), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0.25), // yScale - HSTART(93, 567), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0.75), // yScale - HSTART(95, 569), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_PAL_LAN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_1 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(625), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0.75), // yScale + HSTART(95, 569), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_PAL_LAN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_1 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(625), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(95, 569), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(95, 569), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(95, 569), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_PAL_LAF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(95, 569), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_PAL_LAF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0.25), // yScale + HSTART(93, 567), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0.25), // yScale - HSTART(93, 567), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0.75), // yScale - HSTART(95, 569), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_PAL_LPN2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_ANTIALIAS_MODE_3 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(625), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0.75), // yScale + HSTART(95, 569), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_PAL_LPN2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_ANTIALIAS_MODE_3 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(625), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(95, 569), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(95, 569), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(95, 569), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_PAL_LPF2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(95, 569), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_PAL_LPF2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0.25), // yScale + HSTART(93, 567), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0.25), // yScale - HSTART(93, 567), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0.75), // yScale - HSTART(95, 569), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_PAL_LAN2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(625), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0.75), // yScale + HSTART(95, 569), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_PAL_LAN2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(625), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(95, 569), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(95, 569), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(95, 569), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_PAL_LAF2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(95, 569), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_PAL_LAF2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0.25), // yScale + HSTART(93, 567), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0.25), // yScale - HSTART(93, 567), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0.75), // yScale - HSTART(95, 569), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_PAL_HPN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(1280), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0.75), // yScale + HSTART(95, 569), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_PAL_HPN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(1280), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(93, 567), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(93, 567), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(2560), // origin - SCALE(1, 0), // yScale - HSTART(95, 569), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_PAL_HPF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(640), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(2560), // origin + SCALE(1, 0), // yScale + HSTART(95, 569), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_PAL_HPF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(640), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(0.5, 0.5), // yScale + HSTART(93, 567), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(0.5, 0.5), // yScale - HSTART(93, 567), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(2560), // origin - SCALE(0.5, 0.5), // yScale - HSTART(95, 569), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_PAL_HAN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(1280), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(2560), // origin + SCALE(0.5, 0.5), // yScale + HSTART(95, 569), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_PAL_HAN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(1280), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(93, 567), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(93, 567), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(2560), // origin - SCALE(1, 0), // yScale - HSTART(95, 569), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_PAL_HAF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(640), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(2560), // origin + SCALE(1, 0), // yScale + HSTART(95, 569), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_PAL_HAF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(640), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(0.5, 0.5), // yScale + HSTART(93, 567), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(0.5, 0.5), // yScale - HSTART(93, 567), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(2560), // origin - SCALE(0.5, 0.5), // yScale - HSTART(95, 569), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_PAL_HPN2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_3 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(1280), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(2560), // origin + SCALE(0.5, 0.5), // yScale + HSTART(95, 569), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_PAL_HPN2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_3 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(1280), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(2560), // origin + SCALE(1, 0), // yScale + HSTART(93, 567), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(2560), // origin - SCALE(1, 0), // yScale - HSTART(93, 567), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(5120), // origin - SCALE(1, 0), // yScale - HSTART(95, 569), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_PAL_HPF2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(640), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(5120), // origin + SCALE(1, 0), // yScale + HSTART(95, 569), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_PAL_HPF2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(640), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(2560), // origin + SCALE(0.5, 0.5), // yScale + HSTART(93, 567), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(2560), // origin - SCALE(0.5, 0.5), // yScale - HSTART(93, 567), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(5120), // origin - SCALE(0.5, 0.5), // yScale - HSTART(95, 569), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_MPAL_LPN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 30, 5, 70), // burst - VSYNC(525), // vSync - HSYNC(3089, 4), // hSync - LEAP(3097, 3098), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(5120), // origin + SCALE(0.5, 0.5), // yScale + HSTART(95, 569), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_MPAL_LPN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 30, 5, 70), // burst + VSYNC(525), // vSync + HSYNC(3089, 4), // hSync + LEAP(3097, 3098), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_MPAL_LPF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 30, 5, 70), // burst - VSYNC(524), // vSync - HSYNC(3088, 0), // hSync - LEAP(3100, 3100), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_MPAL_LPF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 30, 5, 70), // burst + VSYNC(524), // vSync + HSYNC(3088, 0), // hSync + LEAP(3100, 3100), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0.25), // yScale + HSTART(35, 509), // vStart + BURST(2, 2, 11, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0.25), // yScale - HSTART(35, 509), // vStart - BURST(2, 2, 11, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0.75), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_MPAL_LAN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_1 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 30, 5, 70), // burst - VSYNC(525), // vSync - HSYNC(3089, 4), // hSync - LEAP(3097, 3098), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0.75), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_MPAL_LAN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_1 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 30, 5, 70), // burst + VSYNC(525), // vSync + HSYNC(3089, 4), // hSync + LEAP(3097, 3098), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_MPAL_LAF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 30, 5, 70), // burst - VSYNC(524), // vSync - HSYNC(3088, 0), // hSync - LEAP(3100, 3100), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_MPAL_LAF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 30, 5, 70), // burst + VSYNC(524), // vSync + HSYNC(3088, 0), // hSync + LEAP(3100, 3100), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0.25), // yScale + HSTART(35, 509), // vStart + BURST(2, 2, 11, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0.25), // yScale - HSTART(35, 509), // vStart - BURST(2, 2, 11, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0.75), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_MPAL_LPN2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_ANTIALIAS_MODE_3 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 30, 5, 70), // burst - VSYNC(525), // vSync - HSYNC(3089, 4), // hSync - LEAP(3097, 3098), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0.75), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_MPAL_LPN2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_ANTIALIAS_MODE_3 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 30, 5, 70), // burst + VSYNC(525), // vSync + HSYNC(3089, 4), // hSync + LEAP(3097, 3098), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_MPAL_LPF2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 30, 5, 70), // burst - VSYNC(524), // vSync - HSYNC(3088, 0), // hSync - LEAP(3100, 3100), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_MPAL_LPF2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 30, 5, 70), // burst + VSYNC(524), // vSync + HSYNC(3088, 0), // hSync + LEAP(3100, 3100), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0.25), // yScale + HSTART(35, 509), // vStart + BURST(2, 2, 11, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0.25), // yScale - HSTART(35, 509), // vStart - BURST(2, 2, 11, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0.75), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_MPAL_LAN2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 30, 5, 70), // burst - VSYNC(525), // vSync - HSYNC(3089, 4), // hSync - LEAP(3097, 3098), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0.75), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_MPAL_LAN2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 30, 5, 70), // burst + VSYNC(525), // vSync + HSYNC(3089, 4), // hSync + LEAP(3097, 3098), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_MPAL_LAF2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 30, 5, 70), // burst - VSYNC(524), // vSync - HSYNC(3088, 0), // hSync - LEAP(3100, 3100), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_MPAL_LAF2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 30, 5, 70), // burst + VSYNC(524), // vSync + HSYNC(3088, 0), // hSync + LEAP(3100, 3100), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0.25), // yScale + HSTART(35, 509), // vStart + BURST(2, 2, 11, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0.25), // yScale - HSTART(35, 509), // vStart - BURST(2, 2, 11, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0.75), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_MPAL_HPN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(1280), // width - BURST(57, 30, 5, 70), // burst - VSYNC(524), // vSync - HSYNC(3088, 0), // hSync - LEAP(3100, 3100), // leap - HSTART(108, 748), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0.75), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_MPAL_HPN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(1280), // width + BURST(57, 30, 5, 70), // burst + VSYNC(524), // vSync + HSYNC(3088, 0), // hSync + LEAP(3100, 3100), // leap + HSTART(108, 748), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(35, 509), // vStart + BURST(2, 2, 11, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(35, 509), // vStart - BURST(2, 2, 11, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(2560), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_MPAL_HPF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(640), // width - BURST(57, 30, 5, 70), // burst - VSYNC(524), // vSync - HSYNC(3088, 0), // hSync - LEAP(3100, 3100), // leap - HSTART(108, 748), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(2560), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_MPAL_HPF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(640), // width + BURST(57, 30, 5, 70), // burst + VSYNC(524), // vSync + HSYNC(3088, 0), // hSync + LEAP(3100, 3100), // leap + HSTART(108, 748), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(0.5, 0.5), // yScale + HSTART(35, 509), // vStart + BURST(2, 2, 11, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(0.5, 0.5), // yScale - HSTART(35, 509), // vStart - BURST(2, 2, 11, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(2560), // origin - SCALE(0.5, 0.5), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_MPAL_HAN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(1280), // width - BURST(57, 30, 5, 70), // burst - VSYNC(524), // vSync - HSYNC(3088, 0), // hSync - LEAP(3100, 3100), // leap - HSTART(108, 748), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(2560), // origin + SCALE(0.5, 0.5), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_MPAL_HAN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(1280), // width + BURST(57, 30, 5, 70), // burst + VSYNC(524), // vSync + HSYNC(3088, 0), // hSync + LEAP(3100, 3100), // leap + HSTART(108, 748), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(35, 509), // vStart + BURST(2, 2, 11, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(35, 509), // vStart - BURST(2, 2, 11, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(2560), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_MPAL_HAF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(640), // width - BURST(57, 30, 5, 70), // burst - VSYNC(524), // vSync - HSYNC(3088, 0), // hSync - LEAP(3100, 3100), // leap - HSTART(108, 748), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(2560), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_MPAL_HAF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(640), // width + BURST(57, 30, 5, 70), // burst + VSYNC(524), // vSync + HSYNC(3088, 0), // hSync + LEAP(3100, 3100), // leap + HSTART(108, 748), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + //[0] + ORIGIN(1280), // origin + SCALE(0.5, 0.5), // yScale + HSTART(35, 509), // vStart + BURST(2, 2, 11, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { //[0] - ORIGIN(1280), // origin - SCALE(0.5, 0.5), // yScale - HSTART(35, 509), // vStart - BURST(2, 2, 11, 0), // vBurst - VINTR(2), // vIntr - }, - { //[1] - ORIGIN(2560), // origin - SCALE(0.5, 0.5), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_MPAL_HPN2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_3 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(1280), // width - BURST(57, 30, 5, 70), // burst - VSYNC(524), // vSync - HSYNC(3088, 0), // hSync - LEAP(3100, 3100), // leap - HSTART(108, 748), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + { + //[1] + ORIGIN(2560), // origin + SCALE(0.5, 0.5), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_MPAL_HPN2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_3 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(1280), // width + BURST(57, 30, 5, 70), // burst + VSYNC(524), // vSync + HSYNC(3088, 0), // hSync + LEAP(3100, 3100), // leap + HSTART(108, 748), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(2560), // origin + SCALE(1, 0), // yScale + HSTART(35, 509), // vStart + BURST(2, 2, 11, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(2560), // origin - SCALE(1, 0), // yScale - HSTART(35, 509), // vStart - BURST(2, 2, 11, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(5120), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_MPAL_HPF2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(640), // width - BURST(57, 30, 5, 70), // burst - VSYNC(524), // vSync - HSYNC(3088, 0), // hSync - LEAP(3100, 3100), // leap - HSTART(108, 748), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(5120), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_MPAL_HPF2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(640), // width + BURST(57, 30, 5, 70), // burst + VSYNC(524), // vSync + HSYNC(3088, 0), // hSync + LEAP(3100, 3100), // leap + HSTART(108, 748), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(2560), // origin + SCALE(0.5, 0.5), // yScale + HSTART(35, 509), // vStart + BURST(2, 2, 11, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(2560), // origin - SCALE(0.5, 0.5), // yScale - HSTART(35, 509), // vStart - BURST(2, 2, 11, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(5120), // origin - SCALE(0.5, 0.5), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_FPAL_LPN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(625), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(5120), // origin + SCALE(0.5, 0.5), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_FPAL_LPN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(625), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(47, 617), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(47, 617), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(47, 617), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_FPAL_LPF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(47, 617), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_FPAL_LPF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0.25), // yScale + HSTART(45, 615), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0.25), // yScale - HSTART(45, 615), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0.75), // yScale - HSTART(47, 617), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_FPAL_LAN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_1 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(625), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0.75), // yScale + HSTART(47, 617), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_FPAL_LAN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_1 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(625), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(47, 617), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(47, 617), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(47, 617), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_FPAL_LAF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(47, 617), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_FPAL_LAF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0.25), // yScale + HSTART(45, 615), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0.25), // yScale - HSTART(45, 615), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0.75), // yScale - HSTART(47, 617), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_FPAL_LPN2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_ANTIALIAS_MODE_3 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(625), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0.75), // yScale + HSTART(47, 617), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_FPAL_LPN2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_ANTIALIAS_MODE_3 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(625), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(47, 617), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(47, 617), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(47, 617), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_FPAL_LPF2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(47, 617), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_FPAL_LPF2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0.25), // yScale + HSTART(45, 615), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0.25), // yScale - HSTART(45, 615), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0.75), // yScale - HSTART(47, 617), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_FPAL_LAN2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(625), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0.75), // yScale + HSTART(47, 617), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_FPAL_LAN2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(625), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(47, 617), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(47, 617), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(47, 617), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_FPAL_LAF2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(47, 617), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_FPAL_LAF2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0.25), // yScale + HSTART(45, 615), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0.25), // yScale - HSTART(45, 615), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0.75), // yScale - HSTART(47, 617), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_FPAL_HPN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(1280), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0.75), // yScale + HSTART(47, 617), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_FPAL_HPN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(1280), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(45, 615), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(45, 615), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(2560), // origin - SCALE(1, 0), // yScale - HSTART(47, 617), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_FPAL_HPF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(640), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(2560), // origin + SCALE(1, 0), // yScale + HSTART(47, 617), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_FPAL_HPF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(640), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(0.5, 0.5), // yScale + HSTART(45, 615), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(0.5, 0.5), // yScale - HSTART(45, 615), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(2560), // origin - SCALE(0.5, 0.5), // yScale - HSTART(47, 617), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_FPAL_HAN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(1280), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(2560), // origin + SCALE(0.5, 0.5), // yScale + HSTART(47, 617), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_FPAL_HAN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(1280), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(45, 615), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(45, 615), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(2560), // origin - SCALE(1, 0), // yScale - HSTART(47, 617), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_FPAL_HAF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(640), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(2560), // origin + SCALE(1, 0), // yScale + HSTART(47, 617), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_FPAL_HAF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(640), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(1280), // origin + SCALE(0.5, 0.5), // yScale + HSTART(45, 615), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(0.5, 0.5), // yScale - HSTART(45, 615), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(2560), // origin - SCALE(0.5, 0.5), // yScale - HSTART(47, 617), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_FPAL_HPN2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_3 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(1280), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(2560), // origin + SCALE(0.5, 0.5), // yScale + HSTART(47, 617), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_FPAL_HPN2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_3 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(1280), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(2560), // origin + SCALE(1, 0), // yScale + HSTART(45, 615), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(2560), // origin - SCALE(1, 0), // yScale - HSTART(45, 615), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(5120), // origin - SCALE(1, 0), // yScale - HSTART(47, 617), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } - }, - { - OS_VI_FPAL_HPF2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(640), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + { + // [1] + ORIGIN(5120), // origin + SCALE(1, 0), // yScale + HSTART(47, 617), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } } }, + { OS_VI_FPAL_HPF2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(640), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent + }, + { // fldRegs + { + // [0] + ORIGIN(2560), // origin + SCALE(0.5, 0.5), // yScale + HSTART(45, 615), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr }, - { // fldRegs - { // [0] - ORIGIN(2560), // origin - SCALE(0.5, 0.5), // yScale - HSTART(45, 615), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(5120), // origin - SCALE(0.5, 0.5), // yScale - HSTART(47, 617), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } - } + { + // [1] + ORIGIN(5120), // origin + SCALE(0.5, 0.5), // yScale + HSTART(47, 617), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } } } }; diff --git a/lib/ultralib/src/libc/bcmp.s b/lib/ultralib/src/libc/bcmp.s index f6fcc8b..11db46d 100644 --- a/lib/ultralib/src/libc/bcmp.s +++ b/lib/ultralib/src/libc/bcmp.s @@ -3,8 +3,12 @@ #include "sys/regdef.h" .text -WEAK(_bcmp, bcmp) -LEAF(bcmp) +#ifdef __sgi +WEAK(bcmp, _bcmp) +#else +#define _bcmp bcmp +#endif +LEAF(_bcmp) xor v0, a0, a1 blt a2, 16, bytecmp @@ -88,5 +92,5 @@ cmpdone: cmpne: li v0, 1 jr ra - -END(bcmp) + +.end _bcmp diff --git a/lib/ultralib/src/libc/bcopy.s b/lib/ultralib/src/libc/bcopy.s index 9bf1583..216c378 100644 --- a/lib/ultralib/src/libc/bcopy.s +++ b/lib/ultralib/src/libc/bcopy.s @@ -3,8 +3,12 @@ #include "sys/regdef.h" .text -WEAK(_bcopy, bcopy) -LEAF(bcopy) +#ifdef __sgi +WEAK(bcopy, _bcopy) +#else +#define _bcopy bcopy +#endif +LEAF(_bcopy) move a3, a1 beqz a2, ret beq a0, a1, ret @@ -212,7 +216,5 @@ backwards_4: addiu a1, a1, -4 addiu a2, a2, -4 b backwards_4 - -END(bcopy) -/* -*/ + +.end _bcopy diff --git a/lib/ultralib/src/libc/bzero.s b/lib/ultralib/src/libc/bzero.s index 13dcfa2..894c186 100644 --- a/lib/ultralib/src/libc/bzero.s +++ b/lib/ultralib/src/libc/bzero.s @@ -3,10 +3,15 @@ #include "sys/regdef.h" .text -WEAK(_bzero, bzero) -WEAK(_blkclr, blkclr) -LEAF(bzero) -XLEAF(blkclr) +#ifdef __sgi +WEAK(bzero, _bzero) +WEAK(blkclr, _blkclr) +#else +#define _bzero bzero +#define _blkclr blkclr +#endif +LEAF(_bzero) +XLEAF(_blkclr) negu v1, a0 blt a1, 12, bytezero @@ -55,4 +60,5 @@ bytezero: bne a0, a1, 1b zerodone: jr ra -END(bzero) + +.end _bzero diff --git a/lib/ultralib/src/libc/ldiv.c b/lib/ultralib/src/libc/ldiv.c index 59644e9..b0d98c4 100755..100644 --- a/lib/ultralib/src/libc/ldiv.c +++ b/lib/ultralib/src/libc/ldiv.c @@ -11,7 +11,7 @@ ldiv_t ldiv(long num, long denom) { ret.rem = num - denom * ret.quot; if (ret.quot < 0 && ret.rem > 0) { - ret.quot++; + ret.quot += 1; ret.rem -= denom; } @@ -25,7 +25,7 @@ lldiv_t lldiv(long long num, long long denom) { ret.rem = num - denom * ret.quot; if (ret.quot < 0 && ret.rem > 0) { - ret.quot++; + ret.quot += 1; ret.rem -= denom; } diff --git a/lib/ultralib/src/libc/ll.c b/lib/ultralib/src/libc/ll.c index 71582bf..4334b03 100755..100644 --- a/lib/ultralib/src/libc/ll.c +++ b/lib/ultralib/src/libc/ll.c @@ -1,3 +1,5 @@ +#include "PR/os.h" + unsigned long long __ull_rshift(unsigned long long a0, unsigned long long a1) { return a0 >> a1; } @@ -6,7 +8,7 @@ unsigned long long __ull_rem(unsigned long long a0, unsigned long long a1) { return a0 % a1; } -unsigned long long __ull_div(unsigned long long a0, unsigned long long a1) { +unsigned long long __ull_div(unsigned long long a0, unsigned long long a1) { return a0 / a1; } @@ -26,21 +28,21 @@ unsigned long long __ll_mul(unsigned long long a0, unsigned long long a1) { return a0 * a1; } -void __ull_divremi(unsigned long long *div, unsigned long long *rem, unsigned long long a2, unsigned short a3) { +void __ull_divremi(unsigned long long* div, unsigned long long* rem, unsigned long long a2, unsigned short a3) { *div = a2 / a3; - *rem = a2 % a3; + *rem = a2 % a3; } long long __ll_mod(long long a0, long long a1) { long long tmp = a0 % a1; if ((tmp < 0 && a1 > 0) || (tmp > 0 && a1 < 0)) { - tmp += a1; + tmp += a1; } return tmp; } - + long long __ll_rshift(long long a0, long long a1) { return a0 >> a1; } diff --git a/lib/ultralib/src/libc/llbit.c b/lib/ultralib/src/libc/llbit.c index 73d6056..0680726 100755..100644 --- a/lib/ultralib/src/libc/llbit.c +++ b/lib/ultralib/src/libc/llbit.c @@ -1,28 +1,30 @@ +#include "PR/os.h" #include "PR/ultratypes.h" -s64 __ll_bit_extract(u64 *addr, unsigned int start_bit, unsigned int length) { +s64 __ll_bit_extract(u64* addr, unsigned int start_bit, unsigned int length) { unsigned int words; unsigned int lbits; unsigned int rbits; u64 mask; - words = start_bit >> 6; - lbits = start_bit & ((1 << 6) - 1); + words = start_bit / 64; + lbits = start_bit & (64 - 1); rbits = 64 - (lbits + length); + addr += words; mask = ((u64)1 << length) - 1; mask = mask << rbits; return (s64)((*addr & mask) >> rbits); } -u64 __ull_bit_extract(u64 *addr, unsigned int start_bit, unsigned int length) { +u64 __ull_bit_extract(u64* addr, unsigned int start_bit, unsigned int length) { unsigned int words; unsigned int lbits; unsigned int rbits; u64 mask; - words = start_bit >> 6; - lbits = start_bit & ((1 << 6) - 1); + words = start_bit / 64; + lbits = start_bit & (64 - 1); rbits = 64 - (lbits + length); addr += words; mask = ((u64)1 << length) - 1; @@ -30,14 +32,14 @@ u64 __ull_bit_extract(u64 *addr, unsigned int start_bit, unsigned int length) { return (u64)((*addr & mask) >> rbits); } -u64 __ll_bit_insert(u64 *addr, unsigned int start_bit, unsigned int length, u64 val) { +u64 __ll_bit_insert(u64* addr, unsigned int start_bit, unsigned int length, u64 val) { unsigned int words; unsigned int lbits; unsigned int rbits; unsigned long long llval; unsigned long long mask; - - words = start_bit >> 6; + + words = start_bit / 64; lbits = start_bit & 0x3f; rbits = 64 - (lbits + length); addr += words; diff --git a/lib/ultralib/src/libc/llcvt.c b/lib/ultralib/src/libc/llcvt.c index 2c423dd..74d244b 100755..100644 --- a/lib/ultralib/src/libc/llcvt.c +++ b/lib/ultralib/src/libc/llcvt.c @@ -1,31 +1,31 @@ long long __d_to_ll(double d) { - return d; + return d; } long long __f_to_ll(float f) { - return f; + return f; } unsigned long long __d_to_ull(double d) { - return d; + return d; } unsigned long long __f_to_ull(float f) { - return f; + return f; } double __ll_to_d(long long s) { - return s; + return s; } float __ll_to_f(long long s) { - return s; + return s; } double __ull_to_d(unsigned long long u) { - return u; + return u; } float __ull_to_f(unsigned long long u) { - return u; + return u; } diff --git a/lib/ultralib/src/libc/sprintf.c b/lib/ultralib/src/libc/sprintf.c index 8d619f5..fd95523 100755..100644 --- a/lib/ultralib/src/libc/sprintf.c +++ b/lib/ultralib/src/libc/sprintf.c @@ -1,24 +1,22 @@ #include "xstdio.h" #include "string.h" +#include "os.h" // TODO: this comes from a header #ident "$Revision: 1.23 $" -static char *proutSprintf(char *dst, const char *src, size_t count); +static char* proutSprintf(char* dst, const char* src, size_t count); -int sprintf(char *dst, const char *fmt, ...) -{ +int sprintf(char* dst, const char* fmt, ...) { s32 ans; va_list ap; va_start(ap, fmt); ans = _Printf(proutSprintf, dst, fmt, ap); - if (ans >= 0) - { + if (ans >= 0) { dst[ans] = 0; } - return ans; + return ans; } -static char *proutSprintf(char *dst, const char *src, size_t count) -{ - return (char *)memcpy((u8 *)dst, (u8 *)src, count) + count; +static char* proutSprintf(char* dst, const char* src, size_t count) { + return (char*)memcpy((u8*)dst, (u8*)src, count) + count; } diff --git a/lib/ultralib/src/libc/string.c b/lib/ultralib/src/libc/string.c index c9a2b97..0f01d1f 100755..100644 --- a/lib/ultralib/src/libc/string.c +++ b/lib/ultralib/src/libc/string.c @@ -4,31 +4,33 @@ // TODO: this comes from a header #ident "$Revision: 1.23 $" -char *strchr(const char *s, int c) { +char* strchr(const char* s, int c) { const char ch = c; - while (*s != ch) - { - if (*s == 0) + while (*s != ch) { + if (*s == 0) { return NULL; + } s++; } - return (char *)s; + return (char*)s; } -size_t strlen(const char *s) { - const char *sc = s; - while (*sc) +size_t strlen(const char* s) { + const char* sc = s; + while (*sc != 0) { sc++; + } return sc - s; } -void *memcpy(void *s1, const void *s2, size_t n) { - char *su1 = (char *)s1; - const char *su2 = (const char *)s2; - while (n > 0) - { - *su1++ = *su2++; +void* memcpy(void* s1, const void* s2, size_t n) { + char* su1 = (char*)s1; + const char* su2 = (const char*)s2; + while (n > 0) { + *su1 = *su2; + su1++; + su2++; n--; } - return (void *)s1; + return (void*)s1; } diff --git a/lib/ultralib/src/libc/syncprintf.c b/lib/ultralib/src/libc/syncprintf.c index f2e758c..867bd99 100755..100644 --- a/lib/ultralib/src/libc/syncprintf.c +++ b/lib/ultralib/src/libc/syncprintf.c @@ -1,17 +1,40 @@ #include "stdarg.h" #include "PR/os.h" +#include "PR/rdb.h" +#include "xstdio.h" -void __osSyncVPrintf(const char *fmt, va_list args) { - // these functions intentionally left blank. ifdeffed out in rom release +extern void* __printfunc; + +void __osSyncVPrintf(const char* fmt, va_list args) { + + int ans; +#ifndef _FINALROM + if (__printfunc != NULL) { + ans = _Printf(__printfunc, NULL, fmt, args); + } +#endif } -void osSyncPrintf(const char *fmt, ...) { +void osSyncPrintf(const char* fmt, ...) { int ans; va_list ap; - // these functions intentionally left blank. ifdeffed out in rom release + +#ifndef _FINALROM + va_start(ap, fmt); + __osSyncVPrintf(fmt, ap); + va_end(ap); +#endif } -void rmonPrintf(const char *fmt, ...) { +void rmonPrintf(const char* fmt, ...) { int ans; va_list ap; + +#ifndef _FINALROM + va_start(ap, fmt); + if (__printfunc != NULL) { + ans = _Printf(__printfunc, NULL, fmt, ap); + } + va_end(ap); +#endif } diff --git a/lib/ultralib/src/libc/xldtob.c b/lib/ultralib/src/libc/xldtob.c index b032e57..2929955 100644 --- a/lib/ultralib/src/libc/xldtob.c +++ b/lib/ultralib/src/libc/xldtob.c @@ -69,34 +69,36 @@ void _Ldtob(_Pft* px, char code) { nsig = 0; xexp = 0; } else { - int i; - int n; + { + int i; + int n; - if (ldval < 0) { - ldval = -ldval; - } + if (ldval < 0) { + ldval = -ldval; + } - // what - if ((xexp = xexp * 30103 / 100000 - 4) < 0) { - n = ALIGN(-xexp, 4), xexp = -n; + // what + if ((xexp = xexp * 30103 / 100000 - 4) < 0) { + n = ALIGN(-xexp, 4), xexp = -n; - for (i = 0; n > 0; n >>= 1, i++) { - if (n & 1) { - ldval *= pows[i]; + for (i = 0; n > 0; n >>= 1, i++) { + if (n & 1) { + ldval *= pows[i]; + } } - } - } else if (xexp > 0) { - f64 factor = 1; - - xexp &= ~3; - - for (n = xexp, i = 0; n > 0; n >>= 1, i++) { - if (n & 1) { - factor *= pows[i]; + } else if (xexp > 0) { + f64 factor = 1; + + xexp &= ~3; + + for (n = xexp, i = 0; n > 0; n >>= 1, i++) { + if (n & 1) { + factor *= pows[i]; + } } - } - ldval /= factor; + ldval /= factor; + } } { int gen = px->prec + ((code == 'f') ? 10 + xexp : 6); @@ -107,7 +109,7 @@ void _Ldtob(_Pft* px, char code) { for (*p++ = '0'; gen > 0 && 0 < ldval; p += 8) { int j; - int lo = ldval; + long lo = ldval; if ((gen -= 8) > 0) { ldval = (ldval - lo) * 1e8; @@ -136,7 +138,7 @@ void _Ldtob(_Pft* px, char code) { } if (nsig > 0) { - char drop = nsig < gen && '5' <= p[nsig] ? '9' : '0'; + const char drop = nsig < gen && '5' <= p[nsig] ? '9' : '0'; int n; for (n = nsig; p[--n] == drop;) { @@ -182,18 +184,17 @@ void _Genld(_Pft* px, char code, u8* p, s16 nsig, s16 xexp) { const unsigned char point = '.'; if (nsig <= 0) { - nsig = 1, p = "0"; // memes + nsig = 1, p = "0"; } if (code == 'f' || (code == 'g' || code == 'G') && xexp >= -4 && xexp < px->prec) { - xexp += 1; + xexp++; if (code != 'f') { if (((px->flags & 8) == 0) && nsig < px->prec) { px->prec = nsig; } - px->prec -= xexp; - if (px->prec < 0) { + if ((px->prec -= xexp) < 0) { px->prec = 0; } } @@ -216,7 +217,7 @@ void _Genld(_Pft* px, char code, u8* p, s16 nsig, s16 xexp) { nsig = px->prec; } - memcpy(&px->s[px->n1], p, px->n2 = nsig); // , memes (this one is insane) + memcpy(&px->s[px->n1], p, px->n2 = nsig); px->nz2 = px->prec - nsig; } else if (nsig < xexp) { memcpy(&px->s[px->n1], p, nsig); @@ -224,7 +225,7 @@ void _Genld(_Pft* px, char code, u8* p, s16 nsig, s16 xexp) { px->nz1 = xexp - nsig; if (px->prec > 0 || (px->flags & 8)) { px->s[px->n1] = point; - px->n2 += 1; + px->n2++; } px->nz2 = px->prec; @@ -255,11 +256,7 @@ void _Genld(_Pft* px, char code, u8* p, s16 nsig, s16 xexp) { px->prec = 0; } - if (code == 'g') { - code = 'e'; - } else { - code = 'E'; - } + code = (code == 'g') ? 'e' : 'E'; } px->s[px->n1++] = *p++; @@ -290,11 +287,11 @@ void _Genld(_Pft* px, char code, u8* p, s16 nsig, s16 xexp) { if (xexp >= 100) { if (xexp >= 1000) { - *p++ = (xexp / 1000) + '0', xexp %= 1000; // , memes + *p++ = (xexp / 1000) + '0', xexp %= 1000; } - *p++ = (xexp / 100) + '0', xexp %= 100; // , memes + *p++ = (xexp / 100) + '0', xexp %= 100; } - *p++ = (xexp / 10) + '0', xexp %= 10; // , memes + *p++ = (xexp / 10) + '0', xexp %= 10; *p++ = xexp + '0'; px->n2 = (size_t)p - ((size_t)px->s + px->n1); diff --git a/lib/ultralib/src/libc/xlitob.c b/lib/ultralib/src/libc/xlitob.c index f297df4..2b27b3a 100755..100644 --- a/lib/ultralib/src/libc/xlitob.c +++ b/lib/ultralib/src/libc/xlitob.c @@ -19,11 +19,7 @@ void _Litob(_Pft *args, char type) { s32 i; unsigned long long ullval; - if (type == 'X') { - digs = udigs; - } else { - digs = ldigs; - } + digs = (type == 'X') ? udigs : ldigs; base = (type == 'o') ? 8 : ((type != 'x' && type != 'X') ? 10 : 16); i = BUFF_LEN; @@ -55,9 +51,7 @@ void _Litob(_Pft *args, char type) { } if (args->prec < 0 && (args->flags & (FLAGS_ZERO | FLAGS_MINUS)) == FLAGS_ZERO) { - i = args->width - args->n0 - args->nz0 - args->n1; - - if (i > 0) { + if ((i = args->width - args->n0 - args->nz0 - args->n1) > 0) { args->nz0 += i; } } diff --git a/lib/ultralib/src/libc/xprintf.c b/lib/ultralib/src/libc/xprintf.c index d9f1003..788f42c 100755..100644 --- a/lib/ultralib/src/libc/xprintf.c +++ b/lib/ultralib/src/libc/xprintf.c @@ -44,16 +44,16 @@ static void _Putfld(_Pft *pf, va_list *pap, char code, char *ac); int _Printf(outfun prout, char *arg, const char *fmt, va_list args) { _Pft x; - const char *s; - char c; - const char *t; - static const char fchar[] = {' ', '+', '-', '#', '0', '\0'}; - static const int fbit[] = {FLAGS_SPACE, FLAGS_PLUS, FLAGS_MINUS, FLAGS_HASH, FLAGS_ZERO, 0}; - char ac[32]; x.nchar = 0; - for (;;) { + while (TRUE) { + const char *s; + char c; + const char *t; + static const char fchar[] = {' ', '+', '-', '#', '0', '\0'}; + static const int fbit[] = {FLAGS_SPACE, FLAGS_PLUS, FLAGS_MINUS, FLAGS_HASH, FLAGS_ZERO, 0}; + char ac[32]; s = fmt; for (c = *s; c != 0 && c != '%';) { @@ -80,18 +80,21 @@ int _Printf(outfun prout, char *arg, const char *fmt, va_list args) { x.flags |= FLAGS_MINUS; } s++; - } else { + } else ATOI(x.width, s); - } + if (*s != '.') { x.prec = -1; } else if (*++s == '*') { x.prec = va_arg(args, int); ++s; - } else { - ATOI(x.prec, s); - } + } else + for (x.prec = 0; isdigit(*s); s++) { + if (x.prec < 999) + x.prec = x.prec * 10 + *s - '0'; + } + x.qual = strchr("hlL", *s) ? *s++ : '\0'; @@ -102,22 +105,35 @@ int _Printf(outfun prout, char *arg, const char *fmt, va_list args) { _Putfld(&x, &args, *s, ac); x.width -= x.n0 + x.nz0 + x.n1 + x.nz1 + x.n2 + x.nz2; - - if (!(x.flags & FLAGS_MINUS)) { - PAD(spaces, x.width); - } - - PUT(ac, x.n0); - PAD(zeroes, x.nz0); - PUT(x.s, x.n1); - PAD(zeroes, x.nz1); - PUT(x.s + x.n1, x.n2); - PAD(zeroes, x.nz2); - - if (x.flags & FLAGS_MINUS) { - PAD(spaces, x.width); + + { + + if (!(x.flags & FLAGS_MINUS)) { + int i, j; + if (0 < (x.width)) + { + i, j = x.width; + for (; 0 < j; j -= i) + { + i = MAX_PAD < (unsigned int)j ? (int)MAX_PAD : j; + PUT(spaces, i); + } + } + } + + PUT(ac, x.n0); + PAD(zeroes, x.nz0) + + PUT(x.s, x.n1); + PAD(zeroes, x.nz1); + + PUT(x.s + x.n1, x.n2); + PAD(zeroes, x.nz2); + + if (x.flags & FLAGS_MINUS) { + PAD(spaces, x.width); + } } - fmt = s + 1; } return 0; @@ -226,7 +242,7 @@ static void _Putfld(_Pft *x, va_list *args, char type, char *buff) { x->s = va_arg(*args, char *); x->n1 = strlen(x->s); - if (x->prec >= 0 && x->n1 > x->prec) { + if (x->prec >= 0 && x->prec < x->n1) { x->n1 = x->prec; } diff --git a/lib/ultralib/src/libc/xstdio.h b/lib/ultralib/src/libc/xstdio.h index bd70de8..bd70de8 100755..100644 --- a/lib/ultralib/src/libc/xstdio.h +++ b/lib/ultralib/src/libc/xstdio.h diff --git a/lib/ultralib/src/log/delay.s b/lib/ultralib/src/log/delay.s new file mode 100644 index 0000000..bbfc7dd --- /dev/null +++ b/lib/ultralib/src/log/delay.s @@ -0,0 +1,22 @@ +#ifndef _FINALROM +#include "sys/asm.h" +#include "sys/regdef.h" + +LEAF(osDelay) + sll t0,a0,2 + addu t0,a0 + sll t0,t0,2 + beqz a0,2f + +1: + subu t0,1 + NOP + NOP + bnez t0,1b + +2: + j ra + +END(osDelay) + +#endif diff --git a/lib/ultralib/src/log/log.c b/lib/ultralib/src/log/log.c new file mode 100644 index 0000000..85129d2 --- /dev/null +++ b/lib/ultralib/src/log/log.c @@ -0,0 +1,124 @@ +#include "stdarg.h" +#include "PR/rdb.h" +#include "PR/os.h" +#include "PR/os_internal.h" +#include "PR/ultraerror.h" +#include "PR/ultralog.h" +#include "macros.h" + +#ifndef _FINALROM + +static u32 __osLogOKtoWrite = TRUE; +static u32 __osLogInitialized = FALSE; + +static OSMesgQueue __osLogDoneMsgQ ALIGNED(8); +static OSMesg __osLogMsgBuf; + +void __osLogWrite(OSLog* log, s16 code, s16 numArgs, va_list argPtr); + +void osCreateLog(OSLog* log, u32* base, s32 byteLen) { + log->magic = OS_LOG_MAGIC; + log->base = base; + log->len = byteLen; + log->startCount = osGetCount(); + log->writeOffset = 0; +} + +void osLogEvent(OSLog* log, s16 code, s16 numArgs, ...) { + va_list argPtr; + + if (numArgs > 16) { + return; + } + + va_start(argPtr, numArgs); + __osLogWrite(log, code, numArgs, argPtr); + va_end(argPtr); +} + +void osFlushLog(OSLog* log) { + s32 mask; + u32 sent; + u32 count; + u32 subcount; + u8* base; + u8 dCount[3]; + + if (!__osLogInitialized) { + osCreateMesgQueue(&__osLogDoneMsgQ, &__osLogMsgBuf, 1); + osSetEventMesg(OS_EVENT_RDB_LOG_DONE, &__osLogDoneMsgQ, 0); + __osLogInitialized = 1; + } + + mask = __osDisableInt(); + __osLogOKtoWrite = 0; + base = log->base; + count = log->writeOffset * 4; + __osRestoreInt(mask); + + while (count != 0) { + subcount = (count < 0x8000) ? count : 0x8000; + dCount[0] = (subcount & 0xFF0000) >> 0x10; + dCount[1] = (subcount & 0xFF00) >> 8; + dCount[2] = subcount & 0xFF; + + sent = 0; + while (sent < 3) { + sent += __osRdbSend(dCount + sent, 3 - sent, RDB_TYPE_GtoH_LOG_CT); + } + + sent = 0; + while (sent < subcount) { + sent += __osRdbSend(base + sent, subcount - sent, RDB_TYPE_GtoH_LOG); + } + + count -= subcount; + base += subcount; + osRecvMesg(&__osLogDoneMsgQ, NULL, OS_MESG_BLOCK); + } + mask = __osDisableInt(); + log->writeOffset = 0; + __osLogOKtoWrite = 1; + __osRestoreInt(mask); +} + +void __osLogWrite(OSLog* log, s16 code, s16 numArgs, va_list argPtr) { + int i; + u32 saveEnable; + u32 buf[19]; + u32* bufp; + OSLogItem* hdr; + s32* args; + s32* dest; + int numLongs; + + bufp = buf; + hdr = buf; + args = buf + 3; + numLongs = numArgs + 3; + saveEnable = __osDisableInt(); + + hdr->magic = log->magic; + hdr->timeStamp = osGetCount() - log->startCount; + hdr->argCount = numArgs; + hdr->eventID = code; + + for (i = 0; i < numArgs; i++) { + *args++ = va_arg(argPtr, int); + } + + if (__osLogOKtoWrite) { + if ((log->writeOffset + numLongs) < (log->len >> 2)) { + dest = log->base + log->writeOffset; + for (i = 0; i < numLongs; i++) { + *dest++ = *bufp++; + } + log->writeOffset += numLongs; + } else { + __osLogOKtoWrite = FALSE; + } + } + __osRestoreInt(saveEnable); +} + +#endif diff --git a/lib/ultralib/src/log/logfloat.c b/lib/ultralib/src/log/logfloat.c new file mode 100644 index 0000000..01acab6 --- /dev/null +++ b/lib/ultralib/src/log/logfloat.c @@ -0,0 +1,9 @@ +#ifndef _FINALROM + +#include "ultralog.h" + +u32 osLogFloat(f32 f) { + return OS_LOG_FLOAT(f); +} + +#endif diff --git a/lib/ultralib/src/monutil.s b/lib/ultralib/src/monutil.s new file mode 100644 index 0000000..e5974bd --- /dev/null +++ b/lib/ultralib/src/monutil.s @@ -0,0 +1,188 @@ +#ifndef _FINALROM +#include "asm.h" +#include "sgidefs.h" +#include "regdef.h" +#include "sgidefs.h" +#include "PR/R4300.h" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +#define EXC(code) (EXC_##code >> CAUSE_EXCSHIFT) + +.text + +LEAF(__isExpJP); .set noreorder + j __isExp + nop + sw k0, -0x10(sp) + la k0, __isExp + jr k0 + nop +.set reorder +END(__isExpJP) + +LEAF(__isExp); .set noreorder + sw k0, -0x10(sp) + sw k1, -8(sp) + + mfc0 k0, C0_CAUSE + nop + andi k0, k0, CAUSE_EXCMASK + bnez k0, non_stop + + nop + mfc0 k0, C0_CAUSE + nop + andi k0, k0, CAUSE_IP7 + beqz k0, throw_os_exception + nop + j go_monitor + nop +non_stop: + sra k0, k0, CAUSE_EXCSHIFT + li k1, EXC(BREAK) + bne k0, k1, non_bp + nop + j go_monitor + nop + +non_bp: + li k1, EXC(RADE) + bne k0, k1, non_adrs_store_exp + nop + j go_monitor + nop +non_adrs_store_exp: + li k1, EXC(WADE) + bne k0, k1, non_adrs_load_exp + nop + j go_monitor + nop +non_adrs_load_exp: + li k1, EXC(IBE) + bne k0, k1, non_bus_code_exp + nop + j go_monitor + nop +non_bus_code_exp: + li k1, EXC(DBE) + bne k0, k1, non_bus_data_exp + nop + j go_monitor + nop +non_bus_data_exp: + li k1, EXC(MOD) + bne k0, k1, non_tlb_mod + nop + j go_monitor + nop +non_tlb_mod: + li k1, EXC(RMISS) + bne k0, k1, non_tlb_load + nop + j go_monitor + nop +non_tlb_load: + li k1, EXC(WMISS) + bne k0, k1, non_tlb_store + nop + j go_monitor + nop +non_tlb_store: + li k1, EXC(II) + bne k0, k1, non_resv + nop + j go_monitor + nop + +non_resv: + lw k1, -8(sp) + +throw_os_exception: + j ramOldVector + nop + + + + + + + + + +go_monitor: + move k0, sp + addiu sp, sp, -0x200 + sw k0, 0x78(sp) + lw k1, -8(k0) + sw k1, 0x70(sp) + lw k1, -0x10(k0) + sw k1, 0x6c(sp) + nop +w: + lui k0, (0xA4600010 >> 16) + lw k0, (0xA4600010 & 0xFFFF)(k0) /* PI_STATUS_REG */ + nop + andi k0, k0, 3 /* (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY) */ + bnez k0, w + nop + la k0, 0xBFF00050 + jr k0 + nop +.set reorder +END(__isExp) + + +LEAF(MonitorInitBreak); .set noreorder + nop + nop +INIT_BREAK_POSITION: + break 4 + nop + nop + nop + jr ra + nop +.set reorder +END(MonitorInitBreak) + +#endif diff --git a/lib/ultralib/src/os/ackramromread.c b/lib/ultralib/src/os/ackramromread.c index 4aea863..aa671bf 100644 --- a/lib/ultralib/src/os/ackramromread.c +++ b/lib/ultralib/src/os/ackramromread.c @@ -4,5 +4,4 @@ #ident "$Revision: 1.4 $" void osAckRamromRead() { - } diff --git a/lib/ultralib/src/os/ackramromwrite.c b/lib/ultralib/src/os/ackramromwrite.c index 34fe2ad..8a29f60 100644 --- a/lib/ultralib/src/os/ackramromwrite.c +++ b/lib/ultralib/src/os/ackramromwrite.c @@ -4,5 +4,4 @@ #ident "$Revision: 1.4 $" void osAckRamromWrite() { - } diff --git a/lib/ultralib/src/os/assert.c b/lib/ultralib/src/os/assert.c deleted file mode 100644 index d076a24..0000000 --- a/lib/ultralib/src/os/assert.c +++ /dev/null @@ -1,5 +0,0 @@ -#include "PR/os_internal.h" - -void __assert(const char *exp, const char *filename, int line) { - osSyncPrintf("\nASSERTION FAULT: %s, %d: \"%s\"\n", filename, line, exp); -} diff --git a/lib/ultralib/src/os/atomic.c b/lib/ultralib/src/os/atomic.c index f96bb63..a0bd8fe 100644 --- a/lib/ultralib/src/os/atomic.c +++ b/lib/ultralib/src/os/atomic.c @@ -1,15 +1,16 @@ #include "PR/os_internal.h" -int __osAtomicDec(unsigned int *p) { - register u32 saveMask = __osDisableInt(); - int mask; +int __osAtomicDec(unsigned int* p) { + u32 mask; + int result; + mask = __osDisableInt(); if (*p) { (*p)--; - mask = 1; + result = 1; } else { - mask = 0; + result = 0; } - __osRestoreInt(saveMask); - return mask; + __osRestoreInt(mask); + return result; } diff --git a/lib/ultralib/src/os/createmesgqueue.c b/lib/ultralib/src/os/createmesgqueue.c index 4e71cba..5c92f04 100644 --- a/lib/ultralib/src/os/createmesgqueue.c +++ b/lib/ultralib/src/os/createmesgqueue.c @@ -1,9 +1,18 @@ #include "PR/os_internal.h" +#include "PR/ultraerror.h" #include "osint.h" -void osCreateMesgQueue(OSMesgQueue *mq, OSMesg *msg, s32 msgCount) { - mq->mtqueue = &__osThreadTail.next; - mq->fullqueue = &__osThreadTail.next; +void osCreateMesgQueue(OSMesgQueue* mq, OSMesg* msg, s32 msgCount) { + +#ifdef _DEBUG + if (msgCount <= 0) { + __osError(ERR_OSCREATEMESGQUEUE, 1, msgCount); + return; + } +#endif + + mq->mtqueue = (OSThread*)&__osThreadTail.next; + mq->fullqueue = (OSThread*)&__osThreadTail.next; mq->validCount = 0; mq->first = 0; mq->msgCount = msgCount; diff --git a/lib/ultralib/src/os/createthread.c b/lib/ultralib/src/os/createthread.c index 1ae9f0b..fdf0c20 100644 --- a/lib/ultralib/src/os/createthread.c +++ b/lib/ultralib/src/os/createthread.c @@ -1,10 +1,26 @@ #include "PR/os_internal.h" #include "PR/R4300.h" +#include "PR/ultraerror.h" #include "osint.h" -void osCreateThread(OSThread *t, OSId id, void (*entry)(void *), void *arg, void *sp, OSPri p) { +extern __OSThreadprofile_s thprof[]; + +void osCreateThread(OSThread* t, OSId id, void (*entry)(void*), void* arg, void* sp, OSPri p) { register u32 saveMask; OSIntMask mask; + +#ifdef _DEBUG + if ((u32)sp & 0x7) { + __osError(ERR_OSCREATETHREAD_SP, 1, sp); + return; + } + + if ((p < OS_PRIORITY_IDLE) || (p > OS_PRIORITY_MAX)) { + __osError(ERR_OSCREATETHREAD_PRI, 1, p); + return; + } +#endif + t->id = id; t->priority = p; t->next = NULL; @@ -14,12 +30,21 @@ void osCreateThread(OSThread *t, OSId id, void (*entry)(void *), void *arg, void t->context.sp = (s64)(s32)sp - 16; t->context.ra = (u64)__osCleanupThread; mask = OS_IM_ALL; - t->context.sr = SR_IMASK | SR_EXL | SR_IE; + t->context.sr = (mask & (SR_IMASK | SR_IE)) | SR_EXL; t->context.rcp = (mask & RCP_IMASK) >> RCP_IMASKSHIFT; t->context.fpcsr = (u32)(FPCSR_FS | FPCSR_EV); t->fp = 0; t->state = OS_STATE_STOPPED; t->flags = 0; + +#ifndef _FINALROM + if (id < THPROF_IDMAX) { + t->thprof = &thprof[id]; + } else { + t->thprof = &thprof[THPROF_IDMAX - 1]; + } +#endif + saveMask = __osDisableInt(); t->tlnext = __osActiveQueue; __osActiveQueue = t; diff --git a/lib/ultralib/src/os/destroythread.c b/lib/ultralib/src/os/destroythread.c index 43d2436..91ad92c 100644 --- a/lib/ultralib/src/os/destroythread.c +++ b/lib/ultralib/src/os/destroythread.c @@ -1,10 +1,10 @@ #include "PR/os_internal.h" #include "osint.h" -void osDestroyThread(OSThread *t) { +void osDestroyThread(OSThread* t) { register u32 saveMask; - register OSThread *pred; - register OSThread *succ; + register OSThread* pred; + register OSThread* succ; saveMask = __osDisableInt(); @@ -25,13 +25,12 @@ void osDestroyThread(OSThread *t) { break; } pred = succ; - succ = pred->tlnext; } } if (t == __osRunningThread) { __osDispatchThread(); } - + __osRestoreInt(saveMask); } diff --git a/lib/ultralib/src/os/exceptasm.h b/lib/ultralib/src/os/exceptasm.h index 48c1234..3e599ee 100644 --- a/lib/ultralib/src/os/exceptasm.h +++ b/lib/ultralib/src/os/exceptasm.h @@ -13,11 +13,11 @@ #define OS_EVENTSTATE_MESSAGE_QUEUE 0 #define OS_EVENTSTATE_MESSAGE 4 -// __osHwInt struct member offsets +/* __osHwInt struct member offsets */ #define HWINTR_CALLBACK 0x00 #define HWINTR_SP 0x04 -// __osHwInt struct size +/* __osHwInt struct size */ #define HWINTR_SIZE 0x8 #endif diff --git a/lib/ultralib/src/os/exceptasm.s b/lib/ultralib/src/os/exceptasm.s index 5a0bdcf..577aed5 100644 --- a/lib/ultralib/src/os/exceptasm.s +++ b/lib/ultralib/src/os/exceptasm.s @@ -64,7 +64,6 @@ __osIntTable: EXPORT(__osCauseTable_pt) .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 .byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 - .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 #endif .data @@ -109,7 +108,7 @@ LEAF(__ptExceptionPreamble) nop nop pt_next: - addiu k0, %lo(__ptException) + addiu k0, k0, %lo(__ptException) jr k0 nop .set reorder @@ -194,14 +193,14 @@ STAY2(mfc0 t0, C0_CAUSE) andi t2, t1, CAUSE_IP7 beqz t2, notIP7 /* clear rdb write interrupt */ - li t1, RDB_WRITE_INTR_REG + la t1, RDB_WRITE_INTR_REG sw zero, (t1) IP7check: STAY2(mfc0 t0, C0_CAUSE) andi t0, t0, CAUSE_IP7 bne zero, t0, IP7check - lui t2, (RDB_BASE_REG >> 16) - lw t0, (RDB_BASE_REG & 0xFFFF)(t2) + la t2, RDB_BASE_REG + lw t0, (t2) srl t1, t0, 0x1a andi t1, t1, 0x3f li t2, RDB_TYPE_HtoG_DATA @@ -331,14 +330,14 @@ notIP7: andi t2, t1, CAUSE_IP6 beqz t2, savecontext /* clear rdb read interrupt */ - li t1, RDB_READ_INTR_REG + la t1, RDB_READ_INTR_REG sw zero, (t1) lw t2, __osRdb_IP6_Ct - bnez t2, 1f + bnez t2, 2f li t2, 1 sw t2, __osRdb_IP6_Empty b rdbout -1: +2: addi t2, t2, -1 sw t2, __osRdb_IP6_Ct lw t0, __osRdb_IP6_Data @@ -357,8 +356,8 @@ checkIP6: STAY2(mfc0 t0, C0_CAUSE) andi t0, t0, CAUSE_IP6 bne zero, t0, checkIP6 - lui t0, (RDB_BASE_REG >> 16) - sw t2, (RDB_BASE_REG & 0xFFFF)(t0) + la t0, RDB_BASE_REG + sw t2, (t0) rdbout: ld t0, THREAD_GP8(k0) ld t1, THREAD_GP9(k0) @@ -368,11 +367,13 @@ rdbout: .set at lw k1, THREAD_SR(k0) STAY2(mtc0 k1, C0_SR) +.set noreorder nop nop nop nop eret +.set reorder skip_kmc_mode: #endif @@ -393,6 +394,7 @@ savecontext: sd t1, THREAD_GP9(k0) ld t1, THREAD_GP10(t0) sd t1, THREAD_GP10(k0) +3: sd $2, THREAD_GP2(k0) sd $3, THREAD_GP3(k0) sd $4, THREAD_GP4(k0) @@ -461,8 +463,8 @@ STAY2(mfc0 t0, C0_EPC) sw t0, THREAD_PC(k0) lw t0, THREAD_FP(k0) beqz t0, 1f - cfc1 t0, fcr31 - nop +STAY2(cfc1 t0, fcr31) + NOP sw t0, THREAD_FPCSR(k0) sdc1 $f0, THREAD_FP0(k0) sdc1 $f2, THREAD_FP2(k0) @@ -484,8 +486,10 @@ STAY2(mfc0 t0, C0_EPC) STAY2(mfc0 t0, C0_CAUSE) sw t0, THREAD_CAUSE(k0) +.set noreorder li t1, OS_STATE_RUNNABLE sh t1, THREAD_STATE(k0) +.set reorder #ifndef _FINALROM lw a0, __os_Kdebug_Pkt @@ -881,13 +885,13 @@ LEAF(__osEnqueueThread) lw t8, 0(a0) lw ta3, THREAD_PRI(a1) lw ta2, THREAD_PRI(t8) - blt ta2, ta3, 1f -2: + blt ta2, ta3, 2f +1: move t9, t8 lw t8, THREAD_NEXT(t8) lw ta2, THREAD_PRI(t8) - bge ta2, ta3, 2b -1: + bge ta2, ta3, 1b +2: lw t8, THREAD_NEXT(t9) sw t8, THREAD_NEXT(a1) sw a1, THREAD_NEXT(t9) @@ -918,6 +922,7 @@ LEAF(__osDispatchThread) la t0, __osThprofFunc lw t0, (t0) beqz t0, __osDispatchThreadSave +1: lw a0, __osPreviousThread lw sp, __osThprofStack jalr t0 @@ -993,6 +998,7 @@ STAY2(ctc1 k1, fcr31) ldc1 $f30, THREAD_FP30(k0) 1: +.set noreorder lw k1, THREAD_RCP(k0) la k0, __OSGlobalIntMask lw k0, 0(k0) @@ -1010,10 +1016,13 @@ STAY2(ctc1 k1, fcr31) nop nop eret +.set reorder END(__osDispatchThread) LEAF(__osCleanupThread) move a0, zero +#if !defined(BBPLAYER) && !defined(__sgi) nop +#endif jal osDestroyThread END(__osCleanupThread) diff --git a/lib/ultralib/src/os/exit.c b/lib/ultralib/src/os/exit.c index d5e60eb..24a873f 100644 --- a/lib/ultralib/src/os/exit.c +++ b/lib/ultralib/src/os/exit.c @@ -3,6 +3,7 @@ void osExit() { __osGIOInterrupt(16); - for (;;); + for (;;) { + ; + } } - diff --git a/lib/ultralib/src/os/getactivequeue.c b/lib/ultralib/src/os/getactivequeue.c index 4175e7d..1fefc88 100644 --- a/lib/ultralib/src/os/getactivequeue.c +++ b/lib/ultralib/src/os/getactivequeue.c @@ -1,6 +1,6 @@ #include "PR/os_internal.h" #include "osint.h" -OSThread *__osGetActiveQueue(void) { +OSThread* __osGetActiveQueue(void) { return __osActiveQueue; } diff --git a/lib/ultralib/src/os/getcurrfaultthread.c b/lib/ultralib/src/os/getcurrfaultthread.c index 7500928..d7668c2 100644 --- a/lib/ultralib/src/os/getcurrfaultthread.c +++ b/lib/ultralib/src/os/getcurrfaultthread.c @@ -1,6 +1,6 @@ #include "PR/os_internal.h" #include "osint.h" -OSThread *__osGetCurrFaultedThread() { +OSThread* __osGetCurrFaultedThread() { return __osFaultedThread; } diff --git a/lib/ultralib/src/os/getfpccsr.s b/lib/ultralib/src/os/getfpccsr.s index 05bb19d..56837a5 100644 --- a/lib/ultralib/src/os/getfpccsr.s +++ b/lib/ultralib/src/os/getfpccsr.s @@ -6,5 +6,4 @@ LEAF(__osGetFpcCsr) STAY2(cfc1 v0, fcr31) jr ra -END(__osGetFpcCsr) -.globl __osGetSR +END(__osGetSR) # @bug: Should be __osGetFpcCsr diff --git a/lib/ultralib/src/os/gethwinterrupt.c b/lib/ultralib/src/os/gethwinterrupt.c index 3a0e136..21b46e7 100644 --- a/lib/ultralib/src/os/gethwinterrupt.c +++ b/lib/ultralib/src/os/gethwinterrupt.c @@ -2,12 +2,12 @@ struct __osHwInt { s32 (*handler)(void); - void *stackEnd; + void* stackEnd; }; extern struct __osHwInt __osHwIntTable[]; -void __osGetHWIntrRoutine(OSHWIntr interrupt, s32 (**handler)(void), void **stackEnd) { +void __osGetHWIntrRoutine(OSHWIntr interrupt, s32 (**handler)(void), void** stackEnd) { *handler = __osHwIntTable[interrupt].handler; *stackEnd = __osHwIntTable[interrupt].stackEnd; } diff --git a/lib/ultralib/src/os/getintmask.s b/lib/ultralib/src/os/getintmask.s index deaccb6..573eed1 100644 --- a/lib/ultralib/src/os/getintmask.s +++ b/lib/ultralib/src/os/getintmask.s @@ -18,7 +18,7 @@ LEAF(osGetIntMask) lw t1, PHYS_TO_K1(MI_INTR_MASK_REG) beqz t1, 1f - la t0, __OSGlobalIntMask #this is intentionally a macro in the branch delay slot + la t0, __OSGlobalIntMask # this is intentionally a macro in the branch delay slot lw t0, 0(t0) srl t0, t0, 0x10 @@ -29,4 +29,5 @@ LEAF(osGetIntMask) sll t2, t1, 0x10 or v0, v0, t2 jr ra + nop END(osGetIntMask) diff --git a/lib/ultralib/src/os/getnextfaultthread.c b/lib/ultralib/src/os/getnextfaultthread.c index 9add6dd..44d723a 100644 --- a/lib/ultralib/src/os/getnextfaultthread.c +++ b/lib/ultralib/src/os/getnextfaultthread.c @@ -1,15 +1,11 @@ #include "PR/os_internal.h" #include "osint.h" -OSThread *__osGetNextFaultedThread(OSThread *lastFault) { +OSThread* __osGetNextFaultedThread(OSThread* lastFault) { register int saveMask = __osDisableInt(); - register OSThread *fault; + register OSThread* fault; - if (lastFault == NULL) { - fault = __osActiveQueue; - } else { - fault = lastFault; - } + fault = lastFault == NULL ? __osActiveQueue : lastFault; while (fault->priority != -1) { if ((fault->flags & OS_FLAG_FAULT) != 0 && fault != lastFault) { @@ -25,4 +21,3 @@ OSThread *__osGetNextFaultedThread(OSThread *lastFault) { __osRestoreInt(saveMask); return fault; } - diff --git a/lib/ultralib/src/os/getthreadid.c b/lib/ultralib/src/os/getthreadid.c index 9aac16d..8bbc9f6 100644 --- a/lib/ultralib/src/os/getthreadid.c +++ b/lib/ultralib/src/os/getthreadid.c @@ -1,7 +1,7 @@ #include "PR/os_internal.h" #include "osint.h" -OSId osGetThreadId(OSThread *thread) { +OSId osGetThreadId(OSThread* thread) { if (thread == NULL) { thread = __osRunningThread; } diff --git a/lib/ultralib/src/os/getthreadpri.c b/lib/ultralib/src/os/getthreadpri.c index a1e9ce2..149f3f7 100644 --- a/lib/ultralib/src/os/getthreadpri.c +++ b/lib/ultralib/src/os/getthreadpri.c @@ -1,10 +1,10 @@ #include "PR/os_internal.h" #include "osint.h" -OSPri osGetThreadPri(OSThread *thread) { +OSPri osGetThreadPri(OSThread* thread) { if (thread == NULL) { thread = __osRunningThread; } - + return thread->priority; } diff --git a/lib/ultralib/src/os/gettime.c b/lib/ultralib/src/os/gettime.c index aee799a..aab4133 100644 --- a/lib/ultralib/src/os/gettime.c +++ b/lib/ultralib/src/os/gettime.c @@ -1,11 +1,21 @@ #include "PR/os_internal.h" +#include "PR/ultraerror.h" #include "osint.h" +#include "../io/viint.h" OSTime osGetTime() { u32 tmptime; u32 elapseCount; OSTime currentCount; register u32 saveMask; + +#ifdef _DEBUG + if (!__osViDevMgr.active) { + __osError(ERR_OSGETTIME, 0); + return 0; + } +#endif + saveMask = __osDisableInt(); tmptime = osGetCount(); elapseCount = tmptime - __osBaseCounter; diff --git a/lib/ultralib/src/os/initialize.c b/lib/ultralib/src/os/initialize.c index ecc001e..3edfe45 100644 --- a/lib/ultralib/src/os/initialize.c +++ b/lib/ultralib/src/os/initialize.c @@ -1,14 +1,13 @@ #include "PR/os_internal.h" #include "PR/rcp.h" -typedef struct -{ - /* 0x0 */ unsigned int inst1; - /* 0x4 */ unsigned int inst2; - /* 0x8 */ unsigned int inst3; - /* 0xC */ unsigned int inst4; +typedef struct { + /* 0x0 */ unsigned int inst1; + /* 0x4 */ unsigned int inst2; + /* 0x8 */ unsigned int inst3; + /* 0xC */ unsigned int inst4; } __osExceptionVector; -extern __osExceptionVector __osExceptionPreamble; +extern __osExceptionVector __osExceptionPreamble[]; extern OSPiHandle __Dom1SpeedParam; extern OSPiHandle __Dom2SpeedParam; @@ -20,8 +19,8 @@ u32 __OSGlobalIntMask = OS_IM_ALL; #ifdef _FINALROM u32 __osFinalrom; #else -void* __printfunc = NULL; u32 __kmc_pt_mode; +void* __printfunc = NULL; #endif void __createSpeedParam(void) { @@ -45,28 +44,28 @@ void __osInitialize_common() { __osFinalrom = TRUE; #endif - __osSetSR(__osGetSR() | SR_CU1); //enable fpu - __osSetFpcCsr(FPCSR_FS | FPCSR_EV); //flush denorm to zero, enable invalid operation + __osSetSR(__osGetSR() | SR_CU1); // enable fpu + __osSetFpcCsr(FPCSR_FS | FPCSR_EV); // flush denorm to zero, enable invalid operation __osSetWatchLo(0x4900000); - while (__osSiRawReadIo(PIF_RAM_END - 3, &pifdata)) { //last byte of joychannel ram + while (__osSiRawReadIo(PIF_RAM_END - 3, &pifdata)) { // last byte of joychannel ram ; } while (__osSiRawWriteIo(PIF_RAM_END - 3, pifdata | 8)) { - ; //todo: magic contant + ; // todo: magic contant } - *(__osExceptionVector *)UT_VEC = __osExceptionPreamble; - *(__osExceptionVector *)XUT_VEC = __osExceptionPreamble; - *(__osExceptionVector *)ECC_VEC = __osExceptionPreamble; - *(__osExceptionVector *)E_VEC = __osExceptionPreamble; - osWritebackDCache((void *)UT_VEC, E_VEC - UT_VEC + sizeof(__osExceptionVector)); - osInvalICache((void *)UT_VEC, E_VEC - UT_VEC + sizeof(__osExceptionVector)); + *(__osExceptionVector*)UT_VEC = *__osExceptionPreamble; + *(__osExceptionVector*)XUT_VEC = *__osExceptionPreamble; + *(__osExceptionVector*)ECC_VEC = *__osExceptionPreamble; + *(__osExceptionVector*)E_VEC = *__osExceptionPreamble; + osWritebackDCache((void*)UT_VEC, E_VEC - UT_VEC + sizeof(__osExceptionVector)); + osInvalICache((void*)UT_VEC, E_VEC - UT_VEC + sizeof(__osExceptionVector)); __createSpeedParam(); osUnmapTLBAll(); osMapTLBRdb(); osClockRate = osClockRate * 3 / 4; - if (osResetType == 0 ) { // cold reset + if (osResetType == 0) { // cold reset bzero(osAppNMIBuffer, OS_APP_NMI_BUFSIZE); } diff --git a/lib/ultralib/src/os/initialize_emu.c b/lib/ultralib/src/os/initialize_emu.c index 5b68da5..7f7dd85 100644 --- a/lib/ultralib/src/os/initialize_emu.c +++ b/lib/ultralib/src/os/initialize_emu.c @@ -4,12 +4,11 @@ #include "PR/rdb.h" #include "osint.h" -typedef struct -{ - /* 0x0 */ unsigned int inst1; - /* 0x4 */ unsigned int inst2; - /* 0x8 */ unsigned int inst3; - /* 0xC */ unsigned int inst4; +typedef struct { + /* 0x0 */ unsigned int inst1; + /* 0x4 */ unsigned int inst2; + /* 0x8 */ unsigned int inst3; + /* 0xC */ unsigned int inst4; } __osExceptionVector; static void* proutSyncPrintf(void* str, const char* buf, size_t n) { diff --git a/lib/ultralib/src/os/initialize_isv.c b/lib/ultralib/src/os/initialize_isv.c index cd64821..60c1385 100644 --- a/lib/ultralib/src/os/initialize_isv.c +++ b/lib/ultralib/src/os/initialize_isv.c @@ -6,12 +6,11 @@ #include "macros.h" -typedef struct -{ - /* 0x0 */ unsigned int inst1; - /* 0x4 */ unsigned int inst2; - /* 0x8 */ unsigned int inst3; - /* 0xC */ unsigned int inst4; +typedef struct { + /* 0x0 */ unsigned int inst1; + /* 0x4 */ unsigned int inst2; + /* 0x8 */ unsigned int inst3; + /* 0xC */ unsigned int inst4; } __osExceptionVector; extern __osExceptionVector __isExpJP; @@ -21,21 +20,19 @@ void MonitorInitBreak(void); typedef struct { /* 0x00 */ u32 magic; // IS64 /* 0x04 */ u32 get; - /* 0x08 */ u8 unk_08[0x14-0x08]; + /* 0x08 */ u8 unk_08[0x14 - 0x08]; /* 0x14 */ u32 put; - /* 0x18 */ u8 unk_18[0x20-0x18]; - /* 0x20 */ u8 data[0x10000-0x20]; + /* 0x18 */ u8 unk_18[0x20 - 0x18]; + /* 0x20 */ u8 data[0x10000 - 0x20]; } ISVDbg; #define IS64_MAGIC 'IS64' -ISVDbg* gISVDbgPrnAdrs; - -u32 leoComuBuffAdd; +__osExceptionVector ramOldVector ALIGNED(8); u32 gISVFlag; u16 gISVChk; - -__osExceptionVector ramOldVector ALIGNED(8); +ISVDbg* gISVDbgPrnAdrs; +u32 leoComuBuffAdd; static OSPiHandle* is_Handle; @@ -44,7 +41,7 @@ void isPrintfInit(void) { osEPiWriteIo(is_Handle, &gISVDbgPrnAdrs->put, 0); osEPiWriteIo(is_Handle, &gISVDbgPrnAdrs->get, 0); - osEPiWriteIo(is_Handle, gISVDbgPrnAdrs, IS64_MAGIC); + osEPiWriteIo(is_Handle, &gISVDbgPrnAdrs->magic, IS64_MAGIC); } static void* is_proutSyncPrintf(void* arg, const u8* str, u32 count) { @@ -52,12 +49,13 @@ static void* is_proutSyncPrintf(void* arg, const u8* str, u32 count) { s32 p; s32 start; s32 end; + u32* magic = &gISVDbgPrnAdrs->magic; if (gISVDbgPrnAdrs == NULL) { return 0; } - osEPiReadIo(is_Handle, (u32)&gISVDbgPrnAdrs->magic, &data); + osEPiReadIo(is_Handle, (u32)magic, &data); if (data != IS64_MAGIC) { return 1; } @@ -103,9 +101,8 @@ static void* is_proutSyncPrintf(void* arg, const u8* str, u32 count) { int __checkHardware_isv(void) { u32 i = 0; - u32 data; // BUG: data is used uninitialized + u32 data; u32 save[4]; - u32 addr; OSPiHandle* hnd = osCartRomInit(); gISVDbgPrnAdrs = NULL; @@ -114,15 +111,17 @@ int __checkHardware_isv(void) { gISVChk = 0; for (i = 0; i < 4; i++) { - osEPiReadIo(hnd, 0xB0000100 + i * 4, save + i); + osEPiReadIo(hnd, 0xB0000100 + i * 4, &save[i]); } - // data = 0; +#ifndef __GNU__ // BUG: data is used uninitialized for GCC + data = 0; +#endif osEPiWriteIo(hnd, 0xB000010C, data); data = IS64_MAGIC; osEPiWriteIo(hnd, 0xB0000100, IS64_MAGIC); - for (i = 0; i <= 0x1FFFF; i++) { + for (i = 0; i < 0x20000; i++) { osEPiReadIo(hnd, 0xB000010C, &data); if (data == IS64_MAGIC) { data = 0; @@ -148,6 +147,8 @@ int __checkHardware_isv(void) { void __osInitialize_isv(void) { void (*fn)(void); OSPiHandle* hnd; + s32 pad; + s32 pad2; if (gISVFlag == IS64_MAGIC || __checkHardware_isv()) { if (gISVDbgPrnAdrs != NULL) { @@ -164,7 +165,7 @@ void __osInitialize_isv(void) { osInvalICache(&ramOldVector, 0x10); osWritebackDCache(0x80000000, 0x190); osInvalICache(0x80000000, 0x190); - osEPiReadIo(hnd, 0xBFF00010, &fn); + osEPiReadIo(hnd, 0xBFF00010, (u32*)&fn); fn(); } if (gISVChk & 2) { diff --git a/lib/ultralib/src/os/initialize_kmc.c b/lib/ultralib/src/os/initialize_kmc.c index c09b1fa..4952a0d 100644 --- a/lib/ultralib/src/os/initialize_kmc.c +++ b/lib/ultralib/src/os/initialize_kmc.c @@ -4,15 +4,14 @@ #include "PR/rcp.h" #include "osint.h" -typedef struct -{ - /* 0x0 */ unsigned int inst1; - /* 0x4 */ unsigned int inst2; - /* 0x8 */ unsigned int inst3; - /* 0xC */ unsigned int inst4; +typedef struct { + /* 0x0 */ unsigned int inst1; + /* 0x4 */ unsigned int inst2; + /* 0x8 */ unsigned int inst3; + /* 0xC */ unsigned int inst4; } __osExceptionVector; -extern __osExceptionVector* __ptExceptionPreamble; +extern __osExceptionVector __ptExceptionPreamble[]; static volatile unsigned int* stat = (unsigned*)0xbff08004; static volatile unsigned int* wport = (unsigned*)0xbff08000; @@ -57,7 +56,6 @@ static void* kmc_proutSyncPrintf(void* str, const char* buf, int n) { column++; *p++ = c; break; - } if (c == '\n' || (p - xbuf) > 100) { @@ -98,13 +96,13 @@ void __osInitialize_kmc(void) { return; } - src = (unsigned*)&__ptExceptionPreamble; + src = (unsigned*)__ptExceptionPreamble; dst = (unsigned*)E_VEC; *dst++ = *src++; *dst++ = *src++; *dst++ = *src++; - src+=2; - dst+=2; + src += 2; + dst += 2; *dst++ = *src++; *dst++ = *src++; *dst++ = *src++; diff --git a/lib/ultralib/src/os/initialize_msp.c b/lib/ultralib/src/os/initialize_msp.c index d0deead..1f120e1 100644 --- a/lib/ultralib/src/os/initialize_msp.c +++ b/lib/ultralib/src/os/initialize_msp.c @@ -4,15 +4,14 @@ #include "PR/rcp.h" #include "osint.h" -typedef struct -{ - /* 0x0 */ unsigned int inst1; - /* 0x4 */ unsigned int inst2; - /* 0x8 */ unsigned int inst3; - /* 0xC */ unsigned int inst4; +typedef struct { + /* 0x0 */ unsigned int inst1; + /* 0x4 */ unsigned int inst2; + /* 0x8 */ unsigned int inst3; + /* 0xC */ unsigned int inst4; } __osExceptionVector; -extern __osExceptionVector* __ptExceptionPreamble; +extern __osExceptionVector __ptExceptionPreamble[]; static volatile unsigned int* stat = (unsigned*)0xbff08004; static volatile unsigned int* wport = (unsigned*)0xbff08000; @@ -57,7 +56,6 @@ static void* msp_proutSyncPrintf(void* str, const char* buf, int n) { column++; *p++ = c; break; - } if (c == '\n' || (p - xbuf) > 100) { @@ -98,13 +96,13 @@ void __osInitialize_msp(void) { return; } - src = (unsigned*)&__ptExceptionPreamble; + src = (unsigned*)__ptExceptionPreamble; dst = (unsigned*)E_VEC; *dst++ = *src++; *dst++ = *src++; *dst++ = *src++; - src+=2; - dst+=2; + src += 2; + dst += 2; *dst++ = *src++; *dst++ = *src++; *dst++ = *src++; diff --git a/lib/ultralib/src/os/initrdb.c b/lib/ultralib/src/os/initrdb.c index a332c29..5537eb1 100644 --- a/lib/ultralib/src/os/initrdb.c +++ b/lib/ultralib/src/os/initrdb.c @@ -1,7 +1,8 @@ #ifndef _FINALROM +#include "PR/rdb.h" #include "PR/os_internal.h" -void* __osRdb_IP6_Data; +rdbPacket* __osRdb_IP6_Data; u32 __osRdb_IP6_Size; u32 __osRdb_IP6_Ct; u32 __osRdb_IP6_CurWrite; diff --git a/lib/ultralib/src/os/interrupt.s b/lib/ultralib/src/os/interrupt.s index 8fac481..e8f02d0 100644 --- a/lib/ultralib/src/os/interrupt.s +++ b/lib/ultralib/src/os/interrupt.s @@ -15,7 +15,7 @@ LEAF(__osDisableInt) lw t0, (t2) andi t0, 0xFF00 beq t0, t3, No_Change_Global_Int - la t2, __osRunningThread + la t2, __osRunningThread # this is intentionally a macro in the branch delay slot lw t1, 280(t2) andi t2, t1, 0xFF00 and t2, t0 diff --git a/lib/ultralib/src/os/invaldcache.s b/lib/ultralib/src/os/invaldcache.s index 24cfb1c..ea6a657 100644 --- a/lib/ultralib/src/os/invaldcache.s +++ b/lib/ultralib/src/os/invaldcache.s @@ -3,38 +3,36 @@ #include "sys/regdef.h" .text -.set noreorder LEAF(osInvalDCache) blez a1, 3f - nop li t3, DCACHE_SIZE bgeu a1, t3, 4f - nop + move t0, a0 addu t1, a0, a1 bgeu t0, t1, 3f - nop + addiu t1, t1, -DCACHE_LINESIZE andi t2, t0, DCACHE_LINEMASK beqz t2, 1f - nop + subu t0, t0, t2 CACHE((C_HWBINV|CACH_PD), (t0)) bgeu t0, t1, 3f - # nop + addiu t0, t0, DCACHE_LINESIZE 1: andi t2, t1, DCACHE_LINEMASK beqz t2, 2f - # nop + subu t1, t1, t2 CACHE((C_HWBINV|CACH_PD), 0x10(t1)) bltu t1, t0, 3f - # nop + 2: CACHE((C_HINV|CACH_PD), (t0)) .set noreorder @@ -43,7 +41,7 @@ LEAF(osInvalDCache) .set reorder 3: jr ra - # nop + 4: li t0, KUSIZE addu t1, t0, t3 @@ -56,6 +54,5 @@ LEAF(osInvalDCache) .set reorder jr ra - # nop - # nop + END(osInvalDCache) diff --git a/lib/ultralib/src/os/invalicache.s b/lib/ultralib/src/os/invalicache.s index aeaf200..f5ceb58 100644 --- a/lib/ultralib/src/os/invalicache.s +++ b/lib/ultralib/src/os/invalicache.s @@ -3,17 +3,16 @@ #include "sys/regdef.h" .text -.set noreorder LEAF(osInvalICache) blez a1, 2f - nop + li t3, ICACHE_SIZE bgeu a1, t3, 3f - nop + move t0, a0 addu t1, a0, a1 bgeu t0, t1, 2f - nop + addiu t1, t1, -ICACHE_LINESIZE andi t2, t0, ICACHE_LINEMASK subu t0, t0, t2 @@ -25,7 +24,7 @@ LEAF(osInvalICache) .set reorder 2: jr ra - #nop + 3: li t0, KUSIZE addu t1, t0, t3 @@ -38,5 +37,5 @@ LEAF(osInvalICache) .set reorder jr ra - #nop + END(osInvalICache) diff --git a/lib/ultralib/src/os/jammesg.c b/lib/ultralib/src/os/jammesg.c index 289d850..cef68da 100644 --- a/lib/ultralib/src/os/jammesg.c +++ b/lib/ultralib/src/os/jammesg.c @@ -1,8 +1,18 @@ #include "PR/os_internal.h" +#include "PR/ultraerror.h" #include "osint.h" -s32 osJamMesg(OSMesgQueue *mq, OSMesg msg, s32 flag) { - register u32 saveMask = __osDisableInt(); +s32 osJamMesg(OSMesgQueue* mq, OSMesg msg, s32 flag) { + register u32 saveMask; + +#ifdef _DEBUG + if ((flag != OS_MESG_NOBLOCK) && (flag != OS_MESG_BLOCK)) { + __osError(ERR_OSJAMMESG, 1, flag); + return -1; + } +#endif + + saveMask = __osDisableInt(); while (mq->validCount >= mq->msgCount) { if (flag == OS_MESG_BLOCK) { @@ -21,7 +31,7 @@ s32 osJamMesg(OSMesgQueue *mq, OSMesg msg, s32 flag) { if (mq->mtqueue->next != NULL) { osStartThread(__osPopThread(&mq->mtqueue)); } - + __osRestoreInt(saveMask); return 0; } diff --git a/lib/ultralib/src/os/maptlb.s b/lib/ultralib/src/os/maptlb.s index d02e3fd..20125b6 100644 --- a/lib/ultralib/src/os/maptlb.s +++ b/lib/ultralib/src/os/maptlb.s @@ -1,3 +1,4 @@ +#include "PR/ultraerror.h" #include "PR/R4300.h" #include "sys/asm.h" #include "sys/regdef.h" @@ -9,7 +10,53 @@ #define oddpaddr 16(sp) #define asid 20(sp) .text +.set noreorder LEAF(osMapTLB) +#if defined (_DEBUG) && defined (__sgi) + bgez index, 1f + nop + b 2f + nop +1: + li t0, 0x1F +.set noat + slt AT, index, t0 + bnez AT, 3f + nop +.set at +2: + move a2, a0 + li a0, ERR_OSMAPTLB_INDEX + li a1, 1 + j __osError + nop + +3: + lw t0, asid + li t1, -1 +.set noat + slt AT, t0, t1 + beqz AT, 4f + nop +.set at + b 5f + nop +4: + li t1, 0xFF +.set noat + slt AT, t1, t0 + beqz AT, 6f + nop +.set at +5: + move a2, t0 + li a0, ERR_OSMAPTLB_ASID + li a1, 1 + j __osError + nop +6: +.set reorder +#endif STAY2(mfc0 t0, C0_ENTRYHI) STAY2(mtc0 index, C0_INX) STAY2(mtc0 pm, C0_PAGEMASK) @@ -17,10 +64,10 @@ LEAF(osMapTLB) lw t1, asid beq t1, -1, 7f li ta0, TLBLO_G -.set reorder li t2, TLBLO_NONCOHRNT | TLBLO_D | TLBLO_V - or vaddr, vaddr, t1 b 8f + or vaddr, vaddr, t1 +.set reorder 7: li t2, TLBLO_NONCOHRNT | TLBLO_D | TLBLO_V | TLBLO_G diff --git a/lib/ultralib/src/os/osint.h b/lib/ultralib/src/os/osint.h index 7a4c0cd..75b94ea 100644 --- a/lib/ultralib/src/os/osint.h +++ b/lib/ultralib/src/os/osint.h @@ -39,11 +39,14 @@ extern u32 __osViIntrCount; extern u32 __osTimerCounter; extern u32 __osShutdown; +extern OSMesgQueue __osProfTimerQ; +extern OSProf *__osProfileList; +extern OSProf *__osProfileListEnd; +extern u32 __osProfileOverflowBin; + extern __OSEventState __osEventStateTab[OS_NUM_EVENTS]; -//not sure if this should be here -extern s32 osViClock; extern void __osTimerServicesInit(void); extern s32 __osAiDeviceBusy(void); extern int __osDpDeviceBusy(void); diff --git a/lib/ultralib/src/os/parameters.s b/lib/ultralib/src/os/parameters.s index ce6ebb5..450af31 100644 --- a/lib/ultralib/src/os/parameters.s +++ b/lib/ultralib/src/os/parameters.s @@ -12,5 +12,6 @@ ABS(osCicId, 0x80000310) ABS(osVersion, 0x80000314) ABS(osMemSize, 0x80000318) ABS(osAppNMIBuffer, 0x8000031c) -.fill 0x60 + +.space 0x60 /* padded to 0x60 in the object file */ diff --git a/lib/ultralib/src/os/physicaltovirtual.c b/lib/ultralib/src/os/physicaltovirtual.c index a0c1bae..6fbb9c3 100644 --- a/lib/ultralib/src/os/physicaltovirtual.c +++ b/lib/ultralib/src/os/physicaltovirtual.c @@ -1,6 +1,6 @@ #include "PR/os_internal.h" #include "PR/R4300.h" -void *osPhysicalToVirtual(u32 addr) { - return (void *)PHYS_TO_K0(addr); +void* osPhysicalToVirtual(u32 addr) { + return (void*)PHYS_TO_K0(addr); } diff --git a/lib/ultralib/src/os/rdbsend.c b/lib/ultralib/src/os/rdbsend.c index b561d99..0dc111e 100644 --- a/lib/ultralib/src/os/rdbsend.c +++ b/lib/ultralib/src/os/rdbsend.c @@ -1 +1,76 @@ -/* this file is completely empty in the rom release */ +#include "PR/os_internal.h" +#include "PR/rdb.h" +#include "PR/R4300.h" + +#ifndef _FINALROM +extern rdbPacket* __osRdb_IP6_Data; +extern u32 __osRdb_IP6_Size; +extern u32 __osRdb_IP6_Ct; +extern u32 __osRdb_IP6_CurWrite; + +u32 __osRdb_IP6_Empty = 1; + +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) + +u32 __osRdbSend(u8* buf, u32 size, u32 type) { + rdbPacket* pPtr; + rdbPacket pkt; + u32 len; + u32 c; + u32 inCt = 0; + u32 needFirst = 0; + u32 mask; + u32 sent = 0; + + mask = __osDisableInt(); + + if (__osRdb_IP6_Empty != 0) { + __osRdb_IP6_Empty = 0; + pkt.type = type; + + len = MIN(size, sizeof(pkt.buf)); + + pkt.length = len; + + c = 0; + while (c < len) { + pkt.buf[c++] = buf[inCt++]; + } + + size -= len; + sent = len; + needFirst = 1; + } + + while (size != 0 && __osRdb_IP6_Ct < __osRdb_IP6_Size) { + len = MIN(size, sizeof(pPtr->buf)); + + pPtr = &__osRdb_IP6_Data[__osRdb_IP6_CurWrite]; + + pPtr->type = type; + pPtr->length = len; + + c = 0; + while (c < len) { + pPtr->buf[c++] = buf[inCt++]; + } + + __osRdb_IP6_CurWrite++; + if (__osRdb_IP6_CurWrite >= __osRdb_IP6_Size) { + __osRdb_IP6_CurWrite = 0; + } + + __osRdb_IP6_Ct++; + size -= len; + sent += len; + } + + if (needFirst) { + *(u32*)RDB_BASE_REG = *(u32*)&pkt; + } + __osRestoreInt(mask); + + return sent; +} + +#endif diff --git a/lib/ultralib/src/os/recvmesg.c b/lib/ultralib/src/os/recvmesg.c index f7f0e63..043ed21 100644 --- a/lib/ultralib/src/os/recvmesg.c +++ b/lib/ultralib/src/os/recvmesg.c @@ -1,18 +1,27 @@ #include "PR/os_internal.h" +#include "PR/ultraerror.h" #include "osint.h" -s32 osRecvMesg(OSMesgQueue *mq, OSMesg *msg, s32 flags) { +s32 osRecvMesg(OSMesgQueue* mq, OSMesg* msg, s32 flags) { register u32 saveMask; + +#ifdef _DEBUG + if ((flags != OS_MESG_NOBLOCK) && (flags != OS_MESG_BLOCK)) { + __osError(ERR_OSRECVMESG, 1, flags); + return -1; + } +#endif + saveMask = __osDisableInt(); while (MQ_IS_EMPTY(mq)) { if (flags == OS_MESG_NOBLOCK) { __osRestoreInt(saveMask); return -1; + } else { + __osRunningThread->state = OS_STATE_WAITING; + __osEnqueueAndYield(&mq->mtqueue); } - - __osRunningThread->state = OS_STATE_WAITING; - __osEnqueueAndYield(&mq->mtqueue); } if (msg != NULL) { @@ -25,7 +34,7 @@ s32 osRecvMesg(OSMesgQueue *mq, OSMesg *msg, s32 flags) { if (mq->fullqueue->next != NULL) { osStartThread(__osPopThread(&mq->fullqueue)); } - + __osRestoreInt(saveMask); return 0; } diff --git a/lib/ultralib/src/os/sendmesg.c b/lib/ultralib/src/os/sendmesg.c index 4d48d08..19cf3de 100644 --- a/lib/ultralib/src/os/sendmesg.c +++ b/lib/ultralib/src/os/sendmesg.c @@ -1,10 +1,20 @@ #include "PR/os_internal.h" +#include "PR/ultraerror.h" #include "osint.h" -s32 osSendMesg(OSMesgQueue *mq, OSMesg msg, s32 flags) { +s32 osSendMesg(OSMesgQueue* mq, OSMesg msg, s32 flags) { register u32 saveMask; register s32 last; + +#ifdef _DEBUG + if ((flags != OS_MESG_NOBLOCK) && (flags != OS_MESG_BLOCK)) { + __osError(ERR_OSSENDMESG, 1, flags); + return -1; + } +#endif + saveMask = __osDisableInt(); + while (MQ_IS_FULL(mq)) { if (flags == OS_MESG_BLOCK) { __osRunningThread->state = OS_STATE_WAITING; @@ -14,15 +24,15 @@ s32 osSendMesg(OSMesgQueue *mq, OSMesg msg, s32 flags) { return -1; } } - + last = (mq->first + mq->validCount) % mq->msgCount; mq->msg[last] = msg; mq->validCount++; - + if (mq->mtqueue->next != NULL) { osStartThread(__osPopThread(&mq->mtqueue)); } - + __osRestoreInt(saveMask); return 0; } diff --git a/lib/ultralib/src/os/seteventmesg.c b/lib/ultralib/src/os/seteventmesg.c index dd2ad99..5a00bc9 100644 --- a/lib/ultralib/src/os/seteventmesg.c +++ b/lib/ultralib/src/os/seteventmesg.c @@ -1,16 +1,28 @@ #include "macros.h" #include "PR/os_internal.h" +#include "PR/ultraerror.h" #include "osint.h" __OSEventState __osEventStateTab[OS_NUM_EVENTS] ALIGNED(8); u32 __osPreNMI = FALSE; -void osSetEventMesg(OSEvent event, OSMesgQueue *mq, OSMesg msg) { - register u32 saveMask = __osDisableInt(); - __OSEventState *es = &__osEventStateTab[event]; +void osSetEventMesg(OSEvent event, OSMesgQueue* mq, OSMesg msg) { + register u32 saveMask; + __OSEventState* es; - es->messageQueue = mq; - es->message = msg; +#ifdef _DEBUG + if (event >= OS_NUM_EVENTS) { + __osError(ERR_OSSETEVENTMESG, 1, event); + return; + } +#endif + + saveMask = __osDisableInt(); + + es = &__osEventStateTab[event]; + + es->messageQueue = mq; + es->message = msg; if (event == OS_EVENT_PRENMI) { if (__osShutdown && !__osPreNMI) { @@ -19,5 +31,5 @@ void osSetEventMesg(OSEvent event, OSMesgQueue *mq, OSMesg msg) { __osPreNMI = TRUE; } - __osRestoreInt(saveMask); + __osRestoreInt(saveMask); } diff --git a/lib/ultralib/src/os/setfpccsr.s b/lib/ultralib/src/os/setfpccsr.s index f96ab33..f288437 100644 --- a/lib/ultralib/src/os/setfpccsr.s +++ b/lib/ultralib/src/os/setfpccsr.s @@ -7,5 +7,4 @@ LEAF(__osSetFpcCsr) STAY2(cfc1 v0, fcr31) STAY2(ctc1 a0, fcr31) jr ra -END(__osSetFpcCsr) -.globl __osSetSR +END(__osSetSR) # @bug: Should be __osGetFpcCsr diff --git a/lib/ultralib/src/os/setglobalintmask.c b/lib/ultralib/src/os/setglobalintmask.c index 1d82b6e..a718980 100644 --- a/lib/ultralib/src/os/setglobalintmask.c +++ b/lib/ultralib/src/os/setglobalintmask.c @@ -4,6 +4,6 @@ void __osSetGlobalIntMask(OSHWIntr mask) { register u32 saveMask = __osDisableInt(); __OSGlobalIntMask |= mask; - + __osRestoreInt(saveMask); } diff --git a/lib/ultralib/src/os/sethwinterrupt.c b/lib/ultralib/src/os/sethwinterrupt.c index 0fc9d30..bb0ddba 100644 --- a/lib/ultralib/src/os/sethwinterrupt.c +++ b/lib/ultralib/src/os/sethwinterrupt.c @@ -2,13 +2,13 @@ struct __osHwInt { s32 (*handler)(void); - void *stackEnd; + void* stackEnd; }; extern struct __osHwInt __osHwIntTable[]; -void __osSetHWIntrRoutine(OSHWIntr interrupt, s32 (*handler)(void), void *stackEnd) { - register u32 saveMask= __osDisableInt(); +void __osSetHWIntrRoutine(OSHWIntr interrupt, s32 (*handler)(void), void* stackEnd) { + register u32 saveMask = __osDisableInt(); __osHwIntTable[interrupt].handler = handler; __osHwIntTable[interrupt].stackEnd = stackEnd; diff --git a/lib/ultralib/src/os/setpiinterrupt.c b/lib/ultralib/src/os/setpiinterrupt.c index ddc3f2f..1af72b5 100644 --- a/lib/ultralib/src/os/setpiinterrupt.c +++ b/lib/ultralib/src/os/setpiinterrupt.c @@ -2,13 +2,13 @@ struct __osHwInt { s32 (*handler)(void); - void *stackEnd; + void* stackEnd; }; extern struct __osHwInt __osPiIntTable; -void __osSetPIIntrRoutine(struct __osHwInt *ir) { - register u32 saveMask= __osDisableInt(); +void __osSetPIIntrRoutine(struct __osHwInt* ir) { + register u32 saveMask = __osDisableInt(); __osPiIntTable.handler = ir->handler; __osPiIntTable.stackEnd = ir->stackEnd; diff --git a/lib/ultralib/src/os/setsr.s b/lib/ultralib/src/os/setsr.s index c2eb1d7..d7d98fa 100644 --- a/lib/ultralib/src/os/setsr.s +++ b/lib/ultralib/src/os/setsr.s @@ -5,6 +5,6 @@ .text LEAF(__osSetSR) STAY2(mtc0 a0, C0_SR) - nop + NOP jr ra END(__osSetSR) diff --git a/lib/ultralib/src/os/setthreadpri.c b/lib/ultralib/src/os/setthreadpri.c index ab6b23e..d836323 100644 --- a/lib/ultralib/src/os/setthreadpri.c +++ b/lib/ultralib/src/os/setthreadpri.c @@ -1,16 +1,26 @@ #include "PR/os_internal.h" +#include "PR/ultraerror.h" #include "osint.h" -void osSetThreadPri(OSThread *t, OSPri pri) { - register u32 saveMask = __osDisableInt(); - +void osSetThreadPri(OSThread* t, OSPri pri) { + register u32 saveMask; + +#ifdef _DEBUG + if ((pri < OS_PRIORITY_IDLE) || (pri > OS_PRIORITY_MAX)) { + __osError(ERR_OSSETTHREADPRI, 1, pri); + return; + } +#endif + + saveMask = __osDisableInt(); + if (t == NULL) { t = __osRunningThread; } if (t->priority != pri) { t->priority = pri; - + if (t != __osRunningThread && t->state != OS_STATE_STOPPED) { __osDequeueThread(t->queue, t); __osEnqueueThread(t->queue, t); diff --git a/lib/ultralib/src/os/settime.c b/lib/ultralib/src/os/settime.c index 5bae2a2..b7d14e3 100644 --- a/lib/ultralib/src/os/settime.c +++ b/lib/ultralib/src/os/settime.c @@ -1,6 +1,16 @@ #include "PR/os_internal.h" +#include "PR/ultraerror.h" #include "osint.h" +#include "../io/viint.h" void osSetTime(OSTime time) { + +#ifdef _DEBUG + if (!__osViDevMgr.active) { + __osError(ERR_OSSETTIME, 0); + return; + } +#endif + __osCurrentTime = time; } diff --git a/lib/ultralib/src/os/settimer.c b/lib/ultralib/src/os/settimer.c index 0b78f27..1eb7fbe 100644 --- a/lib/ultralib/src/os/settimer.c +++ b/lib/ultralib/src/os/settimer.c @@ -1,27 +1,33 @@ #include "PR/os_internal.h" +#include "PR/ultraerror.h" #include "osint.h" +#include "../io/viint.h" -int osSetTimer(OSTimer *t, OSTime countdown, OSTime interval, OSMesgQueue *mq, OSMesg msg) { - register u32 saveMask; +int osSetTimer(OSTimer* t, OSTime countdown, OSTime interval, OSMesgQueue* mq, OSMesg msg) { OSTime time; OSTimer* next; u32 count; u32 value; + u32 saveMask; + +#ifdef _DEBUG + if (!__osViDevMgr.active) { + __osError(ERR_OSSETTIMER, 0); + return 0; + } +#endif t->next = NULL; t->prev = NULL; - t->value = countdown; t->interval = interval; - - if (countdown == 0) { - t->value = interval; - } - + t->value = (countdown != 0) ? countdown : interval; t->mq = mq; t->msg = msg; - + saveMask = __osDisableInt(); - if (__osTimerList->next != __osTimerList) { + if (__osTimerList->next == __osTimerList) { + + } else { next = __osTimerList->next; count = osGetCount(); value = count - __osTimerCounter; diff --git a/lib/ultralib/src/os/settlbasid.s b/lib/ultralib/src/os/settlbasid.s index efaed5e..13a17e8 100644 --- a/lib/ultralib/src/os/settlbasid.s +++ b/lib/ultralib/src/os/settlbasid.s @@ -1,9 +1,32 @@ +#include "PR/ultraerror.h" #include "PR/R4300.h" #include "sys/asm.h" #include "sys/regdef.h" .text LEAF(osSetTLBASID) +#if defined (_DEBUG) && defined (__sgi) +.set noreorder + bgez a0, 1f + nop + b 2f + nop +1: + li t1, 0xFF +.set noat + slt AT, t1, a0 + beqz AT, 3f + nop +.set at +2: + move a2, a0 + li a0, ERR_OSSETTLBASID + li a1, 1 + j __osError + nop +3: +.set reorder +#endif STAY2(mtc0 a0, C0_ENTRYHI) jr ra END(osSetTLBASID) diff --git a/lib/ultralib/src/os/setwatchlo.s b/lib/ultralib/src/os/setwatchlo.s index 2f645a7..91cc58e 100644 --- a/lib/ultralib/src/os/setwatchlo.s +++ b/lib/ultralib/src/os/setwatchlo.s @@ -5,6 +5,6 @@ .text LEAF(__osSetWatchLo) STAY2(mtc0 a0, C0_WATCHLO) - nop + NOP jr ra END(__osSetWatchLo) diff --git a/lib/ultralib/src/os/startthread.c b/lib/ultralib/src/os/startthread.c index dfd7f1c..2ce1546 100644 --- a/lib/ultralib/src/os/startthread.c +++ b/lib/ultralib/src/os/startthread.c @@ -1,27 +1,31 @@ #include "PR/os_internal.h" +#include "PR/ultraerror.h" #include "osint.h" -void osStartThread(OSThread *t) { +void osStartThread(OSThread* t) { register u32 saveMask = __osDisableInt(); - + switch (t->state) { case OS_STATE_WAITING: t->state = OS_STATE_RUNNABLE; __osEnqueueThread(&__osRunQueue, t); break; case OS_STATE_STOPPED: - if (t->queue == NULL || t->queue == &__osRunQueue) - { + if (t->queue == NULL || t->queue == &__osRunQueue) { t->state = OS_STATE_RUNNABLE; __osEnqueueThread(&__osRunQueue, t); - } - else - { + } else { t->state = OS_STATE_WAITING; __osEnqueueThread(t->queue, t); __osEnqueueThread(&__osRunQueue, __osPopThread(t->queue)); } break; +#ifdef _DEBUG + default: + __osError(ERR_OSSTARTTHREAD, 0); + __osRestoreInt(saveMask); + return; +#endif } if (__osRunningThread == NULL) { diff --git a/lib/ultralib/src/os/stopthread.c b/lib/ultralib/src/os/stopthread.c index d276b3b..9a51652 100644 --- a/lib/ultralib/src/os/stopthread.c +++ b/lib/ultralib/src/os/stopthread.c @@ -1,13 +1,11 @@ #include "PR/os_internal.h" #include "osint.h" -void osStopThread(OSThread *t) { +void osStopThread(OSThread* t) { register u32 saveMask = __osDisableInt(); - register u16 state = OS_STATE_RUNNING; + register u16 state; - if (t != NULL) { - state = t->state; - } + state = (t == NULL) ? OS_STATE_RUNNING: t->state; switch (state) { case OS_STATE_RUNNING: diff --git a/lib/ultralib/src/os/stoptimer.c b/lib/ultralib/src/os/stoptimer.c index e9e07af..b6db1c1 100644 --- a/lib/ultralib/src/os/stoptimer.c +++ b/lib/ultralib/src/os/stoptimer.c @@ -1,9 +1,18 @@ #include "PR/os_internal.h" +#include "PR/ultraerror.h" #include "osint.h" +#include "../io/viint.h" -int osStopTimer(OSTimer *t) { +int osStopTimer(OSTimer* t) { register u32 savedMask; - OSTimer *timep; + OSTimer* timep; + +#ifdef _DEBUG + if (!__osViDevMgr.active) { + __osError(ERR_OSSTOPTIMER, 0); + return 0; + } +#endif if (t->next == NULL) { return -1; diff --git a/lib/ultralib/src/os/syncputchars.c b/lib/ultralib/src/os/syncputchars.c index 9095a04..d2d5332 100644 --- a/lib/ultralib/src/os/syncputchars.c +++ b/lib/ultralib/src/os/syncputchars.c @@ -6,27 +6,30 @@ unsigned int __osRdbSendMessage = 0; unsigned int __osRdbWriteOK = 1; -void __osSyncPutChars(int type, int length, const char *buf) { - rdbPacket packet; - int i; - u32 mask; - packet.type = type; - packet.length = length; - - for (i = 0; i < length; i++) { - packet.buf[i] = buf[i]; - } - - while (!__osAtomicDec(&__osRdbWriteOK)) { - } - - mask = __osDisableInt(); - *(vu32 *)RDB_BASE_REG = *(vu32 *)&packet; - - while (!(__osGetCause() & CAUSE_IP6)) { - } - - *(vu32 *)RDB_READ_INTR_REG = 0; - __osRdbWriteOK++; - __osRestoreInt(mask); +void __osSyncPutChars(int type, int length, const char* buf) { + rdbPacket packet; + int i; + u32 mask; + + packet.type = type; + packet.length = length; + + for (i = 0; i < length; i++) { + packet.buf[i] = buf[i]; + } + + while (!__osAtomicDec(&__osRdbWriteOK)) { + ; + } + + mask = __osDisableInt(); + *(vu32*)RDB_BASE_REG = *(vu32*)&packet; + + while (!(__osGetCause() & CAUSE_IP6)) { + ; + } + + *(vu32*)RDB_READ_INTR_REG = 0; + __osRdbWriteOK++; + __osRestoreInt(mask); } diff --git a/lib/ultralib/src/os/thread.c b/lib/ultralib/src/os/thread.c index 767c4cf..9a4a141 100644 --- a/lib/ultralib/src/os/thread.c +++ b/lib/ultralib/src/os/thread.c @@ -1,25 +1,28 @@ #include "PR/os_internal.h" #include "osint.h" -struct __osThreadTail __osThreadTail = {NULL, -1}; -OSThread *__osRunQueue = (OSThread *)&__osThreadTail; -OSThread *__osActiveQueue = (OSThread *)&__osThreadTail; -OSThread *__osRunningThread = {0}; -OSThread *__osFaultedThread = {0}; +struct __osThreadTail __osThreadTail = { NULL, -1 }; +OSThread* __osRunQueue = (OSThread*)&__osThreadTail; +OSThread* __osActiveQueue = (OSThread*)&__osThreadTail; +OSThread* __osRunningThread = { 0 }; +OSThread* __osFaultedThread = { 0 }; -void __osDequeueThread(OSThread **queue, OSThread *t) { - register OSThread **pred; - register OSThread *succ; +void __osDequeueThread(register OSThread** queue, register OSThread* t) { + register OSThread* pred; + register OSThread* succ; - pred = queue; - succ = *pred; + pred = (OSThread*)queue; + succ = pred->next; while (succ != NULL) { if (succ == t) { - *pred = t->next; + pred->next = t->next; +#ifdef _DEBUG + t->next = NULL; +#endif return; } pred = succ; - succ = *pred; + succ = pred->next; } } diff --git a/lib/ultralib/src/os/threadasm.h b/lib/ultralib/src/os/threadasm.h index c5a73da..dfd91b6 100644 --- a/lib/ultralib/src/os/threadasm.h +++ b/lib/ultralib/src/os/threadasm.h @@ -1,7 +1,7 @@ #ifndef _THREADASM_H_ #define _THREADASM_H_ -// Offsets of members in the OSThread struct +/* Offsets of members in the OSThread struct */ #define THREAD_NEXT 0 #define THREAD_PRI 4 #define THREAD_QUEUE 8 @@ -35,7 +35,7 @@ #define THREAD_GP23 208 #define THREAD_GP24 216 #define THREAD_GP25 224 -// k0 and k1 are reserved for the kernel +/* k0 and k1 are reserved for the kernel */ #define THREAD_GP28 232 #define THREAD_GP29 240 #define THREAD_GP30 248 diff --git a/lib/ultralib/src/os/timerintr.c b/lib/ultralib/src/os/timerintr.c index 0f09d1f..46beadf 100644 --- a/lib/ultralib/src/os/timerintr.c +++ b/lib/ultralib/src/os/timerintr.c @@ -1,106 +1,139 @@ +#include "macros.h" #include "PR/os_internal.h" #include "osint.h" -OSTimer *__osTimerList = &__osBaseTimer; -OSTimer __osBaseTimer; OSTime __osCurrentTime; u32 __osBaseCounter; u32 __osViIntrCount; u32 __osTimerCounter; +OSTimer __osBaseTimer; +OSTimer* __osTimerList = &__osBaseTimer; + +#ifndef _FINALROM +OSMesgQueue __osProfTimerQ ALIGNED(8); +OSProf* __osProfileList; +OSProf* __osProfileListEnd; +u32 __osProfileOverflowBin; +#endif void __osTimerServicesInit(void) { - __osCurrentTime = 0; - __osBaseCounter = 0; - __osViIntrCount = 0; - __osTimerList->prev = __osTimerList; - __osTimerList->next = __osTimerList->prev; - __osTimerList->value = 0; - __osTimerList->interval = __osTimerList->value; - __osTimerList->mq = NULL; - __osTimerList->msg = 0; + __osCurrentTime = 0; + __osBaseCounter = 0; + __osViIntrCount = 0; + __osTimerList->next = __osTimerList->prev = __osTimerList; + __osTimerList->interval = __osTimerList->value = 0; + __osTimerList->mq = NULL; + __osTimerList->msg = 0; } void __osTimerInterrupt(void) { - OSTimer *t; - u32 count; - u32 elapsed_cycles; - - if (__osTimerList->next != __osTimerList) { - while (TRUE) { - t = __osTimerList->next; - if (t == __osTimerList) { - __osSetCompare(0); - __osTimerCounter = 0; - break; - } - - count = osGetCount(); - elapsed_cycles = count - __osTimerCounter; - __osTimerCounter = count; - - if (elapsed_cycles < t->value) - { - t->value -= elapsed_cycles; - __osSetTimerIntr(t->value); - break; - } else { - t->prev->next = t->next; - t->next->prev = t->prev; - t->next = NULL; - t->prev = NULL; - - if (t->mq != NULL) { - osSendMesg(t->mq, t->msg, OS_MESG_NOBLOCK); - } - - if (t->interval != 0) { - t->value = t->interval; - __osInsertTimer(t); - } - } - } - } + OSTimer* t; + u32 count; + u32 elapsed_cycles; + +#ifndef _FINALROM + u32 pc; + s32 offset; + OSProf* prof = __osProfileList; +#endif + + if (__osTimerList->next == __osTimerList) { + return; + } + for (;;) { + t = __osTimerList->next; + + if (t == __osTimerList) { + __osSetCompare(0); + __osTimerCounter = 0; + break; + } + + count = osGetCount(); + elapsed_cycles = count - __osTimerCounter; + __osTimerCounter = count; + + if (elapsed_cycles < t->value) { + t->value -= elapsed_cycles; + __osSetTimerIntr(t->value); + break; + } + + t->prev->next = t->next; + t->next->prev = t->prev; + t->next = NULL; + t->prev = NULL; + + if (t->mq != NULL) { +#ifdef _FINALROM + osSendMesg(t->mq, t->msg, OS_MESG_NOBLOCK); + } +#else + if (t->mq != &__osProfTimerQ) { + osSendMesg(t->mq, t->msg, OS_MESG_NOBLOCK); + } else { + pc = __osRunQueue->context.pc; + for (prof = __osProfileList; prof < __osProfileListEnd; prof++) { + offset = pc - (u32)prof->text_start; + + if (offset >= 0) { + if ((s32)prof->text_end - (s32)pc > 0) { + (*(u16*)(u32)((offset >> 2) + prof->histo_base))++; + goto __ProfDone; + } + } + } + + __osProfileOverflowBin++; + } + } +#endif + + __ProfDone: + + if (t->interval != 0) { + t->value = t->interval; + __osInsertTimer(t); + } + } } void __osSetTimerIntr(OSTime tim) { - OSTime NewTime; - u32 savedMask; - - if (tim < 468) { - tim = 468; - } - - savedMask = __osDisableInt(); - __osTimerCounter = osGetCount(); - NewTime = __osTimerCounter + tim; - __osSetCompare(NewTime); - __osRestoreInt(savedMask); + OSTime NewTime; + u32 savedMask; + + if (tim < 468) { + tim = 468; + } + + savedMask = __osDisableInt(); + __osTimerCounter = osGetCount(); + NewTime = __osTimerCounter + tim; + __osSetCompare(NewTime); + __osRestoreInt(savedMask); } -OSTime __osInsertTimer(OSTimer *t) { - OSTimer *timep; - OSTime tim; - u32 savedMask; - savedMask = __osDisableInt(); - - timep = __osTimerList->next; - tim = t->value; - - while (timep != __osTimerList && tim > timep->value) { - tim -= timep->value; - timep = timep->next; - } - - t->value = tim; - - if (timep != __osTimerList) { - timep->value -= tim; - } - - t->next = timep; - t->prev = timep->prev; - timep->prev->next = t; - timep->prev = t; - __osRestoreInt(savedMask); - return tim; +OSTime __osInsertTimer(OSTimer* t) { + OSTimer* timep; + OSTime tim; + u32 savedMask = __osDisableInt(); + + timep = __osTimerList->next; + tim = t->value; + for (; timep != __osTimerList && tim > timep->value; timep = timep->next) { + tim -= timep->value; + } + + t->value = tim; + + if (timep != __osTimerList) { + timep->value -= tim; + } + + t->next = timep; + t->prev = timep->prev; + timep->prev->next = t; + timep->prev = t; + __osRestoreInt(savedMask); + return tim; } diff --git a/lib/ultralib/src/os/unmaptlb.s b/lib/ultralib/src/os/unmaptlb.s index 280a42e..362fd1e 100644 --- a/lib/ultralib/src/os/unmaptlb.s +++ b/lib/ultralib/src/os/unmaptlb.s @@ -1,3 +1,4 @@ +#include "PR/ultraerror.h" #include "PR/R4300.h" #include "sys/asm.h" #include "sys/regdef.h" @@ -5,6 +6,26 @@ .text .set noreorder LEAF(osUnmapTLB) +#if defined (_DEBUG) && defined (__sgi) + bgez a0, 1f + nop + b 2f + nop +1: + li t0, 0x1F +.set noat + slt AT, a0, t0 + bnez AT, 3f + nop +.set at +2: + move a2, a0 + li a0, ERR_OSUNMAPTLB + li a1, 1 + j __osError + nop +3: +#endif mfc0 t0, C0_ENTRYHI mtc0 a0, C0_INX li t1, K0BASE diff --git a/lib/ultralib/src/os/virtualtophysical.c b/lib/ultralib/src/os/virtualtophysical.c index 5cf9e86..553fe68 100644 --- a/lib/ultralib/src/os/virtualtophysical.c +++ b/lib/ultralib/src/os/virtualtophysical.c @@ -2,7 +2,7 @@ #include "PR/R4300.h" #include "osint.h" -u32 osVirtualToPhysical(void *addr) { +u32 osVirtualToPhysical(void* addr) { if (IS_KSEG0(addr)) { return K0_TO_PHYS(addr); } else if (IS_KSEG1(addr)) { diff --git a/lib/ultralib/src/os/yieldthread.c b/lib/ultralib/src/os/yieldthread.c index f4ed7c5..9a4dafb 100644 --- a/lib/ultralib/src/os/yieldthread.c +++ b/lib/ultralib/src/os/yieldthread.c @@ -3,7 +3,7 @@ void osYieldThread(void) { register u32 saveMask = __osDisableInt(); - + __osRunningThread->state = OS_STATE_RUNNABLE; __osEnqueueAndYield(&__osRunQueue); __osRestoreInt(saveMask); diff --git a/lib/ultralib/src/rg/free.c b/lib/ultralib/src/rg/free.c index 0229b2c..c426000 100755..100644 --- a/lib/ultralib/src/rg/free.c +++ b/lib/ultralib/src/rg/free.c @@ -1,15 +1,73 @@ #include "PR/region.h" #include "PR/R4300.h" +#include "PR/ultraerror.h" +#include "PR/os_internal.h" +#include "assert.h" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + // TODO: this comes from a header #ident "$Revision: 1.17 $" -void osFree(void *region, void *addr) { - register OSRegion *rp = region; +void osFree(void* region, void* addr) { + register OSRegion* rp = region; int i; - rp = region; - i = ((u8 *)addr - rp->r_startBufferAddress) / rp->r_bufferSize; - *(u16 *)(&rp->r_startBufferAddress[i * rp->r_bufferSize]) = rp->r_freeList; +#ifdef _DEBUG + assert((region != NULL) && (addr != NULL)); + if (((char*)rp + ALIGN(sizeof(OSRegion), rp->r_alignSize)) != rp->r_startBufferAddress) { + __osError(ERR_OSFREE_REGION, 1, region); + return; + } +#endif + + i = ((u8*)addr - rp->r_startBufferAddress) / rp->r_bufferSize; + +#ifdef _DEBUG + if ((i < 0) || (i >= rp->r_bufferCount)) { + __osError(ERR_OSFREE_ADDR, 2, addr, region); + return; + } + + if (((unsigned char*)addr - rp->r_startBufferAddress) % (rp->r_bufferSize) != 0) { + __osError(ERR_OSFREE_ADDR, 2, addr, region); + return; + } +#endif + *(u16*)(&rp->r_startBufferAddress[i * rp->r_bufferSize]) = rp->r_freeList; rp->r_freeList = i; } diff --git a/lib/ultralib/src/rg/getbufcount.c b/lib/ultralib/src/rg/getbufcount.c index 4f61521..d4deeba 100755..100644 --- a/lib/ultralib/src/rg/getbufcount.c +++ b/lib/ultralib/src/rg/getbufcount.c @@ -1,10 +1,57 @@ #include "PR/region.h" +#include "PR/ultraerror.h" +#include "PR/os_internal.h" +#include "assert.h" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + // TODO: this comes from a header #ident "$Revision: 1.17 $" -s32 osGetRegionBufCount(void *region) { - register OSRegion *rp = region; +s32 osGetRegionBufCount(void* region) { + register OSRegion* rp = region; + +#ifdef _DEBUG + assert(rp != NULL); + if (((char*)rp + ALIGN(sizeof(OSRegion), rp->r_alignSize)) != rp->r_startBufferAddress) { + __osError(ERR_OSGETREGIONBUFCOUNT, 1, region); + return 0; + } +#endif return rp->r_bufferCount; } - diff --git a/lib/ultralib/src/rg/getsize.c b/lib/ultralib/src/rg/getsize.c index 6bd4b2a..2b1fb90 100755..100644 --- a/lib/ultralib/src/rg/getsize.c +++ b/lib/ultralib/src/rg/getsize.c @@ -1,9 +1,57 @@ #include "PR/region.h" +#include "PR/ultraerror.h" +#include "PR/os_internal.h" +#include "assert.h" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + // TODO: this comes from a header #ident "$Revision: 1.17 $" -s32 osGetRegionBufSize(void *region) { - register OSRegion *rp = region; +s32 osGetRegionBufSize(void* region) { + register OSRegion* rp = region; + +#ifdef _DEBUG + assert(rp != NULL); + if (((char*)rp + ALIGN(sizeof(OSRegion), rp->r_alignSize)) != rp->r_startBufferAddress) { + __osError(ERR_OSGETREGIONBUFSIZE, 1, region); + return 0; + } +#endif + return rp->r_bufferSize; } diff --git a/lib/ultralib/src/rg/malloc.c b/lib/ultralib/src/rg/malloc.c index 4b26431..59c0399 100755..100644 --- a/lib/ultralib/src/rg/malloc.c +++ b/lib/ultralib/src/rg/malloc.c @@ -1,17 +1,70 @@ #include "PR/region.h" +#include "PR/ultraerror.h" +#include "PR/os_internal.h" +#include "assert.h" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + // TODO: this comes from a header #ident "$Revision: 1.17 $" -void *osMalloc(void *region) { - register OSRegion *rp = region; - unsigned char *addr; +void* osMalloc(void* region) { + register OSRegion* rp = region; + char* addr; + +#ifdef _DEBUG + assert(rp != NULL); + if (((char*)rp + ALIGN(sizeof(OSRegion), rp->r_alignSize)) != rp->r_startBufferAddress) { + __osError(ERR_OSMALLOC, 1, region); + return NULL; + } +#endif if (rp->r_freeList == MAX_BUFCOUNT) { return NULL; } - + addr = &rp->r_startBufferAddress[rp->r_freeList * rp->r_bufferSize]; - rp->r_freeList = *(u16 *)addr; + rp->r_freeList = *(u16*)addr; return addr; } diff --git a/lib/ultralib/src/rg/printregion.c b/lib/ultralib/src/rg/printregion.c new file mode 100644 index 0000000..2f84319 --- /dev/null +++ b/lib/ultralib/src/rg/printregion.c @@ -0,0 +1,26 @@ +#ifndef _FINALROM + +#include "../os/osint.h" +#include "PR/rmon.h" +#include "PR/region.h" + +void __osPrintRegion(void* region) { + register OSRegion* rp = region; + int i; + + rmonPrintf("Region = 0x%x\n", rp); + rmonPrintf("\tstartBufferAddress = 0x%x\n", RP(startBufferAddress)); + rmonPrintf("\tendAddress = 0x%x\n", RP(endAddress)); + rmonPrintf("\tbufferSize = %d\n", RP(bufferSize)); + rmonPrintf("\tbufferCount = %d\n", RP(bufferCount)); + rmonPrintf("\tfreeList = %d\n", RP(freeList)); + rmonPrintf("\talignSize = %d\n", RP(alignSize)); + rmonPrintf("\tMemory Header Layout:\n"); + + for (i = 0; i < RP(bufferCount); i++) { + rmonPrintf("\tBuf[%d]:\tAddress: 0x%x Value: 0x%x\n", i, RP(startBufferAddress) + i * RP(bufferSize), + *(u16*)(RP(startBufferAddress) + i * RP(bufferSize))); + } +} + +#endif diff --git a/lib/ultralib/src/rg/region.c b/lib/ultralib/src/rg/region.c index 181f52f..377ec9e 100755..100644 --- a/lib/ultralib/src/rg/region.c +++ b/lib/ultralib/src/rg/region.c @@ -1,12 +1,201 @@ #include "PR/region.h" +#include "PR/ultraerror.h" +#include "os_internal_error.h" +#include "assert.h" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + // TODO: this comes from a header #ident "$Revision: 1.17 $" -void *osCreateRegion(void *startAddress, u32 length, u32 bufferSize, u32 alignSize) { - register OSRegion *rp; +void* osCreateRegion(void* startAddress, u32 length, u32 bufferSize, u32 alignSize) { + register OSRegion* rp; register int i; - register unsigned char *addr; + register char* addr; + + assert(startAddress != NULL); + +#ifdef _DEBUG + if ((alignSize != 0) && (alignSize != OS_RG_ALIGN_2B) && (alignSize != OS_RG_ALIGN_4B) && + (alignSize != OS_RG_ALIGN_8B) && (alignSize != OS_RG_ALIGN_16B)) { + __osError(ERR_OSCREATEREGION_ALIGN, 1, alignSize); + return 0; + } +#endif if (alignSize == 0) { alignSize = OS_RG_ALIGN_DEFAULT; @@ -16,20 +205,27 @@ void *osCreateRegion(void *startAddress, u32 length, u32 bufferSize, u32 alignSi length = length - ((s32)rp - (s32)startAddress); rp->r_bufferSize = ALIGN(bufferSize, alignSize); rp->r_bufferCount = (s32)(length - ALIGN(sizeof(OSRegion), alignSize)) / rp->r_bufferSize; - + +#ifdef _DEBUG + if (rp->r_bufferCount <= 0) { + __osError(ERR_OSCREATEREGION_SIZE, 2, length, bufferSize); + return 0; + } +#endif + if (rp->r_bufferCount > MAX_BUFCOUNT) { rp->r_bufferCount = MAX_BUFCOUNT; } - + rp->r_startBufferAddress = (u8*)rp + ALIGN(sizeof(OSRegion), alignSize); rp->r_endAddress = (u8*)rp + length; addr = rp->r_startBufferAddress; - + for (i = 0; i < rp->r_bufferCount - 1; i++) { - *((s16 *)(&addr[i * rp->r_bufferSize])) = i + 1; + *((s16*)(&addr[i * rp->r_bufferSize])) = i + 1; } - *((u16 *)(&addr[i * rp->r_bufferSize])) = BUF_FREE_WO_NEXT; + *((u16*)(&addr[i * rp->r_bufferSize])) = BUF_FREE_WO_NEXT; rp->r_alignSize = alignSize; rp->r_freeList = 0; return rp; diff --git a/lib/ultralib/src/rmon/rmonbrk.c b/lib/ultralib/src/rmon/rmonbrk.c index ccae395..b3cf239 100644 --- a/lib/ultralib/src/rmon/rmonbrk.c +++ b/lib/ultralib/src/rmon/rmonbrk.c @@ -11,8 +11,6 @@ // TODO: this comes from a header #ident "$Revision: 1.4 $" -static void rmonFindFaultedThreads(void); - #define TMP_BP 0 #define NUM_BREAKPOINTS 16 @@ -37,6 +35,8 @@ static BREAKINFO RCPbreakpoints[NUM_BREAKPOINTS] ALIGNED(8); u8 __rmonRcpAtBreak; +static void rmonFindFaultedThreads(void); + static void SetTempBreakpoint(u32* addr1, u32* addr2) { STUBBED_PRINTF(("Set temp BP at %08x", addr1)); if (addr2 != NULL) { @@ -146,7 +146,8 @@ int __rmonSetBreak(KKHeader* req) { osInvalICache((void*)request->addr, sizeof(whichBreak->oldInstruction)); } whichBreak->breakAddress = (u32*)request->addr; - STUBBED_PRINTF(("* (%08x) = %08x (was %08x)\n", whichBreak->breakAddress, *whichBreak->breakAddress, whichBreak->oldInstruction)); + STUBBED_PRINTF(("* (%08x) = %08x (was %08x)\n", whichBreak->breakAddress, *whichBreak->breakAddress, + whichBreak->oldInstruction)); } /* Send reply */ @@ -237,31 +238,31 @@ u32 __rmonGetBranchTarget(int method, int thread, char* addr) { break; case 1: /* REGIMM */ switch ((inst >> 16) & 0x1F) { - case 0: /* BLTZ */ - case 1: /* BGEZ */ - case 2: /* BLTZL */ - case 3: /* BGEZL */ + case 0: /* BLTZ */ + case 1: /* BGEZ */ + case 2: /* BLTZL */ + case 3: /* BGEZL */ case 16: /* BLTZAL */ case 17: /* BGEZAL */ case 18: /* BLTZALL */ case 19: /* BGEZALL */ - return (u32)addr + ((inst << 0x10) >> 0xE) + 4; + return (((inst << 0x10) >> 0xE) + addr + 4); } break; case 2: /* J */ case 3: /* JAL */ return (((u32)inst << 6) >> 4) + (((s32)((u32)addr + 4) >> 0x1C) << 0x1C); - case 4: /* BEQ */ - case 5: /* BNE */ + case 4: /* BEQ */ + case 5: /* BNE */ case 20: /* BEQL */ case 21: /* BNEL */ - return (u32)addr + ((inst << 0x10) >> 0xE) + 4; - case 6: /* BLEZ */ - case 7: /* BGTZ */ + return (((inst << 0x10) >> 0xE) + addr + 4); + case 6: /* BLEZ */ + case 7: /* BGTZ */ case 22: /* BLEZL */ case 23: /* BGTZL */ if (((inst >> 16) & 0x1F) == 0) { - return (u32)addr + ((inst << 0x10) >> 0xE) + 4; + return (((inst << 0x10) >> 0xE) + addr + 4); } break; case 16: /* COP0 */ @@ -274,7 +275,7 @@ u32 __rmonGetBranchTarget(int method, int thread, char* addr) { case 1: /* BCzT */ case 2: /* BCzFL */ case 3: /* BCzTL */ - return (u32)addr + ((inst << 0x10) >> 0xE) + 4; + return (((inst << 0x10) >> 0xE) + addr + 4); } } break; @@ -309,10 +310,10 @@ int __rmonSetSingleStep(int thread, u32* instptr) { if ((branchTarget & 3) != 0) { /* no branch target, set breakpoint at next pc */ SetTempBreakpoint(instptr + 1, NULL); - } else if ((u32*)branchTarget == instptr) { + } else if (branchTarget == (u32)instptr) { /* branch target is this instruction, can't single step here */ return FALSE; - } else if (IsJump(*instptr) || (u32*)branchTarget == instptr + 2) { + } else if (IsJump(*instptr) || branchTarget == (u32)(instptr + 2)) { /* unconditional branch, set at branch target */ SetTempBreakpoint((u32*)branchTarget, NULL); } else { diff --git a/lib/ultralib/src/rmon/rmoncmds.c b/lib/ultralib/src/rmon/rmoncmds.c index a2bee99..5dd34d1 100644 --- a/lib/ultralib/src/rmon/rmoncmds.c +++ b/lib/ultralib/src/rmon/rmoncmds.c @@ -13,20 +13,17 @@ static int NotImplemented(KKHeader* dummy UNUSED) { } static FUNPTR dispatchTable[] = { - __rmonLoadProgram, __rmonListProcesses, __rmonGetExeName, __rmonListThreads, - __rmonThreadStatus, NotImplemented, __rmonStopThread, __rmonRunThread, - NotImplemented, NotImplemented, __rmonSetFault, NotImplemented, - __rmonGetRegionCount, __rmonGetRegions, __rmonGetGRegisters, __rmonSetGRegisters, - __rmonGetFRegisters, __rmonSetFRegisters, __rmonReadMem, __rmonWriteMem, - __rmonSetBreak, __rmonClearBreak, __rmonListBreak, NotImplemented, - NotImplemented, NotImplemented, NotImplemented, NotImplemented, - NotImplemented, NotImplemented, __rmonSetComm, NotImplemented, - NotImplemented, NotImplemented, NotImplemented, NotImplemented, - NotImplemented, NotImplemented, NotImplemented, NotImplemented, - NotImplemented, NotImplemented, NotImplemented, NotImplemented, - NotImplemented, NotImplemented, NotImplemented, NotImplemented, - NotImplemented, __rmonGetSRegs, __rmonSetSRegs, __rmonGetVRegs, - __rmonSetVRegs, NotImplemented, + __rmonLoadProgram, __rmonListProcesses, __rmonGetExeName, __rmonListThreads, __rmonThreadStatus, + NotImplemented, __rmonStopThread, __rmonRunThread, NotImplemented, NotImplemented, + __rmonSetFault, NotImplemented, __rmonGetRegionCount, __rmonGetRegions, __rmonGetGRegisters, + __rmonSetGRegisters, __rmonGetFRegisters, __rmonSetFRegisters, __rmonReadMem, __rmonWriteMem, + __rmonSetBreak, __rmonClearBreak, __rmonListBreak, NotImplemented, NotImplemented, + NotImplemented, NotImplemented, NotImplemented, NotImplemented, NotImplemented, + __rmonSetComm, NotImplemented, NotImplemented, NotImplemented, NotImplemented, + NotImplemented, NotImplemented, NotImplemented, NotImplemented, NotImplemented, + NotImplemented, NotImplemented, NotImplemented, NotImplemented, NotImplemented, + NotImplemented, NotImplemented, NotImplemented, NotImplemented, __rmonGetSRegs, + __rmonSetSRegs, __rmonGetVRegs, __rmonSetVRegs, NotImplemented, }; int __rmonExecute(KKHeader* request) { diff --git a/lib/ultralib/src/rmon/rmonint.h b/lib/ultralib/src/rmon/rmonint.h index 350b779..59ad736 100644 --- a/lib/ultralib/src/rmon/rmonint.h +++ b/lib/ultralib/src/rmon/rmonint.h @@ -92,7 +92,7 @@ u32 __rmonReadWordAt(u32* addr); void __rmonMemcpy(u8* dest, u8* srce, u32 count); void __rmonCopyWords(u32* dest, u32* srce, u32 count); -extern u8 __rmonUtilityBuffer[256]; +extern u8 __rmonUtilityBuffer[]; /* rmonsio */ diff --git a/lib/ultralib/src/rmon/rmonmain.c b/lib/ultralib/src/rmon/rmonmain.c index 6e2ee6d..8cb0c1b 100644 --- a/lib/ultralib/src/rmon/rmonmain.c +++ b/lib/ultralib/src/rmon/rmonmain.c @@ -69,11 +69,12 @@ void __rmonSendData(char* const block, unsigned int blockSize) { __rmonIOputw(*(blockPointer++)); } } - } else while (wordCount--) { - __rmonMemcpy((u8*)buffer.bufBytes, (u8*)blockPointer, sizeof(buffer)); - __rmonIOputw(buffer.bufWord); - blockPointer++; - } + } else + while (wordCount--) { + __rmonMemcpy((u8*)buffer.bufBytes, (u8*)blockPointer, sizeof(buffer)); + __rmonIOputw(buffer.bufWord); + blockPointer++; + } __rmonIOflush(); } @@ -90,10 +91,8 @@ void rmonMain(void) { __rmonInit(); __rmonActive = TRUE; - state = 0; - newChars = 0; - inPointer = (void*)&inbuffer; + state = 0, newChars = 0, inPointer = (void*)&inbuffer; for (;;) { OSMesg work; @@ -115,11 +114,11 @@ void rmonMain(void) { } if (somethingToDo & 0x10) { somethingToDo; - somethingToDo &= 0xEF; + somethingToDo &= (u8)~0x10; } if (somethingToDo & 0x20) { somethingToDo; - somethingToDo &= 0xDF; + somethingToDo &= (u8)~0x20; } } } diff --git a/lib/ultralib/src/rmon/rmonmem.c b/lib/ultralib/src/rmon/rmonmem.c index 3a8a3ab..0880fe9 100644 --- a/lib/ultralib/src/rmon/rmonmem.c +++ b/lib/ultralib/src/rmon/rmonmem.c @@ -23,7 +23,7 @@ void __rmonWriteWordTo(u32* addr, u32 val) { u32 __rmonReadWordAt(u32* addr) { u32 data; - if (addr >= (u32*)SP_DMEM_START && addr < (u32*)0x05000000) { + if ((u32)addr >= SP_DMEM_START && (u32)addr < 0x05000000) { __osSpRawReadIo((u32)addr, &data); return data; } @@ -70,10 +70,9 @@ int __rmonReadMem(KKHeader* req) { } if (req->method == RMON_RSP) { - if ((request->addr < SP_IMEM_START || (request->addr + request->nbytes) > SP_IMEM_END)) { - if ((request->addr < SP_DMEM_START || (request->addr + request->nbytes) > SP_DMEM_END)) { + if (!((request->addr < SP_IMEM_START || (request->addr + request->nbytes) > SP_IMEM_END) ? FALSE : TRUE) && + !((request->addr < SP_DMEM_START || (request->addr + request->nbytes) > SP_DMEM_END) ? FALSE : TRUE)) { return TV_ERROR_INVALID_ADDRESS; - } } } else if (osVirtualToPhysical((void*)request->addr) == (u32)-1) { return TV_ERROR_INVALID_ADDRESS; @@ -110,7 +109,8 @@ int __rmonWriteMem(KKHeader* req) { return TV_ERROR_INVALID_CAPABILITY; } - if ((request->writeHeader.addr >= SP_DMEM_START && (request->writeHeader.addr + request->writeHeader.nbytes) < 0x05000000)) { + if (((request->writeHeader.addr < SP_DMEM_START || + (request->writeHeader.addr + request->writeHeader.nbytes) > 0x04FFFFFF) ? FALSE : TRUE)) { int align; u32 word; diff --git a/lib/ultralib/src/rmon/rmonmisc.c b/lib/ultralib/src/rmon/rmonmisc.c index 0f9c4cd..aec32d6 100644 --- a/lib/ultralib/src/rmon/rmonmisc.c +++ b/lib/ultralib/src/rmon/rmonmisc.c @@ -10,8 +10,6 @@ // TODO: this comes from a header #ident "$Revision: 1.4 $" -OSMesgQueue __rmonMQ ALIGNED(8); - int __rmonSetFault(KKHeader* req) { KKFaultRequest* request = (KKFaultRequest*)req; KKObjectEvent reply; @@ -26,9 +24,10 @@ int __rmonSetFault(KKHeader* req) { return TV_ERROR_NO_ERROR; } +OSMesgQueue __rmonMQ ALIGNED(8); static OSThread rmonIOThread ALIGNED(8); static OSMesg rmonMsgs[8] ALIGNED(8); -static u64 rmonIOStack[2048] ALIGNED(8); +static u64 rmonIOStack[2048] ALIGNED(16); static OSMesg rmonPiMsgs[8] ALIGNED(8); static OSMesgQueue rmonPiMQ ALIGNED(8); @@ -38,8 +37,8 @@ void __rmonInit(void) { osSetEventMesg(OS_EVENT_SP_BREAK, &__rmonMQ, (OSMesg)RMON_MESG_SP_BREAK); osSetEventMesg(OS_EVENT_FAULT, &__rmonMQ, (OSMesg)RMON_MESG_FAULT); osSetEventMesg(OS_EVENT_THREADSTATUS, &__rmonMQ, NULL); - osCreateThread(&rmonIOThread, 0, (void (*)(void*))__rmonIOhandler, NULL, - rmonIOStack + ARRLEN(rmonIOStack), OS_PRIORITY_MAX); + osCreateThread(&rmonIOThread, 0, (void (*)(void*))__rmonIOhandler, NULL, rmonIOStack + ARRLEN(rmonIOStack), + OS_PRIORITY_MAX); osCreatePiManager(OS_PRIORITY_PIMGR, &rmonPiMQ, rmonPiMsgs, ARRLEN(rmonPiMsgs)); osStartThread(&rmonIOThread); } diff --git a/lib/ultralib/src/rmon/rmonregs.c b/lib/ultralib/src/rmon/rmonregs.c index d1e3af2..06b3e2c 100644 --- a/lib/ultralib/src/rmon/rmonregs.c +++ b/lib/ultralib/src/rmon/rmonregs.c @@ -18,7 +18,7 @@ static u32 RCPpc; static u32 oldIMEMvalue; -static u32 DMEMbuffer[4]; +static u32 DMEMbuffer[4] ALIGNED(8); typedef union { u32 everything; @@ -190,7 +190,6 @@ int __rmonGetFRegisters(KKHeader* req) { __rmonSendReply(&reply.header, sizeof(reply), KK_TYPE_REPLY); return TV_ERROR_NO_ERROR; - } int __rmonSetFRegisters(KKHeader* req) { @@ -213,7 +212,8 @@ int __rmonSetFRegisters(KKHeader* req) { return TV_ERROR_INVALID_ID; } - __rmonCopyWords((u32*)&tptr->context.fp0, (u32*)request->registers.fpregs.regs, ARRLEN(request->registers.fpregs.regs)); + __rmonCopyWords((u32*)&tptr->context.fp0, (u32*)request->registers.fpregs.regs, + ARRLEN(request->registers.fpregs.regs)); tptr->context.fpcsr = request->registers.fpcsr; reply.object = request->tid; @@ -237,7 +237,6 @@ static u32 rmonGetRcpRegister(int regNumber) { CleanupFromRCPop(FALSE); return contents; - } int __rmonGetSRegs(KKHeader* req) { diff --git a/lib/ultralib/src/rmon/rmonsio.c b/lib/ultralib/src/rmon/rmonsio.c index ffeca17..c239376 100644 --- a/lib/ultralib/src/rmon/rmonsio.c +++ b/lib/ultralib/src/rmon/rmonsio.c @@ -15,7 +15,7 @@ // TODO: this comes from a header #ident "$Revision: 1.4 $" -static OSMesgQueue IOmq; +static OSMesgQueue IOmq ALIGNED(8); static OSMesg IOmsgs; void* __osRdb_DbgRead_Buf; diff --git a/lib/ultralib/src/rmon/rmontask.c b/lib/ultralib/src/rmon/rmontask.c index 8728374..f1c73f0 100644 --- a/lib/ultralib/src/rmon/rmontask.c +++ b/lib/ultralib/src/rmon/rmontask.c @@ -4,7 +4,7 @@ #include "PR/os_internal.h" #include "rmonint.h" #include "PR/rcp.h" -#include "sptask.h" +#include "PR/sptask.h" #include "macros.h" @@ -111,7 +111,8 @@ int __rmonListThreads(KKHeader* req) { } reply->header.code = request->header.code; reply->header.error = TV_ERROR_NO_ERROR; - __rmonSendReply(&reply->header, sizeof(*reply) + sizeof(reply->objs.objects[0]) * (reply->objs.number - 1), KK_TYPE_REPLY); + __rmonSendReply(&reply->header, sizeof(*reply) + sizeof(reply->objs.objects[0]) * (reply->objs.number - 1), + KK_TYPE_REPLY); return TV_ERROR_NO_ERROR; } @@ -228,7 +229,7 @@ int __rmonStopThread(KKHeader* req) { } pc--; /* Check if the RSP is stopped in a branch delay slot, if it is step out of it. The RSP would otherwise - lose information about whether the branch should or should not be taken when reading registers. */ + lose information about whether the branch should or should not be taken when reading registers. */ if (__rmonGetBranchTarget(RMON_RSP, RMON_TID_RSP, (void*)((u32)pc + SP_IMEM_START)) % 4 == 0) { __rmonStepRCP(); } @@ -249,7 +250,6 @@ int __rmonStopThread(KKHeader* req) { __rmonSendReply(&reply.header, sizeof(reply), KK_TYPE_EXCEPTION); } return TV_ERROR_NO_ERROR; - } int __rmonRunThread(KKHeader* req) { @@ -295,7 +295,10 @@ int __rmonRunThread(KKHeader* req) { } if (request->actions.flags & KK_RUN_SSTEP) { /* If the RSP is stopped at a branch step twice so as to not stop in a branch delay slot. */ - if (__rmonGetBranchTarget(RMON_RSP, RMON_TID_RSP, (void*)(__rmonReadWordAt((u32*)SP_PC_REG) + SP_IMEM_START)) % 4 == 0) { + if (__rmonGetBranchTarget(RMON_RSP, RMON_TID_RSP, + (void*)(__rmonReadWordAt((u32*)SP_PC_REG) + SP_IMEM_START)) % + 4 == + 0) { __rmonStepRCP(); } __rmonStepRCP(); diff --git a/lib/ultralib/src/sched/sched.c b/lib/ultralib/src/sched/sched.c index 7cf59dd..70ebf55 100644 --- a/lib/ultralib/src/sched/sched.c +++ b/lib/ultralib/src/sched/sched.c @@ -2,7 +2,6 @@ * * Copyright 1995, Silicon Graphics, Inc. * All Rights Reserved. - * * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, * Inc.; the contents of this file may not be disclosed to third * parties, copied or duplicated in any form, in whole or in part, @@ -16,11 +15,9 @@ * DOD or NASA FAR Supplement. Unpublished - rights reserved under the * Copyright Laws of the United States. *====================================================================*/ - #include <ultralog.h> #include <assert.h> #include <sched.h> - // TODO: this comes from a header #ident "$Revision: 1.17 $" diff --git a/lib/ultralib/src/sp/sprite.c b/lib/ultralib/src/sp/sprite.c index 0779f1f..f0732b4 100644 --- a/lib/ultralib/src/sp/sprite.c +++ b/lib/ultralib/src/sp/sprite.c @@ -1,11 +1,9 @@ /* * Copyright 1995, Silicon Graphics, Inc. * ALL RIGHTS RESERVED - * * UNPUBLISHED -- Rights reserved under the copyright laws of the United * States. Use of a copyright notice is precautionary only and does not * imply publication or disclosure. - * * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND: * Use, duplication or disclosure by the Government is subject to restrictions * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights @@ -20,7 +18,6 @@ * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON * GRAPHICS, INC. */ - #include <assert.h> #include <sp.h> diff --git a/lib/ultralib/src/vimodes/vimodefpalhaf1.c b/lib/ultralib/src/vimodes/vimodefpalhaf1.c index 86e0f80..5ad95fa 100644 --- a/lib/ultralib/src/vimodes/vimodefpalhaf1.c +++ b/lib/ultralib/src/vimodes/vimodefpalhaf1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeFpalHaf1 = { - OS_VI_FPAL_HAF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(640), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_FPAL_HAF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(640), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(0.5, 0.5), // yScale - HSTART(45, 615), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(2560), // origin - SCALE(0.5, 0.5), // yScale - HSTART(47, 617), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(0.5, 0.5), // yScale + HSTART(45, 615), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(2560), // origin + SCALE(0.5, 0.5), // yScale + HSTART(47, 617), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodefpalhan1.c b/lib/ultralib/src/vimodes/vimodefpalhan1.c index 857c493..f29ff4b 100644 --- a/lib/ultralib/src/vimodes/vimodefpalhan1.c +++ b/lib/ultralib/src/vimodes/vimodefpalhan1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeFpalHan1 = { - OS_VI_FPAL_HAN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(1280), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_FPAL_HAN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(1280), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(45, 615), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(2560), // origin - SCALE(1, 0), // yScale - HSTART(47, 617), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(45, 615), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(2560), // origin + SCALE(1, 0), // yScale + HSTART(47, 617), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodefpalhpf1.c b/lib/ultralib/src/vimodes/vimodefpalhpf1.c index 366ed78..db0eb9d 100644 --- a/lib/ultralib/src/vimodes/vimodefpalhpf1.c +++ b/lib/ultralib/src/vimodes/vimodefpalhpf1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeFpalHpf1 = { - OS_VI_FPAL_HPF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(640), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_FPAL_HPF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(640), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(0.5, 0.5), // yScale - HSTART(45, 615), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(2560), // origin - SCALE(0.5, 0.5), // yScale - HSTART(47, 617), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(0.5, 0.5), // yScale + HSTART(45, 615), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(2560), // origin + SCALE(0.5, 0.5), // yScale + HSTART(47, 617), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodefpalhpf2.c b/lib/ultralib/src/vimodes/vimodefpalhpf2.c index 76eaa13..dfd3d92 100644 --- a/lib/ultralib/src/vimodes/vimodefpalhpf2.c +++ b/lib/ultralib/src/vimodes/vimodefpalhpf2.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeFpalHpf2 = { - OS_VI_FPAL_HPF2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(640), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_FPAL_HPF2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(640), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(2560), // origin - SCALE(0.5, 0.5), // yScale - HSTART(45, 615), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(5120), // origin - SCALE(0.5, 0.5), // yScale - HSTART(47, 617), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(2560), // origin + SCALE(0.5, 0.5), // yScale + HSTART(45, 615), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(5120), // origin + SCALE(0.5, 0.5), // yScale + HSTART(47, 617), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodefpalhpn1.c b/lib/ultralib/src/vimodes/vimodefpalhpn1.c index 416e63e..8b665a8 100644 --- a/lib/ultralib/src/vimodes/vimodefpalhpn1.c +++ b/lib/ultralib/src/vimodes/vimodefpalhpn1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeFpalHpn1 = { - OS_VI_FPAL_HPN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(1280), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_FPAL_HPN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(1280), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(45, 615), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(2560), // origin - SCALE(1, 0), // yScale - HSTART(47, 617), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(45, 615), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(2560), // origin + SCALE(1, 0), // yScale + HSTART(47, 617), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodefpalhpn2.c b/lib/ultralib/src/vimodes/vimodefpalhpn2.c index 3f3f165..c046e97 100644 --- a/lib/ultralib/src/vimodes/vimodefpalhpn2.c +++ b/lib/ultralib/src/vimodes/vimodefpalhpn2.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeFpalHpn2 = { - OS_VI_FPAL_HPN2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_3 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(1280), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_FPAL_HPN2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_3 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(1280), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(2560), // origin - SCALE(1, 0), // yScale - HSTART(45, 615), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(5120), // origin - SCALE(1, 0), // yScale - HSTART(47, 617), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(2560), // origin + SCALE(1, 0), // yScale + HSTART(45, 615), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(5120), // origin + SCALE(1, 0), // yScale + HSTART(47, 617), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodefpallaf1.c b/lib/ultralib/src/vimodes/vimodefpallaf1.c index bc86c99..e4a8a9e 100644 --- a/lib/ultralib/src/vimodes/vimodefpallaf1.c +++ b/lib/ultralib/src/vimodes/vimodefpallaf1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeFpalLaf1 = { - OS_VI_FPAL_LAF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_FPAL_LAF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0.25), // yScale - HSTART(45, 615), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0.75), // yScale - HSTART(47, 617), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0.25), // yScale + HSTART(45, 615), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0.75), // yScale + HSTART(47, 617), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodefpallaf2.c b/lib/ultralib/src/vimodes/vimodefpallaf2.c index 8233460..8b3b608 100644 --- a/lib/ultralib/src/vimodes/vimodefpallaf2.c +++ b/lib/ultralib/src/vimodes/vimodefpallaf2.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeFpalLaf2 = { - OS_VI_FPAL_LAF2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_FPAL_LAF2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0.25), // yScale - HSTART(45, 615), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0.75), // yScale - HSTART(47, 617), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0.25), // yScale + HSTART(45, 615), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0.75), // yScale + HSTART(47, 617), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodefpallan1.c b/lib/ultralib/src/vimodes/vimodefpallan1.c index 30532a0..f190f55 100644 --- a/lib/ultralib/src/vimodes/vimodefpallan1.c +++ b/lib/ultralib/src/vimodes/vimodefpallan1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeFpalLan1 = { - OS_VI_FPAL_LAN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_1 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(625), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_FPAL_LAN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_1 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(625), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(47, 617), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(47, 617), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(47, 617), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(47, 617), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodefpallan2.c b/lib/ultralib/src/vimodes/vimodefpallan2.c index 76ddf13..13c71e5 100644 --- a/lib/ultralib/src/vimodes/vimodefpallan2.c +++ b/lib/ultralib/src/vimodes/vimodefpallan2.c @@ -3,33 +3,34 @@ #include "../io/viint.h" OSViMode osViModeFpalLan2 = { - OS_VI_FPAL_LAN2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(625), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_FPAL_LAN2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(625), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(47, 617), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(47, 617), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(47, 617), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(47, 617), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodefpallpf1.c b/lib/ultralib/src/vimodes/vimodefpallpf1.c index d743345..d1c307c 100644 --- a/lib/ultralib/src/vimodes/vimodefpallpf1.c +++ b/lib/ultralib/src/vimodes/vimodefpallpf1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeFpalLpf1 = { - OS_VI_FPAL_LPF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_FPAL_LPF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0.25), // yScale - HSTART(45, 615), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0.75), // yScale - HSTART(47, 617), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0.25), // yScale + HSTART(45, 615), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0.75), // yScale + HSTART(47, 617), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodefpallpf2.c b/lib/ultralib/src/vimodes/vimodefpallpf2.c index 04b4c6c..385b1df 100644 --- a/lib/ultralib/src/vimodes/vimodefpallpf2.c +++ b/lib/ultralib/src/vimodes/vimodefpallpf2.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeFpalLpf2 = { - OS_VI_FPAL_LPF2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_FPAL_LPF2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0.25), // yScale - HSTART(45, 615), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0.75), // yScale - HSTART(47, 617), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0.25), // yScale + HSTART(45, 615), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0.75), // yScale + HSTART(47, 617), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodefpallpn1.c b/lib/ultralib/src/vimodes/vimodefpallpn1.c index 634d984..6fbcfe9 100644 --- a/lib/ultralib/src/vimodes/vimodefpallpn1.c +++ b/lib/ultralib/src/vimodes/vimodefpallpn1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeFpalLpn1 = { - OS_VI_FPAL_LPN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(625), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_FPAL_LPN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(625), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(47, 617), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(47, 617), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(47, 617), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(47, 617), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodefpallpn2.c b/lib/ultralib/src/vimodes/vimodefpallpn2.c index cc1627a..c852cf9 100644 --- a/lib/ultralib/src/vimodes/vimodefpallpn2.c +++ b/lib/ultralib/src/vimodes/vimodefpallpn2.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeFpalLpn2 = { - OS_VI_FPAL_LPN2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_ANTIALIAS_MODE_3 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(625), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_FPAL_LPN2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_ANTIALIAS_MODE_3 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(625), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(47, 617), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(47, 617), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(47, 617), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(47, 617), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodempalhaf1.c b/lib/ultralib/src/vimodes/vimodempalhaf1.c index 0c3d605..c9a74dc 100644 --- a/lib/ultralib/src/vimodes/vimodempalhaf1.c +++ b/lib/ultralib/src/vimodes/vimodempalhaf1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeMpalHaf1 = { - OS_VI_MPAL_HAF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(640), // width - BURST(57, 30, 5, 70), // burst - VSYNC(524), // vSync - HSYNC(3088, 0), // hSync - LEAP(3100, 3100), // leap - HSTART(108, 748), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_MPAL_HAF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(640), // width + BURST(57, 30, 5, 70), // burst + VSYNC(524), // vSync + HSYNC(3088, 0), // hSync + LEAP(3100, 3100), // leap + HSTART(108, 748), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { //[0] - ORIGIN(1280), // origin - SCALE(0.5, 0.5), // yScale - HSTART(35, 509), // vStart - BURST(2, 2, 11, 0), // vBurst - VINTR(2), // vIntr - }, - { //[1] - ORIGIN(2560), // origin - SCALE(0.5, 0.5), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } + { + //[0] + ORIGIN(1280), // origin + SCALE(0.5, 0.5), // yScale + HSTART(35, 509), // vStart + BURST(2, 2, 11, 0), // vBurst + VINTR(2), // vIntr + }, + { + //[1] + ORIGIN(2560), // origin + SCALE(0.5, 0.5), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodempalhan1.c b/lib/ultralib/src/vimodes/vimodempalhan1.c index 0566ccc..038163b 100644 --- a/lib/ultralib/src/vimodes/vimodempalhan1.c +++ b/lib/ultralib/src/vimodes/vimodempalhan1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeMpalHan1 = { - OS_VI_MPAL_HAN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(1280), // width - BURST(57, 30, 5, 70), // burst - VSYNC(524), // vSync - HSYNC(3088, 0), // hSync - LEAP(3100, 3100), // leap - HSTART(108, 748), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_MPAL_HAN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(1280), // width + BURST(57, 30, 5, 70), // burst + VSYNC(524), // vSync + HSYNC(3088, 0), // hSync + LEAP(3100, 3100), // leap + HSTART(108, 748), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(35, 509), // vStart - BURST(2, 2, 11, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(2560), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(35, 509), // vStart + BURST(2, 2, 11, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(2560), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodempalhpf1.c b/lib/ultralib/src/vimodes/vimodempalhpf1.c index 3aa2b6b..4bbb0e5 100644 --- a/lib/ultralib/src/vimodes/vimodempalhpf1.c +++ b/lib/ultralib/src/vimodes/vimodempalhpf1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeMpalHpf1 = { - OS_VI_MPAL_HPF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(640), // width - BURST(57, 30, 5, 70), // burst - VSYNC(524), // vSync - HSYNC(3088, 0), // hSync - LEAP(3100, 3100), // leap - HSTART(108, 748), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_MPAL_HPF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(640), // width + BURST(57, 30, 5, 70), // burst + VSYNC(524), // vSync + HSYNC(3088, 0), // hSync + LEAP(3100, 3100), // leap + HSTART(108, 748), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(0.5, 0.5), // yScale - HSTART(35, 509), // vStart - BURST(2, 2, 11, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(2560), // origin - SCALE(0.5, 0.5), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(0.5, 0.5), // yScale + HSTART(35, 509), // vStart + BURST(2, 2, 11, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(2560), // origin + SCALE(0.5, 0.5), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodempalhpf2.c b/lib/ultralib/src/vimodes/vimodempalhpf2.c index 128ca15..b2fad3d 100644 --- a/lib/ultralib/src/vimodes/vimodempalhpf2.c +++ b/lib/ultralib/src/vimodes/vimodempalhpf2.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeMpalHpf2 = { - OS_VI_MPAL_HPF2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(640), // width - BURST(57, 30, 5, 70), // burst - VSYNC(524), // vSync - HSYNC(3088, 0), // hSync - LEAP(3100, 3100), // leap - HSTART(108, 748), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_MPAL_HPF2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(640), // width + BURST(57, 30, 5, 70), // burst + VSYNC(524), // vSync + HSYNC(3088, 0), // hSync + LEAP(3100, 3100), // leap + HSTART(108, 748), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(2560), // origin - SCALE(0.5, 0.5), // yScale - HSTART(35, 509), // vStart - BURST(2, 2, 11, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(5120), // origin - SCALE(0.5, 0.5), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(2560), // origin + SCALE(0.5, 0.5), // yScale + HSTART(35, 509), // vStart + BURST(2, 2, 11, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(5120), // origin + SCALE(0.5, 0.5), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodempalhpn1.c b/lib/ultralib/src/vimodes/vimodempalhpn1.c index d589ad9..3955a4f 100644 --- a/lib/ultralib/src/vimodes/vimodempalhpn1.c +++ b/lib/ultralib/src/vimodes/vimodempalhpn1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeMpalHpn1 = { - OS_VI_MPAL_HPN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(1280), // width - BURST(57, 30, 5, 70), // burst - VSYNC(524), // vSync - HSYNC(3088, 0), // hSync - LEAP(3100, 3100), // leap - HSTART(108, 748), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_MPAL_HPN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(1280), // width + BURST(57, 30, 5, 70), // burst + VSYNC(524), // vSync + HSYNC(3088, 0), // hSync + LEAP(3100, 3100), // leap + HSTART(108, 748), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(35, 509), // vStart - BURST(2, 2, 11, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(2560), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(35, 509), // vStart + BURST(2, 2, 11, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(2560), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodempalhpn2.c b/lib/ultralib/src/vimodes/vimodempalhpn2.c index 57f43cd..b4c7a6d 100644 --- a/lib/ultralib/src/vimodes/vimodempalhpn2.c +++ b/lib/ultralib/src/vimodes/vimodempalhpn2.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeMpalHpn2 = { - OS_VI_MPAL_HPN2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_3 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(1280), // width - BURST(57, 30, 5, 70), // burst - VSYNC(524), // vSync - HSYNC(3088, 0), // hSync - LEAP(3100, 3100), // leap - HSTART(108, 748), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_MPAL_HPN2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_3 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(1280), // width + BURST(57, 30, 5, 70), // burst + VSYNC(524), // vSync + HSYNC(3088, 0), // hSync + LEAP(3100, 3100), // leap + HSTART(108, 748), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(2560), // origin - SCALE(1, 0), // yScale - HSTART(35, 509), // vStart - BURST(2, 2, 11, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(5120), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(2560), // origin + SCALE(1, 0), // yScale + HSTART(35, 509), // vStart + BURST(2, 2, 11, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(5120), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodempallaf1.c b/lib/ultralib/src/vimodes/vimodempallaf1.c index 2d726e7..1369d39 100644 --- a/lib/ultralib/src/vimodes/vimodempallaf1.c +++ b/lib/ultralib/src/vimodes/vimodempallaf1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeMpalLaf1 = { - OS_VI_MPAL_LAF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 30, 5, 70), // burst - VSYNC(524), // vSync - HSYNC(3088, 0), // hSync - LEAP(3100, 3100), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_MPAL_LAF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 30, 5, 70), // burst + VSYNC(524), // vSync + HSYNC(3088, 0), // hSync + LEAP(3100, 3100), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0.25), // yScale - HSTART(35, 509), // vStart - BURST(2, 2, 11, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0.75), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0.25), // yScale + HSTART(35, 509), // vStart + BURST(2, 2, 11, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0.75), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodempallaf2.c b/lib/ultralib/src/vimodes/vimodempallaf2.c index 8eac118..0502362 100644 --- a/lib/ultralib/src/vimodes/vimodempallaf2.c +++ b/lib/ultralib/src/vimodes/vimodempallaf2.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeMpalLaf2 = { - OS_VI_MPAL_LAF2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 30, 5, 70), // burst - VSYNC(524), // vSync - HSYNC(3088, 0), // hSync - LEAP(3100, 3100), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_MPAL_LAF2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 30, 5, 70), // burst + VSYNC(524), // vSync + HSYNC(3088, 0), // hSync + LEAP(3100, 3100), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0.25), // yScale - HSTART(35, 509), // vStart - BURST(2, 2, 11, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0.75), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0.25), // yScale + HSTART(35, 509), // vStart + BURST(2, 2, 11, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0.75), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodempallan1.c b/lib/ultralib/src/vimodes/vimodempallan1.c index 2a4f73a..a3f4e69 100644 --- a/lib/ultralib/src/vimodes/vimodempallan1.c +++ b/lib/ultralib/src/vimodes/vimodempallan1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeMpalLan1 = { - OS_VI_MPAL_LAN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_1 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 30, 5, 70), // burst - VSYNC(525), // vSync - HSYNC(3089, 4), // hSync - LEAP(3097, 3098), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_MPAL_LAN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_1 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 30, 5, 70), // burst + VSYNC(525), // vSync + HSYNC(3089, 4), // hSync + LEAP(3097, 3098), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodempallan2.c b/lib/ultralib/src/vimodes/vimodempallan2.c index 2ff5fad..65817e7 100644 --- a/lib/ultralib/src/vimodes/vimodempallan2.c +++ b/lib/ultralib/src/vimodes/vimodempallan2.c @@ -3,33 +3,34 @@ #include "../io/viint.h" OSViMode osViModeMpalLan2 = { - OS_VI_MPAL_LAN2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 30, 5, 70), // burst - VSYNC(525), // vSync - HSYNC(3089, 4), // hSync - LEAP(3097, 3098), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_MPAL_LAN2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 30, 5, 70), // burst + VSYNC(525), // vSync + HSYNC(3089, 4), // hSync + LEAP(3097, 3098), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodempallpf1.c b/lib/ultralib/src/vimodes/vimodempallpf1.c index d89f113..7df1655 100644 --- a/lib/ultralib/src/vimodes/vimodempallpf1.c +++ b/lib/ultralib/src/vimodes/vimodempallpf1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeMpalLpf1 = { - OS_VI_MPAL_LPF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 30, 5, 70), // burst - VSYNC(524), // vSync - HSYNC(3088, 0), // hSync - LEAP(3100, 3100), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_MPAL_LPF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 30, 5, 70), // burst + VSYNC(524), // vSync + HSYNC(3088, 0), // hSync + LEAP(3100, 3100), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0.25), // yScale - HSTART(35, 509), // vStart - BURST(2, 2, 11, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0.75), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0.25), // yScale + HSTART(35, 509), // vStart + BURST(2, 2, 11, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0.75), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodempallpf2.c b/lib/ultralib/src/vimodes/vimodempallpf2.c index 2e5386b..285832e 100644 --- a/lib/ultralib/src/vimodes/vimodempallpf2.c +++ b/lib/ultralib/src/vimodes/vimodempallpf2.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeMpalLpf2 = { - OS_VI_MPAL_LPF2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 30, 5, 70), // burst - VSYNC(524), // vSync - HSYNC(3088, 0), // hSync - LEAP(3100, 3100), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_MPAL_LPF2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 30, 5, 70), // burst + VSYNC(524), // vSync + HSYNC(3088, 0), // hSync + LEAP(3100, 3100), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0.25), // yScale - HSTART(35, 509), // vStart - BURST(2, 2, 11, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0.75), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0.25), // yScale + HSTART(35, 509), // vStart + BURST(2, 2, 11, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0.75), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodempallpn1.c b/lib/ultralib/src/vimodes/vimodempallpn1.c index 420d5e6..8914794 100644 --- a/lib/ultralib/src/vimodes/vimodempallpn1.c +++ b/lib/ultralib/src/vimodes/vimodempallpn1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeMpalLpn1 = { - OS_VI_MPAL_LPN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 30, 5, 70), // burst - VSYNC(525), // vSync - HSYNC(3089, 4), // hSync - LEAP(3097, 3098), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_MPAL_LPN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 30, 5, 70), // burst + VSYNC(525), // vSync + HSYNC(3089, 4), // hSync + LEAP(3097, 3098), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodempallpn2.c b/lib/ultralib/src/vimodes/vimodempallpn2.c index 8195790..40f381c 100644 --- a/lib/ultralib/src/vimodes/vimodempallpn2.c +++ b/lib/ultralib/src/vimodes/vimodempallpn2.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeMpalLpn2 = { - OS_VI_MPAL_LPN2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_ANTIALIAS_MODE_3 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 30, 5, 70), // burst - VSYNC(525), // vSync - HSYNC(3089, 4), // hSync - LEAP(3097, 3098), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_MPAL_LPN2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_ANTIALIAS_MODE_3 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 30, 5, 70), // burst + VSYNC(525), // vSync + HSYNC(3089, 4), // hSync + LEAP(3097, 3098), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodentschaf1.c b/lib/ultralib/src/vimodes/vimodentschaf1.c index 071b330..e6ad8bc 100644 --- a/lib/ultralib/src/vimodes/vimodentschaf1.c +++ b/lib/ultralib/src/vimodes/vimodentschaf1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeNtscHaf1 = { - OS_VI_NTSC_HAF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(640), // width - BURST(57, 34, 5, 62), // burst - VSYNC(524), // vSync - HSYNC(3093, 0), // hSync - LEAP(3093, 3093), // leap - HSTART(108, 748), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_NTSC_HAF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(640), // width + BURST(57, 34, 5, 62), // burst + VSYNC(524), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(0.5, 0.5), // yScale - HSTART(35, 509), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(2560), // origin - SCALE(0.5, 0.5), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(0.5, 0.5), // yScale + HSTART(35, 509), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(2560), // origin + SCALE(0.5, 0.5), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodentschan1.c b/lib/ultralib/src/vimodes/vimodentschan1.c index 279bb83..14711e7 100644 --- a/lib/ultralib/src/vimodes/vimodentschan1.c +++ b/lib/ultralib/src/vimodes/vimodentschan1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeNtscHan1 = { - OS_VI_NTSC_HAN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(1280), // width - BURST(57, 34, 5, 62), // burst - VSYNC(524), // vSync - HSYNC(3093, 0), // hSync - LEAP(3093, 3093), // leap - HSTART(108, 748), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_NTSC_HAN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(1280), // width + BURST(57, 34, 5, 62), // burst + VSYNC(524), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(35, 509), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(2560), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(35, 509), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(2560), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodentschpf1.c b/lib/ultralib/src/vimodes/vimodentschpf1.c index 5ad8c2b..8f70311 100644 --- a/lib/ultralib/src/vimodes/vimodentschpf1.c +++ b/lib/ultralib/src/vimodes/vimodentschpf1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeNtscHpf1 = { - OS_VI_NTSC_HPF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(640), // width - BURST(57, 34, 5, 62), // burst - VSYNC(524), // vSync - HSYNC(3093, 0), // hSync - LEAP(3093, 3093), // leap - HSTART(108, 748), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_NTSC_HPF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(640), // width + BURST(57, 34, 5, 62), // burst + VSYNC(524), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(0.5, 0.5), // yScale - HSTART(35, 509), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(2560), // origin - SCALE(0.5, 0.5), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(0.5, 0.5), // yScale + HSTART(35, 509), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(2560), // origin + SCALE(0.5, 0.5), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodentschpf2.c b/lib/ultralib/src/vimodes/vimodentschpf2.c index b9720a5..8533e23 100644 --- a/lib/ultralib/src/vimodes/vimodentschpf2.c +++ b/lib/ultralib/src/vimodes/vimodentschpf2.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeNtscHpf2 = { - OS_VI_NTSC_HPF2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(640), // width - BURST(57, 34, 5, 62), // burst - VSYNC(524), // vSync - HSYNC(3093, 0), // hSync - LEAP(3093, 3093), // leap - HSTART(108, 748), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_NTSC_HPF2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(640), // width + BURST(57, 34, 5, 62), // burst + VSYNC(524), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(2560), // origin - SCALE(0.5, 0.5), // yScale - HSTART(35, 509), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(5120), // origin - SCALE(0.5, 0.5), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(2560), // origin + SCALE(0.5, 0.5), // yScale + HSTART(35, 509), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(5120), // origin + SCALE(0.5, 0.5), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodentschpn1.c b/lib/ultralib/src/vimodes/vimodentschpn1.c index ae8c0a9..f82e277 100644 --- a/lib/ultralib/src/vimodes/vimodentschpn1.c +++ b/lib/ultralib/src/vimodes/vimodentschpn1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeNtscHpn1 = { - OS_VI_NTSC_HPN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(1280), // width - BURST(57, 34, 5, 62), // burst - VSYNC(524), // vSync - HSYNC(3093, 0), // hSync - LEAP(3093, 3093), // leap - HSTART(108, 748), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_NTSC_HPN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(1280), // width + BURST(57, 34, 5, 62), // burst + VSYNC(524), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(35, 509), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(2560), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(35, 509), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(2560), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodentschpn2.c b/lib/ultralib/src/vimodes/vimodentschpn2.c index 5c73d69..d1b5974 100644 --- a/lib/ultralib/src/vimodes/vimodentschpn2.c +++ b/lib/ultralib/src/vimodes/vimodentschpn2.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeNtscHpn2 = { - OS_VI_NTSC_HPN2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_3 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(1280), // width - BURST(57, 34, 5, 62), // burst - VSYNC(524), // vSync - HSYNC(3093, 0), // hSync - LEAP(3093, 3093), // leap - HSTART(108, 748), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_NTSC_HPN2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_3 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(1280), // width + BURST(57, 34, 5, 62), // burst + VSYNC(524), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(2560), // origin - SCALE(1, 0), // yScale - HSTART(35, 509), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(5120), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(2560), // origin + SCALE(1, 0), // yScale + HSTART(35, 509), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(5120), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodentsclaf1.c b/lib/ultralib/src/vimodes/vimodentsclaf1.c index 31ff70b..fe12792 100644 --- a/lib/ultralib/src/vimodes/vimodentsclaf1.c +++ b/lib/ultralib/src/vimodes/vimodentsclaf1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeNtscLaf1 = { - OS_VI_NTSC_LAF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 34, 5, 62), // burst - VSYNC(524), // vSync - HSYNC(3093, 0), // hSync - LEAP(3093, 3093), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_NTSC_LAF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 34, 5, 62), // burst + VSYNC(524), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0.25), // yScale - HSTART(35, 509), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0.75), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0.25), // yScale + HSTART(35, 509), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0.75), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodentsclaf2.c b/lib/ultralib/src/vimodes/vimodentsclaf2.c index fd15f40..acf2c3c 100644 --- a/lib/ultralib/src/vimodes/vimodentsclaf2.c +++ b/lib/ultralib/src/vimodes/vimodentsclaf2.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeNtscLaf2 = { - OS_VI_NTSC_LAF2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 34, 5, 62), // burst - VSYNC(524), // vSync - HSYNC(3093, 0), // hSync - LEAP(3093, 3093), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_NTSC_LAF2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 34, 5, 62), // burst + VSYNC(524), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0.25), // yScale - HSTART(35, 509), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0.75), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0.25), // yScale + HSTART(35, 509), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0.75), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodentsclan1.c b/lib/ultralib/src/vimodes/vimodentsclan1.c index 9a052be..0092a00 100644 --- a/lib/ultralib/src/vimodes/vimodentsclan1.c +++ b/lib/ultralib/src/vimodes/vimodentsclan1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeNtscLan1 = { - OS_VI_NTSC_LAN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_1 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 34, 5, 62), // burst - VSYNC(525), // vSync - HSYNC(3093, 0), // hSync - LEAP(3093, 3093), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_NTSC_LAN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_1 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 34, 5, 62), // burst + VSYNC(525), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodentsclan2.c b/lib/ultralib/src/vimodes/vimodentsclan2.c index fa66af4..da2747b 100644 --- a/lib/ultralib/src/vimodes/vimodentsclan2.c +++ b/lib/ultralib/src/vimodes/vimodentsclan2.c @@ -3,33 +3,34 @@ #include "../io/viint.h" OSViMode osViModeNtscLan2 = { - OS_VI_NTSC_LAN2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 34, 5, 62), // burst - VSYNC(525), // vSync - HSYNC(3093, 0), // hSync - LEAP(3093, 3093), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_NTSC_LAN2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 34, 5, 62), // burst + VSYNC(525), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodentsclpf1.c b/lib/ultralib/src/vimodes/vimodentsclpf1.c index dd146b9..b6bb5e7 100644 --- a/lib/ultralib/src/vimodes/vimodentsclpf1.c +++ b/lib/ultralib/src/vimodes/vimodentsclpf1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeNtscLpf1 = { - OS_VI_NTSC_LPF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 34, 5, 62), // burst - VSYNC(524), // vSync - HSYNC(3093, 0), // hSync - LEAP(3093, 3093), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_NTSC_LPF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 34, 5, 62), // burst + VSYNC(524), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0.25), // yScale - HSTART(35, 509), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0.75), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0.25), // yScale + HSTART(35, 509), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0.75), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodentsclpf2.c b/lib/ultralib/src/vimodes/vimodentsclpf2.c index 6cda2a1..f3f82c7 100644 --- a/lib/ultralib/src/vimodes/vimodentsclpf2.c +++ b/lib/ultralib/src/vimodes/vimodentsclpf2.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeNtscLpf2 = { - OS_VI_NTSC_LPF2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 34, 5, 62), // burst - VSYNC(524), // vSync - HSYNC(3093, 0), // hSync - LEAP(3093, 3093), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_NTSC_LPF2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 34, 5, 62), // burst + VSYNC(524), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0.25), // yScale - HSTART(35, 509), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0.75), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0.25), // yScale + HSTART(35, 509), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0.75), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodentsclpn1.c b/lib/ultralib/src/vimodes/vimodentsclpn1.c index ff6172c..ecc68cb 100644 --- a/lib/ultralib/src/vimodes/vimodentsclpn1.c +++ b/lib/ultralib/src/vimodes/vimodentsclpn1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeNtscLpn1 = { - OS_VI_NTSC_LPN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 34, 5, 62), // burst - VSYNC(525), // vSync - HSYNC(3093, 0), // hSync - LEAP(3093, 3093), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_NTSC_LPN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 34, 5, 62), // burst + VSYNC(525), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodentsclpn2.c b/lib/ultralib/src/vimodes/vimodentsclpn2.c index 6340981..bce83b8 100644 --- a/lib/ultralib/src/vimodes/vimodentsclpn2.c +++ b/lib/ultralib/src/vimodes/vimodentsclpn2.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModeNtscLpn2 = { - OS_VI_NTSC_LPN2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_ANTIALIAS_MODE_3 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(57, 34, 5, 62), // burst - VSYNC(525), // vSync - HSYNC(3093, 0), // hSync - LEAP(3093, 3093), // leap - HSTART(108, 748), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_NTSC_LPN2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_ANTIALIAS_MODE_3 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(57, 34, 5, 62), // burst + VSYNC(525), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(37, 511), // vStart - BURST(4, 2, 14, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodepalhaf1.c b/lib/ultralib/src/vimodes/vimodepalhaf1.c index 791a918..3ff1394 100644 --- a/lib/ultralib/src/vimodes/vimodepalhaf1.c +++ b/lib/ultralib/src/vimodes/vimodepalhaf1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModePalHaf1 = { - OS_VI_PAL_HAF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(640), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_PAL_HAF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(640), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(0.5, 0.5), // yScale - HSTART(93, 567), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(2560), // origin - SCALE(0.5, 0.5), // yScale - HSTART(95, 569), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(0.5, 0.5), // yScale + HSTART(93, 567), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(2560), // origin + SCALE(0.5, 0.5), // yScale + HSTART(95, 569), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodepalhan1.c b/lib/ultralib/src/vimodes/vimodepalhan1.c index 947a0c1..3d32ba6 100644 --- a/lib/ultralib/src/vimodes/vimodepalhan1.c +++ b/lib/ultralib/src/vimodes/vimodepalhan1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModePalHan1 = { - OS_VI_PAL_HAN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(1280), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_PAL_HAN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(1280), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(93, 567), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(2560), // origin - SCALE(1, 0), // yScale - HSTART(95, 569), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(93, 567), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(2560), // origin + SCALE(1, 0), // yScale + HSTART(95, 569), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodepalhpf1.c b/lib/ultralib/src/vimodes/vimodepalhpf1.c index 6c9e915..bdd0871 100644 --- a/lib/ultralib/src/vimodes/vimodepalhpf1.c +++ b/lib/ultralib/src/vimodes/vimodepalhpf1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModePalHpf1 = { - OS_VI_PAL_HPF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(640), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_PAL_HPF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(640), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(0.5, 0.5), // yScale - HSTART(93, 567), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(2560), // origin - SCALE(0.5, 0.5), // yScale - HSTART(95, 569), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(0.5, 0.5), // yScale + HSTART(93, 567), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(2560), // origin + SCALE(0.5, 0.5), // yScale + HSTART(95, 569), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodepalhpf2.c b/lib/ultralib/src/vimodes/vimodepalhpf2.c index 62d162e..565ac4f 100644 --- a/lib/ultralib/src/vimodes/vimodepalhpf2.c +++ b/lib/ultralib/src/vimodes/vimodepalhpf2.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModePalHpf2 = { - OS_VI_PAL_HPF2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(640), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_PAL_HPF2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(640), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(2560), // origin - SCALE(0.5, 0.5), // yScale - HSTART(93, 567), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(5120), // origin - SCALE(0.5, 0.5), // yScale - HSTART(95, 569), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(2560), // origin + SCALE(0.5, 0.5), // yScale + HSTART(93, 567), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(5120), // origin + SCALE(0.5, 0.5), // yScale + HSTART(95, 569), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodepalhpn1.c b/lib/ultralib/src/vimodes/vimodepalhpn1.c index a06efac..a0c1ecc 100644 --- a/lib/ultralib/src/vimodes/vimodepalhpn1.c +++ b/lib/ultralib/src/vimodes/vimodepalhpn1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModePalHpn1 = { - OS_VI_PAL_HPN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(1280), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_PAL_HPN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(1280), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(93, 567), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(2560), // origin - SCALE(1, 0), // yScale - HSTART(95, 569), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(93, 567), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(2560), // origin + SCALE(1, 0), // yScale + HSTART(95, 569), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodepalhpn2.c b/lib/ultralib/src/vimodes/vimodepalhpn2.c index 0ed9dfc..d6e05b8 100644 --- a/lib/ultralib/src/vimodes/vimodepalhpn2.c +++ b/lib/ultralib/src/vimodes/vimodepalhpn2.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModePalHpn2 = { - OS_VI_PAL_HPN2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_3 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(1280), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(1, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_PAL_HPN2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_3 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(1280), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(1, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(2560), // origin - SCALE(1, 0), // yScale - HSTART(93, 567), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(5120), // origin - SCALE(1, 0), // yScale - HSTART(95, 569), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(2560), // origin + SCALE(1, 0), // yScale + HSTART(93, 567), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(5120), // origin + SCALE(1, 0), // yScale + HSTART(95, 569), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodepallaf1.c b/lib/ultralib/src/vimodes/vimodepallaf1.c index 1a43489..3d03857 100644 --- a/lib/ultralib/src/vimodes/vimodepallaf1.c +++ b/lib/ultralib/src/vimodes/vimodepallaf1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModePalLaf1 = { - OS_VI_PAL_LAF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_PAL_LAF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0.25), // yScale - HSTART(93, 567), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0.75), // yScale - HSTART(95, 569), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0.25), // yScale + HSTART(93, 567), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0.75), // yScale + HSTART(95, 569), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodepallaf2.c b/lib/ultralib/src/vimodes/vimodepallaf2.c index 89bd8a2..4fc496c 100644 --- a/lib/ultralib/src/vimodes/vimodepallaf2.c +++ b/lib/ultralib/src/vimodes/vimodepallaf2.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModePalLaf2 = { - OS_VI_PAL_LAF2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_PAL_LAF2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0.25), // yScale - HSTART(93, 567), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0.75), // yScale - HSTART(95, 569), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0.25), // yScale + HSTART(93, 567), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0.75), // yScale + HSTART(95, 569), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodepallan1.c b/lib/ultralib/src/vimodes/vimodepallan1.c index 3dd00be..22a893c 100644 --- a/lib/ultralib/src/vimodes/vimodepallan1.c +++ b/lib/ultralib/src/vimodes/vimodepallan1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModePalLan1 = { - OS_VI_PAL_LAN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_1 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(625), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_PAL_LAN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_1 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(625), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(95, 569), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(95, 569), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(95, 569), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(95, 569), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodepallan2.c b/lib/ultralib/src/vimodes/vimodepallan2.c index bc5a270..d32360b 100644 --- a/lib/ultralib/src/vimodes/vimodepallan2.c +++ b/lib/ultralib/src/vimodes/vimodepallan2.c @@ -3,33 +3,34 @@ #include "../io/viint.h" OSViMode osViModePalLan2 = { - OS_VI_PAL_LAN2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_DIVOT_ON | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(625), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_PAL_LAN2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(625), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(95, 569), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(95, 569), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(95, 569), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(95, 569), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodepallpf1.c b/lib/ultralib/src/vimodes/vimodepallpf1.c index 50828ce..37d68e4 100644 --- a/lib/ultralib/src/vimodes/vimodepallpf1.c +++ b/lib/ultralib/src/vimodes/vimodepallpf1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModePalLpf1 = { - OS_VI_PAL_LPF1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_PAL_LPF1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0.25), // yScale - HSTART(93, 567), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0.75), // yScale - HSTART(95, 569), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0.25), // yScale + HSTART(93, 567), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0.75), // yScale + HSTART(95, 569), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodepallpf2.c b/lib/ultralib/src/vimodes/vimodepallpf2.c index da2fead..c37ebe1 100644 --- a/lib/ultralib/src/vimodes/vimodepallpf2.c +++ b/lib/ultralib/src/vimodes/vimodepallpf2.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModePalLpf2 = { - OS_VI_PAL_LPF2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(624), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_PAL_LPF2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_SERRATE_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(624), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0.25), // yScale - HSTART(93, 567), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0.75), // yScale - HSTART(95, 569), // vStart - BURST(105, 2, 13, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0.25), // yScale + HSTART(93, 567), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0.75), // yScale + HSTART(95, 569), // vStart + BURST(105, 2, 13, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodepallpn1.c b/lib/ultralib/src/vimodes/vimodepallpn1.c index e27e74b..eafbe6b 100644 --- a/lib/ultralib/src/vimodes/vimodepallpn1.c +++ b/lib/ultralib/src/vimodes/vimodepallpn1.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModePalLpn1 = { - OS_VI_PAL_LPN1, // type - { // comRegs - VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_ANTIALIAS_MODE_2 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(625), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_PAL_LPN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_ANTIALIAS_MODE_2 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(625), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(95, 569), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(640), // origin - SCALE(1, 0), // yScale - HSTART(95, 569), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(95, 569), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(95, 569), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/vimodes/vimodepallpn2.c b/lib/ultralib/src/vimodes/vimodepallpn2.c index 76fa04d..49a26fd 100644 --- a/lib/ultralib/src/vimodes/vimodepallpn2.c +++ b/lib/ultralib/src/vimodes/vimodepallpn2.c @@ -3,33 +3,35 @@ #include "../io/viint.h" OSViMode osViModePalLpn2 = { - OS_VI_PAL_LPN2, // type - { // comRegs - VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | - VI_CTRL_ANTIALIAS_MODE_3 | VI_CTRL_PIXEL_ADV_3, // ctrl - WIDTH(320), // width - BURST(58, 30, 4, 69), // burst - VSYNC(625), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap - HSTART(128, 768), // hStart - SCALE(2, 0), // xScale - VCURRENT(0), // vCurrent + OS_VI_PAL_LPN2, // type + { + // comRegs + VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_ANTIALIAS_MODE_3 | + VI_CTRL_PIXEL_ADV_3, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(625), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent }, { // fldRegs - { // [0] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(95, 569), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - }, - { // [1] - ORIGIN(1280), // origin - SCALE(1, 0), // yScale - HSTART(95, 569), // vStart - BURST(107, 2, 9, 0), // vBurst - VINTR(2), // vIntr - } - } + { + // [0] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(95, 569), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }, + { + // [1] + ORIGIN(1280), // origin + SCALE(1, 0), // yScale + HSTART(95, 569), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + } }, }; diff --git a/lib/ultralib/src/voice/voicecheckresult.c b/lib/ultralib/src/voice/voicecheckresult.c index 6f615e1..5318652 100644 --- a/lib/ultralib/src/voice/voicecheckresult.c +++ b/lib/ultralib/src/voice/voicecheckresult.c @@ -1,23 +1,28 @@ #include "PR/os_internal.h" #include "io/controller.h" #include "PR/os_voice.h" +#include "voiceinternal.h" s32 __osVoiceCheckResult(OSVoiceHandle* hd, u8* stat) { s32 ret; u8 buf[2]; - if (ret = __osVoiceGetStatus(hd->__mq, hd->__channel, stat), ret == 0) { + ret = __osVoiceGetStatus(hd->__mq, hd->__channel, stat); + if (ret == 0) { if (*stat & 1) { ret = CONT_ERR_VOICE_NO_RESPONSE; - } else if (ret = __osVoiceContRead2(hd->__mq, hd->__channel, 0, buf), ret == 0) { - hd->cmd_status = buf[0] & 7; + } else { + ret = __osVoiceContRead2(hd->__mq, hd->__channel, 0, buf); + if (ret == 0) { + hd->cmd_status = buf[0] & 7; - if (buf[0] & 0x40) { - ret = CONT_ERR_VOICE_NO_RESPONSE; - } else { - ret = buf[1] << 8; + if (buf[0] & 0x40) { + ret = CONT_ERR_VOICE_NO_RESPONSE; + } else { + ret = buf[1] << 8; + } } } } return ret; -}
\ No newline at end of file +} diff --git a/lib/ultralib/src/voice/voicecheckword.c b/lib/ultralib/src/voice/voicecheckword.c index 25c51fa..05c2a59 100644 --- a/lib/ultralib/src/voice/voicecheckword.c +++ b/lib/ultralib/src/voice/voicecheckword.c @@ -10,102 +10,66 @@ s32 osVoiceCheckWord(u8* word) { for (k = 0; word[k] != 0; k += 2) { sjis = (word[k] << 8) + word[k + 1]; - if (((sjis != 'ー') && (sjis < 'ぁ')) - || ((sjis > 'ん') && (sjis < 'ァ')) - || (sjis == 0x837F) || (sjis > 'ヶ') - ) { + if (((sjis != 'ー') && (sjis < 'ぁ')) || ((sjis > 'ん') && (sjis < 'ァ')) || (sjis == 0x837F) || + (sjis > 'ヶ')) { ret = CONT_ERR_VOICE_WORD; - } else if ((k == 0) && ((sjis == 'ー') || (sjis == 'ん') || (sjis == 'っ') - || (sjis == 'ゎ') || (sjis == 'ン') || (sjis == 'ッ') - || (sjis == 'ヮ') || (sjis == 'ヵ') || (sjis == 'ヶ')) - ) { + } else if ((k == 0) && + ((sjis == 'ー') || (sjis == 'ん') || (sjis == 'っ') || (sjis == 'ゎ') || (sjis == 'ン') || + (sjis == 'ッ') || (sjis == 'ヮ') || (sjis == 'ヵ') || (sjis == 'ヶ'))) { ret = CONT_ERR_VOICE_WORD; - } else if (((sjis == 'ぁ') || (sjis == 'ァ')) - && (old != 'ふ') && (old != 'フ') && (old != 'ヴ') - ) { + } else if (((sjis == 'ぁ') || (sjis == 'ァ')) && (old != 'ふ') && (old != 'フ') && (old != 'ヴ')) { ret = CONT_ERR_VOICE_WORD; - } else if (((sjis == 'ぃ') || (sjis == 'ィ')) && (old != 'う') - && (old != 'て') && (old != 'で') && (old != 'ふ') - && (old != 'ウ') && (old != 'テ') && (old != 'デ') - && (old != 'フ') && (old != 'ヴ') - ) { + } else if (((sjis == 'ぃ') || (sjis == 'ィ')) && (old != 'う') && (old != 'て') && (old != 'で') && + (old != 'ふ') && (old != 'ウ') && (old != 'テ') && (old != 'デ') && (old != 'フ') && (old != 'ヴ')) { ret = CONT_ERR_VOICE_WORD; - } else if (((sjis == 'ぅ') || (sjis == 'ゥ')) - && (old != 'と') && (old != 'ど') - && (old != 'ふ') - && (old != 'ト') && (old != 'ド') - && (old != 'フ') && (old != 'ヴ') - ) { + } else if (((sjis == 'ぅ') || (sjis == 'ゥ')) && (old != 'と') && (old != 'ど') && (old != 'ふ') && + (old != 'ト') && (old != 'ド') && (old != 'フ') && (old != 'ヴ')) { ret = CONT_ERR_VOICE_WORD; - } else if (((sjis == 'ぇ') || (sjis == 'ェ')) - && (old != 'う') - && (old != 'し') && (old != 'じ') - && (old != 'ち') && (old != 'ぢ') - && (old != 'つ') && (old != 'ふ') && (old != 'ウ') - && (old != 'シ') && (old != 'ジ') - && (old != 'チ') && (old != 'ヂ') - && (old != 'ツ') && (old != 'フ') && (old != 'ヴ') - ) { + } else if (((sjis == 'ぇ') || (sjis == 'ェ')) && (old != 'う') && (old != 'し') && (old != 'じ') && + (old != 'ち') && (old != 'ぢ') && (old != 'つ') && (old != 'ふ') && (old != 'ウ') && (old != 'シ') && + (old != 'ジ') && (old != 'チ') && (old != 'ヂ') && (old != 'ツ') && (old != 'フ') && (old != 'ヴ')) { ret = CONT_ERR_VOICE_WORD; - } else if (((sjis == 'ぉ') || (sjis == 'ォ')) - && (old != 'う') && (old != 'ふ') && (old != 'ウ') && (old != 'フ') && (old != 'ヴ') - ) { + } else if (((sjis == 'ぉ') || (sjis == 'ォ')) && (old != 'う') && (old != 'ふ') && (old != 'ウ') && + (old != 'フ') && (old != 'ヴ')) { ret = CONT_ERR_VOICE_WORD; - } else if (((sjis == 'ゃ') || (sjis == 'ゅ') || (sjis == 'ょ') - || (sjis == 'ャ') || (sjis == 'ュ') || (sjis == 'ョ')) - && (old != 'き') && (old != 'し') && (old != 'ち') - && (old != 'に') && (old != 'ひ') && (old != 'み') - && (old != 'り') && (old != 'ぎ') && (old != 'じ') - && (old != 'ぢ') && (old != 'び') && (old != 'ぴ') - && (old != 'キ') && (old != 'シ') && (old != 'チ') - && (old != 'ニ') && (old != 'ヒ') && (old != 'ミ') - && (old != 'リ') && (old != 'ギ') && (old != 'ジ') - && (old != 'ヂ') && (old != 'ビ') && (old != 'ピ') - && (old != 'ヴ') - ) { + } else if (((sjis == 'ゃ') || (sjis == 'ゅ') || (sjis == 'ょ') || (sjis == 'ャ') || (sjis == 'ュ') || + (sjis == 'ョ')) && + (old != 'き') && (old != 'し') && (old != 'ち') && (old != 'に') && (old != 'ひ') && (old != 'み') && + (old != 'り') && (old != 'ぎ') && (old != 'じ') && (old != 'ぢ') && (old != 'び') && (old != 'ぴ') && + (old != 'キ') && (old != 'シ') && (old != 'チ') && (old != 'ニ') && (old != 'ヒ') && (old != 'ミ') && + (old != 'リ') && (old != 'ギ') && (old != 'ジ') && (old != 'ヂ') && (old != 'ビ') && (old != 'ピ') && + (old != 'ヴ')) { ret = CONT_ERR_VOICE_WORD; - } else if ((sjis == 'ー') - && ((old == 'ん') || (old == 'っ') - || (old == 'ン') || (old == 'ッ')) - ) { + } else if ((sjis == 'ー') && ((old == 'ん') || (old == 'っ') || (old == 'ン') || (old == 'ッ'))) { ret = CONT_ERR_VOICE_WORD; - } else if (((sjis == 'ん') || (sjis == 'ン')) - && ((old == 'ん') || (old == 'ン')) - ) { + } else if (((sjis == 'ん') || (sjis == 'ン')) && ((old == 'ん') || (old == 'ン'))) { ret = CONT_ERR_VOICE_WORD; - } else if (((old == 'っ') || (old == 'ッ')) - && ((sjis == 'ー') - || (sjis == 'あ') || (sjis == 'い') || (sjis == 'う') || (sjis == 'え') || (sjis == 'お') - || (sjis == 'な') || (sjis == 'に') || (sjis == 'ぬ') || (sjis == 'ね') || (sjis == 'の') - || (sjis == 'ま') || (sjis == 'み') || (sjis == 'む') || (sjis == 'め') || (sjis == 'も') - || (sjis == 'や') || (sjis == 'ゆ') || (sjis == 'よ') - || (sjis == 'ら') || (sjis == 'り') || (sjis == 'る') || (sjis == 'れ') || (sjis == 'ろ') - || (sjis == 'わ') || (sjis == 'ゐ') || (sjis == 'ゑ') || (sjis == 'を') - || (sjis == 'ん') - || (sjis == 'ぁ') || (sjis == 'ぃ') || (sjis == 'ぅ') || (sjis == 'ぇ') || (sjis == 'ぉ') - || (sjis == 'ゃ') || (sjis == 'ゅ') || (sjis == 'ょ') - || (sjis == 'っ') || (sjis == 'ゎ') + } else if (((old == 'っ') || (old == 'ッ')) && + ((sjis == 'ー') || (sjis == 'あ') || (sjis == 'い') || (sjis == 'う') || (sjis == 'え') || + (sjis == 'お') || (sjis == 'な') || (sjis == 'に') || (sjis == 'ぬ') || (sjis == 'ね') || + (sjis == 'の') || (sjis == 'ま') || (sjis == 'み') || (sjis == 'む') || (sjis == 'め') || + (sjis == 'も') || (sjis == 'や') || (sjis == 'ゆ') || (sjis == 'よ') || (sjis == 'ら') || + (sjis == 'り') || (sjis == 'る') || (sjis == 'れ') || (sjis == 'ろ') || (sjis == 'わ') || + (sjis == 'ゐ') || (sjis == 'ゑ') || (sjis == 'を') || (sjis == 'ん') || (sjis == 'ぁ') || + (sjis == 'ぃ') || (sjis == 'ぅ') || (sjis == 'ぇ') || (sjis == 'ぉ') || (sjis == 'ゃ') || + (sjis == 'ゅ') || (sjis == 'ょ') || (sjis == 'っ') || (sjis == 'ゎ') - || (sjis == 'ア') || (sjis == 'イ') || (sjis == 'ウ') || (sjis == 'エ') || (sjis == 'オ') - || (sjis == 'ナ') || (sjis == 'ニ') || (sjis == 'ヌ') || (sjis == 'ネ') || (sjis == 'ノ') - || (sjis == 'マ') || (sjis == 'ミ') || (sjis == 'ム') || (sjis == 'メ') || (sjis == 'モ') - || (sjis == 'ヤ') || (sjis == 'ユ') || (sjis == 'ヨ') - || (sjis == 'ラ') || (sjis == 'リ') || (sjis == 'ル') || (sjis == 'レ') || (sjis == 'ロ') - || (sjis == 'ワ') || (sjis == 'ヰ') || (sjis == 'ヱ') || (sjis == 'ヲ') - || (sjis == 'ン') - || (sjis == 'ァ') || (sjis == 'ィ') || (sjis == 'ゥ') || (sjis == 'ェ') || (sjis == 'ォ') - || (sjis == 'ャ') || (sjis == 'ュ') || (sjis == 'ョ') - || (sjis == 'ッ') || (sjis == 'ヮ') - ) - ) { + || (sjis == 'ア') || (sjis == 'イ') || (sjis == 'ウ') || (sjis == 'エ') || (sjis == 'オ') || + (sjis == 'ナ') || (sjis == 'ニ') || (sjis == 'ヌ') || (sjis == 'ネ') || (sjis == 'ノ') || + (sjis == 'マ') || (sjis == 'ミ') || (sjis == 'ム') || (sjis == 'メ') || (sjis == 'モ') || + (sjis == 'ヤ') || (sjis == 'ユ') || (sjis == 'ヨ') || (sjis == 'ラ') || (sjis == 'リ') || + (sjis == 'ル') || (sjis == 'レ') || (sjis == 'ロ') || (sjis == 'ワ') || (sjis == 'ヰ') || + (sjis == 'ヱ') || (sjis == 'ヲ') || (sjis == 'ン') || (sjis == 'ァ') || (sjis == 'ィ') || + (sjis == 'ゥ') || (sjis == 'ェ') || (sjis == 'ォ') || (sjis == 'ャ') || (sjis == 'ュ') || + (sjis == 'ョ') || (sjis == 'ッ') || (sjis == 'ヮ'))) { ret = CONT_ERR_VOICE_WORD; } if (ret != 0) { return ret; + } else { + old = sjis; } - - old = sjis; } if ((sjis == 'っ') || (sjis == 'ッ')) { diff --git a/lib/ultralib/src/voice/voicecleardictionary.c b/lib/ultralib/src/voice/voicecleardictionary.c index ef6388f..6ed1464 100644 --- a/lib/ultralib/src/voice/voicecleardictionary.c +++ b/lib/ultralib/src/voice/voicecleardictionary.c @@ -1,15 +1,17 @@ #include "PR/os_internal.h" #include "io/controller.h" #include "PR/os_voice.h" +#include "voiceinternal.h" s32 osVoiceClearDictionary(OSVoiceHandle* hd, u8 words) { s32 ret; u8 stat; u8 buf[4]; - ERRCK(__osVoiceGetStatus(hd->__mq, hd->__channel, &stat)); - - if (stat & 2) { + ret = __osVoiceGetStatus(hd->__mq, hd->__channel, &stat); + if (ret != 0) { + return ret; + } else if (stat & 2) { return CONT_ERR_VOICE_NO_RESPONSE; } @@ -25,4 +27,3 @@ s32 osVoiceClearDictionary(OSVoiceHandle* hd, u8 words) { return ret; } - diff --git a/lib/ultralib/src/voice/voicecontread2.c b/lib/ultralib/src/voice/voicecontread2.c index ae4b07b..3808c7b 100644 --- a/lib/ultralib/src/voice/voicecontread2.c +++ b/lib/ultralib/src/voice/voicecontread2.c @@ -3,11 +3,12 @@ #include "PR/os_voice.h" #include "voiceinternal.h" #include "io/controller_voice.h" +#include "io/siint.h" #define READ2FORMAT(p) ((__OSVoiceRead2Format*)(ptr)) s32 __osVoiceContRead2(OSMesgQueue* mq, int channel, u16 address, u8* buffer) { - s32 ret; + s32 ret = 0; u8 status; int i; u8* ptr; @@ -21,13 +22,11 @@ s32 __osVoiceContRead2(OSMesgQueue* mq, int channel, u16 address, u8* buffer) { ptr = (u8*)&__osPfsPifRam.ramarray; - if ((__osContLastCmd != CONT_CMD_READ2_VOICE) || (__osPfsLastChannel != channel)) { + if ((__osContLastCmd != CONT_CMD_READ2_VOICE) || ((u32)__osPfsLastChannel != channel)) { __osContLastCmd = CONT_CMD_READ2_VOICE; __osPfsLastChannel = channel; - for (i = 0; i < channel; i++) { - *ptr++ = 0; - } + for (i = 0; i < channel; i++) { *ptr++ = 0; } __osPfsPifRam.pifstatus = CONT_CMD_EXE; @@ -39,27 +38,28 @@ s32 __osVoiceContRead2(OSMesgQueue* mq, int channel, u16 address, u8* buffer) { ptr[sizeof(__OSVoiceRead2Format)] = CONT_CMD_END; } else { - ptr = (u8*)&__osPfsPifRam.ramarray + channel; + ptr += channel; } READ2FORMAT(ptr)->addrh = address >> 3; - READ2FORMAT(ptr)->addrl = __osContAddressCrc(address) | (address << 5); + READ2FORMAT(ptr)->addrl = (address << 5) | __osContAddressCrc(address); - __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); + ret = __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); osRecvMesg(mq, NULL, OS_MESG_BLOCK); - __osSiRawStartDma(OS_READ, &__osPfsPifRam); + ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam); osRecvMesg(mq, NULL, OS_MESG_BLOCK); ret = CHNL_ERR(*READ2FORMAT(ptr)); if (ret == 0) { - if (__osVoiceContDataCrc(&READ2FORMAT(ptr)->data, ARRLEN(READ2FORMAT(ptr)->data)) != READ2FORMAT(ptr)->datacrc) { + if (__osVoiceContDataCrc(READ2FORMAT(ptr)->data, ARRLEN(READ2FORMAT(ptr)->data)) != + READ2FORMAT(ptr)->datacrc) { ret = __osVoiceGetStatus(mq, channel, &status); if (ret != 0) { break; + } else { + ret = CONT_ERR_CONTRFAIL; } - - ret = CONT_ERR_CONTRFAIL; } else { bcopy(&READ2FORMAT(ptr)->data, buffer, ARRLEN(READ2FORMAT(ptr)->data)); } diff --git a/lib/ultralib/src/voice/voicecontread36.c b/lib/ultralib/src/voice/voicecontread36.c index a3c80a4..6c1677e 100644 --- a/lib/ultralib/src/voice/voicecontread36.c +++ b/lib/ultralib/src/voice/voicecontread36.c @@ -3,11 +3,12 @@ #include "PR/os_voice.h" #include "voiceinternal.h" #include "io/controller_voice.h" +#include "io/siint.h" #define READ36FORMAT(p) ((__OSVoiceRead36Format*)(ptr)) -s32 __osVoiceContRead36(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer) { - s32 ret; +s32 __osVoiceContRead36(OSMesgQueue* mq, int channel, u16 address, u8* buffer) { + s32 ret = 0; u8 status; s32 i; u8* ptr; @@ -19,13 +20,11 @@ s32 __osVoiceContRead36(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer) { ptr = (u8*)&__osPfsPifRam.ramarray; - if ((__osContLastCmd != CONT_CMD_READ36_VOICE) || (__osPfsLastChannel != channel)) { + if ((__osContLastCmd != CONT_CMD_READ36_VOICE) || ((u32)__osPfsLastChannel != channel)) { __osContLastCmd = CONT_CMD_READ36_VOICE; __osPfsLastChannel = channel; - for (i = 0; i < channel; i++) { - *ptr++ = 0; - } + for (i = 0; i < channel; i++) { *ptr++ = 0; } __osPfsPifRam.pifstatus = CONT_CMD_EXE; @@ -37,29 +36,30 @@ s32 __osVoiceContRead36(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer) { ptr[sizeof(__OSVoiceRead36Format)] = CONT_CMD_END; } else { - ptr = (u8*)&__osPfsPifRam + channel; + ptr += channel; } READ36FORMAT(ptr)->addrh = address >> 3; - READ36FORMAT(ptr)->addrl = __osContAddressCrc(address) | (address << 5); + READ36FORMAT(ptr)->addrl = (address << 5) | __osContAddressCrc(address); - __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); + ret = __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); osRecvMesg(mq, NULL, OS_MESG_BLOCK); - __osSiRawStartDma(OS_READ, &__osPfsPifRam); + ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam); osRecvMesg(mq, NULL, OS_MESG_BLOCK); ret = CHNL_ERR(*READ36FORMAT(ptr)); if (ret == 0) { - if (__osVoiceContDataCrc(&READ36FORMAT(ptr)->data, ARRLEN(READ36FORMAT(ptr)->data)) != READ36FORMAT(ptr)->datacrc) { + if (__osVoiceContDataCrc(READ36FORMAT(ptr)->data, ARRLEN(READ36FORMAT(ptr)->data)) != + READ36FORMAT(ptr)->datacrc) { ret = __osVoiceGetStatus(mq, channel, &status); if (ret != 0) { break; + } else { + ret = CONT_ERR_CONTRFAIL; } - - ret = CONT_ERR_CONTRFAIL; } else { - bcopy(&READ36FORMAT(ptr)->data, buffer, ARRLEN(READ36FORMAT(ptr)->data)); + bcopy(READ36FORMAT(ptr)->data, buffer, ARRLEN(READ36FORMAT(ptr)->data)); } } else { ret = CONT_ERR_NO_CONTROLLER; diff --git a/lib/ultralib/src/voice/voicecontrolgain.c b/lib/ultralib/src/voice/voicecontrolgain.c index ffb833c..95e9bb2 100644 --- a/lib/ultralib/src/voice/voicecontrolgain.c +++ b/lib/ultralib/src/voice/voicecontrolgain.c @@ -1,22 +1,28 @@ #include "PR/os_internal.h" #include "io/controller.h" #include "PR/os_voice.h" +#include "voiceinternal.h" -s32 __osVoiceSetADConverter(OSMesgQueue*, int ch, u8 cmd); - -s32 osVoiceControlGain(OSVoiceHandle *hd, s32 analog, s32 digital) { +s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital) { s32 ret; - u8 cmd = (u8) (analog == 0 ? 0x18 : 0x98); - static u8 digital_table[] = {0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0}; + u8 cmd; + + static u8 digital_table[] = { 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0 }; + + if (analog == 0) { + cmd = 0x18; + } else { + cmd = 0x98; + } + + ERRCK(__osVoiceSetADConverter(hd->__mq, hd->__channel, cmd)); - ERRCK(__osVoiceSetADConverter(hd->__mq,hd->__channel, cmd)); - if ((digital < ARRLEN(digital_table)) && (digital >= 0)) { cmd = digital_table[digital] + 2; } else { return CONT_ERR_INVALID; } - ERRCK(__osVoiceSetADConverter(hd->__mq,hd->__channel, cmd)); + ERRCK(__osVoiceSetADConverter(hd->__mq, hd->__channel, cmd)); return ret; } diff --git a/lib/ultralib/src/voice/voicecontwrite20.c b/lib/ultralib/src/voice/voicecontwrite20.c index 3842e3c..53b78eb 100644 --- a/lib/ultralib/src/voice/voicecontwrite20.c +++ b/lib/ultralib/src/voice/voicecontwrite20.c @@ -3,11 +3,12 @@ #include "PR/os_voice.h" #include "voiceinternal.h" #include "io/controller_voice.h" +#include "io/siint.h" #define WRITE20FORMAT(p) ((__OSVoiceWrite20Format*)(ptr)) s32 __osVoiceContWrite20(OSMesgQueue* mq, int channel, u16 address, u8* buffer) { - s32 ret; + s32 ret = 0; u8 status; int i; u8* ptr; @@ -22,13 +23,11 @@ s32 __osVoiceContWrite20(OSMesgQueue* mq, int channel, u16 address, u8* buffer) ptr = (u8*)&__osPfsPifRam; - if ((__osContLastCmd != CONT_CMD_WRITE20_VOICE) || (__osPfsLastChannel != channel)) { + if ((__osContLastCmd != CONT_CMD_WRITE20_VOICE) || ((u32)__osPfsLastChannel != channel)) { __osContLastCmd = CONT_CMD_WRITE20_VOICE; __osPfsLastChannel = channel; - for (i = 0; i < channel; i++) { - *ptr++ = 0; - } + for (i = 0; i < channel; i++) { *ptr++ = 0; } __osPfsPifRam.pifstatus = CONT_CMD_EXE; @@ -40,18 +39,18 @@ s32 __osVoiceContWrite20(OSMesgQueue* mq, int channel, u16 address, u8* buffer) ptr[sizeof(__OSVoiceWrite20Format)] = CONT_CMD_END; } else { - ptr = (u8*)&__osPfsPifRam.ramarray + channel; + ptr += channel; } WRITE20FORMAT(ptr)->addrh = address >> 3; - WRITE20FORMAT(ptr)->addrl = __osContAddressCrc(address) | (address << 5); + WRITE20FORMAT(ptr)->addrl = (address << 5) | __osContAddressCrc(address); bcopy(buffer, &WRITE20FORMAT(ptr)->data, 20); - __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); + ret = __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); crc = __osVoiceContDataCrc(buffer, 20); osRecvMesg(mq, NULL, OS_MESG_BLOCK); - __osSiRawStartDma(OS_READ, &__osPfsPifRam); + ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam); osRecvMesg(mq, NULL, OS_MESG_BLOCK); ret = (WRITE20FORMAT(ptr)->rxsize & 0xC0) >> 4; @@ -61,9 +60,9 @@ s32 __osVoiceContWrite20(OSMesgQueue* mq, int channel, u16 address, u8* buffer) ret = __osVoiceGetStatus(mq, channel, &status); if (ret != 0) { break; + } else { + ret = CONT_ERR_CONTRFAIL; } - - ret = CONT_ERR_CONTRFAIL; } } else { ret = CONT_ERR_NO_CONTROLLER; diff --git a/lib/ultralib/src/voice/voicecontwrite4.c b/lib/ultralib/src/voice/voicecontwrite4.c index c2af86d..949952c 100644 --- a/lib/ultralib/src/voice/voicecontwrite4.c +++ b/lib/ultralib/src/voice/voicecontwrite4.c @@ -3,11 +3,12 @@ #include "PR/os_voice.h" #include "voiceinternal.h" #include "io/controller_voice.h" +#include "io/siint.h" #define WRITE4FORMAT(p) ((__OSVoiceWrite4Format*)(ptr)) -s32 __osVoiceContWrite4(OSMesgQueue* mq, int channel, u16 address, u8 dst[4]) { - s32 ret; +s32 __osVoiceContWrite4(OSMesgQueue* mq, int channel, u16 address, u8* buffer) { + s32 ret = 0; u8 status; int i; u8* ptr; @@ -20,13 +21,11 @@ s32 __osVoiceContWrite4(OSMesgQueue* mq, int channel, u16 address, u8 dst[4]) { ptr = (u8*)&__osPfsPifRam; - if ((__osContLastCmd != CONT_CMD_WRITE4_VOICE) || (__osPfsLastChannel != channel)) { + if ((__osContLastCmd != CONT_CMD_WRITE4_VOICE) || ((u32)__osPfsLastChannel != channel)) { __osContLastCmd = CONT_CMD_WRITE4_VOICE; __osPfsLastChannel = channel; - for (i = 0; i < channel; i++) { - *ptr++ = 0; - } + for (i = 0; i < channel; i++) { *ptr++ = 0; } __osPfsPifRam.pifstatus = CONT_CMD_EXE; @@ -38,18 +37,18 @@ s32 __osVoiceContWrite4(OSMesgQueue* mq, int channel, u16 address, u8 dst[4]) { ptr[sizeof(__OSVoiceWrite4Format)] = CONT_CMD_END; } else { - ptr = (u8*)&__osPfsPifRam + channel; + ptr += channel; } WRITE4FORMAT(ptr)->addrh = address >> 3; - WRITE4FORMAT(ptr)->addrl = __osContAddressCrc(address) | (address << 5); + WRITE4FORMAT(ptr)->addrl = (address << 5) | __osContAddressCrc(address); - bcopy(dst, &WRITE4FORMAT(ptr)->data, 4); + bcopy(buffer, &WRITE4FORMAT(ptr)->data, 4); - __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); - crc = __osVoiceContDataCrc(dst, 4); + ret = __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); + crc = __osVoiceContDataCrc(buffer, 4); osRecvMesg(mq, NULL, OS_MESG_BLOCK); - __osSiRawStartDma(OS_READ, &__osPfsPifRam); + ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam); osRecvMesg(mq, NULL, OS_MESG_BLOCK); ret = (WRITE4FORMAT(ptr)->rxsize & 0xC0) >> 4; @@ -59,9 +58,9 @@ s32 __osVoiceContWrite4(OSMesgQueue* mq, int channel, u16 address, u8 dst[4]) { ret = __osVoiceGetStatus(mq, channel, &status); if (ret != 0) { break; + } else { + ret = CONT_ERR_CONTRFAIL; } - - ret = CONT_ERR_CONTRFAIL; } } else { ret = CONT_ERR_NO_CONTROLLER; diff --git a/lib/ultralib/src/voice/voicecountsyllables.c b/lib/ultralib/src/voice/voicecountsyllables.c index 89b4c63..b0112ef 100644 --- a/lib/ultralib/src/voice/voicecountsyllables.c +++ b/lib/ultralib/src/voice/voicecountsyllables.c @@ -6,7 +6,7 @@ // Use this function to determine the semisyllable count before adding a word with osVoiceSetWord, // to properly see whether it will fit. -void osVoiceCountSyllables(u8 *data, u32 *syllable) { +void osVoiceCountSyllables(u8* data, u32* syllable) { s32 k; u16 sjis; u16 old; @@ -14,22 +14,20 @@ void osVoiceCountSyllables(u8 *data, u32 *syllable) { old = 0; *syllable = 1; for (k = 0; data[k] != 0; k += 2) { - sjis = data[k + 1] + (data[k] << 8); - if ((sjis == 'あ') || (sjis == 'い') || (sjis == 'う') || (sjis == 'え') || (sjis == 'お') - || (sjis == 'ア') || (sjis == 'イ') || (sjis == 'ウ') || (sjis == 'エ') || (sjis == 'オ') - ) { + sjis = (data[k] << 8) + data[k + 1]; + if ((sjis == 'あ') || (sjis == 'い') || (sjis == 'う') || (sjis == 'え') || (sjis == 'お') || (sjis == 'ア') || + (sjis == 'イ') || (sjis == 'ウ') || (sjis == 'エ') || (sjis == 'オ')) { if (k == 0) { *syllable += 2; } else { *syllable += 1; } - } else if ((sjis == 'か') || (sjis == 'き') || (sjis == 'く') || (sjis == 'け') || (sjis == 'こ') - || (sjis == 'た') || (sjis == 'ち') || (sjis == 'つ') || (sjis == 'て') || (sjis == 'と') - || (sjis == 'ぱ') || (sjis == 'ぴ') || (sjis == 'ぷ') || (sjis == 'ぺ') || (sjis == 'ぽ') - || (sjis == 'カ') || (sjis == 'キ') || (sjis == 'ク') || (sjis == 'ケ') || (sjis == 'コ') - || (sjis == 'タ') || (sjis == 'チ') || (sjis == 'ツ') || (sjis == 'テ') || (sjis == 'ト') - || (sjis == 'パ') || (sjis == 'ピ') || (sjis == 'プ') || (sjis == 'ペ') || (sjis == 'ポ') - ) { + } else if ((sjis == 'か') || (sjis == 'き') || (sjis == 'く') || (sjis == 'け') || (sjis == 'こ') || + (sjis == 'た') || (sjis == 'ち') || (sjis == 'つ') || (sjis == 'て') || (sjis == 'と') || + (sjis == 'ぱ') || (sjis == 'ぴ') || (sjis == 'ぷ') || (sjis == 'ぺ') || (sjis == 'ぽ') || + (sjis == 'カ') || (sjis == 'キ') || (sjis == 'ク') || (sjis == 'ケ') || (sjis == 'コ') || + (sjis == 'タ') || (sjis == 'チ') || (sjis == 'ツ') || (sjis == 'テ') || (sjis == 'ト') || + (sjis == 'パ') || (sjis == 'ピ') || (sjis == 'プ') || (sjis == 'ペ') || (sjis == 'ポ')) { if (k == 0) { *syllable += 2; } else if ((old == 'っ') || (old == 'ッ')) { @@ -37,16 +35,14 @@ void osVoiceCountSyllables(u8 *data, u32 *syllable) { } else { *syllable += 3; } - } else if ((sjis == 'ぁ') || (sjis == 'ぃ') || (sjis == 'ぅ') || (sjis == 'ぇ') || (sjis == 'ぉ') - || (sjis == 'ゃ') || (sjis == 'ゅ') || (sjis == 'ょ') || (sjis == 'ゎ') + } else if ((sjis == 'ぁ') || (sjis == 'ぃ') || (sjis == 'ぅ') || (sjis == 'ぇ') || (sjis == 'ぉ') || + (sjis == 'ゃ') || (sjis == 'ゅ') || (sjis == 'ょ') || (sjis == 'ゎ') - || (sjis == 'ァ') || (sjis == 'ィ') || (sjis == 'ゥ') || (sjis == 'ェ') || (sjis == 'ォ') - || (sjis == 'ャ') || (sjis == 'ュ') || (sjis == 'ョ') || (sjis == 'ヮ') - || (sjis == 'ヵ') || (sjis == 'ヶ') - ) { - if ((old == 'あ') || (old == 'い') || (old == 'う') || (old == 'え') || (old == 'お') - || (old == 'ア') || (old == 'イ') || (old == 'ウ') || (old == 'エ') || (old == 'オ') - ) { + || (sjis == 'ァ') || (sjis == 'ィ') || (sjis == 'ゥ') || (sjis == 'ェ') || (sjis == 'ォ') || + (sjis == 'ャ') || (sjis == 'ュ') || (sjis == 'ョ') || (sjis == 'ヮ') || (sjis == 'ヵ') || + (sjis == 'ヶ')) { + if ((old == 'あ') || (old == 'い') || (old == 'う') || (old == 'え') || (old == 'お') || (old == 'ア') || + (old == 'イ') || (old == 'ウ') || (old == 'エ') || (old == 'オ')) { *syllable += 1; } } else if ((sjis == 'ん') || (sjis == 'ー') || (sjis == 'っ') || (sjis == 'ン') || (sjis == 'ッ')) { diff --git a/lib/ultralib/src/voice/voicecrc.c b/lib/ultralib/src/voice/voicecrc.c index 95741e6..56b4838 100644 --- a/lib/ultralib/src/voice/voicecrc.c +++ b/lib/ultralib/src/voice/voicecrc.c @@ -6,35 +6,35 @@ #define VOICE_CRC_GENERATOR 0x85 u8 __osVoiceContDataCrc(u8* data, u32 length) { - s32 ret = 0; + s32 temp = 0; u32 i; u32 j; - for (j = length; j != 0; j--, data++) { - // Loop over each i in the j starting with most significant - for (i = (1 << (VOICE_CRC_LENGTH - 1)); i != 0; i >>= 1) { - ret <<= 1; - if (*data & i) { - if (ret & (1 << VOICE_CRC_LENGTH)) { - // Same as ret++; ret ^= 0x85 since last i always 0 after the shift - ret ^= VOICE_CRC_GENERATOR - 1; + for (i = length; i != 0; i--) { + // Loop over each j in the i starting with most significant + for (j = (1 << (VOICE_CRC_LENGTH - 1)); j != 0; j >>= 1) { + temp <<= 1; + if (*data & j) { + if (temp & (1 << VOICE_CRC_LENGTH)) { + // Same as temp++; temp ^= 0x85 since last j always 0 after the shift + temp ^= VOICE_CRC_GENERATOR - 1; } else { - ret++; + temp++; } - } else if (ret & (1 << VOICE_CRC_LENGTH)) { - ret ^= VOICE_CRC_GENERATOR; + } else if (temp & (1 << VOICE_CRC_LENGTH)) { + temp ^= VOICE_CRC_GENERATOR; } } + data++; } - // Act like a j of zeros is appended to data + // Act like a i of zeros is appended to data do { - ret <<= 1; - if (ret & (1 << VOICE_CRC_LENGTH)) { - ret ^= VOICE_CRC_GENERATOR; + temp <<= 1; + if (temp & (1 << VOICE_CRC_LENGTH)) { + temp ^= VOICE_CRC_GENERATOR; } - j++; - } while (j < VOICE_CRC_LENGTH); + } while (++i < VOICE_CRC_LENGTH); // Discarding the excess is done automatically by the return type - return ret; -}
\ No newline at end of file + return temp; +} diff --git a/lib/ultralib/src/voice/voicegetreaddata.c b/lib/ultralib/src/voice/voicegetreaddata.c index 5627846..d2f5063 100644 --- a/lib/ultralib/src/voice/voicegetreaddata.c +++ b/lib/ultralib/src/voice/voicegetreaddata.c @@ -29,7 +29,7 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* micdata) { case 2: hd->__mode = 2; - ERRCK(__osVoiceGetStatus(hd->__mq, hd->__channel, &stat)) + ERRCK(__osVoiceGetStatus(hd->__mq, hd->__channel, &stat)); if (stat & 2) { return CONT_ERR_VOICE_NO_RESPONSE; diff --git a/lib/ultralib/src/voice/voicegetstatus.c b/lib/ultralib/src/voice/voicegetstatus.c index 8d33f31..966e539 100644 --- a/lib/ultralib/src/voice/voicegetstatus.c +++ b/lib/ultralib/src/voice/voicegetstatus.c @@ -2,6 +2,7 @@ #include "io/controller.h" #include "PR/os_voice.h" #include "voiceinternal.h" +#include "io/siint.h" s32 __osVoiceGetStatus(OSMesgQueue* mq, s32 port, u8* status) { __OSContRequesFormatShort header; @@ -37,7 +38,7 @@ s32 __osVoiceGetStatus(OSMesgQueue* mq, s32 port, u8* status) { header = *((__OSContRequesFormatShort*)ptr); - ret = CHNL_ERR(header); + ret = (u8)CHNL_ERR(header); *status = header.status; if (ret == 0) { diff --git a/lib/ultralib/src/voice/voiceinit.c b/lib/ultralib/src/voice/voiceinit.c index a60f943..5074a84 100644 --- a/lib/ultralib/src/voice/voiceinit.c +++ b/lib/ultralib/src/voice/voiceinit.c @@ -1,13 +1,14 @@ #include "PR/os_internal.h" #include "io/controller.h" #include "PR/os_voice.h" +#include "voiceinternal.h" s32 osVoiceInit(OSMesgQueue* mq, OSVoiceHandle* handle, int channel) { s32 ret; s32 i; u8 stat = 0; u8 buf[4]; - static u8 cmd[] = {0x1E, 0x6E, 0x08, 0x56, 0x03}; + static u8 cmd[] = { 0x1E, 0x6E, 0x08, 0x56, 0x03 }; handle->__channel = channel; handle->__mq = mq; @@ -15,7 +16,8 @@ s32 osVoiceInit(OSMesgQueue* mq, OSVoiceHandle* handle, int channel) { ERRCK(__osVoiceGetStatus(mq, channel, &stat)); - if (__osContChannelReset(mq, channel) != 0) { + ret = __osContChannelReset(mq, channel); + if (ret != 0) { return CONT_ERR_CONTRFAIL; } @@ -30,7 +32,7 @@ s32 osVoiceInit(OSMesgQueue* mq, OSVoiceHandle* handle, int channel) { *(u32*)buf = 0x100; ERRCK(__osVoiceContWrite4(mq, channel, 0, buf)); - + ret = __osVoiceCheckResult(handle, &stat); if (ret & 0xFF00) { ret = CONT_ERR_INVALID; diff --git a/lib/ultralib/src/voice/voiceinternal.h b/lib/ultralib/src/voice/voiceinternal.h index 899c150..8dc6299 100644 --- a/lib/ultralib/src/voice/voiceinternal.h +++ b/lib/ultralib/src/voice/voiceinternal.h @@ -4,7 +4,15 @@ // Various prototypes and externs that don't show up in os_voice.h extern s32 __osPfsLastChannel; -u8 __osVoiceContDataCrc(u8* data, u32 length); +s32 __osContChannelReset(OSMesgQueue* mq, int channel); + s32 __osVoiceCheckResult(OSVoiceHandle* hd, u8* stat); +s32 __osVoiceContRead2(OSMesgQueue* mq, int channel, u16 address, u8* buffer); +s32 __osVoiceContRead36(OSMesgQueue* mq, int channel, u16 address, u8* buffer); +s32 __osVoiceContWrite4(OSMesgQueue* mq, int channel, u16 address, u8* buffer); +s32 __osVoiceContWrite20(OSMesgQueue* mq, int channel, u16 address, u8* buffer); +u8 __osVoiceContDataCrc(u8* data, u32 length); +s32 __osVoiceGetStatus(OSMesgQueue* mq, s32 port, u8* status); +s32 __osVoiceSetADConverter(OSMesgQueue*, s32 channel, u8 cmd); #endif diff --git a/lib/ultralib/src/voice/voicemaskdictionary.c b/lib/ultralib/src/voice/voicemaskdictionary.c index a017e3d..39db7ac 100644 --- a/lib/ultralib/src/voice/voicemaskdictionary.c +++ b/lib/ultralib/src/voice/voicemaskdictionary.c @@ -4,15 +4,16 @@ #include "voiceinternal.h" s32 osVoiceMaskDictionary(OSVoiceHandle* hd, u8* pattern, int size) { - s32 ret; + s32 ret = 0; s32 i; s32 j; u8 stat; u8 buf[20]; - ERRCK(__osVoiceGetStatus(hd->__mq, hd->__channel, &stat)); - - if (stat & 2) { + ret = __osVoiceGetStatus(hd->__mq, hd->__channel, &stat); + if (ret != 0) { + return ret; + } else if (stat & 2) { return CONT_ERR_VOICE_NO_RESPONSE; } @@ -35,7 +36,7 @@ s32 osVoiceMaskDictionary(OSVoiceHandle* hd, u8* pattern, int size) { buf[ARRLEN(buf) - 1] = 0; } - ret = __osVoiceContWrite20(hd->__mq, hd->__channel, 0, &buf); + ret = __osVoiceContWrite20(hd->__mq, hd->__channel, 0, (u8*)&buf); if (ret == 0) { ret = __osVoiceCheckResult(hd, &stat); if (ret & 0xFF00) { diff --git a/lib/ultralib/src/voice/voicesetadconverter.c b/lib/ultralib/src/voice/voicesetadconverter.c index 2287c0d..7dcbaf0 100644 --- a/lib/ultralib/src/voice/voicesetadconverter.c +++ b/lib/ultralib/src/voice/voicesetadconverter.c @@ -3,11 +3,12 @@ #include "PR/os_voice.h" #include "voiceinternal.h" #include "io/controller_voice.h" +#include "io/siint.h" #define SWRITEFORMAT(p) ((__OSVoiceSWriteFormat*)(p)) s32 __osVoiceSetADConverter(OSMesgQueue* mq, s32 channel, u8 data) { - s32 ret; + s32 ret = 0; int i; u8* ptr; u8 status; @@ -23,9 +24,7 @@ s32 __osVoiceSetADConverter(OSMesgQueue* mq, s32 channel, u8 data) { __osContLastCmd = CONT_CMD_SWRITE_VOICE; __osPfsLastChannel = channel; - for (i = 0; i < channel; i++) { - *ptr++ = 0; - } + for (i = 0; i < channel; i++) { *ptr++ = 0; } __osPfsPifRam.pifstatus = CONT_CMD_EXE; @@ -36,15 +35,15 @@ s32 __osVoiceSetADConverter(OSMesgQueue* mq, s32 channel, u8 data) { ptr[sizeof(__OSVoiceSWriteFormat)] = CONT_CMD_END; } else { - ptr = (u8*)&__osPfsPifRam + channel; + ptr += channel; } SWRITEFORMAT(ptr)->data = data; - SWRITEFORMAT(ptr)->scrc = __osContAddressCrc(data * 8); + SWRITEFORMAT(ptr)->scrc = __osContAddressCrc(data << 3); - __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); + ret = __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); osRecvMesg(mq, NULL, OS_MESG_BLOCK); - __osSiRawStartDma(OS_READ, &__osPfsPifRam); + ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam); osRecvMesg(mq, NULL, OS_MESG_BLOCK); ret = CHNL_ERR(*SWRITEFORMAT(ptr)); @@ -54,9 +53,9 @@ s32 __osVoiceSetADConverter(OSMesgQueue* mq, s32 channel, u8 data) { ret = __osVoiceGetStatus(mq, channel, &status); if (ret != 0) { break; + } else { + ret = CONT_ERR_CONTRFAIL; } - - ret = CONT_ERR_CONTRFAIL; } } else { ret = CONT_ERR_NO_CONTROLLER; diff --git a/lib/ultralib/src/voice/voicesetword.c b/lib/ultralib/src/voice/voicesetword.c index 9a7ed6f..7969fae 100644 --- a/lib/ultralib/src/voice/voicesetword.c +++ b/lib/ultralib/src/voice/voicesetword.c @@ -1,22 +1,32 @@ #include "PR/os_internal.h" #include "io/controller.h" #include "PR/os_voice.h" +#include "voiceinternal.h" -s32 osVoiceSetWord(OSVoiceHandle *hd, u8 *word) { +s32 osVoiceSetWord(OSVoiceHandle* hd, u8* word) { s32 j; s32 k; s32 ret; u8 stat; u8 buf[40]; - ERRCK(__osVoiceGetStatus(hd->__mq, hd->__channel, &stat)); - if (stat & 2) { + ret = __osVoiceGetStatus(hd->__mq, hd->__channel, &stat); + if (ret != 0) { + return ret; + } else if (stat & 2) { return CONT_ERR_VOICE_NO_RESPONSE; } + for (k = 0; word[k] != 0; k += 2) { ; } +#ifndef NDEBUG + if (k >= 34) { + return CONT_ERR_VOICE_WORD; + } +#endif + bzero(buf, ARRLEN(buf)); for (j = 0; j < k; j += 2) { diff --git a/lib/ultralib/src/voice/voicestartreaddata.c b/lib/ultralib/src/voice/voicestartreaddata.c index 0f9fc73..ea83da0 100644 --- a/lib/ultralib/src/voice/voicestartreaddata.c +++ b/lib/ultralib/src/voice/voicestartreaddata.c @@ -8,9 +8,10 @@ s32 osVoiceStartReadData(OSVoiceHandle* hd) { u8 stat; u8 temp[4]; - - ERRCK(__osVoiceGetStatus(hd->__mq, hd->__channel, &stat)); - if (stat & 2) { + ret = __osVoiceGetStatus(hd->__mq, hd->__channel, &stat); + if (ret != 0) { + return ret; + } else if (stat & 2) { return CONT_ERR_VOICE_NO_RESPONSE; } @@ -32,4 +33,4 @@ s32 osVoiceStartReadData(OSVoiceHandle* hd) { } return ret; -}
\ No newline at end of file +} diff --git a/lib/ultralib/src/voice/voicestopreaddata.c b/lib/ultralib/src/voice/voicestopreaddata.c index e5b97ca..b0f9cba 100644 --- a/lib/ultralib/src/voice/voicestopreaddata.c +++ b/lib/ultralib/src/voice/voicestopreaddata.c @@ -9,9 +9,10 @@ s32 osVoiceStopReadData(OSVoiceHandle* hd) { u8 stat; u8 temp[4]; - ERRCK(__osVoiceGetStatus(hd->__mq, hd->__channel, &stat)); - - if (stat & 2) { + ret = __osVoiceGetStatus(hd->__mq, hd->__channel, &stat); + if (ret != 0) { + return ret; + } else if (stat & 2) { return CONT_ERR_VOICE_NO_RESPONSE; } @@ -39,6 +40,9 @@ s32 osVoiceStopReadData(OSVoiceHandle* hd) { i++; } while ((ret == CONT_ERR_VOICE_NO_RESPONSE) && (i < 20)); } + if (i >= 20) { + ret == CONT_ERR_VOICE_NO_RESPONSE; + } return ret; -}
\ No newline at end of file +} diff --git a/lib/ultralib/tools/Makefile b/lib/ultralib/tools/Makefile index f7bff84..8b5487e 100644 --- a/lib/ultralib/tools/Makefile +++ b/lib/ultralib/tools/Makefile @@ -1,11 +1,17 @@ .PHONY: all clean distclean + +# GCC GCC_DIR := gcc AR := $(GCC_DIR)/ar GCC-2.7.2 := $(GCC_DIR)/gcc STRIP-2.7 := $(GCC_DIR)/strip-2.7 -all: $(AR) $(GCC-2.7.2) $(STRIP-2.7) +# IDO +IDO_DIR := ido +IDO-5.3 := $(IDO_DIR)/cc + +all: $(AR) $(GCC-2.7.2) $(STRIP-2.7) $(IDO-5.3) $(AR): | $(GCC_DIR) wget https://github.com/decompals/mips-binutils-2.6/releases/download/main/binutils-2.6-linux.tar.gz @@ -25,6 +31,16 @@ $(STRIP-2.7): | $(GCC_DIR) $(GCC_DIR): mkdir -p $@ +$(IDO-5.3): | $(IDO_DIR) + wget https://github.com/decompals/ido-static-recomp/releases/latest/download/ido-5.3-recomp-ubuntu-20.04.tar.gz + tar xf ido-5.3-recomp-ubuntu-20.04.tar.gz -C $(IDO_DIR) + $(RM) ido-5.3-recomp-ubuntu-20.04.tar.gz + +$(IDO_DIR): + mkdir -p $@ + clean: -distclean: clean $(RM) -rf $(GCC_DIR) + $(RM) -rf $(IDO_DIR) + +distclean: clean diff --git a/lib/ultralib/tools/ar.py b/lib/ultralib/tools/ar.py new file mode 100755 index 0000000..0f3e574 --- /dev/null +++ b/lib/ultralib/tools/ar.py @@ -0,0 +1,476 @@ +#!/usr/bin/env python3 +# +# ar +# + +from genericpath import isfile +import os, struct, time +from dataclasses import dataclass +from libelf import ElfFile, SB_GLOBAL, SHN_UND + +class Archive: + @dataclass + class ArchiveFileRecord: + """ + AR file headers + data + + Offset Length Name Format + 0 16 File identifier ASCII + 16 12 File modification timestamp (in seconds) Decimal + 28 6 Owner ID Decimal + 34 6 Group ID Decimal + 40 8 File mode (type and permission) Octal + 48 10 File size in bytes Decimal + 58 2 Ending characters 0x60 0x0A + """ + name : str + time : int + uid : int + gid : int + mode : int + size : int + data : bytes + + def __init__(self): + self.files = [] # List[ArchiveFileRecord] + self.armap_entries = None + self.time = int(time.time()) + + def add_data(self, name, time, uid, gid, mode, size, data): + self.files.append(Archive.ArchiveFileRecord(name, time, uid, gid, mode, size, data)) + + def add_file(self, file_path): + if not os.path.isfile(file_path): + print(f"Error: No file named {file_path}") + return + + st = os.stat(file_path) + name = os.path.basename(file_path) + time = int(st.st_mtime) + uid = st.st_uid + gid = st.st_gid + mode = st.st_mode + size = st.st_size + + data = None + with open(file_path, "rb") as infile: + data = bytes(infile.read()) + + self.add_data(name, time, uid, gid, mode, size, data) + + def add_ar(self, file_path): + for file in Archive.from_file(file_path).files: + self.add_data(file) + + def build_image(self): + def add_bin(ba, bin): + for b in bin: + ba.append(b) + + def add_str(ba, s, pad_to_len=-1): + if pad_to_len != -1: + s = f"{s:{pad_to_len}}" + s = s.encode("ASCII") + for c in s: + ba.append(c) + + def add_pad(ba): + if len(ba) % 2 != 0: + ba.append(0) + + def add_ar_hdr(ba, name, time, uid, gid, mode, length): + add_str(ba, name, 16) + add_str(ba, str(time), 12) + add_str(ba, str(uid), 6) + add_str(ba, str(gid), 6) + add_str(ba, oct(mode)[2:], 8) + add_str(ba, str(length), 10) + add_str(ba, "`\n") + + b = bytearray() + + # MAGIC + + add_str(b, "!<arch>\n") + + # ARMAP + + armap_data= bytearray() + + armap_entries_files = [] + + num_entries = 0 + armap_size = 4 + armap_string_data = bytearray() + for i,file in enumerate(self.files): + elf = ElfFile(file.data) + if elf.symtab is not None: + for sym in elf.symtab.symbol_entries: + if sym.st_shndx != SHN_UND and sym.bind == SB_GLOBAL: + num_entries += 1 + armap_size += 4 + len(sym.name) + 1 + armap_string_data.extend(sym.name.encode("latin1") + b'\0') + armap_entries_files.append(i) + + armap_data.extend(struct.pack(">I", num_entries)) + armap_data.extend([0] * 4 * num_entries) # defer writing file positions until files are emplaced later + armap_data.extend(armap_string_data) + + if len(armap_data) % 4 != 0: + alsiz = (len(armap_data) + 3) & ~3 + armap_data.extend([0] * (alsiz - len(armap_data))) + + current_time = int(time.time()) + + add_ar_hdr(b, "/", current_time, 0, 0, 0, len(armap_data)) + armap_offsets_start = len(b) + 4 + add_bin(b, armap_data) + add_pad(b) + + # LONG STRINGS + + long_strings = "" + + file_names = [] + flag = False + for _,file in enumerate(self.files): + if len(file.name) >= 16: + fname = f"{file.name}/\n" + ind = len(long_strings) + long_strings += fname + else: + fname = f"{file.name}/" + ind = None + file_names.append((fname, ind)) + + # Weird hack + if len(long_strings) != 0 and not flag: + flag = True + long_strings += "/\n" + + long_strings += "/" + + add_ar_hdr(b, "//", current_time, 0, 0, 0, len(long_strings)) + add_str(b, long_strings) + add_pad(b) + + # FILES + + armap_pos = 0 + for i,(file,(fname,ind)) in enumerate(zip(self.files, file_names)): + file_pos = len(b) + add_ar_hdr(b, f"/{ind}" if ind is not None else fname, file.time, file.uid, file.gid, file.mode, file.size) + add_bin(b, file.data) + add_pad(b) + + # Patch the armap with file locations + while armap_pos < len(armap_entries_files) and armap_entries_files[armap_pos] == i: + b[armap_offsets_start+armap_pos*4:armap_offsets_start+armap_pos*4+4] = struct.pack(">I", file_pos) + armap_pos += 1 + + return b + + def write(self, file_path): + ar = self.build_image() + with open(file_path, "wb") as outfile: + outfile.write(ar) + + @staticmethod + def from_image(ar_data): + long_strings = None + ar = Archive() + + assert ar_data[:8].decode("ASCII") == "!<arch>\n" , "Not an archive file? Bad file magic value" + + i = 8 + while i < len(ar_data): + file_name = ar_data[i:][ 0:][:16].decode("ASCII").strip() + file_time = int(ar_data[i:][16:][:12].decode("ASCII").strip()) + file_uid = int(ar_data[i:][28:][: 6].decode("ASCII").strip()) + file_gid = int(ar_data[i:][34:][: 6].decode("ASCII").strip()) + file_mode = int(ar_data[i:][40:][: 8].decode("ASCII").strip(), 8) + file_size = int(ar_data[i:][48:][:10].decode("ASCII").strip()) + end = ar_data[i:][58:][:2].decode("ASCII") + assert end == "`\n" + + data = ar_data[i:][60:][:file_size] + assert len(data) == file_size + + if file_name == '/': + """ + "armap" + The special filename "/" denotes that this entry contains a symbol lookup table used by some libraries + to speed up file access. + The symbol table is comprised of three contiguous parts: + - A 32-bit Big Endian integer recording the number of symbol entries. + - A list of 32-bit Big Endian integers for each symbol entry, recording the position within the + archive of the header of the file containing the symbol. + - A list of null-terminated strings, the symbol names for each symbol entry. + + We rebuild this from scratch on write out. + """ + ar.time = file_time + assert file_uid == 0 + assert file_gid == 0 + assert file_mode == 0 + + # Code to interpret the armap, currently unused + """ + armap_n_syms = struct.unpack(">I", data[0:4])[0] + offsets = [i[0] for i in struct.iter_unpack(">I", data[4:4+4*armap_n_syms])] + + strings = [] + ofs = 4 + 4 * armap_n_syms + for _ in range(armap_n_syms): + to = data.find(b'\0', ofs) + assert to != -1 + string = data[ofs:to].decode('latin1') + strings.append(string) + ofs += len(string) + 1 + assert all([b == 0 for b in data[ofs:]]) + assert len(strings) == len(offsets) + + ar.armap_entries = list(zip(offsets, strings)) + """ + elif file_name == '//': + """ + Long string table. Strings larger than 16 are placed here and referenced from the header by /<offset>. + + We rebuild this from scratch on write out. + """ + assert file_time == ar.time + assert file_uid == 0 + assert file_gid == 0 + assert file_mode == 0 + long_strings = data.decode("ASCII") + else: + """ + Normal files. + """ + if file_name.startswith("/"): + assert long_strings is not None + # Fetch the name from the long string table + file_name = long_strings[int(file_name[1:]):].split("\n")[0] + # Add file + ar.add_data(file_name[:-1], file_time, file_uid, file_gid, file_mode, file_size, data) + + if file_size % 2 != 0: + file_size += 1 + i += 60 + file_size + + return ar + + @staticmethod + def from_file(file_path): + ar_file = None + with open(file_path, "rb") as infile: + ar_file = infile.read() + + return Archive.from_image(ar_file) + +def ar_usage(progname): + print(f"Usage: {progname} [-]{{dmpqrstx}}[abcDfilMNoOPsSTuvV] [member-name] [count] archive-file file...") + print(f" commands:") + print(f" d - delete file(s) from the archive") + print(f" m[ab] - move file(s) in the archive") + print(f" p - print file(s) found in the archive") + print(f" q[f] - quick append file(s) to the archive") + print(f" r[ab][f][u] - replace existing or insert new file(s) into the archive") + print(f" s - act as ranlib") + print(f" t[O][v] - display contents of the archive") + print(f" x[o] - extract file(s) from the archive") + print(f" command specific modifiers:") + print(f" [a] - put file(s) after [member-name]") + print(f" [b] - put file(s) before [member-name] (same as [i])") + print(f" [D] - use zero for timestamps and uids/gids (default)") + print(f" [U] - use actual timestamps and uids/gids") + print(f" [N] - use instance [count] of name") + print(f" [f] - truncate inserted file names") + print(f" [P] - use full path names when matching") + print(f" [o] - preserve original dates") + print(f" [O] - display offsets of files in the archive") + print(f" [u] - only replace files that are newer than current archive contents") + print(f" generic modifiers:") + print(f" [c] - do not warn if the library had to be created") + print(f" [s] - create an archive index (cf. ranlib)") + print(f" [S] - do not build a symbol table") + print(f" [v] - be verbose") + print(f" [V] - display the version number") + print(f" @<file> - read options from <file>") + print(f" --output=DIRNAME - specify the output directory for extraction operations") + return 1 + +def ar(argv): + if len(argv) < 2: + return ar_usage(argv[0]) + + progname = argv[0] + create_ok = False + make_ar_idx = False + no_symtab = False + verbose = False + + def verbose_print(msg): + if verbose: + print(msg) + + def dcmd(modifiers, args): + if modifiers != "": + print(f"{progname}: bad modifiers -- '{modifiers}'") + return ar_usage(progname) + + ar_file = args[0] + o_files = args[1:] + + ar = Archive.from_file(ar_file) + for file in ar.files: + if file.name in o_files: + ar.files.remove(file) + ar.write(ar_file) + return 0 + + def mcmd(modifiers, args): + print("<UNIMPLEMENTED>") + return 1 + + def pcmd(modifiers, args): + if modifiers != "": + print(f"{progname}: bad modifiers -- '{modifiers}'") + return ar_usage(progname) + if len(args) != 1: + print(f"{progname} p: bad args") + return ar_usage(progname) + + ar_file = args[0] + + ar = Archive.from_file(ar_file) + for file in ar.files: + print(file.data) + return 0 + + def qcmd(modifiers, args): + print("<UNIMPLEMENTED>") + return 1 + + def rcmd(modifiers, args): + if modifiers !="": + print("<UNIMPLEMENTED MODIFIERS>") + if len(args) < 2: + print(f"{progname} r: bad args") + return ar_usage(progname) + + ar_file = args[0] + o_files = args[1:] + + ar = Archive() + if os.path.isfile(ar_file): + ar = Archive.from_file(ar_file) + else: + if not create_ok: + print(f"Warning: Created file {ar_file}") + ar = Archive() + + for o_file in o_files: + ar.add_file(o_file) + + ar.write(ar_file) + + def scmd(modifiers, args): + print("<UNIMPLEMENTED>") + return 1 + + def tcmd(modifiers, args): + # TODO modifiers + + if len(args) != 1: + print(f"{progname} t: bad args") + return ar_usage(progname) + + ar_file = args[0] + + ar = Archive.from_file(ar_file) + for file in ar.files: + print(file.name) + return 0 + + def xcmd(modifiers, args): + if modifiers not in ('', 'o'): + print(f"{progname}: bad modifiers -- '{modifiers}'") + return ar_usage(progname) + if len(args) not in (1, 3) or not (args[0].startswith("--output") or args[1].startswith("--output")): + print(f"{progname} t: bad args") + return ar_usage(progname) + + original_times = modifiers == 'o' + + if args[0].startswith("--output"): + out_dir = args[1] + ar_file = args[2] + elif args[1].startswith("--output"): + out_dir = args[2] + ar_file = args[0] + else: + ar_file = args[0] + out_dir = "" + + # Create dir if not exists + if not os.path.exists(out_dir): + os.makedirs(out_dir, exist_ok=True) + + if not os.path.isdir(out_dir): + print(f"Output directory {out_dir} is a file") + return ar_usage(progname) + + # Extract files to destination + ar = Archive.from_file(ar_file) + for file in ar.files: + opath =os.path.join(out_dir, file.name) + with open(opath, "wb") as ofile: + ofile.write(file.data) + + if not original_times: + t = time.time() + os.utime(opath, (t, t)) + # TODO patch with original dates etc. + + return 0 + + argtbl = { + 'd': dcmd, # delete file(s) from the archive + 'm': mcmd, # [ab] move file(s) in the archive + 'p': pcmd, # print file(s) found in the archive + 'q': qcmd, # [f] quick append file(s) to the archive + 'r': rcmd, # [ab][f][u] replace existing or insert new file(s) into the archive + 's': scmd, # act as ranlib + 't': tcmd, # [O][v] display contents of the archive + 'x': xcmd, # [o] extract file(s) from the archive + } + + arg1 = argv[1] + if arg1[0] == '-': + arg1 = arg1[1:] + cmd = arg1[0] + + if cmd not in argtbl: + print(f"{progname}: invalid option -- '{cmd}'") + return ar_usage(argv[0]) + + modifiers = arg1[1:] + + create_ok = "c" in modifiers + modifiers = modifiers.replace("c","") + make_ar_idx = "s" in modifiers + modifiers = modifiers.replace("s","") + no_symtab = "S" in modifiers + modifiers = modifiers.replace("S","") + verbose = "v" in modifiers + modifiers = modifiers.replace("v","") + + if "V" in modifiers: + print(f"{progname} v1.0") + + return argtbl[cmd](modifiers, argv[2:]) + +if __name__ == '__main__': + import sys + sys.exit(ar(sys.argv)) diff --git a/lib/ultralib/tools/compile_sjis.py b/lib/ultralib/tools/compile_sjis.py index 1905745..136bdc7 100755 --- a/lib/ultralib/tools/compile_sjis.py +++ b/lib/ultralib/tools/compile_sjis.py @@ -9,6 +9,7 @@ WORKING_DIR = os.getcwd() fb = [] original_c_file = [i for i in sys.argv if ".c" in i][0] CC = [i for i in sys.argv if "-D__CC=" in i][0][7:] +build_dir = [i for i in sys.argv if "-D__BUILD_DIR" in i][0][14:] output_c_file = original_c_file @@ -19,7 +20,7 @@ original_c_file = "src/voice/" + original_c_file with open(original_c_file) as f: fb = f.read() -os.chdir("build/src/voice") +os.chdir(build_dir + "/src/voice") with open(output_c_file, "w+") as outf: sjis_process(fb, outf) diff --git a/lib/ultralib/tools/libelf.py b/lib/ultralib/tools/libelf.py index 0c9cc3a..11c4c03 100755 --- a/lib/ultralib/tools/libelf.py +++ b/lib/ultralib/tools/libelf.py @@ -1102,9 +1102,9 @@ class ElfFile: if s.sh_type == SHT_SYMTAB: assert not symtab , "Found more than one symtab section?" symtab = s - assert symtab is not None , "Could not find symtab" self.symtab = symtab - self.symtab.late_init() + if self.symtab is not None: + self.symtab.late_init() # Late Init sections for s in self.sections: @@ -1147,11 +1147,12 @@ if __name__ == "__main__": for i,s in enumerate(elf_file.sections,0): print(f" [{i:2}] {s}") # Symbols Info Test - print("") - print(f"Symbol table '{elf_file.symtab.name}' contains {len(elf_file.symtab.symbol_entries)} entries") - print(" Num: Value Size Type Bind Vis Ndx Name") - for i,sym in enumerate(elf_file.symtab.symbol_entries,0): - print(f"{i:6}: {sym}") + if elf_file.symtab is not None: + print("") + print(f"Symbol table '{elf_file.symtab.name}' contains {len(elf_file.symtab.symbol_entries)} entries") + print(" Num: Value Size Type Bind Vis Ndx Name") + for i,sym in enumerate(elf_file.symtab.symbol_entries,0): + print(f"{i:6}: {sym}") # Relocations Info Test print("") for s in elf_file.sections: diff --git a/lib/ultralib/tools/m2ctx.py b/lib/ultralib/tools/m2ctx.py new file mode 100755 index 0000000..39c5dc5 --- /dev/null +++ b/lib/ultralib/tools/m2ctx.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python3 + +import argparse +import os +import sys +import subprocess +import tempfile + +script_dir = os.path.dirname(os.path.realpath(__file__)) +root_dir = os.path.abspath(os.path.join(script_dir, "..")) +src_dir = root_dir + "src/" + +# Project-specific +CPP_FLAGS = [ + "-Iinclude", + "-Iinclude/PR", + "-Iinclude/gcc", + "-Isrc", + "-Isrc/libc", + "-Iver/current/build/include", + "-D_LANGUAGE_C", + "-DF3DEX_GBI_2", + "-D_MIPS_SZLONG=32", + "-DSCRIPT(...)={}" + "-D__attribute__(...)=", + "-D__asm__(...)=", + "-ffreestanding", + "-DM2CTX", +] + +def import_c_file(in_file) -> str: + in_file = os.path.relpath(in_file, root_dir) + cpp_command = ["gcc", "-E", "-P", "-dM", *CPP_FLAGS, in_file] + cpp_command2 = ["gcc", "-E", "-P", *CPP_FLAGS, in_file] + + with tempfile.NamedTemporaryFile(suffix=".c") as tmp: + stock_macros = subprocess.check_output(["gcc", "-E", "-P", "-dM", tmp.name], cwd=root_dir, encoding="utf-8") + + out_text = "" + try: + out_text += subprocess.check_output(cpp_command, cwd=root_dir, encoding="utf-8") + out_text += subprocess.check_output(cpp_command2, cwd=root_dir, encoding="utf-8") + except subprocess.CalledProcessError: + print( + "Failed to preprocess input file, when running command:\n" + + cpp_command, + file=sys.stderr, + ) + sys.exit(1) + + if not out_text: + print("Output is empty - aborting") + sys.exit(1) + + for line in stock_macros.strip().splitlines(): + out_text = out_text.replace(line + "\n", "") + return out_text + +def main(): + parser = argparse.ArgumentParser( + description="""Create a context file which can be used for mips_to_c""" + ) + parser.add_argument( + "c_file", + help="""File from which to create context""", + ) + args = parser.parse_args() + + output = import_c_file(args.c_file) + + with open(os.path.join(root_dir, "ctx.c"), "w", encoding="UTF-8") as f: + f.write(output) + + +if __name__ == "__main__": + main() diff --git a/lib/ultralib/tools/patch_ar_meta.py b/lib/ultralib/tools/patch_ar_meta.py index 98d11f8..d831785 100755 --- a/lib/ultralib/tools/patch_ar_meta.py +++ b/lib/ultralib/tools/patch_ar_meta.py @@ -5,7 +5,7 @@ import argparse -def ar_patch(ar, new_uid, new_gid, new_filemode): +def ar_patch(ar, original, new_uid, new_gid, new_filemode): """ AR file headers @@ -20,6 +20,29 @@ def ar_patch(ar, new_uid, new_gid, new_filemode): """ assert len(ar) > 0x24 , "Got empty archive?" + armap_time1 = None + armap_time2 = None + + i = 8 + while i < len(original): + file_name = original[i:][0:][:16].decode("ASCII") + file_size = int(original[i:][48:][:10].decode("ASCII").strip()) + end = original[i:][58:][:2].decode("ASCII") + + assert end == "`\n" + + if file_name.strip() == "/": + armap_time1 = original[i+16:i+16+12] + elif file_name.strip() == "//": + armap_time2 = original[i+16:i+16+12] + + if file_size % 2 != 0: + file_size += 1 + i += file_size + 60 + + assert armap_time1 is not None + assert armap_time2 is not None + i = 8 while i < len(ar): file_name = ar[i:][0:][:16].decode("ASCII") @@ -28,7 +51,11 @@ def ar_patch(ar, new_uid, new_gid, new_filemode): assert end == "`\n" - if file_name.strip() not in ["/", "//"]: # Skip armap + if file_name.strip() == "/": + ar[i+16:i+16+12] = armap_time1 + elif file_name.strip() == "//": + ar[i+16:i+16+12] = armap_time2 + else: ar[i+28:i+28+6] = f"{new_uid:<6}".encode("ASCII")[:6] ar[i+34:i+34+6] = f"{new_gid:<6}".encode("ASCII")[:6] ar[i+40:i+40+8] = f"{new_filemode:<8}".encode("ASCII")[:8] @@ -39,16 +66,24 @@ def ar_patch(ar, new_uid, new_gid, new_filemode): def main(): parser = argparse.ArgumentParser(description="Patch metadata in .a files.") - parser.add_argument("archive", help="path to the ar file") + parser.add_argument("target", help="path to the ar file to patch") + parser.add_argument("original", help="path to the original ar file") + parser.add_argument("uid", help="new uid") + parser.add_argument("gid", help="new gid") + parser.add_argument("filemode", help="new filemode") args = parser.parse_args() ar = None - with open(args.archive, "rb") as ar_file: + with open(args.target, "rb") as ar_file: ar = bytearray(ar_file.read()) - ar_patch(ar, 0, 0, 37777700) + original = None + with open(args.original, "rb") as original_ar_file: + original = bytearray(original_ar_file.read()) + + ar_patch(ar, original, args.uid, args.gid, args.filemode) - with open(args.archive, "wb") as ar_file: + with open(args.target, "wb") as ar_file: ar_file.write(ar) if __name__ == '__main__': diff --git a/lib/ultralib/tools/print_mdebug.py b/lib/ultralib/tools/print_mdebug.py new file mode 100755 index 0000000..e0b295a --- /dev/null +++ b/lib/ultralib/tools/print_mdebug.py @@ -0,0 +1,589 @@ +#!/usr/bin/env python3 +''' +Resources: +http://www.cs.unibo.it/~solmi/teaching/arch_2002-2003/AssemblyLanguageProgDoc.pdf +https://github.com/pathscale/binutils/blob/5c2c133020e41fc4aadd80a99156d2cea4754b96/include/coff/sym.h +https://github.com/pathscale/binutils/blob/5c2c133020e41fc4aadd80a99156d2cea4754b96/include/coff/symconst.h +https://github.com/pathscale/binutils/blob/5c2c133020e41fc4aadd80a99156d2cea4754b96/gas/ecoff.c +https://github.com/pathscale/binutils/blob/5c2c133020e41fc4aadd80a99156d2cea4754b96/bfd/ecoff.c +https://github.com/pathscale/absoft/blob/master/svn/trunk/ekopath-gcc/ekopath-gcc-4.2.0/gcc/mips-tdump.c +https://chromium.googlesource.com/native_client/nacl-toolchain/+/refs/tags/gcc-4.4.3/binutils/gas/ecoff.c +https://android.googlesource.com/toolchain/binutils/+/refs/heads/donut/binutils-2.17/bfd/ecofflink.c +https://kernel.googlesource.com/pub/scm/linux/kernel/git/hjl/binutils/+/hjl/secondary/include/coff/symconst.h +https://c0de.pw/bg/binutils-gdb/blob/cdbf20f73486c66e24f322400eba877eb534ae51/gdb/mdebugread.c +''' + +import os +import struct +import collections +import sys + +OFFSET = 0 # TODO why are the offsets in the symbolic header off by some amount? + +indent_level = 0 +is_comment = False + +symbol_type_list = [ + 'stNil', 'stGlobal', 'stStatic', 'stParam', 'stLocal', 'stLabel', 'stProc', 'stBlock', + 'stEnd', 'stMember', 'stTypedef', 'stFile', 'INVALID', 'INVALID', 'stStaticProc', 'stConstant', + 'stStaParam', 'INVALID', 'INVALID', 'INVALID', 'INVALID', 'INVALID', 'INVALID', 'INVALID', + 'INVALID', 'INVALID', 'stStruct', 'stUnion', 'stEnum', 'INVALID', 'INVALID', 'INVALID', + 'INVALID', 'INVALID', 'stIndirect'] +storage_class_list = ['scNil', 'scText', 'scData', 'scBss', 'scRegister', 'scAbs', 'scUndefined', 'reserved', + 'scBits', 'scDbx', 'scRegImage', 'scInfo', 'scUserStruct', 'scSData', 'scSBss', 'scRData', + 'scVar', 'scCommon', 'scSCommon', 'scVarRegister', 'scVariant', 'scUndefined', 'scInit'] +basic_type_c_list = ['nil', 'addr', 'signed char', 'unsigned char', 'short', 'unsigned short', 'int', 'unsigned int', + 'long', 'unsigned long', 'float', 'double', 'struct', 'union', 'enum', 'typedef', + 'range', 'set', 'complex', 'double complex', 'indirect', 'fixed decimal', 'float decimal', 'string', + 'bit', 'picture', 'void', 'long long', 'unsigned long long', 'INVALID', 'long', 'unsigned long', + 'long long', 'unsigned long long', 'addr', 'int64', 'unsigned int64'] + +def increase_indent(): + global indent_level + indent_level += 1 + +def decrease_indent(): + global indent_level + indent_level -= 1 + +def set_is_comment(set_to): + global is_comment + old = is_comment + is_comment = set_to + return old + +def get_indent(): + global indent_level + global is_comment + ret = '//' if is_comment else '' + for i in range(indent_level): + ret += ' ' + return ret + +def check_indent(): + global indent_level + assert indent_level == 0 + +def read_uint32_be(file_data, offset): + return struct.unpack('>I', file_data[offset:offset+4])[0] + +def read_uint16_be(file_data, offset): + return struct.unpack('>H', file_data[offset:offset+2])[0] + +def read_uint8_be(file_data, offset): + return struct.unpack('>B', file_data[offset:offset+1])[0] + +def read_elf_header(file_data, offset): + Header = collections.namedtuple('ElfHeader', + '''e_magic e_class e_data e_version e_osabi e_abiversion e_pad + e_type e_machine e_version2 e_entry e_phoff e_shoff e_flags + e_ehsize e_phentsize e_phnum e_shentsize e_shnum e_shstrndx''') + return Header._make(struct.unpack('>I5B7s2H5I6H', file_data[offset:offset+52])) + +def read_elf_section_header(file_data, offset): + Header = collections.namedtuple('SectionHeader', + '''sh_name sh_type sh_flags sh_addr sh_offset sh_size sh_link + sh_info sh_addralign sh_entsize''') + return Header._make(struct.unpack('>10I', file_data[offset:offset+40])) + +def read_symbolic_header(file_data, offset): + Header = collections.namedtuple('SymbolicHeader', + '''magic vstamp ilineMax cbLine cbLineOffset idnMax cbDnOffset + ipdMax cbPdOffset isymMax cbSymOffset ioptMax cbOptOffset + iauxMax cbAuxOffset issMax cbSsOffset issExtMax cbSsExtOffset + ifdMax cbFdOffset crfd cbRfdOffset iextMax cbExtOffset''') + return Header._make(struct.unpack('>2H23I', file_data[offset:offset+96])) + +# TODO find a better solution for the bitfield +def read_file_descriptor(file_data, offset): + if 'init' not in read_file_descriptor.__dict__: + read_file_descriptor.cache = {} + read_file_descriptor.header = collections.namedtuple('FileDescriptor', + '''adr rss issBase cbSs isymBase csym ilineBase cline ioptBase + copt ipdFirst cpd iauxBase caux rfdBase crfd XXX_bitfield + cbLineOffset cbLine''') + read_file_descriptor.init = True + if offset in read_file_descriptor.cache: + return read_file_descriptor.cache[offset] + read_file_descriptor.cache[offset] = read_file_descriptor.header._make( + struct.unpack('>I2iI6iHh4iI2I', file_data[offset:offset+72])) + return read_file_descriptor.cache[offset] + +def read_procedure_descriptor(file_data, offset): + Header = collections.namedtuple('ProcedureDescriptor', + '''adr isym iline regmask regoffset iopt fregmask fregoffset + frameoffset framereg pcreg lnLow lnHigh cbLineOffset''') + return Header._make(struct.unpack('>I8i2h2iI', file_data[offset:offset+52])) + +def read_symbol(file_data, offset): + if 'init' not in read_symbol.__dict__: + read_symbol.cache = {} + read_symbol.header = collections.namedtuple('Symbol', '''iss value st sc index''') + read_symbol.init = True + if offset in read_symbol.cache: + return read_symbol.cache[offset] + (word0, word1, word2) = struct.unpack('>iiI', file_data[offset:offset+12]) + read_symbol.cache[offset] = read_symbol.header._make(( + word0, word1, (word2 >> 26) & 0x3F, (word2 >> 21) & 0x1F, word2 & 0xFFFFF)) + return read_symbol.cache[offset] + +def read_auxiliary_symbol(file_data, offset): + if 'init' not in read_auxiliary_symbol.__dict__: + read_auxiliary_symbol.cache = {} + read_auxiliary_symbol.header = collections.namedtuple('AuxSymbol', + '''ti rndx dnLow dnHigh isym iss width count''') + read_auxiliary_symbol.type_info = collections.namedtuple('TypeInfo', + '''fBitfield continued bt tq4 tq5 tq0 tq1 tq2 tq3''') + read_auxiliary_symbol.rel_sym = collections.namedtuple('RelativeSymbol', '''rfd index''') + read_auxiliary_symbol.init = True + if offset in read_auxiliary_symbol.cache: + return read_auxiliary_symbol.cache[offset] + word0 = struct.unpack('>I', file_data[offset:offset+4])[0] + read_auxiliary_symbol.cache[offset] = read_auxiliary_symbol.header._make(( + read_auxiliary_symbol.type_info._make(((word0 >> 31) & 1, (word0 >> 30) & 1, (word0 >> 24) & 0x3F, (word0 >> 20) & 0xF, (word0 >> 16) & 0xF, (word0 >> 12) & 0xF, (word0 >> 8) & 0xF, (word0 >> 4) & 0xF, word0 & 0xF)), + read_auxiliary_symbol.rel_sym._make(((word0 >> 20) & 0xFFF, word0 & 0xFFFFF)), + word0, word0, word0, word0, word0, word0)) + return read_auxiliary_symbol.cache[offset] + +def read_string(file_data, offset): + current_offset = 0 + current_string = b'' + while True: + char = struct.unpack('c', file_data[offset+current_offset:offset+current_offset+1])[0] + if char == b'\0': + return current_string.decode('ascii') + else: + current_string += char + current_offset += 1 + +def map_relative_file_descriptor(file_data, fd, symbolic_header, rfd_num): + if fd.crfd == 0: + return rfd_num + + offset = symbolic_header.cbRfdOffset - OFFSET + (fd.rfdBase + rfd_num)*4 + return struct.unpack('>I', file_data[offset:offset+4])[0] + +def get_symbol_name_from_aux(file_data, fd, symbolic_header, aux_num, search_for_typedef): + aux = read_auxiliary_symbol(file_data, symbolic_header.cbAuxOffset - OFFSET + (fd.iauxBase + aux_num)*4) + fd_num = aux.rndx.rfd + next_aux = aux_num+1 + if fd_num == 4095: + aux2 = read_auxiliary_symbol(file_data, symbolic_header.cbAuxOffset - OFFSET + (fd.iauxBase + next_aux)*4) + fd_num = aux2.isym + next_aux = next_aux+1; + fd_num = map_relative_file_descriptor(file_data, fd, symbolic_header, fd_num) + fd2 = read_file_descriptor(file_data, symbolic_header.cbFdOffset - OFFSET + fd_num*72) + sym = read_symbol(file_data, symbolic_header.cbSymOffset - OFFSET + (fd2.isymBase + aux.rndx.index)*12) + ret = '' + #print('%r' % (aux,)); + #print('%r' % (aux2,)); + #print('%r' % (sym,)); + if sym.st == 26 or sym.st == 27: #stStruct, stunion + ret = get_struct_or_union_string(file_data, fd2, symbolic_header, fd2.isymBase + aux.rndx.index, search_for_typedef) + elif sym.st == 28: #stEnum: + ret = get_enum_string(file_data, fd2, symbolic_header, fd2.isymBase + aux.rndx.index) + else: + ret = read_string(file_data, symbolic_header.cbSsOffset - OFFSET + fd2.issBase + sym.iss) + return (ret, next_aux) + +def get_type_string(file_data, fd, symbolic_header, aux_num, name, search_for_typedef): + ret = '' + aux = read_auxiliary_symbol(file_data, symbolic_header.cbAuxOffset - OFFSET + (fd.iauxBase + aux_num)*4) + #print(''); + #print('%r' % (aux,)); + next_aux = aux_num+1 + has_bitfield = aux.ti.fBitfield == 1 + bitwidth = 0 + if has_bitfield: + bit_aux = read_auxiliary_symbol(file_data, symbolic_header.cbAuxOffset - OFFSET + (fd.iauxBase + next_aux)*4) + bitwidth = bit_aux.isym + next_aux = next_aux+1 + if aux.ti.bt == 12: # btStruct + (ret, next_aux) = get_symbol_name_from_aux(file_data, fd, symbolic_header, next_aux, search_for_typedef) + elif aux.ti.bt == 13: # btUnion + (ret, next_aux) = get_symbol_name_from_aux(file_data, fd, symbolic_header, next_aux, search_for_typedef) + elif aux.ti.bt == 15: # btTypedef + (ret, next_aux) = get_symbol_name_from_aux(file_data, fd, symbolic_header, next_aux, search_for_typedef) + elif aux.ti.bt == 14: # btEnum + (ret, next_aux) = get_symbol_name_from_aux(file_data, fd, symbolic_header, next_aux, search_for_typedef) + else: + if aux.ti.bt >= 36: + print('Error unknow bt: %d' % (aux.ti.bt)) + ret = basic_type_c_list[aux.ti.bt] + + tq_list = (aux.ti.tq0, aux.ti.tq1, aux.ti.tq2, aux.ti.tq3, aux.ti.tq4, aux.ti.tq5) + + # TODO this is very naive and probably does not work in a large amount of cases + last_was_proc = False # if we see a tqProc, assume the next will be a tqPtr + for tq in tq_list: + if tq == 0: # tqNil + break; + elif tq == 1: # tqPtr + if last_was_proc: + last_was_proc = False + continue + ret += '*' + elif tq == 2: # tqProc + last_was_proc = True + name = '(*%s)(/* ECOFF does not store param types */)' % name + elif tq == 3: # tqArray + next_aux += 2 # todo what does this skip over? (Apparantly the type of the index, so always int for C) + array_low_aux = read_auxiliary_symbol(file_data, symbolic_header.cbAuxOffset - OFFSET + (fd.iauxBase + next_aux)*4) + array_high_aux = read_auxiliary_symbol(file_data, symbolic_header.cbAuxOffset - OFFSET + (fd.iauxBase + next_aux+1)*4) + stride_aux = read_auxiliary_symbol(file_data, symbolic_header.cbAuxOffset - OFFSET + (fd.iauxBase + next_aux+2)*4) + next_aux += 3 + if array_high_aux.dnHigh == 0xFFFFFFFF: + name += '[]' + else: + name += '[%d]' % (array_high_aux.dnHigh + 1) + elif tq == 4: # tqFar + print('ERROR tqFar in get_type_name') + elif tq == 5: # tqVol + ret = 'volatile ' + ret + elif tq == 6: # tqConst + ret = 'const ' + ret + if has_bitfield: + name += ' : %d' % bitwidth + return ret + ' ' + name + +def get_enum_string(file_data, fd, symbolic_header, enum_sym_num): + ret = '' + start_sym = read_symbol(file_data, symbolic_header.cbSymOffset - OFFSET + enum_sym_num*12) + if start_sym.st != 28: + print('ERROR unknown type in get_enum_string start:%d' % start_sym.st) + return ret + name = read_string(file_data, symbolic_header.cbSsOffset - OFFSET + fd.issBase + start_sym.iss) + if name != '': + name += ' ' + ret += 'enum %s{\n' % name + increase_indent() + sym_num = enum_sym_num + 1 + while sym_num < fd.isymBase + start_sym.index: + sym = read_symbol(file_data, symbolic_header.cbSymOffset - OFFSET + sym_num*12) + if sym.st == 8: # stEnd + decrease_indent() + ret += get_indent() + ret += '}' + elif sym.st == 9: # stMember + name = read_string(file_data, symbolic_header.cbSsOffset - OFFSET + fd.issBase + sym.iss) + ret += get_indent() + ret += '%s = %d,\n' % (name, sym.value) + else: + print('ERROR unknown type in get_enum_string:%d' % sym.st) + break + sym_num += 1 + return ret + +def get_struct_or_union_string(file_data, fd, symbolic_header, union_sym_num, search_for_typedef): + ret = '' + start_sym = read_symbol(file_data, symbolic_header.cbSymOffset - OFFSET + union_sym_num*12) + if search_for_typedef: + typedef_sym = read_symbol(file_data, symbolic_header.cbSymOffset - OFFSET + (fd.isymBase + start_sym.index)*12) + if typedef_sym.st == 10: # stTypedef + return read_string(file_data, symbolic_header.cbSsOffset - OFFSET + fd.issBase + typedef_sym.iss) + else: + name = read_string(file_data, symbolic_header.cbSsOffset - OFFSET + fd.issBase + start_sym.iss) + if name != '': + return name + name = read_string(file_data, symbolic_header.cbSsOffset - OFFSET + fd.issBase + start_sym.iss) + if name != '': + name += ' ' + if start_sym.st == 26: # stStruct + ret += 'struct %s{\n' % name + increase_indent() + elif start_sym.st == 27: # stUnion + ret += 'union %s{\n' % name + increase_indent() + else: + print('ERROR unknown type in get_struct_or_union_string start:%d' % start_sym.st) + return ret + sym_num = union_sym_num + 1 + while sym_num < fd.isymBase + start_sym.index: + sym = read_symbol(file_data, symbolic_header.cbSymOffset - OFFSET + sym_num*12) + if sym.st == 8: # stEnd + decrease_indent() + ret += get_indent() + ret += '}' + elif sym.st == 9: # stMember + name = read_string(file_data, symbolic_header.cbSsOffset - OFFSET + fd.issBase + sym.iss) + ret += get_indent() + ret += '/* 0x%X */ %s;\n' % (sym.value // 8, get_type_string(file_data, fd, symbolic_header, sym.index, name, True)) + elif sym.st == 26 or sym.st == 27: #stStruct, stUnion + sym_num = fd.isymBase + sym.index + continue + elif sym.st == 34: # stIndirect + # TODO what even is a stIndirect? + sym_num += 1 + else: + print('ERROR unknown type in get_struct_or_union_string:%d' % sym.st) + break + sym_num += 1 + return ret + +def print_typedef_symbols(file_data, fd, symbolic_header, typedef_sym_num): + typedef_sym = read_symbol(file_data, symbolic_header.cbSymOffset - OFFSET + typedef_sym_num*12) + if typedef_sym.st != 10: # stTypedef + print('ERROR expected stTypedef symbol in print_typedef_symbols, found:%d' % typedef_sym.st) + return + name = read_string(file_data, symbolic_header.cbSsOffset - OFFSET + fd.issBase + typedef_sym.iss) + print('typedef %s;' % get_type_string(file_data, fd, symbolic_header, typedef_sym.index, name, False)) + +def print_procedure(file_data, fd, symbolic_header, proc_sym_num): + proc_sym = read_symbol(file_data, symbolic_header.cbSymOffset - OFFSET + proc_sym_num*12) + proc_name = read_string(file_data, symbolic_header.cbSsOffset - OFFSET + fd.issBase + proc_sym.iss) + print('%s(' % get_type_string(file_data, fd, symbolic_header, proc_sym.index+1, proc_name, True), end='') + sym_num = proc_sym_num+1 + param_sym = read_symbol(file_data, symbolic_header.cbSymOffset - OFFSET + sym_num*12) + first = True + while param_sym.st == 3: # stParam + param_name = read_string(file_data, symbolic_header.cbSsOffset - OFFSET + fd.issBase + param_sym.iss) + print('%s%s' % ('' if first else ', ', + get_type_string(file_data, fd, symbolic_header, param_sym.index, param_name, True)), + end='') + sym_num += 1 + param_sym = read_symbol(file_data, symbolic_header.cbSymOffset - OFFSET + sym_num*12) + first = False + + print(');') + + check_indent(); + + comment_old = set_is_comment(True) + while sym_num < fd.isymBase + fd.csym: + sym = read_symbol(file_data, symbolic_header.cbSymOffset - OFFSET + sym_num*12) + sym_num += 1 + if sym.st == 7: # stBlock + print('%s{' % get_indent()) + increase_indent() + elif sym.st == 8: # stEnd + end_name = read_string(file_data, symbolic_header.cbSsOffset - OFFSET + fd.issBase + sym.iss) + if end_name == proc_name: + break + if end_name != '': + # this is a stEnd for something other than the function. Let's back out and return + sym_num -= 1 + break + decrease_indent() + print('%s}' % get_indent()) + elif sym.st == 4: # stLocal + local_name = read_string(file_data, symbolic_header.cbSsOffset - OFFSET + fd.issBase + sym.iss) + is_reg = sym.sc == 4 # scRegister + print('%s%s%s;' % (get_indent(), + 'register ' if is_reg else '', + get_type_string(file_data, fd, symbolic_header, sym.index, local_name, True))) + elif sym.st == 2: # stStatic + static_name = read_string(file_data, symbolic_header.cbSsOffset - OFFSET + fd.issBase + sym.iss) + if sym.index == 0xFFFFF: + print('%sstatic %s; // no type symbol' % (get_indent(),static_name)) + else: + print('%sstatic %s;' % (get_indent(),get_type_string(file_data, fd, symbolic_header, sym.index, static_name, True))) + elif sym.st == 5: # stLabel + label_name = read_string(file_data, symbolic_header.cbSsOffset - OFFSET + fd.issBase + sym.iss) + print('%sLabel: %s @ %d;' % (get_indent(), label_name, sym.value)) + elif sym.st == 6: # stProc + # multiple name for function? + sym_num = print_procedure(file_data, fd, symbolic_header, sym_num-1) + elif sym.st == 26 or sym.st == 27: # stStruct, stUnion + print('%s%s;' % (get_indent(), get_struct_or_union_string(file_data, fd, symbolic_header, sym_num-1, False))) + sym_num = fd.isymBase + sym.index + elif sym.st == 28: # stEnum + print('%s%s;' % (get_indent(), get_enum_string(file_data, fd, symbolic_header, sym_num-1))) + sym_num = fd.isymBase + sym.index + elif sym.st == 34: # stIndirect + # TODO what even is a stIndirect? + indirect_name = read_string(file_data, symbolic_header.cbSsOffset - OFFSET + fd.issBase + sym.iss) + print('%sTODO Indirect: %s;' % (get_indent(), indirect_name)) + else: + print('ERROR unknown st in print_procedure: %d' % sym.st) + set_is_comment(comment_old) + + check_indent(); + + return sym_num + +def print_symbols(file_data, fd, symbolic_header): + sym_num = fd.isymBase + indirects = [] + typedefs = [] + while sym_num < fd.isymBase + fd.csym: + root_sym = read_symbol(file_data, symbolic_header.cbSymOffset - OFFSET + sym_num*12) + if root_sym.st == 10: # stTypedef + aux = read_auxiliary_symbol(file_data, symbolic_header.cbAuxOffset - OFFSET + (fd.iauxBase + root_sym.index)*4) + offset = 0 + if aux.ti.fBitfield == 1: + offset = 1 + if aux.ti.bt == 12 or aux.ti.bt == 13 or aux.ti.bt == 14 or aux.ti.bt == 15: # btStruct, btUnion, btEnum, btTypedef + aux2 = read_auxiliary_symbol(file_data, symbolic_header.cbAuxOffset - OFFSET + (fd.iauxBase + root_sym.index + 1 + offset)*4) + fd_num = aux2.rndx.rfd + if fd_num == 4095: + fd_num = read_auxiliary_symbol(file_data, symbolic_header.cbAuxOffset - OFFSET + (fd.iauxBase + root_sym.index + 2 + offset)*4).isym + fd_num = map_relative_file_descriptor(file_data, fd, symbolic_header, fd_num) + fd2 = read_file_descriptor(file_data, symbolic_header.cbFdOffset - OFFSET + fd_num*72) + sym2 = read_symbol(file_data, symbolic_header.cbSymOffset - OFFSET + (fd2.isymBase + aux2.rndx.index)*12) + name = read_string(file_data, symbolic_header.cbSsOffset - OFFSET + fd2.issBase + sym2.iss) + if name != '': + typedefs.append(name) + elif root_sym.st == 34: # stIndirect + name = read_string(file_data, symbolic_header.cbSsOffset - OFFSET + fd.issBase + root_sym.iss) + indirects.append(name); + sym_num += 1 + sym_num = fd.isymBase + while sym_num < fd.isymBase + fd.csym: + root_sym = read_symbol(file_data, symbolic_header.cbSymOffset - OFFSET + sym_num*12) + if root_sym.st == 11: # stFile + file_name = read_string(file_data, symbolic_header.cbSsOffset - OFFSET + fd.issBase + root_sym.iss) + print('// begin file %s\n' % file_name) + sym_num += 1 + leaf_sym = read_symbol(file_data, symbolic_header.cbSymOffset - OFFSET + sym_num*12) + while leaf_sym.st != 8: # stEnd + if leaf_sym.st == 26 or leaf_sym.st == 27: # stStruct, stUnion + name = read_string(file_data, symbolic_header.cbSsOffset - OFFSET + fd.issBase + leaf_sym.iss) + if (name != '') and ((name in indirects) or (name not in typedefs)): # TODO + print('%s;\n' % get_struct_or_union_string(file_data, fd, symbolic_header, sym_num, False)) + sym_num = fd.isymBase + leaf_sym.index + elif leaf_sym.st == 28: # stEnum + name = read_string(file_data, symbolic_header.cbSsOffset - OFFSET + fd.issBase + leaf_sym.iss) + if (name != '') and (name not in typedefs): # TODO + print('%s;\n' % get_enum_string(file_data, fd, symbolic_header, sym_num)) + sym_num = fd.isymBase + leaf_sym.index + elif leaf_sym.st == 10: # stTypedef + # TODO typedef for stIndirect shoulf print the keyword i.e. typdef >struct< THING thing + print_typedef_symbols(file_data, fd, symbolic_header, sym_num) + sym_num += 1 + print('') + elif leaf_sym.st == 6 or leaf_sym.st == 14: # stProc, stStaticProc + # TODO how do stProc and stStaticProc differ? stStaticProc isn't exported? + sym_num = print_procedure(file_data, fd, symbolic_header, sym_num) + print('') + elif leaf_sym.st == 2: # stStatic + static_name = read_string(file_data, symbolic_header.cbSsOffset - OFFSET + fd.issBase + leaf_sym.iss) + if leaf_sym.sc == 2 or leaf_sym.sc == 3 or leaf_sym.sc == 5 or leaf_sym.sc == 15: # scData, scBss, scAbsolute, scRData + if leaf_sym.index != 0xFFFFF: # looks like it's an invalid value for .s files + print('static %s;\n' % get_type_string(file_data, fd, symbolic_header, leaf_sym.index, static_name, True)) + else: + print('static %s;\n' % static_name) + else: + print('ERROR unknown sc for stStatic in print_symbols: %d' % leaf_sym.sc) + sym_num += 1 + elif leaf_sym.st == 34: # stIndirect + # stIndirect is put out when the compiler sees a struct when it is not yet defined + # TODO more info + sym_num += 1 + elif leaf_sym.st == 5: # stLabel + print('// label: %s' % read_string(file_data, symbolic_header.cbSsOffset - OFFSET + fd.issBase + leaf_sym.iss)) + sym_num += 1 + elif leaf_sym.st == 0: # stNil + print('// nil: %s' % read_string(file_data, symbolic_header.cbSsOffset - OFFSET + fd.issBase + leaf_sym.iss)) + sym_num += 1 + else: + print('ERROR unknown st in leaf_sym in print_symbols: %d' % leaf_sym.st) + sym_num += 1 + leaf_sym = read_symbol(file_data, symbolic_header.cbSymOffset - OFFSET + sym_num*12) + sym_num = fd.isymBase + root_sym.index + print('// end file %s' % file_name) + else: + print('ERROR expected st of stFile as only root type in print_symbols:%d' % root_sym.st) + return + +def main(): + global OFFSET + if len(sys.argv) < 2: + return # TODO print usage + + filename = sys.argv[1] + + try: + with open(filename, 'rb') as f: + file_data = f.read() + except IOError: + print('failed to read file ' + filename) + return + + elf_header = read_elf_header(file_data, 0) + section_headers = [] + debug_index = 0xFFFFFFFF + #print('%r' % (elf_header,)) + for i in range(elf_header.e_shnum): + section_headers.append(read_elf_section_header(file_data, elf_header.e_shoff + i*40)) + #print('%r' % (section_headers[i],)) + if section_headers[i].sh_type == 0x70000005: + debug_index = i + + if debug_index != 0xFFFFFFFF: + symbolic_header = read_symbolic_header(file_data, section_headers[debug_index].sh_offset) + file_descriptors = [] + print('%r' % (symbolic_header,)) + # Set offset by assuming that there are no optimization symbols so cbOptOffset points to the start of the symbolic header + #OFFSET = symbolic_header.cbOptOffset - section_headers[debug_index].sh_offset + #print('Using OFFSET of %d' % OFFSET) + #for sym_num in range(symbolic_header.isymMax): + #sym = read_symbol(file_data, symbolic_header.cbSymOffset - OFFSET + sym_num*12) + #print('%d:%r' % (sym_num, (sym,))); + #for aux_num in range(symbolic_header.iauxMax): + #aux = read_auxiliary_symbol(file_data, symbolic_header.cbAuxOffset - OFFSET + aux_num*4) + #print('%d:%r' % (aux_num, (aux,))); + for file_num in range(symbolic_header.ifdMax): + fd = read_file_descriptor(file_data, symbolic_header.cbFdOffset - OFFSET + file_num*72) + file_descriptors.append(fd) + for file_num in range(symbolic_header.ifdMax): + fd = read_file_descriptor(file_data, symbolic_header.cbFdOffset - OFFSET + file_num*72) + print('%r' % (fd,)) + print(' name:%s' % read_string(file_data, symbolic_header.cbSsOffset - OFFSET + fd.issBase + fd.rss)) + + ''' + print(' Relative File Descriptors:') + for rfd_num in range(fd.rfdBase, fd.rfdBase + fd.crfd): + offset = symbolic_header.cbRfdOffset - OFFSET + rfd_num*4 + rfd_index = struct.unpack('>I', file_data[offset:offset+4])[0] + rfd = read_file_descriptor(file_data, symbolic_header.cbFdOffset - OFFSET + rfd_index*72) + print(' %d:%r' % (rfd_index, (rfd,))) + ''' + + ''' + print(' procedures:') + for proc_num in range(fd.ipdFirst, fd.ipdFirst + fd.cpd): + pd = read_procedure_descriptor(file_data, symbolic_header.cbPdOffset - OFFSET + proc_num*52) + print(' %r' % ((pd,))) + ''' + + ''' + print(' symbols:') + for sym_num in range(fd.isymBase, fd.isymBase + fd.csym): + sym = read_symbol(file_data, symbolic_header.cbSymOffset - OFFSET + sym_num*12) + print(' %r' % ((sym,))) + print(' name:%s' % read_string(file_data, symbolic_header.cbSsOffset - OFFSET + fd.issBase + sym.iss)) + print(' type:%s(%d)' % (symbol_type_list[sym.st], sym.st)) + print(' storage class:%s(%d)' % (storage_class_list[sym.sc], sym.sc)) + if sym.st == 3 or sym.st == 4 or sym.st == 9 or sym.st == 10 or sym.st == 28: # stParam, stLocal, stMember, stTypedef, stEnum + aux = read_auxiliary_symbol(file_data, symbolic_header.cbAuxOffset - OFFSET + (fd.iauxBase + sym.index)*4) + print(' %r' % ((aux,))) + offset = 0 + if aux.ti.fBitfield == 1: + bitfield_aux = read_auxiliary_symbol(file_data, symbolic_header.cbAuxOffset - OFFSET + (fd.iauxBase + sym.index + 1)*4) + print(' %r' % ((bitfield_aux,))) + offset = 1 + if aux.ti.bt == 12 or aux.ti.bt == 13 or aux.ti.bt == 14 or aux.ti.bt == 15: # btStruct, btUnion, btEnum, btTypedef + aux2 = read_auxiliary_symbol(file_data, symbolic_header.cbAuxOffset - OFFSET + (fd.iauxBase + sym.index + 1 + offset)*4) + print(' %r' % ((aux2,))) + fd_num = aux2.rndx.rfd + if fd_num == 4095: + aux3 = read_auxiliary_symbol(file_data, symbolic_header.cbAuxOffset - OFFSET + (fd.iauxBase + sym.index + 2 + offset)*4) + print(' %r' % ((aux3,))) + fd_num = aux3.isym + fd_num = map_relative_file_descriptor(file_data, fd, symbolic_header, fd_num) + sym2 = read_symbol(file_data, symbolic_header.cbSymOffset - OFFSET + (file_descriptors[fd_num].isymBase + aux2.rndx.index)*12) + print(' %r' % (sym2,)) + print(' name:%s' % read_string(file_data, symbolic_header.cbSsOffset - OFFSET + file_descriptors[aux3.isym].issBase + sym2.iss)) + if sym.st == 6 or sym.st == 14: # stProc, stStaticProc + # TODO what is the first aux symbol for? + aux = read_auxiliary_symbol(file_data, symbolic_header.cbAuxOffset - OFFSET + (fd.iauxBase + sym.index)*4) + type_aux = read_auxiliary_symbol(file_data, symbolic_header.cbAuxOffset - OFFSET + (fd.iauxBase + sym.index+1)*4) + print(' %r' % ((aux,))) + print(' %r' % ((type_aux,))) + ''' + + print(' pretty print:') + print_symbols(file_data, fd, symbolic_header) + + +main()
\ No newline at end of file diff --git a/lib/ultralib/tools/strip_debug.sh b/lib/ultralib/tools/strip_debug.sh new file mode 100755 index 0000000..4a8be78 --- /dev/null +++ b/lib/ultralib/tools/strip_debug.sh @@ -0,0 +1,10 @@ +#!/usr/bin/bash + +cd $1 + +mkdir -p .cmp + +for f in *.o ; +do + ${CROSS}objcopy -p --strip-debug $f .cmp/${f/.o/.cmp.o} +done |
