aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
authorJes Sorensen <jes@sgi.com>2007-10-21 21:03:31 -0400
committerRusty Russell <rusty@rustcorp.com.au>2007-10-23 01:49:52 -0400
commit511801dc31c095b2bfe3bf5c6a370dbe9b042a70 (patch)
treefcd0f1111e503f33e39660d3aba55ff5b64ebf56 /Documentation
parentb410e7b1499c49513cab18275db8a8ab549d9e09 (diff)
Change example launcher to use unsigned long not u32
Apply Clue 2x4 to lguest userland<->kernel handling code and the lguest launcher. Pointers are not to be passed in u32's! Basic rule of thumb: Anything passing u32's back and forth should be passing unsigned longs to be portable to 64 bit archs. For those who forgotten already, I repeat: NO POINTERS IN u32! Signed-off-by: Jes Sorensen <jes@sgi.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/lguest/lguest.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/Documentation/lguest/lguest.c b/Documentation/lguest/lguest.c
index 140bd98a8417..4950b03514e6 100644
--- a/Documentation/lguest/lguest.c
+++ b/Documentation/lguest/lguest.c
@@ -473,9 +473,9 @@ static unsigned long setup_pagetables(unsigned long mem,
473 unsigned long initrd_size, 473 unsigned long initrd_size,
474 unsigned long page_offset) 474 unsigned long page_offset)
475{ 475{
476 u32 *pgdir, *linear; 476 unsigned long *pgdir, *linear;
477 unsigned int mapped_pages, i, linear_pages; 477 unsigned int mapped_pages, i, linear_pages;
478 unsigned int ptes_per_page = getpagesize()/sizeof(u32); 478 unsigned int ptes_per_page = getpagesize()/sizeof(void *);
479 479
480 /* Ideally we map all physical memory starting at page_offset. 480 /* Ideally we map all physical memory starting at page_offset.
481 * However, if page_offset is 0xC0000000 we can only map 1G of physical 481 * However, if page_offset is 0xC0000000 we can only map 1G of physical
@@ -505,7 +505,7 @@ static unsigned long setup_pagetables(unsigned long mem,
505 * continue from there. */ 505 * continue from there. */
506 for (i = 0; i < mapped_pages; i += ptes_per_page) { 506 for (i = 0; i < mapped_pages; i += ptes_per_page) {
507 pgdir[(i + page_offset/getpagesize())/ptes_per_page] 507 pgdir[(i + page_offset/getpagesize())/ptes_per_page]
508 = ((to_guest_phys(linear) + i*sizeof(u32)) 508 = ((to_guest_phys(linear) + i*sizeof(void *))
509 | PAGE_PRESENT); 509 | PAGE_PRESENT);
510 } 510 }
511 511
@@ -537,12 +537,13 @@ static void concat(char *dst, char *args[])
537 * the base of guest "physical" memory, the top physical page to allow, the 537 * the base of guest "physical" memory, the top physical page to allow, the
538 * top level pagetable, the entry point and the page_offset constant for the 538 * top level pagetable, the entry point and the page_offset constant for the
539 * Guest. */ 539 * Guest. */
540static int tell_kernel(u32 pgdir, u32 start, u32 page_offset) 540static int tell_kernel(unsigned long pgdir, unsigned long start,
541 unsigned long page_offset)
541{ 542{
542 u32 args[] = { LHREQ_INITIALIZE, 543 unsigned long args[] = { LHREQ_INITIALIZE,
543 (unsigned long)guest_base, 544 (unsigned long)guest_base,
544 guest_limit / getpagesize(), 545 guest_limit / getpagesize(),
545 pgdir, start, page_offset }; 546 pgdir, start, page_offset };
546 int fd; 547 int fd;
547 548
548 verbose("Guest: %p - %p (%#lx)\n", 549 verbose("Guest: %p - %p (%#lx)\n",
@@ -586,7 +587,7 @@ static void wake_parent(int pipefd, int lguest_fd, struct device_list *devices)
586 587
587 for (;;) { 588 for (;;) {
588 fd_set rfds = devices->infds; 589 fd_set rfds = devices->infds;
589 u32 args[] = { LHREQ_BREAK, 1 }; 590 unsigned long args[] = { LHREQ_BREAK, 1 };
590 591
591 /* Wait until input is ready from one of the devices. */ 592 /* Wait until input is ready from one of the devices. */
592 select(devices->max_infd+1, &rfds, NULL, NULL, NULL); 593 select(devices->max_infd+1, &rfds, NULL, NULL, NULL);
@@ -684,7 +685,7 @@ static u32 *dma2iov(unsigned long dma, struct iovec iov[], unsigned *num)
684static u32 *get_dma_buffer(int fd, void *key, 685static u32 *get_dma_buffer(int fd, void *key,
685 struct iovec iov[], unsigned int *num, u32 *irq) 686 struct iovec iov[], unsigned int *num, u32 *irq)
686{ 687{
687 u32 buf[] = { LHREQ_GETDMA, to_guest_phys(key) }; 688 unsigned long buf[] = { LHREQ_GETDMA, to_guest_phys(key) };
688 unsigned long udma; 689 unsigned long udma;
689 u32 *res; 690 u32 *res;
690 691
@@ -705,7 +706,7 @@ static u32 *get_dma_buffer(int fd, void *key,
705/* This is a convenient routine to send the Guest an interrupt. */ 706/* This is a convenient routine to send the Guest an interrupt. */
706static void trigger_irq(int fd, u32 irq) 707static void trigger_irq(int fd, u32 irq)
707{ 708{
708 u32 buf[] = { LHREQ_IRQ, irq }; 709 unsigned long buf[] = { LHREQ_IRQ, irq };
709 if (write(fd, buf, sizeof(buf)) != 0) 710 if (write(fd, buf, sizeof(buf)) != 0)
710 err(1, "Triggering irq %i", irq); 711 err(1, "Triggering irq %i", irq);
711} 712}
@@ -787,7 +788,7 @@ static bool handle_console_input(int fd, struct device *dev)
787 struct timeval now; 788 struct timeval now;
788 gettimeofday(&now, NULL); 789 gettimeofday(&now, NULL);
789 if (now.tv_sec <= abort->start.tv_sec+1) { 790 if (now.tv_sec <= abort->start.tv_sec+1) {
790 u32 args[] = { LHREQ_BREAK, 0 }; 791 unsigned long args[] = { LHREQ_BREAK, 0 };
791 /* Close the fd so Waker will know it has to 792 /* Close the fd so Waker will know it has to
792 * exit. */ 793 * exit. */
793 close(waker_fd); 794 close(waker_fd);
@@ -1365,7 +1366,7 @@ static void __attribute__((noreturn))
1365run_guest(int lguest_fd, struct device_list *device_list) 1366run_guest(int lguest_fd, struct device_list *device_list)
1366{ 1367{
1367 for (;;) { 1368 for (;;) {
1368 u32 args[] = { LHREQ_BREAK, 0 }; 1369 unsigned long args[] = { LHREQ_BREAK, 0 };
1369 unsigned long arr[2]; 1370 unsigned long arr[2];
1370 int readval; 1371 int readval;
1371 1372