All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Support FreeBSD in osdetect.lua
@ 2009-07-21 13:45 Vladimir 'phcoder' Serbinenko
  2009-07-21 16:02 ` Pavel Roskin
  0 siblings, 1 reply; 9+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2009-07-21 13:45 UTC (permalink / raw)
  To: The development of GRUB 2

[-- Attachment #1: Type: text/plain, Size: 202 bytes --]

Support FreeBSD on both UFS and ZFS. Requires my zfs.mod for zfs and
my ufs uuid patch for UFS

-- 
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git

[-- Attachment #2: freebsd_osdetect.diff --]
[-- Type: text/plain, Size: 2930 bytes --]

diff --git a/util/osdetect.lua b/util/osdetect.lua
index 38a9099..1d09500 100644
--- a/util/osdetect.lua
+++ b/util/osdetect.lua
@@ -40,6 +40,28 @@ function enum_device (device, fs, uuid)
     b1, b2, b3, b4 = string.match (second, "(%d+)%.?(%d*).?(%d*)%-?(%d*)")
     return (a1 > b1) or (a2 > b2) or (a3 > b3) or (a4 < b4);
   end
+  local function freebsd_variants (title, header, footer)
+     normal = "\nset FreeBSD.acpi_load=YES" ..
+	"\nset FreeBSD.hint.acpi.0.disabled=0"
+     noacpi = "\nunset FreeBSD.acpi_load" ..
+	"\nset FreeBSD.hint.acpi.0.disabled=1" ..
+	"\nset FreeBSD.loader.acpi_disabled_by_user=1"
+     safe = "\nset FreeBSD.hint.apic.0.disabled=1" ..
+	"\nset FreeBSD.hw.ata.ata_dma=0" ..
+	"\nset FreeBSD.hw.ata.atapi_dma=0" ..
+	"\nset FreeBSD.hw.ata.wc=0" ..
+	"\nset FreeBSD.hw.eisa_slots=0" ..
+	"\nset FreeBSD.hint.kbdmux.0.disabled=1"
+     grub.add_menu (header .. normal .. footer, title)
+     grub.add_menu (header .. " single" .. normal .. footer,
+		    title .. " (single)")
+     grub.add_menu (header .. " verbose" .. normal .. footer,
+		    title .. " (verbose)")
+     grub.add_menu (header .. noacpi .. footer,
+		    title .. " (without ACPI)")
+     grub.add_menu (header .. noacpi .. safe .. footer,
+		    title .. " (safe mode)")
+  end
 
   root = "(" .. device .. ")/"
   source = "root (" .. device .. ")\nchainloader +1"
@@ -58,11 +80,26 @@ function enum_device (device, fs, uuid)
     title = "MS-DOS"
   elseif (grub.file_exist (root .. "kernel.sys")) then
     title = "FreeDOS"
-  elseif (grub.file_exist (root .. "boot/loader") and
+  elseif (fs == "ufs" and grub.file_exist (root .. "boot/kernel/kernel") and
 	  grub.file_exist (root .. "boot/device.hints")) then
-    source = "root (" .. device .. ")\nfreebsd /boot/loader" ..
-      "\nfreebsd_loadenv /boot/device.hints"
-    title = "FreeBSD"
+     header = "set root=" .. device .. "\nfreebsd /boot/kernel/kernel"
+     footer = "\nset FreeBSD.vfs.root.mountfrom=ufs:ufsid/" .. uuid ..
+	"\nfreebsd_loadenv /boot/device.hints"
+     title = "FreeBSD (on " .. fs .. " ".. device .. ")"
+     freebsd_variants (title, header, footer)
+     return 0
+  elseif (fs == "zfs" and grub.file_exist (root .. "@/boot/kernel/kernel") and
+      grub.file_exist (root .. "@/boot/device.hints")) then
+     header = "set root=" .. device .. "\nfreebsd /@/boot/kernel/kernel"
+     footer =  "\nfreebsd_module_elf /@/boot/kernel/opensolaris.ko" ..
+      "\nfreebsd_module_elf /@/boot/kernel/zfs.ko" ..
+      "\nfreebsd_module /@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache" ..
+      "\nprobe -l -s name $root" ..
+      "\nset FreeBSD.vfs.root.mountfrom=zfs:$name" ..
+      "\nfreebsd_loadenv /@/boot/device.hints"
+     title = "FreeBSD (on " .. fs .. " ".. device .. ")"
+     freebsd_variants (title, header, footer)
+     return 0
   else
     grub.enum_file (enum_file, root .. "boot")
     if kernel_num ~= 0 then

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-07-25 16:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-21 13:45 [PATCH] Support FreeBSD in osdetect.lua Vladimir 'phcoder' Serbinenko
2009-07-21 16:02 ` Pavel Roskin
2009-07-21 20:17   ` Vladimir 'phcoder' Serbinenko
2009-07-21 21:25     ` Pavel Roskin
2009-07-21 21:50       ` Vladimir 'phcoder' Serbinenko
2009-07-22 17:51         ` Robert Millan
2009-07-22 18:02           ` Vladimir 'phcoder' Serbinenko
2009-07-25 16:10             ` Robert Millan
2009-07-25 16:46               ` Vladimir 'phcoder' Serbinenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.