1{- 2 Dev: representation of a device 3 4 Part of Mackerel: a strawman device definition DSL for Barrelfish 5 6 Copyright (c) 2007, 2008, ETH Zurich. 7 All rights reserved. 8 9 This file is distributed under the terms in the attached LICENSE file. 10 If you do not find this file, copies can be found by writing to: 11 ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group. 12-} 13 14module Dev where 15 16import MackerelParser 17 18 19import qualified TypeTable as TT 20import qualified RegisterTable as RT 21import qualified Space 22 23 24{-------------------------------------------------------------------- 25 26--------------------------------------------------------------------} 27 28data Rec = Rec { name :: String, 29 desc :: String, 30 args :: [ AST ], 31 types ::[ TT.Rec ], 32 all_types ::[ TT.Rec ], 33 registers ::[ RT.Rec ], 34 spaces :: [ Space.Rec ], 35 imports :: [ String ] 36 } 37 38-- Create a device record from a list of DeviceFile ASTs from the Parser. The first is the actual device file, while the rest are imports 39make_dev :: DeviceFile -> [DeviceFile] -> Rec 40make_dev df@(DeviceFile (Device n bitorder al d decls) imps) dfl = 41 let ttbl = TT.make_rtypetable df 42 stbl = Space.builtins ++ [ rec | (SpaceDecl rec) <- decls ] 43 rtbl = RT.make_table ttbl decls n bitorder stbl 44 in 45 Rec { name = n, 46 desc = d, 47 args = al, 48 types = ttbl, 49 all_types = ttbl ++ ( concat $ map TT.make_rtypetable dfl ), 50 registers = rtbl, 51 spaces = stbl, 52 imports = imps 53 } 54 55shdws :: Rec -> [ RT.Shadow ] 56shdws dev = RT.get_shadows (registers dev) 57