Pesky '#define current' in mini-os/sched.h
Hi,
I'm trying to port ncurses to mini-os, and hit an ugly snag:xen-3.3.1/extras/mini-os/include/mini-os/sched.h says near the end:
#define current get_current()
which clashes with each field or variable named 'current'. Thus it pollutes the global and field namespace real bad, and is very easy to activate through including errno.h if HAVE_LIBC is defined.
What is the best way around?
Signature · 2 lines
Thanks, Feri.
Quoted 1 line · Ferenc Wagner, le Mon 27 Apr 2009 20:11:24 +0200, a écrit :
#define current
get_current()
I guess we should probably just get rid of the current macro
Samuel
Quoted 4 lines · Samuel Thibault
Quoted 1 line · Ferenc Wagner, le Mon 27 Apr 2009 20:11:24 +0200, a écrit :
#define current
get_current()I guess we should probably just get rid of the current macro
Simply removing it works in my case, but I guess there are cases when it is needed, aren't there?
Signature · 2 lines
Thanks, Feri.
Quoted 8 lines · Ferenc Wagner, le Mon 27 Apr 2009 20:45:57 +0200, a écrit :
Quoted 4 lines · Samuel Thibault
Quoted 1 line · Ferenc Wagner, le Mon 27 Apr 2009 20:11:24 +0200, a écrit :
#define current
get_current()I guess we should probably just get rid of the current macro
Simply removing it works in my case, but I guess there are cases when it is needed, aren't there?
Of course, everywhere it's used inside minios.
Samuel
Quoted 11 lines · Samuel Thibault
Quoted 8 lines · Ferenc Wagner, le Mon 27 Apr 2009 20:45:57 +0200, a écrit :
Quoted 4 lines · Samuel Thibault
Quoted 1 line · Ferenc Wagner, le Mon 27 Apr 2009 20:11:24 +0200, a écrit :
#define current
get_current()I guess we should probably just get rid of the current macro
Simply removing it works in my case, but I guess there are cases when it is needed, aren't there?
Of course, everywhere it's used inside minios.
Ok. Till then, may I ask for your help to integrate ncurses into minios? I'm not familiar with the build system. Basically, I think I got the ncurses library built for the minios target, but can't use it in my c stubdom yet, it get undefined references:
wferi@rs22:~/xen/xen-3.3.1/extras/mini-os$ ld -nostdlib -L/home/wferi/xen/xen-3.3.1/stubdom/cross-root-i686/i686-xen-elf/lib -L/home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/lib -m elf_i386 -T arch/x86/minios-x86_32.lds /home/wferi/xen/xen-3.3.1/stubdom/mini-os-x86_32-c/mini-os.o -o /home/wferi/xen/xen-3.3.1/stubdom/mini-os-x86_32-c/mini-os /home/wferi/xen/xen-3.3.1/stubdom/mini-os-x86_32-c/mini-os.o: In function `grub_ncurses_getxy': /home/wferi/xen/grub2/util/console.c:267: undefined reference to `stdscr' [...]
(Yes, I'm trying to build a PV-Grub2 for getting LVM support :)
Of course if I add -lncurses to the above command, I get lots of undefined references to the libc functions from ncurses. Sure it's possible to find out, but it would be nice if you could spare me a few cycles if you don't mind. At least I wouldn't waste further effort banging my head against the wrong wall.
Signature · 2 lines
Thanks, Feri.
Quoted 10 lines · Ferenc Wagner
Quoted 5 lines
Quoted 3 lines
Simply removing it works in my case, but I guess there are cases when it is needed, aren't there?
Of course, everywhere it's used inside minios.
Ok. Till then, may I ask for your help to integrate ncurses into minios? I'm not familiar with the build system. Basically, I think I got the ncurses library built for the minios target, but can't use it in my c stubdom yet, it get undefined references:
The simplest fix would be to wrap the '#define current' in a '#ifdef __MINIOS__' region. The cleaner fix would be to partition minios headers into private vs. public and not include the former from the latter, and keep the latter namespace-clean.
-- Keir
Quoted 2 lines · Keir Fraser, le Mon 27 Apr 2009 20:50:18 +0100, a écrit :
The simplest fix would be to wrap the '#define current' in a '#ifdef
__MINIOS__' region.
There actually already is such wrapper.
Samuel
Quoted 6 lines · Samuel Thibault
Quoted 2 lines · Keir Fraser, le Mon 27 Apr 2009 20:50:18 +0100, a écrit :
The simplest fix would be to wrap the '#define current' in a '#ifdef
__MINIOS__' region.There actually already is such wrapper.
Where? Not in mini-os/sched.h. There is an #ifdef HAVE_LIBC around #include <mini-os/sched.h> in errno.h, though.
Signature · 1 line
Feri.
Quoted 10 lines · Ferenc Wagner, le Mon 27 Apr 2009 22:32:06 +0200, a écrit :
Quoted 6 lines · Samuel Thibault
Quoted 2 lines · Keir Fraser, le Mon 27 Apr 2009 20:50:18 +0100, a écrit :
The simplest fix would be to wrap the '#define current' in a '#ifdef
__MINIOS__' region.There actually already is such wrapper.
Where? Not in
mini-os/sched.h.
Are we perhaps looking at different trees? I can see
#ifdef __INSIDE_MINIOS__
Samuel
Quoted 8 lines · Samuel Thibault
Quoted 7 lines · Ferenc Wagner, le Mon 27 Apr 2009 22:32:06 +0200, a écrit :
Quoted 5 lines · Samuel Thibault
Quoted 2 lines · Keir Fraser, le Mon 27 Apr 2009 20:50:18 +0100, a écrit :
The simplest fix would be to wrap the '#define current' in a '#ifdef
__MINIOS__' region.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
There actually already is such wrapper.
Where? Not in
mini-os/sched.h.Are we perhaps looking at different trees? I can see
#ifdef
__INSIDE_MINIOS__
I'm working with xen-3.3.1, which is the latest stable, as far as I know. Maybe it's already fixed in your development version.
Signature · 1 line
Feri.
Quoted 6 lines · Ferenc Wagner
Quoted 3 lines
Are we perhaps looking at different trees? I can see
#ifdef
__INSIDE_MINIOS__I'm working with xen-3.3.1, which is the latest stable, as far as I know. Maybe it's already fixed in your development version.
Yes, it's fixed in xen-unstable but not in xen-3.3.
-- Keir
Quoted 12 lines · Ferenc Wagner, le Mon 27 Apr 2009 22:47:54 +0200, a écrit :
Quoted 10 lines · Samuel Thibault
Quoted 9 lines · Ferenc Wagner, le Mon 27 Apr 2009 22:32:06 +0200, a écrit :
Quoted 6 lines · Samuel Thibault
Quoted 2 lines · Keir Fraser, le Mon 27 Apr 2009 20:50:18 +0100, a écrit :
The simplest fix would be to wrap the '#define current' in a '#ifdef
__MINIOS__' region.There actually already is such wrapper.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Where? Not in
mini-os/sched.h.Are we perhaps looking at different trees? I can see
#ifdef
__INSIDE_MINIOS__I'm working with xen-3.3.1, which is the latest stable, as far as I know. Maybe it's already fixed in your development version.
Ok, yes it is.
Samuel
Quoted 2 lines · Ferenc Wagner, le Mon 27 Apr 2009 21:42:42 +0200, a écrit :
Of course if I add -lncurses to the above command, I get lots of undefined references to the libc functions from ncurses.
Which ones? Adding -lncurses really is the correct way, just like is done for libpci & libz for qemu-stubdom.
Samuel
Quoted 6 lines · Samuel Thibault
Quoted 2 lines · Ferenc Wagner, le Mon 27 Apr 2009 21:42:42 +0200, a écrit :
Of course if I add -lncurses to the above command, I get lots of undefined references to the libc functions from ncurses.
Which ones?
/home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses/../ncurses/./base/lib_color.c:265: undefined reference to `calloc' etc.
No wonder, as the linker command originally had a single object (mini-os.o), and if I put -lncurses before it, it wasn't pulled in, and if I put -lncurses after it, then every single libc function became undefined.
Quoted 2 lines
Adding -lncurses really is the correct way, just like is done for libpci & libz for qemu-stubdom.
Yes, but I tried the crazy way first, which was bound to fail. Setting
LDLIBS := -L/home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/lib -lncurses
in mini-os/Makefile got me further, but may still not be the correct way. I couldn't track how it's done for libpci & libz for qemu-stubdom (ioemu?) yet. This make magic is somewhat convoluted, and I'm not too much into linker scripts et al.
So, where should I add it for proper operation?
Anyway, now I'm down to
/home/wferi/xen/xen-3.3.1/stubdom/mini-os-x86_32-c/mini-os.o: In function `grub_memalign':/home/wferi/xen/grub2/util/misc.c:263: undefined reference to posix_memalign' /home/wferi/xen/xen-3.3.1/stubdom/mini-os-x86_32-c/mini-os.o: In function find_root_device':/home/wferi/xen/grub2/util/getroot.c:215: undefined reference to lstat' /home/wferi/xen/xen-3.3.1/stubdom/mini-os-x86_32-c/mini-os.o: In function tstp':/home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses/../ncurses/./tty/lib_tstp.c:159: undefined reference to tcgetpgrp' /home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses/../ncurses/./tty/lib_tstp.c:159: undefined reference to getpgrp' /home/wferi/xen/xen-3.3.1/stubdom/mini-os-x86_32-c/mini-os.o: In function `baudrate':/home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses/../ncurses/./tinfo/lib_baudrate.c:244: undefined reference to cfgetospeed' /home/wferi/xen/xen-3.3.1/stubdom/mini-os-x86_32-c/mini-os.o: In function flushinp':/home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses/../ncurses/./tinfo/lib_kernel.c:143: undefined reference to tcflush' /home/wferi/xen/xen-3.3.1/stubdom/mini-os-x86_32-c/mini-os.o: In function _nc_vdisable':/home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses/../ncurses/./tinfo/lib_kernel.c:67: undefined reference to fpathconf' /home/wferi/xen/xen-3.3.1/stubdom/mini-os-x86_32-c/mini-os.o: In function _nc_access':/home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses/../ncurses/./tinfo/access.c:112: undefined reference to access' /home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses/../ncurses/./tinfo/access.c:125: undefined reference to access' make[1]: *** [/home/wferi/xen/xen-3.3.1/stubdom/mini-os-x86_32-c/mini-os] Error 1
make[1]: Leaving directory `/home/wferi/xen/xen-3.3.1/extras/mini-os'
make: *** [c-stubdom] Error 2
for grub-emu, which may be far or close, I don't know yet...
Signature · 2 lines
Thank, Feri.
Quoted 8 lines · Ferenc Wagner, le Mon 27 Apr 2009 22:29:02 +0200, a écrit :
Quoted 6 lines · Samuel Thibault
Quoted 2 lines · Ferenc Wagner, le Mon 27 Apr 2009 21:42:42 +0200, a écrit :
Of course if I add -lncurses to the above command, I get lots of undefined references to the libc functions from ncurses.
Which ones?
Quoted 7 lines
/home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses/../ncurses/./base/lib_color.c:265: undefined reference to `calloc' etc.No wonder, as the linker command originally had a single object (mini-os.o), and if I put -lncurses before it, it wasn't pulled in, and if I put -lncurses after it, then every single libc function became undefined.
Have you, like in the C example of stubdom/Makefile, propagated TARGET_CPPFLAGS, TARGET_CFLAGS, and added a rule like is done for other stubdom images in the "minios" paragraph of stubdom/Makefile?
Quoted 3 lines
Yes, but I tried the crazy way first, which was bound to fail. Setting
LDLIBS := -L/home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/lib -lncurses
That's not how it's supposed to be done. See the Cross-zlib paragraph for instance: the cross-zlib target not only configures & builds libz, but also installs it, the prefix being properly set during configuration into the cross-chain directory.
Quoted 2 lines
I couldn't track how it's done for libpci & libz for qemu-stubdom (ioemu?) yet.
It's all in stubdom/Makefile: they get installed within the cross-root-$(GNU_TARGET_ARCH) hierarchy, where the linker finds it thanks to the TARGET_LDFLAGS variable.
Quoted 1 line
This make magic is somewhat convoluted,
It's no magic, it's makefiles :)
Quoted 1 line
and I'm not too much into linker scripts et al.
You do not need to change any linker script.
Quoted 1 line
So, where should I add it for proper operation?
Just the same way as zlib & C stubdom examples.
Quoted 2 lines
/home/wferi/xen/xen-3.3.1/stubdom/mini-os-x86_32-c/mini-os.o: In function `grub_memalign':/home/wferi/xen/grub2/util/misc.c:263: undefined reference to `posix_memalign'
It should just be a matter of setting it as an alias for newlib's memalign, by adding a macro into newlib/libc/include/malloc.h for instance. Ideally it should be reported to newlib's upstream actually.
Quoted 4 lines
/home/wferi/xen/grub2/util/getroot.c:215: undefined reference tolstat' /home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses/../ncurses/./tty/lib_tstp.c:159: undefined reference totcgetpgrp'/home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses/../ncurses/./tty/lib_tstp.c:159: undefined reference togetpgrp' /home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses/../ncurses/./tinfo/lib_kernel.c:143: undefined reference totcflush'
Should be fixed by the patch below.
Quoted 1 line
/home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses/../ncurses/./tinfo/lib_baudrate.c:244: undefined reference to `cfgetospeed'
I'm a bit surprised you actually got code using cfgetospeed compiled in the miniOS environment. It's supposed to return something like B9600, but that's not defined by newlib!
Quoted 1 line
/home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses/../ncurses/./tinfo/lib_kernel.c:67: undefined reference to `fpathconf'
Same issue: how did you get that code to compile? _PC_VDISABLE is not defined... I believe you are not using the cross-chain flags.
Quoted 2 lines
/home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses/../ncurses/./tinfo/access.c:112: undefined reference toaccess' /home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses/../ncurses/./tinfo/access.c:125: undefined reference toaccess'
Mmmm, the fsif protocol does not provide an access operation to implement that properly. You could add a dummy implementation in lib/sys.c that just open()/close() it and return proper error codes if any and it should be fine for ncurses' use cases.
Samuel
Add tcgetpgrp getpgrp tcflush and lstat dummy implementations.
extras/mini-os/lib/sys.c +26 -0
@@ -148,6 +148,16 @@return 1 ; } +pid_t tcgetpgrp (int fd) +{ +return 1 ; +} + +pid_t getpgrp (void ) +{ +return 1 ; +} +char *getcwd (char *buf,size_t size) {snprintf (buf, size,"/" );
@@ -365,6 +375,20 @@return -1 ; } +int tcflush (int fd,int queue_selector) +{ +switch (files[fd].type) { +case FTYPE_CONSOLE : +/* Already flushed */ +return 0 ; +default : +break ; + } +printk ("tcflush(%d): Bad descriptor\n" , fd); + errno =EBADF ; +return -1 ; +} +int close (int fd) {printk ("close(%d)\n" , fd);
@@ -473,6 +497,8 @@ out:return ret; } +/* We do not have symlinks */ +int lstat (const char *path,struct stat *buf) __attribute__((alias ("stat" )));int fstat (int fd,struct stat *buf) {
Quoted 3 lines · Samuel Thibault
Have you, like in the C example of stubdom/Makefile, propagated
TARGET_CPPFLAGS,TARGET_CFLAGS, and added a rule like is done for other stubdom images in the "minios" paragraph of stubdom/Makefile?
No, I had no idea how to start with this, I stole the various flags from the output of make c-stubdom and configured ncurses with those.
Quoted 4 lines
That's not how it's supposed to be done. See the Cross-zlib paragraph for instance: the cross-zlib target not only configures & builds libz, but also installs it, the prefix being properly set during configuration into the cross-chain directory.
Oh yes, I copied that, but forgot the install step, because the build itself was so tedious.
Quoted 5 lines
Ferenc Wagner, le Mon 27 Apr 2009 22:29:02 +0200, a .ANicrit :
Quoted 2 lines
I couldn't track how it's done for libpci & libz for qemu-stubdom (ioemu?) yet.
Quoted 7 lines
It's all in stubdom/Makefile: they get installed within the cross-root-$(GNU_TARGET_ARCH) hierarchy, where the linker finds it thanks to the
TARGET_LDFLAGSvariable.Quoted 1 line
This make magic is somewhat convoluted,
It's no magic, it's makefiles :)
Ok, do I have to extend the # Links section as well?
Quoted 3 lines
Quoted 1 line
So, where should I add it for proper operation?
Just the same way as zlib & C stubdom examples.
I may be blind, but there's no -l linker option in stubdom/Makefile.
Quoted 6 lines
Quoted 2 lines
/home/wferi/xen/xen-3.3.1/stubdom/mini-os-x86_32-c/mini-os.o: In function `grub_memalign':/home/wferi/xen/grub2/util/misc.c:263: undefined reference to `posix_memalign'It should just be a matter of setting it as an alias for newlib's memalign, by adding a macro into
newlib/libc/include/malloc.hfor instance. Ideally it should be reported to newlib's upstream actually.
Thanks for the tip.
Quoted 6 lines
Quoted 4 lines
/home/wferi/xen/grub2/util/getroot.c:215: undefined reference tolstat' /home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses/../ncurses/./tty/lib_tstp.c:159: undefined reference totcgetpgrp'/home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses/../ncurses/./tty/lib_tstp.c:159: undefined reference togetpgrp' /home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses/../ncurses/./tinfo/lib_kernel.c:143: undefined reference totcflush'Should be fixed by the patch below.
And thanks for the patch! Will try once I get a correct build infrastructure.
Quoted 5 lines
Quoted 1 line
/home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses/../ncurses/./tinfo/lib_baudrate.c:244: undefined reference to `cfgetospeed'I'm a bit surprised you actually got code using cfgetospeed compiled in the miniOS environment. It's supposed to return something like B9600, but that's not defined by newlib!
Yeah, I copied those defines from my libc headers. Figured I won't need them after all, as the MiniOS console won't care, so I can stub them out later. But wanted a proof of concept first of all.
Quoted 4 lines
Quoted 1 line
/home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses/../ncurses/./tinfo/lib_kernel.c:67: undefined reference to `fpathconf'Same issue: how did you get that code to compile?
_PC_VDISABLEis not defined... I believe you are not using the cross-chain flags.
Hmm, I don't remember hacking around this...
Quoted 7 lines
Quoted 2 lines
/home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses/../ncurses/./tinfo/access.c:112: undefined reference toaccess' /home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses/../ncurses/./tinfo/access.c:125: undefined reference toaccess'Mmmm, the fsif protocol does not provide an access operation to implement that properly. You could add a dummy implementation in
lib/sys.cthat just open()/close() it and return proper error codes if any and it should be fine for ncurses' use cases.
Thanks, that's about what I expected. Will do.
Until then, here are my notes from the yesterday session. If you have further comments, I'd be glad to hear them.
Thanks,
Feri.
---------------------------------------------------
1. wferi@rs22:~/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses$ gcc -DHAVE_CONFIG_H -I../ncurses -I. -I. -I../include -DNDEBUG -I/home/wferi/xen/xen-3.3.1/stubdom/cross-root-i686/i686-xen-elf/include/ncurses -isystem /home/wferi/xen/xen-3.3.1/stubdom/../extras/mini-os/include -D__MINIOS__ -DHAVE_LIBC -isystem /home/wferi/xen/xen-3.3.1/stubdom/../extras/mini-os/include/posix -isystem /home/wferi/xen/xen-3.3.1/stubdom/../tools/xenstore -isystem /home/wferi/xen/xen-3.3.1/stubdom/../extras/mini-os/include/x86 -isystem /home/wferi/xen/xen-3.3.1/stubdom/../extras/mini-os/include/x86/x86_32 -U __linux__ -U __FreeBSD__ -U __sun__ -nostdinc -isystem /home/wferi/xen/xen-3.3.1/stubdom/../extras/mini-os/include/posix -isystem /home/wferi/xen/xen-3.3.1/stubdom/cross-root-i686/i686-xen-elf/include -isys tem /usr/lib/gcc/i486-linux-gnu/4.3.2/include -isystem /home/wferi/xen/xen-3.3.1/stubdom/lwip-x86_32/src/include -isystem /home/wferi/xen/xen-3.3.1/stubdom/lwip-x86_32/src/include/ipv4 -I/ho
me/wferi/xen/xen-3.3.1/stubdom/include -O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls -m32 -march=i686 -m32 -march=i686 -g -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-unused-value -Wdeclaration-after-statement -fno-stack-protector --param max-inline-insns-single=1200 -c ../objects/tty_update.c -o ../objects/tty_update.o
That is, both lwip -isystem pathes missed the -x86_32 bit (the original was the result of adapting the zlib cross-compilation stanza in stubdom/Makefile:
NCURSES_URL?=ftp://invisible-island.net/ncurses
NCURSES_VERSION=5.7
[...]
###############
# Cross-ncurses
###############
ncurses-$(NCURSES_VERSION).tar.gz:
$(WGET) $(NCURSES_URL)/$@
ncurses-$(XEN_TARGET_ARCH): ncurses-$(NCURSES_VERSION).tar.gz
tar xzf $<
mv ncurses-$(NCURSES_VERSION) $@
NCURSES_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libncurses.a .PHONY: cross-ncurses
cross-ncurses: $(NCURSES_STAMPFILE)
$(NCURSES_STAMPFILE): ncurses-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE)
( cd $< && \
CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" CC=$(CC) ./configure --prefix=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf --with-build-cppflags="" --with-build-cflags="" --with-build-ldflags="" --with-build-libs="" && \
$(MAKE) libs && \
$(MAKE) install.libs )The --with-build-* options do nothing, so two utilities must be compiled by hand.
1b. Fix the two include pathes in stubdom/Makefile:
TARGET_CPPFLAGS += -isystem $(CURDIR)/lwip-x86_32/src/include TARGET_CPPFLAGS += -isystem $(CURDIR)/lwip-x86_32/src/include/ipv4
(Probably helps after reconfiguration only.)
2. Some other file required renaming the local variable holding the current screen from 'current' to 'currrent' (cca. 3 occurences) due to some strange Xen include clash?!
3. 'columns' in the above tty_update.c has a similar problem. Moving
#include <curses.priv.h> past #include <sys/select.h> solves this, but still gives ../ncurses/./tty/tty_update.c:351: warning: implicit declaration of function $B!F(Bselect$B!G(B
4. Add to ../ncurses/./tinfo/lib_baudrate.c, above 'static struct speed const speeds[] =':
/* Copied from Linux' /usr/include/bits/termios.h, Mini-OS has no support for these */
#define B0 0000000 /* hang up */ #define B50 0000001 #define B75 0000002 #define B110 0000003 #define B134 0000004 #define B150 0000005 #define B200 0000006 #define B300 0000007 #define B600 0000010 #define B1200 0000011 #define B1800 0000012 #define B2400 0000013 #define B4800 0000014 #define B9600 0000015 #define B19200 0000016 #define B38400 0000017
5. Add to the head of ../ncurses/./tinfo/lib_kernel.c:
/* Copied from Linux' /usr/include/bits/termios.h, Mini-OS has no support for these */ #define VERASE 2
#define VKILL 3
#define TCIFLUSH 0
Maybe #undef TERMIOS would be better? This still leaves:../ncurses/./tinfo/lib_kernel.c:143: warning: implicit declaration of function $B!F(Btcflush$B!G(B
6. #include <curses.priv.h> problem in ../ncurses/./tty/lib_twait.c, too.
7. These alone get us a libncurses.a!
8. The 'form' part still does not compile, because the field 'current' in ../form/form.h clashes with the #define current at /home/wferi/xen/xen-3.3.1/stubdom/../extras/mini-os/include/mini-os/sched.h:51:1 This is the same problem as 2., but without an easy fix, as this 'current' isn't a local variable.
9. Actually, deleting #define current get_current() from extras/mini-os/include/mini-os/sched.h made libncurses++.a build, but broke make c-stubdom... According to Keir Fraser, the simplest fix is:
#ifdef __MINIOS__
#define current get_current()
#endif
Quoted 7 lines · Ferenc Wagner, le Tue 28 Apr 2009 12:12:54 +0200, a écrit :
Quoted 3 lines · Samuel Thibault
Have you, like in the C example of stubdom/Makefile, propagated
TARGET_CPPFLAGS,TARGET_CFLAGS, and added a rule like is done for other stubdom images in the "minios" paragraph of stubdom/Makefile?No, I had no idea how to start with this, I stole the various flags from the output of make c-stubdom and configured ncurses with those.
Errrr, that's an odd way. ncurses is a library, so stole things from a library, see the cross-zlib part for instance. No need to look at c-stubdom (which is only about the main application, not a library).
Quoted 9 lines
Quoted 9 lines
Quoted 2 lines · Ferenc Wagner, le Mon 27 Apr 2009 22:29:02 +0200, a écrit :
I couldn't track how it's done for libpci & libz for qemu-stubdom (ioemu?) yet.
It's all in stubdom/Makefile: they get installed within the cross-root-$(GNU_TARGET_ARCH) hierarchy, where the linker finds it thanks to the
TARGET_LDFLAGSvariable.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
This make magic is somewhat convoluted,
It's no magic, it's makefiles :)
Ok, do I have to extend the # Links section as well?
You need to add a cross-ncurses dependency, but the rest is only for libxc.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
So, where should I add it for proper operation?
Just the same way as zlib & C stubdom examples.
I may be blind, but there's no -l linker option in stubdom/Makefile.
Sure, but in qemu/ there is a -lz linker option. Just the usual way, that is.
Quoted 10 lines
NCURSES_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libncurses.a .PHONY: cross-ncurses
cross-ncurses: $(NCURSES_STAMPFILE)
$(NCURSES_STAMPFILE): ncurses-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE)( cd $< && \ CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" CC=$(CC) ./configure --prefix=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf --with-build-cppflags="" --with-build-cflags="" --with-build-ldflags="" --with-build-libs="" && \ $(MAKE) libs && \ $(MAKE) install.libs )The --with-build-* options do nothing, so two utilities must be compiled by hand.
You need to pass the $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) there.
I'm actually feared by all your terminal additions. These will probably never be implemented in mini-os. They can sure be stubbed, but the application will probably just not work properly. Remember that the Xen console can be attached/detached/reattached from a lot of various kinds of terminals...
Quoted 6 lines
9. Actually, deleting #define current
get_current()fromextras/mini-os/include/mini-os/sched.hmade libncurses++.a build, but broke make c-stubdom... According to Keir Fraser, the simplest fix is:#ifdef
__MINIOS__
#define currentget_current()
#endif
Use the same fix as in the unstable tree.
Samuel
Quoted 8 lines · Samuel Thibault
Quoted 1 line · Ferenc Wagner, le Mon 27 Apr 2009 22:29:02 +0200, a écrit :
LDLIBS := -L/home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/lib -lncurses
That's not how it's supposed to be done. See the Cross-zlib paragraph for instance: the cross-zlib target not only configures & builds libz, but also installs it, the prefix being properly set during configuration into the cross-chain directory.
Now I have ncurses installed into cross-root. Suppose I want to use it from c-stubdom. #include <ncurses/curses.h> works without any further modification, but where should I put -lncurses? The best I could come up with is APP_LDLIBS in extras/mini-os/Makefile...
Quoted 6 lines
Quoted 2 lines
/home/wferi/xen/xen-3.3.1/stubdom/mini-os-x86_32-c/mini-os.o: In function `grub_memalign':/home/wferi/xen/grub2/util/misc.c:263: undefined reference to `posix_memalign'It should just be a matter of setting it as an alias for newlib's memalign, by adding a macro into
newlib/libc/include/malloc.hfor instance. Ideally it should be reported to newlib's upstream actually.
Seems good.
Quoted 1 line
Should be fixed by the patch below.
Works as advertised, thanks!
Quoted 5 lines
Quoted 1 line
/home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses/../ncurses/./tinfo/lib_baudrate.c:244: undefined reference to `cfgetospeed'I'm a bit surprised you actually got code using cfgetospeed compiled in the miniOS environment. It's supposed to return something like B9600, but that's not defined by newlib!
I'll stub this to always return B38400 and define those constants. Do you think it matters the least?
Quoted 4 lines
Quoted 1 line
/home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses/../ncurses/./tinfo/lib_kernel.c:67: undefined reference to `fpathconf'Same issue: how did you get that code to compile?
_PC_VDISABLEis not defined... I believe you are not using the cross-chain flags.
newlib-1.16.0/newlib/libc/include/sys/unistd.h defines _PC_VDISABLE. It even has an fpathconf implementation in libc/sys/linux. Is there a way to get that work or had I better stub this one, too?
Quoted 7 lines
Quoted 2 lines
/home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses/../ncurses/./tinfo/access.c:112: undefined reference toaccess' /home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses/../ncurses/./tinfo/access.c:125: undefined reference toaccess'Mmmm, the fsif protocol does not provide an access operation to implement that properly. You could add a dummy implementation in
lib/sys.cthat just open()/close() it and return proper error codes if any and it should be fine for ncurses' use cases.
I stubbed this last one, and now I can compile the ncurses example at
http://www.captain.at/howto-curses-example.php as a c-stubdom; too bad it does not work:
Error opening terminal: unknown.
Now let's try to hardwire the terminal type to xterm or similar...
Signature · 2 lines
Cheers, Feri.
Quoted 6 lines · Ferenc Wagner, le Tue 28 Apr 2009 19:57:07 +0200, a écrit :
Quoted 3 lines
I'm a bit surprised you actually got code using cfgetospeed compiled in the miniOS environment. It's supposed to return something like B9600, but that's not defined by newlib!
I'll stub this to always return B38400 and define those constants. Do you think it matters the least?
I doesn't.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
/home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses/../ncurses/./tinfo/lib_kernel.c:67: undefined reference to `fpathconf'Same issue: how did you get that code to compile?
_PC_VDISABLEis not defined... I believe you are not using the cross-chain flags.
newlib-1.16.0/newlib/libc/include/sys/unistd.hdefines_PC_VDISABLE.
Oh, right it's not defined in the linux/ part.
Quoted 2 lines
It even has an fpathconf implementation in libc/sys/linux. Is there a way to get that work or had I better stub this one, too?
That one should be fine indeed.
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
/home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses/../ncurses/./tinfo/access.c:112: undefined reference toaccess' /home/wferi/xen/xen-3.3.1/stubdom/ncurses-x86_32/ncurses/../ncurses/./tinfo/access.c:125: undefined reference toaccess'Mmmm, the fsif protocol does not provide an access operation to implement that properly. You could add a dummy implementation in
lib/sys.cthat just open()/close() it and return proper error codes if any and it should be fine for ncurses' use cases.
Quoted 5 lines
I stubbed this last one, and now I can compile the ncurses example at
http://www.captain.at/howto-curses-example.php as a c-stubdom; too bad it does not work:Error opening terminal: unknown.
What do you mean by "stubbing"? An implementation just always returning an error?
Quoted 1 line
Now let's try to hardwire the terminal type to xterm or similar...
Note that for that to eventually work you need to give your stubdomain access to the terminfo database via fsif.
Now, I'm wondering about the ncurses requirement: is grub2 really using it for the bootloader, not just for the userland tool? Note for instance that in the case of grub1, I took care of _not_ compiling grub/asmstub.c which is the source for the userland grub, not the bootloader.
Samuel
Hi Samuel,
I've just sent the summary mail before reading yours...
Quoted 8 lines · Samuel Thibault
Quoted 3 lines · Ferenc Wagner, le Tue 28 Apr 2009 19:57:07 +0200, a écrit :
newlib-1.16.0/newlib/libc/include/sys/unistd.hdefines_PC_VDISABLE. It even has an fpathconf implementation in libc/sys/linux. Is there a way to get that work or had I better stub this one, too?Oh, right it's not defined in the linux/ part.
That one should be fine indeed.
Do you know offhand why it isn't found?
Quoted 2 lines
What do you mean by "stubbing"? An implementation just always returning an error?
Or rather success, in this case. But yes.
Quoted 4 lines
Quoted 1 line
Now let's try to hardwire the terminal type to xterm or similar...
Note that for that to eventually work you need to give your stubdomain access to the terminfo database via fsif.
For now I configured out database access and compiled in some fallbacks.
Quoted 2 lines
Now, I'm wondering about the ncurses requirement: is grub2 really using it for the bootloader, not just for the userland tool?
No, it does not require it for the bootloader. My plan is to port the grub-emu userland tool instead, and finally patch kexec on that, just like you did with grub1. That may or may not work out. All I know is
http://grub.enbug.org/FranklinPiat/grub-emu.manpage
Failure was and is an option. :)
Quoted 4 lines
Quoted 1 line
Ok, do I have to extend the # Links section as well?
You need to add a cross-ncurses dependency, but the rest is only for libxc.
I wonder how I got it right...
Quoted 4 lines
Quoted 1 line
I may be blind, but there's no -l linker option in stubdom/Makefile.
Sure, but in qemu/ there is a -lz linker option. Just the usual way, that is.
There's no qemu/ in the 3.3.1 tree, as far as I can see. Looks like I really had better starting with the development tree, but I read stubdom has problems there...
Quoted 9 lines
Quoted 9 lines
NCURSES_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libncurses.a .PHONY: cross-ncurses
cross-ncurses: $(NCURSES_STAMPFILE)
$(NCURSES_STAMPFILE): ncurses-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE)( cd $< && \ CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" CC=$(CC) ./configure --prefix=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf --with-build-cppflags="" --with-build-cflags="" --with-build-ldflags="" --with-build-libs="" && \ $(MAKE) libs && \ $(MAKE) install.libs )
Quoted 3 lines
Quoted 1 line
The --with-build-* options do nothing, so two utilities must be compiled by hand.
You need to pass the $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) there.
Sorry, I don't understand. Where? The target flags are the very thing causing the problem for the build helper programs.
Quoted 5 lines
I'm actually feared by all your terminal additions. These will probably never be implemented in mini-os. They can sure be stubbed, but the application will probably just not work properly. Remember that the Xen console can be attached/detached/reattached from a lot of various kinds of terminals...
Yes, the terminal type should be propagated (and changed on the fly) in mini-os, which is infeasible. Either one has to stick to some common subset or use this in short-lived stub domains only. For example with a boot loader. :)
Quoted 10 lines
Quoted 8 lines
9. Actually, deleting #define current
get_current()fromextras/mini-os/include/mini-os/sched.hmade libncurses++.a build, but broke make c-stubdom... According to Keir Fraser, the simplest fix is:#ifdef
__MINIOS__
#define currentget_current()
#endifUse the same fix as in the unstable tree.
Yes, it didn't work, __MINIOS__ is defined all the time. I worked around in ncurses instead for now.
So let's see how grub-emu likes this environment...
Signature · 2 lines
Thanks, Feri.
Quoted 10 lines · Ferenc Wagner, le Tue 28 Apr 2009 20:47:41 +0200, a écrit :
Quoted 7 lines · Samuel Thibault
Quoted 3 lines · Ferenc Wagner, le Tue 28 Apr 2009 19:57:07 +0200, a écrit :
newlib-1.16.0/newlib/libc/include/sys/unistd.hdefines_PC_VDISABLE. It even has an fpathconf implementation in libc/sys/linux. Is there a way to get that work or had I better stub this one, too?Oh, right it's not defined in the linux/ part.
That one should be fine indeed.Do you know offhand why it isn't found?
What do you refer to by "it"?
_PC_VDISABLE is in the generic part, so that's why ncurses sees it. fpathconf is in the linux/ part, so that's why it's not compiled in. Just take that implementation and it will get compiled in.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Now let's try to hardwire the terminal type to xterm or similar...
Note that for that to eventually work you need to give your stubdomain access to the terminfo database via fsif.
For now I configured out database access and compiled in some fallbacks.
Ok, that should be fine. In that case, maybe you should rather stub access() as always failing, as it's not supposed to read files.
Quoted 6 lines
Quoted 2 lines
Now, I'm wondering about the ncurses requirement: is grub2 really using it for the bootloader, not just for the userland tool?
No, it does not require it for the bootloader. My plan is to port the grub-emu userland tool instead, and finally patch kexec on that, just like you did with grub1.
Err, I didn't port the userland tool, I ported the bootloader. The userland grub1 tool does not even include code to boot kernels, actually...
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
I may be blind, but there's no -l linker option in stubdom/Makefile.
Sure, but in qemu/ there is a -lz linker option. Just the usual way, that is.
There's no qemu/ in the 3.3.1 tree, as far as I can see.
It's a symlink to the ioemu/ tree, yes, I didn't mean a precise directory name, just vaguely evoking ioemu.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
NCURSES_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libncurses.a .PHONY: cross-ncurses
cross-ncurses: $(NCURSES_STAMPFILE)
$(NCURSES_STAMPFILE): ncurses-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE)( cd $< && \ CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" CC=$(CC) ./configure --prefix=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf --with-build-cppflags="" --with-build-cflags="" --with-build-ldflags="" --with-build-libs="" && \ $(MAKE) libs && \ $(MAKE) install.libs )
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
The --with-build-* options do nothing, so two utilities must be compiled by hand.
You need to pass the $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) there.
Sorry, I don't understand. Where? The target flags are the very thing causing the problem for the build helper programs.
In --with-build-*, I guess. What do you hope to build with helper programs? Mini-OS kernels? That would indeed require much more invasive Makefile changes in ncurses. I don't think you need that anyway.
Samuel
Quoted 9 lines · Samuel Thibault, le Tue 28 Apr 2009 20:59:08 +0200, a écrit :
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Now let's try to hardwire the terminal type to xterm or similar...
Note that for that to eventually work you need to give your stubdomain access to the terminfo database via fsif.
For now I configured out database access and compiled in some fallbacks.
Ok, that should be fine. In that case, maybe you should rather stub
access()as always failing, as it's not supposed to read files.
(And put it in the ncurses code. Generally speaking minios _is_ able to access files, via fsif).
Samuel
Quoted 7 lines · Samuel Thibault
Quoted 5 lines · Samuel Thibault, le Tue 28 Apr 2009 20:59:08 +0200, a écrit :
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
Now let's try to hardwire the terminal type to xterm or similar...
Note that for that to eventually work you need to give your stubdomain access to the terminfo database via fsif.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
For now I configured out database access and compiled in some fallbacks.
Ok, that should be fine. In that case, maybe you should rather stub
access()as always failing, as it's not supposed to read files.(And put it in the ncurses code. Generally speaking minios _is_ able to access files, via fsif).
So why deprive ncurses of accessing files for ever? Eventually it could as well read the terminfo database from the host. Btw. it tries to do so by invoking a stat() call, and then segfaults the stubdom. So there's some problem left here, more serious than access().
Signature · 1 line
Feri.
Quoted 11 lines · Ferenc Wagner, le Tue 28 Apr 2009 22:02:03 +0200, a écrit :
Quoted 9 lines · Samuel Thibault
Quoted 7 lines · Samuel Thibault, le Tue 28 Apr 2009 20:59:08 +0200, a écrit :
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Now let's try to hardwire the terminal type to xterm or similar...
Note that for that to eventually work you need to give your stubdomain access to the terminfo database via fsif.
For now I configured out database access and compiled in some fallbacks.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Ok, that should be fine. In that case, maybe you should rather stub
access()as always failing, as it's not supposed to read files.(And put it in the ncurses code. Generally speaking minios _is_ able to access files, via fsif).
So why deprive ncurses of accessing files for ever?
That's why I said to put it in the ncurses code, as you said you enabled an internal database.
Quoted 4 lines
Eventually it could as well read the terminfo database from the host. Btw. it tries to do so by invoking a
stat()call, and then segfaults the stubdom. So there's some problem left here, more serious thanaccess().
Right, I'm not sure we really want to have a stubdom do this.
Samuel
Quoted 7 lines · Samuel Thibault
Quoted 6 lines · Ferenc Wagner, le Tue 28 Apr 2009 20:47:41 +0200, a écrit :
Quoted 5 lines · Samuel Thibault
Quoted 3 lines · Ferenc Wagner, le Tue 28 Apr 2009 19:57:07 +0200, a écrit :
newlib-1.16.0/newlib/libc/include/sys/unistd.hdefines_PC_VDISABLE. It even has an fpathconf implementation in libc/sys/linux. Is there a way to get that work or had I better stub this one, too?
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Oh, right it's not defined in the linux/ part.
That one should be fine indeed.Do you know offhand why it isn't found?
What do you refer to by "it"?
The fpathconf implementation.
Quoted 2 lines
_PC_VDISABLEis in the generic part, so that's why ncurses sees it. fpathconf is in the linux/ part, so that's why it's not compiled in.
Ah, I wasn't aware of this distinction.
Quoted 1 line
Just take that implementation and it will get compiled in.
Sorry for sounding dense... How do I "take that implementation"? I guess you don't mean cut&paste, do you?
Quoted 4 lines
Quoted 1 line
For now I configured out database access and compiled in some fallbacks.
Ok, that should be fine. In that case, maybe you should rather stub
access()as always failing, as it's not supposed to read files.
Not for the ncurses library, but maybe for something else...
Quoted 10 lines
Quoted 6 lines
Quoted 2 lines
Now, I'm wondering about the ncurses requirement: is grub2 really using it for the bootloader, not just for the userland tool?
No, it does not require it for the bootloader. My plan is to port the grub-emu userland tool instead, and finally patch kexec on that, just like you did with grub1.
Err, I didn't port the userland tool, I ported the bootloader. The userland grub1 tool does not even include code to boot kernels, actually...
Yes, it's all the same for grub2. With "just like you did" I meant patching in kexec, so that the grub-emu userland tool can actually boot kernels. You also needed to patch kexec onto the grub1 boot loader (but not the userland tool).
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
I may be blind, but there's no -l linker option in stubdom/Makefile.
Sure, but in qemu/ there is a -lz linker option. Just the usual way, that is.
There's no qemu/ in the 3.3.1 tree, as far as I can see.
It's a symlink to the ioemu/ tree, yes, I didn't mean a precise directory name, just vaguely evoking ioemu.
OK, in ioemu I found
tapdisk-ioemu: tapdisk-ioemu.c cutils.c block.c block-raw.c block-cow.c block-qcow.c aes.c block-vmdk.c block-cloop.c block-dmg.c block-bochs.c block-vpc.c block-vvfat.c block-qcow2.c hw/xen_blktap.c osdep.c
$(CC) -DQEMU_TOOL $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) $(LDFLAGS) $(BASE_LDFLAGS) -o $@ $^ -lz $(LIBS)
and
qemu-img$(EXESUF): qemu-img.c cutils.c block.c block-raw.c block-cow.c block-qcow.c aes.c block-vmdk.c block-cloop.c block-dmg.c block-bochs.c block-vpc.c block-vvfat.c block-qcow2.c
$(CC) -DQEMU_TOOL $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) $(LDFLAGS) $(BASE_LDFLAGS) -o $@ $^ -lz $(LIBS)
but neither is applicable to c-stubdom, where the Makefile stops at creating an archive. I can't add -lncurses there... And generally I feel like being on a totally wrong track, as this part doesn't seem to involve minios at all.
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 7 lines
$(NCURSES_STAMPFILE): ncurses-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE)
( cd $< && \ CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" CC=$(CC) ./configure --prefix=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf --with-build-cppflags="" --with-build-cflags="" --with-build-ldflags="" --with-build-libs="" && \ $(MAKE) libs && \ $(MAKE) install.libs )The --with-build-* options do nothing, so two utilities must be compiled by hand.
You need to pass the $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) there.
Quoted 7 lines
Quoted 2 lines
Sorry, I don't understand. Where? The target flags are the very thing causing the problem for the build helper programs.
In --with-build-*, I guess. What do you hope to build with helper programs? Mini-OS kernels? That would indeed require much more invasive
Makefilechanges in ncurses. I don't think you need that anyway.
Oh no, these helpers are run as part of the cross building process itself, on the host system, not on the target. In the end I found a way to override the target flags for them by specifying BUILD_CCFLAGS="" as a make argument.
Signature · 1 line
Feri.
Quoted 4 lines · Ferenc Wagner, le Tue 28 Apr 2009 21:43:17 +0200, a écrit :
Quoted 1 line
Just take that implementation and it will get compiled in.
Sorry for sounding dense... How do I "take that implementation"? I guess you don't mean cut&paste, do you?
Yep.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
Now, I'm wondering about the ncurses requirement: is grub2 really using it for the bootloader, not just for the userland tool?
No, it does not require it for the bootloader. My plan is to port the grub-emu userland tool instead, and finally patch kexec on that, just like you did with grub1.
Quoted 5 lines
Quoted 3 lines
Err, I didn't port the userland tool, I ported the bootloader. The userland grub1 tool does not even include code to boot kernels, actually...
Yes, it's all the same for grub2.
Err, does grub2 compiles ncurses into the bootloader too?
Quoted 4 lines
but neither is applicable to c-stubdom, where the
Makefilestops at creating an archive. I can't add -lncurses there... And generally I feel like being on a totally wrong track, as this part doesn't seem to involve minios at all.
Oh right, sorry. The final link is not done there but by the minios paragraph of stubdom/Makefile. You can either set APP_LDLIBS to -lncurses there, to override the empty default of mini-os/Makefile, or add -lncurses to APP_LDLIBS in the ifeq($libc),y) section along others.
Samuel
POC: ncurses in stubdom
In reply to Ferenc WagnerQuoted 3 lines · Ferenc Wagner
Error opening terminal: unknown.
Now let's try to hardwire the terminal type to xterm or similar...
Yeah, calling setenv("TERM","xterm",1) before initialization resulted in a working ncurses stub domain! Patches against Xen-3.3.1 attached.
* One needs to apply xen_ncurses.patch only, that references the other two (so tune the paths).
* fpathconf() is stubbed in main.c, because I don't understand the issue yet.
* access() is also blatantly stubbed, as it's pointless in stub domains anyway.
* Most other changes are debatable as well, but they're quite small and should be even smaller in the development version, where some issues are already fixed.
* Example from http://www.captain.at/howto-curses-example.php.
I think something like this (but done right) would be useful in the official packages as well.
Comments welcome!
Signature · 2 lines
Thanks, Feri.
extras/mini-os/lib/sys.c +32 -0
@@ -147,6 +147,16 @@return 1 ; } +pid_t tcgetpgrp (int fd) +{ +return 1 ; +} + +pid_t getpgrp (void ) +{ +return 1 ; +} +char *getcwd (char *buf,size_t size) {snprintf (buf, size,"/" );
@@ -364,6 +374,20 @@return -1 ; } +int tcflush (int fd,int queue_selector) +{ +switch (files[fd].type) { +case FTYPE_CONSOLE : +/* Already flushed */ +return 0 ; +default : +break ; + } +printk ("tcflush(%d): Bad descriptor\n" , fd); + errno =EBADF ; +return -1 ; +} +int close (int fd) {printk ("close(%d)\n" , fd);
@@ -472,6 +496,8 @@ out:return ret; } +/* We do not have symlinks */ +int lstat (const char *path,struct stat *buf) __attribute__((alias ("stat" )));int fstat (int fd,struct stat *buf) {
@@ -509,6 +535,12 @@return -1 ; } +/* Dummy implementation: always true */ +int access (const char *path,int mode) +{ +return 0 ; +} +int ftruncate (int fd,off_t length) {switch (files[fd].type) {
extras/mini-os/Makefile +1 -1
@@ -20,7 +20,7 @@ # Define some default flags for linking. LDLIBS := -APP_LDLIBS := +APP_LDLIBS := -lncurses LDARCHLIB := -L$(OBJ_DIR)/$(TARGET_ARCH_DIR) -l$(ARCH_LIB_NAME) LDFLAGS_FINAL := -T $(TARGET_ARCH_DIR)/minios-$(XEN_TARGET_ARCH).lds
stubdom/c/main.c +77 -1
85 lines not on this page · raw message
stubdom/Makefile +27 -3
@@ -20,6 +20,8 @@ LWIP_VERSION=1.3.0 GRUB_URL?=http://alpha.gnu.org/gnu/grub GRUB_VERSION=0.97 +NCURSES_URL?=ftp://invisible-island.net/ncurses +NCURSES_VERSION=5.7 WGET=wget -c
@@ -59,8 +61,8 @@ TARGET_CPPFLAGS += -isystem $(CURDIR)/$(MINI_OS)/include/posix TARGET_CPPFLAGS += -isystem $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include TARGET_CPPFLAGS += -isystem $(GCC_INSTALL)include -TARGET_CPPFLAGS += -isystem $(CURDIR)/lwip/src/include -TARGET_CPPFLAGS += -isystem $(CURDIR)/lwip/src/include/ipv4 +TARGET_CPPFLAGS += -isystem $(CURDIR)/lwip-$(XEN_TARGET_ARCH)/src/include +TARGET_CPPFLAGS += -isystem $(CURDIR)/lwip-$(XEN_TARGET_ARCH)/src/include/ipv4 TARGET_CPPFLAGS += -I$(CURDIR)/include TARGET_LDFLAGS += -nostdlib -L$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib
@@ -85,6 +87,7 @@ newlib-$(NEWLIB_VERSION): newlib-$(NEWLIB_VERSION).tar.gz tar xzf $< patch -d $@ -p0 < newlib.patch + patch -d $@ -p0 < ~/xen/newlib_memalign.patch touch $@ NEWLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libc.a
@@ -117,6 +120,27 @@ $(MAKE) libz.a && \ $(MAKE) install ) +############### +# Cross-ncurses +############### + +ncurses-$(NCURSES_VERSION).tar.gz: + $(WGET) $(NCURSES_URL)/$@ + +ncurses-$(XEN_TARGET_ARCH): ncurses-$(NCURSES_VERSION).tar.gz + tar xzf $< + mv ncurses-$(NCURSES_VERSION) $@ + chmod -R o+w $@ + patch -d $@ -p1 < ~/xen/ncurses.patch + +NCURSES_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libncurses.a +.PHONY: cross-ncurses +cross-ncurses: $(NCURSES_STAMPFILE) +$(NCURSES_STAMPFILE): ncurses-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE) + ( cd $< && \ + CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" CC=$(CC) ./configure --prefix=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf --disable-database --with-fallbacks="ansi,linux,vt102,xterm" && \ + $(MAKE) BUILD_CCFLAGS="-DHAVE_CONFIG_H -I../ncurses -I$(srcdir) -I$(INCDIR) -I../include" install.libs ) + ############## # Cross-libpci ##############
@@ -162,7 +186,7 @@ ####### .PHONY: $(CROSS_ROOT) -$(CROSS_ROOT): cross-newlib cross-zlib cross-libpci +$(CROSS_ROOT): cross-newlib cross-zlib cross-ncurses cross-libpci mk-headers-$(XEN_TARGET_ARCH): mkdir -p include/xen && \
form/form.h +3 -0
@@ -38,6 +38,9 @@#include <curses.h> #include <eti.h> +/* Xen header bug workaround */ +#undef current +#ifdef __cplusplusextern "C" {#endif
ncurses/base/lib_newterm.c +3 -0
@@ -48,6 +48,9 @@#include <term.h> /* clear_screen, cup & friends, cur_term */ #include <tic.h> +/* Xen header bug workaround */ +#undef current + MODULE_ID("$Id: lib_newterm.c,v 1.73 2008/08/16 21:20:48 Werner.Fink Exp $")#ifndef ONLCR /* Allows compilation under the QNX 4.2 OS */
ncurses/tinfo/lib_baudrate.c +19 -1
@@ -95,6 +95,24 @@int sp;/* the actual speed */ }; +/* Copied from Linux' /usr/include/bits/termios.h, Mini-OS has no support for these */ +#define B0 0000000/* hang up */ +#define B50 0000001 +#define B75 0000002 +#define B110 0000003 +#define B134 0000004 +#define B150 0000005 +#define B200 0000006 +#define B300 0000007 +#define B600 0000010 +#define B1200 0000011 +#define B1800 0000012 +#define B2400 0000013 +#define B4800 0000014 +#define B9600 0000015 +#define B19200 0000016 +#define B38400 0000017 +static struct speed const speeds[] = { {B0 ,0 },
@@ -223,7 +241,7 @@ ospeed =_nc_ospeed (result);#else /* !USE_OLD_TTY */ #ifdef TERMIOS - ospeed =cfgetospeed (&cur_term->Nttyb); + ospeed =B38400 ;/* not applicable */ #else ospeed = cur_term->Nttyb.sg_ospeed;#endif
ncurses/tinfo/lib_kernel.c +5 -0
@@ -48,6 +48,11 @@#include <curses.priv.h> #include <term.h> /* cur_term */ +/* Copied from Linux' /usr/include/bits/termios.h, Mini-OS has no support for these */ +#define VERASE 2 +#define VKILL 3 +#define TCIFLUSH 0 + MODULE_ID("$Id: lib_kernel.c,v 1.24 2004/05/08 17:11:21 tom Exp $") static int
ncurses/tty/lib_twait.c +2 -2
@@ -41,8 +41,6 @@** comments, none of the original code remains - T.Dickey). */ -#include <curses.priv.h> -#if defined __HAIKU__ && defined __BEOS__#undef __BEOS__#endif
@@ -68,6 +66,8 @@#undef CUR +#include <curses.priv.h> + MODULE_ID("$Id: lib_twait.c,v 1.59 2008/08/30 20:08:19 tom Exp $") static long
ncurses/tty/tty_update.c +2 -2
@@ -42,8 +42,6 @@* *-----------------------------------------------------------------*/ -#include <curses.priv.h> -#if defined __HAIKU__ && defined __BEOS__#undef __BEOS__#endif
@@ -75,6 +73,8 @@#endif #endif +#include <curses.priv.h> +#include <ctype.h> #include <term.h>
libc/include/malloc.h renamed from libc/include/malloc.h.orig +1 -0
@@ -73,6 +73,7 @@#else extern _PTR _memalign_r _PARAMS ((struct _reent *, size_t, size_t));#endif +#define posix_memalign memalign extern struct mallinfo mallinfo _PARAMS ((void));#ifdef __CYGWIN__
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Re: POC: ncurses in stubdom
Quoted 2 lines · Ferenc Wagner, le Tue 28 Apr 2009 20:22:11 +0200, a écrit :
*
fpathconf()is stubbed inmain.c, because I don't understand the issue yet.
Just use the implementation from the linux/ part of newlib, it should be fine.
Quoted 2 lines
*
access()is also blatantly stubbed, as it's pointless in stub domains anyway.
No it's not. It's just a matter of adding the interface to fsio. Trying to open/close the file and returning appropriate errors should already be enough to test the R_OK and W_OK cases, which are what ncurses use in addition to X_OK which we could consider as always successful for now.
Quoted 3 lines
* Most other changes are debatable as well, but they're quite small and should be even smaller in the development version, where some issues are already fixed.
Yes, please rebase to that.
Content-Description: Master patch against Xen-3.3.1
Quoted 10 lines
diff -ru
xen-3.3.1.orig/extras/mini-os/lib/sys.cxen-3.3.1/extras/mini-os/lib/sys.cextras/mini-os/lib/sys.c +3
-0@@ -147,6 +147,16 @@return 1 ; } +pid_t tcgetpgrp (int fd) +{ +return 1 ;
extras/mini-os/lib/sys.c line 162
Quoted 10 lines
extras/mini-os/lib/sys.c +7
-0+} + +pid_t getpgrp (void ) +{ +return 1 ; +} +char *getcwd (char *buf,size_t size) {snprintf (buf, size,"/" );
Do not forget to put the
To keep credits (as well as blame) properly assigned.
extras/mini-os/Makefile line 25
Quoted 11 lines
diff -ru xen-3.3.1.orig/extras/mini-os/Makefile xen-3.3.1/extras/mini-os/Makefile
extras/mini-os/Makefile +1
-1@@ -20,7 +20,7 @@ # Define some default flags for linking. LDLIBS := -APP_LDLIBS := +APP_LDLIBS := -lncurses LDARCHLIB := -L$(OBJ_DIR)/$(TARGET_ARCH_DIR) -l$(ARCH_LIB_NAME) LDFLAGS_FINAL := -T $(TARGET_ARCH_DIR)/minios-$(XEN_TARGET_ARCH).lds
It shouldn't be there, but in your c-stubdom Makefile, just like regular applications do.
extras/mini-os/Makefile line 90
Quoted 5 lines
extras/mini-os/Makefile +1
-0@@ -85,6 +87,7 @@ newlib-$(NEWLIB_VERSION): newlib-$(NEWLIB_VERSION).tar.gz tar xzf $< patch -d $@ -p0 < newlib.patch + patch -d $@ -p0 < ~/xen/newlib_memalign.patch
Just fold it into newlib.patch, no need to separate them.
Samuel
Re: POC: ncurses in stubdom
Quoted 7 lines · Samuel Thibault
Quoted 2 lines · Ferenc Wagner, le Tue 28 Apr 2009 20:22:11 +0200, a écrit :
*
fpathconf()is stubbed inmain.c, because I don't understand the issue yet.Just use the implementation from the linux/ part of newlib, it should be fine.
As noted in my other reply, it isn't clear to me how I could use the linux/ part of newlib, sorry.
Quoted 4 lines
Quoted 2 lines
*
access()is also blatantly stubbed, as it's pointless in stub domains anyway.No it's not. It's just a matter of adding the interface to fsio.
I meant that it makes a distinction on real vs effective UID/GID, which isn't an issue in the single-user stubdom environment. Otherwise, I wouldn't do anything but opened races...
Quoted 2 lines
Trying to open/close the file and returning appropriate errors should already be enough to test the
R_OKandW_OKcases,
Only if euid=ruid, which is always the case in stubdom, isn't it? But then trying the operation itself provides the exact same diagnostics. This is what I mean by "pointless".
Quoted 2 lines
which are what ncurses use in addition to
X_OKwhich we could consider as always successful for now.
Yes, we could approximate the functionality. I don't know what ncurses uses it for, but we'll see.
Quoted 5 lines
Quoted 3 lines
* Most other changes are debatable as well, but they're quite small and should be even smaller in the development version, where some issues are already fixed.
Yes, please rebase to that.
Will do if this stuff turns out to be useful after all.
Quoted 3 lines
Do not forget to put the
Signed-off-by Samuel Thibault <[email protected]>To keep credits (as well as blame) properly assigned.
Sure, I didn't mean this as a patch submission. As your changes are generally useful, I expected that you submit them anyway, and they disappear from my diff.
Quoted 5 lines
Quoted 5 lines
diff -ru xen-3.3.1.orig/extras/mini-os/Makefile xen-3.3.1/extras/mini-os/Makefile
extras/mini-os/Makefile +0
-0@@ -20,7 +20,7 @@
Quoted 9 lines
extras/mini-os/Makefile line 25
Quoted 6 lines
extras/mini-os/Makefile +1
-1# Define some default flags for linking. LDLIBS := -APP_LDLIBS := +APP_LDLIBS := -lncurses LDARCHLIB := -L$(OBJ_DIR)/$(TARGET_ARCH_DIR) -l$(ARCH_LIB_NAME) LDFLAGS_FINAL := -T $(TARGET_ARCH_DIR)/minios-$(XEN_TARGET_ARCH).ldsIt shouldn't be there, but in your c-stubdom
Makefile, just like regular applications do.
My problem is that the c-stubdom Makefile does not link, but creates an archive instead, so I can't add linker options there.
Quoted 7 lines
extras/mini-os/Makefile line 90
Quoted 5 lines
extras/mini-os/Makefile +1
-0@@ -85,6 +87,7 @@ newlib-$(NEWLIB_VERSION): newlib-$(NEWLIB_VERSION).tar.gz tar xzf $< patch -d $@ -p0 < newlib.patch + patch -d $@ -p0 < ~/xen/newlib_memalign.patchJust fold it into newlib.patch, no need to separate them.
Grub2 fell over on this, btw. In util/misc.c:
/* Include malloc.h, only if memalign is available. It is known that
memalign is declared in malloc.h in all systems, if present. */
#ifdef HAVE_MEMALIGN
# include <malloc.h> #endif
[...]
void *grub_memalign (grub_size_t align, grub_size_t size) {
void *p;
#if defined(HAVE_POSIX_MEMALIGN)
if (posix_memalign (&p, align, size) != 0)
p = 0;
#elif defined(HAVE_MEMALIGN)
p = memalign (align, size);
#else
(void) align;
(void) size;
grub_util_error ("grub_memalign is not supported");
#endif
if (! p)
grub_util_error ("out of memory"); return p;
}
which shows that memalign() and posix_memalign() have a different number of arguments, so #define posix_memalign memalign can't be right.
Signature · 1 line
Feri.
Re: POC: ncurses in stubdom
Quoted 5 lines · Ferenc Wagner, le Tue 28 Apr 2009 21:56:07 +0200, a écrit :
Quoted 4 lines
Quoted 2 lines
*
access()is also blatantly stubbed, as it's pointless in stub domains anyway.No it's not. It's just a matter of adding the interface to fsio.
Quoted 8 lines
I meant that it makes a distinction on real vs effective UID/GID, which isn't an issue in the single-user stubdom environment. Otherwise, I wouldn't do anything but opened races...
Quoted 2 lines
Trying to open/close the file and returning appropriate errors should already be enough to test the
R_OKandW_OKcases,Only if euid=ruid, which is always the case in stubdom, isn't it?
Yes.
Quoted 2 lines
But then trying the operation itself provides the exact same diagnostics. This is what I mean by "pointless".
Ok, but applications could still be upset to see access() work and not open(), or vice-versa.
Quoted 5 lines
#if
defined(HAVE_POSIX_MEMALIGN)
if (posix_memalign(&p, align, size) != 0)p = 0;#elif
defined(HAVE_MEMALIGN)
p = memalign (align, size);
Errr, so grub2 doesn't unconditionally use posix_memalign. How did grub2 detect HAVE_POSIX_MEMALIGN? Adding posix_memalign as a proper function shouldn't be hard, though (and could be submitted upstream).
Samuel
Re: POC: ncurses in stubdom
Quoted 7 lines · Samuel Thibault
Quoted 2 lines · Ferenc Wagner, le Tue 28 Apr 2009 21:56:07 +0200, a écrit :
But then trying the operation itself provides the exact same diagnostics. This is what I mean by "pointless".
Ok, but applications could still be upset to see
access()work and notopen(), or vice-versa.
Sure, but then they are buggy. No one should assume that nothing changes in the time slice between access() and open() for example.
Quoted 8 lines
Quoted 5 lines
#if
defined(HAVE_POSIX_MEMALIGN)
if (posix_memalign(&p, align, size) != 0)p = 0;#elif
defined(HAVE_MEMALIGN)
p = memalign (align, size);Errr, so grub2 doesn't unconditionally use
posix_memalign. How did grub2 detectHAVE_POSIX_MEMALIGN?
By autoconf:AC_CHECK_FUNCS(posix_memalign memalign asprintf)
Quoted 2 lines
Adding
posix_memalignas a proper function shouldn't be hard, though (and could be submitted upstream).
If you say so... It's actually the first time I met the memalign family.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Just take that implementation and it will get compiled in.
Sorry for sounding dense... How do I "take that implementation"? I guess you don't mean cut&paste, do you?
Yep.
Horrors!
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
Now, I'm wondering about the ncurses requirement: is grub2 really using it for the bootloader, not just for the userland tool?
No, it does not require it for the bootloader. My plan is to port the grub-emu userland tool instead, and finally patch kexec on that, just like you did with grub1.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Err, I didn't port the userland tool, I ported the bootloader. The userland grub1 tool does not even include code to boot kernels, actually...
Yes, it's all the same for grub2.
Err, does grub2 compiles ncurses into the bootloader too?
No, it does not.
Quoted 9 lines
Quoted 4 lines
but neither is applicable to c-stubdom, where the
Makefilestops at creating an archive. I can't add -lncurses there... And generally I feel like being on a totally wrong track, as this part doesn't seem to involve minios at all.Oh right, sorry. The final link is not done there but by the minios paragraph of stubdom/Makefile. You can either set
APP_LDLIBSto -lncurses there, to override the empty default of mini-os/Makefile, or add -lncurses toAPP_LDLIBSin the ifeq($libc),y) section along others.
This is what I did in the POC.
Quoted 8 lines
Quoted 4 lines · Ferenc Wagner, le Tue 28 Apr 2009 22:02:03 +0200, a écrit :
Eventually it could as well read the terminfo database from the host. Btw. it tries to do so by invoking a
stat()call, and then segfaults the stubdom. So there's some problem left here, more serious thanaccess().Right, I'm not sure we really want to have a stubdom do this.
Do you mean accessing the host filesystem? I agree that shouldn't be made necessary, as stubdoms are a security measure in part.
Huh, I'm getting out of steam for today, and not sure I will be able to work on this tomorrow. Now comes interfacing grub2's host disk access code with blkfront, which wouldn't be hard if blkfront didn't require aligned buffers... :/
Signature · 3 lines
Thanks for today's help, again! Cheers, Feri.
Re: POC: ncurses in stubdom
Quoted 10 lines · Ferenc Wagner, le Tue 28 Apr 2009 22:46:19 +0200, a écrit :
Quoted 7 lines · Samuel Thibault
Quoted 2 lines · Ferenc Wagner, le Tue 28 Apr 2009 21:56:07 +0200, a écrit :
But then trying the operation itself provides the exact same diagnostics. This is what I mean by "pointless".
Ok, but applications could still be upset to see
access()work and notopen(), or vice-versa.Sure, but then they are buggy.
So be they. We unfortunately can't change all of them just by will.
Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
#if
defined(HAVE_POSIX_MEMALIGN)
if (posix_memalign(&p, align, size) != 0)p = 0;#elif
defined(HAVE_MEMALIGN)
p = memalign (align, size);Errr, so grub2 doesn't unconditionally use
posix_memalign. How did grub2 detectHAVE_POSIX_MEMALIGN?By autoconf:
AC_CHECK_FUNCS(posix_memalign memalign asprintf)
Mmmmm, and I guess it's linking against the host OS, not the stubdom OS, grmbl.
Quoted 6 lines
Quoted 4 lines
Oh right, sorry. The final link is not done there but by the minios paragraph of stubdom/Makefile. You can either set
APP_LDLIBSto -lncurses there, to override the empty default of mini-os/Makefile, or add -lncurses toAPP_LDLIBSin the ifeq($libc),y) section along others.This is what I did in the POC.
Err, in your patch it wasn't in the ifeq section but the empty declaration.
Quoted 11 lines
Quoted 8 lines
Quoted 4 lines · Ferenc Wagner, le Tue 28 Apr 2009 22:02:03 +0200, a écrit :
Eventually it could as well read the terminfo database from the host. Btw. it tries to do so by invoking a
stat()call, and then segfaults the stubdom. So there's some problem left here, more serious thanaccess().Right, I'm not sure we really want to have a stubdom do this.
Do you mean accessing the host filesystem? I agree that shouldn't be made necessary, as stubdoms are a security measure in part.
Yes.
Samuel
Re: POC: ncurses in stubdom
Quoted 7 lines · Samuel Thibault
Quoted 6 lines · Ferenc Wagner, le Tue 28 Apr 2009 22:46:19 +0200, a écrit :
Quoted 5 lines · Samuel Thibault
Quoted 2 lines · Ferenc Wagner, le Tue 28 Apr 2009 21:56:07 +0200, a écrit :
But then trying the operation itself provides the exact same diagnostics. This is what I mean by "pointless".
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Ok, but applications could still be upset to see
access()work and notopen(), or vice-versa.Sure, but then they are buggy.
So be they. We unfortunately can't change all of them just by will.
I tried to imply there shouldn't be that many of them. Maybe none... Well, at least not too many which could be usefully run in a stubdom.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
#if
defined(HAVE_POSIX_MEMALIGN)
if (posix_memalign(&p, align, size) != 0)p = 0;#elif
defined(HAVE_MEMALIGN)
p = memalign (align, size);
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Errr, so grub2 doesn't unconditionally use
posix_memalign. How did grub2 detectHAVE_POSIX_MEMALIGN?By autoconf:
AC_CHECK_FUNCS(posix_memalign memalign asprintf)Mmmmm, and I guess it's linking against the host OS, not the stubdom OS, grmbl.
Ugh, that can be. One can't pass LDFLAGS to configure, as then:
checking whether the C compiler works... configure: error: cannot run C compiled programs.
Cross compilation should be made more explicit somehow.
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
Oh right, sorry. The final link is not done there but by the minios paragraph of stubdom/Makefile. You can either set
APP_LDLIBSto -lncurses there, to override the empty default of mini-os/Makefile, or add -lncurses toAPP_LDLIBSin the ifeq($libc),y) section along others.This is what I did in the POC.
Err, in your patch it wasn't in the ifeq section but the empty declaration.
Yes, I read the above as allowing that. But I'll move it.
Signature · 2 lines
Thanks, Feri.
Re: POC: ncurses in stubdom
Quoted 9 lines · Ferenc Wagner, le Tue 28 Apr 2009 23:24:24 +0200, a écrit :
Quoted 5 lines
Quoted 2 lines
By autoconf:
AC_CHECK_FUNCS(posix_memalign memalign asprintf)Mmmmm, and I guess it's linking against the host OS, not the stubdom OS, grmbl.
Ugh, that can be. One can't pass LDFLAGS to configure, as then:
checking whether the C compiler works... configure: error: cannot run C compiled programs.
Yes since it'd have to not only link libc.a but also the minios kernel.
Samuel
Re: POC: ncurses in stubdom (now with hg patch set)
In reply to Samuel ThibaultQuoted 6 lines · Samuel Thibault
Quoted 2 lines · Ferenc Wagner, le Tue 28 Apr 2009 20:22:11 +0200, a écrit :
*
fpathconf()is stubbed inmain.c, because I don't understand the issue yet.Just use the implementation from the linux/ part of newlib, it should be fine.
After respinning this stuff against unstable, I couldn't find and easy way to compile fpathconf() from the linux part of newlib (lots of undefined symbols everywhere), so this didn't change. Anyway, if it's linux specific, it should be stubdom specific as well, as I understand it.
A dummy access() is much easier, it's probably never invoked, so I didn't care for now.
Quoted 5 lines
Quoted 3 lines
* Most other changes are debatable as well, but they're quite small and should be even smaller in the development version, where some issues are already fixed.
Yes, please rebase to that.
Please find the exported ncurses patch queue attached. There are still header problems, but these are ncurses ones: columns is #defined in ncurses-x86_32/include/term.h, which breaks line 590 in stubdom/include/xen/xen.h, if curses.priv.h is #included before sys/select.h. There were two occurences of this. Otherwise, the included example works pretty good.
Cheers,
Feri.
# HG changeset patch
# User Samuel Thibault <[email protected]> # Date 1242219292 -7200
# Node ID 427556bd6e28f5697cc5fd797eee2f62affe1387
# Parent 2522cc95efd2f3fadf7342d18fe86e8f37f89c2a Add tcgetpgrp getpgrp tcflush and lstat dummy implementations.
extras/mini-os/lib/sys.c +26 -0
@@ -144,6 +144,16 @@ }pid_t setsid (void ) +{ +return 1 ; +} + +pid_t tcgetpgrp (int fd) +{ +return 1 ; +} + +pid_t getpgrp (void ) {return 1 ; }
@@ -365,6 +375,20 @@return -1 ; } +int tcflush (int fd,int queue_selector) +{ +switch (files[fd].type) { +case FTYPE_CONSOLE : +/* Already flushed */ +return 0 ; +default : +break ; + } +printk ("tcflush(%d): Bad descriptor\n" , fd); + errno =EBADF ; +return -1 ; +} +int close (int fd) {printk ("close(%d)\n" , fd);
@@ -473,6 +497,8 @@ out:return ret; } +/* We do not have symlinks */ +int lstat (const char *path,struct stat *buf) __attribute__((alias ("stat" )));int fstat (int fd,struct stat *buf) {
# HG changeset patch
# User Ferenc Wagner <[email protected]>
# Date 1242219918 -7200
# Node ID 9a29b3c38acbad0c431eab8ab0fab2022d04abaf # Parent 427556bd6e28f5697cc5fd797eee2f62affe1387 Add access() dummy implementation.
extras/mini-os/lib/sys.c +7 -0
@@ -534,6 +534,13 @@printk ("statf(%d): Bad descriptor\n" , fd); errno =EBADF ;return -1 ; +} + +/* Dummy implementation: always true. +* There's no distinction between real and effective UID and GID. */ +int access (const char *path,int mode) +{ +return 0 ; }int ftruncate (int fd,off_t length)
# HG changeset patch
# User Ferenc Wagner <[email protected]>
# Date 1242220483 -7200
# Node ID 1d65cd8ddb592098d7cf34dcf103c48cf4ab8f7e # Parent 9a29b3c38acbad0c431eab8ab0fab2022d04abaf Add ncurses library to cross-root
extras/mini-os/Makefile +1 -0
@@ -80,6 +80,7 @@ ifeq ($(libc),y) APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libxc-$(XEN_TARGET_ARCH) -whole-archive -lxenguest -lxenctrl -no-whole-archive +APP_LDLIBS += -lncurses APP_LDLIBS += -lpci APP_LDLIBS += -lz APP_LDLIBS += -lm
stubdom/Makefile +26 -1
@@ -26,6 +26,9 @@ #GRUB_URL?=http://alpha.gnu.org/gnu/grub GRUB_URL?=$(XEN_EXTFILES_URL) GRUB_VERSION=0.97 + +NCURSES_URL?=ftp://invisible-island.net/ncurses +NCURSES_VERSION=5.7 WGET=wget -c
@@ -151,6 +154,28 @@ $(INSTALL_DATA) lib/config.h lib/header.h lib/pci.h lib/types.h $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci/ \ ) +############### +# Cross-ncurses +############### + +ncurses-$(NCURSES_VERSION).tar.gz: + $(WGET) $(NCURSES_URL)/$@ + +ncurses-$(XEN_TARGET_ARCH): ncurses-$(NCURSES_VERSION).tar.gz ncurses.patch + rm -rf $@ + tar xmzf $< + mv ncurses-$(NCURSES_VERSION) $@ + chmod -R u+w $@ + patch -d $@ -p1 < ncurses.patch + +NCURSES_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libncurses.a +.PHONY: cross-ncurses +cross-ncurses: $(NCURSES_STAMPFILE) +$(NCURSES_STAMPFILE): ncurses-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE) + ( cd $< && \ + CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" CC=$(CC) ./configure --prefix=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf --disable-database --with-fallbacks="ansi,linux,vt102,xterm" && \ + $(MAKE) BUILD_CCFLAGS="-DHAVE_CONFIG_H -I../ncurses -I$(srcdir) -I$(INCDIR) -I../include" install.libs ) + ###### # lwIP ######
@@ -169,7 +194,7 @@ ####### .PHONY: $(CROSS_ROOT) -$(CROSS_ROOT): cross-newlib cross-zlib cross-libpci +$(CROSS_ROOT): cross-newlib cross-zlib cross-libpci cross-ncurses $(XEN_ROOT)/tools/ioemu-dir: make -C $(XEN_ROOT)/tools ioemu-dir-find
stubdom/ncurses.patch new file +94 -0
94 lines not on this page · raw message
# HG changeset patch
# User Ferenc Wagner <[email protected]>
# Date 1242221098 -7200
# Node ID a17dfe7bd0be7986eaf46e84c6091d905345da9a # Parent 1d65cd8ddb592098d7cf34dcf103c48cf4ab8f7e Replace the C "Hello world!" example with an ncurses example from http://www.captain.at/howto-curses-example.php
stubdom/c/main.c +77 -1
85 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Re: Re: POC: ncurses in stubdom (now with hg patch set)
Quoted 10 lines · Ferenc Wagner, le Wed 13 May 2009 21:07:27 +0200, a écrit :
Quoted 6 lines · Samuel Thibault
Quoted 2 lines · Ferenc Wagner, le Tue 28 Apr 2009 20:22:11 +0200, a écrit :
*
fpathconf()is stubbed inmain.c, because I don't understand the issue yet.Just use the implementation from the linux/ part of newlib, it should be fine.
After respinning this stuff against unstable, I couldn't find and easy way to compile
fpathconf()from the linux part of newlib
Err, I was probably not clear: I meant to just copy the code, not try to do Makefile contorsions to manage to compile linux files.
Quoted 2 lines
Anyway, if it's linux specific, it should be stubdom specific as well, as I understand it.
Actually the linux implementation is not.
Quoted 3 lines
columns is #defined
inncurses-x86_32/include/term.h, which breaks line 590 instubdom/include/xen/xen.h,
Damn. ncurses sucks :)
The inversion of headers should be not so ugly, though.
Samuel
Re: POC: ncurses in stubdom (now with hg patch set)
Quoted 6 lines · Samuel Thibault
Quoted 5 lines · Ferenc Wagner, le Wed 13 May 2009 21:07:27 +0200, a écrit :
Quoted 4 lines · Samuel Thibault
Quoted 2 lines · Ferenc Wagner, le Tue 28 Apr 2009 20:22:11 +0200, a écrit :
*
fpathconf()is stubbed inmain.c, because I don't understand the issue yet.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Just use the implementation from the linux/ part of newlib, it should be fine.
After respinning this stuff against unstable, I couldn't find and easy way to compile
fpathconf()from the linux part of newlibErr, I was probably not clear: I meant to just copy the code, not try to do
Makefilecontorsions to manage to compile linux files.
I didn't try that. I copied fpathconf.c into stubdom/c and tried to
compile it alongside main.c. It wanted to #include everything in the
world and more, so I called it a day.
Quoted 4 lines
Quoted 2 lines
Anyway, if it's linux specific, it should be stubdom specific as well, as I understand it.
Actually the linux implementation is not.
Fine, then.
Quoted 6 lines
Quoted 3 lines
columns is #defined
inncurses-x86_32/include/term.h, which breaks line 590 instubdom/include/xen/xen.h,Damn. ncurses sucks :)
The inversion of headers should be not so ugly, though.
I feel it isn't as it is, don't you think? Two simple changes in two files, to get the static library compiled, as the patches show.
Anyway, maybe this stuff loses relevance. I asked the Grub developers, and they were more interested in porting Grub natively to Xen PV than piggybacking Mini-OS. But I couldn't find the Xen ABI documentation (or whatever it's called). blkif-drivers-explained.txt sounds somewhat aged. Can you recommend something definitive? Also, the roadmap suggests that some changes are expected. That would mean 4 different new architectures for Grub (32 vs 64 bit and current vs new ABI)...
Signature · 1 line
Feri.
Re: POC: ncurses in stubdom (now with hg patch set)
Quoted 7 lines · Ferenc Wagner, le Thu 14 May 2009 13:36:36 +0200, a écrit :
Quoted 2 lines · Samuel Thibault
Err, I was probably not clear: I meant to just copy the code, not try to do
Makefilecontorsions to manage to compile linux files.I didn't try that. I copied
fpathconf.cinto stubdom/c and tried to
compile it alongsidemain.c. It wanted to #include everything in the
world and more, so I called it a day.
I didn't mean the whole file, just the code that you need,
case _PC_VDISABLE:
#ifdef>-_POSIX_VDISABLE
return _POSIX_VDISABLE;
#else
return -1;#endif
and the fd<0 check case and default:
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Anyway, if it's linux specific, it should be stubdom specific as well, as I understand it.
Actually the linux implementation is not.
Fine, then.
I mean, the few lines above.
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
columns is #defined
inncurses-x86_32/include/term.h, which breaks line 590 instubdom/include/xen/xen.h,Damn. ncurses sucks :)
The inversion of headers should be not so ugly, though.
Quoted 7 lines
I feel it isn't as it is, don't you think? Two simple changes in two files, to get the static library compiled, as the patches show.
Anyway, maybe this stuff loses relevance. I asked the Grub developers, and they were more interested in porting Grub natively to Xen PV than piggybacking Mini-OS. But I couldn't find the Xen ABI documentation (or whatever it's called).
It's all in docs/, interface.tex notably, and xen/include/public/
Quoted 1 line
Also, the roadmap suggests that some changes are expected.
Which roadmap, where?
Samuel