1
Fabrice Mérillon, Laurent Réveillère, Charles Consel, Renaud Marlet, Gilles Muller
Compose Group http://www.irisa.fr/compose Irisa/Labri, Rennes/Bordeaux (France)
Devil: an IDL for Hardware Programming Fabrice Mrillon, Laurent - - PowerPoint PPT Presentation
Devil: an IDL for Hardware Programming Fabrice Mrillon, Laurent Rveillre, Charles Consel, Renaud Marlet, Gilles Muller Compose Group http://www.irisa.fr/compose Irisa/Labri, Rennes/Bordeaux (France) 1 Interfacing Devices ... The
1
Compose Group http://www.irisa.fr/compose Irisa/Labri, Rennes/Bordeaux (France)
Page 2 Page 2 Compose group Compose group
Page 3 Page 3 Compose group Compose group
#define MSE_DATA_PORT 0x23c #define MSE_SIGNATURE_PORT 0x23d #define MSE_CONTROL_PORT 0x23e ... #define MSE_READ_X_LOW 0x80 #define MSE_READ_X_HIGH 0xa0
(busmouse.h) (busmouse.h)
dy = (inb(MSE_DATA_PORT) & 0xf);
buttons = inb(MSE_DATA_PORT); dy |= (buttons & 0xf) << 4; buttons = ((buttons >> 5) & 0x07);
(busmouse.c) (busmouse.c)
Page 4 Page 4 Compose group Compose group
N Assembly-level programming style N Macros
Page 5 Page 5 Compose group Compose group
N Paper documentation » natural language » manufacturer-specific terminology » inconsistencies, ambiguities, omissions, typos N Mixed levels of abstractions » communication mechanisms, data layout, semantics N Inherent complexity of devices
Page 6 Page 6 Compose group Compose group
Device Driver System Application
API API DI
MSE_CONTROL_PORT ); dy = (inb(MSE_DATA_PORT) & 0xf);
MSE_CONTROL_PORT); buttons = inb(MSE_DATA_PORT); dy |= (buttons & 0xf) << 4;
Existing device interface code
DevI L
CDevil Generated Stubs
Page 7 Page 7 Compose group Compose group
Hardware vendor, Public repository, Device expert
Verifier Compiler
Device Specification
D e v I L D e v I L
Driver CDevil
Driver programmer
C stubs (run-time checks)
Page 8 Page 8 Compose group Compose group
N Ports
N Registers
N Variables: programmer interface
» bounded integers » enumerated types
Page 9 Page 9 Compose group Compose group
N Consistency of Devil specifications
N CDevil interface usage in debug mode
Page 10 Page 10 Compose group Compose group
N dx (delta X)
N dy (delta Y)
N buttons
Page 11 Page 11 Compose group Compose group
dx = (inb(MSE_DATA_PORT) & 0xf);
dx |= (inb(MSE_DATA_PORT) & 0xf) << 4;
dy = (inb(MSE_DATA_PORT) & 0xf);
buttons = inb(MSE_DATA_PORT); dy |= (buttons & 0xf) << 4; buttons = ((buttons >> 5) & 0x07); Existing code dx = get_dx(); dy = get_dy(); buttons = get_buttons(); CDevil
Page 12 Page 12 Compose group Compose group
* * * * . . . . * * * * . . . . * * * * . . . . . . . * . . . . base + 0 1 . . 0 0 0 0 0 base + 2
1 1 2 2 3 3 index dx dy buttons
Direct register Register array
Page 13 Page 13 Compose group Compose group
...
register index_reg = write base@2, mask ’1..00000’: bit[8];
* * * * . . . . * * * * . . . . * * * * . . . . . . . * . . . . base + 0
buttons dx dy
1 . . 0 0 0 0 0 base + 2
→ index_reg 1 1 2 2 3 3
index
Register array
Page 14 Page 14 Compose group Compose group
... register index_reg = write base@2, mask ’1..00000’ : bit[8];
private variable index = index_reg[6..5] : int(2);
* * * * . . . . * * * * . . . . * * * * . . . . . . . * . . . . base + 0 1 . . 0 0 0 0 0 base + 2
→ index_reg 1 1 2 2 3 3 dx dy buttons
index
Register array
Page 15 Page 15 Compose group Compose group
... register index_reg = write base@2, mask ’1..00000’ : bit[8]; private variable index = index_reg[6..5] : int(2); ...
register x_low = read base@0, pre {index = 0}, mask ’****....’ : bit[8]; register x_high = read base@0, pre {index = 1}, mask ’****....’ : bit[8];
...
* * * * . . . . * * * * . . . . * * * * . . . . . . . * . . . . base + 0
→ x_low → x_high → y_low → y_high
1 . . 0 0 0 0 0 base + 2
→ index_reg 1 1 2 2 3 3 dx dy buttons
index
Page 16 Page 16 Compose group Compose group
... register index_reg = write base@2, mask ’1..00000’ : bit[8]; private variable index = index_reg[6..5] : int(2); ... register x_low = read base@0, pre {index = 0}, mask ’****....’ : bit[8]; register x_high = read base@0, pre {index = 1}, mask ’****....’ : bit[8]; ...
variable dx = x_high[3..0] # x_low[3..0], volatile : signed int(8); variable dy = y_high[3..0] # y_low[3..0], volatile : signed int(8);
* * * * . . . . * * * * . . . . * * * * . . . . . . . * . . . . base + 0
→ x_low → x_high → y_low → y_high
1 . . 0 0 0 0 0 base + 2
→ index_reg 1 1 2 2 3 3 dx dy buttons
index
Page 17 Page 17 Compose group Compose group
N Sharing registers between variables may
N Re-engineering of performance critical
Page 18 Page 18 Compose group Compose group
N Characteristics:
N DMA mode C: 14 I/Os Devil: 20 I/Os 14.25 Mb/s N PIO-32bits mode, 16 sectors/interrupt C (rep loop): 8.17 Mb/s Devil (C loop): 7.36 Mb/s (90% of C) Devil (rep loop): 8.17 Mb/s
Page 19 Page 19 Compose group Compose group
N Characteristics:
N Screen copy operations (24 bpp) – 100% performance of C N Rectangle operations (24 bpp) – 97%-100% performance of C – difference due to stub code for small size operation
Page 20 Page 20 Compose group Compose group
N Expressivity » advanced Devil constructs (see paper and manual) » DMA, sound, interrupt, Ethernet controllers N Guaranteed safety » Mutation-based experiment (typo simulation) » 5 times less prone to errors than C code N Negligible performance overhead N Improved productivity » reuse of specifications » tools and verifications
Page 21 Page 21 Compose group Compose group
Device specification Device interface implementation Verifier Compiler Hardware vendor Device interface documentation Device driver specification DSL type-checker DSL optimizer DSL compiler Driver programmer Device driver documentation Generated device driver
Page 22 Page 22 Compose group Compose group
N Step toward the development of robust
N Compiler/checker available N No performance penalty N Expressive enough to allow the
Page 23 Page 23 Compose group Compose group
Page 24 Page 24 Compose group Compose group
N Specifications/compiler/manual available :
N Public CVS repository of specs