Compare commits
	
		
			75 Commits
		
	
	
		
			v1.6.2
			...
			baseline_f
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 23fe2b3f9e | ||
|  | a0dba644c1 | ||
|  | c165473269 | ||
|  | 3bf4dfdd11 | ||
|  | 1466cef32d | ||
|  | 9eda7d373e | ||
|  | 1ae2757c6c | ||
|  | 1e09955619 | ||
|  | 396f79f45e | ||
|  | 89b439f313 | ||
|  | 43a52ce657 | ||
|  | 3b6fb9cab2 | ||
|  | 5650f5f48b | ||
|  | 9223836745 | ||
|  | ee87e32f83 | ||
|  | 6b63ef4d0f | ||
|  | 4b38e989b4 | ||
|  | 04920fc0fa | ||
|  | 0851c9f75c | ||
|  | c0b4cc1f9f | ||
|  | ecfe10c9a6 | ||
|  | 9176e8fb8f | ||
|  | 72420ce9f0 | ||
|  | 237e4f92a8 | ||
|  | 230058106a | ||
|  | 66aae5e1ec | ||
|  | 6033e840c7 | ||
|  | 55d284af8e | ||
|  | 2452731c88 | ||
|  | 22d9e1a986 | ||
|  | b643e4b90b | ||
|  | e4a6540ded | ||
|  | fe9120a5d1 | ||
|  | bace999f8a | ||
|  | 4f071cf9b5 | ||
|  | 033ee5a5ac | ||
|  | 437f0f10a4 | ||
|  | fcef61ec6b | ||
|  | 2f69ba1736 | ||
|  | 99d228d6e9 | ||
|  | 9188dbf71a | ||
|  | ad666d91f4 | ||
|  | de3a658f5b | ||
|  | 7c1840b686 | ||
|  | 3f1beaca88 | ||
|  | f2e5dca46b | ||
|  | 1b9ecdb164 | ||
|  | bb52b14be1 | ||
|  | ce689368bb | ||
|  | f0d3576599 | ||
|  | d6d94c6785 | ||
|  | 5d289cc724 | ||
|  | bed2e759eb | ||
|  | 94473d0c06 | ||
|  | 70ecdc6e4e | ||
|  | 372835fbc3 | ||
|  | bc02fb304c | ||
|  | 0d1460226f | ||
|  | 164a101f28 | ||
|  | 35ecde2601 | ||
|  | 24d1a6d9d5 | ||
|  | bf0da4df83 | ||
|  | 88266f5aa7 | ||
|  | e1b5c52e04 | ||
|  | b83c4db895 | ||
|  | b114b68adf | ||
|  | a9ead83261 | ||
|  | ba96394e20 | ||
|  | 321bc0b2b2 | ||
|  | 92067bf4bf | ||
|  | 99a0b03650 | ||
|  | 8231c2dd22 | ||
|  | 747b0cb4b5 | ||
|  | 35143f0164 | ||
|  | f202039811 | 
							
								
								
									
										2
									
								
								.mailmap
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								.mailmap
									
									
									
									
									
								
							| @@ -2,7 +2,7 @@ | ||||
| # into proper addresses so that they are counted properly in git shortlog output. | ||||
| # | ||||
| Andrzej Zaborowski <balrogg@gmail.com> balrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162> | ||||
| Anthony Liguori <aliguori@us.ibm.com> aliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162> | ||||
| Anthony Liguori <anthony@codemonkey.ws> aliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162> | ||||
| Aurelien Jarno <aurelien@aurel32.net> aurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162> | ||||
| Blue Swirl <blauwirbel@gmail.com> blueswir1 <blueswir1@c046a42c-6fe2-441c-8c8c-71466251a162> | ||||
| Edgar E. Iglesias <edgar.iglesias@gmail.com> edgar_igl <edgar_igl@c046a42c-6fe2-441c-8c8c-71466251a162> | ||||
|   | ||||
							
								
								
									
										14
									
								
								MAINTAINERS
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								MAINTAINERS
									
									
									
									
									
								
							| @@ -50,7 +50,7 @@ Descriptions of section entries: | ||||
|  | ||||
| General Project Administration | ||||
| ------------------------------ | ||||
| M: Anthony Liguori <aliguori@us.ibm.com> | ||||
| M: Anthony Liguori <anthony@codemonkey.ws> | ||||
| M: Paul Brook <paul@codesourcery.com> | ||||
|  | ||||
| Guest CPU cores (TCG): | ||||
| @@ -509,7 +509,7 @@ F: hw/unicore32/ | ||||
| X86 Machines | ||||
| ------------ | ||||
| PC | ||||
| M: Anthony Liguori <aliguori@us.ibm.com> | ||||
| M: Anthony Liguori <anthony@codemonkey.ws> | ||||
| S: Supported | ||||
| F: hw/i386/pc.[ch] | ||||
| F: hw/i386/pc_piix.c | ||||
| @@ -593,7 +593,7 @@ S: Supported | ||||
| F: hw/*/*vhost* | ||||
|  | ||||
| virtio | ||||
| M: Anthony Liguori <aliguori@us.ibm.com> | ||||
| M: Anthony Liguori <anthony@codemonkey.ws> | ||||
| S: Supported | ||||
| F: hw/*/virtio* | ||||
|  | ||||
| @@ -651,7 +651,7 @@ F: block/ | ||||
| F: hw/block/ | ||||
|  | ||||
| Character Devices | ||||
| M: Anthony Liguori <aliguori@us.ibm.com> | ||||
| M: Anthony Liguori <anthony@codemonkey.ws> | ||||
| S: Maintained | ||||
| F: qemu-char.c | ||||
|  | ||||
| @@ -689,7 +689,7 @@ F: audio/spiceaudio.c | ||||
| F: hw/display/qxl* | ||||
|  | ||||
| Graphics | ||||
| M: Anthony Liguori <aliguori@us.ibm.com> | ||||
| M: Anthony Liguori <anthony@codemonkey.ws> | ||||
| S: Maintained | ||||
| F: ui/ | ||||
|  | ||||
| @@ -699,7 +699,7 @@ S: Odd Fixes | ||||
| F: ui/cocoa.m | ||||
|  | ||||
| Main loop | ||||
| M: Anthony Liguori <aliguori@us.ibm.com> | ||||
| M: Anthony Liguori <anthony@codemonkey.ws> | ||||
| S: Supported | ||||
| F: vl.c | ||||
|  | ||||
| @@ -711,7 +711,7 @@ F: hmp.c | ||||
| F: hmp-commands.hx | ||||
|  | ||||
| Network device layer | ||||
| M: Anthony Liguori <aliguori@us.ibm.com> | ||||
| M: Anthony Liguori <anthony@codemonkey.ws> | ||||
| M: Stefan Hajnoczi <stefanha@redhat.com> | ||||
| S: Maintained | ||||
| F: net/ | ||||
|   | ||||
							
								
								
									
										36
									
								
								aio-posix.c
									
									
									
									
									
								
							
							
						
						
									
										36
									
								
								aio-posix.c
									
									
									
									
									
								
							| @@ -23,7 +23,6 @@ struct AioHandler | ||||
|     GPollFD pfd; | ||||
|     IOHandler *io_read; | ||||
|     IOHandler *io_write; | ||||
|     AioFlushHandler *io_flush; | ||||
|     int deleted; | ||||
|     int pollfds_idx; | ||||
|     void *opaque; | ||||
| @@ -47,7 +46,6 @@ void aio_set_fd_handler(AioContext *ctx, | ||||
|                         int fd, | ||||
|                         IOHandler *io_read, | ||||
|                         IOHandler *io_write, | ||||
|                         AioFlushHandler *io_flush, | ||||
|                         void *opaque) | ||||
| { | ||||
|     AioHandler *node; | ||||
| @@ -84,7 +82,6 @@ void aio_set_fd_handler(AioContext *ctx, | ||||
|         /* Update handler with latest information */ | ||||
|         node->io_read = io_read; | ||||
|         node->io_write = io_write; | ||||
|         node->io_flush = io_flush; | ||||
|         node->opaque = opaque; | ||||
|         node->pollfds_idx = -1; | ||||
|  | ||||
| @@ -97,12 +94,10 @@ void aio_set_fd_handler(AioContext *ctx, | ||||
|  | ||||
| void aio_set_event_notifier(AioContext *ctx, | ||||
|                             EventNotifier *notifier, | ||||
|                             EventNotifierHandler *io_read, | ||||
|                             AioFlushEventNotifierHandler *io_flush) | ||||
|                             EventNotifierHandler *io_read) | ||||
| { | ||||
|     aio_set_fd_handler(ctx, event_notifier_get_fd(notifier), | ||||
|                        (IOHandler *)io_read, NULL, | ||||
|                        (AioFlushHandler *)io_flush, notifier); | ||||
|                        (IOHandler *)io_read, NULL, notifier); | ||||
| } | ||||
|  | ||||
| bool aio_pending(AioContext *ctx) | ||||
| @@ -147,7 +142,11 @@ static bool aio_dispatch(AioContext *ctx) | ||||
|             (revents & (G_IO_IN | G_IO_HUP | G_IO_ERR)) && | ||||
|             node->io_read) { | ||||
|             node->io_read(node->opaque); | ||||
|             progress = true; | ||||
|  | ||||
|             /* aio_notify() does not count as progress */ | ||||
|             if (node->opaque != &ctx->notifier) { | ||||
|                 progress = true; | ||||
|             } | ||||
|         } | ||||
|         if (!node->deleted && | ||||
|             (revents & (G_IO_OUT | G_IO_ERR)) && | ||||
| @@ -173,7 +172,7 @@ bool aio_poll(AioContext *ctx, bool blocking) | ||||
| { | ||||
|     AioHandler *node; | ||||
|     int ret; | ||||
|     bool busy, progress; | ||||
|     bool progress; | ||||
|  | ||||
|     progress = false; | ||||
|  | ||||
| @@ -200,20 +199,8 @@ bool aio_poll(AioContext *ctx, bool blocking) | ||||
|     g_array_set_size(ctx->pollfds, 0); | ||||
|  | ||||
|     /* fill pollfds */ | ||||
|     busy = false; | ||||
|     QLIST_FOREACH(node, &ctx->aio_handlers, node) { | ||||
|         node->pollfds_idx = -1; | ||||
|  | ||||
|         /* If there aren't pending AIO operations, don't invoke callbacks. | ||||
|          * Otherwise, if there are no AIO requests, qemu_aio_wait() would | ||||
|          * wait indefinitely. | ||||
|          */ | ||||
|         if (!node->deleted && node->io_flush) { | ||||
|             if (node->io_flush(node->opaque) == 0) { | ||||
|                 continue; | ||||
|             } | ||||
|             busy = true; | ||||
|         } | ||||
|         if (!node->deleted && node->pfd.events) { | ||||
|             GPollFD pfd = { | ||||
|                 .fd = node->pfd.fd, | ||||
| @@ -226,8 +213,8 @@ bool aio_poll(AioContext *ctx, bool blocking) | ||||
|  | ||||
|     ctx->walking_handlers--; | ||||
|  | ||||
|     /* No AIO operations?  Get us out of here */ | ||||
|     if (!busy) { | ||||
|     /* early return if we only have the aio_notify() fd */ | ||||
|     if (ctx->pollfds->len == 1) { | ||||
|         return progress; | ||||
|     } | ||||
|  | ||||
| @@ -250,6 +237,5 @@ bool aio_poll(AioContext *ctx, bool blocking) | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     assert(progress || busy); | ||||
|     return true; | ||||
|     return progress; | ||||
| } | ||||
|   | ||||
							
								
								
									
										37
									
								
								aio-win32.c
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								aio-win32.c
									
									
									
									
									
								
							| @@ -23,7 +23,6 @@ | ||||
| struct AioHandler { | ||||
|     EventNotifier *e; | ||||
|     EventNotifierHandler *io_notify; | ||||
|     AioFlushEventNotifierHandler *io_flush; | ||||
|     GPollFD pfd; | ||||
|     int deleted; | ||||
|     QLIST_ENTRY(AioHandler) node; | ||||
| @@ -31,8 +30,7 @@ struct AioHandler { | ||||
|  | ||||
| void aio_set_event_notifier(AioContext *ctx, | ||||
|                             EventNotifier *e, | ||||
|                             EventNotifierHandler *io_notify, | ||||
|                             AioFlushEventNotifierHandler *io_flush) | ||||
|                             EventNotifierHandler *io_notify) | ||||
| { | ||||
|     AioHandler *node; | ||||
|  | ||||
| @@ -73,7 +71,6 @@ void aio_set_event_notifier(AioContext *ctx, | ||||
|         } | ||||
|         /* Update handler with latest information */ | ||||
|         node->io_notify = io_notify; | ||||
|         node->io_flush = io_flush; | ||||
|     } | ||||
|  | ||||
|     aio_notify(ctx); | ||||
| @@ -96,7 +93,7 @@ bool aio_poll(AioContext *ctx, bool blocking) | ||||
| { | ||||
|     AioHandler *node; | ||||
|     HANDLE events[MAXIMUM_WAIT_OBJECTS + 1]; | ||||
|     bool busy, progress; | ||||
|     bool progress; | ||||
|     int count; | ||||
|  | ||||
|     progress = false; | ||||
| @@ -126,7 +123,11 @@ bool aio_poll(AioContext *ctx, bool blocking) | ||||
|         if (node->pfd.revents && node->io_notify) { | ||||
|             node->pfd.revents = 0; | ||||
|             node->io_notify(node->e); | ||||
|             progress = true; | ||||
|  | ||||
|             /* aio_notify() does not count as progress */ | ||||
|             if (node->opaque != &ctx->notifier) { | ||||
|                 progress = true; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         tmp = node; | ||||
| @@ -147,19 +148,8 @@ bool aio_poll(AioContext *ctx, bool blocking) | ||||
|     ctx->walking_handlers++; | ||||
|  | ||||
|     /* fill fd sets */ | ||||
|     busy = false; | ||||
|     count = 0; | ||||
|     QLIST_FOREACH(node, &ctx->aio_handlers, node) { | ||||
|         /* If there aren't pending AIO operations, don't invoke callbacks. | ||||
|          * Otherwise, if there are no AIO requests, qemu_aio_wait() would | ||||
|          * wait indefinitely. | ||||
|          */ | ||||
|         if (!node->deleted && node->io_flush) { | ||||
|             if (node->io_flush(node->e) == 0) { | ||||
|                 continue; | ||||
|             } | ||||
|             busy = true; | ||||
|         } | ||||
|         if (!node->deleted && node->io_notify) { | ||||
|             events[count++] = event_notifier_get_handle(node->e); | ||||
|         } | ||||
| @@ -167,8 +157,8 @@ bool aio_poll(AioContext *ctx, bool blocking) | ||||
|  | ||||
|     ctx->walking_handlers--; | ||||
|  | ||||
|     /* No AIO operations?  Get us out of here */ | ||||
|     if (!busy) { | ||||
|     /* early return if we only have the aio_notify() fd */ | ||||
|     if (count == 1) { | ||||
|         return progress; | ||||
|     } | ||||
|  | ||||
| @@ -196,7 +186,11 @@ bool aio_poll(AioContext *ctx, bool blocking) | ||||
|                 event_notifier_get_handle(node->e) == events[ret - WAIT_OBJECT_0] && | ||||
|                 node->io_notify) { | ||||
|                 node->io_notify(node->e); | ||||
|                 progress = true; | ||||
|  | ||||
|                 /* aio_notify() does not count as progress */ | ||||
|                 if (node->opaque != &ctx->notifier) { | ||||
|                     progress = true; | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             tmp = node; | ||||
| @@ -214,6 +208,5 @@ bool aio_poll(AioContext *ctx, bool blocking) | ||||
|         events[ret - WAIT_OBJECT_0] = events[--count]; | ||||
|     } | ||||
|  | ||||
|     assert(progress || busy); | ||||
|     return true; | ||||
|     return progress; | ||||
| } | ||||
|   | ||||
| @@ -342,7 +342,8 @@ ram_addr_t migration_bitmap_find_and_reset_dirty(MemoryRegion *mr, | ||||
| { | ||||
|     unsigned long base = mr->ram_addr >> TARGET_PAGE_BITS; | ||||
|     unsigned long nr = base + (start >> TARGET_PAGE_BITS); | ||||
|     unsigned long size = base + (int128_get64(mr->size) >> TARGET_PAGE_BITS); | ||||
|     uint64_t mr_size = TARGET_PAGE_ALIGN(memory_region_size(mr)); | ||||
|     unsigned long size = base + (mr_size >> TARGET_PAGE_BITS); | ||||
|  | ||||
|     unsigned long next; | ||||
|  | ||||
|   | ||||
							
								
								
									
										4
									
								
								async.c
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								async.c
									
									
									
									
									
								
							| @@ -201,7 +201,7 @@ aio_ctx_finalize(GSource     *source) | ||||
|     AioContext *ctx = (AioContext *) source; | ||||
|  | ||||
|     thread_pool_free(ctx->thread_pool); | ||||
|     aio_set_event_notifier(ctx, &ctx->notifier, NULL, NULL); | ||||
|     aio_set_event_notifier(ctx, &ctx->notifier, NULL); | ||||
|     event_notifier_cleanup(&ctx->notifier); | ||||
|     qemu_mutex_destroy(&ctx->bh_lock); | ||||
|     g_array_free(ctx->pollfds, TRUE); | ||||
| @@ -243,7 +243,7 @@ AioContext *aio_context_new(void) | ||||
|     event_notifier_init(&ctx->notifier, false); | ||||
|     aio_set_event_notifier(ctx, &ctx->notifier,  | ||||
|                            (EventNotifierHandler *) | ||||
|                            event_notifier_test_and_clear, NULL); | ||||
|                            event_notifier_test_and_clear); | ||||
|  | ||||
|     return ctx; | ||||
| } | ||||
|   | ||||
							
								
								
									
										49
									
								
								block.c
									
									
									
									
									
								
							
							
						
						
									
										49
									
								
								block.c
									
									
									
									
									
								
							| @@ -148,7 +148,6 @@ static void bdrv_block_timer(void *opaque) | ||||
|  | ||||
| void bdrv_io_limits_enable(BlockDriverState *bs) | ||||
| { | ||||
|     qemu_co_queue_init(&bs->throttled_reqs); | ||||
|     bs->block_timer = qemu_new_timer_ns(vm_clock, bdrv_block_timer, bs); | ||||
|     bs->io_limits_enabled = true; | ||||
| } | ||||
| @@ -306,6 +305,7 @@ BlockDriverState *bdrv_new(const char *device_name) | ||||
|     bdrv_iostatus_disable(bs); | ||||
|     notifier_list_init(&bs->close_notifiers); | ||||
|     notifier_with_return_list_init(&bs->before_write_notifiers); | ||||
|     qemu_co_queue_init(&bs->throttled_reqs); | ||||
|  | ||||
|     return bs; | ||||
| } | ||||
| @@ -1428,6 +1428,35 @@ void bdrv_close_all(void) | ||||
|     } | ||||
| } | ||||
|  | ||||
| /* Check if any requests are in-flight (including throttled requests) */ | ||||
| static bool bdrv_requests_pending(BlockDriverState *bs) | ||||
| { | ||||
|     if (!QLIST_EMPTY(&bs->tracked_requests)) { | ||||
|         return true; | ||||
|     } | ||||
|     if (!qemu_co_queue_empty(&bs->throttled_reqs)) { | ||||
|         return true; | ||||
|     } | ||||
|     if (bs->file && bdrv_requests_pending(bs->file)) { | ||||
|         return true; | ||||
|     } | ||||
|     if (bs->backing_hd && bdrv_requests_pending(bs->backing_hd)) { | ||||
|         return true; | ||||
|     } | ||||
|     return false; | ||||
| } | ||||
|  | ||||
| static bool bdrv_requests_pending_all(void) | ||||
| { | ||||
|     BlockDriverState *bs; | ||||
|     QTAILQ_FOREACH(bs, &bdrv_states, list) { | ||||
|         if (bdrv_requests_pending(bs)) { | ||||
|             return true; | ||||
|         } | ||||
|     } | ||||
|     return false; | ||||
| } | ||||
|  | ||||
| /* | ||||
|  * Wait for pending requests to complete across all BlockDriverStates | ||||
|  * | ||||
| @@ -1442,12 +1471,11 @@ void bdrv_close_all(void) | ||||
|  */ | ||||
| void bdrv_drain_all(void) | ||||
| { | ||||
|     /* Always run first iteration so any pending completion BHs run */ | ||||
|     bool busy = true; | ||||
|     BlockDriverState *bs; | ||||
|     bool busy; | ||||
|  | ||||
|     do { | ||||
|         busy = qemu_aio_wait(); | ||||
|  | ||||
|     while (busy) { | ||||
|         /* FIXME: We do not have timer support here, so this is effectively | ||||
|          * a busy wait. | ||||
|          */ | ||||
| @@ -1456,12 +1484,9 @@ void bdrv_drain_all(void) | ||||
|                 busy = true; | ||||
|             } | ||||
|         } | ||||
|     } while (busy); | ||||
|  | ||||
|     /* If requests are still pending there is a bug somewhere */ | ||||
|     QTAILQ_FOREACH(bs, &bdrv_states, list) { | ||||
|         assert(QLIST_EMPTY(&bs->tracked_requests)); | ||||
|         assert(qemu_co_queue_empty(&bs->throttled_reqs)); | ||||
|         busy = bdrv_requests_pending_all(); | ||||
|         busy |= aio_poll(qemu_get_aio_context(), busy); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @@ -1606,11 +1631,11 @@ void bdrv_delete(BlockDriverState *bs) | ||||
|     assert(!bs->job); | ||||
|     assert(!bs->in_use); | ||||
|  | ||||
|     bdrv_close(bs); | ||||
|  | ||||
|     /* remove from list, if necessary */ | ||||
|     bdrv_make_anon(bs); | ||||
|  | ||||
|     bdrv_close(bs); | ||||
|  | ||||
|     g_free(bs); | ||||
| } | ||||
|  | ||||
|   | ||||
							
								
								
									
										25
									
								
								block/curl.c
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								block/curl.c
									
									
									
									
									
								
							| @@ -86,7 +86,6 @@ typedef struct BDRVCURLState { | ||||
|  | ||||
| static void curl_clean_state(CURLState *s); | ||||
| static void curl_multi_do(void *arg); | ||||
| static int curl_aio_flush(void *opaque); | ||||
|  | ||||
| static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action, | ||||
|                         void *s, void *sp) | ||||
| @@ -94,17 +93,16 @@ static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action, | ||||
|     DPRINTF("CURL (AIO): Sock action %d on fd %d\n", action, fd); | ||||
|     switch (action) { | ||||
|         case CURL_POLL_IN: | ||||
|             qemu_aio_set_fd_handler(fd, curl_multi_do, NULL, curl_aio_flush, s); | ||||
|             qemu_aio_set_fd_handler(fd, curl_multi_do, NULL, s); | ||||
|             break; | ||||
|         case CURL_POLL_OUT: | ||||
|             qemu_aio_set_fd_handler(fd, NULL, curl_multi_do, curl_aio_flush, s); | ||||
|             qemu_aio_set_fd_handler(fd, NULL, curl_multi_do, s); | ||||
|             break; | ||||
|         case CURL_POLL_INOUT: | ||||
|             qemu_aio_set_fd_handler(fd, curl_multi_do, curl_multi_do, | ||||
|                                     curl_aio_flush, s); | ||||
|             qemu_aio_set_fd_handler(fd, curl_multi_do, curl_multi_do, s); | ||||
|             break; | ||||
|         case CURL_POLL_REMOVE: | ||||
|             qemu_aio_set_fd_handler(fd, NULL, NULL, NULL, NULL); | ||||
|             qemu_aio_set_fd_handler(fd, NULL, NULL, NULL); | ||||
|             break; | ||||
|     } | ||||
|  | ||||
| @@ -495,21 +493,6 @@ out_noclean: | ||||
|     return -EINVAL; | ||||
| } | ||||
|  | ||||
| static int curl_aio_flush(void *opaque) | ||||
| { | ||||
|     BDRVCURLState *s = opaque; | ||||
|     int i, j; | ||||
|  | ||||
|     for (i=0; i < CURL_NUM_STATES; i++) { | ||||
|         for(j=0; j < CURL_NUM_ACB; j++) { | ||||
|             if (s->states[i].acb[j]) { | ||||
|                 return 1; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|     return 0; | ||||
| } | ||||
|  | ||||
| static void curl_aio_cancel(BlockDriverAIOCB *blockacb) | ||||
| { | ||||
|     // Do we have to implement canceling? Seems to work without... | ||||
|   | ||||
| @@ -32,7 +32,6 @@ typedef struct BDRVGlusterState { | ||||
|     struct glfs *glfs; | ||||
|     int fds[2]; | ||||
|     struct glfs_fd *fd; | ||||
|     int qemu_aio_count; | ||||
|     int event_reader_pos; | ||||
|     GlusterAIOCB *event_acb; | ||||
| } BDRVGlusterState; | ||||
| @@ -247,7 +246,6 @@ static void qemu_gluster_complete_aio(GlusterAIOCB *acb, BDRVGlusterState *s) | ||||
|         ret = -EIO; /* Partial read/write - fail it */ | ||||
|     } | ||||
|  | ||||
|     s->qemu_aio_count--; | ||||
|     qemu_aio_release(acb); | ||||
|     cb(opaque, ret); | ||||
|     if (finished) { | ||||
| @@ -275,13 +273,6 @@ static void qemu_gluster_aio_event_reader(void *opaque) | ||||
|     } while (ret < 0 && errno == EINTR); | ||||
| } | ||||
|  | ||||
| static int qemu_gluster_aio_flush_cb(void *opaque) | ||||
| { | ||||
|     BDRVGlusterState *s = opaque; | ||||
|  | ||||
|     return (s->qemu_aio_count > 0); | ||||
| } | ||||
|  | ||||
| /* TODO Convert to fine grained options */ | ||||
| static QemuOptsList runtime_opts = { | ||||
|     .name = "gluster", | ||||
| @@ -348,7 +339,7 @@ static int qemu_gluster_open(BlockDriverState *bs,  QDict *options, | ||||
|     } | ||||
|     fcntl(s->fds[GLUSTER_FD_READ], F_SETFL, O_NONBLOCK); | ||||
|     qemu_aio_set_fd_handler(s->fds[GLUSTER_FD_READ], | ||||
|         qemu_gluster_aio_event_reader, NULL, qemu_gluster_aio_flush_cb, s); | ||||
|         qemu_gluster_aio_event_reader, NULL, s); | ||||
|  | ||||
| out: | ||||
|     qemu_opts_del(opts); | ||||
| @@ -445,11 +436,9 @@ static void gluster_finish_aiocb(struct glfs_fd *fd, ssize_t ret, void *arg) | ||||
|         qemu_mutex_lock_iothread(); /* We are in gluster thread context */ | ||||
|         acb->common.cb(acb->common.opaque, -EIO); | ||||
|         qemu_aio_release(acb); | ||||
|         s->qemu_aio_count--; | ||||
|         close(s->fds[GLUSTER_FD_READ]); | ||||
|         close(s->fds[GLUSTER_FD_WRITE]); | ||||
|         qemu_aio_set_fd_handler(s->fds[GLUSTER_FD_READ], NULL, NULL, NULL, | ||||
|             NULL); | ||||
|         qemu_aio_set_fd_handler(s->fds[GLUSTER_FD_READ], NULL, NULL, NULL); | ||||
|         bs->drv = NULL; /* Make the disk inaccessible */ | ||||
|         qemu_mutex_unlock_iothread(); | ||||
|     } | ||||
| @@ -467,7 +456,6 @@ static BlockDriverAIOCB *qemu_gluster_aio_rw(BlockDriverState *bs, | ||||
|  | ||||
|     offset = sector_num * BDRV_SECTOR_SIZE; | ||||
|     size = nb_sectors * BDRV_SECTOR_SIZE; | ||||
|     s->qemu_aio_count++; | ||||
|  | ||||
|     acb = qemu_aio_get(&gluster_aiocb_info, bs, cb, opaque); | ||||
|     acb->size = size; | ||||
| @@ -488,7 +476,6 @@ static BlockDriverAIOCB *qemu_gluster_aio_rw(BlockDriverState *bs, | ||||
|     return &acb->common; | ||||
|  | ||||
| out: | ||||
|     s->qemu_aio_count--; | ||||
|     qemu_aio_release(acb); | ||||
|     return NULL; | ||||
| } | ||||
| @@ -531,7 +518,6 @@ static BlockDriverAIOCB *qemu_gluster_aio_flush(BlockDriverState *bs, | ||||
|     acb->size = 0; | ||||
|     acb->ret = 0; | ||||
|     acb->finished = NULL; | ||||
|     s->qemu_aio_count++; | ||||
|  | ||||
|     ret = glfs_fsync_async(s->fd, &gluster_finish_aiocb, acb); | ||||
|     if (ret < 0) { | ||||
| @@ -540,7 +526,6 @@ static BlockDriverAIOCB *qemu_gluster_aio_flush(BlockDriverState *bs, | ||||
|     return &acb->common; | ||||
|  | ||||
| out: | ||||
|     s->qemu_aio_count--; | ||||
|     qemu_aio_release(acb); | ||||
|     return NULL; | ||||
| } | ||||
| @@ -563,7 +548,6 @@ static BlockDriverAIOCB *qemu_gluster_aio_discard(BlockDriverState *bs, | ||||
|     acb->size = 0; | ||||
|     acb->ret = 0; | ||||
|     acb->finished = NULL; | ||||
|     s->qemu_aio_count++; | ||||
|  | ||||
|     ret = glfs_discard_async(s->fd, offset, size, &gluster_finish_aiocb, acb); | ||||
|     if (ret < 0) { | ||||
| @@ -572,7 +556,6 @@ static BlockDriverAIOCB *qemu_gluster_aio_discard(BlockDriverState *bs, | ||||
|     return &acb->common; | ||||
|  | ||||
| out: | ||||
|     s->qemu_aio_count--; | ||||
|     qemu_aio_release(acb); | ||||
|     return NULL; | ||||
| } | ||||
| @@ -611,7 +594,7 @@ static void qemu_gluster_close(BlockDriverState *bs) | ||||
|  | ||||
|     close(s->fds[GLUSTER_FD_READ]); | ||||
|     close(s->fds[GLUSTER_FD_WRITE]); | ||||
|     qemu_aio_set_fd_handler(s->fds[GLUSTER_FD_READ], NULL, NULL, NULL, NULL); | ||||
|     qemu_aio_set_fd_handler(s->fds[GLUSTER_FD_READ], NULL, NULL, NULL); | ||||
|  | ||||
|     if (s->fd) { | ||||
|         glfs_close(s->fd); | ||||
|   | ||||
| @@ -146,13 +146,6 @@ static const AIOCBInfo iscsi_aiocb_info = { | ||||
| static void iscsi_process_read(void *arg); | ||||
| static void iscsi_process_write(void *arg); | ||||
|  | ||||
| static int iscsi_process_flush(void *arg) | ||||
| { | ||||
|     IscsiLun *iscsilun = arg; | ||||
|  | ||||
|     return iscsi_queue_length(iscsilun->iscsi) > 0; | ||||
| } | ||||
|  | ||||
| static void | ||||
| iscsi_set_events(IscsiLun *iscsilun) | ||||
| { | ||||
| @@ -166,7 +159,6 @@ iscsi_set_events(IscsiLun *iscsilun) | ||||
|         qemu_aio_set_fd_handler(iscsi_get_fd(iscsi), | ||||
|                       iscsi_process_read, | ||||
|                       (ev & POLLOUT) ? iscsi_process_write : NULL, | ||||
|                       iscsi_process_flush, | ||||
|                       iscsilun); | ||||
|  | ||||
|     } | ||||
| @@ -1215,7 +1207,7 @@ static void iscsi_close(BlockDriverState *bs) | ||||
|         qemu_del_timer(iscsilun->nop_timer); | ||||
|         qemu_free_timer(iscsilun->nop_timer); | ||||
|     } | ||||
|     qemu_aio_set_fd_handler(iscsi_get_fd(iscsi), NULL, NULL, NULL, NULL); | ||||
|     qemu_aio_set_fd_handler(iscsi_get_fd(iscsi), NULL, NULL, NULL); | ||||
|     iscsi_destroy_context(iscsi); | ||||
|     memset(iscsilun, 0, sizeof(IscsiLun)); | ||||
| } | ||||
|   | ||||
| @@ -39,7 +39,6 @@ struct qemu_laiocb { | ||||
| struct qemu_laio_state { | ||||
|     io_context_t ctx; | ||||
|     EventNotifier e; | ||||
|     int count; | ||||
| }; | ||||
|  | ||||
| static inline ssize_t io_event_ret(struct io_event *ev) | ||||
| @@ -55,8 +54,6 @@ static void qemu_laio_process_completion(struct qemu_laio_state *s, | ||||
| { | ||||
|     int ret; | ||||
|  | ||||
|     s->count--; | ||||
|  | ||||
|     ret = laiocb->ret; | ||||
|     if (ret != -ECANCELED) { | ||||
|         if (ret == laiocb->nbytes) { | ||||
| @@ -101,13 +98,6 @@ static void qemu_laio_completion_cb(EventNotifier *e) | ||||
|     } | ||||
| } | ||||
|  | ||||
| static int qemu_laio_flush_cb(EventNotifier *e) | ||||
| { | ||||
|     struct qemu_laio_state *s = container_of(e, struct qemu_laio_state, e); | ||||
|  | ||||
|     return (s->count > 0) ? 1 : 0; | ||||
| } | ||||
|  | ||||
| static void laio_cancel(BlockDriverAIOCB *blockacb) | ||||
| { | ||||
|     struct qemu_laiocb *laiocb = (struct qemu_laiocb *)blockacb; | ||||
| @@ -177,14 +167,11 @@ BlockDriverAIOCB *laio_submit(BlockDriverState *bs, void *aio_ctx, int fd, | ||||
|         goto out_free_aiocb; | ||||
|     } | ||||
|     io_set_eventfd(&laiocb->iocb, event_notifier_get_fd(&s->e)); | ||||
|     s->count++; | ||||
|  | ||||
|     if (io_submit(s->ctx, 1, &iocbs) < 0) | ||||
|         goto out_dec_count; | ||||
|         goto out_free_aiocb; | ||||
|     return &laiocb->common; | ||||
|  | ||||
| out_dec_count: | ||||
|     s->count--; | ||||
| out_free_aiocb: | ||||
|     qemu_aio_release(laiocb); | ||||
|     return NULL; | ||||
| @@ -203,8 +190,7 @@ void *laio_init(void) | ||||
|         goto out_close_efd; | ||||
|     } | ||||
|  | ||||
|     qemu_aio_set_event_notifier(&s->e, qemu_laio_completion_cb, | ||||
|                                 qemu_laio_flush_cb); | ||||
|     qemu_aio_set_event_notifier(&s->e, qemu_laio_completion_cb); | ||||
|  | ||||
|     return s; | ||||
|  | ||||
|   | ||||
							
								
								
									
										18
									
								
								block/nbd.c
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								block/nbd.c
									
									
									
									
									
								
							| @@ -279,13 +279,6 @@ static void nbd_coroutine_start(BDRVNBDState *s, struct nbd_request *request) | ||||
|     request->handle = INDEX_TO_HANDLE(s, i); | ||||
| } | ||||
|  | ||||
| static int nbd_have_request(void *opaque) | ||||
| { | ||||
|     BDRVNBDState *s = opaque; | ||||
|  | ||||
|     return s->in_flight > 0; | ||||
| } | ||||
|  | ||||
| static void nbd_reply_ready(void *opaque) | ||||
| { | ||||
|     BDRVNBDState *s = opaque; | ||||
| @@ -341,8 +334,7 @@ static int nbd_co_send_request(BDRVNBDState *s, struct nbd_request *request, | ||||
|  | ||||
|     qemu_co_mutex_lock(&s->send_mutex); | ||||
|     s->send_coroutine = qemu_coroutine_self(); | ||||
|     qemu_aio_set_fd_handler(s->sock, nbd_reply_ready, nbd_restart_write, | ||||
|                             nbd_have_request, s); | ||||
|     qemu_aio_set_fd_handler(s->sock, nbd_reply_ready, nbd_restart_write, s); | ||||
|     if (qiov) { | ||||
|         if (!s->is_unix) { | ||||
|             socket_set_cork(s->sock, 1); | ||||
| @@ -361,8 +353,7 @@ static int nbd_co_send_request(BDRVNBDState *s, struct nbd_request *request, | ||||
|     } else { | ||||
|         rc = nbd_send_request(s->sock, request); | ||||
|     } | ||||
|     qemu_aio_set_fd_handler(s->sock, nbd_reply_ready, NULL, | ||||
|                             nbd_have_request, s); | ||||
|     qemu_aio_set_fd_handler(s->sock, nbd_reply_ready, NULL, s); | ||||
|     s->send_coroutine = NULL; | ||||
|     qemu_co_mutex_unlock(&s->send_mutex); | ||||
|     return rc; | ||||
| @@ -438,8 +429,7 @@ static int nbd_establish_connection(BlockDriverState *bs) | ||||
|     /* Now that we're connected, set the socket to be non-blocking and | ||||
|      * kick the reply mechanism.  */ | ||||
|     qemu_set_nonblock(sock); | ||||
|     qemu_aio_set_fd_handler(sock, nbd_reply_ready, NULL, | ||||
|                             nbd_have_request, s); | ||||
|     qemu_aio_set_fd_handler(sock, nbd_reply_ready, NULL, s); | ||||
|  | ||||
|     s->sock = sock; | ||||
|     s->size = size; | ||||
| @@ -459,7 +449,7 @@ static void nbd_teardown_connection(BlockDriverState *bs) | ||||
|     request.len = 0; | ||||
|     nbd_send_request(s->sock, &request); | ||||
|  | ||||
|     qemu_aio_set_fd_handler(s->sock, NULL, NULL, NULL, NULL); | ||||
|     qemu_aio_set_fd_handler(s->sock, NULL, NULL, NULL); | ||||
|     closesocket(s->sock); | ||||
| } | ||||
|  | ||||
|   | ||||
							
								
								
									
										16
									
								
								block/rbd.c
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								block/rbd.c
									
									
									
									
									
								
							| @@ -100,7 +100,6 @@ typedef struct BDRVRBDState { | ||||
|     rados_ioctx_t io_ctx; | ||||
|     rbd_image_t image; | ||||
|     char name[RBD_MAX_IMAGE_NAME_SIZE]; | ||||
|     int qemu_aio_count; | ||||
|     char *snap; | ||||
|     int event_reader_pos; | ||||
|     RADOSCB *event_rcb; | ||||
| @@ -428,19 +427,11 @@ static void qemu_rbd_aio_event_reader(void *opaque) | ||||
|             if (s->event_reader_pos == sizeof(s->event_rcb)) { | ||||
|                 s->event_reader_pos = 0; | ||||
|                 qemu_rbd_complete_aio(s->event_rcb); | ||||
|                 s->qemu_aio_count--; | ||||
|             } | ||||
|         } | ||||
|     } while (ret < 0 && errno == EINTR); | ||||
| } | ||||
|  | ||||
| static int qemu_rbd_aio_flush_cb(void *opaque) | ||||
| { | ||||
|     BDRVRBDState *s = opaque; | ||||
|  | ||||
|     return (s->qemu_aio_count > 0); | ||||
| } | ||||
|  | ||||
| /* TODO Convert to fine grained options */ | ||||
| static QemuOptsList runtime_opts = { | ||||
|     .name = "rbd", | ||||
| @@ -554,7 +545,7 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags) | ||||
|     fcntl(s->fds[0], F_SETFL, O_NONBLOCK); | ||||
|     fcntl(s->fds[1], F_SETFL, O_NONBLOCK); | ||||
|     qemu_aio_set_fd_handler(s->fds[RBD_FD_READ], qemu_rbd_aio_event_reader, | ||||
|                             NULL, qemu_rbd_aio_flush_cb, s); | ||||
|                             NULL, s); | ||||
|  | ||||
|  | ||||
|     qemu_opts_del(opts); | ||||
| @@ -578,7 +569,7 @@ static void qemu_rbd_close(BlockDriverState *bs) | ||||
|  | ||||
|     close(s->fds[0]); | ||||
|     close(s->fds[1]); | ||||
|     qemu_aio_set_fd_handler(s->fds[RBD_FD_READ], NULL, NULL, NULL, NULL); | ||||
|     qemu_aio_set_fd_handler(s->fds[RBD_FD_READ], NULL, NULL, NULL); | ||||
|  | ||||
|     rbd_close(s->image); | ||||
|     rados_ioctx_destroy(s->io_ctx); | ||||
| @@ -741,8 +732,6 @@ static BlockDriverAIOCB *rbd_start_aio(BlockDriverState *bs, | ||||
|     off = sector_num * BDRV_SECTOR_SIZE; | ||||
|     size = nb_sectors * BDRV_SECTOR_SIZE; | ||||
|  | ||||
|     s->qemu_aio_count++; /* All the RADOSCB */ | ||||
|  | ||||
|     rcb = g_malloc(sizeof(RADOSCB)); | ||||
|     rcb->done = 0; | ||||
|     rcb->acb = acb; | ||||
| @@ -779,7 +768,6 @@ static BlockDriverAIOCB *rbd_start_aio(BlockDriverState *bs, | ||||
|  | ||||
| failed: | ||||
|     g_free(rcb); | ||||
|     s->qemu_aio_count--; | ||||
|     qemu_aio_release(acb); | ||||
|     return NULL; | ||||
| } | ||||
|   | ||||
| @@ -509,13 +509,6 @@ static void restart_co_req(void *opaque) | ||||
|     qemu_coroutine_enter(co, NULL); | ||||
| } | ||||
|  | ||||
| static int have_co_req(void *opaque) | ||||
| { | ||||
|     /* this handler is set only when there is a pending request, so | ||||
|      * always returns 1. */ | ||||
|     return 1; | ||||
| } | ||||
|  | ||||
| typedef struct SheepdogReqCo { | ||||
|     int sockfd; | ||||
|     SheepdogReq *hdr; | ||||
| @@ -538,14 +531,14 @@ static coroutine_fn void do_co_req(void *opaque) | ||||
|     unsigned int *rlen = srco->rlen; | ||||
|  | ||||
|     co = qemu_coroutine_self(); | ||||
|     qemu_aio_set_fd_handler(sockfd, NULL, restart_co_req, have_co_req, co); | ||||
|     qemu_aio_set_fd_handler(sockfd, NULL, restart_co_req, co); | ||||
|  | ||||
|     ret = send_co_req(sockfd, hdr, data, wlen); | ||||
|     if (ret < 0) { | ||||
|         goto out; | ||||
|     } | ||||
|  | ||||
|     qemu_aio_set_fd_handler(sockfd, restart_co_req, NULL, have_co_req, co); | ||||
|     qemu_aio_set_fd_handler(sockfd, restart_co_req, NULL, co); | ||||
|  | ||||
|     ret = qemu_co_recv(sockfd, hdr, sizeof(*hdr)); | ||||
|     if (ret < sizeof(*hdr)) { | ||||
| @@ -570,7 +563,7 @@ static coroutine_fn void do_co_req(void *opaque) | ||||
| out: | ||||
|     /* there is at most one request for this sockfd, so it is safe to | ||||
|      * set each handler to NULL. */ | ||||
|     qemu_aio_set_fd_handler(sockfd, NULL, NULL, NULL, NULL); | ||||
|     qemu_aio_set_fd_handler(sockfd, NULL, NULL, NULL); | ||||
|  | ||||
|     srco->ret = ret; | ||||
|     srco->finished = true; | ||||
| @@ -796,14 +789,6 @@ static void co_write_request(void *opaque) | ||||
|     qemu_coroutine_enter(s->co_send, NULL); | ||||
| } | ||||
|  | ||||
| static int aio_flush_request(void *opaque) | ||||
| { | ||||
|     BDRVSheepdogState *s = opaque; | ||||
|  | ||||
|     return !QLIST_EMPTY(&s->inflight_aio_head) || | ||||
|         !QLIST_EMPTY(&s->pending_aio_head); | ||||
| } | ||||
|  | ||||
| /* | ||||
|  * Return a socket discriptor to read/write objects. | ||||
|  * | ||||
| @@ -819,7 +804,7 @@ static int get_sheep_fd(BDRVSheepdogState *s) | ||||
|         return fd; | ||||
|     } | ||||
|  | ||||
|     qemu_aio_set_fd_handler(fd, co_read_response, NULL, aio_flush_request, s); | ||||
|     qemu_aio_set_fd_handler(fd, co_read_response, NULL, s); | ||||
|     return fd; | ||||
| } | ||||
|  | ||||
| @@ -1069,8 +1054,7 @@ static int coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req, | ||||
|  | ||||
|     qemu_co_mutex_lock(&s->lock); | ||||
|     s->co_send = qemu_coroutine_self(); | ||||
|     qemu_aio_set_fd_handler(s->fd, co_read_response, co_write_request, | ||||
|                             aio_flush_request, s); | ||||
|     qemu_aio_set_fd_handler(s->fd, co_read_response, co_write_request, s); | ||||
|     socket_set_cork(s->fd, 1); | ||||
|  | ||||
|     /* send a header */ | ||||
| @@ -1091,8 +1075,7 @@ static int coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req, | ||||
|     } | ||||
|  | ||||
|     socket_set_cork(s->fd, 0); | ||||
|     qemu_aio_set_fd_handler(s->fd, co_read_response, NULL, | ||||
|                             aio_flush_request, s); | ||||
|     qemu_aio_set_fd_handler(s->fd, co_read_response, NULL, s); | ||||
|     qemu_co_mutex_unlock(&s->lock); | ||||
|  | ||||
|     return 0; | ||||
| @@ -1350,7 +1333,7 @@ static int sd_open(BlockDriverState *bs, QDict *options, int flags) | ||||
|     g_free(buf); | ||||
|     return 0; | ||||
| out: | ||||
|     qemu_aio_set_fd_handler(s->fd, NULL, NULL, NULL, NULL); | ||||
|     qemu_aio_set_fd_handler(s->fd, NULL, NULL, NULL); | ||||
|     if (s->fd >= 0) { | ||||
|         closesocket(s->fd); | ||||
|     } | ||||
| @@ -1578,7 +1561,7 @@ static void sd_close(BlockDriverState *bs) | ||||
|         error_report("%s, %s", sd_strerror(rsp->result), s->name); | ||||
|     } | ||||
|  | ||||
|     qemu_aio_set_fd_handler(s->fd, NULL, NULL, NULL, NULL); | ||||
|     qemu_aio_set_fd_handler(s->fd, NULL, NULL, NULL); | ||||
|     closesocket(s->fd); | ||||
|     g_free(s->host_spec); | ||||
| } | ||||
|   | ||||
							
								
								
									
										12
									
								
								block/ssh.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								block/ssh.c
									
									
									
									
									
								
							| @@ -740,14 +740,6 @@ static void restart_coroutine(void *opaque) | ||||
|     qemu_coroutine_enter(co, NULL); | ||||
| } | ||||
|  | ||||
| /* Always true because when we have called set_fd_handler there is | ||||
|  * always a request being processed. | ||||
|  */ | ||||
| static int return_true(void *opaque) | ||||
| { | ||||
|     return 1; | ||||
| } | ||||
|  | ||||
| static coroutine_fn void set_fd_handler(BDRVSSHState *s) | ||||
| { | ||||
|     int r; | ||||
| @@ -766,13 +758,13 @@ static coroutine_fn void set_fd_handler(BDRVSSHState *s) | ||||
|     DPRINTF("s->sock=%d rd_handler=%p wr_handler=%p", s->sock, | ||||
|             rd_handler, wr_handler); | ||||
|  | ||||
|     qemu_aio_set_fd_handler(s->sock, rd_handler, wr_handler, return_true, co); | ||||
|     qemu_aio_set_fd_handler(s->sock, rd_handler, wr_handler, co); | ||||
| } | ||||
|  | ||||
| static coroutine_fn void clear_fd_handler(BDRVSSHState *s) | ||||
| { | ||||
|     DPRINTF("s->sock=%d", s->sock); | ||||
|     qemu_aio_set_fd_handler(s->sock, NULL, NULL, NULL, NULL); | ||||
|     qemu_aio_set_fd_handler(s->sock, NULL, NULL, NULL); | ||||
| } | ||||
|  | ||||
| /* A non-blocking call returned EAGAIN, so yield, ensuring the | ||||
|   | ||||
| @@ -57,6 +57,11 @@ static void close_unused_images(BlockDriverState *top, BlockDriverState *base, | ||||
|     BlockDriverState *intermediate; | ||||
|     intermediate = top->backing_hd; | ||||
|  | ||||
|     /* Must assign before bdrv_delete() to prevent traversing dangling pointer | ||||
|      * while we delete backing image instances. | ||||
|      */ | ||||
|     top->backing_hd = base; | ||||
|  | ||||
|     while (intermediate) { | ||||
|         BlockDriverState *unused; | ||||
|  | ||||
| @@ -70,7 +75,6 @@ static void close_unused_images(BlockDriverState *top, BlockDriverState *base, | ||||
|         unused->backing_hd = NULL; | ||||
|         bdrv_delete(unused); | ||||
|     } | ||||
|     top->backing_hd = base; | ||||
| } | ||||
|  | ||||
| static void coroutine_fn stream_run(void *opaque) | ||||
|   | ||||
							
								
								
									
										14
									
								
								cpus.c
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								cpus.c
									
									
									
									
									
								
							| @@ -62,12 +62,17 @@ | ||||
|  | ||||
| static CPUState *next_cpu; | ||||
|  | ||||
| bool cpu_is_stopped(CPUState *cpu) | ||||
| { | ||||
|     return cpu->stopped || !runstate_is_running(); | ||||
| } | ||||
|  | ||||
| static bool cpu_thread_is_idle(CPUState *cpu) | ||||
| { | ||||
|     if (cpu->stop || cpu->queued_work_first) { | ||||
|         return false; | ||||
|     } | ||||
|     if (cpu->stopped || !runstate_is_running()) { | ||||
|     if (cpu_is_stopped(cpu)) { | ||||
|         return true; | ||||
|     } | ||||
|     if (!cpu->halted || qemu_cpu_has_work(cpu) || | ||||
| @@ -429,11 +434,6 @@ void cpu_synchronize_all_post_init(void) | ||||
|     } | ||||
| } | ||||
|  | ||||
| bool cpu_is_stopped(CPUState *cpu) | ||||
| { | ||||
|     return !runstate_is_running() || cpu->stopped; | ||||
| } | ||||
|  | ||||
| static int do_vm_stop(RunState state) | ||||
| { | ||||
|     int ret = 0; | ||||
| @@ -457,7 +457,7 @@ static bool cpu_can_run(CPUState *cpu) | ||||
|     if (cpu->stop) { | ||||
|         return false; | ||||
|     } | ||||
|     if (cpu->stopped || !runstate_is_running()) { | ||||
|     if (cpu_is_stopped(cpu)) { | ||||
|         return false; | ||||
|     } | ||||
|     return true; | ||||
|   | ||||
| @@ -34,9 +34,9 @@ CONFIG_PFLASH_CFI02=y | ||||
| CONFIG_MICRODRIVE=y | ||||
| CONFIG_USB_MUSB=y | ||||
|  | ||||
| CONFIG_ARM9MPCORE=y | ||||
| CONFIG_ARM11MPCORE=y | ||||
| CONFIG_ARM15MPCORE=y | ||||
| CONFIG_A9MPCORE=y | ||||
| CONFIG_A15MPCORE=y | ||||
|  | ||||
| CONFIG_ARM_GIC=y | ||||
| CONFIG_ARM_GIC_KVM=$(CONFIG_KVM) | ||||
|   | ||||
| @@ -91,6 +91,29 @@ | ||||
|   port = "4" | ||||
|   chassis = "4" | ||||
|  | ||||
| ## | ||||
| # Example PCIe switch with two downstream ports | ||||
| # | ||||
| #[device "pcie-switch-upstream-port-1"] | ||||
| #  driver = "x3130-upstream" | ||||
| #  bus = "ich9-pcie-port-4" | ||||
| #  addr = "00.0" | ||||
| # | ||||
| #[device "pcie-switch-downstream-port-1-1"] | ||||
| #  driver = "xio3130-downstream" | ||||
| #  multifunction = "on" | ||||
| #  bus = "pcie-switch-upstream-port-1" | ||||
| #  addr = "00.0" | ||||
| #  port = "1" | ||||
| #  chassis = "5" | ||||
| # | ||||
| #[device "pcie-switch-downstream-port-1-2"] | ||||
| #  driver = "xio3130-downstream" | ||||
| #  multifunction = "on" | ||||
| #  bus = "pcie-switch-upstream-port-1" | ||||
| #  addr = "00.1" | ||||
| #  port = "1" | ||||
| #  chassis = "6" | ||||
|  | ||||
| [device "ich9-ehci-1"] | ||||
|   driver = "ich9-usb-ehci1" | ||||
|   | ||||
| @@ -621,6 +621,8 @@ void gdb_register_coprocessor(CPUState *cpu, | ||||
|         if (g_pos != s->base_reg) { | ||||
|             fprintf(stderr, "Error: Bad gdb register numbering for '%s'\n" | ||||
|                     "Expected %d got %d\n", xml, g_pos, s->base_reg); | ||||
|         } else { | ||||
|             cpu->gdb_num_g_regs = cpu->gdb_num_regs; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -902,7 +904,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) | ||||
|     case 'g': | ||||
|         cpu_synchronize_state(s->g_cpu); | ||||
|         len = 0; | ||||
|         for (addr = 0; addr < s->g_cpu->gdb_num_regs; addr++) { | ||||
|         for (addr = 0; addr < s->g_cpu->gdb_num_g_regs; addr++) { | ||||
|             reg_size = gdb_read_register(s->g_cpu, mem_buf + len, addr); | ||||
|             len += reg_size; | ||||
|         } | ||||
| @@ -914,7 +916,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) | ||||
|         registers = mem_buf; | ||||
|         len = strlen(p) / 2; | ||||
|         hextomem((uint8_t *)registers, p, len); | ||||
|         for (addr = 0; addr < s->g_cpu->gdb_num_regs && len > 0; addr++) { | ||||
|         for (addr = 0; addr < s->g_cpu->gdb_num_g_regs && len > 0; addr++) { | ||||
|             reg_size = gdb_write_register(s->g_cpu, registers, addr); | ||||
|             len -= reg_size; | ||||
|             registers += reg_size; | ||||
|   | ||||
| @@ -173,7 +173,6 @@ static QEMUMachine clipper_machine = { | ||||
|     .init = clipper_init, | ||||
|     .max_cpus = 4, | ||||
|     .is_default = 1, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void clipper_machine_init(void) | ||||
|   | ||||
| @@ -26,9 +26,9 @@ typedef struct TyphoonCchip { | ||||
| } TyphoonCchip; | ||||
|  | ||||
| typedef struct TyphoonWindow { | ||||
|     uint32_t base_addr; | ||||
|     uint32_t mask; | ||||
|     uint32_t translated_base_pfn; | ||||
|     uint64_t wba; | ||||
|     uint64_t wsm; | ||||
|     uint64_t tba; | ||||
| } TyphoonWindow; | ||||
|   | ||||
| typedef struct TyphoonPchip { | ||||
| @@ -37,6 +37,10 @@ typedef struct TyphoonPchip { | ||||
|     MemoryRegion reg_mem; | ||||
|     MemoryRegion reg_io; | ||||
|     MemoryRegion reg_conf; | ||||
|  | ||||
|     AddressSpace iommu_as; | ||||
|     MemoryRegion iommu; | ||||
|  | ||||
|     uint64_t ctl; | ||||
|     TyphoonWindow win[4]; | ||||
| } TyphoonPchip; | ||||
| @@ -209,53 +213,53 @@ static uint64_t pchip_read(void *opaque, hwaddr addr, unsigned size) | ||||
|     switch (addr) { | ||||
|     case 0x0000: | ||||
|         /* WSBA0: Window Space Base Address Register.  */ | ||||
|         ret = s->pchip.win[0].base_addr; | ||||
|         ret = s->pchip.win[0].wba; | ||||
|         break; | ||||
|     case 0x0040: | ||||
|         /* WSBA1 */ | ||||
|         ret = s->pchip.win[1].base_addr; | ||||
|         ret = s->pchip.win[1].wba; | ||||
|         break; | ||||
|     case 0x0080: | ||||
|         /* WSBA2 */ | ||||
|         ret = s->pchip.win[2].base_addr; | ||||
|         ret = s->pchip.win[2].wba; | ||||
|         break; | ||||
|     case 0x00c0: | ||||
|         /* WSBA3 */ | ||||
|         ret = s->pchip.win[3].base_addr; | ||||
|         ret = s->pchip.win[3].wba; | ||||
|         break; | ||||
|  | ||||
|     case 0x0100: | ||||
|         /* WSM0: Window Space Mask Register.  */ | ||||
|         ret = s->pchip.win[0].mask; | ||||
|         ret = s->pchip.win[0].wsm; | ||||
|         break; | ||||
|     case 0x0140: | ||||
|         /* WSM1 */ | ||||
|         ret = s->pchip.win[1].mask; | ||||
|         ret = s->pchip.win[1].wsm; | ||||
|         break; | ||||
|     case 0x0180: | ||||
|         /* WSM2 */ | ||||
|         ret = s->pchip.win[2].mask; | ||||
|         ret = s->pchip.win[2].wsm; | ||||
|         break; | ||||
|     case 0x01c0: | ||||
|         /* WSM3 */ | ||||
|         ret = s->pchip.win[3].mask; | ||||
|         ret = s->pchip.win[3].wsm; | ||||
|         break; | ||||
|  | ||||
|     case 0x0200: | ||||
|         /* TBA0: Translated Base Address Register.  */ | ||||
|         ret = (uint64_t)s->pchip.win[0].translated_base_pfn << 10; | ||||
|         ret = s->pchip.win[0].tba; | ||||
|         break; | ||||
|     case 0x0240: | ||||
|         /* TBA1 */ | ||||
|         ret = (uint64_t)s->pchip.win[1].translated_base_pfn << 10; | ||||
|         ret = s->pchip.win[1].tba; | ||||
|         break; | ||||
|     case 0x0280: | ||||
|         /* TBA2 */ | ||||
|         ret = (uint64_t)s->pchip.win[2].translated_base_pfn << 10; | ||||
|         ret = s->pchip.win[2].tba; | ||||
|         break; | ||||
|     case 0x02c0: | ||||
|         /* TBA3 */ | ||||
|         ret = (uint64_t)s->pchip.win[3].translated_base_pfn << 10; | ||||
|         ret = s->pchip.win[3].tba; | ||||
|         break; | ||||
|  | ||||
|     case 0x0300: | ||||
| @@ -458,53 +462,53 @@ static void pchip_write(void *opaque, hwaddr addr, | ||||
|     switch (addr) { | ||||
|     case 0x0000: | ||||
|         /* WSBA0: Window Space Base Address Register.  */ | ||||
|         s->pchip.win[0].base_addr = val; | ||||
|         s->pchip.win[0].wba = val & 0xfff00003u; | ||||
|         break; | ||||
|     case 0x0040: | ||||
|         /* WSBA1 */ | ||||
|         s->pchip.win[1].base_addr = val; | ||||
|         s->pchip.win[1].wba = val & 0xfff00003u; | ||||
|         break; | ||||
|     case 0x0080: | ||||
|         /* WSBA2 */ | ||||
|         s->pchip.win[2].base_addr = val; | ||||
|         s->pchip.win[2].wba = val & 0xfff00003u; | ||||
|         break; | ||||
|     case 0x00c0: | ||||
|         /* WSBA3 */ | ||||
|         s->pchip.win[3].base_addr = val; | ||||
|         s->pchip.win[3].wba = (val & 0x80fff00001ull) | 2; | ||||
|         break; | ||||
|  | ||||
|     case 0x0100: | ||||
|         /* WSM0: Window Space Mask Register.  */ | ||||
|         s->pchip.win[0].mask = val; | ||||
|         s->pchip.win[0].wsm = val & 0xfff00000u; | ||||
|         break; | ||||
|     case 0x0140: | ||||
|         /* WSM1 */ | ||||
|         s->pchip.win[1].mask = val; | ||||
|         s->pchip.win[1].wsm = val & 0xfff00000u; | ||||
|         break; | ||||
|     case 0x0180: | ||||
|         /* WSM2 */ | ||||
|         s->pchip.win[2].mask = val; | ||||
|         s->pchip.win[2].wsm = val & 0xfff00000u; | ||||
|         break; | ||||
|     case 0x01c0: | ||||
|         /* WSM3 */ | ||||
|         s->pchip.win[3].mask = val; | ||||
|         s->pchip.win[3].wsm = val & 0xfff00000u; | ||||
|         break; | ||||
|  | ||||
|     case 0x0200: | ||||
|         /* TBA0: Translated Base Address Register.  */ | ||||
|         s->pchip.win[0].translated_base_pfn = val >> 10; | ||||
|         s->pchip.win[0].tba = val & 0x7fffffc00ull; | ||||
|         break; | ||||
|     case 0x0240: | ||||
|         /* TBA1 */ | ||||
|         s->pchip.win[1].translated_base_pfn = val >> 10; | ||||
|         s->pchip.win[1].tba = val & 0x7fffffc00ull; | ||||
|         break; | ||||
|     case 0x0280: | ||||
|         /* TBA2 */ | ||||
|         s->pchip.win[2].translated_base_pfn = val >> 10; | ||||
|         s->pchip.win[2].tba = val & 0x7fffffc00ull; | ||||
|         break; | ||||
|     case 0x02c0: | ||||
|         /* TBA3 */ | ||||
|         s->pchip.win[3].translated_base_pfn = val >> 10; | ||||
|         s->pchip.win[3].tba = val & 0x7fffffc00ull; | ||||
|         break; | ||||
|  | ||||
|     case 0x0300: | ||||
| @@ -512,7 +516,6 @@ static void pchip_write(void *opaque, hwaddr addr, | ||||
|         oldval = s->pchip.ctl; | ||||
|         oldval &= ~0x00001cff0fc7ffull;       /* RW fields */ | ||||
|         oldval |= val & 0x00001cff0fc7ffull; | ||||
|  | ||||
|         s->pchip.ctl = oldval; | ||||
|         break; | ||||
|  | ||||
| @@ -593,6 +596,140 @@ static const MemoryRegionOps pchip_ops = { | ||||
|     }, | ||||
| }; | ||||
|  | ||||
| /* A subroutine of typhoon_translate_iommu that builds an IOMMUTLBEntry | ||||
|    using the given translated address and mask.  */ | ||||
| static bool make_iommu_tlbe(hwaddr taddr, hwaddr mask, IOMMUTLBEntry *ret) | ||||
| { | ||||
|     *ret = (IOMMUTLBEntry) { | ||||
|         .target_as = &address_space_memory, | ||||
|         .translated_addr = taddr, | ||||
|         .addr_mask = mask, | ||||
|         .perm = IOMMU_RW, | ||||
|     }; | ||||
|     return true; | ||||
| } | ||||
|  | ||||
| /* A subroutine of typhoon_translate_iommu that handles scatter-gather | ||||
|    translation, given the address of the PTE.  */ | ||||
| static bool pte_translate(hwaddr pte_addr, IOMMUTLBEntry *ret) | ||||
| { | ||||
|     uint64_t pte = ldq_phys(pte_addr); | ||||
|  | ||||
|     /* Check valid bit.  */ | ||||
|     if ((pte & 1) == 0) { | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     return make_iommu_tlbe((pte & 0x3ffffe) << 12, 0x1fff, ret); | ||||
| } | ||||
|  | ||||
| /* A subroutine of typhoon_translate_iommu that handles one of the | ||||
|    four single-address-cycle translation windows.  */ | ||||
| static bool window_translate(TyphoonWindow *win, hwaddr addr, | ||||
|                              IOMMUTLBEntry *ret) | ||||
| { | ||||
|     uint32_t wba = win->wba; | ||||
|     uint64_t wsm = win->wsm; | ||||
|     uint64_t tba = win->tba; | ||||
|     uint64_t wsm_ext = wsm | 0xfffff; | ||||
|  | ||||
|     /* Check for window disabled.  */ | ||||
|     if ((wba & 1) == 0) { | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     /* Check for window hit.  */ | ||||
|     if ((addr & ~wsm_ext) != (wba & 0xfff00000u)) { | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     if (wba & 2) { | ||||
|         /* Scatter-gather translation.  */ | ||||
|         hwaddr pte_addr; | ||||
|  | ||||
|         /* See table 10-6, Generating PTE address for PCI DMA Address.  */ | ||||
|         pte_addr  = tba & ~(wsm >> 10); | ||||
|         pte_addr |= (addr & (wsm | 0xfe000)) >> 10; | ||||
|         return pte_translate(pte_addr, ret); | ||||
|     } else { | ||||
| 	/* Direct-mapped translation.  */ | ||||
| 	return make_iommu_tlbe(tba & ~wsm_ext, wsm_ext, ret); | ||||
|     } | ||||
| } | ||||
|  | ||||
| /* Handle PCI-to-system address translation.  */ | ||||
| /* TODO: A translation failure here ought to set PCI error codes on the | ||||
|    Pchip and generate a machine check interrupt.  */ | ||||
| static IOMMUTLBEntry typhoon_translate_iommu(MemoryRegion *iommu, hwaddr addr) | ||||
| { | ||||
|     TyphoonPchip *pchip = container_of(iommu, TyphoonPchip, iommu); | ||||
|     IOMMUTLBEntry ret; | ||||
|     int i; | ||||
|  | ||||
|     if (addr <= 0xffffffffu) { | ||||
|         /* Single-address cycle.  */ | ||||
|  | ||||
|         /* Check for the Window Hole, inhibiting matching.  */ | ||||
|         if ((pchip->ctl & 0x20) | ||||
|             && addr >= 0x80000 | ||||
|             && addr <= 0xfffff) { | ||||
|             goto failure; | ||||
|         } | ||||
|  | ||||
|         /* Check the first three windows.  */ | ||||
|         for (i = 0; i < 3; ++i) { | ||||
|             if (window_translate(&pchip->win[i], addr, &ret)) { | ||||
|                 goto success; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         /* Check the fourth window for DAC disable.  */ | ||||
|         if ((pchip->win[3].wba & 0x80000000000ull) == 0 | ||||
| 	    && window_translate(&pchip->win[3], addr, &ret)) { | ||||
|             goto success; | ||||
|         } | ||||
|     } else { | ||||
|         /* Double-address cycle.  */ | ||||
|  | ||||
|         if (addr >= 0x10000000000ull && addr < 0x20000000000ull) { | ||||
|             /* Check for the DMA monster window.  */ | ||||
|             if (pchip->ctl & 0x40) { | ||||
|                 /* See 10.1.4.4; in particular <39:35> is ignored.  */ | ||||
|                 make_iommu_tlbe(0, 0x007ffffffffull, &ret); | ||||
| 		goto success; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if (addr >= 0x80000000000 && addr <= 0xfffffffffff) { | ||||
|             /* Check the fourth window for DAC enable and window enable.  */ | ||||
|             if ((pchip->win[3].wba & 0x80000000001ull) == 0x80000000001ull) { | ||||
|                 uint64_t pte_addr; | ||||
|  | ||||
|                 pte_addr  = pchip->win[3].tba & 0x7ffc00000ull; | ||||
|                 pte_addr |= (addr & 0xffffe000u) >> 10; | ||||
|                 if (pte_translate(pte_addr, &ret)) { | ||||
| 			goto success; | ||||
| 		} | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|  failure: | ||||
|     ret = (IOMMUTLBEntry) { .perm = IOMMU_NONE }; | ||||
|  success: | ||||
|     return ret; | ||||
| } | ||||
|  | ||||
| static const MemoryRegionIOMMUOps typhoon_iommu_ops = { | ||||
|     .translate = typhoon_translate_iommu, | ||||
| }; | ||||
|  | ||||
| static AddressSpace *typhoon_pci_dma_iommu(PCIBus *bus, void *opaque, int devfn) | ||||
| { | ||||
|     TyphoonState *s = opaque; | ||||
|     return &s->pchip.iommu_as; | ||||
| } | ||||
|  | ||||
| static void typhoon_set_irq(void *opaque, int irq, int level) | ||||
| { | ||||
|     TyphoonState *s = opaque; | ||||
| @@ -688,6 +825,9 @@ PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus, | ||||
|     s = TYPHOON_PCI_HOST_BRIDGE(dev); | ||||
|     phb = PCI_HOST_BRIDGE(dev); | ||||
|  | ||||
|     s->cchip.misc = 0x800000000ull; /* Revision: Typhoon.  */ | ||||
|     s->pchip.win[3].wba = 2;        /* Window 3 SG always enabled. */ | ||||
|  | ||||
|     /* Remember the CPUs so that we can deliver interrupts to them.  */ | ||||
|     for (i = 0; i < 4; i++) { | ||||
|         AlphaCPU *cpu = cpus[i]; | ||||
| @@ -746,6 +886,12 @@ PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus, | ||||
|                          0, 64, TYPE_PCI_BUS); | ||||
|     phb->bus = b; | ||||
|  | ||||
|     /* Host memory as seen from the PCI side, via the IOMMU.  */ | ||||
|     memory_region_init_iommu(&s->pchip.iommu, OBJECT(s), &typhoon_iommu_ops, | ||||
|                              "iommu-typhoon", UINT64_MAX); | ||||
|     address_space_init(&s->pchip.iommu_as, &s->pchip.iommu, "pchip0-pci"); | ||||
|     pci_setup_iommu(b, typhoon_pci_dma_iommu, s); | ||||
|  | ||||
|     /* Pchip0 PCI special/interrupt acknowledge, 0x801.F800.0000, 64MB.  */ | ||||
|     memory_region_init_io(&s->pchip.reg_iack, OBJECT(s), &alpha_pci_iack_ops, | ||||
|                           b, "pci0-iack", 64*MB); | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| obj-y += boot.o collie.o exynos4_boards.o gumstix.o highbank.o | ||||
| obj-y += integratorcp.o kzm.o mainstone.o musicpal.o nseries.o | ||||
| obj-y += omap_sx1.o palm.o pic_cpu.o realview.o spitz.o stellaris.o | ||||
| obj-y += omap_sx1.o palm.o realview.o spitz.o stellaris.o | ||||
| obj-y += tosa.o versatilepb.o vexpress.o xilinx_zynq.o z2.o | ||||
|  | ||||
| obj-y += armv7m.o exynos4210.o pxa2xx.o pxa2xx_gpio.o pxa2xx_pic.o | ||||
|   | ||||
| @@ -173,7 +173,6 @@ qemu_irq *armv7m_init(MemoryRegion *address_space_mem, | ||||
|     DeviceState *nvic; | ||||
|     /* FIXME: make this local state.  */ | ||||
|     static qemu_irq pic[64]; | ||||
|     qemu_irq *cpu_pic; | ||||
|     int image_size; | ||||
|     uint64_t entry; | ||||
|     uint64_t lowaddr; | ||||
| @@ -221,8 +220,8 @@ qemu_irq *armv7m_init(MemoryRegion *address_space_mem, | ||||
|     nvic = qdev_create(NULL, "armv7m_nvic"); | ||||
|     env->nvic = nvic; | ||||
|     qdev_init_nofail(nvic); | ||||
|     cpu_pic = arm_pic_init_cpu(cpu); | ||||
|     sysbus_connect_irq(SYS_BUS_DEVICE(nvic), 0, cpu_pic[ARM_PIC_CPU_IRQ]); | ||||
|     sysbus_connect_irq(SYS_BUS_DEVICE(nvic), 0, | ||||
|                        qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ)); | ||||
|     for (i = 0; i < 64; i++) { | ||||
|         pic[i] = qdev_get_gpio_in(nvic, i); | ||||
|     } | ||||
|   | ||||
| @@ -62,7 +62,6 @@ static QEMUMachine collie_machine = { | ||||
|     .name = "collie", | ||||
|     .desc = "Collie PDA (SA-1110)", | ||||
|     .init = collie_init, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void collie_machine_init(void) | ||||
|   | ||||
| @@ -137,10 +137,8 @@ void exynos4210_write_secondary(ARMCPU *cpu, | ||||
| Exynos4210State *exynos4210_init(MemoryRegion *system_mem, | ||||
|         unsigned long ram_size) | ||||
| { | ||||
|     qemu_irq cpu_irq[EXYNOS4210_NCPUS]; | ||||
|     int i, n; | ||||
|     Exynos4210State *s = g_new(Exynos4210State, 1); | ||||
|     qemu_irq *irqp; | ||||
|     qemu_irq gate_irq[EXYNOS4210_NCPUS][EXYNOS4210_IRQ_GATE_NINPUTS]; | ||||
|     unsigned long mem_size; | ||||
|     DeviceState *dev; | ||||
| @@ -152,15 +150,6 @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem, | ||||
|             fprintf(stderr, "Unable to find CPU %d definition\n", n); | ||||
|             exit(1); | ||||
|         } | ||||
|  | ||||
|         /* Create PIC controller for each processor instance */ | ||||
|         irqp = arm_pic_init_cpu(s->cpu[n]); | ||||
|  | ||||
|         /* | ||||
|          * Get GICs gpio_in cpu_irq to connect a combiner to them later. | ||||
|          * Use only IRQ for a while. | ||||
|          */ | ||||
|         cpu_irq[n] = irqp[ARM_PIC_CPU_IRQ]; | ||||
|     } | ||||
|  | ||||
|     /*** IRQs ***/ | ||||
| @@ -178,8 +167,9 @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem, | ||||
|         } | ||||
|         busdev = SYS_BUS_DEVICE(dev); | ||||
|  | ||||
|         /* Connect IRQ Gate output to cpu_irq */ | ||||
|         sysbus_connect_irq(busdev, 0, cpu_irq[i]); | ||||
|         /* Connect IRQ Gate output to CPU's IRQ line */ | ||||
|         sysbus_connect_irq(busdev, 0, | ||||
|                            qdev_get_gpio_in(DEVICE(s->cpu[i]), ARM_CPU_IRQ)); | ||||
|     } | ||||
|  | ||||
|     /* Private memory region and Internal GIC */ | ||||
|   | ||||
| @@ -150,14 +150,12 @@ static QEMUMachine exynos4_machines[EXYNOS4_NUM_OF_BOARDS] = { | ||||
|         .desc = "Samsung NURI board (Exynos4210)", | ||||
|         .init = nuri_init, | ||||
|         .max_cpus = EXYNOS4210_NCPUS, | ||||
|         DEFAULT_MACHINE_OPTIONS, | ||||
|     }, | ||||
|     [EXYNOS4_BOARD_SMDKC210] = { | ||||
|         .name = "smdkc210", | ||||
|         .desc = "Samsung SMDKC210 board (Exynos4210)", | ||||
|         .init = smdkc210_init, | ||||
|         .max_cpus = EXYNOS4210_NCPUS, | ||||
|         DEFAULT_MACHINE_OPTIONS, | ||||
|     }, | ||||
| }; | ||||
|  | ||||
|   | ||||
| @@ -122,14 +122,12 @@ static QEMUMachine connex_machine = { | ||||
|     .name = "connex", | ||||
|     .desc = "Gumstix Connex (PXA255)", | ||||
|     .init = connex_init, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static QEMUMachine verdex_machine = { | ||||
|     .name = "verdex", | ||||
|     .desc = "Gumstix Verdex (PXA270)", | ||||
|     .init = verdex_init, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void gumstix_machine_init(void) | ||||
|   | ||||
| @@ -209,7 +209,6 @@ static void calxeda_init(QEMUMachineInitArgs *args, enum cxmachines machine) | ||||
|     const char *initrd_filename = args->initrd_filename; | ||||
|     DeviceState *dev = NULL; | ||||
|     SysBusDevice *busdev; | ||||
|     qemu_irq *irqp; | ||||
|     qemu_irq pic[128]; | ||||
|     int n; | ||||
|     qemu_irq cpu_irq[4]; | ||||
| @@ -239,8 +238,7 @@ static void calxeda_init(QEMUMachineInitArgs *args, enum cxmachines machine) | ||||
|  | ||||
|         /* This will become a QOM property eventually */ | ||||
|         cpu->reset_cbar = GIC_BASE_ADDR; | ||||
|         irqp = arm_pic_init_cpu(cpu); | ||||
|         cpu_irq[n] = irqp[ARM_PIC_CPU_IRQ]; | ||||
|         cpu_irq[n] = qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ); | ||||
|     } | ||||
|  | ||||
|     sysmem = get_system_memory(); | ||||
| @@ -365,7 +363,6 @@ static QEMUMachine highbank_machine = { | ||||
|     .init = highbank_init, | ||||
|     .block_default_type = IF_SCSI, | ||||
|     .max_cpus = 4, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static QEMUMachine midway_machine = { | ||||
| @@ -374,7 +371,6 @@ static QEMUMachine midway_machine = { | ||||
|     .init = midway_init, | ||||
|     .block_default_type = IF_SCSI, | ||||
|     .max_cpus = 4, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void calxeda_machines_init(void) | ||||
|   | ||||
| @@ -465,7 +465,6 @@ static void integratorcp_init(QEMUMachineInitArgs *args) | ||||
|     MemoryRegion *ram = g_new(MemoryRegion, 1); | ||||
|     MemoryRegion *ram_alias = g_new(MemoryRegion, 1); | ||||
|     qemu_irq pic[32]; | ||||
|     qemu_irq *cpu_pic; | ||||
|     DeviceState *dev; | ||||
|     int i; | ||||
|  | ||||
| @@ -493,10 +492,10 @@ static void integratorcp_init(QEMUMachineInitArgs *args) | ||||
|     qdev_init_nofail(dev); | ||||
|     sysbus_mmio_map((SysBusDevice *)dev, 0, 0x10000000); | ||||
|  | ||||
|     cpu_pic = arm_pic_init_cpu(cpu); | ||||
|     dev = sysbus_create_varargs(TYPE_INTEGRATOR_PIC, 0x14000000, | ||||
|                                 cpu_pic[ARM_PIC_CPU_IRQ], | ||||
|                                 cpu_pic[ARM_PIC_CPU_FIQ], NULL); | ||||
|                                 qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ), | ||||
|                                 qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_FIQ), | ||||
|                                 NULL); | ||||
|     for (i = 0; i < 32; i++) { | ||||
|         pic[i] = qdev_get_gpio_in(dev, i); | ||||
|     } | ||||
| @@ -527,7 +526,6 @@ static QEMUMachine integratorcp_machine = { | ||||
|     .desc = "ARM Integrator/CP (ARM926EJ-S)", | ||||
|     .init = integratorcp_init, | ||||
|     .is_default = 1, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void integratorcp_machine_init(void) | ||||
|   | ||||
| @@ -82,7 +82,6 @@ static void kzm_init(QEMUMachineInitArgs *args) | ||||
|     MemoryRegion *ram = g_new(MemoryRegion, 1); | ||||
|     MemoryRegion *sram = g_new(MemoryRegion, 1); | ||||
|     MemoryRegion *ram_alias = g_new(MemoryRegion, 1); | ||||
|     qemu_irq *cpu_pic; | ||||
|     DeviceState *dev; | ||||
|     DeviceState *ccm; | ||||
|  | ||||
| @@ -108,11 +107,10 @@ static void kzm_init(QEMUMachineInitArgs *args) | ||||
|     memory_region_init_ram(sram, NULL, "kzm.sram", 0x4000); | ||||
|     memory_region_add_subregion(address_space_mem, 0x1FFFC000, sram); | ||||
|  | ||||
|     cpu_pic = arm_pic_init_cpu(cpu); | ||||
|     dev = sysbus_create_varargs("imx_avic", 0x68000000, | ||||
|                                 cpu_pic[ARM_PIC_CPU_IRQ], | ||||
|                                 cpu_pic[ARM_PIC_CPU_FIQ], NULL); | ||||
|  | ||||
|                                 qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ), | ||||
|                                 qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_FIQ), | ||||
|                                 NULL); | ||||
|  | ||||
|     imx_serial_create(0, 0x43f90000, qdev_get_gpio_in(dev, 45)); | ||||
|     imx_serial_create(1, 0x43f94000, qdev_get_gpio_in(dev, 32)); | ||||
| @@ -146,7 +144,6 @@ static QEMUMachine kzm_machine = { | ||||
|     .name = "kzm", | ||||
|     .desc = "ARM KZM Emulation Baseboard (ARM1136)", | ||||
|     .init = kzm_init, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void kzm_machine_init(void) | ||||
|   | ||||
| @@ -179,7 +179,6 @@ static QEMUMachine mainstone2_machine = { | ||||
|     .name = "mainstone", | ||||
|     .desc = "Mainstone II (PXA27x)", | ||||
|     .init = mainstone_init, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void mainstone_machine_init(void) | ||||
|   | ||||
| @@ -1586,7 +1586,6 @@ static void musicpal_init(QEMUMachineInitArgs *args) | ||||
|     const char *kernel_cmdline = args->kernel_cmdline; | ||||
|     const char *initrd_filename = args->initrd_filename; | ||||
|     ARMCPU *cpu; | ||||
|     qemu_irq *cpu_pic; | ||||
|     qemu_irq pic[32]; | ||||
|     DeviceState *dev; | ||||
|     DeviceState *i2c_dev; | ||||
| @@ -1610,7 +1609,6 @@ static void musicpal_init(QEMUMachineInitArgs *args) | ||||
|         fprintf(stderr, "Unable to find CPU definition\n"); | ||||
|         exit(1); | ||||
|     } | ||||
|     cpu_pic = arm_pic_init_cpu(cpu); | ||||
|  | ||||
|     /* For now we use a fixed - the original - RAM size */ | ||||
|     memory_region_init_ram(ram, NULL, "musicpal.ram", MP_RAM_DEFAULT_SIZE); | ||||
| @@ -1622,7 +1620,7 @@ static void musicpal_init(QEMUMachineInitArgs *args) | ||||
|     memory_region_add_subregion(address_space_mem, MP_SRAM_BASE, sram); | ||||
|  | ||||
|     dev = sysbus_create_simple(TYPE_MV88W8618_PIC, MP_PIC_BASE, | ||||
|                                cpu_pic[ARM_PIC_CPU_IRQ]); | ||||
|                                qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ)); | ||||
|     for (i = 0; i < 32; i++) { | ||||
|         pic[i] = qdev_get_gpio_in(dev, i); | ||||
|     } | ||||
| @@ -1731,7 +1729,6 @@ static QEMUMachine musicpal_machine = { | ||||
|     .name = "musicpal", | ||||
|     .desc = "Marvell 88w8618 / MusicPal (ARM926EJ-S)", | ||||
|     .init = musicpal_init, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void musicpal_machine_init(void) | ||||
|   | ||||
| @@ -1340,7 +1340,7 @@ static void n8x0_init(QEMUMachineInitArgs *args, | ||||
|     } | ||||
|  | ||||
|     if (option_rom[0].name && | ||||
|         (args->boot_device[0] == 'n' || !args->kernel_filename)) { | ||||
|         (args->boot_order[0] == 'n' || !args->kernel_filename)) { | ||||
|         uint8_t nolo_tags[0x10000]; | ||||
|         /* No, wait, better start at the ROM.  */ | ||||
|         s->mpu->cpu->env.regs[15] = OMAP2_Q2_BASE + 0x400000; | ||||
| @@ -1396,14 +1396,14 @@ static QEMUMachine n800_machine = { | ||||
|     .name = "n800", | ||||
|     .desc = "Nokia N800 tablet aka. RX-34 (OMAP2420)", | ||||
|     .init = n800_init, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
|     .default_boot_order = "", | ||||
| }; | ||||
|  | ||||
| static QEMUMachine n810_machine = { | ||||
|     .name = "n810", | ||||
|     .desc = "Nokia N810 tablet aka. RX-44 (OMAP2420)", | ||||
|     .init = n810_init, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
|     .default_boot_order = "", | ||||
| }; | ||||
|  | ||||
| static void nseries_machine_init(void) | ||||
|   | ||||
| @@ -3827,7 +3827,6 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *system_memory, | ||||
|     int i; | ||||
|     struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) | ||||
|             g_malloc0(sizeof(struct omap_mpu_state_s)); | ||||
|     qemu_irq *cpu_irq; | ||||
|     qemu_irq dma_irqs[6]; | ||||
|     DriveInfo *dinfo; | ||||
|     SysBusDevice *busdev; | ||||
| @@ -3860,14 +3859,15 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *system_memory, | ||||
|  | ||||
|     omap_clkm_init(system_memory, 0xfffece00, 0xe1008000, s); | ||||
|  | ||||
|     cpu_irq = arm_pic_init_cpu(s->cpu); | ||||
|     s->ih[0] = qdev_create(NULL, "omap-intc"); | ||||
|     qdev_prop_set_uint32(s->ih[0], "size", 0x100); | ||||
|     qdev_prop_set_ptr(s->ih[0], "clk", omap_findclk(s, "arminth_ck")); | ||||
|     qdev_init_nofail(s->ih[0]); | ||||
|     busdev = SYS_BUS_DEVICE(s->ih[0]); | ||||
|     sysbus_connect_irq(busdev, 0, cpu_irq[ARM_PIC_CPU_IRQ]); | ||||
|     sysbus_connect_irq(busdev, 1, cpu_irq[ARM_PIC_CPU_FIQ]); | ||||
|     sysbus_connect_irq(busdev, 0, | ||||
|                        qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_IRQ)); | ||||
|     sysbus_connect_irq(busdev, 1, | ||||
|                        qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_FIQ)); | ||||
|     sysbus_mmio_map(busdev, 0, 0xfffecb00); | ||||
|     s->ih[1] = qdev_create(NULL, "omap-intc"); | ||||
|     qdev_prop_set_uint32(s->ih[1], "size", 0x800); | ||||
|   | ||||
| @@ -2244,7 +2244,6 @@ struct omap_mpu_state_s *omap2420_mpu_init(MemoryRegion *sysmem, | ||||
| { | ||||
|     struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) | ||||
|             g_malloc0(sizeof(struct omap_mpu_state_s)); | ||||
|     qemu_irq *cpu_irq; | ||||
|     qemu_irq dma_irqs[4]; | ||||
|     DriveInfo *dinfo; | ||||
|     int i; | ||||
| @@ -2277,15 +2276,16 @@ struct omap_mpu_state_s *omap2420_mpu_init(MemoryRegion *sysmem, | ||||
|     s->l4 = omap_l4_init(sysmem, OMAP2_L4_BASE, 54); | ||||
|  | ||||
|     /* Actually mapped at any 2K boundary in the ARM11 private-peripheral if */ | ||||
|     cpu_irq = arm_pic_init_cpu(s->cpu); | ||||
|     s->ih[0] = qdev_create(NULL, "omap2-intc"); | ||||
|     qdev_prop_set_uint8(s->ih[0], "revision", 0x21); | ||||
|     qdev_prop_set_ptr(s->ih[0], "fclk", omap_findclk(s, "mpu_intc_fclk")); | ||||
|     qdev_prop_set_ptr(s->ih[0], "iclk", omap_findclk(s, "mpu_intc_iclk")); | ||||
|     qdev_init_nofail(s->ih[0]); | ||||
|     busdev = SYS_BUS_DEVICE(s->ih[0]); | ||||
|     sysbus_connect_irq(busdev, 0, cpu_irq[ARM_PIC_CPU_IRQ]); | ||||
|     sysbus_connect_irq(busdev, 1, cpu_irq[ARM_PIC_CPU_FIQ]); | ||||
|     sysbus_connect_irq(busdev, 0, | ||||
|                        qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_IRQ)); | ||||
|     sysbus_connect_irq(busdev, 1, | ||||
|                        qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_FIQ)); | ||||
|     sysbus_mmio_map(busdev, 0, 0x480fe000); | ||||
|     s->prcm = omap_prcm_init(omap_l4tao(s->l4, 3), | ||||
|                              qdev_get_gpio_in(s->ih[0], | ||||
|   | ||||
| @@ -219,14 +219,12 @@ static QEMUMachine sx1_machine_v2 = { | ||||
|     .name = "sx1", | ||||
|     .desc = "Siemens SX1 (OMAP310) V2", | ||||
|     .init = sx1_init_v2, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static QEMUMachine sx1_machine_v1 = { | ||||
|     .name = "sx1-v1", | ||||
|     .desc = "Siemens SX1 (OMAP310) V1", | ||||
|     .init = sx1_init_v1, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void sx1_machine_init(void) | ||||
|   | ||||
| @@ -273,7 +273,6 @@ static QEMUMachine palmte_machine = { | ||||
|     .name = "cheetah", | ||||
|     .desc = "Palm Tungsten|E aka. Cheetah PDA (OMAP310)", | ||||
|     .init = palmte_init, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void palmte_machine_init(void) | ||||
|   | ||||
| @@ -1,68 +0,0 @@ | ||||
| /* | ||||
|  * Generic ARM Programmable Interrupt Controller support. | ||||
|  * | ||||
|  * Copyright (c) 2006 CodeSourcery. | ||||
|  * Written by Paul Brook | ||||
|  * | ||||
|  * This code is licensed under the LGPL | ||||
|  */ | ||||
|  | ||||
| #include "hw/hw.h" | ||||
| #include "hw/arm/arm.h" | ||||
| #include "sysemu/kvm.h" | ||||
|  | ||||
| /* Input 0 is IRQ and input 1 is FIQ.  */ | ||||
| static void arm_pic_cpu_handler(void *opaque, int irq, int level) | ||||
| { | ||||
|     ARMCPU *cpu = opaque; | ||||
|     CPUState *cs = CPU(cpu); | ||||
|  | ||||
|     switch (irq) { | ||||
|     case ARM_PIC_CPU_IRQ: | ||||
|         if (level) { | ||||
|             cpu_interrupt(cs, CPU_INTERRUPT_HARD); | ||||
|         } else { | ||||
|             cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); | ||||
|         } | ||||
|         break; | ||||
|     case ARM_PIC_CPU_FIQ: | ||||
|         if (level) { | ||||
|             cpu_interrupt(cs, CPU_INTERRUPT_FIQ); | ||||
|         } else { | ||||
|             cpu_reset_interrupt(cs, CPU_INTERRUPT_FIQ); | ||||
|         } | ||||
|         break; | ||||
|     default: | ||||
|         hw_error("arm_pic_cpu_handler: Bad interrupt line %d\n", irq); | ||||
|     } | ||||
| } | ||||
|  | ||||
| static void kvm_arm_pic_cpu_handler(void *opaque, int irq, int level) | ||||
| { | ||||
| #ifdef CONFIG_KVM | ||||
|     ARMCPU *cpu = opaque; | ||||
|     CPUState *cs = CPU(cpu); | ||||
|     int kvm_irq = KVM_ARM_IRQ_TYPE_CPU << KVM_ARM_IRQ_TYPE_SHIFT; | ||||
|  | ||||
|     switch (irq) { | ||||
|     case ARM_PIC_CPU_IRQ: | ||||
|         kvm_irq |= KVM_ARM_IRQ_CPU_IRQ; | ||||
|         break; | ||||
|     case ARM_PIC_CPU_FIQ: | ||||
|         kvm_irq |= KVM_ARM_IRQ_CPU_FIQ; | ||||
|         break; | ||||
|     default: | ||||
|         hw_error("kvm_arm_pic_cpu_handler: Bad interrupt line %d\n", irq); | ||||
|     } | ||||
|     kvm_irq |= cs->cpu_index << KVM_ARM_IRQ_VCPU_SHIFT; | ||||
|     kvm_set_irq(kvm_state, kvm_irq, level ? 1 : 0); | ||||
| #endif | ||||
| } | ||||
|  | ||||
| qemu_irq *arm_pic_init_cpu(ARMCPU *cpu) | ||||
| { | ||||
|     if (kvm_enabled()) { | ||||
|         return qemu_allocate_irqs(kvm_arm_pic_cpu_handler, cpu, 2); | ||||
|     } | ||||
|     return qemu_allocate_irqs(arm_pic_cpu_handler, cpu, 2); | ||||
| } | ||||
| @@ -56,7 +56,6 @@ static void realview_init(QEMUMachineInitArgs *args, | ||||
|     MemoryRegion *ram_hack = g_new(MemoryRegion, 1); | ||||
|     DeviceState *dev, *sysctl, *gpio2, *pl041; | ||||
|     SysBusDevice *busdev; | ||||
|     qemu_irq *irqp; | ||||
|     qemu_irq pic[64]; | ||||
|     qemu_irq mmc_irq[2]; | ||||
|     PCIBus *pci_bus = NULL; | ||||
| @@ -92,8 +91,7 @@ static void realview_init(QEMUMachineInitArgs *args, | ||||
|             fprintf(stderr, "Unable to find CPU definition\n"); | ||||
|             exit(1); | ||||
|         } | ||||
|         irqp = arm_pic_init_cpu(cpu); | ||||
|         cpu_irq[n] = irqp[ARM_PIC_CPU_IRQ]; | ||||
|         cpu_irq[n] = qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ); | ||||
|     } | ||||
|     env = &cpu->env; | ||||
|     if (arm_feature(env, ARM_FEATURE_V7)) { | ||||
| @@ -371,7 +369,6 @@ static QEMUMachine realview_eb_machine = { | ||||
|     .desc = "ARM RealView Emulation Baseboard (ARM926EJ-S)", | ||||
|     .init = realview_eb_init, | ||||
|     .block_default_type = IF_SCSI, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static QEMUMachine realview_eb_mpcore_machine = { | ||||
| @@ -380,14 +377,12 @@ static QEMUMachine realview_eb_mpcore_machine = { | ||||
|     .init = realview_eb_mpcore_init, | ||||
|     .block_default_type = IF_SCSI, | ||||
|     .max_cpus = 4, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static QEMUMachine realview_pb_a8_machine = { | ||||
|     .name = "realview-pb-a8", | ||||
|     .desc = "ARM RealView Platform Baseboard for Cortex-A8", | ||||
|     .init = realview_pb_a8_init, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static QEMUMachine realview_pbx_a9_machine = { | ||||
| @@ -396,7 +391,6 @@ static QEMUMachine realview_pbx_a9_machine = { | ||||
|     .init = realview_pbx_a9_init, | ||||
|     .block_default_type = IF_SCSI, | ||||
|     .max_cpus = 4, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void realview_machine_init(void) | ||||
|   | ||||
| @@ -966,28 +966,24 @@ static QEMUMachine akitapda_machine = { | ||||
|     .name = "akita", | ||||
|     .desc = "Akita PDA (PXA270)", | ||||
|     .init = akita_init, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static QEMUMachine spitzpda_machine = { | ||||
|     .name = "spitz", | ||||
|     .desc = "Spitz PDA (PXA270)", | ||||
|     .init = spitz_init, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static QEMUMachine borzoipda_machine = { | ||||
|     .name = "borzoi", | ||||
|     .desc = "Borzoi PDA (PXA270)", | ||||
|     .init = borzoi_init, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static QEMUMachine terrierpda_machine = { | ||||
|     .name = "terrier", | ||||
|     .desc = "Terrier PDA (PXA270)", | ||||
|     .init = terrier_init, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void spitz_machine_init(void) | ||||
|   | ||||
| @@ -1348,14 +1348,12 @@ static QEMUMachine lm3s811evb_machine = { | ||||
|     .name = "lm3s811evb", | ||||
|     .desc = "Stellaris LM3S811EVB", | ||||
|     .init = lm3s811evb_init, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static QEMUMachine lm3s6965evb_machine = { | ||||
|     .name = "lm3s6965evb", | ||||
|     .desc = "Stellaris LM3S6965EVB", | ||||
|     .init = lm3s6965evb_init, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void stellaris_machine_init(void) | ||||
|   | ||||
| @@ -1588,7 +1588,6 @@ StrongARMState *sa1110_init(MemoryRegion *sysmem, | ||||
|                             unsigned int sdram_size, const char *rev) | ||||
| { | ||||
|     StrongARMState *s; | ||||
|     qemu_irq *pic; | ||||
|     int i; | ||||
|  | ||||
|     s = g_malloc0(sizeof(StrongARMState)); | ||||
| @@ -1613,9 +1612,10 @@ StrongARMState *sa1110_init(MemoryRegion *sysmem, | ||||
|     vmstate_register_ram_global(&s->sdram); | ||||
|     memory_region_add_subregion(sysmem, SA_SDCS0, &s->sdram); | ||||
|  | ||||
|     pic = arm_pic_init_cpu(s->cpu); | ||||
|     s->pic = sysbus_create_varargs("strongarm_pic", 0x90050000, | ||||
|                     pic[ARM_PIC_CPU_IRQ], pic[ARM_PIC_CPU_FIQ], NULL); | ||||
|                     qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_IRQ), | ||||
|                     qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_FIQ), | ||||
|                     NULL); | ||||
|  | ||||
|     sysbus_create_varargs("pxa25x-timer", 0x90000000, | ||||
|                     qdev_get_gpio_in(s->pic, SA_PIC_OSTC0), | ||||
|   | ||||
| @@ -251,7 +251,6 @@ static QEMUMachine tosapda_machine = { | ||||
|     .name = "tosa", | ||||
|     .desc = "Tosa PDA (PXA255)", | ||||
|     .init = tosa_init, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void tosapda_machine_init(void) | ||||
|   | ||||
| @@ -178,7 +178,6 @@ static void versatile_init(QEMUMachineInitArgs *args, int board_id) | ||||
|     ARMCPU *cpu; | ||||
|     MemoryRegion *sysmem = get_system_memory(); | ||||
|     MemoryRegion *ram = g_new(MemoryRegion, 1); | ||||
|     qemu_irq *cpu_pic; | ||||
|     qemu_irq pic[32]; | ||||
|     qemu_irq sic[32]; | ||||
|     DeviceState *dev, *sysctl; | ||||
| @@ -211,10 +210,10 @@ static void versatile_init(QEMUMachineInitArgs *args, int board_id) | ||||
|     qdev_init_nofail(sysctl); | ||||
|     sysbus_mmio_map(SYS_BUS_DEVICE(sysctl), 0, 0x10000000); | ||||
|  | ||||
|     cpu_pic = arm_pic_init_cpu(cpu); | ||||
|     dev = sysbus_create_varargs("pl190", 0x10140000, | ||||
|                                 cpu_pic[ARM_PIC_CPU_IRQ], | ||||
|                                 cpu_pic[ARM_PIC_CPU_FIQ], NULL); | ||||
|                                 qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ), | ||||
|                                 qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_FIQ), | ||||
|                                 NULL); | ||||
|     for (n = 0; n < 32; n++) { | ||||
|         pic[n] = qdev_get_gpio_in(dev, n); | ||||
|     } | ||||
| @@ -368,7 +367,6 @@ static QEMUMachine versatilepb_machine = { | ||||
|     .desc = "ARM Versatile/PB (ARM926EJ-S)", | ||||
|     .init = vpb_init, | ||||
|     .block_default_type = IF_SCSI, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static QEMUMachine versatileab_machine = { | ||||
| @@ -376,7 +374,6 @@ static QEMUMachine versatileab_machine = { | ||||
|     .desc = "ARM Versatile/AB (ARM926EJ-S)", | ||||
|     .init = vab_init, | ||||
|     .block_default_type = IF_SCSI, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void versatile_machine_init(void) | ||||
|   | ||||
| @@ -183,7 +183,6 @@ static void a9_daughterboard_init(const VEDBoardInfo *daughterboard, | ||||
|     MemoryRegion *lowram = g_new(MemoryRegion, 1); | ||||
|     DeviceState *dev; | ||||
|     SysBusDevice *busdev; | ||||
|     qemu_irq *irqp; | ||||
|     int n; | ||||
|     qemu_irq cpu_irq[4]; | ||||
|     ram_addr_t low_ram_size; | ||||
| @@ -198,8 +197,7 @@ static void a9_daughterboard_init(const VEDBoardInfo *daughterboard, | ||||
|             fprintf(stderr, "Unable to find CPU definition\n"); | ||||
|             exit(1); | ||||
|         } | ||||
|         irqp = arm_pic_init_cpu(cpu); | ||||
|         cpu_irq[n] = irqp[ARM_PIC_CPU_IRQ]; | ||||
|         cpu_irq[n] = qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ); | ||||
|     } | ||||
|  | ||||
|     if (ram_size > 0x40000000) { | ||||
| @@ -312,15 +310,13 @@ static void a15_daughterboard_init(const VEDBoardInfo *daughterboard, | ||||
|  | ||||
|     for (n = 0; n < smp_cpus; n++) { | ||||
|         ARMCPU *cpu; | ||||
|         qemu_irq *irqp; | ||||
|  | ||||
|         cpu = cpu_arm_init(cpu_model); | ||||
|         if (!cpu) { | ||||
|             fprintf(stderr, "Unable to find CPU definition\n"); | ||||
|             exit(1); | ||||
|         } | ||||
|         irqp = arm_pic_init_cpu(cpu); | ||||
|         cpu_irq[n] = irqp[ARM_PIC_CPU_IRQ]; | ||||
|         cpu_irq[n] = qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ); | ||||
|     } | ||||
|  | ||||
|     { | ||||
| @@ -651,7 +647,6 @@ static QEMUMachine vexpress_a9_machine = { | ||||
|     .init = vexpress_a9_init, | ||||
|     .block_default_type = IF_SCSI, | ||||
|     .max_cpus = 4, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static QEMUMachine vexpress_a15_machine = { | ||||
| @@ -660,7 +655,6 @@ static QEMUMachine vexpress_a15_machine = { | ||||
|     .init = vexpress_a15_init, | ||||
|     .block_default_type = IF_SCSI, | ||||
|     .max_cpus = 4, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void vexpress_machine_init(void) | ||||
|   | ||||
| @@ -108,11 +108,9 @@ static void zynq_init(QEMUMachineInitArgs *args) | ||||
|     MemoryRegion *ocm_ram = g_new(MemoryRegion, 1); | ||||
|     DeviceState *dev; | ||||
|     SysBusDevice *busdev; | ||||
|     qemu_irq *irqp; | ||||
|     qemu_irq pic[64]; | ||||
|     NICInfo *nd; | ||||
|     int n; | ||||
|     qemu_irq cpu_irq; | ||||
|  | ||||
|     if (!cpu_model) { | ||||
|         cpu_model = "cortex-a9"; | ||||
| @@ -123,8 +121,6 @@ static void zynq_init(QEMUMachineInitArgs *args) | ||||
|         fprintf(stderr, "Unable to find CPU definition\n"); | ||||
|         exit(1); | ||||
|     } | ||||
|     irqp = arm_pic_init_cpu(cpu); | ||||
|     cpu_irq = irqp[ARM_PIC_CPU_IRQ]; | ||||
|  | ||||
|     /* max 2GB ram */ | ||||
|     if (ram_size > 0x80000000) { | ||||
| @@ -159,7 +155,8 @@ static void zynq_init(QEMUMachineInitArgs *args) | ||||
|     qdev_init_nofail(dev); | ||||
|     busdev = SYS_BUS_DEVICE(dev); | ||||
|     sysbus_mmio_map(busdev, 0, 0xF8F00000); | ||||
|     sysbus_connect_irq(busdev, 0, cpu_irq); | ||||
|     sysbus_connect_irq(busdev, 0, | ||||
|                        qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ)); | ||||
|  | ||||
|     for (n = 0; n < 64; n++) { | ||||
|         pic[n] = qdev_get_gpio_in(dev, n); | ||||
| @@ -236,7 +233,6 @@ static QEMUMachine zynq_machine = { | ||||
|     .block_default_type = IF_SCSI, | ||||
|     .max_cpus = 1, | ||||
|     .no_sdcard = 1, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void zynq_machine_init(void) | ||||
|   | ||||
| @@ -373,7 +373,6 @@ static QEMUMachine z2_machine = { | ||||
|     .name = "z2", | ||||
|     .desc = "Zipit Z2 (PXA27x)", | ||||
|     .init = z2_init, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void z2_machine_init(void) | ||||
|   | ||||
| @@ -261,11 +261,6 @@ static int process_request(IOQueue *ioq, struct iovec iov[], | ||||
|     } | ||||
| } | ||||
|  | ||||
| static int flush_true(EventNotifier *e) | ||||
| { | ||||
|     return true; | ||||
| } | ||||
|  | ||||
| static void handle_notify(EventNotifier *e) | ||||
| { | ||||
|     VirtIOBlockDataPlane *s = container_of(e, VirtIOBlockDataPlane, | ||||
| @@ -345,14 +340,6 @@ static void handle_notify(EventNotifier *e) | ||||
|     } | ||||
| } | ||||
|  | ||||
| static int flush_io(EventNotifier *e) | ||||
| { | ||||
|     VirtIOBlockDataPlane *s = container_of(e, VirtIOBlockDataPlane, | ||||
|                                            io_notifier); | ||||
|  | ||||
|     return s->num_reqs > 0; | ||||
| } | ||||
|  | ||||
| static void handle_io(EventNotifier *e) | ||||
| { | ||||
|     VirtIOBlockDataPlane *s = container_of(e, VirtIOBlockDataPlane, | ||||
| @@ -376,9 +363,9 @@ static void *data_plane_thread(void *opaque) | ||||
| { | ||||
|     VirtIOBlockDataPlane *s = opaque; | ||||
|  | ||||
|     do { | ||||
|     while (!s->stopping || s->num_reqs > 0) { | ||||
|         aio_poll(s->ctx, true); | ||||
|     } while (!s->stopping || s->num_reqs > 0); | ||||
|     } | ||||
|     return NULL; | ||||
| } | ||||
|  | ||||
| @@ -485,7 +472,7 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s) | ||||
|         exit(1); | ||||
|     } | ||||
|     s->host_notifier = *virtio_queue_get_host_notifier(vq); | ||||
|     aio_set_event_notifier(s->ctx, &s->host_notifier, handle_notify, flush_true); | ||||
|     aio_set_event_notifier(s->ctx, &s->host_notifier, handle_notify); | ||||
|  | ||||
|     /* Set up ioqueue */ | ||||
|     ioq_init(&s->ioqueue, s->fd, REQ_MAX); | ||||
| @@ -493,7 +480,7 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s) | ||||
|         ioq_put_iocb(&s->ioqueue, &s->requests[i].iocb); | ||||
|     } | ||||
|     s->io_notifier = *ioq_get_notifier(&s->ioqueue); | ||||
|     aio_set_event_notifier(s->ctx, &s->io_notifier, handle_io, flush_io); | ||||
|     aio_set_event_notifier(s->ctx, &s->io_notifier, handle_io); | ||||
|  | ||||
|     s->started = true; | ||||
|     trace_virtio_blk_data_plane_start(s); | ||||
| @@ -525,10 +512,10 @@ void virtio_blk_data_plane_stop(VirtIOBlockDataPlane *s) | ||||
|         qemu_thread_join(&s->thread); | ||||
|     } | ||||
|  | ||||
|     aio_set_event_notifier(s->ctx, &s->io_notifier, NULL, NULL); | ||||
|     aio_set_event_notifier(s->ctx, &s->io_notifier, NULL); | ||||
|     ioq_cleanup(&s->ioqueue); | ||||
|  | ||||
|     aio_set_event_notifier(s->ctx, &s->host_notifier, NULL, NULL); | ||||
|     aio_set_event_notifier(s->ctx, &s->host_notifier, NULL); | ||||
|     k->set_host_notifier(qbus->parent, 0, false); | ||||
|  | ||||
|     aio_context_unref(s->ctx); | ||||
|   | ||||
| @@ -54,6 +54,8 @@ | ||||
|  | ||||
| #include <zlib.h> | ||||
|  | ||||
| bool rom_file_in_ram = true; | ||||
|  | ||||
| static int roms_loaded; | ||||
|  | ||||
| /* return the size or -1 if error */ | ||||
| @@ -576,6 +578,7 @@ struct Rom { | ||||
|     size_t datasize; | ||||
|  | ||||
|     uint8_t *data; | ||||
|     MemoryRegion *mr; | ||||
|     int isrom; | ||||
|     char *fw_dir; | ||||
|     char *fw_file; | ||||
| @@ -605,6 +608,21 @@ static void rom_insert(Rom *rom) | ||||
|     QTAILQ_INSERT_TAIL(&roms, rom, next); | ||||
| } | ||||
|  | ||||
| static void *rom_set_mr(Rom *rom, Object *owner, const char *name) | ||||
| { | ||||
|     void *data; | ||||
|  | ||||
|     rom->mr = g_malloc(sizeof(*rom->mr)); | ||||
|     memory_region_init_ram(rom->mr, owner, name, rom->datasize); | ||||
|     memory_region_set_readonly(rom->mr, true); | ||||
|     vmstate_register_ram_global(rom->mr); | ||||
|  | ||||
|     data = memory_region_get_ram_ptr(rom->mr); | ||||
|     memcpy(data, rom->data, rom->datasize); | ||||
|  | ||||
|     return data; | ||||
| } | ||||
|  | ||||
| int rom_add_file(const char *file, const char *fw_dir, | ||||
|                  hwaddr addr, int32_t bootindex) | ||||
| { | ||||
| @@ -646,6 +664,7 @@ int rom_add_file(const char *file, const char *fw_dir, | ||||
|     if (rom->fw_file && fw_cfg) { | ||||
|         const char *basename; | ||||
|         char fw_file_name[56]; | ||||
|         void *data; | ||||
|  | ||||
|         basename = strrchr(rom->fw_file, '/'); | ||||
|         if (basename) { | ||||
| @@ -655,8 +674,15 @@ int rom_add_file(const char *file, const char *fw_dir, | ||||
|         } | ||||
|         snprintf(fw_file_name, sizeof(fw_file_name), "%s/%s", rom->fw_dir, | ||||
|                  basename); | ||||
|         fw_cfg_add_file(fw_cfg, fw_file_name, rom->data, rom->romsize); | ||||
|         snprintf(devpath, sizeof(devpath), "/rom@%s", fw_file_name); | ||||
|  | ||||
|         if (rom_file_in_ram) { | ||||
|             data = rom_set_mr(rom, OBJECT(fw_cfg), devpath); | ||||
|         } else { | ||||
|             data = rom->data; | ||||
|         } | ||||
|  | ||||
|         fw_cfg_add_file(fw_cfg, fw_file_name, data, rom->romsize); | ||||
|     } else { | ||||
|         snprintf(devpath, sizeof(devpath), "/rom@" TARGET_FMT_plx, addr); | ||||
|     } | ||||
| @@ -731,7 +757,12 @@ static void rom_reset(void *unused) | ||||
|         if (rom->data == NULL) { | ||||
|             continue; | ||||
|         } | ||||
|         cpu_physical_memory_write_rom(rom->addr, rom->data, rom->datasize); | ||||
|         if (rom->mr) { | ||||
|             void *host = memory_region_get_ram_ptr(rom->mr); | ||||
|             memcpy(host, rom->data, rom->datasize); | ||||
|         } else { | ||||
|             cpu_physical_memory_write_rom(rom->addr, rom->data, rom->datasize); | ||||
|         } | ||||
|         if (rom->isrom) { | ||||
|             /* rom needs to be written only once */ | ||||
|             g_free(rom->data); | ||||
| @@ -781,6 +812,9 @@ static Rom *find_rom(hwaddr addr) | ||||
|         if (rom->fw_file) { | ||||
|             continue; | ||||
|         } | ||||
|         if (rom->mr) { | ||||
|             continue; | ||||
|         } | ||||
|         if (rom->addr > addr) { | ||||
|             continue; | ||||
|         } | ||||
| @@ -808,6 +842,9 @@ int rom_copy(uint8_t *dest, hwaddr addr, size_t size) | ||||
|         if (rom->fw_file) { | ||||
|             continue; | ||||
|         } | ||||
|         if (rom->mr) { | ||||
|             continue; | ||||
|         } | ||||
|         if (rom->addr + rom->romsize < addr) { | ||||
|             continue; | ||||
|         } | ||||
| @@ -866,7 +903,13 @@ void do_info_roms(Monitor *mon, const QDict *qdict) | ||||
|     Rom *rom; | ||||
|  | ||||
|     QTAILQ_FOREACH(rom, &roms, next) { | ||||
|         if (!rom->fw_file) { | ||||
|         if (rom->mr) { | ||||
|             monitor_printf(mon, "%s" | ||||
|                            " size=0x%06zx name=\"%s\"\n", | ||||
|                            rom->mr->name, | ||||
|                            rom->romsize, | ||||
|                            rom->name); | ||||
|         } else if (!rom->fw_file) { | ||||
|             monitor_printf(mon, "addr=" TARGET_FMT_plx | ||||
|                            " size=0x%06zx mem=%s name=\"%s\"\n", | ||||
|                            rom->addr, rom->romsize, | ||||
|   | ||||
| @@ -24,7 +24,6 @@ static QEMUMachine machine_none = { | ||||
|     .desc = "empty machine", | ||||
|     .init = machine_none_init, | ||||
|     .max_cpus = 0, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void register_machines(void) | ||||
|   | ||||
| @@ -752,7 +752,6 @@ static void device_initfn(Object *obj) | ||||
|         } | ||||
|         class = object_class_get_parent(class); | ||||
|     } while (class != object_class_by_name(TYPE_DEVICE)); | ||||
|     qdev_prop_set_globals(dev, &err); | ||||
|     if (err != NULL) { | ||||
|         qerror_report_err(err); | ||||
|         error_free(err); | ||||
| @@ -764,6 +763,15 @@ static void device_initfn(Object *obj) | ||||
|     assert_no_error(err); | ||||
| } | ||||
|  | ||||
| static void device_post_init(Object *obj) | ||||
| { | ||||
|     DeviceState *dev = DEVICE(obj); | ||||
|     Error *err = NULL; | ||||
|  | ||||
|     qdev_prop_set_globals(dev, &err); | ||||
|     assert_no_error(err); | ||||
| } | ||||
|  | ||||
| /* Unlink device from bus and free the structure.  */ | ||||
| static void device_finalize(Object *obj) | ||||
| { | ||||
| @@ -853,6 +861,7 @@ static const TypeInfo device_type_info = { | ||||
|     .parent = TYPE_OBJECT, | ||||
|     .instance_size = sizeof(DeviceState), | ||||
|     .instance_init = device_initfn, | ||||
|     .instance_post_init = device_post_init, | ||||
|     .instance_finalize = device_finalize, | ||||
|     .class_base_init = device_class_base_init, | ||||
|     .class_init = device_class_init, | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| obj-$(CONFIG_ARM11MPCORE) += arm11mpcore.o | ||||
| obj-$(CONFIG_ARM9MPCORE) += a9mpcore.o | ||||
| obj-$(CONFIG_ARM15MPCORE) += a15mpcore.o | ||||
| obj-$(CONFIG_A9MPCORE) += a9mpcore.o | ||||
| obj-$(CONFIG_A15MPCORE) += a15mpcore.o | ||||
| obj-$(CONFIG_ICC_BUS) += icc_bus.o | ||||
|  | ||||
|   | ||||
| @@ -49,6 +49,8 @@ static int a15mp_priv_init(SysBusDevice *dev) | ||||
|     A15MPPrivState *s = A15MPCORE_PRIV(dev); | ||||
|     SysBusDevice *busdev; | ||||
|     const char *gictype = "arm_gic"; | ||||
|     int i; | ||||
|     CPUState *cpu; | ||||
|  | ||||
|     if (kvm_irqchip_in_kernel()) { | ||||
|         gictype = "kvm-arm-gic"; | ||||
| @@ -67,6 +69,22 @@ static int a15mp_priv_init(SysBusDevice *dev) | ||||
|     /* Pass through inbound GPIO lines to the GIC */ | ||||
|     qdev_init_gpio_in(DEVICE(dev), a15mp_priv_set_irq, s->num_irq - 32); | ||||
|  | ||||
|     /* Wire the outputs from each CPU's generic timer to the | ||||
|      * appropriate GIC PPI inputs | ||||
|      */ | ||||
|     for (i = 0, cpu = first_cpu; i < s->num_cpu; i++, cpu = cpu->next_cpu) { | ||||
|         DeviceState *cpudev = DEVICE(cpu); | ||||
|         int ppibase = s->num_irq - 32 + i * 32; | ||||
|         /* physical timer; we wire it up to the non-secure timer's ID, | ||||
|          * since a real A15 always has TrustZone but QEMU doesn't. | ||||
|          */ | ||||
|         qdev_connect_gpio_out(cpudev, 0, | ||||
|                               qdev_get_gpio_in(s->gic, ppibase + 30)); | ||||
|         /* virtual timer */ | ||||
|         qdev_connect_gpio_out(cpudev, 1, | ||||
|                               qdev_get_gpio_in(s->gic, ppibase + 27)); | ||||
|     } | ||||
|  | ||||
|     /* Memory map (addresses are offsets from PERIPHBASE): | ||||
|      *  0x0000-0x0fff -- reserved | ||||
|      *  0x1000-0x1fff -- GIC Distributor | ||||
|   | ||||
| @@ -355,7 +355,6 @@ static QEMUMachine axisdev88_machine = { | ||||
|     .desc = "AXIS devboard 88", | ||||
|     .init = axisdev88_init, | ||||
|     .is_default = 1, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void axisdev88_machine_init(void) | ||||
|   | ||||
| @@ -25,6 +25,7 @@ | ||||
| #include <glib.h> | ||||
|  | ||||
| #include "hw/hw.h" | ||||
| #include "hw/loader.h" | ||||
| #include "hw/i386/pc.h" | ||||
| #include "hw/i386/apic.h" | ||||
| #include "hw/pci/pci.h" | ||||
| @@ -60,17 +61,12 @@ static bool has_pvpanic; | ||||
| static bool has_pci_info = true; | ||||
|  | ||||
| /* PC hardware initialisation */ | ||||
| static void pc_init1(MemoryRegion *system_memory, | ||||
|                      MemoryRegion *system_io, | ||||
|                      ram_addr_t ram_size, | ||||
|                      const char *boot_device, | ||||
|                      const char *kernel_filename, | ||||
|                      const char *kernel_cmdline, | ||||
|                      const char *initrd_filename, | ||||
|                      const char *cpu_model, | ||||
| static void pc_init1(QEMUMachineInitArgs *args, | ||||
|                      int pci_enabled, | ||||
|                      int kvmclock_enabled) | ||||
| { | ||||
|     MemoryRegion *system_memory = get_system_memory(); | ||||
|     MemoryRegion *system_io = get_system_io(); | ||||
|     int i; | ||||
|     ram_addr_t below_4g_mem_size, above_4g_mem_size; | ||||
|     PCIBus *pci_bus; | ||||
| @@ -102,18 +98,18 @@ static void pc_init1(MemoryRegion *system_memory, | ||||
|     object_property_add_child(qdev_get_machine(), "icc-bridge", | ||||
|                               OBJECT(icc_bridge), NULL); | ||||
|  | ||||
|     pc_cpus_init(cpu_model, icc_bridge); | ||||
|     pc_cpus_init(args->cpu_model, icc_bridge); | ||||
|  | ||||
|     if (kvm_enabled() && kvmclock_enabled) { | ||||
|         kvmclock_create(); | ||||
|     } | ||||
|  | ||||
|     if (ram_size >= 0xe0000000 ) { | ||||
|         above_4g_mem_size = ram_size - 0xe0000000; | ||||
|     if (args->ram_size >= 0xe0000000) { | ||||
|         above_4g_mem_size = args->ram_size - 0xe0000000; | ||||
|         below_4g_mem_size = 0xe0000000; | ||||
|     } else { | ||||
|         above_4g_mem_size = 0; | ||||
|         below_4g_mem_size = ram_size; | ||||
|         below_4g_mem_size = args->ram_size; | ||||
|     } | ||||
|  | ||||
|     if (pci_enabled) { | ||||
| @@ -132,7 +128,8 @@ static void pc_init1(MemoryRegion *system_memory, | ||||
|     /* allocate ram and load rom/bios */ | ||||
|     if (!xen_enabled()) { | ||||
|         fw_cfg = pc_memory_init(system_memory, | ||||
|                        kernel_filename, kernel_cmdline, initrd_filename, | ||||
|                        args->kernel_filename, args->kernel_cmdline, | ||||
|                        args->initrd_filename, | ||||
|                        below_4g_mem_size, above_4g_mem_size, | ||||
|                        rom_memory, &ram_memory, guest_info); | ||||
|     } | ||||
| @@ -148,7 +145,7 @@ static void pc_init1(MemoryRegion *system_memory, | ||||
|  | ||||
|     if (pci_enabled) { | ||||
|         pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi, | ||||
|                               system_memory, system_io, ram_size, | ||||
|                               system_memory, system_io, args->ram_size, | ||||
|                               below_4g_mem_size, | ||||
|                               0x100000000ULL - below_4g_mem_size, | ||||
|                               above_4g_mem_size, | ||||
| @@ -207,7 +204,7 @@ static void pc_init1(MemoryRegion *system_memory, | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device, | ||||
|     pc_cmos_init(below_4g_mem_size, above_4g_mem_size, args->boot_order, | ||||
|                  floppy, idebus[0], idebus[1], rtc_state); | ||||
|  | ||||
|     if (pci_enabled && usb_enabled(false)) { | ||||
| @@ -236,95 +233,91 @@ static void pc_init1(MemoryRegion *system_memory, | ||||
|  | ||||
| static void pc_init_pci(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     ram_addr_t ram_size = args->ram_size; | ||||
|     const char *cpu_model = args->cpu_model; | ||||
|     const char *kernel_filename = args->kernel_filename; | ||||
|     const char *kernel_cmdline = args->kernel_cmdline; | ||||
|     const char *initrd_filename = args->initrd_filename; | ||||
|     const char *boot_device = args->boot_device; | ||||
|     pc_init1(get_system_memory(), | ||||
|              get_system_io(), | ||||
|              ram_size, boot_device, | ||||
|              kernel_filename, kernel_cmdline, | ||||
|              initrd_filename, cpu_model, 1, 1); | ||||
|     pc_init1(args, 1, 1); | ||||
| } | ||||
|  | ||||
| static void pc_compat_1_6(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     has_pci_info = false; | ||||
|     rom_file_in_ram = false; | ||||
| } | ||||
|  | ||||
| static void pc_compat_1_5(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     pc_compat_1_6(args); | ||||
|     has_pvpanic = true; | ||||
| } | ||||
|  | ||||
| static void pc_compat_1_4(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     pc_compat_1_5(args); | ||||
|     has_pvpanic = false; | ||||
|     x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE); | ||||
|     x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ); | ||||
| } | ||||
|  | ||||
| static void pc_compat_1_3(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     pc_compat_1_4(args); | ||||
|     enable_compat_apic_id_mode(); | ||||
| } | ||||
|  | ||||
| /* PC compat function for pc-0.14 to pc-1.2 */ | ||||
| static void pc_compat_1_2(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     pc_compat_1_3(args); | ||||
|     disable_kvm_pv_eoi(); | ||||
| } | ||||
|  | ||||
| static void pc_init_pci_1_6(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     has_pci_info = false; | ||||
|     pc_compat_1_6(args); | ||||
|     pc_init_pci(args); | ||||
| } | ||||
|  | ||||
| static void pc_init_pci_1_5(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     has_pvpanic = true; | ||||
|     pc_init_pci_1_6(args); | ||||
|     pc_compat_1_5(args); | ||||
|     pc_init_pci(args); | ||||
| } | ||||
|  | ||||
| static void pc_init_pci_1_4(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE); | ||||
|     x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ); | ||||
|     has_pci_info = false; | ||||
|     pc_compat_1_4(args); | ||||
|     pc_init_pci(args); | ||||
| } | ||||
|  | ||||
| static void pc_init_pci_1_3(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     enable_compat_apic_id_mode(); | ||||
|     pc_init_pci_1_4(args); | ||||
|     pc_compat_1_3(args); | ||||
|     pc_init_pci(args); | ||||
| } | ||||
|  | ||||
| /* PC machine init function for pc-1.1 to pc-1.2 */ | ||||
| /* PC machine init function for pc-0.14 to pc-1.2 */ | ||||
| static void pc_init_pci_1_2(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     disable_kvm_pv_eoi(); | ||||
|     pc_init_pci_1_3(args); | ||||
| } | ||||
|  | ||||
| /* PC machine init function for pc-0.14 to pc-1.0 */ | ||||
| static void pc_init_pci_1_0(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     pc_init_pci_1_2(args); | ||||
|     pc_compat_1_2(args); | ||||
|     pc_init_pci(args); | ||||
| } | ||||
|  | ||||
| /* PC init function for pc-0.10 to pc-0.13, and reused by xenfv */ | ||||
| static void pc_init_pci_no_kvmclock(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     ram_addr_t ram_size = args->ram_size; | ||||
|     const char *cpu_model = args->cpu_model; | ||||
|     const char *kernel_filename = args->kernel_filename; | ||||
|     const char *kernel_cmdline = args->kernel_cmdline; | ||||
|     const char *initrd_filename = args->initrd_filename; | ||||
|     const char *boot_device = args->boot_device; | ||||
|     has_pci_info = false; | ||||
|     disable_kvm_pv_eoi(); | ||||
|     enable_compat_apic_id_mode(); | ||||
|     pc_init1(get_system_memory(), | ||||
|              get_system_io(), | ||||
|              ram_size, boot_device, | ||||
|              kernel_filename, kernel_cmdline, | ||||
|              initrd_filename, cpu_model, 1, 0); | ||||
|     pc_init1(args, 1, 0); | ||||
| } | ||||
|  | ||||
| static void pc_init_isa(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     ram_addr_t ram_size = args->ram_size; | ||||
|     const char *cpu_model = args->cpu_model; | ||||
|     const char *kernel_filename = args->kernel_filename; | ||||
|     const char *kernel_cmdline = args->kernel_cmdline; | ||||
|     const char *initrd_filename = args->initrd_filename; | ||||
|     const char *boot_device = args->boot_device; | ||||
|     has_pci_info = false; | ||||
|     if (cpu_model == NULL) | ||||
|         cpu_model = "486"; | ||||
|     if (!args->cpu_model) { | ||||
|         args->cpu_model = "486"; | ||||
|     } | ||||
|     disable_kvm_pv_eoi(); | ||||
|     enable_compat_apic_id_mode(); | ||||
|     pc_init1(get_system_memory(), | ||||
|              get_system_io(), | ||||
|              ram_size, boot_device, | ||||
|              kernel_filename, kernel_cmdline, | ||||
|              initrd_filename, cpu_model, 0, 1); | ||||
|     pc_init1(args, 0, 1); | ||||
| } | ||||
|  | ||||
| #ifdef CONFIG_XEN | ||||
| @@ -341,40 +334,43 @@ static void pc_xen_hvm_init(QEMUMachineInitArgs *args) | ||||
| } | ||||
| #endif | ||||
|  | ||||
| #define PC_I440FX_MACHINE_OPTIONS \ | ||||
|     PC_DEFAULT_MACHINE_OPTIONS, \ | ||||
|     .desc = "Standard PC (i440FX + PIIX, 1996)", \ | ||||
|     .hot_add_cpu = pc_hot_add_cpu | ||||
|  | ||||
| #define PC_I440FX_1_6_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS | ||||
|  | ||||
| static QEMUMachine pc_i440fx_machine_v1_6 = { | ||||
|     PC_I440FX_1_6_MACHINE_OPTIONS, | ||||
|     .name = "pc-i440fx-1.6", | ||||
|     .alias = "pc", | ||||
|     .desc = "Standard PC (i440FX + PIIX, 1996)", | ||||
|     .init = pc_init_pci_1_6, | ||||
|     .hot_add_cpu = pc_hot_add_cpu, | ||||
|     .max_cpus = 255, | ||||
|     .is_default = 1, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static QEMUMachine pc_i440fx_machine_v1_5 = { | ||||
|     PC_I440FX_1_6_MACHINE_OPTIONS, | ||||
|     .name = "pc-i440fx-1.5", | ||||
|     .desc = "Standard PC (i440FX + PIIX, 1996)", | ||||
|     .init = pc_init_pci_1_5, | ||||
|     .hot_add_cpu = pc_hot_add_cpu, | ||||
|     .max_cpus = 255, | ||||
|     .compat_props = (GlobalProperty[]) { | ||||
|         PC_COMPAT_1_5, | ||||
|         { /* end of list */ } | ||||
|     }, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| #define PC_I440FX_1_4_MACHINE_OPTIONS \ | ||||
|     PC_I440FX_1_6_MACHINE_OPTIONS, \ | ||||
|     .hot_add_cpu = NULL | ||||
|  | ||||
| static QEMUMachine pc_i440fx_machine_v1_4 = { | ||||
|     PC_I440FX_1_4_MACHINE_OPTIONS, | ||||
|     .name = "pc-i440fx-1.4", | ||||
|     .desc = "Standard PC (i440FX + PIIX, 1996)", | ||||
|     .init = pc_init_pci_1_4, | ||||
|     .max_cpus = 255, | ||||
|     .compat_props = (GlobalProperty[]) { | ||||
|         PC_COMPAT_1_4, | ||||
|         { /* end of list */ } | ||||
|     }, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| #define PC_COMPAT_1_3 \ | ||||
| @@ -398,15 +394,13 @@ static QEMUMachine pc_i440fx_machine_v1_4 = { | ||||
|         } | ||||
|  | ||||
| static QEMUMachine pc_machine_v1_3 = { | ||||
|     PC_I440FX_1_4_MACHINE_OPTIONS, | ||||
|     .name = "pc-1.3", | ||||
|     .desc = "Standard PC", | ||||
|     .init = pc_init_pci_1_3, | ||||
|     .max_cpus = 255, | ||||
|     .compat_props = (GlobalProperty[]) { | ||||
|         PC_COMPAT_1_3, | ||||
|         { /* end of list */ } | ||||
|     }, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| #define PC_COMPAT_1_2 \ | ||||
| @@ -437,16 +431,17 @@ static QEMUMachine pc_machine_v1_3 = { | ||||
|             .value    = "off",\ | ||||
|         } | ||||
|  | ||||
| #define PC_I440FX_1_2_MACHINE_OPTIONS \ | ||||
|     PC_I440FX_1_4_MACHINE_OPTIONS, \ | ||||
|     .init = pc_init_pci_1_2 | ||||
|  | ||||
| static QEMUMachine pc_machine_v1_2 = { | ||||
|     PC_I440FX_1_2_MACHINE_OPTIONS, | ||||
|     .name = "pc-1.2", | ||||
|     .desc = "Standard PC", | ||||
|     .init = pc_init_pci_1_2, | ||||
|     .max_cpus = 255, | ||||
|     .compat_props = (GlobalProperty[]) { | ||||
|         PC_COMPAT_1_2, | ||||
|         { /* end of list */ } | ||||
|     }, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| #define PC_COMPAT_1_1 \ | ||||
| @@ -482,15 +477,12 @@ static QEMUMachine pc_machine_v1_2 = { | ||||
|         } | ||||
|  | ||||
| static QEMUMachine pc_machine_v1_1 = { | ||||
|     PC_I440FX_1_2_MACHINE_OPTIONS, | ||||
|     .name = "pc-1.1", | ||||
|     .desc = "Standard PC", | ||||
|     .init = pc_init_pci_1_2, | ||||
|     .max_cpus = 255, | ||||
|     .compat_props = (GlobalProperty[]) { | ||||
|         PC_COMPAT_1_1, | ||||
|         { /* end of list */ } | ||||
|     }, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| #define PC_COMPAT_1_0 \ | ||||
| @@ -514,32 +506,26 @@ static QEMUMachine pc_machine_v1_1 = { | ||||
|         } | ||||
|  | ||||
| static QEMUMachine pc_machine_v1_0 = { | ||||
|     PC_I440FX_1_2_MACHINE_OPTIONS, | ||||
|     .name = "pc-1.0", | ||||
|     .desc = "Standard PC", | ||||
|     .init = pc_init_pci_1_0, | ||||
|     .max_cpus = 255, | ||||
|     .compat_props = (GlobalProperty[]) { | ||||
|         PC_COMPAT_1_0, | ||||
|         { /* end of list */ } | ||||
|     }, | ||||
|     .hw_version = "1.0", | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| #define PC_COMPAT_0_15 \ | ||||
|         PC_COMPAT_1_0 | ||||
|  | ||||
| static QEMUMachine pc_machine_v0_15 = { | ||||
|     PC_I440FX_1_2_MACHINE_OPTIONS, | ||||
|     .name = "pc-0.15", | ||||
|     .desc = "Standard PC", | ||||
|     .init = pc_init_pci_1_0, | ||||
|     .max_cpus = 255, | ||||
|     .compat_props = (GlobalProperty[]) { | ||||
|         PC_COMPAT_0_15, | ||||
|         { /* end of list */ } | ||||
|     }, | ||||
|     .hw_version = "0.15", | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| #define PC_COMPAT_0_14 \ | ||||
| @@ -563,10 +549,8 @@ static QEMUMachine pc_machine_v0_15 = { | ||||
|         } | ||||
|  | ||||
| static QEMUMachine pc_machine_v0_14 = { | ||||
|     PC_I440FX_1_2_MACHINE_OPTIONS, | ||||
|     .name = "pc-0.14", | ||||
|     .desc = "Standard PC", | ||||
|     .init = pc_init_pci_1_0, | ||||
|     .max_cpus = 255, | ||||
|     .compat_props = (GlobalProperty[]) { | ||||
|         PC_COMPAT_0_14,  | ||||
|         { | ||||
| @@ -581,7 +565,6 @@ static QEMUMachine pc_machine_v0_14 = { | ||||
|         { /* end of list */ } | ||||
|     }, | ||||
|     .hw_version = "0.14", | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| #define PC_COMPAT_0_13 \ | ||||
| @@ -596,11 +579,13 @@ static QEMUMachine pc_machine_v0_14 = { | ||||
|             .value    = stringify(1),\ | ||||
|         } | ||||
|  | ||||
| #define PC_I440FX_0_13_MACHINE_OPTIONS \ | ||||
|     PC_I440FX_1_2_MACHINE_OPTIONS, \ | ||||
|     .init = pc_init_pci_no_kvmclock | ||||
|  | ||||
| static QEMUMachine pc_machine_v0_13 = { | ||||
|     PC_I440FX_0_13_MACHINE_OPTIONS, | ||||
|     .name = "pc-0.13", | ||||
|     .desc = "Standard PC", | ||||
|     .init = pc_init_pci_no_kvmclock, | ||||
|     .max_cpus = 255, | ||||
|     .compat_props = (GlobalProperty[]) { | ||||
|         PC_COMPAT_0_13, | ||||
|         { | ||||
| @@ -619,7 +604,6 @@ static QEMUMachine pc_machine_v0_13 = { | ||||
|         { /* end of list */ } | ||||
|     }, | ||||
|     .hw_version = "0.13", | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| #define PC_COMPAT_0_12 \ | ||||
| @@ -647,10 +631,8 @@ static QEMUMachine pc_machine_v0_13 = { | ||||
|         } | ||||
|  | ||||
| static QEMUMachine pc_machine_v0_12 = { | ||||
|     PC_I440FX_0_13_MACHINE_OPTIONS, | ||||
|     .name = "pc-0.12", | ||||
|     .desc = "Standard PC", | ||||
|     .init = pc_init_pci_no_kvmclock, | ||||
|     .max_cpus = 255, | ||||
|     .compat_props = (GlobalProperty[]) { | ||||
|         PC_COMPAT_0_12, | ||||
|         { | ||||
| @@ -665,7 +647,6 @@ static QEMUMachine pc_machine_v0_12 = { | ||||
|         { /* end of list */ } | ||||
|     }, | ||||
|     .hw_version = "0.12", | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| #define PC_COMPAT_0_11 \ | ||||
| @@ -681,10 +662,8 @@ static QEMUMachine pc_machine_v0_12 = { | ||||
|         } | ||||
|  | ||||
| static QEMUMachine pc_machine_v0_11 = { | ||||
|     PC_I440FX_0_13_MACHINE_OPTIONS, | ||||
|     .name = "pc-0.11", | ||||
|     .desc = "Standard PC, qemu 0.11", | ||||
|     .init = pc_init_pci_no_kvmclock, | ||||
|     .max_cpus = 255, | ||||
|     .compat_props = (GlobalProperty[]) { | ||||
|         PC_COMPAT_0_11, | ||||
|         { | ||||
| @@ -699,14 +678,11 @@ static QEMUMachine pc_machine_v0_11 = { | ||||
|         { /* end of list */ } | ||||
|     }, | ||||
|     .hw_version = "0.11", | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static QEMUMachine pc_machine_v0_10 = { | ||||
|     PC_I440FX_0_13_MACHINE_OPTIONS, | ||||
|     .name = "pc-0.10", | ||||
|     .desc = "Standard PC, qemu 0.10", | ||||
|     .init = pc_init_pci_no_kvmclock, | ||||
|     .max_cpus = 255, | ||||
|     .compat_props = (GlobalProperty[]) { | ||||
|         PC_COMPAT_0_11, | ||||
|         { | ||||
| @@ -733,10 +709,10 @@ static QEMUMachine pc_machine_v0_10 = { | ||||
|         { /* end of list */ } | ||||
|     }, | ||||
|     .hw_version = "0.10", | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static QEMUMachine isapc_machine = { | ||||
|     PC_COMMON_MACHINE_OPTIONS, | ||||
|     .name = "isapc", | ||||
|     .desc = "ISA-only PC", | ||||
|     .init = pc_init_isa, | ||||
| @@ -744,17 +720,16 @@ static QEMUMachine isapc_machine = { | ||||
|     .compat_props = (GlobalProperty[]) { | ||||
|         { /* end of list */ } | ||||
|     }, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| #ifdef CONFIG_XEN | ||||
| static QEMUMachine xenfv_machine = { | ||||
|     PC_COMMON_MACHINE_OPTIONS, | ||||
|     .name = "xenfv", | ||||
|     .desc = "Xen Fully-virtualized PC", | ||||
|     .init = pc_xen_hvm_init, | ||||
|     .max_cpus = HVM_MAX_VCPUS, | ||||
|     .default_machine_opts = "accel=xen", | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -28,6 +28,7 @@ | ||||
|  * THE SOFTWARE. | ||||
|  */ | ||||
| #include "hw/hw.h" | ||||
| #include "hw/loader.h" | ||||
| #include "sysemu/arch_init.h" | ||||
| #include "hw/i2c/smbus.h" | ||||
| #include "hw/boards.h" | ||||
| @@ -52,12 +53,6 @@ static bool has_pci_info = true; | ||||
| /* PC hardware initialisation */ | ||||
| static void pc_q35_init(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     ram_addr_t ram_size = args->ram_size; | ||||
|     const char *cpu_model = args->cpu_model; | ||||
|     const char *kernel_filename = args->kernel_filename; | ||||
|     const char *kernel_cmdline = args->kernel_cmdline; | ||||
|     const char *initrd_filename = args->initrd_filename; | ||||
|     const char *boot_device = args->boot_device; | ||||
|     ram_addr_t below_4g_mem_size, above_4g_mem_size; | ||||
|     Q35PCIHost *q35_host; | ||||
|     PCIHostState *phb; | ||||
| @@ -85,17 +80,17 @@ static void pc_q35_init(QEMUMachineInitArgs *args) | ||||
|     object_property_add_child(qdev_get_machine(), "icc-bridge", | ||||
|                               OBJECT(icc_bridge), NULL); | ||||
|  | ||||
|     pc_cpus_init(cpu_model, icc_bridge); | ||||
|     pc_cpus_init(args->cpu_model, icc_bridge); | ||||
|     pc_acpi_init("q35-acpi-dsdt.aml"); | ||||
|  | ||||
|     kvmclock_create(); | ||||
|  | ||||
|     if (ram_size >= 0xb0000000) { | ||||
|         above_4g_mem_size = ram_size - 0xb0000000; | ||||
|     if (args->ram_size >= 0xb0000000) { | ||||
|         above_4g_mem_size = args->ram_size - 0xb0000000; | ||||
|         below_4g_mem_size = 0xb0000000; | ||||
|     } else { | ||||
|         above_4g_mem_size = 0; | ||||
|         below_4g_mem_size = ram_size; | ||||
|         below_4g_mem_size = args->ram_size; | ||||
|     } | ||||
|  | ||||
|     /* pci enabled */ | ||||
| @@ -114,8 +109,10 @@ static void pc_q35_init(QEMUMachineInitArgs *args) | ||||
|  | ||||
|     /* allocate ram and load rom/bios */ | ||||
|     if (!xen_enabled()) { | ||||
|         pc_memory_init(get_system_memory(), kernel_filename, kernel_cmdline, | ||||
|                        initrd_filename, below_4g_mem_size, above_4g_mem_size, | ||||
|         pc_memory_init(get_system_memory(), | ||||
|                        args->kernel_filename, args->kernel_cmdline, | ||||
|                        args->initrd_filename, | ||||
|                        below_4g_mem_size, above_4g_mem_size, | ||||
|                        rom_memory, &ram_memory, guest_info); | ||||
|     } | ||||
|  | ||||
| @@ -203,7 +200,7 @@ static void pc_q35_init(QEMUMachineInitArgs *args) | ||||
|                                     0xb100), | ||||
|                       8, NULL, 0); | ||||
|  | ||||
|     pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device, | ||||
|     pc_cmos_init(below_4g_mem_size, above_4g_mem_size, args->boot_order, | ||||
|                  floppy, idebus[0], idebus[1], rtc_state); | ||||
|  | ||||
|     /* the rest devices to which pci devfn is automatically assigned */ | ||||
| @@ -218,59 +215,80 @@ static void pc_q35_init(QEMUMachineInitArgs *args) | ||||
|     } | ||||
| } | ||||
|  | ||||
| static void pc_q35_init_1_6(QEMUMachineInitArgs *args) | ||||
| static void pc_compat_1_6(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     has_pci_info = false; | ||||
|     rom_file_in_ram = false; | ||||
| } | ||||
|  | ||||
| static void pc_compat_1_5(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     pc_compat_1_6(args); | ||||
|     has_pvpanic = true; | ||||
| } | ||||
|  | ||||
| static void pc_compat_1_4(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     pc_compat_1_5(args); | ||||
|     has_pvpanic = false; | ||||
|     x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE); | ||||
|     x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ); | ||||
| } | ||||
|  | ||||
| static void pc_q35_init_1_6(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     pc_compat_1_6(args); | ||||
|     pc_q35_init(args); | ||||
| } | ||||
|  | ||||
| static void pc_q35_init_1_5(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     has_pvpanic = true; | ||||
|     pc_q35_init_1_6(args); | ||||
|     pc_compat_1_5(args); | ||||
|     pc_q35_init(args); | ||||
| } | ||||
|  | ||||
| static void pc_q35_init_1_4(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE); | ||||
|     x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ); | ||||
|     has_pci_info = false; | ||||
|     pc_compat_1_4(args); | ||||
|     pc_q35_init(args); | ||||
| } | ||||
|  | ||||
| #define PC_Q35_MACHINE_OPTIONS \ | ||||
|     PC_DEFAULT_MACHINE_OPTIONS, \ | ||||
|     .desc = "Standard PC (Q35 + ICH9, 2009)", \ | ||||
|     .hot_add_cpu = pc_hot_add_cpu | ||||
|  | ||||
| #define PC_Q35_1_6_MACHINE_OPTIONS PC_Q35_MACHINE_OPTIONS | ||||
|  | ||||
| static QEMUMachine pc_q35_machine_v1_6 = { | ||||
|     PC_Q35_1_6_MACHINE_OPTIONS, | ||||
|     .name = "pc-q35-1.6", | ||||
|     .alias = "q35", | ||||
|     .desc = "Standard PC (Q35 + ICH9, 2009)", | ||||
|     .init = pc_q35_init_1_6, | ||||
|     .hot_add_cpu = pc_hot_add_cpu, | ||||
|     .max_cpus = 255, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static QEMUMachine pc_q35_machine_v1_5 = { | ||||
|     PC_Q35_1_6_MACHINE_OPTIONS, | ||||
|     .name = "pc-q35-1.5", | ||||
|     .desc = "Standard PC (Q35 + ICH9, 2009)", | ||||
|     .init = pc_q35_init_1_5, | ||||
|     .hot_add_cpu = pc_hot_add_cpu, | ||||
|     .max_cpus = 255, | ||||
|     .compat_props = (GlobalProperty[]) { | ||||
|         PC_COMPAT_1_5, | ||||
|         { /* end of list */ } | ||||
|     }, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| #define PC_Q35_1_4_MACHINE_OPTIONS \ | ||||
|     PC_Q35_1_6_MACHINE_OPTIONS, \ | ||||
|     .hot_add_cpu = NULL | ||||
|  | ||||
| static QEMUMachine pc_q35_machine_v1_4 = { | ||||
|     PC_Q35_1_4_MACHINE_OPTIONS, | ||||
|     .name = "pc-q35-1.4", | ||||
|     .desc = "Standard PC (Q35 + ICH9, 2009)", | ||||
|     .init = pc_q35_init_1_4, | ||||
|     .max_cpus = 255, | ||||
|     .compat_props = (GlobalProperty[]) { | ||||
|         PC_COMPAT_1_4, | ||||
|         { /* end of list */ } | ||||
|     }, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void pc_q35_machine_init(void) | ||||
|   | ||||
| @@ -99,7 +99,6 @@ static QEMUMachine xenpv_machine = { | ||||
|     .init = xen_init_pv, | ||||
|     .max_cpus = 1, | ||||
|     .default_machine_opts = "accel=xen", | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void xenpv_machine_init(void) | ||||
|   | ||||
| @@ -289,7 +289,6 @@ static QEMUMachine lm32_evr_machine = { | ||||
|     .desc = "LatticeMico32 EVR32 eval system", | ||||
|     .init = lm32_evr_init, | ||||
|     .is_default = 1, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static QEMUMachine lm32_uclinux_machine = { | ||||
| @@ -297,7 +296,6 @@ static QEMUMachine lm32_uclinux_machine = { | ||||
|     .desc = "lm32 platform for uClinux and u-boot by Theobroma Systems", | ||||
|     .init = lm32_uclinux_init, | ||||
|     .is_default = 0, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void lm32_machine_init(void) | ||||
|   | ||||
| @@ -208,7 +208,6 @@ static QEMUMachine milkymist_machine = { | ||||
|     .desc = "Milkymist One", | ||||
|     .init = milkymist_init, | ||||
|     .is_default = 0, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void milkymist_machine_init(void) | ||||
|   | ||||
| @@ -89,7 +89,6 @@ static QEMUMachine an5206_machine = { | ||||
|     .name = "an5206", | ||||
|     .desc = "Arnewsh 5206", | ||||
|     .init = an5206_init, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void an5206_machine_init(void) | ||||
|   | ||||
| @@ -73,7 +73,6 @@ static QEMUMachine dummy_m68k_machine = { | ||||
|     .name = "dummy", | ||||
|     .desc = "Dummy board", | ||||
|     .init = dummy_m68k_init, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void dummy_m68k_machine_init(void) | ||||
|   | ||||
| @@ -295,7 +295,6 @@ static QEMUMachine mcf5208evb_machine = { | ||||
|     .desc = "MCF5206EVB", | ||||
|     .init = mcf5208evb_init, | ||||
|     .is_default = 1, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void mcf5208evb_machine_init(void) | ||||
|   | ||||
| @@ -186,7 +186,6 @@ static QEMUMachine petalogix_ml605_machine = { | ||||
|     .desc = "PetaLogix linux refdesign for xilinx ml605 little endian", | ||||
|     .init = petalogix_ml605_init, | ||||
|     .is_default = 0, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void petalogix_ml605_machine_init(void) | ||||
|   | ||||
| @@ -116,7 +116,6 @@ static QEMUMachine petalogix_s3adsp1800_machine = { | ||||
|     .desc = "PetaLogix linux refdesign for xilinx Spartan 3ADSP1800", | ||||
|     .init = petalogix_s3adsp1800_init, | ||||
|     .is_default = 1, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void petalogix_s3adsp1800_machine_init(void) | ||||
|   | ||||
| @@ -403,7 +403,6 @@ static QEMUMachine mips_fulong2e_machine = { | ||||
|     .name = "fulong2e", | ||||
|     .desc = "Fulong 2e mini pc", | ||||
|     .init = mips_fulong2e_init, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void mips_fulong2e_machine_init(void) | ||||
|   | ||||
| @@ -327,7 +327,6 @@ static QEMUMachine mips_magnum_machine = { | ||||
|     .desc = "MIPS Magnum", | ||||
|     .init = mips_magnum_init, | ||||
|     .block_default_type = IF_SCSI, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static QEMUMachine mips_pica61_machine = { | ||||
| @@ -335,7 +334,6 @@ static QEMUMachine mips_pica61_machine = { | ||||
|     .desc = "Acer Pica 61", | ||||
|     .init = mips_pica61_init, | ||||
|     .block_default_type = IF_SCSI, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void mips_jazz_machine_init(void) | ||||
|   | ||||
| @@ -1136,7 +1136,6 @@ static QEMUMachine mips_malta_machine = { | ||||
|     .init = mips_malta_init, | ||||
|     .max_cpus = 16, | ||||
|     .is_default = 1, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void mips_malta_register_types(void) | ||||
|   | ||||
| @@ -232,7 +232,6 @@ static QEMUMachine mips_mipssim_machine = { | ||||
|     .name = "mipssim", | ||||
|     .desc = "MIPS MIPSsim platform", | ||||
|     .init = mips_mipssim_init, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void mips_mipssim_machine_init(void) | ||||
|   | ||||
| @@ -306,7 +306,6 @@ static QEMUMachine mips_machine = { | ||||
|     .name = "mips", | ||||
|     .desc = "mips r4k platform", | ||||
|     .init = mips_r4k_init, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void mips_machine_init(void) | ||||
|   | ||||
| @@ -139,7 +139,6 @@ static QEMUMachine openrisc_sim_machine = { | ||||
|     .init = openrisc_sim_init, | ||||
|     .max_cpus = 1, | ||||
|     .is_default = 1, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void openrisc_sim_machine_init(void) | ||||
|   | ||||
| @@ -320,6 +320,7 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, | ||||
|     PCII440FXState *f; | ||||
|     unsigned i; | ||||
|     I440FXState *i440fx; | ||||
|     uint64_t pci_hole64_size; | ||||
|  | ||||
|     dev = qdev_create(NULL, TYPE_I440FX_PCI_HOST_BRIDGE); | ||||
|     s = PCI_HOST_BRIDGE(dev); | ||||
| @@ -351,13 +352,15 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, | ||||
|                              pci_hole_start, pci_hole_size); | ||||
|     memory_region_add_subregion(f->system_memory, pci_hole_start, &f->pci_hole); | ||||
|  | ||||
|     pci_hole64_size = pci_host_get_hole64_size(i440fx->pci_hole64_size); | ||||
|  | ||||
|     pc_init_pci64_hole(&i440fx->pci_info, 0x100000000ULL + above_4g_mem_size, | ||||
|                        i440fx->pci_hole64_size); | ||||
|                        pci_hole64_size); | ||||
|     memory_region_init_alias(&f->pci_hole_64bit, OBJECT(d), "pci-hole64", | ||||
|                              f->pci_address_space, | ||||
|                              i440fx->pci_info.w64.begin, | ||||
|                              i440fx->pci_hole64_size); | ||||
|     if (i440fx->pci_hole64_size) { | ||||
|                              pci_hole64_size); | ||||
|     if (pci_hole64_size) { | ||||
|         memory_region_add_subregion(f->system_memory, | ||||
|                                     i440fx->pci_info.w64.begin, | ||||
|                                     &f->pci_hole_64bit); | ||||
|   | ||||
| @@ -320,6 +320,7 @@ static int mch_init(PCIDevice *d) | ||||
| { | ||||
|     int i; | ||||
|     MCHPCIState *mch = MCH_PCI_DEVICE(d); | ||||
|     uint64_t pci_hole64_size; | ||||
|  | ||||
|     /* setup pci memory regions */ | ||||
|     memory_region_init_alias(&mch->pci_hole, OBJECT(mch), "pci-hole", | ||||
| @@ -329,13 +330,14 @@ static int mch_init(PCIDevice *d) | ||||
|     memory_region_add_subregion(mch->system_memory, mch->below_4g_mem_size, | ||||
|                                 &mch->pci_hole); | ||||
|  | ||||
|     pci_hole64_size = pci_host_get_hole64_size(mch->pci_hole64_size); | ||||
|     pc_init_pci64_hole(&mch->pci_info, 0x100000000ULL + mch->above_4g_mem_size, | ||||
|                        mch->pci_hole64_size); | ||||
|                        pci_hole64_size); | ||||
|     memory_region_init_alias(&mch->pci_hole_64bit, OBJECT(mch), "pci-hole64", | ||||
|                              mch->pci_address_space, | ||||
|                              mch->pci_info.w64.begin, | ||||
|                              mch->pci_hole64_size); | ||||
|     if (mch->pci_hole64_size) { | ||||
|                              pci_hole64_size); | ||||
|     if (pci_hole64_size) { | ||||
|         memory_region_add_subregion(mch->system_memory, | ||||
|                                     mch->pci_info.w64.begin, | ||||
|                                     &mch->pci_hole_64bit); | ||||
|   | ||||
							
								
								
									
										24
									
								
								hw/pci/pci.c
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								hw/pci/pci.c
									
									
									
									
									
								
							| @@ -812,12 +812,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, | ||||
|     } | ||||
|  | ||||
|     pci_dev->bus = bus; | ||||
|     if (bus->iommu_fn) { | ||||
|         dma_as = bus->iommu_fn(bus, bus->iommu_opaque, devfn); | ||||
|     } else { | ||||
|         /* FIXME: inherit memory region from bus creator */ | ||||
|         dma_as = &address_space_memory; | ||||
|     } | ||||
|     dma_as = pci_device_iommu_address_space(pci_dev); | ||||
|  | ||||
|     memory_region_init_alias(&pci_dev->bus_master_enable_region, | ||||
|                              OBJECT(pci_dev), "bus master", | ||||
| @@ -2239,6 +2234,23 @@ static void pci_device_class_init(ObjectClass *klass, void *data) | ||||
|     k->props = pci_props; | ||||
| } | ||||
|  | ||||
| AddressSpace *pci_device_iommu_address_space(PCIDevice *dev) | ||||
| { | ||||
|     PCIBus *bus = PCI_BUS(dev->bus); | ||||
|  | ||||
|     if (bus->iommu_fn) { | ||||
|         return bus->iommu_fn(bus, bus->iommu_opaque, dev->devfn); | ||||
|     } | ||||
|  | ||||
|     if (bus->parent_dev) { | ||||
|         /** We are ignoring the bus master DMA bit of the bridge | ||||
|          *  as it would complicate things such as VFIO for no good reason */ | ||||
|         return pci_device_iommu_address_space(bus->parent_dev); | ||||
|     } | ||||
|  | ||||
|     return &address_space_memory; | ||||
| } | ||||
|  | ||||
| void pci_setup_iommu(PCIBus *bus, PCIIOMMUFunc fn, void *opaque) | ||||
| { | ||||
|     bus->iommu_fn = fn; | ||||
|   | ||||
| @@ -20,6 +20,7 @@ | ||||
|  | ||||
| #include "hw/pci/pci.h" | ||||
| #include "hw/pci/pci_host.h" | ||||
| #include "trace.h" | ||||
|  | ||||
| /* debug PCI */ | ||||
| //#define DEBUG_PCI | ||||
| @@ -51,14 +52,22 @@ void pci_host_config_write_common(PCIDevice *pci_dev, uint32_t addr, | ||||
|                                   uint32_t limit, uint32_t val, uint32_t len) | ||||
| { | ||||
|     assert(len <= 4); | ||||
|     trace_pci_cfg_write(pci_dev->name, PCI_SLOT(pci_dev->devfn), | ||||
|                         PCI_FUNC(pci_dev->devfn), addr, val); | ||||
|     pci_dev->config_write(pci_dev, addr, val, MIN(len, limit - addr)); | ||||
| } | ||||
|  | ||||
| uint32_t pci_host_config_read_common(PCIDevice *pci_dev, uint32_t addr, | ||||
|                                      uint32_t limit, uint32_t len) | ||||
| { | ||||
|     uint32_t ret; | ||||
|  | ||||
|     assert(len <= 4); | ||||
|     return pci_dev->config_read(pci_dev, addr, MIN(len, limit - addr)); | ||||
|     ret = pci_dev->config_read(pci_dev, addr, MIN(len, limit - addr)); | ||||
|     trace_pci_cfg_read(pci_dev->name, PCI_SLOT(pci_dev->devfn), | ||||
|                        PCI_FUNC(pci_dev->devfn), addr, ret); | ||||
|  | ||||
|     return ret; | ||||
| } | ||||
|  | ||||
| void pci_data_write(PCIBus *s, uint32_t addr, uint32_t val, int len) | ||||
|   | ||||
| @@ -124,13 +124,14 @@ static void dt_serial_create(void *fdt, unsigned long long offset, | ||||
| } | ||||
|  | ||||
| static int ppce500_load_device_tree(CPUPPCState *env, | ||||
|                                     QEMUMachineInitArgs *args, | ||||
|                                     PPCE500Params *params, | ||||
|                                     hwaddr addr, | ||||
|                                     hwaddr initrd_base, | ||||
|                                     hwaddr initrd_size) | ||||
| { | ||||
|     int ret = -1; | ||||
|     uint64_t mem_reg_property[] = { 0, cpu_to_be64(params->ram_size) }; | ||||
|     uint64_t mem_reg_property[] = { 0, cpu_to_be64(args->ram_size) }; | ||||
|     int fdt_size; | ||||
|     void *fdt; | ||||
|     uint8_t hypercall[16]; | ||||
| @@ -205,7 +206,7 @@ static int ppce500_load_device_tree(CPUPPCState *env, | ||||
|     } | ||||
|  | ||||
|     ret = qemu_devtree_setprop_string(fdt, "/chosen", "bootargs", | ||||
|                                       params->kernel_cmdline); | ||||
|                                       args->kernel_cmdline); | ||||
|     if (ret < 0) | ||||
|         fprintf(stderr, "couldn't set /chosen/bootargs\n"); | ||||
|  | ||||
| @@ -559,7 +560,7 @@ static qemu_irq *ppce500_init_mpic(PPCE500Params *params, MemoryRegion *ccsr, | ||||
|     return mpic; | ||||
| } | ||||
|  | ||||
| void ppce500_init(PPCE500Params *params) | ||||
| void ppce500_init(QEMUMachineInitArgs *args, PPCE500Params *params) | ||||
| { | ||||
|     MemoryRegion *address_space_mem = get_system_memory(); | ||||
|     MemoryRegion *ram = g_new(MemoryRegion, 1); | ||||
| @@ -584,8 +585,8 @@ void ppce500_init(PPCE500Params *params) | ||||
|     PPCE500CCSRState *ccsr; | ||||
|  | ||||
|     /* Setup CPUs */ | ||||
|     if (params->cpu_model == NULL) { | ||||
|         params->cpu_model = "e500v2_v30"; | ||||
|     if (args->cpu_model == NULL) { | ||||
|         args->cpu_model = "e500v2_v30"; | ||||
|     } | ||||
|  | ||||
|     irqs = g_malloc0(smp_cpus * sizeof(qemu_irq *)); | ||||
| @@ -595,7 +596,7 @@ void ppce500_init(PPCE500Params *params) | ||||
|         CPUState *cs; | ||||
|         qemu_irq *input; | ||||
|  | ||||
|         cpu = cpu_ppc_init(params->cpu_model); | ||||
|         cpu = cpu_ppc_init(args->cpu_model); | ||||
|         if (cpu == NULL) { | ||||
|             fprintf(stderr, "Unable to initialize CPU!\n"); | ||||
|             exit(1); | ||||
| @@ -634,7 +635,7 @@ void ppce500_init(PPCE500Params *params) | ||||
|  | ||||
|     /* Fixup Memory size on a alignment boundary */ | ||||
|     ram_size &= ~(RAM_SIZES_ALIGN - 1); | ||||
|     params->ram_size = ram_size; | ||||
|     args->ram_size = ram_size; | ||||
|  | ||||
|     /* Register Memory */ | ||||
|     memory_region_init_ram(ram, NULL, "mpc8544ds.ram", ram_size); | ||||
| @@ -701,11 +702,11 @@ void ppce500_init(PPCE500Params *params) | ||||
|     sysbus_create_simple("e500-spin", MPC8544_SPIN_BASE, NULL); | ||||
|  | ||||
|     /* Load kernel. */ | ||||
|     if (params->kernel_filename) { | ||||
|         kernel_size = load_uimage(params->kernel_filename, &entry, | ||||
|     if (args->kernel_filename) { | ||||
|         kernel_size = load_uimage(args->kernel_filename, &entry, | ||||
|                                   &loadaddr, NULL); | ||||
|         if (kernel_size < 0) { | ||||
|             kernel_size = load_elf(params->kernel_filename, NULL, NULL, | ||||
|             kernel_size = load_elf(args->kernel_filename, NULL, NULL, | ||||
|                                    &elf_entry, &elf_lowaddr, NULL, 1, | ||||
|                                    ELF_MACHINE, 0); | ||||
|             entry = elf_entry; | ||||
| @@ -714,7 +715,7 @@ void ppce500_init(PPCE500Params *params) | ||||
|         /* XXX try again as binary */ | ||||
|         if (kernel_size < 0) { | ||||
|             fprintf(stderr, "qemu: could not load kernel '%s'\n", | ||||
|                     params->kernel_filename); | ||||
|                     args->kernel_filename); | ||||
|             exit(1); | ||||
|         } | ||||
|  | ||||
| @@ -726,14 +727,14 @@ void ppce500_init(PPCE500Params *params) | ||||
|     } | ||||
|  | ||||
|     /* Load initrd. */ | ||||
|     if (params->initrd_filename) { | ||||
|     if (args->initrd_filename) { | ||||
|         initrd_base = (cur_base + INITRD_LOAD_PAD) & ~INITRD_PAD_MASK; | ||||
|         initrd_size = load_image_targphys(params->initrd_filename, initrd_base, | ||||
|         initrd_size = load_image_targphys(args->initrd_filename, initrd_base, | ||||
|                                           ram_size - initrd_base); | ||||
|  | ||||
|         if (initrd_size < 0) { | ||||
|             fprintf(stderr, "qemu: could not load initial ram disk '%s'\n", | ||||
|                     params->initrd_filename); | ||||
|                     args->initrd_filename); | ||||
|             exit(1); | ||||
|         } | ||||
|  | ||||
| @@ -741,12 +742,12 @@ void ppce500_init(PPCE500Params *params) | ||||
|     } | ||||
|  | ||||
|     /* If we're loading a kernel directly, we must load the device tree too. */ | ||||
|     if (params->kernel_filename) { | ||||
|     if (args->kernel_filename) { | ||||
|         struct boot_info *boot_info; | ||||
|         int dt_size; | ||||
|  | ||||
|         dt_size = ppce500_load_device_tree(env, params, dt_base, initrd_base, | ||||
|                                            initrd_size); | ||||
|         dt_size = ppce500_load_device_tree(env, args, params, dt_base, | ||||
|                                            initrd_base, initrd_size); | ||||
|         if (dt_size < 0) { | ||||
|             fprintf(stderr, "couldn't load device tree\n"); | ||||
|             exit(1); | ||||
|   | ||||
| @@ -1,25 +1,18 @@ | ||||
| #ifndef PPCE500_H | ||||
| #define PPCE500_H | ||||
|  | ||||
| #include "hw/boards.h" | ||||
|  | ||||
| typedef struct PPCE500Params { | ||||
|     /* Standard QEMU machine init params */ | ||||
|     ram_addr_t ram_size; | ||||
|     const char *boot_device; | ||||
|     const char *kernel_filename; | ||||
|     const char *kernel_cmdline; | ||||
|     const char *initrd_filename; | ||||
|     const char *cpu_model; | ||||
|     int pci_first_slot; | ||||
|     int pci_nr_slots; | ||||
|  | ||||
|     /* e500-specific params */ | ||||
|  | ||||
|     /* required -- must at least add toplevel board compatible */ | ||||
|     void (*fixup_devtree)(struct PPCE500Params *params, void *fdt); | ||||
|  | ||||
|     int mpic_version; | ||||
| } PPCE500Params; | ||||
|  | ||||
| void ppce500_init(PPCE500Params *params); | ||||
| void ppce500_init(QEMUMachineInitArgs *args, PPCE500Params *params); | ||||
|  | ||||
| #endif | ||||
|   | ||||
| @@ -30,19 +30,7 @@ static void e500plat_fixup_devtree(PPCE500Params *params, void *fdt) | ||||
|  | ||||
| static void e500plat_init(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     ram_addr_t ram_size = args->ram_size; | ||||
|     const char *boot_device = args->boot_device; | ||||
|     const char *cpu_model = args->cpu_model; | ||||
|     const char *kernel_filename = args->kernel_filename; | ||||
|     const char *kernel_cmdline = args->kernel_cmdline; | ||||
|     const char *initrd_filename = args->initrd_filename; | ||||
|     PPCE500Params params = { | ||||
|         .ram_size = ram_size, | ||||
|         .boot_device = boot_device, | ||||
|         .kernel_filename = kernel_filename, | ||||
|         .kernel_cmdline = kernel_cmdline, | ||||
|         .initrd_filename = initrd_filename, | ||||
|         .cpu_model = cpu_model, | ||||
|         .pci_first_slot = 0x1, | ||||
|         .pci_nr_slots = PCI_SLOT_MAX - 1, | ||||
|         .fixup_devtree = e500plat_fixup_devtree, | ||||
| @@ -55,7 +43,7 @@ static void e500plat_init(QEMUMachineInitArgs *args) | ||||
|         params.mpic_version = OPENPIC_MODEL_FSL_MPIC_20; | ||||
|     } | ||||
|  | ||||
|     ppce500_init(¶ms); | ||||
|     ppce500_init(args, ¶ms); | ||||
| } | ||||
|  | ||||
| static QEMUMachine e500plat_machine = { | ||||
| @@ -63,7 +51,6 @@ static QEMUMachine e500plat_machine = { | ||||
|     .desc = "generic paravirt e500 platform", | ||||
|     .init = e500plat_init, | ||||
|     .max_cpus = 32, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void e500plat_machine_init(void) | ||||
|   | ||||
| @@ -147,7 +147,7 @@ static void ppc_core99_init(QEMUMachineInitArgs *args) | ||||
|     const char *kernel_filename = args->kernel_filename; | ||||
|     const char *kernel_cmdline = args->kernel_cmdline; | ||||
|     const char *initrd_filename = args->initrd_filename; | ||||
|     const char *boot_device = args->boot_device; | ||||
|     const char *boot_device = args->boot_order; | ||||
|     PowerPCCPU *cpu = NULL; | ||||
|     CPUPPCState *env = NULL; | ||||
|     char *filename; | ||||
| @@ -477,7 +477,7 @@ static QEMUMachine core99_machine = { | ||||
|     .desc = "Mac99 based PowerMAC", | ||||
|     .init = ppc_core99_init, | ||||
|     .max_cpus = MAX_CPUS, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
|     .default_boot_order = "cd", | ||||
| }; | ||||
|  | ||||
| static void core99_machine_init(void) | ||||
|   | ||||
| @@ -78,7 +78,7 @@ static void ppc_heathrow_init(QEMUMachineInitArgs *args) | ||||
|     const char *kernel_filename = args->kernel_filename; | ||||
|     const char *kernel_cmdline = args->kernel_cmdline; | ||||
|     const char *initrd_filename = args->initrd_filename; | ||||
|     const char *boot_device = args->boot_device; | ||||
|     const char *boot_device = args->boot_order; | ||||
|     MemoryRegion *sysmem = get_system_memory(); | ||||
|     PowerPCCPU *cpu = NULL; | ||||
|     CPUPPCState *env = NULL; | ||||
| @@ -350,7 +350,7 @@ static QEMUMachine heathrow_machine = { | ||||
| #ifndef TARGET_PPC64 | ||||
|     .is_default = 1, | ||||
| #endif | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
|     .default_boot_order = "cd", /* TOFIX "cad" when Mac floppy is implemented */ | ||||
| }; | ||||
|  | ||||
| static void heathrow_machine_init(void) | ||||
|   | ||||
| @@ -28,26 +28,14 @@ static void mpc8544ds_fixup_devtree(PPCE500Params *params, void *fdt) | ||||
|  | ||||
| static void mpc8544ds_init(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     ram_addr_t ram_size = args->ram_size; | ||||
|     const char *boot_device = args->boot_device; | ||||
|     const char *cpu_model = args->cpu_model; | ||||
|     const char *kernel_filename = args->kernel_filename; | ||||
|     const char *kernel_cmdline = args->kernel_cmdline; | ||||
|     const char *initrd_filename = args->initrd_filename; | ||||
|     PPCE500Params params = { | ||||
|         .ram_size = ram_size, | ||||
|         .boot_device = boot_device, | ||||
|         .kernel_filename = kernel_filename, | ||||
|         .kernel_cmdline = kernel_cmdline, | ||||
|         .initrd_filename = initrd_filename, | ||||
|         .cpu_model = cpu_model, | ||||
|         .pci_first_slot = 0x11, | ||||
|         .pci_nr_slots = 2, | ||||
|         .fixup_devtree = mpc8544ds_fixup_devtree, | ||||
|         .mpic_version = OPENPIC_MODEL_FSL_MPIC_20, | ||||
|     }; | ||||
|  | ||||
|     ppce500_init(¶ms); | ||||
|     ppce500_init(args, ¶ms); | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -56,7 +44,6 @@ static QEMUMachine ppce500_machine = { | ||||
|     .desc = "mpc8544ds", | ||||
|     .init = mpc8544ds_init, | ||||
|     .max_cpus = 15, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void ppce500_machine_init(void) | ||||
|   | ||||
| @@ -362,7 +362,6 @@ static QEMUMachine ref405ep_machine = { | ||||
|     .name = "ref405ep", | ||||
|     .desc = "ref405ep", | ||||
|     .init = ref405ep_init, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| /*****************************************************************************/ | ||||
| @@ -650,7 +649,6 @@ static QEMUMachine taihu_machine = { | ||||
|     .name = "taihu", | ||||
|     .desc = "taihu", | ||||
|     .init = taihu_405ep_init, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void ppc405_machine_init(void) | ||||
|   | ||||
| @@ -296,7 +296,6 @@ static QEMUMachine bamboo_machine = { | ||||
|     .name = "bamboo", | ||||
|     .desc = "bamboo", | ||||
|     .init = bamboo_init, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void bamboo_machine_init(void) | ||||
|   | ||||
| @@ -452,7 +452,7 @@ static void ppc_prep_init(QEMUMachineInitArgs *args) | ||||
|     const char *kernel_filename = args->kernel_filename; | ||||
|     const char *kernel_cmdline = args->kernel_cmdline; | ||||
|     const char *initrd_filename = args->initrd_filename; | ||||
|     const char *boot_device = args->boot_device; | ||||
|     const char *boot_device = args->boot_order; | ||||
|     MemoryRegion *sysmem = get_system_memory(); | ||||
|     PowerPCCPU *cpu = NULL; | ||||
|     CPUPPCState *env = NULL; | ||||
| @@ -691,7 +691,7 @@ static QEMUMachine prep_machine = { | ||||
|     .desc = "PowerPC PREP platform", | ||||
|     .init = ppc_prep_init, | ||||
|     .max_cpus = MAX_CPUS, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
|     .default_boot_order = "cad", | ||||
| }; | ||||
|  | ||||
| static void prep_machine_init(void) | ||||
|   | ||||
| @@ -1071,7 +1071,7 @@ static void ppc_spapr_init(QEMUMachineInitArgs *args) | ||||
|     const char *kernel_filename = args->kernel_filename; | ||||
|     const char *kernel_cmdline = args->kernel_cmdline; | ||||
|     const char *initrd_filename = args->initrd_filename; | ||||
|     const char *boot_device = args->boot_device; | ||||
|     const char *boot_device = args->boot_order; | ||||
|     PowerPCCPU *cpu; | ||||
|     CPUPPCState *env; | ||||
|     PCIHostState *phb; | ||||
| @@ -1325,7 +1325,7 @@ static QEMUMachine spapr_machine = { | ||||
|     .block_default_type = IF_SCSI, | ||||
|     .max_cpus = MAX_CPUS, | ||||
|     .no_parallel = 1, | ||||
|     .boot_order = NULL, | ||||
|     .default_boot_order = NULL, | ||||
| }; | ||||
|  | ||||
| static void spapr_machine_init(void) | ||||
|   | ||||
| @@ -245,7 +245,6 @@ static QEMUMachine virtex_machine = { | ||||
|     .name = "virtex-ml507", | ||||
|     .desc = "Xilinx Virtex ML507 reference design", | ||||
|     .init = virtex_init, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void virtex_machine_init(void) | ||||
|   | ||||
| @@ -126,7 +126,6 @@ static QEMUMachine ccw_machine = { | ||||
|     .no_sdcard = 1, | ||||
|     .use_sclp = 1, | ||||
|     .max_cpus = 255, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void ccw_machine_init(void) | ||||
|   | ||||
| @@ -293,7 +293,6 @@ static QEMUMachine s390_machine = { | ||||
|     .use_virtcon = 1, | ||||
|     .max_cpus = 255, | ||||
|     .is_default = 1, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void s390_machine_init(void) | ||||
|   | ||||
| @@ -356,7 +356,6 @@ static QEMUMachine r2d_machine = { | ||||
|     .name = "r2d", | ||||
|     .desc = "r2d-plus board", | ||||
|     .init = r2d_init, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void r2d_machine_init(void) | ||||
|   | ||||
| @@ -96,7 +96,6 @@ static QEMUMachine shix_machine = { | ||||
|     .desc = "shix card", | ||||
|     .init = shix_init, | ||||
|     .is_default = 1, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void shix_machine_init(void) | ||||
|   | ||||
| @@ -216,7 +216,6 @@ static QEMUMachine leon3_generic_machine = { | ||||
|     .name     = "leon3_generic", | ||||
|     .desc     = "Leon-3 generic", | ||||
|     .init     = leon3_generic_hw_init, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void leon3_machine_init(void) | ||||
|   | ||||
							
								
								
									
										131
									
								
								hw/sparc/sun4m.c
									
									
									
									
									
								
							
							
						
						
									
										131
									
								
								hw/sparc/sun4m.c
									
									
									
									
									
								
							| @@ -836,12 +836,10 @@ static void dummy_fdc_tc(void *opaque, int irq, int level) | ||||
| { | ||||
| } | ||||
|  | ||||
| static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size, | ||||
|                           const char *boot_device, | ||||
|                           const char *kernel_filename, | ||||
|                           const char *kernel_cmdline, | ||||
|                           const char *initrd_filename, const char *cpu_model) | ||||
| static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, | ||||
|                           QEMUMachineInitArgs *args) | ||||
| { | ||||
|     const char *cpu_model = args->cpu_model; | ||||
|     unsigned int i; | ||||
|     void *iommu, *espdma, *ledma, *nvram; | ||||
|     qemu_irq *cpu_irqs[MAX_CPUS], slavio_irq[32], slavio_cpu_irq[MAX_CPUS], | ||||
| @@ -867,10 +865,10 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size, | ||||
|  | ||||
|  | ||||
|     /* set up devices */ | ||||
|     ram_init(0, RAM_size, hwdef->max_mem); | ||||
|     ram_init(0, args->ram_size, hwdef->max_mem); | ||||
|     /* models without ECC don't trap when missing ram is accessed */ | ||||
|     if (!hwdef->ecc_base) { | ||||
|         empty_slot_init(RAM_size, hwdef->max_mem - RAM_size); | ||||
|         empty_slot_init(args->ram_size, hwdef->max_mem - args->ram_size); | ||||
|     } | ||||
|  | ||||
|     prom_init(hwdef->slavio_base, bios_name); | ||||
| @@ -993,11 +991,12 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size, | ||||
|         empty_slot_init(hwdef->bpp_base, 0x20); | ||||
|     } | ||||
|  | ||||
|     kernel_size = sun4m_load_kernel(kernel_filename, initrd_filename, | ||||
|                                     RAM_size); | ||||
|     kernel_size = sun4m_load_kernel(args->kernel_filename, | ||||
|                                     args->initrd_filename, | ||||
|                                     args->ram_size); | ||||
|  | ||||
|     nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline, | ||||
|                boot_device, RAM_size, kernel_size, graphic_width, | ||||
|     nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, args->kernel_cmdline, | ||||
|                args->boot_order, args->ram_size, kernel_size, graphic_width, | ||||
|                graphic_height, graphic_depth, hwdef->nvram_machine_id, | ||||
|                "Sun4m"); | ||||
|  | ||||
| @@ -1015,19 +1014,20 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size, | ||||
|     fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_HEIGHT, graphic_height); | ||||
|     fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, KERNEL_LOAD_ADDR); | ||||
|     fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size); | ||||
|     if (kernel_cmdline) { | ||||
|     if (args->kernel_cmdline) { | ||||
|         fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR); | ||||
|         pstrcpy_targphys("cmdline", CMDLINE_ADDR, TARGET_PAGE_SIZE, kernel_cmdline); | ||||
|         fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, kernel_cmdline); | ||||
|         pstrcpy_targphys("cmdline", CMDLINE_ADDR, TARGET_PAGE_SIZE, | ||||
|                          args->kernel_cmdline); | ||||
|         fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, args->kernel_cmdline); | ||||
|         fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, | ||||
|                        strlen(kernel_cmdline) + 1); | ||||
|                        strlen(args->kernel_cmdline) + 1); | ||||
|     } else { | ||||
|         fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0); | ||||
|         fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, 0); | ||||
|     } | ||||
|     fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, INITRD_LOAD_ADDR); | ||||
|     fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, 0); // not used | ||||
|     fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, boot_device[0]); | ||||
|     fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, args->boot_order[0]); | ||||
|     qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); | ||||
| } | ||||
|  | ||||
| @@ -1291,118 +1291,55 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = { | ||||
| /* SPARCstation 5 hardware initialisation */ | ||||
| static void ss5_init(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     ram_addr_t RAM_size = args->ram_size; | ||||
|     const char *cpu_model = args->cpu_model; | ||||
|     const char *kernel_filename = args->kernel_filename; | ||||
|     const char *kernel_cmdline = args->kernel_cmdline; | ||||
|     const char *initrd_filename = args->initrd_filename; | ||||
|     const char *boot_device = args->boot_device; | ||||
|     sun4m_hw_init(&sun4m_hwdefs[0], RAM_size, boot_device, kernel_filename, | ||||
|                   kernel_cmdline, initrd_filename, cpu_model); | ||||
|     sun4m_hw_init(&sun4m_hwdefs[0], args); | ||||
| } | ||||
|  | ||||
| /* SPARCstation 10 hardware initialisation */ | ||||
| static void ss10_init(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     ram_addr_t RAM_size = args->ram_size; | ||||
|     const char *cpu_model = args->cpu_model; | ||||
|     const char *kernel_filename = args->kernel_filename; | ||||
|     const char *kernel_cmdline = args->kernel_cmdline; | ||||
|     const char *initrd_filename = args->initrd_filename; | ||||
|     const char *boot_device = args->boot_device; | ||||
|     sun4m_hw_init(&sun4m_hwdefs[1], RAM_size, boot_device, kernel_filename, | ||||
|                   kernel_cmdline, initrd_filename, cpu_model); | ||||
|     sun4m_hw_init(&sun4m_hwdefs[1], args); | ||||
| } | ||||
|  | ||||
| /* SPARCserver 600MP hardware initialisation */ | ||||
| static void ss600mp_init(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     ram_addr_t RAM_size = args->ram_size; | ||||
|     const char *cpu_model = args->cpu_model; | ||||
|     const char *kernel_filename = args->kernel_filename; | ||||
|     const char *kernel_cmdline = args->kernel_cmdline; | ||||
|     const char *initrd_filename = args->initrd_filename; | ||||
|     const char *boot_device = args->boot_device; | ||||
|     sun4m_hw_init(&sun4m_hwdefs[2], RAM_size, boot_device, kernel_filename, | ||||
|                   kernel_cmdline, initrd_filename, cpu_model); | ||||
|     sun4m_hw_init(&sun4m_hwdefs[2], args); | ||||
| } | ||||
|  | ||||
| /* SPARCstation 20 hardware initialisation */ | ||||
| static void ss20_init(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     ram_addr_t RAM_size = args->ram_size; | ||||
|     const char *cpu_model = args->cpu_model; | ||||
|     const char *kernel_filename = args->kernel_filename; | ||||
|     const char *kernel_cmdline = args->kernel_cmdline; | ||||
|     const char *initrd_filename = args->initrd_filename; | ||||
|     const char *boot_device = args->boot_device; | ||||
|     sun4m_hw_init(&sun4m_hwdefs[3], RAM_size, boot_device, kernel_filename, | ||||
|                   kernel_cmdline, initrd_filename, cpu_model); | ||||
|     sun4m_hw_init(&sun4m_hwdefs[3], args); | ||||
| } | ||||
|  | ||||
| /* SPARCstation Voyager hardware initialisation */ | ||||
| static void vger_init(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     ram_addr_t RAM_size = args->ram_size; | ||||
|     const char *cpu_model = args->cpu_model; | ||||
|     const char *kernel_filename = args->kernel_filename; | ||||
|     const char *kernel_cmdline = args->kernel_cmdline; | ||||
|     const char *initrd_filename = args->initrd_filename; | ||||
|     const char *boot_device = args->boot_device; | ||||
|     sun4m_hw_init(&sun4m_hwdefs[4], RAM_size, boot_device, kernel_filename, | ||||
|                   kernel_cmdline, initrd_filename, cpu_model); | ||||
|     sun4m_hw_init(&sun4m_hwdefs[4], args); | ||||
| } | ||||
|  | ||||
| /* SPARCstation LX hardware initialisation */ | ||||
| static void ss_lx_init(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     ram_addr_t RAM_size = args->ram_size; | ||||
|     const char *cpu_model = args->cpu_model; | ||||
|     const char *kernel_filename = args->kernel_filename; | ||||
|     const char *kernel_cmdline = args->kernel_cmdline; | ||||
|     const char *initrd_filename = args->initrd_filename; | ||||
|     const char *boot_device = args->boot_device; | ||||
|     sun4m_hw_init(&sun4m_hwdefs[5], RAM_size, boot_device, kernel_filename, | ||||
|                   kernel_cmdline, initrd_filename, cpu_model); | ||||
|     sun4m_hw_init(&sun4m_hwdefs[5], args); | ||||
| } | ||||
|  | ||||
| /* SPARCstation 4 hardware initialisation */ | ||||
| static void ss4_init(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     ram_addr_t RAM_size = args->ram_size; | ||||
|     const char *cpu_model = args->cpu_model; | ||||
|     const char *kernel_filename = args->kernel_filename; | ||||
|     const char *kernel_cmdline = args->kernel_cmdline; | ||||
|     const char *initrd_filename = args->initrd_filename; | ||||
|     const char *boot_device = args->boot_device; | ||||
|     sun4m_hw_init(&sun4m_hwdefs[6], RAM_size, boot_device, kernel_filename, | ||||
|                   kernel_cmdline, initrd_filename, cpu_model); | ||||
|     sun4m_hw_init(&sun4m_hwdefs[6], args); | ||||
| } | ||||
|  | ||||
| /* SPARCClassic hardware initialisation */ | ||||
| static void scls_init(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     ram_addr_t RAM_size = args->ram_size; | ||||
|     const char *cpu_model = args->cpu_model; | ||||
|     const char *kernel_filename = args->kernel_filename; | ||||
|     const char *kernel_cmdline = args->kernel_cmdline; | ||||
|     const char *initrd_filename = args->initrd_filename; | ||||
|     const char *boot_device = args->boot_device; | ||||
|     sun4m_hw_init(&sun4m_hwdefs[7], RAM_size, boot_device, kernel_filename, | ||||
|                   kernel_cmdline, initrd_filename, cpu_model); | ||||
|     sun4m_hw_init(&sun4m_hwdefs[7], args); | ||||
| } | ||||
|  | ||||
| /* SPARCbook hardware initialisation */ | ||||
| static void sbook_init(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     ram_addr_t RAM_size = args->ram_size; | ||||
|     const char *cpu_model = args->cpu_model; | ||||
|     const char *kernel_filename = args->kernel_filename; | ||||
|     const char *kernel_cmdline = args->kernel_cmdline; | ||||
|     const char *initrd_filename = args->initrd_filename; | ||||
|     const char *boot_device = args->boot_device; | ||||
|     sun4m_hw_init(&sun4m_hwdefs[8], RAM_size, boot_device, kernel_filename, | ||||
|                   kernel_cmdline, initrd_filename, cpu_model); | ||||
|     sun4m_hw_init(&sun4m_hwdefs[8], args); | ||||
| } | ||||
|  | ||||
| static QEMUMachine ss5_machine = { | ||||
| @@ -1411,7 +1348,7 @@ static QEMUMachine ss5_machine = { | ||||
|     .init = ss5_init, | ||||
|     .block_default_type = IF_SCSI, | ||||
|     .is_default = 1, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
|     .default_boot_order = "c", | ||||
| }; | ||||
|  | ||||
| static QEMUMachine ss10_machine = { | ||||
| @@ -1420,7 +1357,7 @@ static QEMUMachine ss10_machine = { | ||||
|     .init = ss10_init, | ||||
|     .block_default_type = IF_SCSI, | ||||
|     .max_cpus = 4, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
|     .default_boot_order = "c", | ||||
| }; | ||||
|  | ||||
| static QEMUMachine ss600mp_machine = { | ||||
| @@ -1429,7 +1366,7 @@ static QEMUMachine ss600mp_machine = { | ||||
|     .init = ss600mp_init, | ||||
|     .block_default_type = IF_SCSI, | ||||
|     .max_cpus = 4, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
|     .default_boot_order = "c", | ||||
| }; | ||||
|  | ||||
| static QEMUMachine ss20_machine = { | ||||
| @@ -1438,7 +1375,7 @@ static QEMUMachine ss20_machine = { | ||||
|     .init = ss20_init, | ||||
|     .block_default_type = IF_SCSI, | ||||
|     .max_cpus = 4, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
|     .default_boot_order = "c", | ||||
| }; | ||||
|  | ||||
| static QEMUMachine voyager_machine = { | ||||
| @@ -1446,7 +1383,7 @@ static QEMUMachine voyager_machine = { | ||||
|     .desc = "Sun4m platform, SPARCstation Voyager", | ||||
|     .init = vger_init, | ||||
|     .block_default_type = IF_SCSI, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
|     .default_boot_order = "c", | ||||
| }; | ||||
|  | ||||
| static QEMUMachine ss_lx_machine = { | ||||
| @@ -1454,7 +1391,7 @@ static QEMUMachine ss_lx_machine = { | ||||
|     .desc = "Sun4m platform, SPARCstation LX", | ||||
|     .init = ss_lx_init, | ||||
|     .block_default_type = IF_SCSI, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
|     .default_boot_order = "c", | ||||
| }; | ||||
|  | ||||
| static QEMUMachine ss4_machine = { | ||||
| @@ -1462,7 +1399,7 @@ static QEMUMachine ss4_machine = { | ||||
|     .desc = "Sun4m platform, SPARCstation 4", | ||||
|     .init = ss4_init, | ||||
|     .block_default_type = IF_SCSI, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
|     .default_boot_order = "c", | ||||
| }; | ||||
|  | ||||
| static QEMUMachine scls_machine = { | ||||
| @@ -1470,7 +1407,7 @@ static QEMUMachine scls_machine = { | ||||
|     .desc = "Sun4m platform, SPARCClassic", | ||||
|     .init = scls_init, | ||||
|     .block_default_type = IF_SCSI, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
|     .default_boot_order = "c", | ||||
| }; | ||||
|  | ||||
| static QEMUMachine sbook_machine = { | ||||
| @@ -1478,7 +1415,7 @@ static QEMUMachine sbook_machine = { | ||||
|     .desc = "Sun4m platform, SPARCbook", | ||||
|     .init = sbook_init, | ||||
|     .block_default_type = IF_SCSI, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
|     .default_boot_order = "c", | ||||
| }; | ||||
|  | ||||
| static void sun4m_register_types(void) | ||||
|   | ||||
| @@ -811,10 +811,7 @@ static SPARCCPU *cpu_devinit(const char *cpu_model, const struct hwdef *hwdef) | ||||
| } | ||||
|  | ||||
| static void sun4uv_init(MemoryRegion *address_space_mem, | ||||
|                         ram_addr_t RAM_size, | ||||
|                         const char *boot_devices, | ||||
|                         const char *kernel_filename, const char *kernel_cmdline, | ||||
|                         const char *initrd_filename, const char *cpu_model, | ||||
|                         QEMUMachineInitArgs *args, | ||||
|                         const struct hwdef *hwdef) | ||||
| { | ||||
|     SPARCCPU *cpu; | ||||
| @@ -829,10 +826,10 @@ static void sun4uv_init(MemoryRegion *address_space_mem, | ||||
|     FWCfgState *fw_cfg; | ||||
|  | ||||
|     /* init CPUs */ | ||||
|     cpu = cpu_devinit(cpu_model, hwdef); | ||||
|     cpu = cpu_devinit(args->cpu_model, hwdef); | ||||
|  | ||||
|     /* set up devices */ | ||||
|     ram_init(0, RAM_size); | ||||
|     ram_init(0, args->ram_size); | ||||
|  | ||||
|     prom_init(hwdef->prom_addr, bios_name); | ||||
|  | ||||
| @@ -878,13 +875,15 @@ static void sun4uv_init(MemoryRegion *address_space_mem, | ||||
|  | ||||
|     initrd_size = 0; | ||||
|     initrd_addr = 0; | ||||
|     kernel_size = sun4u_load_kernel(kernel_filename, initrd_filename, | ||||
|     kernel_size = sun4u_load_kernel(args->kernel_filename, | ||||
|                                     args->initrd_filename, | ||||
|                                     ram_size, &initrd_size, &initrd_addr, | ||||
|                                     &kernel_addr, &kernel_entry); | ||||
|  | ||||
|     sun4u_NVRAM_set_params(nvram, NVRAM_SIZE, "Sun4u", RAM_size, boot_devices, | ||||
|     sun4u_NVRAM_set_params(nvram, NVRAM_SIZE, "Sun4u", args->ram_size, | ||||
|                            args->boot_order, | ||||
|                            kernel_addr, kernel_size, | ||||
|                            kernel_cmdline, | ||||
|                            args->kernel_cmdline, | ||||
|                            initrd_addr, initrd_size, | ||||
|                            /* XXX: need an option to load a NVRAM image */ | ||||
|                            0, | ||||
| @@ -898,16 +897,16 @@ static void sun4uv_init(MemoryRegion *address_space_mem, | ||||
|     fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id); | ||||
|     fw_cfg_add_i64(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_entry); | ||||
|     fw_cfg_add_i64(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size); | ||||
|     if (kernel_cmdline) { | ||||
|     if (args->kernel_cmdline) { | ||||
|         fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, | ||||
|                        strlen(kernel_cmdline) + 1); | ||||
|         fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, kernel_cmdline); | ||||
|                        strlen(args->kernel_cmdline) + 1); | ||||
|         fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, args->kernel_cmdline); | ||||
|     } else { | ||||
|         fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, 0); | ||||
|     } | ||||
|     fw_cfg_add_i64(fw_cfg, FW_CFG_INITRD_ADDR, initrd_addr); | ||||
|     fw_cfg_add_i64(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); | ||||
|     fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, boot_devices[0]); | ||||
|     fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, args->boot_order[0]); | ||||
|  | ||||
|     fw_cfg_add_i16(fw_cfg, FW_CFG_SPARC64_WIDTH, graphic_width); | ||||
|     fw_cfg_add_i16(fw_cfg, FW_CFG_SPARC64_HEIGHT, graphic_height); | ||||
| @@ -949,40 +948,19 @@ static const struct hwdef hwdefs[] = { | ||||
| /* Sun4u hardware initialisation */ | ||||
| static void sun4u_init(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     ram_addr_t RAM_size = args->ram_size; | ||||
|     const char *cpu_model = args->cpu_model; | ||||
|     const char *kernel_filename = args->kernel_filename; | ||||
|     const char *kernel_cmdline = args->kernel_cmdline; | ||||
|     const char *initrd_filename = args->initrd_filename; | ||||
|     const char *boot_devices = args->boot_device; | ||||
|     sun4uv_init(get_system_memory(), RAM_size, boot_devices, kernel_filename, | ||||
|                 kernel_cmdline, initrd_filename, cpu_model, &hwdefs[0]); | ||||
|     sun4uv_init(get_system_memory(), args, &hwdefs[0]); | ||||
| } | ||||
|  | ||||
| /* Sun4v hardware initialisation */ | ||||
| static void sun4v_init(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     ram_addr_t RAM_size = args->ram_size; | ||||
|     const char *cpu_model = args->cpu_model; | ||||
|     const char *kernel_filename = args->kernel_filename; | ||||
|     const char *kernel_cmdline = args->kernel_cmdline; | ||||
|     const char *initrd_filename = args->initrd_filename; | ||||
|     const char *boot_devices = args->boot_device; | ||||
|     sun4uv_init(get_system_memory(), RAM_size, boot_devices, kernel_filename, | ||||
|                 kernel_cmdline, initrd_filename, cpu_model, &hwdefs[1]); | ||||
|     sun4uv_init(get_system_memory(), args, &hwdefs[1]); | ||||
| } | ||||
|  | ||||
| /* Niagara hardware initialisation */ | ||||
| static void niagara_init(QEMUMachineInitArgs *args) | ||||
| { | ||||
|     ram_addr_t RAM_size = args->ram_size; | ||||
|     const char *cpu_model = args->cpu_model; | ||||
|     const char *kernel_filename = args->kernel_filename; | ||||
|     const char *kernel_cmdline = args->kernel_cmdline; | ||||
|     const char *initrd_filename = args->initrd_filename; | ||||
|     const char *boot_devices = args->boot_device; | ||||
|     sun4uv_init(get_system_memory(), RAM_size, boot_devices, kernel_filename, | ||||
|                 kernel_cmdline, initrd_filename, cpu_model, &hwdefs[2]); | ||||
|     sun4uv_init(get_system_memory(), args, &hwdefs[2]); | ||||
| } | ||||
|  | ||||
| static QEMUMachine sun4u_machine = { | ||||
| @@ -991,7 +969,7 @@ static QEMUMachine sun4u_machine = { | ||||
|     .init = sun4u_init, | ||||
|     .max_cpus = 1, // XXX for now | ||||
|     .is_default = 1, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
|     .default_boot_order = "c", | ||||
| }; | ||||
|  | ||||
| static QEMUMachine sun4v_machine = { | ||||
| @@ -999,7 +977,7 @@ static QEMUMachine sun4v_machine = { | ||||
|     .desc = "Sun4v platform", | ||||
|     .init = sun4v_init, | ||||
|     .max_cpus = 1, // XXX for now | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
|     .default_boot_order = "c", | ||||
| }; | ||||
|  | ||||
| static QEMUMachine niagara_machine = { | ||||
| @@ -1007,7 +985,7 @@ static QEMUMachine niagara_machine = { | ||||
|     .desc = "Sun4v platform, Niagara", | ||||
|     .init = niagara_init, | ||||
|     .max_cpus = 1, // XXX for now | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
|     .default_boot_order = "c", | ||||
| }; | ||||
|  | ||||
| static void sun4u_register_types(void) | ||||
|   | ||||
| @@ -43,7 +43,7 @@ static char const *imx_epit_reg_name(uint32_t reg) | ||||
| } | ||||
|  | ||||
| #  define DPRINTF(fmt, args...) \ | ||||
|           do { printf("%s: " fmt , __func__, ##args); } while (0) | ||||
|     do { fprintf(stderr, "%s: " fmt , __func__, ##args); } while (0) | ||||
| #else | ||||
| #  define DPRINTF(fmt, args...) do {} while (0) | ||||
| #endif | ||||
| @@ -152,7 +152,7 @@ static void imx_epit_reset(DeviceState *dev) | ||||
|     /* | ||||
|      * Soft reset doesn't touch some bits; hard reset clears them | ||||
|      */ | ||||
|     s->cr &= ~(CR_EN|CR_ENMOD|CR_STOPEN|CR_DOZEN|CR_WAITEN|CR_DBGEN); | ||||
|     s->cr &= (CR_EN|CR_ENMOD|CR_STOPEN|CR_DOZEN|CR_WAITEN|CR_DBGEN); | ||||
|     s->sr = 0; | ||||
|     s->lr = TIMER_MAX; | ||||
|     s->cmp = 0; | ||||
| @@ -167,7 +167,7 @@ static void imx_epit_reset(DeviceState *dev) | ||||
|     ptimer_set_limit(s->timer_reload, TIMER_MAX, 1); | ||||
|     if (s->freq && (s->cr & CR_EN)) { | ||||
|         /* if the timer is still enabled, restart it */ | ||||
|         ptimer_run(s->timer_reload, 1); | ||||
|         ptimer_run(s->timer_reload, 0); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @@ -218,17 +218,17 @@ static uint64_t imx_epit_read(void *opaque, hwaddr offset, unsigned size) | ||||
|  | ||||
| static void imx_epit_reload_compare_timer(IMXEPITState *s) | ||||
| { | ||||
|     if ((s->cr & CR_OCIEN) && s->cmp) { | ||||
|         /* if the compare feature is on */ | ||||
|     if ((s->cr & (CR_EN | CR_OCIEN)) == (CR_EN | CR_OCIEN))  { | ||||
|         /* if the compare feature is on and timers are running */ | ||||
|         uint32_t tmp = imx_epit_update_count(s); | ||||
|         uint64_t next; | ||||
|         if (tmp > s->cmp) { | ||||
|             /* reinit the cmp timer if required */ | ||||
|             ptimer_set_count(s->timer_cmp, tmp - s->cmp); | ||||
|             if ((s->cr & CR_EN)) { | ||||
|                 /* Restart the cmp timer if required */ | ||||
|                 ptimer_run(s->timer_cmp, 0); | ||||
|             } | ||||
|             /* It'll fire in this round of the timer */ | ||||
|             next = tmp - s->cmp; | ||||
|         } else { /* catch it next time around */ | ||||
|             next = tmp - s->cmp + ((s->cr & CR_RLD) ? TIMER_MAX : s->lr); | ||||
|         } | ||||
|         ptimer_set_count(s->timer_cmp, next); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @@ -237,11 +237,14 @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value, | ||||
| { | ||||
|     IMXEPITState *s = IMX_EPIT(opaque); | ||||
|     uint32_t reg = offset >> 2; | ||||
|     uint64_t oldcr; | ||||
|  | ||||
|     DPRINTF("(%s, value = 0x%08x)\n", imx_epit_reg_name(reg), (uint32_t)value); | ||||
|  | ||||
|     switch (reg) { | ||||
|     case 0: /* CR */ | ||||
|  | ||||
|         oldcr = s->cr; | ||||
|         s->cr = value & 0x03ffffff; | ||||
|         if (s->cr & CR_SWR) { | ||||
|             /* handle the reset */ | ||||
| @@ -250,22 +253,35 @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value, | ||||
|             imx_epit_set_freq(s); | ||||
|         } | ||||
|  | ||||
|         if (s->freq && (s->cr & CR_EN)) { | ||||
|         if (s->freq && (s->cr & CR_EN) && !(oldcr & CR_EN)) { | ||||
|             if (s->cr & CR_ENMOD) { | ||||
|                 if (s->cr & CR_RLD) { | ||||
|                     ptimer_set_limit(s->timer_reload, s->lr, 1); | ||||
|                     ptimer_set_limit(s->timer_cmp, s->lr, 1); | ||||
|                 } else { | ||||
|                     ptimer_set_limit(s->timer_reload, TIMER_MAX, 1); | ||||
|                     ptimer_set_limit(s->timer_cmp, TIMER_MAX, 1); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             imx_epit_reload_compare_timer(s); | ||||
|  | ||||
|             ptimer_run(s->timer_reload, 1); | ||||
|         } else { | ||||
|             ptimer_run(s->timer_reload, 0); | ||||
|             if (s->cr & CR_OCIEN) { | ||||
|                 ptimer_run(s->timer_cmp, 0); | ||||
|             } else { | ||||
|                 ptimer_stop(s->timer_cmp); | ||||
|             } | ||||
|         } else if (!(s->cr & CR_EN)) { | ||||
|             /* stop both timers */ | ||||
|             ptimer_stop(s->timer_reload); | ||||
|             ptimer_stop(s->timer_cmp); | ||||
|         } else  if (s->cr & CR_OCIEN) { | ||||
|             if (!(oldcr & CR_OCIEN)) { | ||||
|                 imx_epit_reload_compare_timer(s); | ||||
|                 ptimer_run(s->timer_cmp, 0); | ||||
|             } | ||||
|         } else { | ||||
|             ptimer_stop(s->timer_cmp); | ||||
|         } | ||||
|         break; | ||||
|  | ||||
| @@ -284,13 +300,13 @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value, | ||||
|             /* Also set the limit if the LRD bit is set */ | ||||
|             /* If IOVW bit is set then set the timer value */ | ||||
|             ptimer_set_limit(s->timer_reload, s->lr, s->cr & CR_IOVW); | ||||
|             ptimer_set_limit(s->timer_cmp, s->lr, 0); | ||||
|         } else if (s->cr & CR_IOVW) { | ||||
|             /* If IOVW bit is set then set the timer value */ | ||||
|             ptimer_set_count(s->timer_reload, s->lr); | ||||
|         } | ||||
|  | ||||
|         imx_epit_reload_compare_timer(s); | ||||
|  | ||||
|         break; | ||||
|  | ||||
|     case 3: /* CMP */ | ||||
| @@ -306,51 +322,14 @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value, | ||||
|         break; | ||||
|     } | ||||
| } | ||||
|  | ||||
| static void imx_epit_timeout(void *opaque) | ||||
| { | ||||
|     IMXEPITState *s = IMX_EPIT(opaque); | ||||
|  | ||||
|     DPRINTF("\n"); | ||||
|  | ||||
|     if (!(s->cr & CR_EN)) { | ||||
|         return; | ||||
|     } | ||||
|  | ||||
|     if (s->cr & CR_RLD) { | ||||
|         ptimer_set_limit(s->timer_reload, s->lr, 1); | ||||
|     } else { | ||||
|         ptimer_set_limit(s->timer_reload, TIMER_MAX, 1); | ||||
|     } | ||||
|  | ||||
|     if (s->cr & CR_OCIEN) { | ||||
|         /* if compare register is 0 then we handle the interrupt here */ | ||||
|         if (s->cmp == 0) { | ||||
|             s->sr = 1; | ||||
|             imx_epit_update_int(s); | ||||
|         } else if (s->cmp <= s->lr) { | ||||
|             /* We should launch the compare register */ | ||||
|             ptimer_set_count(s->timer_cmp, s->lr - s->cmp); | ||||
|             ptimer_run(s->timer_cmp, 0); | ||||
|         } else { | ||||
|             IPRINTF("s->lr < s->cmp\n"); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| static void imx_epit_cmp(void *opaque) | ||||
| { | ||||
|     IMXEPITState *s = IMX_EPIT(opaque); | ||||
|  | ||||
|     DPRINTF("\n"); | ||||
|     DPRINTF("sr was %d\n", s->sr); | ||||
|  | ||||
|     ptimer_stop(s->timer_cmp); | ||||
|  | ||||
|     /* compare register is not 0 */ | ||||
|     if (s->cmp) { | ||||
|         s->sr = 1; | ||||
|         imx_epit_update_int(s); | ||||
|     } | ||||
|     s->sr = 1; | ||||
|     imx_epit_update_int(s); | ||||
| } | ||||
|  | ||||
| void imx_timerp_create(const hwaddr addr, qemu_irq irq, DeviceState *ccm) | ||||
| @@ -400,8 +379,7 @@ static void imx_epit_realize(DeviceState *dev, Error **errp) | ||||
|                           0x00001000); | ||||
|     sysbus_init_mmio(sbd, &s->iomem); | ||||
|  | ||||
|     bh = qemu_bh_new(imx_epit_timeout, s); | ||||
|     s->timer_reload = ptimer_init(bh); | ||||
|     s->timer_reload = ptimer_init(NULL); | ||||
|  | ||||
|     bh = qemu_bh_new(imx_epit_cmp, s); | ||||
|     s->timer_cmp = ptimer_init(bh); | ||||
|   | ||||
| @@ -128,7 +128,6 @@ static QEMUMachine puv3_machine = { | ||||
|     .desc = "PKUnity Version-3 based on UniCore32", | ||||
|     .init = puv3_init, | ||||
|     .is_default = 1, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void puv3_machine_init(void) | ||||
|   | ||||
| @@ -799,8 +799,7 @@ static int virtio_pci_set_guest_notifiers(DeviceState *d, int nvqs, bool assign) | ||||
|             break; | ||||
|         } | ||||
|  | ||||
|         r = virtio_pci_set_guest_notifier(d, n, assign, | ||||
|                                           kvm_msi_via_irqfd_enabled()); | ||||
|         r = virtio_pci_set_guest_notifier(d, n, assign, with_irqfd); | ||||
|         if (r < 0) { | ||||
|             goto assign_error; | ||||
|         } | ||||
|   | ||||
| @@ -377,8 +377,8 @@ void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes, | ||||
|             /* loop over the indirect descriptor table */ | ||||
|             indirect = 1; | ||||
|             max = vring_desc_len(desc_pa, i) / sizeof(VRingDesc); | ||||
|             num_bufs = i = 0; | ||||
|             desc_pa = vring_desc_addr(desc_pa, i); | ||||
|             num_bufs = i = 0; | ||||
|         } | ||||
|  | ||||
|         do { | ||||
|   | ||||
| @@ -297,7 +297,6 @@ static QEMUMachine xtensa_lx60_machine = { | ||||
|     .desc = "lx60 EVB (" XTENSA_DEFAULT_CPU_MODEL ")", | ||||
|     .init = xtensa_lx60_init, | ||||
|     .max_cpus = 4, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static QEMUMachine xtensa_lx200_machine = { | ||||
| @@ -305,7 +304,6 @@ static QEMUMachine xtensa_lx200_machine = { | ||||
|     .desc = "lx200 EVB (" XTENSA_DEFAULT_CPU_MODEL ")", | ||||
|     .init = xtensa_lx200_init, | ||||
|     .max_cpus = 4, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void xtensa_lx_machines_init(void) | ||||
|   | ||||
| @@ -108,7 +108,6 @@ static QEMUMachine xtensa_sim_machine = { | ||||
|     .is_default = true, | ||||
|     .init = xtensa_sim_init, | ||||
|     .max_cpus = 4, | ||||
|     DEFAULT_MACHINE_OPTIONS, | ||||
| }; | ||||
|  | ||||
| static void xtensa_sim_machine_init(void) | ||||
|   | ||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user