gnu: ovmf: Update phase style.
[jackhill/guix/guix.git] / gnu / packages / firmware.scm
CommitLineData
4902c3ec 1;;; GNU Guix --- Functional package management for GNU
bd2e1a8c 2;;; Copyright © 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
e36a67c9 3;;; Copyright © 2016 Eric Bavier <bavier@member.fsf.org>
ce03b453 4;;; Copyright © 2017 David Craven <david@craven.ch>
2eb95ade 5;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
bb5c3582 6;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
4902c3ec
LC
7;;;
8;;; This file is part of GNU Guix.
9;;;
10;;; GNU Guix is free software; you can redistribute it and/or modify it
11;;; under the terms of the GNU General Public License as published by
12;;; the Free Software Foundation; either version 3 of the License, or (at
13;;; your option) any later version.
14;;;
15;;; GNU Guix is distributed in the hope that it will be useful, but
16;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;;; GNU General Public License for more details.
19;;;
20;;; You should have received a copy of the GNU General Public License
21;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
22
23(define-module (gnu packages firmware)
ce03b453 24 #:use-module ((guix licenses) #:prefix license:)
4902c3ec 25 #:use-module (guix packages)
e36a67c9 26 #:use-module (guix download)
4902c3ec
LC
27 #:use-module (guix git-download)
28 #:use-module (guix build-system gnu)
29 #:use-module (gnu packages)
a5bc3dfe
DC
30 #:use-module (gnu packages admin)
31 #:use-module (gnu packages assembly)
e36a67c9 32 #:use-module (gnu packages bison)
4902c3ec
LC
33 #:use-module (gnu packages cmake)
34 #:use-module (gnu packages cross-base)
e36a67c9 35 #:use-module (gnu packages flex)
a5bc3dfe 36 #:use-module (gnu packages linux)
1b533bad
DC
37 #:use-module (gnu packages perl)
38 #:use-module (gnu packages python))
4902c3ec
LC
39
40(define-public ath9k-htc-firmware
41 (package
42 (name "ath9k-htc-firmware")
7c473310 43 (version "1.4.0")
4902c3ec
LC
44 (source (origin
45 (method git-fetch)
46 (uri (git-reference
47 (url "https://github.com/qca/open-ath9k-htc-firmware.git")
48 (commit version)))
49 (sha256
50 (base32
7c473310 51 "16jbj8avg5jkgvq5lxm0hdxxn4c3zn7fx8b4nxllvr024apk9w23"))
821f4dc2 52 (file-name (string-append name "-" version "-checkout"))
fc1adab1 53 (patches (search-patches "ath9k-htc-firmware-objcopy.patch"))))
4902c3ec
LC
54 (build-system gnu-build-system)
55 (arguments
dc1d3cde
KK
56 '(#:phases
57 (modify-phases %standard-phases
58 (add-before 'configure 'pre-configure
59 (lambda* (#:key inputs #:allow-other-keys)
60 (chdir "target_firmware")
4902c3ec 61
dc1d3cde
KK
62 ;; 'configure' is a simple script that runs 'cmake' with
63 ;; the right flags.
64 (substitute* "configure"
65 (("^TOOLCHAIN=.*$")
66 (string-append "TOOLCHAIN="
67 (assoc-ref inputs "cross-gcc")
68 "\n")))
69 #t))
70 (replace 'install
71 (lambda* (#:key outputs #:allow-other-keys)
72 (let* ((out (assoc-ref outputs "out"))
73 (fw-dir (string-append out "/lib/firmware")))
74 (mkdir-p fw-dir)
75 (for-each (lambda (file)
76 (copy-file file
77 (string-append fw-dir "/"
78 (basename file))))
79 (find-files "." "\\.fw$"))
80 #t))))
4902c3ec
LC
81 #:tests? #f))
82
83 ;; The firmware is cross-compiled using a "bare bones" compiler (no libc.)
84 ;; Use our own tool chain for that.
bd2e1a8c 85 (native-inputs `(("cross-gcc" ,(cross-gcc "xtensa-elf"))
4902c3ec
LC
86 ("cross-binutils" ,(cross-binutils "xtensa-elf"))
87 ("cmake" ,cmake)
88 ("perl" ,perl)))
89 (home-page "http://wireless.kernel.org/en/users/Drivers/ath9k_htc")
90 (synopsis "Firmware for the Atheros AR7010 and AR9271 USB 802.11n NICs")
91 (description
92 "This is the firmware for the Qualcomm Atheros AR7010 and AR9271 USB
e881752c 93802.11n NICs (aka Wi-Fi USB dongles). It is used by the ath9k driver of
4902c3ec 94Linux-libre.")
ce03b453 95 (license (license:non-copyleft "http://directory.fsf.org/wiki/License:ClearBSD"))))
e36a67c9
EB
96
97(define-public b43-tools
bb5c3582
TGR
98 (let ((commit "27892ef741e7f1d08cb939744f8b8f5dac7b04ae")
99 (revision "1"))
e36a67c9
EB
100 (package
101 (name "b43-tools")
bb5c3582 102 (version (git-version "0.0.0" revision commit))
e36a67c9
EB
103 (source
104 (origin
105 (method git-fetch)
106 (uri (git-reference
107 (url "http://git.bues.ch/git/b43-tools.git")
108 (commit commit)))
109 (file-name (string-append name "-" version "-checkout"))
110 (sha256
111 (base32
bb5c3582 112 "1wgmj4d65izbhprwb5bcwimc2ryv19b9066lqzy4sa5m6wncm9cn"))))
e36a67c9
EB
113 (build-system gnu-build-system)
114 (native-inputs
115 `(("flex" ,flex)
116 ("bison" ,bison)))
117 (arguments
118 `(#:modules ((srfi srfi-1)
119 (guix build gnu-build-system)
120 (guix build utils))
bb5c3582 121 #:tests? #f ; no tests
e36a67c9
EB
122 #:phases
123 (let ((subdirs '("assembler" "disassembler")))
124 (modify-phases %standard-phases
bb5c3582 125 (delete 'configure) ; no configure script
e36a67c9
EB
126 (add-before 'build 'patch-/bin/true
127 (lambda _
128 (substitute* (find-files "." "Makefile")
129 (("/bin/true") ":"))
130 #t))
131 (replace 'build
132 (lambda _
315c89f5
TGR
133 (for-each (lambda (dir)
134 (invoke "make" "-C" dir "CC=gcc"))
135 subdirs)
136 #t))
e36a67c9
EB
137 (replace 'install
138 (lambda* (#:key outputs #:allow-other-keys)
139 (let ((out (assoc-ref outputs "out")))
140 (mkdir-p (string-append out "/bin"))
315c89f5
TGR
141 (for-each (lambda (dir)
142 (invoke "make" "-C" dir
143 (string-append "PREFIX=" out)
144 "install"))
145 subdirs)
146 #t)))))))
e36a67c9 147 (home-page
3ebf12ea 148 "https://bues.ch/cms/hacking/misc.html#linux_b43_driver_firmware_tools")
e36a67c9
EB
149 (synopsis "Collection of tools for the b43 wireless driver")
150 (description
151 "The b43 firmware tools is a collection of firmware extractor,
152assembler, disassembler, and debugging tools for the Linux kernel b43 wireless
153driver.")
ce03b453 154 (license license:gpl2))))
e36a67c9
EB
155
156(define-public openfwwf-firmware
157 (package
158 (name "openfwwf-firmware")
159 (version "5.2")
160 (source
161 (origin
162 (method url-fetch)
163 (uri (string-append "http://netweb.ing.unibs.it/~openfwwf/firmware/"
164 "openfwwf-" version ".tar.gz"))
165 (sha256
166 (base32
167 "1p60gdi7w88s7qw82d3g9v7mk887mhvidf4l5q5hh09j10h37q4x"))))
168 (build-system gnu-build-system)
169 (native-inputs
170 `(("b43-tools" ,b43-tools)))
171 (arguments
172 `(#:make-flags (list (string-append "PREFIX="
173 (assoc-ref %outputs "out")
174 "/lib/firmware/b43-open"))
175 #:tests? #f ;no tests
176 #:phases (modify-phases %standard-phases
177 (delete 'configure))))
178 (home-page "http://netweb.ing.unibs.it/~openfwwf/")
179 (synopsis "Firmware for BCM43xx devices")
180 (description
181 "This is firmware from Open FirmWare for WiFi networks (OpenFWWF) for the
182Broadcom/AirForce chipset BCM43xx with Wireless-Core Revision 5. It is used
183by the b43-open driver of Linux-libre.")
ce03b453 184 (license license:gpl2)))
1b533bad
DC
185
186(define-public seabios
187 (package
188 (name "seabios")
3f9be788 189 (version "1.11.0")
1b533bad
DC
190 (source (origin
191 (method url-fetch)
192 (uri (string-append "https://code.coreboot.org/p/seabios/downloads/get/"
193 "seabios-" version ".tar.gz"))
194 (sha256
195 (base32
3f9be788 196 "1xwvp77djxbxbxg82hzj26pv6zka3556vkdcp09hnfwapcp46av2"))))
1b533bad
DC
197 (build-system gnu-build-system)
198 (native-inputs
199 `(("python-2" ,python-2)))
200 (arguments
201 `(#:tests? #f ; No check target.
202 #:phases
203 (modify-phases %standard-phases
204 (replace 'configure
205 (lambda _
206 (setenv "CC" "gcc")
207 #t))
208 (replace 'install
209 (lambda* (#:key outputs #:allow-other-keys)
210 (let* ((out (assoc-ref outputs "out"))
211 (fmw (string-append out "/share/firmware")))
212 (mkdir-p fmw)
213 (copy-file "out/bios.bin" (string-append fmw "/bios.bin"))))))))
214 (home-page "https://www.seabios.org/SeaBIOS")
215 (synopsis "x86 BIOS implementation")
5a80c15c
RW
216 (description "SeaBIOS is an implementation of a 16bit x86 BIOS. SeaBIOS
217can run in an emulator or it can run natively on X86 hardware with the use of
218coreboot.")
1b533bad
DC
219 ;; Dual licensed.
220 (license (list license:gpl3+ license:lgpl3+
221 ;; src/fw/acpi-dsdt.dsl is lgpl2
222 license:lgpl2.1
223 ;; src/fw/lzmadecode.c and src/fw/lzmadecode.h are lgpl3+ and
224 ;; cpl with a linking exception.
225 license:cpl1.0))))
a5bc3dfe
DC
226
227;; OVMF is part of the edk2 source tree.
228(define edk2-commit "13a50a6fe1dcfa6600c38456ee24e0f9ecf51b5f")
229(define edk2-version (git-version "20170116" "1" edk2-commit))
230(define edk2-origin
231 (origin
232 (method git-fetch)
233 (uri (git-reference
234 (url "https://github.com/tianocore/edk2")
235 (commit edk2-commit)))
236 (file-name (git-file-name "edk2" edk2-version))
237 (sha256
238 (base32
239 "1gy2332kdqk8bjzpcsripx10896rbvgl0ic7r344kmpiwdgm948b"))))
240
241(define-public ovmf
242 (package
243 (name "ovmf")
244 (version edk2-version)
245 (source edk2-origin)
246 (build-system gnu-build-system)
247 (native-inputs
248 `(("acpica" ,acpica)
249 ("nasm" ,nasm)
250 ("python-2" ,python-2)
251 ("util-linux" ,util-linux)))
252 (arguments
253 `(#:tests? #f ; No check target.
254 #:phases
255 (modify-phases %standard-phases
256 (replace 'configure
257 (lambda _
258 (let* ((cwd (getcwd))
259 (tools (string-append cwd "/BaseTools"))
260 (bin (string-append tools "/BinWrappers/PosixLike")))
261 (setenv "WORKSPACE" cwd)
262 (setenv "EDK_TOOLS_PATH" tools)
263 (setenv "PATH" (string-append (getenv "PATH") ":" bin))
f563d199 264 (invoke "bash" "edksetup.sh" "BaseTools")
a5bc3dfe
DC
265 (substitute* "Conf/target.txt"
266 (("^TARGET[ ]*=.*$") "TARGET = RELEASE\n")
267 (("^TOOL_CHAIN_TAG[ ]*=.*$") "TOOL_CHAIN_TAG = GCC49\n")
268 (("^MAX_CONCURRENT_THREAD_NUMBER[ ]*=.*$")
269 (format #f "MAX_CONCURRENT_THREAD_NUMBER = ~a~%"
270 (number->string (parallel-job-count)))))
271 ;; Build build support.
272 (setenv "BUILD_CC" "gcc")
f563d199
TGR
273 (invoke "make" "-C" (string-append tools "/Source/C"))
274 #t)))
a5bc3dfe
DC
275 (add-after 'build 'build-ia32
276 (lambda _
277 (substitute* "Conf/target.txt"
278 (("^TARGET_ARCH[ ]*=.*$") "TARGET_ARCH = IA32\n")
279 (("^ACTIVE_PLATFORM[ ]*=.*$")
280 "ACTIVE_PLATFORM = OvmfPkg/OvmfPkgIa32.dsc\n"))
f563d199
TGR
281 (invoke "build")
282 #t))
2eb95ade 283 ,@(if (string=? "x86_64-linux" (%current-system))
bfba1269
EF
284 '((add-after 'build 'build-x64
285 (lambda _
286 (substitute* "Conf/target.txt"
287 (("^TARGET_ARCH[ ]*=.*$") "TARGET_ARCH = X64\n")
288 (("^ACTIVE_PLATFORM[ ]*=.*$")
289 "ACTIVE_PLATFORM = OvmfPkg/OvmfPkgX64.dsc\n"))
f563d199
TGR
290 (invoke "build")
291 #t)))
2eb95ade 292 '())
a5bc3dfe
DC
293 (delete 'build)
294 (replace 'install
295 (lambda* (#:key outputs #:allow-other-keys)
296 (let* ((out (assoc-ref outputs "out"))
297 (fmw (string-append out "/share/firmware")))
298 (mkdir-p fmw)
299 (copy-file "Build/OvmfIa32/RELEASE_GCC49/FV/OVMF.fd"
300 (string-append fmw "/ovmf_ia32.bin"))
2eb95ade
EF
301 ,@(if (string=? "x86_64-linux" (%current-system))
302 '((copy-file "Build/OvmfX64/RELEASE_GCC49/FV/OVMF.fd"
303 (string-append fmw "/ovmf_x64.bin")))
304 '()))
a5bc3dfe
DC
305 #t)))))
306 (supported-systems '("x86_64-linux" "i686-linux"))
0dae4921 307 (home-page "https://www.tianocore.org")
a5bc3dfe
DC
308 (synopsis "UEFI firmware for QEMU")
309 (description "OVMF is an EDK II based project to enable UEFI support for
310Virtual Machines. OVMF contains a sample UEFI firmware for QEMU and KVM.")
311 (license (list license:expat
312 license:bsd-2 license:bsd-3 license:bsd-4))))