Nicholas Chin has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/83184?usp=email )
Change subject: util/autoport: Extend Add_gpl to more files ......................................................................
util/autoport: Extend Add_gpl to more files
Previously, Add_gpl() was only used with C and ASL source code files, and was hard coded to use the C /* */ style comment. Add a new argument to specify a filetype, which is used to look up a format string with the appropriate comment style. This allows the hard coded gma-mainboard.c SPDX header to be replaced with a call to Add_gpl(), as the original function would not be able to generate -- style Ada comments. An SPDX header is also added to Kconfig, Makefile, and devicetree sources; as previous commits added them to all such files in the tree.
Change-Id: I24a1ccd0afb7045e878bf6eaae7a23f828a9240d Signed-off-by: Nicholas Chin nic.c3.14@gmail.com --- M util/autoport/azalia.go M util/autoport/bd82x6x.go M util/autoport/ec_fixme.go M util/autoport/ec_lenovo.go M util/autoport/ec_none.go M util/autoport/main.go 6 files changed, 45 insertions(+), 19 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/84/83184/1
diff --git a/util/autoport/azalia.go b/util/autoport/azalia.go index c98b03c..90c1cd6 100644 --- a/util/autoport/azalia.go +++ b/util/autoport/azalia.go @@ -12,7 +12,7 @@ az := Create(ctx, "hda_verb.c") defer az.Close()
- Add_gpl(az) + Add_gpl(az, C) az.WriteString( `#include <device/azalia_device.h>
diff --git a/util/autoport/bd82x6x.go b/util/autoport/bd82x6x.go index 00b136b..d9bc3f0 100644 --- a/util/autoport/bd82x6x.go +++ b/util/autoport/bd82x6x.go @@ -44,7 +44,7 @@ AddBootBlockFile("gpio.c", "") AddROMStageFile("gpio.c", "")
- Add_gpl(gpio) + Add_gpl(gpio, C) gpio.WriteString("#include <southbridge/intel/common/gpio.h>\n\n")
addresses := [3][6]int{ @@ -292,7 +292,7 @@
sb := Create(ctx, "early_init.c") defer sb.Close() - Add_gpl(sb) + Add_gpl(sb, C)
sb.WriteString(`#include <bootblock_common.h> #include <device/pci_ops.h> @@ -358,7 +358,7 @@ gnvs := Create(ctx, "acpi_tables.c") defer gnvs.Close()
- Add_gpl(gnvs) + Add_gpl(gnvs, C) gnvs.WriteString(`#include <acpi/acpi_gnvs.h> #include <soc/nvs.h>
diff --git a/util/autoport/ec_fixme.go b/util/autoport/ec_fixme.go index 54f78ab..2902332 100644 --- a/util/autoport/ec_fixme.go +++ b/util/autoport/ec_fixme.go @@ -19,7 +19,7 @@ SouthBridge.EnableGPE(SouthBridge.DecodeGPE(sbGPE)) }
- Add_gpl(ap) + Add_gpl(ap, ASL) ap.WriteString( `Method(_WAK, 1) { @@ -65,7 +65,7 @@ defer si.Close()
if hasKeyboard { - Add_gpl(si) + Add_gpl(si, ASL) si.WriteString("#include <drivers/pc80/pc/ps2_controller.asl>\n") MainboardInit += fmt.Sprintf("\tpc_keyboard_init(NO_AUX_DEVICE);\n") MainboardIncludes = append(MainboardIncludes, "pc80/keyboard.h") @@ -74,7 +74,7 @@ ec := Create(ctx, "acpi/ec.asl") defer ec.Close()
- Add_gpl(ec) + Add_gpl(ec, ASL) ec.WriteString(`Device(EC) { Name (_HID, EISAID("PNP0C09")) diff --git a/util/autoport/ec_lenovo.go b/util/autoport/ec_lenovo.go index a34960f..e8dd847 100644 --- a/util/autoport/ec_lenovo.go +++ b/util/autoport/ec_lenovo.go @@ -39,7 +39,7 @@ Value: "1", }, GPEDefine)
- Add_gpl(ap) + Add_gpl(ap, ASL) ap.WriteString( `Method(_WAK, 1) { @@ -58,7 +58,7 @@ si := Create(ctx, "acpi/superio.asl") defer si.Close()
- Add_gpl(si) + Add_gpl(si, ASL) si.WriteString("#include <drivers/pc80/pc/ps2_controller.asl>\n")
/* FIXME:XX Move this to ec/lenovo. */ @@ -67,7 +67,7 @@
AddSMMFile("smihandler.c", "")
- Add_gpl(smi) + Add_gpl(smi, C) smi.WriteString( `#include <arch/io.h> #include <console/console.h> @@ -146,7 +146,7 @@ ec := Create(ctx, "acpi/ec.asl") defer ec.Close()
- Add_gpl(ec) + Add_gpl(ec, ASL) ec.WriteString("#include <ec/lenovo/h8/acpi/ec.asl>\n")
KconfigBool["EC_LENOVO_PMH7"] = true diff --git a/util/autoport/ec_none.go b/util/autoport/ec_none.go index bcb61bf..60ffd50 100644 --- a/util/autoport/ec_none.go +++ b/util/autoport/ec_none.go @@ -4,7 +4,7 @@ ap := Create(ctx, "acpi/platform.asl") defer ap.Close()
- Add_gpl(ap) + Add_gpl(ap, ASL) ap.WriteString( `Method(_WAK, 1) { diff --git a/util/autoport/main.go b/util/autoport/main.go index 6426dd3..ff530f5 100644 --- a/util/autoport/main.go +++ b/util/autoport/main.go @@ -100,6 +100,26 @@ IRQNO [4]int }
+type Filetype int + +const ( + Ada Filetype = iota + ASL + C + Devicetree + Kconfig + Makefile +) + +var CommentFormatStrings map[Filetype]string = map[Filetype]string { + Ada: "-- %s\n", + ASL: "/* %s */\n", + C: "/* %s */\n", + Devicetree: "# %s\n", + Kconfig: "# %s\n", + Makefile: "# %s\n", +} + var IOAPICIRQs map[PCIAddr]IOAPICIRQ = map[PCIAddr]IOAPICIRQ{} var KconfigBool map[string]bool = map[string]bool{} var KconfigComment map[string]string = map[string]string{} @@ -211,8 +231,9 @@ return mf }
-func Add_gpl(f *os.File) { - fmt.Fprintln(f, "/* SPDX-License-Identifier: GPL-2.0-only */") +func Add_gpl(f *os.File, filetype Filetype) { + fmt.Fprintf(f, CommentFormatStrings[filetype], + "SPDX-License-Identifier: GPL-2.0-only") fmt.Fprintln(f) }
@@ -529,6 +550,7 @@ func makeKconfigName(ctx Context) { kn := Create(ctx, "Kconfig.name") defer kn.Close() + Add_gpl(kn, Kconfig)
fmt.Fprintf(kn, "config %s\n\tbool "%s"\n", ctx.KconfigName, ctx.Model) } @@ -544,6 +566,7 @@ func makeKconfig(ctx Context) { kc := Create(ctx, "Kconfig") defer kc.Close() + Add_gpl(kc, Kconfig)
fmt.Fprintf(kc, "if %s\n\n", ctx.KconfigName)
@@ -640,6 +663,7 @@ log.Fatal(err) } defer f.Close() + Add_gpl(f, Kconfig) f.WriteString(`if VENDOR_` + vendorUpper + `
choice @@ -664,6 +688,7 @@ log.Fatal(err) } defer f.Close() + Add_gpl(f, Kconfig) f.WriteString(`config VENDOR_` + vendorUpper + ` bool "` + vendor + `" `) @@ -741,6 +766,7 @@ if len(BootBlockFiles) > 0 || len(ROMStageFiles) > 0 || len(RAMStageFiles) > 0 || len(SMMFiles) > 0 { mf := Create(ctx, "Makefile.mk") defer mf.Close() + Add_gpl(mf, Makefile) writeMF(mf, BootBlockFiles, "bootblock") writeMF(mf, ROMStageFiles, "romstage") writeMF(mf, RAMStageFiles, "ramstage") @@ -749,6 +775,7 @@
devtree := Create(ctx, "devicetree.cb") defer devtree.Close() + Add_gpl(devtree, Devicetree)
MatchDev(&DevTree) WriteDev(devtree, 0, "", DevTree) @@ -756,7 +783,7 @@ if MainboardInit != "" || MainboardEnable != "" || MainboardIncludes != nil { mainboard := Create(ctx, "mainboard.c") defer mainboard.Close() - Add_gpl(mainboard) + Add_gpl(mainboard, C) mainboard.WriteString("#include <device/device.h>\n") for _, include := range MainboardIncludes { mainboard.WriteString("#include <" + include + ">\n") @@ -835,7 +862,7 @@ dsdt.WriteString("#define " + define.Key + " " + define.Value + "\n") }
- Add_gpl(dsdt) + Add_gpl(dsdt, ASL) dsdt.WriteString( ` #include <acpi/acpi.h> @@ -878,10 +905,9 @@ if IGDEnabled { gma := Create(ctx, "gma-mainboard.ads") defer gma.Close() + Add_gpl(gma, Ada)
- gma.WriteString(`-- SPDX-License-Identifier: GPL-2.0-or-later - -with HW.GFX.GMA; + gma.WriteString(`with HW.GFX.GMA; with HW.GFX.GMA.Display_Probing;
use HW.GFX.GMA;