Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 62782
b: refs/heads/master
c: b2e961e
h: refs/heads/master
v: v3
  • Loading branch information
Linus Torvalds committed Jul 24, 2007
1 parent f069d33 commit 7c22513
Show file tree
Hide file tree
Showing 27 changed files with 128 additions and 141 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 71f65e6bd7651610d2d6aeb3c12aab63667ace30
refs/heads/master: b2e961eb2e7a54ffaae82f8e0198b26b54ade98e
4 changes: 2 additions & 2 deletions trunk/Documentation/gpio.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pin ... that won't always match the specified output value, because of
issues including wire-OR and output latencies.

The get/set calls have no error returns because "invalid GPIO" should have
been reported earlier in gpio_set_direction(). However, note that not all
been reported earlier from gpio_direction_*(). However, note that not all
platforms can read the value of output pins; those that can't should always
return zero. Also, using these calls for GPIOs that can't safely be accessed
without sleeping (see below) is an error.
Expand Down Expand Up @@ -239,7 +239,7 @@ map between them using calls like:
Those return either the corresponding number in the other namespace, or
else a negative errno code if the mapping can't be done. (For example,
some GPIOs can't used as IRQs.) It is an unchecked error to use a GPIO
number that hasn't been marked as an input using gpio_set_direction(), or
number that wasn't set up as an input using gpio_direction_input(), or
to use an IRQ number that didn't originally come from gpio_to_irq().

These two mapping calls are expected to cost on the order of a single
Expand Down
3 changes: 1 addition & 2 deletions trunk/Documentation/lguest/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ endif
include $(KBUILD_OUTPUT)/.config
LGUEST_GUEST_TOP := ($(CONFIG_PAGE_OFFSET) - 0x08000000)

CFLAGS:=-Wall -Wmissing-declarations -Wmissing-prototypes -O3 \
-static -DLGUEST_GUEST_TOP="$(LGUEST_GUEST_TOP)" -Wl,-T,lguest.lds
CFLAGS:=-Wall -Wmissing-declarations -Wmissing-prototypes -O3 -Wl,-T,lguest.lds
LDLIBS:=-lz

all: lguest.lds lguest
Expand Down
84 changes: 34 additions & 50 deletions trunk/Documentation/lguest/lguest.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ static bool verbose;
#define verbose(args...) \
do { if (verbose) printf(args); } while(0)
static int waker_fd;
static u32 top;

struct device_list
{
fd_set infds;
int max_infd;

struct lguest_device_desc *descs;
struct device *dev;
struct device **lastdev;
};
Expand Down Expand Up @@ -324,8 +326,7 @@ static void concat(char *dst, char *args[])
static int tell_kernel(u32 pgdir, u32 start, u32 page_offset)
{
u32 args[] = { LHREQ_INITIALIZE,
LGUEST_GUEST_TOP/getpagesize(), /* Just below us */
pgdir, start, page_offset };
top/getpagesize(), pgdir, start, page_offset };
int fd;

fd = open_or_die("/dev/lguest", O_RDWR);
Expand Down Expand Up @@ -382,7 +383,7 @@ static int setup_waker(int lguest_fd, struct device_list *device_list)
static void *_check_pointer(unsigned long addr, unsigned int size,
unsigned int line)
{
if (addr >= LGUEST_GUEST_TOP || addr + size >= LGUEST_GUEST_TOP)
if (addr >= top || addr + size >= top)
errx(1, "%s:%i: Invalid address %li", __FILE__, line, addr);
return (void *)addr;
}
Expand Down Expand Up @@ -629,24 +630,26 @@ static void handle_input(int fd, struct device_list *devices)
}
}

static struct lguest_device_desc *new_dev_desc(u16 type, u16 features,
u16 num_pages)
static struct lguest_device_desc *
new_dev_desc(struct lguest_device_desc *descs,
u16 type, u16 features, u16 num_pages)
{
static unsigned long top = LGUEST_GUEST_TOP;
struct lguest_device_desc *desc;
unsigned int i;

desc = malloc(sizeof(*desc));
desc->type = type;
desc->num_pages = num_pages;
desc->features = features;
desc->status = 0;
if (num_pages) {
top -= num_pages*getpagesize();
map_zeroed_pages(top, num_pages);
desc->pfn = top / getpagesize();
} else
desc->pfn = 0;
return desc;
for (i = 0; i < LGUEST_MAX_DEVICES; i++) {
if (!descs[i].type) {
descs[i].type = type;
descs[i].features = features;
descs[i].num_pages = num_pages;
if (num_pages) {
map_zeroed_pages(top, num_pages);
descs[i].pfn = top/getpagesize();
top += num_pages*getpagesize();
}
return &descs[i];
}
}
errx(1, "too many devices");
}

static struct device *new_device(struct device_list *devices,
Expand All @@ -669,7 +672,7 @@ static struct device *new_device(struct device_list *devices,
dev->fd = fd;
if (handle_input)
set_fd(dev->fd, devices);
dev->desc = new_dev_desc(type, features, num_pages);
dev->desc = new_dev_desc(devices->descs, type, features, num_pages);
dev->mem = (void *)(dev->desc->pfn * getpagesize());
dev->handle_input = handle_input;
dev->watch_key = (unsigned long)dev->mem + watch_off;
Expand Down Expand Up @@ -866,30 +869,6 @@ static void setup_tun_net(const char *arg, struct device_list *devices)
verbose("attached to bridge: %s\n", br_name);
}

/* Now we know how much memory we have, we copy in device descriptors */
static void map_device_descriptors(struct device_list *devs, unsigned long mem)
{
struct device *i;
unsigned int num;
struct lguest_device_desc *descs;

/* Device descriptor array sits just above top of normal memory */
descs = map_zeroed_pages(mem, 1);

for (i = devs->dev, num = 0; i; i = i->next, num++) {
if (num == LGUEST_MAX_DEVICES)
errx(1, "too many devices");
verbose("Device %i: %s\n", num,
i->desc->type == LGUEST_DEVICE_T_NET ? "net"
: i->desc->type == LGUEST_DEVICE_T_CONSOLE ? "console"
: i->desc->type == LGUEST_DEVICE_T_BLOCK ? "block"
: "unknown");
descs[num] = *i->desc;
free(i->desc);
i->desc = &descs[num];
}
}

static void __attribute__((noreturn))
run_guest(int lguest_fd, struct device_list *device_list)
{
Expand Down Expand Up @@ -934,8 +913,8 @@ static void usage(void)

int main(int argc, char *argv[])
{
unsigned long mem, pgdir, start, page_offset, initrd_size = 0;
int c, lguest_fd;
unsigned long mem = 0, pgdir, start, page_offset, initrd_size = 0;
int i, c, lguest_fd;
struct device_list device_list;
void *boot = (void *)0;
const char *initrd_name = NULL;
Expand All @@ -945,6 +924,15 @@ int main(int argc, char *argv[])
device_list.lastdev = &device_list.dev;
FD_ZERO(&device_list.infds);

/* We need to know how much memory so we can allocate devices. */
for (i = 1; i < argc; i++) {
if (argv[i][0] != '-') {
mem = top = atoi(argv[i]) * 1024 * 1024;
device_list.descs = map_zeroed_pages(top, 1);
top += getpagesize();
break;
}
}
while ((c = getopt_long(argc, argv, "v", opts, NULL)) != EOF) {
switch (c) {
case 'v':
Expand Down Expand Up @@ -974,16 +962,12 @@ int main(int argc, char *argv[])
setup_console(&device_list);

/* First we map /dev/zero over all of guest-physical memory. */
mem = atoi(argv[optind]) * 1024 * 1024;
map_zeroed_pages(0, mem / getpagesize());

/* Now we load the kernel */
start = load_kernel(open_or_die(argv[optind+1], O_RDONLY),
&page_offset);

/* Write the device descriptors into memory. */
map_device_descriptors(&device_list, mem);

/* Map the initrd image if requested */
if (initrd_name) {
initrd_size = load_initrd(initrd_name, mem);
Expand Down
5 changes: 1 addition & 4 deletions trunk/arch/powerpc/platforms/cell/spufs/spufs.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,10 @@ enum {
struct spu_context_ops;
struct spu_gang;

enum {
SPU_SCHED_WAS_ACTIVE, /* was active upon spu_acquire_saved() */
};

/* ctx->sched_flags */
enum {
SPU_SCHED_NOTIFY_ACTIVE,
SPU_SCHED_WAS_ACTIVE, /* was active upon spu_acquire_saved() */
};

struct spu_context {
Expand Down
4 changes: 2 additions & 2 deletions trunk/arch/um/drivers/mconsole_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ static struct mc_device mem_mc = {
.remove = mem_remove,
};

static int mem_mc_init(void)
static int __init mem_mc_init(void)
{
if(can_drop_memory())
mconsole_register_dev(&mem_mc);
Expand Down Expand Up @@ -798,7 +798,7 @@ void mconsole_stack(struct mc_request *req)
*/
static char *notify_socket = NULL;

static int mconsole_init(void)
static int __init mconsole_init(void)
{
/* long to avoid size mismatch warnings from gcc */
long sock;
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/um/drivers/net_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ static int eth_setup_common(char *str, int index)
return found;
}

static int eth_setup(char *str)
static int __init eth_setup(char *str)
{
struct eth_init *new;
char *error;
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/um/kernel/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static void setup_highmem(unsigned long highmem_start,
}
#endif

void mem_init(void)
void __init mem_init(void)
{
/* clear the zero-page */
memset((void *) empty_zero_page, 0, PAGE_SIZE);
Expand Down
15 changes: 5 additions & 10 deletions trunk/arch/um/kernel/physmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ unsigned long high_physmem;

extern unsigned long long physmem_size;

int init_maps(unsigned long physmem, unsigned long iomem, unsigned long highmem)
int __init init_maps(unsigned long physmem, unsigned long iomem,
unsigned long highmem)
{
struct page *p, *map;
unsigned long phys_len, phys_pages, highmem_len, highmem_pages;
Expand All @@ -47,13 +48,7 @@ int init_maps(unsigned long physmem, unsigned long iomem, unsigned long highmem)
total_pages = phys_pages + iomem_pages + highmem_pages;
total_len = phys_len + iomem_len + highmem_len;

if(kmalloc_ok){
map = kmalloc(total_len, GFP_KERNEL);
if(map == NULL)
map = vmalloc(total_len);
}
else map = alloc_bootmem_low_pages(total_len);

map = alloc_bootmem_low_pages(total_len);
if(map == NULL)
return -ENOMEM;

Expand Down Expand Up @@ -98,8 +93,8 @@ void map_memory(unsigned long virt, unsigned long phys, unsigned long len,

extern int __syscall_stub_start;

void setup_physmem(unsigned long start, unsigned long reserve_end,
unsigned long len, unsigned long long highmem)
void __init setup_physmem(unsigned long start, unsigned long reserve_end,
unsigned long len, unsigned long long highmem)
{
unsigned long reserve = reserve_end - start;
int pfn = PFN_UP(__pa(reserve_end));
Expand Down
4 changes: 2 additions & 2 deletions trunk/arch/um/kernel/skas/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void init_idle_skas(void)

extern void start_kernel(void);

static int start_kernel_proc(void *unused)
static int __init start_kernel_proc(void *unused)
{
int pid;

Expand All @@ -165,7 +165,7 @@ extern int userspace_pid[];

extern char cpu0_irqstack[];

int start_uml_skas(void)
int __init start_uml_skas(void)
{
stack_protections((unsigned long) &cpu0_irqstack);
set_sigstack(cpu0_irqstack, THREAD_SIZE);
Expand Down
47 changes: 17 additions & 30 deletions trunk/arch/um/os-Linux/aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "init.h"
#include "user.h"
#include "mode.h"
#include "kern_constants.h"

struct aio_thread_req {
enum aio_type type;
Expand Down Expand Up @@ -65,47 +66,33 @@ static long io_getevents(aio_context_t ctx_id, long min_nr, long nr,
static int do_aio(aio_context_t ctx, enum aio_type type, int fd, char *buf,
int len, unsigned long long offset, struct aio_context *aio)
{
struct iocb iocb, *iocbp = &iocb;
struct iocb *iocbp = & ((struct iocb) {
.aio_data = (unsigned long) aio,
.aio_fildes = fd,
.aio_buf = (unsigned long) buf,
.aio_nbytes = len,
.aio_offset = offset
});
char c;
int err;

iocb = ((struct iocb) { .aio_data = (unsigned long) aio,
.aio_reqprio = 0,
.aio_fildes = fd,
.aio_buf = (unsigned long) buf,
.aio_nbytes = len,
.aio_offset = offset,
.aio_reserved1 = 0,
.aio_reserved2 = 0,
.aio_reserved3 = 0 });

switch(type){
switch (type) {
case AIO_READ:
iocb.aio_lio_opcode = IOCB_CMD_PREAD;
err = io_submit(ctx, 1, &iocbp);
iocbp->aio_lio_opcode = IOCB_CMD_PREAD;
break;
case AIO_WRITE:
iocb.aio_lio_opcode = IOCB_CMD_PWRITE;
err = io_submit(ctx, 1, &iocbp);
iocbp->aio_lio_opcode = IOCB_CMD_PWRITE;
break;
case AIO_MMAP:
iocb.aio_lio_opcode = IOCB_CMD_PREAD;
iocb.aio_buf = (unsigned long) &c;
iocb.aio_nbytes = sizeof(c);
err = io_submit(ctx, 1, &iocbp);
iocbp->aio_lio_opcode = IOCB_CMD_PREAD;
iocbp->aio_buf = (unsigned long) &c;
iocbp->aio_nbytes = sizeof(c);
break;
default:
printk("Bogus op in do_aio - %d\n", type);
err = -EINVAL;
break;
printk(UM_KERN_ERR "Bogus op in do_aio - %d\n", type);
return -EINVAL;
}

if(err > 0)
err = 0;
else
err = -errno;

return err;
return (io_submit(ctx, 1, &iocbp) > 0) ? 0 : -errno;
}

/* Initialized in an initcall and unchanged thereafter */
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/um/os-Linux/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ int os_unmap_memory(void *addr, int len)
#define MADV_REMOVE KERNEL_MADV_REMOVE
#endif

int __init os_drop_memory(void *addr, int length)
int os_drop_memory(void *addr, int length)
{
int err;

Expand Down
5 changes: 1 addition & 4 deletions trunk/arch/um/os-Linux/user_syms.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ extern void *memmove(void *, const void *, size_t);
extern void *memset(void *, int, size_t);
extern int printf(const char *, ...);

/* If they're not defined, the export is included in lib/string.c.*/
#ifdef __HAVE_ARCH_STRLEN
EXPORT_SYMBOL(strlen);
#endif
/* If it's not defined, the export is included in lib/string.c.*/
#ifdef __HAVE_ARCH_STRSTR
EXPORT_SYMBOL(strstr);
#endif
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/um/sys-i386/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ obj-y = bug.o bugs.o checksum.o delay.o fault.o ksyms.o ldt.o ptrace.o \

obj-$(CONFIG_MODE_SKAS) += stub.o stub_segv.o

subarch-obj-y = lib/bitops.o lib/semaphore.o
subarch-obj-y = lib/bitops.o lib/semaphore.o lib/string.o
subarch-obj-$(CONFIG_HIGHMEM) += mm/highmem.o
subarch-obj-$(CONFIG_MODULES) += kernel/module.o

Expand Down
Loading

0 comments on commit 7c22513

Please sign in to comment.