[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



2013/2/15 Alan Hourihane <alanh@fairlite.co.uk>:
> 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:
>>>> 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.
>

When I was making the patch I also looked at Linux sources to see how
they were probing hardware, they have the function hwreg_present():

http://lxr.free-electrons.com/source/arch/m68k/mm/hwtest.c?a=m68k#L17

(I don't think that the comment about that the function is only used
before the VBR is set up is still right)

We could have a similar function in the kernel and export it to kentry
and kinfo structures to be used by drivers.