diff mbox series

[bug#45742] gnu: Add x86emu.

Message ID 20210109143038.1918-1-vincent.legoll@gmail.com
State New
Headers show
Series [bug#45742] gnu: Add x86emu. | expand

Checks

Context Check Description
cbaines/submitting builds success
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Vincent Legoll Jan. 9, 2021, 2:30 p.m. UTC
* gnu/packages/linux.scm (x86emu): New variable.
---
 gnu/packages/linux.scm | 45 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

Comments

Vincent Legoll Jan. 9, 2021, 2:40 p.m. UTC | #1
The repo has no releases.
So I used the "0.0.0" version.
Tobias Geerinckx-Rice Jan. 9, 2021, 3:49 p.m. UTC | #2
Vincent,

Vincent Legoll 写道:
> * gnu/packages/linux.scm (x86emu): New variable.

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

> +(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?

> +         (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].

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

‘inputs’ is unused.

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

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

> +               (mkdir-p outbin)
> +               (copy-file "x86emu" (string-append outbin 
> "/x86emu"))

These two lines can be replaced with the simpler:

  (install-file "x86emu" bin)

> +               (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.

> +    (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]: 
https://web.archive.org/web/20090218022239/http://www.scitechsoft.com/products/dev/x86_emulator.html
[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.
pelzflorian (Florian Pelz) Jan. 9, 2021, 4:15 p.m. UTC | #3
On Sat, Jan 09, 2021 at 04:49:24PM +0100, Tobias Geerinckx-Rice via Guix-patches via wrote:
> > +(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
Tobias Geerinckx-Rice Jan. 9, 2021, 8:30 p.m. UTC | #4
pelzflorian (Florian Pelz) 写道:
> 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
Vincent Legoll Jan. 10, 2021, 10:31 a.m. UTC | #5
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...
diff mbox series

Patch

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")