Merge pull request #6138 from gblues/master

A handful of fixes & cleanups
This commit is contained in:
Twinaphex 2018-01-20 07:31:06 +01:00 committed by GitHub
commit 214c2fe273
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 122 additions and 18 deletions

1
.gitignore vendored
View File

@ -7,6 +7,7 @@
*.elf
*.dol
*.map
*.swp
.tmp
.tmp.c
.tmp.cxx

View File

@ -7,6 +7,7 @@ GRIFFIN_BUILD = 0
SALAMANDER_BUILD = 0
WHOLE_ARCHIVE_LINK = 0
WIIU_HID = 0
WIIU_LOG_RPX = 0
BUILD_DIR = objs/wiiu
PC_DEVELOPMENT_IP_ADDRESS ?=
PC_DEVELOPMENT_TCP_PORT ?=
@ -38,10 +39,24 @@ OBJ += wiiu/hbl.o
DEFINES :=
ifeq ($(WIIU_LOG_RPX),1)
defines += -DWIIU_LOG_RPX
endif
ifeq ($(WIIU_HID),1)
DEFINES += -DWIIU_HID
OBJ += wiiu/input/hidpad_driver.o
OBJ += wiiu/input/wiiu_hid.o
OBJ += input/connect/joypad_connection.o \
input/connect/connect_ps2adapter.o \
input/connect/connect_psxadapter.o \
input/connect/connect_ps3.o \
input/connect/connect_ps4.o \
input/connect/connect_wii.o \
input/connect/connect_nesusb.o \
input/connect/connect_snesusb.o \
input/connect/connect_wiiupro.o \
input/connect/connect_wiiugca.o
endif
ifeq ($(SALAMANDER_BUILD),1)
@ -95,7 +110,6 @@ else
# DEFINES += -DWANT_IFADDRS
# DEFINES += -DHAVE_FREETYPE
DEFINES += -DHAVE_XMB -DHAVE_MATERIALUI
# DEFINES += -DHAVE_HID
else
HAVE_MENU_COMMON = 1
HAVE_RTGA = 1
@ -121,7 +135,6 @@ else
HAVE_OVERLAY = 1
HAVE_STATIC_VIDEO_FILTERS = 1
HAVE_STATIC_AUDIO_FILTERS = 1
# HAVE_HID = 1
WANT_LIBFAT = 1
WANT_IOSUHAX = 1

View File

@ -26,6 +26,10 @@
#include "hbl.h"
#ifdef WIIU_LOG_RPX
#include "../verbosity.h"
#endif
#define MEM_AREA_TABLE ((s_mem_area*)(MEM_BASE + 0x1600))
#define ELF_DATA_ADDR (*(volatile unsigned int*)(MEM_BASE + 0x1300 + 0x00))
#define ELF_DATA_SIZE (*(volatile unsigned int*)(MEM_BASE + 0x1300 + 0x04))
@ -182,6 +186,62 @@ static int HomebrewCopyMemory(u8 *address, u32 bytes, u32 args_size)
return bytes;
}
#ifdef WIIU_LOG_RPX
#define LINE_LEN 32
/**
* This is called between when the RPX is read off the storage medium and
* when it is sent to the loader. It prints a hexdump to the logger, which
* can then be parsed out by a script.
*
* If we can at least semi-reliably generate the "System Memory Error", this
* can be useful in identifying if the problem is corrupt file i/o vs in-memory
* corruption.
*/
void log_rpx(const char *filepath, unsigned char *buf, size_t len)
{
unsigned int line_buffer[LINE_LEN];
int i, offset;
RARCH_LOG("=== BEGIN file=%s size=%d ===\n", filepath, len);
for(i = 0; i < len; i++)
{
offset = i % LINE_LEN;
line_buffer[offset] = buf[i];
if(offset == (LINE_LEN-1)) {
RARCH_LOG("%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n",
line_buffer[0], line_buffer[1], line_buffer[2], line_buffer[3],
line_buffer[4], line_buffer[5], line_buffer[6], line_buffer[7],
line_buffer[8], line_buffer[9], line_buffer[10], line_buffer[11],
line_buffer[12], line_buffer[13], line_buffer[14], line_buffer[15],
line_buffer[16], line_buffer[17], line_buffer[18], line_buffer[19],
line_buffer[20], line_buffer[21], line_buffer[22], line_buffer[23],
line_buffer[24], line_buffer[25], line_buffer[26], line_buffer[27],
line_buffer[28], line_buffer[29], line_buffer[30], line_buffer[31]);
}
}
if((len % LINE_LEN) != 0) {
for(i = (LINE_LEN - (len % LINE_LEN)); i < LINE_LEN; i++)
{
line_buffer[i] = 0;
}
RARCH_LOG("%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n",
line_buffer[0], line_buffer[1], line_buffer[2], line_buffer[3],
line_buffer[4], line_buffer[5], line_buffer[6], line_buffer[7],
line_buffer[8], line_buffer[9], line_buffer[10], line_buffer[11],
line_buffer[16], line_buffer[17], line_buffer[18], line_buffer[19],
line_buffer[20], line_buffer[21], line_buffer[22], line_buffer[23],
line_buffer[24], line_buffer[25], line_buffer[26], line_buffer[27],
line_buffer[28], line_buffer[29], line_buffer[30], line_buffer[31]);
}
RARCH_LOG("=== END %s ===\n", filepath);
}
#endif
int HBL_loadToMemory(const char *filepath, u32 args_size)
{
if (!filepath || !*filepath)
@ -202,8 +262,8 @@ int HBL_loadToMemory(const char *filepath, u32 args_size)
u32 fileSize = ftell(fp);
fseek(fp, 0, SEEK_SET);
unsigned char *buffer = (unsigned char *) memalign(0x40, (fileSize + 0x3F) & ~0x3F);
size_t buffer_size = (fileSize + 0x3f) & ~0x3f;
unsigned char *buffer = (unsigned char *) memalign(0x40, buffer_size);
if (!buffer)
{
@ -211,6 +271,8 @@ int HBL_loadToMemory(const char *filepath, u32 args_size)
return -1;
}
memset(buffer, 0, buffer_size);
/* Copy rpl in memory */
while (bytesRead < fileSize)
{
@ -242,6 +304,9 @@ int HBL_loadToMemory(const char *filepath, u32 args_size)
printf("File read failure");
return -1;
}
#ifdef WIIU_LOG_RPX
log_rpx(filepath, buffer, bytesRead);
#endif
int ret = HomebrewCopyMemory(buffer, bytesRead, args_size);

View File

@ -71,7 +71,6 @@ static bool hidpad_init(void *data)
{
(void *)data;
#if 0
hid_driver = init_hid_driver();
if (!hid_driver)
{
@ -83,9 +82,6 @@ static bool hidpad_init(void *data)
ready = true;
return true;
#else
return false;
#endif
}
static bool hidpad_query_pad(unsigned pad)

View File

@ -252,7 +252,15 @@ static void stop_polling_thread(wiiu_hid_t *hid)
if (!hid || !hid->polling_thread)
return;
/* Unregister our HID client so we don't get any new events. */
if(hid->client) {
HIDDelClient(hid->client);
hid->client = NULL;
}
/* tell the thread it's time to stop. */
hid->polling_thread_quit = true;
/* This returns once the thread runs and the cleanup method completes. */
OSJoinThread(hid->polling_thread, &thread_result);
free(hid->polling_thread);
free(hid->polling_thread_stack);
@ -494,7 +502,7 @@ static void wiiu_hid_polling_thread_cleanup(OSThread *thread, void *stack)
if(adapter->state == ADAPTER_STATE_READING)
incomplete++;
}
/* We are clear for shutdown. Clean up the list
/* We are clear for shutdown. Clean up the list
* while we are holding the lock. */
if(incomplete == 0)
{

View File

@ -1,14 +1,35 @@
#!/bin/sh
#!/bin/bash
if [ -z $1 ] ; then
echo
echo "usage: $0 <WiiU-ip>"
echo
exit 0
#
# This script listens for the WiiU network logger and prints the messages to
# the terminal.
#
# If you would like a logfile, pipe this script's output to tee.
script_dir=$(dirname $(readlink -f $0))
# Using wiiu-devel.properties ensure your make file and this listen script
# stay in sync with each other.
#
# See wiiu-devel.properties.template for instructions.
if [ -e "$script_dir/../wiiu-devel.properties" ]; then
. $script_dir/../wiiu-devel.properties
fi
interrupt_count=0
if [ -z "$PC_DEVELOPMENT_TCP_PORT" ]; then
PC_DEVELOPMENT_TCP_PORT=4405
fi
trap 'if [ $interrupt_count -eq 20 ]; then exit 0; else interrupt_count=$(($interrupt_count + 1)); fi' INT
exit_listen_loop=0
while true; do echo; echo ========= `date` =========; echo; netcat -p 4405 -l $1; done
#
# This prevents a tug-of-war between bash and netcat as to who gets the
# CTRL+C code.
#
trap 'exit_listen_loop=1' SIGINT
while [ $exit_listen_loop -eq 0 ]; do
echo ========= `date` =========
netcat -p $PC_DEVELOPMENT_TCP_PORT -l
done