* [PATCH 3/7] vtpm Mini-Os domain: mini-os defines
@ 2010-08-25 15:15 Matthew Fioravante
2010-08-25 15:39 ` Samuel Thibault
0 siblings, 1 reply; 3+ messages in thread
From: Matthew Fioravante @ 2010-08-25 15:15 UTC (permalink / raw)
To: xen-devel@lists.xensource.com
[-- Attachment #1.1.1: Type: text/plain, Size: 350 bytes --]
Signed-off-by: Matthew Fioravante <Matthew.Fioravante@jhuapl.edu>
This patch adds some #defines to mini-os
NO_BLKFRONT
NO_FSFRONT
NO_NETFRONT
NO_FBFRONT
NO_PCIFRONT
These disable their respective drivers if defined. The vtpm domain does
not need a framebuffer, network, fsfront, or pci so I added these to
disable unneeded drivers.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: 3-minios-defines.patch --]
[-- Type: text/x-patch; name="3-minios-defines.patch", Size: 14589 bytes --]
diff -r c84db039be86 -r 6615dd4045c7 extras/mini-os/blkfront.c
--- a/extras/mini-os/blkfront.c Tue Jul 20 15:42:37 2010 -0400
+++ b/extras/mini-os/blkfront.c Tue Jul 20 16:19:10 2010 -0400
@@ -1,3 +1,4 @@
+#ifndef NO_BLKFRONT
/* Minimal block driver for Mini-OS.
* Copyright (c) 2007-2008 Samuel Thibault.
* Based on netfront.c.
@@ -552,3 +553,4 @@
return dev->fd;
}
#endif
+#endif
diff -r c84db039be86 -r 6615dd4045c7 extras/mini-os/fbfront.c
--- a/extras/mini-os/fbfront.c Tue Jul 20 15:42:37 2010 -0400
+++ b/extras/mini-os/fbfront.c Tue Jul 20 16:19:10 2010 -0400
@@ -1,3 +1,4 @@
+#ifndef NO_FBFRONT
/*
* Frame Buffer + Keyboard driver for Mini-OS.
* Samuel Thibault <samuel.thibault@eu.citrix.com>, 2008
@@ -694,4 +695,4 @@
return dev->fd;
}
#endif
-
+#endif
diff -r c84db039be86 -r 6615dd4045c7 extras/mini-os/fs-front.c
--- a/extras/mini-os/fs-front.c Tue Jul 20 15:42:37 2010 -0400
+++ b/extras/mini-os/fs-front.c Tue Jul 20 16:19:10 2010 -0400
@@ -1,3 +1,4 @@
+#ifndef NO_FSFRONT
/******************************************************************************
* fs-front.c
*
@@ -1295,3 +1296,4 @@
}
/* TODO: shutdown */
+#endif
diff -r c84db039be86 -r 6615dd4045c7 extras/mini-os/kernel.c
--- a/extras/mini-os/kernel.c Tue Jul 20 15:42:37 2010 -0400
+++ b/extras/mini-os/kernel.c Tue Jul 20 16:19:10 2010 -0400
@@ -37,17 +37,27 @@
#include <mini-os/sched.h>
#include <mini-os/xenbus.h>
#include <mini-os/gnttab.h>
+#ifndef NO_NETFRONT
#include <mini-os/netfront.h>
+#endif
+#ifndef NO_BLKFRONT
#include <mini-os/blkfront.h>
+#endif
+#ifndef NO_FBFRONT
#include <mini-os/fbfront.h>
+#endif
+#ifndef NO_PCIFRONT
#include <mini-os/pcifront.h>
+#endif
#include <mini-os/fs.h>
#include <mini-os/xmalloc.h>
#include <fcntl.h>
#include <xen/features.h>
#include <xen/version.h>
+#ifndef NO_NETFRONT
static struct netfront_dev *net_dev;
+#endif
uint8_t xen_features[XENFEAT_NR_SUBMAPS * 32];
@@ -87,11 +97,14 @@
}
}
+#ifndef NO_NETFRONT
static void netfront_thread(void *p)
{
net_dev = init_netfront(NULL, NULL, NULL, NULL);
}
+#endif
+#ifndef NO_BLKFRONT
static struct blkfront_dev *blk_dev;
static struct blkfront_info blk_info;
static uint64_t blk_size_read;
@@ -256,7 +269,9 @@
#endif
}
}
+#endif
+#ifndef NO_FBFRONT
#define WIDTH 800
#define HEIGHT 600
#define DEPTH 32
@@ -432,7 +447,9 @@
schedule();
}
}
+#endif
+#ifndef NO_PCIFRONT
static struct pcifront_dev *pci_dev;
static void print_pcidev(unsigned int domain, unsigned int bus, unsigned int slot, unsigned int fun)
@@ -455,11 +472,14 @@
printk("PCI devices:\n");
pcifront_scan(pci_dev, print_pcidev);
}
+#endif
+#ifndef NO_FSFRONT
static void fs_thread(void *p)
{
init_fs_frontend();
}
+#endif
/* This should be overridden by the application we are linked against. */
__attribute__((weak)) int app_main(start_info_t *si)
@@ -467,12 +487,22 @@
printk("Dummy main: start_info=%p\n", si);
create_thread("xenbus_tester", xenbus_tester, si);
create_thread("periodic_thread", periodic_thread, si);
+#ifndef NO_NETFRONT
create_thread("netfront", netfront_thread, si);
+#endif
+#ifndef NO_BLKFRONT
create_thread("blkfront", blkfront_thread, si);
+#endif
+#ifndef NO_FBFRONT
create_thread("fbfront", fbfront_thread, si);
create_thread("kbdfront", kbdfront_thread, si);
+#endif
+#ifndef NO_PCIFRONT
create_thread("pcifront", pcifront_thread, si);
+#endif
+#ifndef NO_FSFRONT
create_thread("fs-frontend", fs_thread, si);
+#endif
return 0;
}
@@ -540,22 +570,32 @@
void stop_kernel(void)
{
+#ifndef NO_NETFRONT
if (net_dev)
shutdown_netfront(net_dev);
+#endif
+#ifndef NO_BLKFRONT
if (blk_dev)
shutdown_blkfront(blk_dev);
+#endif
+#ifndef NO_FBFRONT
if (fb_dev)
shutdown_fbfront(fb_dev);
if (kbd_dev)
shutdown_kbdfront(kbd_dev);
+#endif
+#ifndef NO_PCIFRONT
if (pci_dev)
shutdown_pcifront(pci_dev);
+#endif
+#ifndef NO_FSFRONT
/* TODO: fs import */
+#endif
local_irq_disable();
diff -r c84db039be86 -r 6615dd4045c7 extras/mini-os/lib/sys.c
--- a/extras/mini-os/lib/sys.c Tue Jul 20 15:42:37 2010 -0400
+++ b/extras/mini-os/lib/sys.c Tue Jul 20 16:19:10 2010 -0400
@@ -24,9 +24,15 @@
#include <sched.h>
#include <events.h>
#include <wait.h>
+#ifndef NO_NETFRONT
#include <netfront.h>
+#endif
+#ifndef NO_BLKFRONT
#include <blkfront.h>
+#endif
+#ifndef NO_FBFRONT
#include <fbfront.h>
+#endif
#include <xenbus.h>
#include <xs.h>
@@ -83,10 +89,12 @@
}
#define NOFILE 32
+#ifndef NO_LIBXC
extern int xc_evtchn_close(int fd);
struct xc_interface;
extern int xc_interface_close_core(struct xc_interface*, int fd);
extern int xc_gnttab_close(int fd);
+#endif
pthread_mutex_t fd_lock = PTHREAD_MUTEX_INITIALIZER;
struct file files[NOFILE] = {
@@ -159,6 +167,7 @@
int mkdir(const char *pathname, mode_t mode)
{
+#ifndef NO_FSFRONT
int ret;
ret = fs_create(fs_import, (char *) pathname, 1, mode);
if (ret < 0) {
@@ -166,6 +175,10 @@
return -1;
}
return 0;
+#else
+ errno = ENOSYS;
+ return -1;
+#endif
}
int posix_openpt(int flags)
@@ -198,6 +211,7 @@
}
if (!strncmp(pathname, "/dev/ptmx", strlen("/dev/ptmx")))
return posix_openpt(flags);
+#ifndef NO_FSFRONT
printk("open(%s, %x)", pathname, flags);
switch (flags & ~O_ACCMODE) {
case 0:
@@ -226,6 +240,10 @@
files[fd].file.fd = fs_fd;
files[fd].file.offset = 0;
return fd;
+#else
+ errno = EIO;
+ return -1;
+#endif
}
int isatty(int fd)
@@ -249,6 +267,7 @@
remove_waiter(w);
return ret;
}
+#ifndef NO_FSFRONT
case FTYPE_FILE: {
ssize_t ret;
if (nbytes > PAGE_SIZE * FSIF_NR_READ_GNTS)
@@ -263,10 +282,12 @@
}
return 0;
}
+#endif
#ifdef HAVE_LWIP
case FTYPE_SOCKET:
return lwip_read(files[fd].socket.fd, buf, nbytes);
#endif
+#ifndef NO_NETFRONT
case FTYPE_TAP: {
ssize_t ret;
ret = netfront_receive(files[fd].tap.dev, buf, nbytes);
@@ -276,6 +297,8 @@
}
return ret;
}
+#endif
+#ifndef NO_FBFRONT
case FTYPE_KBD: {
int ret, n;
n = nbytes / sizeof(union xenkbd_in_event);
@@ -296,6 +319,7 @@
}
return ret * sizeof(union xenfb_in_event);
}
+#endif
default:
break;
}
@@ -310,6 +334,7 @@
case FTYPE_CONSOLE:
console_print(files[fd].cons.dev, (char *)buf, nbytes);
return nbytes;
+#ifndef NO_FSFRONT
case FTYPE_FILE: {
ssize_t ret;
if (nbytes > PAGE_SIZE * FSIF_NR_WRITE_GNTS)
@@ -324,13 +349,16 @@
}
return 0;
}
+#endif
#ifdef HAVE_LWIP
case FTYPE_SOCKET:
return lwip_write(files[fd].socket.fd, (void*) buf, nbytes);
#endif
+#ifndef NO_NETFRONT
case FTYPE_TAP:
netfront_xmit(files[fd].tap.dev, (void*) buf, nbytes);
return nbytes;
+#endif
default:
break;
}
@@ -370,6 +398,7 @@
int fsync(int fd) {
switch (files[fd].type) {
+#ifndef NO_FSFRONT
case FTYPE_FILE: {
int ret;
ret = fs_sync(fs_import, files[fd].file.fd);
@@ -379,6 +408,7 @@
}
return 0;
}
+#endif
default:
break;
}
@@ -394,6 +424,7 @@
default:
files[fd].type = FTYPE_NONE;
return 0;
+#ifndef NO_FSFRONT
case FTYPE_FILE: {
int ret = fs_close(fs_import, files[fd].file.fd);
files[fd].type = FTYPE_NONE;
@@ -403,6 +434,7 @@
}
return 0;
}
+#endif
case FTYPE_XENBUS:
xs_daemon_close((void*)(intptr_t) fd);
return 0;
@@ -413,6 +445,7 @@
return res;
}
#endif
+#ifndef NO_LIBXC
case FTYPE_XC:
xc_interface_close_core(0,fd);
return 0;
@@ -422,14 +455,20 @@
case FTYPE_GNTMAP:
xc_gnttab_close(fd);
return 0;
+#endif
+#ifndef NO_NETFRONT
case FTYPE_TAP:
shutdown_netfront(files[fd].tap.dev);
files[fd].type = FTYPE_NONE;
return 0;
+#endif
+#ifndef NO_BLKFRONT
case FTYPE_BLK:
shutdown_blkfront(files[fd].blk.dev);
files[fd].type = FTYPE_NONE;
return 0;
+#endif
+#ifndef NO_FBFRONT
case FTYPE_KBD:
shutdown_kbdfront(files[fd].kbd.dev);
files[fd].type = FTYPE_NONE;
@@ -442,6 +481,7 @@
fini_console(files[fd].cons.dev);
files[fd].type = FTYPE_NONE;
return 0;
+#endif
case FTYPE_NONE:
break;
}
@@ -461,6 +501,7 @@
buf->st_blocks = 0;
}
+#ifndef NO_FSFRONT
static void stat_from_fs(struct stat *buf, struct fsif_stat_response *stat)
{
buf->st_mode = stat->stat_mode;
@@ -471,9 +512,11 @@
buf->st_mtime = stat->stat_mtime;
buf->st_ctime = stat->stat_ctime;
}
+#endif
int stat(const char *path, struct stat *buf)
{
+#ifndef NO_FSFRONT
struct fsif_stat_response stat;
int ret;
int fs_fd;
@@ -498,6 +541,10 @@
fs_close(fs_import, fs_fd);
out:
return ret;
+#else
+ errno = ENOSYS;
+ return -1;
+#endif
}
int fstat(int fd, struct stat *buf)
@@ -515,6 +562,7 @@
buf->st_ctime = time(NULL);
return 0;
}
+#ifndef NO_FSFRONT
case FTYPE_FILE: {
struct fsif_stat_response stat;
int ret;
@@ -527,6 +575,7 @@
stat_from_fs(buf, &stat);
return 0;
}
+#endif
default:
break;
}
@@ -539,6 +588,7 @@
int ftruncate(int fd, off_t length)
{
switch (files[fd].type) {
+#ifndef NO_FSFRONT
case FTYPE_FILE: {
int ret;
ret = fs_truncate(fs_import, files[fd].file.fd, length);
@@ -548,6 +598,7 @@
}
return 0;
}
+#endif
default:
break;
}
@@ -559,6 +610,7 @@
int remove(const char *pathname)
{
+#ifndef NO_FSFRONT
int ret;
printk("remove(%s)", pathname);
ret = fs_remove(fs_import, (char*) pathname);
@@ -567,6 +619,10 @@
return -1;
}
return 0;
+#else
+ errno = ENOSYS;
+ return -1;
+#endif
}
int unlink(const char *pathname)
@@ -606,6 +662,7 @@
DIR *opendir(const char *name)
{
+#ifndef NO_FSFRONT
DIR *ret;
ret = malloc(sizeof(*ret));
ret->name = strdup(name);
@@ -615,10 +672,15 @@
ret->nbentries = 0;
ret->has_more = 1;
return ret;
+#else
+ errno = ENOSYS;
+ return NULL;
+#endif
}
struct dirent *readdir(DIR *dir)
{
+#ifndef NO_FSFRONT
if (dir->curentry >= 0) {
free(dir->entries[dir->curentry]);
dir->entries[dir->curentry] = NULL;
@@ -638,6 +700,10 @@
}
dir->dirent.d_name = dir->entries[dir->curentry];
return &dir->dirent;
+#else
+ errno = ENOSYS;
+ return NULL;
+#endif
}
int closedir(DIR *dir)
{
@@ -754,11 +820,13 @@
if (FD_ISSET(i, readfds) || FD_ISSET(i, writefds) || FD_ISSET(i, exceptfds))
printk("bogus fd %d in select\n", i);
/* Fallthrough. */
+#ifndef NO_FSFRONT
case FTYPE_FILE:
FD_CLR(i, readfds);
FD_CLR(i, writefds);
FD_CLR(i, exceptfds);
break;
+#endif
case FTYPE_CONSOLE:
if (FD_ISSET(i, readfds)) {
if (xencons_ring_avail(files[i].cons.dev))
@@ -886,11 +954,17 @@
/* Tell people we're going to sleep before looking at what they are
* saying, hence letting them wake us if events happen between here and
* schedule() */
+#ifndef NO_NETFRONT
add_waiter(w1, netfront_queue);
+#endif
add_waiter(w2, event_queue);
+#ifndef NO_BLKFRONT
add_waiter(w3, blkfront_queue);
+#endif
add_waiter(w4, xenbus_watch_queue);
+#ifndef NO_FBFRONT
add_waiter(w5, kbdfront_queue);
+#endif
add_waiter(w6, console_queue);
if (readfds)
diff -r c84db039be86 -r 6615dd4045c7 extras/mini-os/main.c
--- a/extras/mini-os/main.c Tue Jul 20 15:42:37 2010 -0400
+++ b/extras/mini-os/main.c Tue Jul 20 16:19:10 2010 -0400
@@ -66,8 +66,10 @@
#if defined(HAVE_LWIP) && !defined(CONFIG_QEMU)
start_networking();
#endif
+#ifndef NO_FSFRONT
init_fs_frontend();
#endif
+#endif
create_thread("pcifront", pcifront_watches, NULL);
#ifdef CONFIG_QEMU
diff -r c84db039be86 -r 6615dd4045c7 extras/mini-os/netfront.c
--- a/extras/mini-os/netfront.c Tue Jul 20 15:42:37 2010 -0400
+++ b/extras/mini-os/netfront.c Tue Jul 20 16:19:10 2010 -0400
@@ -1,3 +1,4 @@
+#ifndef NO_NETFRONT
/* Minimal network driver for Mini-OS.
* Copyright (c) 2006-2007 Jacob Gorm Hansen, University of Copenhagen.
* Based on netfront.c from Xen Linux.
@@ -672,3 +673,4 @@
return dev->rlen;
}
#endif
+#endif
diff -r c84db039be86 -r 6615dd4045c7 extras/mini-os/pcifront.c
--- a/extras/mini-os/pcifront.c Tue Jul 20 15:42:37 2010 -0400
+++ b/extras/mini-os/pcifront.c Tue Jul 20 16:19:10 2010 -0400
@@ -1,3 +1,4 @@
+#ifndef NO_PCIFRONT
/* Minimal PCI driver for Mini-OS.
* Copyright (c) 2007-2008 Samuel Thibault.
* Based on blkfront.c.
@@ -611,3 +612,4 @@
return op.err;
}
+#endif
diff -r 22a23fed2920 -r bb97efd3e952 extras/mini-os/lib/sys.c
--- a/extras/mini-os/lib/sys.c Tue Jul 20 16:38:40 2010 -0400
+++ b/extras/mini-os/lib/sys.c Tue Jul 20 17:08:50 2010 -0400
@@ -197,7 +197,10 @@
int open(const char *pathname, int flags, ...)
{
- int fs_fd, fd;
+#ifndef NO_FSFRONT
+ int fs_fd;
+#endif
+ int fd;
/* Ugly, but fine. */
if (!strncmp(pathname,LOG_PATH,strlen(LOG_PATH))) {
fd = alloc_fd(FTYPE_CONSOLE);
diff -r 22a23fed2920 -r bb97efd3e952 extras/mini-os/main.c
--- a/extras/mini-os/main.c Tue Jul 20 16:38:40 2010 -0400
+++ b/extras/mini-os/main.c Tue Jul 20 17:08:50 2010 -0400
@@ -8,8 +8,12 @@
#include <os.h>
#include <sched.h>
#include <console.h>
+#ifndef NO_NETFRONT
#include <netfront.h>
+#endif
+#ifndef NO_PCIFRONT
#include <pcifront.h>
+#endif
#include <time.h>
#include <stdlib.h>
#include <unistd.h>
@@ -70,7 +74,9 @@
init_fs_frontend();
#endif
#endif
+#ifndef NO_PCIFRONT
create_thread("pcifront", pcifront_watches, NULL);
+#endif
#ifdef CONFIG_QEMU
/* Fetch argc, argv from XenStore */
[-- Attachment #1.2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 2518 bytes --]
[-- Attachment #2: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 3/7] vtpm Mini-Os domain: mini-os defines
2010-08-25 15:15 [PATCH 3/7] vtpm Mini-Os domain: mini-os defines Matthew Fioravante
@ 2010-08-25 15:39 ` Samuel Thibault
2010-08-30 11:42 ` Stefano Stabellini
0 siblings, 1 reply; 3+ messages in thread
From: Samuel Thibault @ 2010-08-25 15:39 UTC (permalink / raw)
To: Matthew Fioravante; +Cc: xen-devel@lists.xensource.com
The principle is probably useful indeed.
Matthew Fioravante, le Wed 25 Aug 2010 11:15:04 -0400, a écrit :
> This patch adds some #defines to mini-os
> NO_BLKFRONT
I tend to frown upon "negative" flags, as they're less readable. I know
that using "positive" will require adding them to all other stubdom
projects, but it's probably still better that way: we'll realize for
instance that pv-grub doesn't actually need pcifront :)
samuel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 3/7] vtpm Mini-Os domain: mini-os defines
2010-08-25 15:39 ` Samuel Thibault
@ 2010-08-30 11:42 ` Stefano Stabellini
0 siblings, 0 replies; 3+ messages in thread
From: Stefano Stabellini @ 2010-08-30 11:42 UTC (permalink / raw)
To: Samuel Thibault; +Cc: Matthew Fioravante, xen-devel@lists.xensource.com
On Wed, 25 Aug 2010, Samuel Thibault wrote:
> The principle is probably useful indeed.
>
> Matthew Fioravante, le Wed 25 Aug 2010 11:15:04 -0400, a ??crit :
> > This patch adds some #defines to mini-os
> > NO_BLKFRONT
>
> I tend to frown upon "negative" flags, as they're less readable. I know
> that using "positive" will require adding them to all other stubdom
> projects, but it's probably still better that way: we'll realize for
> instance that pv-grub doesn't actually need pcifront :)
>
I agree, also all those ifdef's make the code difficult to read.
Wouldn't it be possible to enable/disable the compilation of those files
altogether and provide stubs for the export functions instead?
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-08-30 11:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-25 15:15 [PATCH 3/7] vtpm Mini-Os domain: mini-os defines Matthew Fioravante
2010-08-25 15:39 ` Samuel Thibault
2010-08-30 11:42 ` Stefano Stabellini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).