Previous - Up - Next

10.3   DEC21140A-dml

The DEC21140A is a PCI Ethernet card. As the AM79C960, it is obsolete today but it provides a good example of a PCI device written in DML.

Normally the module and device class would both have been named DEC21140A, but because Virtutech already had a DEC21140A device model written in C, the sample DML module and the device class are named DEC21140A-dml.

It may be good to have the documentation for the DEC21140A chip when looking at the sample code, so that you can compare the code to the specification. The documentation can be found on the Internet, for example by looking for ec-qn7nc-te.ps.gz with Google.

The source code for the sample device can be found in the directory [simics]/src/devices/DEC21140A-dml. If you want to modify the DEC21140A-dml module yourself, we recommend that you set up a user workspace and copy the source code there, as described in section 3.

10.3.1   Running the DEC21140A model with Enterprise

If your distribution contains the simulated machine enterprise, you can find the Simics script enterprise-DEC21140A-dml.simics in the directory [simics]/targets/x86-440bx. This file creates an enterprise machine using the DEC21140A-dml module instead of the default AM79C360 module. The DEC21140A object is called dec0.

The script enterprise-DEC21140A-dml.simics configures automatically a network link (connected to the DEC device) and a service-node on the link.

Start the simulation, let the machine boot, and log in as the user root. No password is required. You need to load the right kernel module for the DEC device to be recognized:

[root@enterprise root]# modprobe tulip
PCI: Setting latency timer of device 00:02.0 to 64
[root@enterprise root]# 

Once the driver is loaded, the card will be automatically configured by the system. Wait a few seconds and issue an ifconfig command to check that the device eth0 is configured:

[root@enterprise root]# ifconfig
eth0      Link encap:Ethernet  HWaddr 10:10:10:10:10:30
          inet addr:10.10.0.15  Bcast:10.10.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:78 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:0 (0.0 b)  TX bytes:168 (168.0 b)
          Interrupt:10 Base address:0xd080

lo        Link encap:Local Loopback
[...]
[root@enterprise root]# 

You can try to ping the service-node to check that networking is working:

[root@enterprise root]# ping 10.10.0.1
PING 10.10.0.1 (10.10.0.1) from 10.10.0.15 : 56(84) bytes of data.
64 bytes from 10.10.0.1: icmp_seq=1 ttl=31 time=0.286 ms
64 bytes from 10.10.0.1: icmp_seq=2 ttl=31 time=0.095 ms
64 bytes from 10.10.0.1: icmp_seq=3 ttl=31 time=0.095 ms
64 bytes from 10.10.0.1: icmp_seq=4 ttl=31 time=0.095 ms
64 bytes from 10.10.0.1: icmp_seq=5 ttl=31 time=0.094 ms
64 bytes from 10.10.0.1: icmp_seq=6 ttl=31 time=0.095 ms
[...]

10.3.2   Running the DEC21140A model with Ebony

If your distribution contains the simulated machine ebony, you can find the Simics script ebony-linux-dec21140a-dml.simics in the directory [simics]/targets/ebony. This file creates an ebony machine using the DEC21140A-dml module. The DEC21140A object is called dec0.

The script ebony-DEC21140A-dml.simics configures automatically a network link (connected to the DEC device) and a service-node on the link.

Start the simulation and let the machine boot. The network card will be configured automatically at the prompt. You can try to ping the service-node to check that networking is working:

# ping 10.10.0.1
PING 10.10.0.1 (10.10.0.1): 56 data bytes
64 bytes from 10.10.0.1: icmp_seq=0 ttl=31 time=0.0 ms
64 bytes from 10.10.0.1: icmp_seq=1 ttl=31 time=0.0 ms
64 bytes from 10.10.0.1: icmp_seq=2 ttl=31 time=0.0 ms
64 bytes from 10.10.0.1: icmp_seq=3 ttl=31 time=0.0 ms

10.3.3   Comments to the Code

The source code of the DEC21140A module is quite heavily commented, so if you have the documentation for the DEC21140A chip you should hopefully be able to understand most of the code without too much problem.

The DEC21140A model is far from complete, it implements just enough functionality that the device model can be used with Linux.

Note that the source code has been divided into two files:

DEC21140A.dml
This file contains the register bank definitions for the PCI configuration and the CSR registers.
DEC21140A-eth.dml
This file contains code to handle the network and Ethernet frames.
.

The DEC21140A model is built around other models: the SROM is configured as a Microwire EEPROM; the MAC layer and communication with the Ethernet link are handled by the generic mii-transceiver and mii-bus-management modules. In each case, the DEC device communicates via the interfaces that these devices export.

Previous - Up - Next