Skip to content

Commit

Permalink
Fixed weak imports resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
TheOfficialFloW committed Feb 6, 2016
1 parent 45be72f commit 731ad3b
Show file tree
Hide file tree
Showing 9 changed files with 1,438 additions and 1,112 deletions.
12 changes: 6 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.DS_Store
._*
*.obj
*.o
*.bin
uvloader
.DS_Store
._*
*.obj
*.o
*.bin
uvloader
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LDFLAGS=-T linker.x -nodefaultlibs -nostdlib -pie
OBJCOPY=arm-none-eabi-objcopy
OBJCOPYFLAGS=

OBJ=uvloader.o cleanup.o load.o relocate.o resolve.o utils.o scefuncs.o
OBJ=uvloader.o cleanup.o load.o relocate.o resolve.o utils.o scefuncs.o debugnet.o

all: uvloader

Expand Down
157 changes: 157 additions & 0 deletions debugnet.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
/*
* debugnet library for PSP2
* Copyright (C) 2010,2015 Antonio Jose Ramos Marquez (aka bigboss) @psxdev on twitter
* Repository https://github.com/psxdev/debugnet
*/

#include "uvloader.h"
#include "scefuncs.h"
#include "debugnet.h"

static int debugnet_initialized = 0;
static int SocketFD = -1;
static u8_t net_memory[NET_INIT_SIZE];
static SceNetInAddr vita_addr;
static struct SceNetSockaddrIn stSockAddr;

int debugNetSetup()
{
uvl_scefuncs_resolve_debugnet();

uvl_set_debug_log_func(&uvl_debugnet_log);

return debugNetInit("255.255.255.255", 18194);
}

int uvl_debugnet_log(const char *line)
{
debugNetUDPPrintf("%s\n", line);
return 0;
}

int debugNetSend(const char* line, u32_t size)
{
int res = sceNetSendto(SocketFD, line, size, 0, (struct SceNetSockaddr *)&stSockAddr, sizeof stSockAddr);
if (res < 0)
return res;

return 0;
}

/**
* UDP printf for debugnet library
*
* @par Example:
* @code
* debugNetUDPPrintf("This is a test\n");
* @endcode
*/
void debugNetUDPPrintf(const char* fmt, ...)
{
char buffer[0x800];
va_list arg;
va_start(arg, fmt);
sceClibVsnprintf(buffer, sizeof(buffer), fmt, arg);
va_end(arg);

debugNetSend(buffer, strlen(buffer));
}

/**
* Init debugnet library
*
* @par Example:
* @code
* int ret;
* ret = debugNetInit("172.26.0.2", 18194);
* @endcode
*
* @param serverIP - your pc/mac server ip
* @param port - udp port server
*/
int debugNetInit(const char *serverIp, u16_t port)
{
int ret;
SceNetInitParam initparam;
SceNetCtlInfo info;
if (debugnet_initialized) {
return debugnet_initialized;
}

/*net initialazation code from xerpi at https://github.com/xerpi/FTPVita/blob/master/ftp.c*/
/* Init Net */
if (sceNetShowNetstat() == PSP2_NET_ERROR_ENOTINIT) {
initparam.memory = net_memory;
initparam.size = NET_INIT_SIZE;
initparam.flags = 0;

ret = sceNetInit(&initparam);

//printf("sceNetInit(): 0x%08X\n", ret);
} else {
//printf("Net is already initialized.\n");
}

/* Init NetCtl */
ret = sceNetCtlInit();
//printf("sceNetCtlInit(): 0x%08X\n", ret);

/* Get IP address */
ret = sceNetCtlInetGetInfo(PSP2_NETCTL_INFO_GET_IP_ADDRESS, &info);
//printf("sceNetCtlInetGetInfo(): 0x%08X\n", ret);

/* Save the IP of PSVita to a global variable */
sceNetInetPton(PSP2_NET_AF_INET, info.ip_address, &vita_addr);

uvl_unlock_mem();

/* Create datagram udp socket*/
SocketFD = sceNetSocket("debugnet_socket",
PSP2_NET_AF_INET, PSP2_NET_SOCK_DGRAM, PSP2_NET_IPPROTO_UDP);

memset(&stSockAddr, 0, sizeof stSockAddr);

/*Populate SceNetSockaddrIn structure values*/
stSockAddr.sin_family = PSP2_NET_AF_INET;
stSockAddr.sin_port = sceNetHtons(port);

int broadcast = 1;
sceNetSetsockopt(SocketFD, PSP2_NET_SOL_SOCKET, PSP2_NET_SO_BROADCAST, &broadcast, sizeof(broadcast));

sceNetInetPton(PSP2_NET_AF_INET, serverIp, &stSockAddr.sin_addr);

/*Show log on pc/mac side*/
/*debugNetUDPPrintf("debugnet initialized\n");
debugNetUDPPrintf("Copyright (C) 2010,2015 Antonio Jose Ramos Marquez aka bigboss @psxdev\n");
debugNetUDPPrintf("This Program is subject to the terms of the Mozilla Public\n"
"License, v. 2.0. If a copy of the MPL was not distributed with this\n"
"file, You can obtain one at http://mozilla.org/MPL/2.0/.\n");
debugNetUDPPrintf("ready to have a lot of fun...\n");*/

/*library debugnet initialized*/
debugnet_initialized = 1;
uvl_lock_mem();

return debugnet_initialized;
}

/**
* Finish debugnet library
*
* @par Example:
* @code
* debugNetFinish();
* @endcode
*/
void debugNetFinish()
{
if (debugnet_initialized) {

sceNetCtlTerm();
sceNetTerm();

uvl_unlock_mem();
debugnet_initialized = 0;
uvl_lock_mem();
}
}
80 changes: 80 additions & 0 deletions debugnet.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* debugnet library for PSP2
* Copyright (C) 2010,2015 Antonio Jose Ramos Marquez (aka bigboss) @psxdev on twitter
* Repository https://github.com/psxdev/debugnet
*/
#ifndef _DEBUGNET_H_
#define _DEBUGNET_H_

#include "types.h"
#include "utils.h"

#define PSP2_NET_AF_INET 2
#define PSP2_NET_SOCK_DGRAM 2
#define PSP2_NET_IPPROTO_UDP 17
#define PSP2_NET_SOL_SOCKET 0xffff
#define PSP2_NET_SO_BROADCAST 0x00000020
#define PSP2_NET_ERROR_ENOTINIT 0x804101C8
#define PSP2_NETCTL_INFO_GET_IP_ADDRESS 15
#define PSP2_NETCTL_INFO_CONFIG_NAME_LEN_MAX 64
#define PSP2_NETCTL_INFO_SSID_LEN_MAX 32

typedef struct SceNetInitParam {
void *memory;
s32_t size;
s32_t flags;
} SceNetInitParam;

typedef struct SceNetInAddr {
u32_t s_addr;
} SceNetInAddr;

typedef struct SceNetSockaddrIn {
u8_t sin_len;
u8_t sin_family;
u16_t sin_port;
SceNetInAddr sin_addr;
u16_t sin_vport;
s8_t sin_zero[6];
} SceNetSockaddrIn;

typedef struct SceNetEtherAddr {
u8_t data[6];
} SceNetEtherAddr;

typedef union SceNetCtlInfo {
s8_t cnf_name[PSP2_NETCTL_INFO_CONFIG_NAME_LEN_MAX + 1];
u32_t device;
SceNetEtherAddr ether_addr;
u32_t mtu;
u32_t link;
SceNetEtherAddr bssid;
s8_t ssid[PSP2_NETCTL_INFO_SSID_LEN_MAX + 1];
u32_t wifi_security;
u32_t rssi_dbm;
u32_t rssi_percentage;
u32_t channel;
u32_t ip_config;
s8_t dhcp_hostname[256];
s8_t pppoe_auth_name[128];
s8_t ip_address[16];
s8_t netmask[16];
s8_t default_route[16];
s8_t primary_dns[16];
s8_t secondary_dns[16];
u32_t http_proxy_config;
s8_t http_proxy_server[256];
u32_t http_proxy_port;
} SceNetCtlInfo;


#define NET_INIT_SIZE 1*1024*1024

int debugNetSetup();
int debugNetInit(const char *serverIp, u16_t port);
void debugNetFinish();
int debugNetSend(const char* line, u32_t size);
void debugNetUDPPrintf(const char* fmt, ...);
int uvl_debugnet_log(const char *line);

#endif
Loading

0 comments on commit 731ad3b

Please sign in to comment.