opuntiaOS - an operating system targeting x86 and ARMv7
at master 45 lines 1.1 kB view raw
1# Copyright (C) 2020-2022 The opuntiaOS Project Authors. 2# + Contributed by Nikita Melekhin <nimelehin@gmail.com> 3# 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6 7from ABI.Structs import * 8 9 10class Translator(): 11 12 @staticmethod 13 def entry_flag(s): 14 translation = { 15 "MMIO": DEVTREE_ENTRY_FLAGS_MMIO, 16 } 17 return translation.get(s, 0) 18 19 @staticmethod 20 def entry_type(s): 21 translation = { 22 "IO": DEVTREE_ENTRY_TYPE_IO, 23 "FB": DEVTREE_ENTRY_TYPE_FB, 24 "UART": DEVTREE_ENTRY_TYPE_UART, 25 "RAM": DEVTREE_ENTRY_TYPE_RAM, 26 "STORAGE": DEVTREE_ENTRY_TYPE_STORAGE, 27 "BUS_CONTROLLER": DEVTREE_ENTRY_TYPE_BUS_CONTROLLER 28 } 29 return translation.get(s, DEVTREE_ENTRY_TYPE_IO) 30 31 @staticmethod 32 def number(s): 33 return int(s, base=0) 34 35 @staticmethod 36 def entry_flags(s): 37 flags = 0x0 38 ents = s.split(" ") 39 40 for ent in ents: 41 t = Translator.entry_flag(s) 42 if t != None: 43 flags |= t 44 45 return flags