Samuel Thibault <samuel.thibault@xxxxxxxxxxxx> writes:
> Ferenc Wagner, le Tue 28 Apr 2009 20:22:11 +0200, a écrit :
>> * fpathconf() is stubbed in main.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.
>> * 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 <samuel.thibault@xxxxxxxxxxxx>
# Date 1242219292 -7200
# Node ID 427556bd6e28f5697cc5fd797eee2f62affe1387
# Parent 2522cc95efd2f3fadf7342d18fe86e8f37f89c2a
Add tcgetpgrp getpgrp tcflush and lstat dummy implementations.
Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx>
diff -r 2522cc95efd2 -r 427556bd6e28 extras/mini-os/lib/sys.c
--- a/extras/mini-os/lib/sys.c Mon May 11 13:52:04 2009 +0100
+++ b/extras/mini-os/lib/sys.c Wed May 13 14:54:52 2009 +0200
@@ -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 <wferi@xxxxxxx>
# Date 1242219918 -7200
# Node ID 9a29b3c38acbad0c431eab8ab0fab2022d04abaf
# Parent 427556bd6e28f5697cc5fd797eee2f62affe1387
Add access() dummy implementation.
Signed-off-by: Ferenc Wagner <wferi@xxxxxxx>
diff -r 427556bd6e28 -r 9a29b3c38acb extras/mini-os/lib/sys.c
--- a/extras/mini-os/lib/sys.c Wed May 13 14:54:52 2009 +0200
+++ b/extras/mini-os/lib/sys.c Wed May 13 15:05:18 2009 +0200
@@ -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 <wferi@xxxxxxx>
# Date 1242220483 -7200
# Node ID 1d65cd8ddb592098d7cf34dcf103c48cf4ab8f7e
# Parent 9a29b3c38acbad0c431eab8ab0fab2022d04abaf
Add ncurses library to cross-root
Signed-off-by: Ferenc Wagner <wferi@xxxxxxx>
diff -r 9a29b3c38acb -r 1d65cd8ddb59 extras/mini-os/Makefile
--- a/extras/mini-os/Makefile Wed May 13 15:05:18 2009 +0200
+++ b/extras/mini-os/Makefile Wed May 13 15:14:43 2009 +0200
@@ -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
diff -r 9a29b3c38acb -r 1d65cd8ddb59 stubdom/Makefile
--- a/stubdom/Makefile Wed May 13 15:05:18 2009 +0200
+++ b/stubdom/Makefile Wed May 13 15:14:43 2009 +0200
@@ -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
diff -r 9a29b3c38acb -r 1d65cd8ddb59 stubdom/ncurses.patch
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/stubdom/ncurses.patch Wed May 13 15:14:43 2009 +0200
@@ -0,0 +1,94 @@
+diff -ru ncurses-5.7.orig/ncurses/tinfo/lib_baudrate.c
ncurses-5.7/ncurses/tinfo/lib_baudrate.c
+--- ncurses-5.7.orig/ncurses/tinfo/lib_baudrate.c 2009-04-28
17:39:41.471850972 +0200
++++ ncurses-5.7/ncurses/tinfo/lib_baudrate.c 2009-04-28 17:42:55.999849179
+0200
+@@ -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
+diff -ru ncurses-5.7.orig/ncurses/tinfo/lib_kernel.c
ncurses-5.7/ncurses/tinfo/lib_kernel.c
+--- ncurses-5.7.orig/ncurses/tinfo/lib_kernel.c 2009-04-28
17:39:41.467853660 +0200
++++ ncurses-5.7/ncurses/tinfo/lib_kernel.c 2009-04-28 17:39:50.968287551
+0200
+@@ -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
+diff -ru ncurses-5.7.orig/ncurses/tty/lib_twait.c
ncurses-5.7/ncurses/tty/lib_twait.c
+--- ncurses-5.7.orig/ncurses/tty/lib_twait.c 2009-04-28 17:39:41.475852203
+0200
++++ ncurses-5.7/ncurses/tty/lib_twait.c 2009-04-28 17:39:50.968287551 +0200
+@@ -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
+diff -ru ncurses-5.7.orig/ncurses/tty/tty_update.c
ncurses-5.7/ncurses/tty/tty_update.c
+--- ncurses-5.7.orig/ncurses/tty/tty_update.c 2009-04-28 17:39:41.475852203
+0200
++++ ncurses-5.7/ncurses/tty/tty_update.c 2009-04-28 17:39:50.971849134
+0200
+@@ -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>
+
# HG changeset patch
# User Ferenc Wagner <wferi@xxxxxxx>
# 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
Signed-off-by: Ferenc Wagner <wferi@xxxxxxx>
diff -r 1d65cd8ddb59 -r a17dfe7bd0be stubdom/c/main.c
--- a/stubdom/c/main.c Wed May 13 15:14:43 2009 +0200
+++ b/stubdom/c/main.c Wed May 13 15:24:58 2009 +0200
@@ -1,8 +1,84 @@
#include <stdio.h>
#include <unistd.h>
+#include <stdlib.h>
+
+#include <time.h>
+#include <ncurses/curses.h>
+
+long
+fpathconf (int fd, int name)
+{
+ return 0;
+}
+
+int current_getch;
+int doloop = 1;
+static WINDOW *mainwnd;
+static WINDOW *screen;
+WINDOW *my_win;
+
+int now_sec, now_min, now_hour, now_day, now_wday, now_month, now_year;
+time_t now;
+struct tm *now_tm;
+
+void screen_init(void) {
+ mainwnd = initscr();
+ noecho();
+ cbreak();
+ nodelay(mainwnd, TRUE);
+ refresh(); // 1)
+ wrefresh(mainwnd);
+ screen = newwin(13, 27, 1, 1);
+ box(screen, ACS_VLINE, ACS_HLINE);
+}
+
+static void update_display(void) {
+ curs_set(0);
+ mvwprintw(screen,1,1,"-------- HEADER --------");
+ mvwprintw(screen,3,6,"TIME: %d:%d:%d", now_hour, now_min, now_sec);
+ mvwprintw(screen,5,6,"DATE: %d-%d-%d", now_day, now_month, now_year);
+ mvwprintw(screen,7,6,"PRESS q TO END");
+ mvwprintw(screen,10,1,"-------- FOOTER --------");
+ wrefresh(screen);
+ refresh();
+}
+
+void screen_end(void) {
+ endwin();
+}
+
+void maketime(void) {
+ // Get the current date/time
+ now = time (NULL);
+ now_tm = localtime (&now);
+ now_sec = now_tm->tm_sec;
+ now_min = now_tm->tm_min;
+ now_hour = now_tm->tm_hour;
+ now_day = now_tm->tm_mday;
+ now_wday = now_tm->tm_wday;
+ now_month = now_tm->tm_mon + 1;
+ now_year = now_tm->tm_year + 1900;
+}
int main(void) {
sleep(2);
- printf("Hello, world!\n");
+ printf("Hello, ncurses world!!\n");
+ sleep(2);
+
+ setenv("TERM","xterm",1);
+
+ screen_init();
+ while (doloop) {
+ current_getch = getch();
+ if (current_getch == 113) {
+ doloop = 0;
+ }
+ maketime();
+ update_display();
+ sleep(1);
+ }
+ screen_end();
+ printf("TEST ENDS\n");
+
return 0;
}
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|