⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 config.py

📁 C++ 编写的EROS RTOS
💻 PY
📖 第 1 页 / 共 2 页
字号:
## Copyright (C) 1998, 1999, Jonathan S. Shapiro.## This file is part of the EROS Operating System.## This program is free software; you can redistribute it and/or# modify it under the terms of the GNU General Public License# as published by the Free Software Foundation; either version 2,# or (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.## Python script to configure a kernel.## Documentation for this script can be found in the # documentation tree at ##         www/devel/ProgGuide/kernel-config.html##import sysimport stringimport osimport globimport regexconfig_name_table = { }def publish(x):    config_name_table[x] = globals()[x]#################################################### Global variables:#################################################### Known device classes:BT_NONE = -1BT_BASE = 0BT_PCI = 1BT_EISA = 2BT_ISA = 3BT_SCSI = 4BT_USB = 5device_classes = {    -1 : "BT_NONE",    0  : "BT_BASE",    1  : "BT_PCI",    2  : "BT_EISA",    3  : "BT_ISA",    4  : "BT_SCSI",    5  : "BT_USB"    }		   publish('BT_BASE')publish('BT_PCI')publish('BT_EISA')publish('BT_ISA')publish('BT_SCSI')conf_machine = Noneconf_arch = Noneconf_cpus = [ ]conf_options = {}conf_primoptions = {}conf_targets = [ ]conf_busses = [ BT_BASE ]depends_on = {}targdir = "../BUILD/%s" % sys.argv[1]conf_name = os.path.basename(sys.argv[1])port_table = { }port_table[0] = -1mem_addr_table = { }mem_addr_table[0] = -1# file_stack = [] # RE_devname = regex.compile("\([a-zA-Z]+\)\([0-9]*\)?");#################################################### Error Messages##################################################NoMachine = "Unknown machine"#################################################### Known machine and CPU types:##################################################machine_types = {    'x86' : [ "pc" ],    }cpu_types = {    'x86' : [ "i386", "i486", "pentium", "ppro" ],    }def cleanup_targdir():    if not os.path.exists("../BUILD"):	os.mkdir("../BUILD", 0755)    elif not os.path.isdir("../BUILD"):	error("\"../BUILD\" is not a directory")    if not (os.path.exists(targdir)):	os.mkdir(targdir, 0755)    elif not os.path.isdir(targdir):	error("\"%s\" is not a directory" % targdir)    # Clean out the existing contents of that directory    for nm in glob.glob("%s/.*" % targdir):	os.remove(nm)    for nm in glob.glob("%s/*" % targdir):	os.remove(nm)def error(s):#    print "Error in \"%s\" at line %d: %s" % (current_file, current_line, s)    print "Error: %s" % s    sys.exit(1)config_table = {};config_by_name = {};#def device(name, parent=None, irq = None, port = None, mem = None, sz = 0):#    global config_by_name#    if (parent):#	parent = config_by_name[parent]#    else:#	error("Templates must identify their parents")#    tmpl = ConfTemplate(name, parent, irq, port, mem, sz, 'dev ')#    add_conf(tmpl)#next_instance_index = {}#def instance(name, instname, parent = None, irq = None, port = None, mem = None, sz = 0):#    global next_instance_index##    if not parent:#	error("Instances require parents")##    if (name): tmpl = config_by_name[name]#    else: tmpl = None##    parent = config_by_name[parent]##    if parent.devClass != DC_INSTANCE:#	error("Instances can only be hung off of instances")##    if tmpl:#	if (not irq and type(tmpl.irq) == type(5)):#	    irq = tmpl.irq##	if tmpl.irq and irq != tmpl.irq and not irq in tmpl.irq:#	    error("Specified irq not in irq list")##	if (not port and type(tmpl.io_port) == type(5)):#	    port = tmpl.irq##	if (tmpl.io_port and port != tmpl.io_port and not port in tmpl.io_port):#	    error("Specified port not in port list")##	if not mem and tmpl.mem_addr:#	    error("Bad memory address specified")##	if tmpl.mem_addr and not mem in tmpl.mem_addr:#	    error("Specified memory address not in address list")##	name = "%s%d" % (tmpl.name, tmpl.nInstance)#	if (name != instname):#	    error("That instance is already allocated")##	tmpl.nInstance = tmpl.nInstance + 1#    else:#	RE_devname.match(instname)#	if (not next_instance_index.has_key(RE_devname.group(1))):#	    ndx = 0#	else:#	    ndx = next_instance_index[RE_devname.group(1)]##	next_instance_index[RE_devname.group(1)] = ndx+1##	if (RE_devname.group(2) != str(ndx)):#	    error("%s: Unique instances must have sequential indices beginning at 0" % instname)#	name = instname#    #    tmpl = ConfTemplate(name, DC_INSTANCE, parent, irq, port, mem, sz)#    add_conf(tmpl)#    print "Defined instance '%s'." % namedef machine(name):    global conf_machine    global machine_types    valid_machines = machine_types[conf_arch]    if (conf_machine != None):	error("Machine already defined!");    elif (name in valid_machines):	print "Configuring for machine class '%s'." % name	conf_machine = name    else:	error("Unknown machine type")publish('machine')def arch(name):    global conf_arch    global cpu_types    if (conf_arch != None):	error("Architecture already defined!");    elif cpu_types.has_key(name):	print "Configuring for architecture '%s'." % name	conf_arch = name    else:	error("Unknown arch type");publish('arch')def cpu(name):    global conf_machine    global conf_cpus    global cpu_types    if (conf_machine == None):	error("Unknown machine type!");    valid_cpus = cpu_types[conf_arch]    if (name in valid_cpus):#	print "Adding cpu type '%s'." % name	conf_cpus = conf_cpus + [name]    else:	error("Unknown CPU type")publish('cpu')def defoption(name, prim=0):    global conf_options    global conf_primoptions    if (prim):        conf_primoptions[name] = 0    else:        conf_options[name] = 0publish('defoption')#### Following is for internal value extraction:##def option_value(name):    if (conf_options.has_key(name)):        return conf_options[name]    elif (conf_primoptions.has_key(name)):        return conf_primoptions[name]    else:        error("Option_value(\"%s\") on undefined option." % name)def option(name):    global conf_options    global conf_primoptions    if (conf_options.has_key(name)):        conf_options[name] = 1    elif (conf_primoptions.has_key(name)):        conf_primoptions[name] = 1    else:	error("Unknown option \"%s\"" % name)publish('option')def exclude(name):    global conf_options    if (conf_options.has_key(name)):        conf_options[name] = 0    elif (conf_primoptions.has_key(name)):        conf_primoptions[name] = 0    else:	error("Unknown option \"%s\"" % name)publish('exclude')def depends(name1, name2):    global depends_on    global conf_options    global conf_primoptions    if (not depends_on.has_key(name1)):        depends_on[name1] = []    depends_on[name1] = depends_on[name1] + [name2]publish('depends')                #def defbus(name):#    global conf_busses#    conf_busses[name] = 0#publish('defoption')#def bus(name):    global conf_busses    conf_busses = conf_busses + [name]publish('bus')#def target(name):

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -