[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] xaaes.km calls the AES appl_init() in supervisor mode



On 07/03/2013 22:03, Vincent Rivière wrote:
The workaround would be to set USP to a safe location before calling
appl_init() / appl_exit() from supervisor mode.

See the attached testcase. The above trick works fine with both TOS 1.62 and EmuTOS. This is the proof that the AES can be called from supervisor mode, taking special care for USP, as Atari described.

However, it does not work better from xaaes.km. Our problem is probably somewhere else.

My new idea:
From a kernel module, is it legal to call trap #1?

The following scenario happens with EmuTOS:
- xaaes.km calls appl_init() in supervisor mode
- appl_init() calls scrp_write()
- scrp_write() calls Fsfirst() with trap #1

Is that trap #1 legal?
Will it cause trouble inside the kernel?

--
Vincent Rivière
/* Call the AES in supervisor mode.
 * Public domain, by Vincent Riviere, 2013
 * Compile with:
 * m68k-atari-mint-gcc appl.c -o appl.prg -O2 -fomit-frame-pointer -lgem
 */

#include <stdio.h>
#include <gem.h>
#include <mint/osbind.h>

static void set_usp(void *p)
{
	__asm__ volatile
	(
		"move	%0,usp"
	:		/* outputs */
	: "a"(p)	/* inputs */
	: "memory"	/* clobbered regs */
	);
}

unsigned char user_stack[100]; // d1-d7/a0-a6 = 56 bytes

int main(void)
{
	short ret;

	Super(0);

	set_usp(user_stack + sizeof user_stack);

	ret = appl_init();
	printf("appl_init = %d\n", ret);
	getchar();

	return 0;
}