Bug 27930

Summary: NE2000 not supported on FreeBSD Alpha 4.x; fix included
Product: Base System Reporter: thomas.pornin <Thomas.Pornin>
Component: alphaAssignee: freebsd-alpha (Nobody) <alpha>
Status: Closed FIXED    
Severity: Affects Only Me CC: alpha
Priority: Normal    
Version: 4.3-RELEASE   
Hardware: Any   
OS: Any   

Description thomas.pornin 2001-06-07 12:40:01 UTC
The NE2000 support is i386-only, although one of the kernel source
files (/dev/ed/if_ed_pci.c) is in sys/conf/files, not in sys/conf/files.i386.

Fix: 

I stole a patch from FreeBSD-5.0; the fix is the following:

** add the following function at the end of src/sys/alpha/alpha/vm_machdep.c:

u_long kvtop(void *addr)
{
	vm_offset_t va;

	if (va == 0) panic("kvtop: zero page frame");
	return (int)va;
}

** add the following prototype in sys/dev/ed/if_ed.c:

u_long kvtop(void *);

** move the following three lines from sys/conf/files.i386 to sys/conf/files:

dev/ed/if_ed.c          optional ed
dev/ed/if_ed_isa.c      optional ed isa
dev/ed/if_ed_pccard.c   optional ed card


Then compile the kernel with the line 'device ed0' in the config file.
It will link, boot up, recognize the card and use it. At least it works
for me (this message is sent from that machine, through that network
adapter).


I do not provide a unified diff because I think the patch will have to
be a bit sorted out:
-- the cast to int in kvtop() looks suspicious to me
-- cc complains a bit about kvtop() defined without a prior prototype
-- adding a prototype to if_ed.c does not look "clean" and I am not
sure it won't break things on i386
-- credits should be given: I am not the original author of that fix,
I stole it from some message in some mailing-list which would cite
it as coming from the FreeBSD-5.0-current cvs source repository


Yet I believe that it should be fairly easy to add the NE2000 Alpha
support in FreeBDS 4.4 without breaking anything else.

(I do know that NE2000 clones are lousy cards, but they are really cheap)
How-To-Repeat: 
Try compiling a 4.3-RELEASE (or 4.2-RELEASE) kernel with the line:

device ed0

in the config file. It won't link, complaining about not found symbols
(such as ed_probe_Novell_generic, which is in sys/dev/ed/if_ed.c).
Comment 1 mjacob 2001-06-07 16:49:04 UTC
No- I'm afraid this won't be the right answer. kvtop  will go away- what has
to happen is that ed needs to be dmabus-ified.



On Thu, 7 Jun 2001 thomas.pornin@ens.fr wrote:

> 
> >Number:         27930
> >Category:       alpha
> >Synopsis:       NE2000 not supported on FreeBSD Alpha 4.x; fix included
> >Confidential:   no
> >Severity:       non-critical
> >Priority:       medium
> >Responsible:    freebsd-alpha
> >State:          open
> >Quarter:        
> >Keywords:       
> >Date-Required:
> >Class:          change-request
> >Submitter-Id:   current-users
> >Arrival-Date:   Thu Jun 07 04:40:01 PDT 2001
> >Closed-Date:
> >Last-Modified:
> >Originator:     Thomas Pornin
> >Release:        FreeBSD 4.3-RELEASE alpha
> >Organization:
> Ecole Normale Superieure
> >Environment:
> 
> The machine is an AXPpci (NoName) Alpha board, with a 166 MHz 21066 cpu,
> 32 MBytes ram, 256 Kbytes cache. I added an add-on Realtek 8029 PCI
> ethernet card, which is supposed to emulate a NE2000 10Mbits card.
> 
> 
> >Description:
> 
> The NE2000 support is i386-only, although one of the kernel source
> files (/dev/ed/if_ed_pci.c) is in sys/conf/files, not in sys/conf/files.i386.
> 
> 
> >How-To-Repeat:
> 
> Try compiling a 4.3-RELEASE (or 4.2-RELEASE) kernel with the line:
> 
> device ed0
> 
> in the config file. It won't link, complaining about not found symbols
> (such as ed_probe_Novell_generic, which is in sys/dev/ed/if_ed.c).
> 
> 
> >Fix:
> 
> I stole a patch from FreeBSD-5.0; the fix is the following:
> 
> ** add the following function at the end of src/sys/alpha/alpha/vm_machdep.c:
> 
> u_long kvtop(void *addr)
> {
> 	vm_offset_t va;
> 
> 	if (va == 0) panic("kvtop: zero page frame");
> 	return (int)va;
> }
> 
> ** add the following prototype in sys/dev/ed/if_ed.c:
> 
> u_long kvtop(void *);
> 
> ** move the following three lines from sys/conf/files.i386 to sys/conf/files:
> 
> dev/ed/if_ed.c          optional ed
> dev/ed/if_ed_isa.c      optional ed isa
> dev/ed/if_ed_pccard.c   optional ed card
> 
> 
> Then compile the kernel with the line 'device ed0' in the config file.
> It will link, boot up, recognize the card and use it. At least it works
> for me (this message is sent from that machine, through that network
> adapter).
> 
> 
> I do not provide a unified diff because I think the patch will have to
> be a bit sorted out:
> -- the cast to int in kvtop() looks suspicious to me
> -- cc complains a bit about kvtop() defined without a prior prototype
> -- adding a prototype to if_ed.c does not look "clean" and I am not
> sure it won't break things on i386
> -- credits should be given: I am not the original author of that fix,
> I stole it from some message in some mailing-list which would cite
> it as coming from the FreeBSD-5.0-current cvs source repository
> 
> 
> Yet I believe that it should be fairly easy to add the NE2000 Alpha
> support in FreeBDS 4.4 without breaking anything else.
> 
> (I do know that NE2000 clones are lousy cards, but they are really cheap)
> >Release-Note:
> >Audit-Trail:
> >Unformatted:
> 
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-alpha" in the body of the message
>
Comment 2 David E. O'Brien freebsd_committer freebsd_triage 2001-06-07 17:51:26 UTC
Responsible Changed
From-To: freebsd-alpha->obrien
Comment 3 alex 2001-06-07 23:35:18 UTC
Thus spake Matthew Jacob (mjacob@feral.com):

> No- I'm afraid this won't be the right answer. kvtop  will go away- what has
> to happen is that ed needs to be dmabus-ified.

I have a one-year-old patch for that on
http://people.freebsd.org/~alex/remove-kvtop.diff
(it probably won't apply any more).

It removes all occurrencies of kvtop() and replaces it with the more
correct pmap_extract().

Given this, the ed driver compiles again on -alpha as it did when I
initially bus_spacifed the ed driver (that was the reason why I did
it:  One of my alphas only had an NE2000 NIC).

Is there a fix in -CURRENT?  I don't think so (sys/dev/ed/* still use
kvtop()).

Maybe one can rework the above patch, PLEASE?
(Or at least tell me what's wrong, so _I_ can do it).

Alex
-- 
cat: /home/alex/.sig: No such file or directory
Comment 4 mjacob 2001-06-07 23:41:08 UTC
I have nothing wrong with kvtop or pmap_extract. I don't care one way or the
other.

But I do want to see drivers using the dmabus routines. Sometime this year
we'll turn off the hack in alpha that allows PCI drivers to continue to work
on systems with < 2GB of memory.

On Fri, 8 Jun 2001, Alexander Langer wrote:

> Thus spake Matthew Jacob (mjacob@feral.com):
>
> > No- I'm afraid this won't be the right answer. kvtop  will go away- what has
> > to happen is that ed needs to be dmabus-ified.
>
> I have a one-year-old patch for that on
> http://people.freebsd.org/~alex/remove-kvtop.diff
> (it probably won't apply any more).
>
> It removes all occurrencies of kvtop() and replaces it with the more
> correct pmap_extract().
>
> Given this, the ed driver compiles again on -alpha as it did when I
> initially bus_spacifed the ed driver (that was the reason why I did
> it:  One of my alphas only had an NE2000 NIC).
>
> Is there a fix in -CURRENT?  I don't think so (sys/dev/ed/* still use
> kvtop()).
>
> Maybe one can rework the above patch, PLEASE?
> (Or at least tell me what's wrong, so _I_ can do it).
>
> Alex
> --
> cat: /home/alex/.sig: No such file or directory
>
Comment 5 David E. O'Brien freebsd_committer freebsd_triage 2001-06-08 02:29:24 UTC
On Thu, Jun 07, 2001 at 03:50:02PM -0700, Matthew Jacob wrote:
>  Sometime this year
>  we'll turn off the hack in alpha that allows PCI drivers to continue to work
>  on systems with < 2GB of memory.
                   ^

                < or > ?
Comment 6 mjacob 2001-06-08 02:35:00 UTC
On Thu, 7 Jun 2001, David O'Brien wrote:

> On Thu, Jun 07, 2001 at 03:50:02PM -0700, Matthew Jacob wrote:
> >  Sometime this year
> >  we'll turn off the hack in alpha that allows PCI drivers to continue to work
> >  on systems with < 2GB of memory.
>                    ^
> 
>                 < or > ?

Less than. They cannot possibly work even now with systems > 2GB of memory
because we have no direct-mapped implementations that allow for the 1-to-1
mapping of device DMA to primary memory that map more than 2GB.

The hack that allows direct mapping should and will go away because as more
than 2GB systems become even more common, it'll be silly to try and support
things otherwise. The only correct mechanism is bus_dma. 

-matt
Comment 7 alex 2001-09-09 19:48:29 UTC
According to Bill Paul, ed boards don't do bus dma.

However, kvtop is only used in the code of two card types.
We could #ifdef out support for these cards on alpha
so it at least works for most no-name cards.

I would prefer to use bus_dma stuff for the kvtop things, but
I don't own such cards and therefore won't be able to do that.

Alex
Comment 8 David E. O'Brien freebsd_committer freebsd_triage 2001-09-10 17:33:51 UTC
Responsible Changed
From-To: obrien->freebsd-bugs

Someone else is working on this.
Comment 9 Mark Linimon freebsd_committer freebsd_triage 2004-07-22 10:36:18 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-alpha

Canonicalize responsible.
Comment 10 sten 2005-05-23 21:54:36 UTC
The fbsd4 branch has been retired, this won't be fixed in 4.x.
Please close the PR.

-- 
Sten Spans

"There is a crack in everything, that's how the light gets in."
Leonard Cohen - Anthem
Comment 11 Marcel Moolenaar freebsd_committer freebsd_triage 2005-05-24 03:06:37 UTC
State Changed
From-To: open->closed

Expired. Sorry about that...