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

Re: [MiNT] [PATCH] ethernat.xif hangs the system if card isn't present



On 02/15/13 11:28, David Gálvez wrote:
2013/2/15 Alan Hourihane <alanh@fairlite.co.uk>:
On 02/15/13 09:34, Vincent Rivičre wrote:
On 14/02/2013 21:07, David Gálvez wrote:
This patch adds code to change the bus error exception handler before
we try to read the register, and to enable the old one when we're
finish.

Is this the right way to do with FreeMiNT?
I thought there was high level functions like signal catching, etc...

Mmm, yes, I think it should be possible to do....

sigbus()
{
/* failed */
}

SIGACTION(get_curproc(), SIGBUS).sa_handler = (long) sigbus;

Before I made the patch I was unsure if it was a correct practice to
replace the bus error exception handler from a driver,
so I did some investigation, this is what I found out. I think
information below is correct but I'm not 100% sure.

Code inside xdd, xfs and xif modules is run like it was kernel code. Then PID=0.

Take a look at the file sys/signal.c, specially the code below:

/*
  * check_sigs: see if we have any signals pending. if so,
  * handle them.
  */
void
check_sigs (void)
{
	struct proc *p = get_curproc();
	ulong sigs, sigm;
	int i;
	short deliversig;

	if (p->pid == 0)
		return;

Returns if PID is 0 without doing anything, before calling
handle_sig() function where signals are handled.
So I think there is no high level way for signal catching for these drivers.


Good spot. p->pid == 0 would be correct for the handling of kernel mode drivers.

It would be nice though that drivers didn't have to go replacing the bus error handler behind the kernels back.

I wonder if removing this check has any nasty side effects though.

Alan.