here is the proposed patch. Comments welcome.
ron
Implement new path syntax for the dts. The old syntax, where we had special property names for paths, is deprecated (well, removed, actually). So, instead of what we had before, a pathname property in a node, e.g. pcipath = "0xf, 1"; Now you label the node with the path, e.g. [EMAIL PROTECTED],1 This results in a far cleaner and simpler dts. Boots in qemu. alix1c changes to follow. Signed-off-by: Ronald G. Minnich <[EMAIL PROTECTED]> Index: include/device/path.h Add new type DEVICE_PATH_PCI_BUS, and new struct to support it. Index: mainboard/emulation/qemu-x86/dts Modify the dts to use the new path syntax. Explicitly add a bus. Index: device/device_util.c Support generating path names with new bus type. Index: northbridge/intel/i440bxemulation/dts Significant modifictions to use the new syntax. Change node labels to the new [EMAIL PROTECTED] A pci device is [EMAIL PROTECTED],fn And so on. We need to modify the design doc for this change. Index: northbridge/intel/i440bxemulation/i440bx.c Add domain id to the domain in the dts. Index: util/dtc/flattree.c Significant cleanup -- remove commented out and #if 0 code. Remove the path names as properties and support the labels that define the path name. Index: Makefile Replace -O2 with -g. This makes debug and problem determination easier and we really don't need the performance for -O2. Index: include/device/path.h =================================================================== --- include/device/path.h (revision 583) +++ include/device/path.h (working copy) @@ -21,14 +21,16 @@ enum device_path_type { DEVICE_PATH_NONE = 0, DEVICE_PATH_ROOT, + DEVICE_PATH_PCI_DOMAIN, + DEVICE_PATH_PCI_BUS, DEVICE_PATH_PCI, DEVICE_PATH_PNP, DEVICE_PATH_I2C, DEVICE_PATH_APIC, - DEVICE_PATH_PCI_DOMAIN, DEVICE_PATH_APIC_CLUSTER, DEVICE_PATH_CPU, DEVICE_PATH_CPU_BUS, + DEVICE_PATH_SUPERIO, }; struct pci_domain_path @@ -36,6 +38,11 @@ unsigned domain; }; +struct pci_bus_path +{ + unsigned bus; +}; + struct pci_path { unsigned devfn; @@ -74,7 +81,12 @@ unsigned id; }; +struct superio_path +{ + unsigned iobase; +}; + struct device_path { enum device_path_type type; union { @@ -83,9 +95,11 @@ struct i2c_path i2c; struct apic_path apic; struct pci_domain_path pci_domain; + struct pci_bus_path pci_bus; struct apic_cluster_path apic_cluster; struct cpu_path cpu; struct cpu_bus_path cpu_bus; + struct superio_path superio; } u; }; Index: mainboard/emulation/qemu-x86/dts =================================================================== --- mainboard/emulation/qemu-x86/dts (revision 583) +++ mainboard/emulation/qemu-x86/dts (working copy) @@ -23,22 +23,15 @@ mainboard-name = "QEMU x86"; enabled; constructor = "qemuvga_constructors"; - cpus { - enabled; - }; - domain0 { + cpus {}; + [EMAIL PROTECTED] { /config/("northbridge/intel/i440bxemulation/dts"); - ops = "i440bxemulation_pcidomainops"; - enabled; - pcidomain = "0"; - device0,0 { - enabled; - pcipath = "0,0"; + [EMAIL PROTECTED] { + [EMAIL PROTECTED],0 { + }; + [EMAIL PROTECTED],0 { + /config/("southbridge/intel/i82371eb/dts"); + }; }; - southbridge,intel,i82371eb { - /config/("southbridge/intel/i82371eb/dts"); - pcipath = "1,0"; - enabled; - }; }; }; Index: device/device_util.c =================================================================== --- device/device_util.c (revision 583) +++ device/device_util.c (working copy) @@ -221,6 +221,10 @@ sprintf(buffer, "PCI_DOMAIN: %04x", dev->path.u.pci_domain.domain); break; + case DEVICE_PATH_PCI_BUS: + sprintf(buffer, "PCI_BUS: %04x", + dev->path.u.pci_bus.bus); + break; case DEVICE_PATH_APIC_CLUSTER: sprintf(buffer, "APIC_CLUSTER: %01x", dev->path.u.apic_cluster.cluster); Index: northbridge/intel/i440bxemulation/dts =================================================================== --- northbridge/intel/i440bxemulation/dts (revision 583) +++ northbridge/intel/i440bxemulation/dts (working copy) @@ -21,4 +21,5 @@ { ramsize = "128"; constructor = "i440bx_constructors"; + domainid = "0x8086, 0x7190"; }; Index: northbridge/intel/i440bxemulation/i440bx.c =================================================================== --- northbridge/intel/i440bxemulation/i440bx.c (revision 583) +++ northbridge/intel/i440bxemulation/i440bx.c (working copy) @@ -81,10 +81,10 @@ /* The plain PCI device uses the standard PCI operations. */ struct constructor i440bx_constructors[] = { {.id = {.type = DEVICE_ID_PCI_DOMAIN, - .u = {.pci = {.vendor = 0x8086,.device = 0x7190}}}, - &i440bxemulation_pcidomainops}, + .u = {.pci_domain = {.vendor = 0x8086,.device = 0x7190}}}, + .ops = &i440bxemulation_pcidomainops}, {.id = {.type = DEVICE_ID_PCI, .u = {.pci = {.vendor = 0x8086,.device = 0x7190}}}, - &default_pci_ops_bus}, + .ops = &default_pci_ops_bus}, {.ops = 0}, }; Index: util/dtc/flattree.c =================================================================== --- util/dtc/flattree.c (revision 583) +++ util/dtc/flattree.c (working copy) @@ -521,6 +521,8 @@ int ops_set = 0; int is_root = 0; char *configname; + char *path; + int enabled = 1; fprintf(f, "struct device dev_%s = {\n", tree->label); /* special case -- the root has a distinguished path */ @@ -529,6 +531,36 @@ fprintf(f, "\t.path = { .type = DEVICE_PATH_ROOT },\n"); } + /* from the node names (tree->name) we derive the path */ + path = index(tree->name, '@'); + if (path && path[1]) { + path++; + if (!strncmp(tree->name, "cpu", 3)){ + fprintf(f, "\t.path = {.type=DEVICE_PATH_CPU,.u={.cpu={ .id = %s }}},\n", + path); + } + if (!strncmp(tree->name, "bus", 3)){ + fprintf(f, "\t.path = {.type=DEVICE_PATH_PCI_BUS,.u={.pci_bus={ .bus = %s }}},\n", + path); + } + if (!strncmp(tree->name, "apic", 4)){ + fprintf(f, "\t.path = {.type=DEVICE_PATH_APIC,.u={.apic={ %s }}},\n", + path); + } + if (!strncmp(tree->name, "domain", 6)){ + fprintf(f, "\t.path = {.type=DEVICE_PATH_PCI_DOMAIN,.u={.pci_domain={ .domain = %s }}},\n", + path); + } + if (!strncmp(tree->name, "pci", 3)){ + fprintf(f, "\t.path = {.type=DEVICE_PATH_PCI,.u={.pci={ .devfn = PCI_DEVFN(%s)}}},\n", + path); + } + if (!strncmp(tree->name, "lpc", 3)){ + fprintf(f, "\t.path = {.type=DEVICE_PATH_SUPERIO,.u={.superio={.iobase=%s}}},\n", + path); + } + } + if (tree->config){ configname = clean(tree->label, 0); printf("\t.device_configuration = &%s,\n", configname); @@ -564,21 +596,16 @@ * and some are just set directly into the code (e.g. ops_pci). */ for_each_property(tree, prop) { - if (streq(prop->name, "pcidomain")){ - fprintf(f, "\t.path = {.type=DEVICE_PATH_PCI_DOMAIN,.u={.pci_domain={ .domain = %s }}},\n", - prop->val.val); - } - if (streq(prop->name, "pcipath")){ - fprintf(f, "\t.path = {.type=DEVICE_PATH_PCI,.u={.pci={ .devfn = PCI_DEVFN(%s)}}},\n", - prop->val.val); - } /* to do: check the value, maybe. Kinda pointless though. */ if (streq(prop->name, "on_mainboard")){ fprintf(f, "\t.on_mainboard = 1,\n"); } if (streq(prop->name, "enabled")){ - fprintf(f, "\t.enabled = 1,\n"); + enabled = 1; } + if (streq(prop->name, "disabled")){ + enabled = 0; + } if (streq(prop->name, "config")){ fprintf(f, "\t.device_configuration = &%s,\n", clean(tree->label, 1)); @@ -634,6 +661,7 @@ fprintf(f, "\t.ops = &default_dev_ops_root,\n"); fprintf(f, "\t.dtsname = \"%s\",\n", tree->label); + fprintf(f, "\t.enabled = %d\n", enabled); fprintf(f, "};\n"); } @@ -796,18 +824,6 @@ struct node *child; int seen_name_prop = 0; FILE *f = etarget; -/* - treename = clean(tree->name, 0); - fprintf(f, "struct %s %s = {\n", treename, tree->label); - free(treename); - -*/ -#if 0 - if (vi->flags & FTF_FULLPATH) - emit->string(etarget, tree->fullpath, 0); - else - emit->string(etarget, tree->name, 0); -#endif /* here is the real action. What we have to do, given a -> config entry, is this: * foreach property(tree->config) * search for the property in this node's property list @@ -826,24 +842,13 @@ * the operator should take the node itself, not a string. */ printf("struct %s %s = {\n", structname, treelabel); -// emit->beginnode(etarget, treename); -#if 0 - if (vi->flags & FTF_FULLPATH) - emit->string(etarget, tree->fullpath, 0); - else - emit->string(etarget, tree->name, 0); -#endif for_each_config(tree, configprop) { char *cleanname; int found = 0; if (streq(configprop->name, "constructor")) /* this is special */ continue; -#if 0 - cleanname = clean(configprop->name, 0); - fprintf(f, "\tu32 %s = \n", cleanname); - free(cleanname); -#endif + for_each_property(tree, dtsprop) { if (streq(dtsprop->name,configprop->name)){ emit->data(etarget, dtsprop); @@ -854,28 +859,8 @@ emit->data(etarget, configprop); } -#if 0 - if ((vi->flags & FTF_NAMEPROPS) && !seen_name_configprop) { - fprintf(f, "\tu8 %s[%d];\n", configprop->name, configprop->val.len); - } -#endif emit->endnode(etarget, treelabel); } -/* - for_each_property(tree, prop) { - if (streq(prop->name, "name")) - seen_name_prop = 1; - emit->data(etarget, prop); - } - */ -#if 0 - if ((vi->flags & FTF_NAMEPROPS) && !seen_name_prop) { - fprintf(f, "\tu8 %s[%d]\n", prop->name, prop->data.len); - } -#endif -/* - emit->endnode(etarget, tree->label); -*/ /* now emit the device for this node, with sibling and child pointers etc. */ emit->special(f, tree); Index: Makefile =================================================================== --- Makefile (revision 583) +++ Makefile (working copy) @@ -43,7 +43,7 @@ HOSTCC := gcc HOSTCXX := g++ -HOSTCFLAGS := -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer \ +HOSTCFLAGS := -Wall -Wstrict-prototypes -g -fomit-frame-pointer \ -Wno-unused -Wno-sign-compare LEX := flex
-- coreboot mailing list coreboot@coreboot.org http://www.coreboot.org/mailman/listinfo/coreboot