Skip to contentSkip to conversation

add cpumodelname mod to kernel for in grub.cfg to get cpu_mode_name, load different versions of the kernel through the path composed of names. like this: linux /cpu_mode_name/vmlinuz-5.7.7-amd64-desktop

PATCH New wangyouwan 1 participant 1 message Dec 28, 2021

lore
Share & tools
lore

wangyouwan

author
#0 lore raw

PATCH 1/1 add cpumodelname mod to kernel for in grub.cfg to get cpu_mode_name, load different versions of the kernel through the path composed of names. like this: linux /cpu_mode_name/vmlinuz-5.7.7-amd64-desktop

From: ut000745 <[email protected]>

---
 grub-core/Makefile.core.def         |  1 +
 grub-core/kern/i386/coreboot/init.c |  5 ++
 grub-core/kern/i386/cpumodelname.c  | 73 +++++++++++++++++++++++++++++
 grub-core/kern/i386/efi/init.c      |  3 ++
 grub-core/kern/i386/pc/init.c       |  3 ++
 include/grub/i386/cpumodelname.h    | 24 ++++++++++
 6 files changed, 109 insertions(+)
 create mode 100644 grub-core/kern/i386/cpumodelname.c
 create mode 100644 include/grub/i386/cpumodelname.h
grub-core/Makefile.core.def +1 -0
index 8022e1c0a..2d46b945a 100644
@@ -214,6 +214,7 @@ kernel = {
 
   x86 = kern/i386/tsc.c;
   x86 = kern/i386/tsc_pit.c;
+  x86 = kern/i386/cpumodelname.c;
   i386_efi = kern/i386/efi/tsc.c;
   x86_64_efi = kern/i386/efi/tsc.c;
   i386_efi = kern/i386/tsc_pmtimer.c;
grub-core/kern/i386/coreboot/init.c +5 -0
index 3314f027f..68675ac66 100644
@@ -35,6 +35,7 @@
 #include <grub/cpu/floppy.h>
 #include <grub/cpu/tsc.h>
 #include <grub/video.h>
+#include <grub/cpu/cpumodelname.h>
 
 extern grub_uint8_t _start[];
 extern grub_uint8_t _end[];
@@ -109,6 +110,8 @@ grub_machine_init (void)
   grub_gfxterm_init ();
 
   grub_tsc_init ();
+
+  grub_cpu_model_name_init ();
 }
 
 #else
@@ -124,6 +127,8 @@ grub_machine_init (void)
   grub_machine_mmap_iterate (heap_init, NULL);
 
   grub_tsc_init ();
+
+  grub_cpu_model_name_init ();
 }
 
 #endif
grub-core/kern/i386/cpumodelname.c new file +73 -0

73 lines not on this page · raw message

grub-core/kern/i386/efi/init.c +3 -0
index 46476e27e..099265140 100644
@@ -27,12 +27,15 @@
 #include <grub/efi/efi.h>
 #include <grub/i386/tsc.h>
 #include <grub/loader.h>
+#include <grub/i386/cpumodelname.h>
 
 void
 grub_machine_init (void)
 {
   grub_efi_init ();
   grub_tsc_init ();
+
+  grub_cpu_model_name_init ();
 }
 
 void
grub-core/kern/i386/pc/init.c +3 -0
index 27bc68b8a..b8251be8a 100644
@@ -35,6 +35,7 @@
 #include <grub/cpu/cpuid.h>
 #include <grub/cpu/tsc.h>
 #include <grub/machine/time.h>
+#include <grub/cpu/cpumodelname.h>
 
 struct mem_region
 {
@@ -260,6 +261,8 @@ grub_machine_init (void)
     }
 
   grub_tsc_init ();
+
+  grub_cpu_model_name_init ();
 }
 
 void
include/grub/i386/cpumodelname.h new file +24 -0
new file mode 100644
index 000000000..838fe1603
@@ -0,0 +1,24 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2019  Free Software Foundation, Inc.
+ *
+ *  GRUB 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 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB 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 GRUB.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_CPUMODENAME_H
+#define GRUB_CPUMODENAME_H 1
+
+void grub_cpu_model_name_init (void);
+
+#endif /* GRUB_CPUMODENAME_H */
Signature · 1 line
2.20.1