1*4df3f195SPeter Maydell 2*4df3f195SPeter MaydellEDU device 3*4df3f195SPeter Maydell========== 4*4df3f195SPeter Maydell 5*4df3f195SPeter Maydell.. 6*4df3f195SPeter Maydell Copyright (c) 2014-2015 Jiri Slaby 7*4df3f195SPeter Maydell 8*4df3f195SPeter Maydell This document is licensed under the GPLv2 (or later). 9*4df3f195SPeter Maydell 10*4df3f195SPeter MaydellThis is an educational device for writing (kernel) drivers. Its original 11*4df3f195SPeter Maydellintention was to support the Linux kernel lectures taught at the Masaryk 12*4df3f195SPeter MaydellUniversity. Students are given this virtual device and are expected to write a 13*4df3f195SPeter Maydelldriver with I/Os, IRQs, DMAs and such. 14*4df3f195SPeter Maydell 15*4df3f195SPeter MaydellThe devices behaves very similar to the PCI bridge present in the COMBO6 cards 16*4df3f195SPeter Maydelldeveloped under the Liberouter wings. Both PCI device ID and PCI space is 17*4df3f195SPeter Maydellinherited from that device. 18*4df3f195SPeter Maydell 19*4df3f195SPeter MaydellCommand line switches 20*4df3f195SPeter Maydell--------------------- 21*4df3f195SPeter Maydell 22*4df3f195SPeter Maydell``-device edu[,dma_mask=mask]`` 23*4df3f195SPeter Maydell ``dma_mask`` makes the virtual device work with DMA addresses with the given 24*4df3f195SPeter Maydell mask. For educational purposes, the device supports only 28 bits (256 MiB) 25*4df3f195SPeter Maydell by default. Students shall set dma_mask for the device in the OS driver 26*4df3f195SPeter Maydell properly. 27*4df3f195SPeter Maydell 28*4df3f195SPeter MaydellPCI specs 29*4df3f195SPeter Maydell--------- 30*4df3f195SPeter Maydell 31*4df3f195SPeter MaydellPCI ID: 32*4df3f195SPeter Maydell ``1234:11e8`` 33*4df3f195SPeter Maydell 34*4df3f195SPeter MaydellPCI Region 0: 35*4df3f195SPeter Maydell I/O memory, 1 MB in size. Users are supposed to communicate with the card 36*4df3f195SPeter Maydell through this memory. 37*4df3f195SPeter Maydell 38*4df3f195SPeter MaydellMMIO area spec 39*4df3f195SPeter Maydell-------------- 40*4df3f195SPeter Maydell 41*4df3f195SPeter MaydellOnly ``size == 4`` accesses are allowed for addresses ``< 0x80``. 42*4df3f195SPeter Maydell``size == 4`` or ``size == 8`` for the rest. 43*4df3f195SPeter Maydell 44*4df3f195SPeter Maydell0x00 (RO) : identification 45*4df3f195SPeter Maydell Value is in the form ``0xRRrr00edu`` where: 46*4df3f195SPeter Maydell - ``RR`` -- major version 47*4df3f195SPeter Maydell - ``rr`` -- minor version 48*4df3f195SPeter Maydell 49*4df3f195SPeter Maydell0x04 (RW) : card liveness check 50*4df3f195SPeter Maydell It is a simple value inversion (``~`` C operator). 51*4df3f195SPeter Maydell 52*4df3f195SPeter Maydell0x08 (RW) : factorial computation 53*4df3f195SPeter Maydell The stored value is taken and factorial of it is put back here. 54*4df3f195SPeter Maydell This happens only after factorial bit in the status register (0x20 55*4df3f195SPeter Maydell below) is cleared. 56*4df3f195SPeter Maydell 57*4df3f195SPeter Maydell0x20 (RW) : status register 58*4df3f195SPeter Maydell Bitwise OR of: 59*4df3f195SPeter Maydell 60*4df3f195SPeter Maydell 0x01 61*4df3f195SPeter Maydell computing factorial (RO) 62*4df3f195SPeter Maydell 0x80 63*4df3f195SPeter Maydell raise interrupt after finishing factorial computation 64*4df3f195SPeter Maydell 65*4df3f195SPeter Maydell0x24 (RO) : interrupt status register 66*4df3f195SPeter Maydell It contains values which raised the interrupt (see interrupt raise 67*4df3f195SPeter Maydell register below). 68*4df3f195SPeter Maydell 69*4df3f195SPeter Maydell0x60 (WO) : interrupt raise register 70*4df3f195SPeter Maydell Raise an interrupt. The value will be put to the interrupt status 71*4df3f195SPeter Maydell register (using bitwise OR). 72*4df3f195SPeter Maydell 73*4df3f195SPeter Maydell0x64 (WO) : interrupt acknowledge register 74*4df3f195SPeter Maydell Clear an interrupt. The value will be cleared from the interrupt 75*4df3f195SPeter Maydell status register. This needs to be done from the ISR to stop 76*4df3f195SPeter Maydell generating interrupts. 77*4df3f195SPeter Maydell 78*4df3f195SPeter Maydell0x80 (RW) : DMA source address 79*4df3f195SPeter Maydell Where to perform the DMA from. 80*4df3f195SPeter Maydell 81*4df3f195SPeter Maydell0x88 (RW) : DMA destination address 82*4df3f195SPeter Maydell Where to perform the DMA to. 83*4df3f195SPeter Maydell 84*4df3f195SPeter Maydell0x90 (RW) : DMA transfer count 85*4df3f195SPeter Maydell The size of the area to perform the DMA on. 86*4df3f195SPeter Maydell 87*4df3f195SPeter Maydell0x98 (RW) : DMA command register 88*4df3f195SPeter Maydell Bitwise OR of: 89*4df3f195SPeter Maydell 90*4df3f195SPeter Maydell 0x01 91*4df3f195SPeter Maydell start transfer 92*4df3f195SPeter Maydell 0x02 93*4df3f195SPeter Maydell direction (0: from RAM to EDU, 1: from EDU to RAM) 94*4df3f195SPeter Maydell 0x04 95*4df3f195SPeter Maydell raise interrupt 0x100 after finishing the DMA 96*4df3f195SPeter Maydell 97*4df3f195SPeter MaydellIRQ controller 98*4df3f195SPeter Maydell-------------- 99*4df3f195SPeter Maydell 100*4df3f195SPeter MaydellAn IRQ is generated when written to the interrupt raise register. The value 101*4df3f195SPeter Maydellappears in interrupt status register when the interrupt is raised and has to 102*4df3f195SPeter Maydellbe written to the interrupt acknowledge register to lower it. 103*4df3f195SPeter Maydell 104*4df3f195SPeter MaydellThe device supports both INTx and MSI interrupt. By default, INTx is 105*4df3f195SPeter Maydellused. Even if the driver disabled INTx and only uses MSI, it still 106*4df3f195SPeter Maydellneeds to update the acknowledge register at the end of the IRQ handler 107*4df3f195SPeter Maydellroutine. 108*4df3f195SPeter Maydell 109*4df3f195SPeter MaydellDMA controller 110*4df3f195SPeter Maydell-------------- 111*4df3f195SPeter Maydell 112*4df3f195SPeter MaydellOne has to specify, source, destination, size, and start the transfer. One 113*4df3f195SPeter Maydell4096 bytes long buffer at offset 0x40000 is available in the EDU device. I.e. 114*4df3f195SPeter Maydellone can perform DMA to/from this space when programmed properly. 115*4df3f195SPeter Maydell 116*4df3f195SPeter MaydellExample of transferring a 100 byte block to and from the buffer using a given 117*4df3f195SPeter MaydellPCI address ``addr``: 118*4df3f195SPeter Maydell 119*4df3f195SPeter Maydell:: 120*4df3f195SPeter Maydell 121*4df3f195SPeter Maydell addr -> DMA source address 122*4df3f195SPeter Maydell 0x40000 -> DMA destination address 123*4df3f195SPeter Maydell 100 -> DMA transfer count 124*4df3f195SPeter Maydell 1 -> DMA command register 125*4df3f195SPeter Maydell while (DMA command register & 1) 126*4df3f195SPeter Maydell ; 127*4df3f195SPeter Maydell 128*4df3f195SPeter Maydell:: 129*4df3f195SPeter Maydell 130*4df3f195SPeter Maydell 0x40000 -> DMA source address 131*4df3f195SPeter Maydell addr+100 -> DMA destination address 132*4df3f195SPeter Maydell 100 -> DMA transfer count 133*4df3f195SPeter Maydell 3 -> DMA command register 134*4df3f195SPeter Maydell while (DMA command register & 1) 135*4df3f195SPeter Maydell ; 136