[PATCH] gnu: Add x86emu.

  • Done
  • quality assurance status badge
Details
3 participants
  • Tobias Geerinckx-Rice
  • pelzflorian (Florian Pelz)
  • Vincent Legoll
Owner
unassigned
Submitted by
Vincent Legoll
Severity
normal
V
V
Vincent Legoll wrote on 9 Jan 2021 15:30
(address . guix-patches@gnu.org)(name . Vincent Legoll)(address . vincent.legoll@gmail.com)
20210109143038.1918-1-vincent.legoll@gmail.com
* gnu/packages/linux.scm (x86emu): New variable.
---
gnu/packages/linux.scm | 45 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)

Toggle diff (72 lines)
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 8317723bbf..cb712dd8a4 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -74,6 +74,7 @@
#:use-module (gnu packages acl)
#:use-module (gnu packages admin)
#:use-module (gnu packages algebra)
+ #:use-module (gnu packages assembly)
#:use-module (gnu packages audio)
#:use-module (gnu packages autotools)
#:use-module (gnu packages backup)
@@ -98,6 +99,7 @@
#:use-module (gnu packages gawk)
#:use-module (gnu packages gcc)
#:use-module (gnu packages gettext)
+ #:use-module (gnu packages gl)
#:use-module (gnu packages glib)
#:use-module (gnu packages golang)
#:use-module (gnu packages gperf)
@@ -5767,6 +5769,49 @@ not as a replacement for it.")
license:public-domain ; nist/dfft.c
license:gpl3+)))) ; everything else
+(define-public x86emu
+ (let ((revision "0")
+ (commit "cbc65a99d0f7d291b7c72444b8afa71649d214c4"))
+ (package
+ (name "x86emu")
+ (version (git-version "0.0.0" revision commit))
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/shift-crops/x86emu")
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "16q69m5zb71pgwsw5w0ilkd0vqh0hrmgq10fqba3x604chb90a87"))))
+ (build-system gnu-build-system)
+ (arguments
+ `(#:tests? #f ; no tests
+ #:phases
+ (modify-phases %standard-phases
+ (delete 'configure)
+ (replace 'build
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (invoke "make" "all")))
+ (replace 'install
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out"))
+ (outbin (string-append out "/bin")))
+ (mkdir-p outbin)
+ (copy-file "x86emu" (string-append outbin "/x86emu"))
+ (copy-recursively "include" (string-append out "/include"))
+ #t))))))
+ (native-inputs
+ `(("nasm" ,nasm)))
+ (inputs
+ `(("glfw" ,glfw)))
+ (home-page "https://github.com/shift-crops/x86emu")
+ (synopsis "simple x86 emulator")
+ (description "x86emu is an emulator of the x86 architecture. It supports
+multiple CPU modes (16bit/32bit, Real/Protected), and some devices. You can
+boot via FDD simulator (DMA not supported), and operate with mouse and keyboard.")
+ (license license:x11))))
+
(define-public ecryptfs-utils
(package
(name "ecryptfs-utils")
--
2.30.0
V
V
Vincent Legoll wrote on 9 Jan 2021 15:40
(address . 45742@debbugs.gnu.org)
CAEwRq=qLLhb-YM3TzvimUDnRkiYEMsHw2KuhDZem8uUxw34A5A@mail.gmail.com
The repo has no releases.
So I used the "0.0.0" version.

--
Vincent Legoll
T
T
Tobias Geerinckx-Rice wrote on 9 Jan 2021 16:49
(name . Vincent Legoll)(address . vincent.legoll@gmail.com)
874kjq6rgb.fsf@nckx
Vincent,

Vincent Legoll ???
Toggle quote (2 lines)
> * gnu/packages/linux.scm (x86emu): New variable.

I don't see the connection to Linux. How about emulators.scm?

Toggle quote (2 lines)
> +(define-public x86emu

There's at least one other x86emu (declared obsolete upstream[0])
and I wouldn't be surprised if there were twenty. But if (this)
upstream insists on such a generic name, so be it.

What's your use case for this package? Is it a fun hack, or more?

Toggle quote (4 lines)
> + (replace 'build
> + (lambda* (#:key inputs outputs #:allow-other-keys)
> + (invoke "make" "all")))

The ‘all’ is presumably to build the ‘os’ (bios + sample kernel)
images, but they aren't installed below. Is that intentional?

The emulator is useless without them:

$ x86emu
[WARN] run_emulator (main.cpp:141) cannot load image
'sample/kernel.img'
Segmentation fault

$ x86emu .../sample/kernel.img
[hangs]

$ strace x86emu .../sample/kernel.img
[...]
openat(AT_FDCWD, "bios/bios.bin", O_RDONLY) = -1 ENOENT
openat(AT_FDCWD, "bios/crt0.bin", O_RDONLY) = -1 ENOENT
[hangs]

Put them in a separate :os output if you like[1].

Toggle quote (3 lines)
> + (replace 'install
> + (lambda* (#:key inputs outputs #:allow-other-keys)

‘inputs’ is unused.

Toggle quote (3 lines)
> + (let* ((out (assoc-ref outputs "out"))
> + (outbin (string-append out "/bin")))

Subjective nitpick: please just call this ‘bin’ :-)

Toggle quote (4 lines)
> + (mkdir-p outbin)
> + (copy-file "x86emu" (string-append outbin
> "/x86emu"))

These two lines can be replaced with the simpler:

(install-file "x86emu" bin)

Toggle quote (10 lines)
> + (copy-recursively "include" (string-append out
> "/include"))
> + #t))))))
> + (native-inputs
> + `(("nasm" ,nasm)))
> + (inputs
> + `(("glfw" ,glfw)))
> + (home-page "https://github.com/shift-crops/x86emu")
> + (synopsis "simple x86 emulator")

Running ‘guix lint x86emu’ will point out possible issues, like
this lowercase s.

Toggle quote (8 lines)
> + (description "x86emu is an emulator of the x86
> architecture. It supports
> +multiple CPU modes (16bit/32bit, Real/Protected), and some
> devices. You can
> +boot via FDD simulator (DMA not supported), and operate with
> mouse and keyboard.")
> + (license license:x11))))

This should be ‘expat’. The X11 variant is extremely rare.

I made these changes (and a few more) in the attached patch and
the emulator starts, but hangs on a black screen with

[WARN] hundle_interrupt (interrupt.cpp:40) exception interrupt
11 (!idt.P)

looped on stderr. I didn't look into it.

Thanks!

T G-R

[0]:
[1]: I'm not sure where they belong. They're x86 but
‘architecture independent’ from the host's point of view so I put
them in /share nonetheless.
-----BEGIN PGP SIGNATURE-----

iIMEARYKACsWIQT12iAyS4c9C3o4dnINsP+IT1VteQUCX/nQhA0cbWVAdG9iaWFz
LmdyAAoJEA2w/4hPVW15afUBAKulQsFC9qusD3mi+rjfJIcJ7NdxvUXlFrRxQulo
RpYWAP0ams9j57Qofc/VAhLb5an3Bxiu29l1VOClJoipcVo0CQ==
=GLsK
-----END PGP SIGNATURE-----

T
T
Tobias Geerinckx-Rice wrote on 9 Jan 2021 16:51
(name . Vincent Legoll)(address . vincent.legoll@gmail.com)
871reu6rd2.fsf@nckx
Tobias Geerinckx-Rice ???
Toggle quote (1 lines)
> the attached patch
From 6a74a2447e0e1f624903d468376542d785558986 Mon Sep 17 00:00:00 2001
From: Vincent Legoll <vincent.legoll@gmail.com>
Date: Sat, 9 Jan 2021 15:30:38 +0100
Subject: [PATCH] gnu: Add x86emu.

* gnu/packages/emulators.scm (x86emu): New variable.

Signed-off-by: Tobias Geerinckx-Rice <me@tobias.gr>
---
gnu/packages/emulators.scm | 62 ++++++++++++++++++++++++++++++++++++++
gnu/packages/linux.scm | 2 ++
2 files changed, 64 insertions(+)

Toggle diff (99 lines)
diff --git a/gnu/packages/emulators.scm b/gnu/packages/emulators.scm
index 1d94090f48..785d464273 100644
--- a/gnu/packages/emulators.scm
+++ b/gnu/packages/emulators.scm
@@ -13,6 +13,7 @@
;;; Copyright © 2019 David Wilson <david@daviwil.com>
;;; Copyright © 2020 Jakub K?dzio?ka <kuba@kadziolka.net>
;;; Copyright © 2020 Christopher Howard <christopher@librehacker.com>
+;;; Copyright © 2021 Vincent Legoll <vincent.legoll@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -2236,3 +2237,64 @@ framework based on QEMU.")
"PPSSPP is a ``high-level'' emulator simulating the PSP operating
system.")
(license license:gpl2+)))
+
+(define-public x86emu
+ (let ((revision "0")
+ (commit "cbc65a99d0f7d291b7c72444b8afa71649d214c4"))
+ (package
+ (name "x86emu")
+ (version (git-version "0.0.0" revision commit))
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/shift-crops/x86emu")
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "16q69m5zb71pgwsw5w0ilkd0vqh0hrmgq10fqba3x604chb90a87"))))
+ (build-system gnu-build-system)
+ (arguments
+ `(#:tests? #f ; no tests
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'set-image-file-names
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out"))
+ (os (string-append out "/share/x86emu")))
+ (substitute* "main.cpp"
+ (("sample/kernel\\.img|bios/(bios|crt0)\\.bin" file)
+ (string-append os "/" file)))
+ #t)))
+ (delete 'configure) ; no configure script
+ (replace 'build
+ ;; Also build the ‘os’ target with kernel & BIOS images.
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (invoke "make" "all")))
+ (replace 'install
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out"))
+ (bin (string-append out "/bin"))
+ (os (string-append out "/share/x86emu")))
+ (invoke "find")
+ (install-file "x86emu" bin)
+ (copy-recursively "include" (string-append out "/include"))
+ (for-each (lambda (file)
+ (install-file file (string-append os "/bios")))
+ (find-files "bios" "\\.bin$"))
+ (for-each (lambda (file)
+ (install-file file (string-append os "/sample")))
+ (find-files "sample" "\\.img$"))
+ #t))))))
+ (native-inputs
+ `(("nasm" ,nasm)))
+ (inputs
+ `(("glfw" ,glfw)))
+ (home-page "https://github.com/shift-crops/x86emu")
+ (synopsis "Simple x86 emulator")
+ (description
+ "x86emu is an emulator of the x86 architecture. It supports multiple CPU
+modes (16- and 32-bit, real/protected) and some devices. You can boot from a
+simulated floppy disk drive without DMA support and operate it with the mouse
+and keyboard. The package includes a light-weight BIOS and kernel image.")
+ (license license:expat))))
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 6c2556e91a..449258ad50 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -74,6 +74,7 @@
#:use-module (gnu packages acl)
#:use-module (gnu packages admin)
#:use-module (gnu packages algebra)
+ #:use-module (gnu packages assembly)
#:use-module (gnu packages audio)
#:use-module (gnu packages autotools)
#:use-module (gnu packages backup)
@@ -98,6 +99,7 @@
#:use-module (gnu packages gawk)
#:use-module (gnu packages gcc)
#:use-module (gnu packages gettext)
+ #:use-module (gnu packages gl)
#:use-module (gnu packages glib)
#:use-module (gnu packages golang)
#:use-module (gnu packages gperf)
--
2.30.0
-----BEGIN PGP SIGNATURE-----

iIMEARYKACsWIQT12iAyS4c9C3o4dnINsP+IT1VteQUCX/nQ+Q0cbWVAdG9iaWFz
LmdyAAoJEA2w/4hPVW15YGABANvFCvALbxXSEvi6PmX+0q7EerENnXqXC7Gc2ghj
XEGxAP9jrgV7NMVYfQRP2F82PDXs6e7eo5wGrQqt8puD0gJsDQ==
=9xh/
-----END PGP SIGNATURE-----

P
P
pelzflorian (Florian Pelz) wrote on 9 Jan 2021 17:15
20210109161521.jtzlwmh5rsuhxeew@pelzflorian.localdomain
On Sat, Jan 09, 2021 at 04:49:24PM +0100, Tobias Geerinckx-Rice via Guix-patches via wrote:
Toggle quote (6 lines)
> > +(define-public x86emu
>
> There's at least one other x86emu (declared obsolete upstream[0]) and I
> wouldn't be surprised if there were twenty. But if (this) upstream insists
> on such a generic name, so be it.

Another x86emu is part of xorg-server’s non-installed sources and used
by the v86d Guix package which is used by the uvesafb driver in the
Linux kernel.

Anyway, I suppose the name x86emu is fine for this package.

Regards,
Florian
T
T
Tobias Geerinckx-Rice wrote on 9 Jan 2021 21:30
(name . pelzflorian (Florian Pelz))(address . pelzflorian@pelzflorian.de)
87im85vonm.fsf@nckx
pelzflorian (Florian Pelz) ???
Toggle quote (6 lines)
> Another x86emu is part of xorg-server’s non-installed sources
> and used
> by the v86d Guix package which is used by the uvesafb driver in
> the
> Linux kernel.

Thanks, v86d's x86emu's the one I was thinking of.

At second glance my link above appears to be non-free. Apologies.
I got there through another GNU/Linux distribution's repository.

Or how running only FSDG ones can make you complacent :-)

Kind regards,

T G-R
-----BEGIN PGP SIGNATURE-----

iIMEARYKACsWIQT12iAyS4c9C3o4dnINsP+IT1VteQUCX/oSbQ0cbWVAdG9iaWFz
LmdyAAoJEA2w/4hPVW15HQAA/RVjgQvnHusSm1UowllavKLybRehUSKdLpnsUUCM
cOvvAQDyEv23e+IxQLFo7LG0q83PxWQvZiYC2DZs1n1acsSIDg==
=dXCS
-----END PGP SIGNATURE-----

V
V
Vincent Legoll wrote on 10 Jan 2021 11:31
(name . Tobias Geerinckx-Rice)(address . me@tobias.gr)
CAEwRq=ocjOAVptTP1eR4GJGGgEOzT=KP081axzEoBWb+LOJBsg@mail.gmail.com
Hello,

I packaged this one by mistake, as another package needed
something x86emu as a dependency, and I only saw afterwards
that it was libx86emu instead of this.

But having done the packaging work, I just submitted it
anyways.

I'll try to finish the work properly for this one, but its
priority is lower (not that I have a real need for any of
those, just looking at repology as a source for missing
things in guix).

Yeah, I know it's not terribly useful, but...

--
Vincent Legoll
V
V
Vincent Legoll wrote on 26 Jun 2023 20:41
close 45742
(address . control@debbugs.gnu.org)
CAEwRq=r28v6G8bXYQSM98MxAepWTB5mkSKGXS3Ayyk==A822+g@mail.gmail.com
close 45742

This does not look useful to anyone

--
Vincent Legoll
?
Your comment

This issue is archived.

To comment on this conversation send an email to 45742@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 45742
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch