USBGDB Patch for Slim Memory

Create a single thread for each patch to be added to the repository. Please try to stay on topic.
Post Reply
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

USBGDB Patch for Slim Memory

Post by TyRaNiD »

I can't be arsed to find my password these days and don't even have a toolchain installed on this machine so someone else can commit this fix for psplinkusb/usbgdb/main.c which dynamically modifies its memory ranges if you are on a slim with large memory support.

Code: Select all

--- main.c	(revision 2452)
+++ main.c	(working copy)
@@ -34,12 +34,15 @@
 DebugEventHandler g_handler;
 struct GdbContext g_context;
 SceUID g_thid = -1;
+unsigned int userbase = 0x08800000;
+unsigned int usertop =  0x0A000000;
 
 int initialise(SceSize args, void *argp)
 {
 	int len;
 	int fd;
 	Elf32_Ehdr hdr;
+	PspSysmemPartitionInfo info;
 
 	memset(&g_context, 0, sizeof(g_context));
 	if(argp == NULL)
@@ -58,6 +61,14 @@
 	g_context.argp = argp;
 	g_context.args = args;
 
+	memset(&info, 0, sizeof(info));
+	info.size = sizeof(info);
+	if(sceKernelQueryMemoryPartitionInfo(2, &info) == 0)
+	{
+		userbase = info.startaddr;
+		usertop = info.startaddr + info.memsize;
+	}
+
 	fd = sceIoOpen((char*) argp, PSP_O_RDONLY, 0777);
 	if&#40;fd < 0&#41;
 	&#123;
@@ -125,7 +136,7 @@
 	nibble = addr >> 28;
 	addr &= 0x0FFFFFFF;
 
-	if&#40;&#40;addr >= 0x08800000&#41; && &#40;addr < 0x0A000000&#41;&#41;
+	if&#40;&#40;addr >= userbase&#41; && &#40;addr < usertop&#41;&#41;
 	&#123;
 		if&#40;&#40;nibble == 0&#41; || &#40;nibble == 4&#41; || &#40;nibble == 8&#41; || &#40;nibble == 10&#41;&#41;
 		&#123;
@@ -160,7 +171,7 @@
 	nibble = addr >> 28;
 	addr &= 0x0FFFFFFF;
 
-	if&#40;&#40;addr >= 0x08800000&#41; && &#40;addr < 0x0A000000&#41;&#41;
+	if&#40;&#40;addr >= userbase&#41; && &#40;addr < usertop&#41;&#41;
 	&#123;
 		if&#40;&#40;nibble == 0&#41; || &#40;nibble == 4&#41; || &#40;nibble == 8&#41; || &#40;nibble == 10&#41;&#41;
 		&#123;
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

Code: Select all

Sending        usbgdb/main.c
Transmitting file data .
Committed revision 2453.
although I had to patch by hand, so no promises!
hnaves
Posts: 30
Joined: Tue Feb 03, 2009 3:01 am

Post by hnaves »

You forgot to include

Code: Select all

#include <pspsysmem_kernel.h>
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

Fixed in rev 2455, thanks
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Ooops, my bad obviously :)
Post Reply