Turns out I was returning values from syscalls in the wrong register; fixed.
More tests pass.
This commit is contained in:
		
							parent
							
								
									ab660a44e9
								
							
						
					
					
						commit
						78eaf836be
					
				
					 2 changed files with 9 additions and 9 deletions
				
			
		| 
						 | 
				
			
			@ -303,7 +303,7 @@ void dump_state(FILE* stream)
 | 
			
		|||
	int i;
 | 
			
		||||
 | 
			
		||||
	fprintf(stream, "\n");
 | 
			
		||||
	fprintf(stream, "pc=0x%08x lr=0x%08x ctr=0x%08x xer=0x%08x cr=0x%08x\n",
 | 
			
		||||
	fprintf(stream, "pc=0x%08x lr=0x%08x ctr=0x%08x xer=0x%08x cr=0x%08x",
 | 
			
		||||
		cpu.cia, cpu.lr, cpu.ctr, cpu.xer, cpu.cr);
 | 
			
		||||
	for (i=0; i<32; i++)
 | 
			
		||||
	{
 | 
			
		||||
| 
						 | 
				
			
			@ -311,11 +311,11 @@ void dump_state(FILE* stream)
 | 
			
		|||
			fprintf(stream, "\n");
 | 
			
		||||
		fprintf(stream, "gpr%02d=0x%08x ", i, cpu.gpr[i]);
 | 
			
		||||
	}
 | 
			
		||||
	fprintf(stream, "\n");
 | 
			
		||||
	fprintf(stderr, "\n");
 | 
			
		||||
 | 
			
		||||
	/* This might fail and cause a reentrant trap if cia is invalid, so
 | 
			
		||||
	 * do it last. */
 | 
			
		||||
	fprintf(stream, "insn=0x%08x", read_long(cpu.cia));
 | 
			
		||||
	fprintf(stream, "insn=0x%08x\n", read_long(cpu.cia));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void single_step(void)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -136,8 +136,8 @@ void system_call(uint8_t trapno)
 | 
			
		|||
			uint32_t len = cpu.gpr[5];
 | 
			
		||||
			void* ptr = ram + transform_address(address);
 | 
			
		||||
			transform_address(address+len); /* bounds check */
 | 
			
		||||
			cpu.gpr[4] = write(fd, ptr, len);
 | 
			
		||||
			if (cpu.gpr[4] == -1)
 | 
			
		||||
			cpu.gpr[3] = write(fd, ptr, len);
 | 
			
		||||
			if (cpu.gpr[3] == -1)
 | 
			
		||||
				goto error;
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -146,13 +146,13 @@ void system_call(uint8_t trapno)
 | 
			
		|||
		{
 | 
			
		||||
			uint32_t newpos = cpu.gpr[3];
 | 
			
		||||
			if (newpos == 0)
 | 
			
		||||
				cpu.gpr[4] = brkpos;
 | 
			
		||||
				cpu.gpr[3] = brkpos;
 | 
			
		||||
			else if ((newpos < brkbase) || (newpos >= BRK_TOP))
 | 
			
		||||
				cpu.gpr[4] = -ENOMEM;
 | 
			
		||||
				cpu.gpr[3] = -ENOMEM;
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				brkpos = newpos;
 | 
			
		||||
				cpu.gpr[4] = 0;
 | 
			
		||||
				cpu.gpr[3] = 0;
 | 
			
		||||
			}
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -163,7 +163,7 @@ void system_call(uint8_t trapno)
 | 
			
		|||
		case 67: /* sigaction */
 | 
			
		||||
		case 78: /* gettimeofday */
 | 
			
		||||
		case 126: /* sigprocmask */
 | 
			
		||||
			cpu.gpr[4] = 0;
 | 
			
		||||
			cpu.gpr[3] = 0;
 | 
			
		||||
			break;
 | 
			
		||||
 | 
			
		||||
		error:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue