Statistics
| Branch: | Revision:

root / vl.h @ 1f04275e

History | View | Annotate | Download (19.4 kB)

1
/*
2
 * QEMU System Emulator header
3
 * 
4
 * Copyright (c) 2003 Fabrice Bellard
5
 * 
6
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7
 * of this software and associated documentation files (the "Software"), to deal
8
 * in the Software without restriction, including without limitation the rights
9
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
 * copies of the Software, and to permit persons to whom the Software is
11
 * furnished to do so, subject to the following conditions:
12
 *
13
 * The above copyright notice and this permission notice shall be included in
14
 * all copies or substantial portions of the Software.
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
 * THE SOFTWARE.
23
 */
24
#ifndef VL_H
25
#define VL_H
26

    
27
/* we put basic includes here to avoid repeating them in device drivers */
28
#include <stdlib.h>
29
#include <stdio.h>
30
#include <stdarg.h>
31
#include <string.h>
32
#include <inttypes.h>
33
#include <time.h>
34
#include <ctype.h>
35
#include <errno.h>
36
#include <unistd.h>
37
#include <fcntl.h>
38
#include <sys/stat.h>
39

    
40
#ifndef O_LARGEFILE
41
#define O_LARGEFILE 0
42
#endif
43
#ifndef O_BINARY
44
#define O_BINARY 0
45
#endif
46

    
47
#ifdef _WIN32
48
#define lseek64 _lseeki64
49
#endif
50

    
51
#include "cpu.h"
52

    
53
#ifndef glue
54
#define xglue(x, y) x ## y
55
#define glue(x, y) xglue(x, y)
56
#define stringify(s)        tostring(s)
57
#define tostring(s)        #s
58
#endif
59

    
60
#if defined(WORDS_BIGENDIAN)
61
static inline uint32_t be32_to_cpu(uint32_t v)
62
{
63
    return v;
64
}
65

    
66
static inline uint16_t be16_to_cpu(uint16_t v)
67
{
68
    return v;
69
}
70

    
71
static inline uint32_t cpu_to_be32(uint32_t v)
72
{
73
    return v;
74
}
75

    
76
static inline uint16_t cpu_to_be16(uint16_t v)
77
{
78
    return v;
79
}
80

    
81
static inline uint32_t le32_to_cpu(uint32_t v)
82
{
83
    return bswap32(v);
84
}
85

    
86
static inline uint16_t le16_to_cpu(uint16_t v)
87
{
88
    return bswap16(v);
89
}
90

    
91
static inline uint32_t cpu_to_le32(uint32_t v)
92
{
93
    return bswap32(v);
94
}
95

    
96
static inline uint16_t cpu_to_le16(uint16_t v)
97
{
98
    return bswap16(v);
99
}
100

    
101
#else
102

    
103
static inline uint32_t be32_to_cpu(uint32_t v)
104
{
105
    return bswap32(v);
106
}
107

    
108
static inline uint16_t be16_to_cpu(uint16_t v)
109
{
110
    return bswap16(v);
111
}
112

    
113
static inline uint32_t cpu_to_be32(uint32_t v)
114
{
115
    return bswap32(v);
116
}
117

    
118
static inline uint16_t cpu_to_be16(uint16_t v)
119
{
120
    return bswap16(v);
121
}
122

    
123
static inline uint32_t le32_to_cpu(uint32_t v)
124
{
125
    return v;
126
}
127

    
128
static inline uint16_t le16_to_cpu(uint16_t v)
129
{
130
    return v;
131
}
132

    
133
static inline uint32_t cpu_to_le32(uint32_t v)
134
{
135
    return v;
136
}
137

    
138
static inline uint16_t cpu_to_le16(uint16_t v)
139
{
140
    return v;
141
}
142
#endif
143

    
144

    
145
/* vl.c */
146
extern int reset_requested;
147

    
148
uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
149

    
150
void hw_error(const char *fmt, ...);
151

    
152
int load_image(const char *filename, uint8_t *addr);
153
extern const char *bios_dir;
154

    
155
void pstrcpy(char *buf, int buf_size, const char *str);
156
char *pstrcat(char *buf, int buf_size, const char *s);
157

    
158
int serial_open_device(void);
159

    
160
extern int vm_running;
161

    
162
typedef void VMStopHandler(void *opaque, int reason);
163

    
164
int qemu_add_vm_stop_handler(VMStopHandler *cb, void *opaque);
165
void qemu_del_vm_stop_handler(VMStopHandler *cb, void *opaque);
166

    
167
void vm_start(void);
168
void vm_stop(int reason);
169

    
170
extern int audio_enabled;
171
extern int ram_size;
172
extern int bios_size;
173
extern int rtc_utc;
174
extern int cirrus_vga_enabled;
175

    
176
/* XXX: make it dynamic */
177
#if defined (TARGET_PPC)
178
#define BIOS_SIZE (512 * 1024)
179
#else
180
#define BIOS_SIZE 0
181
#endif
182

    
183
/* keyboard/mouse support */
184

    
185
#define MOUSE_EVENT_LBUTTON 0x01
186
#define MOUSE_EVENT_RBUTTON 0x02
187
#define MOUSE_EVENT_MBUTTON 0x04
188

    
189
typedef void QEMUPutKBDEvent(void *opaque, int keycode);
190
typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state);
191

    
192
void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque);
193
void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void *opaque);
194

    
195
void kbd_put_keycode(int keycode);
196
void kbd_mouse_event(int dx, int dy, int dz, int buttons_state);
197

    
198
/* async I/O support */
199

    
200
typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
201
typedef int IOCanRWHandler(void *opaque);
202

    
203
int qemu_add_fd_read_handler(int fd, IOCanRWHandler *fd_can_read, 
204
                             IOReadHandler *fd_read, void *opaque);
205
void qemu_del_fd_read_handler(int fd);
206

    
207
/* network redirectors support */
208

    
209
#define MAX_NICS 8
210

    
211
typedef struct NetDriverState {
212
    int index; /* index number in QEMU */
213
    uint8_t macaddr[6];
214
    char ifname[16];
215
    void (*send_packet)(struct NetDriverState *nd, 
216
                        const uint8_t *buf, int size);
217
    void (*add_read_packet)(struct NetDriverState *nd, 
218
                            IOCanRWHandler *fd_can_read, 
219
                            IOReadHandler *fd_read, void *opaque);
220
    /* tun specific data */
221
    int fd;
222
    /* slirp specific data */
223
} NetDriverState;
224

    
225
extern int nb_nics;
226
extern NetDriverState nd_table[MAX_NICS];
227

    
228
void qemu_send_packet(NetDriverState *nd, const uint8_t *buf, int size);
229
void qemu_add_read_packet(NetDriverState *nd, IOCanRWHandler *fd_can_read, 
230
                          IOReadHandler *fd_read, void *opaque);
231

    
232
/* timers */
233

    
234
typedef struct QEMUClock QEMUClock;
235
typedef struct QEMUTimer QEMUTimer;
236
typedef void QEMUTimerCB(void *opaque);
237

    
238
/* The real time clock should be used only for stuff which does not
239
   change the virtual machine state, as it is run even if the virtual
240
   machine is stopped. The real time clock has a frequency of 1000
241
   Hz. */
242
extern QEMUClock *rt_clock;
243

    
244
/* Rge virtual clock is only run during the emulation. It is stopped
245
   when the virtual machine is stopped. Virtual timers use a high
246
   precision clock, usually cpu cycles (use ticks_per_sec). */
247
extern QEMUClock *vm_clock;
248

    
249
int64_t qemu_get_clock(QEMUClock *clock);
250

    
251
QEMUTimer *qemu_new_timer(QEMUClock *clock, QEMUTimerCB *cb, void *opaque);
252
void qemu_free_timer(QEMUTimer *ts);
253
void qemu_del_timer(QEMUTimer *ts);
254
void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time);
255
int qemu_timer_pending(QEMUTimer *ts);
256

    
257
extern int64_t ticks_per_sec;
258
extern int pit_min_timer_count;
259

    
260
void cpu_enable_ticks(void);
261
void cpu_disable_ticks(void);
262

    
263
/* VM Load/Save */
264

    
265
typedef FILE QEMUFile;
266

    
267
void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size);
268
void qemu_put_byte(QEMUFile *f, int v);
269
void qemu_put_be16(QEMUFile *f, unsigned int v);
270
void qemu_put_be32(QEMUFile *f, unsigned int v);
271
void qemu_put_be64(QEMUFile *f, uint64_t v);
272
int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size);
273
int qemu_get_byte(QEMUFile *f);
274
unsigned int qemu_get_be16(QEMUFile *f);
275
unsigned int qemu_get_be32(QEMUFile *f);
276
uint64_t qemu_get_be64(QEMUFile *f);
277

    
278
static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv)
279
{
280
    qemu_put_be64(f, *pv);
281
}
282

    
283
static inline void qemu_put_be32s(QEMUFile *f, const uint32_t *pv)
284
{
285
    qemu_put_be32(f, *pv);
286
}
287

    
288
static inline void qemu_put_be16s(QEMUFile *f, const uint16_t *pv)
289
{
290
    qemu_put_be16(f, *pv);
291
}
292

    
293
static inline void qemu_put_8s(QEMUFile *f, const uint8_t *pv)
294
{
295
    qemu_put_byte(f, *pv);
296
}
297

    
298
static inline void qemu_get_be64s(QEMUFile *f, uint64_t *pv)
299
{
300
    *pv = qemu_get_be64(f);
301
}
302

    
303
static inline void qemu_get_be32s(QEMUFile *f, uint32_t *pv)
304
{
305
    *pv = qemu_get_be32(f);
306
}
307

    
308
static inline void qemu_get_be16s(QEMUFile *f, uint16_t *pv)
309
{
310
    *pv = qemu_get_be16(f);
311
}
312

    
313
static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv)
314
{
315
    *pv = qemu_get_byte(f);
316
}
317

    
318
int64_t qemu_ftell(QEMUFile *f);
319
int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence);
320

    
321
typedef void SaveStateHandler(QEMUFile *f, void *opaque);
322
typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id);
323

    
324
int qemu_loadvm(const char *filename);
325
int qemu_savevm(const char *filename);
326
int register_savevm(const char *idstr, 
327
                    int instance_id, 
328
                    int version_id,
329
                    SaveStateHandler *save_state,
330
                    LoadStateHandler *load_state,
331
                    void *opaque);
332
void qemu_get_timer(QEMUFile *f, QEMUTimer *ts);
333
void qemu_put_timer(QEMUFile *f, QEMUTimer *ts);
334

    
335
/* block.c */
336
typedef struct BlockDriverState BlockDriverState;
337

    
338
BlockDriverState *bdrv_new(const char *device_name);
339
void bdrv_delete(BlockDriverState *bs);
340
int bdrv_open(BlockDriverState *bs, const char *filename, int snapshot);
341
void bdrv_close(BlockDriverState *bs);
342
int bdrv_read(BlockDriverState *bs, int64_t sector_num, 
343
              uint8_t *buf, int nb_sectors);
344
int bdrv_write(BlockDriverState *bs, int64_t sector_num, 
345
               const uint8_t *buf, int nb_sectors);
346
void bdrv_get_geometry(BlockDriverState *bs, int64_t *nb_sectors_ptr);
347
int bdrv_commit(BlockDriverState *bs);
348
void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size);
349

    
350
#define BDRV_TYPE_HD     0
351
#define BDRV_TYPE_CDROM  1
352
#define BDRV_TYPE_FLOPPY 2
353

    
354
void bdrv_set_geometry_hint(BlockDriverState *bs, 
355
                            int cyls, int heads, int secs);
356
void bdrv_set_type_hint(BlockDriverState *bs, int type);
357
void bdrv_get_geometry_hint(BlockDriverState *bs, 
358
                            int *pcyls, int *pheads, int *psecs);
359
int bdrv_get_type_hint(BlockDriverState *bs);
360
int bdrv_is_removable(BlockDriverState *bs);
361
int bdrv_is_read_only(BlockDriverState *bs);
362
int bdrv_is_inserted(BlockDriverState *bs);
363
int bdrv_is_locked(BlockDriverState *bs);
364
void bdrv_set_locked(BlockDriverState *bs, int locked);
365
void bdrv_set_change_cb(BlockDriverState *bs, 
366
                        void (*change_cb)(void *opaque), void *opaque);
367

    
368
void bdrv_info(void);
369
BlockDriverState *bdrv_find(const char *name);
370

    
371
/* ISA bus */
372

    
373
extern target_phys_addr_t isa_mem_base;
374

    
375
typedef void (IOPortWriteFunc)(void *opaque, uint32_t address, uint32_t data);
376
typedef uint32_t (IOPortReadFunc)(void *opaque, uint32_t address);
377

    
378
int register_ioport_read(int start, int length, int size, 
379
                         IOPortReadFunc *func, void *opaque);
380
int register_ioport_write(int start, int length, int size, 
381
                          IOPortWriteFunc *func, void *opaque);
382
void isa_unassign_ioport(int start, int length);
383

    
384
/* PCI bus */
385

    
386
extern int pci_enabled;
387

    
388
extern target_phys_addr_t pci_mem_base;
389

    
390
typedef struct PCIDevice PCIDevice;
391

    
392
typedef void PCIConfigWriteFunc(PCIDevice *pci_dev, 
393
                                uint32_t address, uint32_t data, int len);
394
typedef uint32_t PCIConfigReadFunc(PCIDevice *pci_dev, 
395
                                   uint32_t address, int len);
396
typedef void PCIMapIORegionFunc(PCIDevice *pci_dev, int region_num, 
397
                                uint32_t addr, uint32_t size, int type);
398

    
399
#define PCI_ADDRESS_SPACE_MEM                0x00
400
#define PCI_ADDRESS_SPACE_IO                0x01
401
#define PCI_ADDRESS_SPACE_MEM_PREFETCH        0x08
402

    
403
typedef struct PCIIORegion {
404
    uint32_t addr; /* current PCI mapping address. -1 means not mapped */
405
    uint32_t size;
406
    uint8_t type;
407
    PCIMapIORegionFunc *map_func;
408
} PCIIORegion;
409

    
410
#define PCI_ROM_SLOT 6
411
#define PCI_NUM_REGIONS 7
412
struct PCIDevice {
413
    /* PCI config space */
414
    uint8_t config[256];
415

    
416
    /* the following fields are read only */
417
    int bus_num;
418
    int devfn;
419
    char name[64];
420
    PCIIORegion io_regions[PCI_NUM_REGIONS];
421
    
422
    /* do not access the following fields */
423
    PCIConfigReadFunc *config_read;
424
    PCIConfigWriteFunc *config_write;
425
    int irq_index;
426
};
427

    
428
PCIDevice *pci_register_device(const char *name, int instance_size,
429
                               int bus_num, int devfn,
430
                               PCIConfigReadFunc *config_read, 
431
                               PCIConfigWriteFunc *config_write);
432

    
433
void pci_register_io_region(PCIDevice *pci_dev, int region_num, 
434
                            uint32_t size, int type, 
435
                            PCIMapIORegionFunc *map_func);
436

    
437
void pci_set_irq(PCIDevice *pci_dev, int irq_num, int level);
438

    
439
uint32_t pci_default_read_config(PCIDevice *d, 
440
                                 uint32_t address, int len);
441
void pci_default_write_config(PCIDevice *d, 
442
                              uint32_t address, uint32_t val, int len);
443

    
444
extern struct PIIX3State *piix3_state;
445

    
446
void i440fx_init(void);
447
void piix3_init(void);
448
void pci_bios_init(void);
449
void pci_info(void);
450

    
451
/* temporary: will be moved in platform specific file */
452
void pci_prep_init(void);
453
void pci_pmac_init(void);
454
void pci_ppc_bios_init(void);
455

    
456
/* vga.c */
457

    
458
#define VGA_RAM_SIZE (4096 * 1024)
459

    
460
typedef struct DisplayState {
461
    uint8_t *data;
462
    int linesize;
463
    int depth;
464
    void (*dpy_update)(struct DisplayState *s, int x, int y, int w, int h);
465
    void (*dpy_resize)(struct DisplayState *s, int w, int h);
466
    void (*dpy_refresh)(struct DisplayState *s);
467
} DisplayState;
468

    
469
static inline void dpy_update(DisplayState *s, int x, int y, int w, int h)
470
{
471
    s->dpy_update(s, x, y, w, h);
472
}
473

    
474
static inline void dpy_resize(DisplayState *s, int w, int h)
475
{
476
    s->dpy_resize(s, w, h);
477
}
478

    
479
int vga_initialize(DisplayState *ds, uint8_t *vga_ram_base, 
480
                   unsigned long vga_ram_offset, int vga_ram_size, 
481
                   int is_pci);
482
void vga_update_display(void);
483
void vga_screen_dump(const char *filename);
484

    
485
/* cirrus_vga.c */
486
void pci_cirrus_vga_init(DisplayState *ds, uint8_t *vga_ram_base, 
487
                         unsigned long vga_ram_offset, int vga_ram_size);
488

    
489
void isa_cirrus_vga_init(DisplayState *ds, uint8_t *vga_ram_base, 
490
                         unsigned long vga_ram_offset, int vga_ram_size);
491

    
492
/* sdl.c */
493
void sdl_display_init(DisplayState *ds);
494

    
495
/* ide.c */
496
#define MAX_DISKS 4
497

    
498
extern BlockDriverState *bs_table[MAX_DISKS];
499

    
500
void isa_ide_init(int iobase, int iobase2, int irq,
501
                  BlockDriverState *hd0, BlockDriverState *hd1);
502
void pci_ide_init(BlockDriverState **hd_table);
503
void pci_piix3_ide_init(BlockDriverState **hd_table);
504

    
505
/* oss.c */
506
typedef enum {
507
  AUD_FMT_U8,
508
  AUD_FMT_S8,
509
  AUD_FMT_U16,
510
  AUD_FMT_S16
511
} audfmt_e;
512

    
513
void AUD_open (int rfreq, int rnchannels, audfmt_e rfmt);
514
void AUD_reset (int rfreq, int rnchannels, audfmt_e rfmt);
515
int AUD_write (void *in_buf, int size);
516
void AUD_run (void);
517
void AUD_adjust_estimate (int _leftover);
518
int AUD_get_free (void);
519
int AUD_get_live (void);
520
int AUD_get_buffer_size (void);
521
void AUD_init (void);
522

    
523
/* dma.c */
524
typedef int (*DMA_transfer_handler) (void *opaque, target_ulong addr, int size);
525
int DMA_get_channel_mode (int nchan);
526
void DMA_hold_DREQ (int nchan);
527
void DMA_release_DREQ (int nchan);
528
void DMA_schedule(int nchan);
529
void DMA_run (void);
530
void DMA_init (void);
531
void DMA_register_channel (int nchan,
532
                           DMA_transfer_handler transfer_handler, void *opaque);
533

    
534
/* sb16.c */
535
void SB16_run (void);
536
void SB16_init (void);
537
 
538
/* fdc.c */
539
#define MAX_FD 2
540
extern BlockDriverState *fd_table[MAX_FD];
541

    
542
typedef struct fdctrl_t fdctrl_t;
543

    
544
fdctrl_t *fdctrl_init (int irq_lvl, int dma_chann, int mem_mapped, 
545
                       uint32_t io_base,
546
                       BlockDriverState **fds);
547
int fdctrl_get_drive_type(fdctrl_t *fdctrl, int drive_num);
548

    
549
/* ne2000.c */
550

    
551
void isa_ne2000_init(int base, int irq, NetDriverState *nd);
552
void pci_ne2000_init(NetDriverState *nd);
553

    
554
/* pckbd.c */
555

    
556
void kbd_init(void);
557

    
558
/* mc146818rtc.c */
559

    
560
typedef struct RTCState RTCState;
561

    
562
RTCState *rtc_init(int base, int irq);
563
void rtc_set_memory(RTCState *s, int addr, int val);
564
void rtc_set_date(RTCState *s, const struct tm *tm);
565

    
566
/* serial.c */
567

    
568
typedef struct SerialState SerialState;
569

    
570
extern SerialState *serial_console;
571

    
572
SerialState *serial_init(int base, int irq, int fd);
573
int serial_can_receive(SerialState *s);
574
void serial_receive_byte(SerialState *s, int ch);
575
void serial_receive_break(SerialState *s);
576

    
577
/* i8259.c */
578

    
579
void pic_set_irq(int irq, int level);
580
void pic_init(void);
581
uint32_t pic_intack_read(CPUState *env);
582
void pic_info(void);
583
void irq_info(void);
584

    
585
/* i8254.c */
586

    
587
#define PIT_FREQ 1193182
588

    
589
typedef struct PITState PITState;
590

    
591
PITState *pit_init(int base, int irq);
592
void pit_set_gate(PITState *pit, int channel, int val);
593
int pit_get_gate(PITState *pit, int channel);
594
int pit_get_out(PITState *pit, int channel, int64_t current_time);
595

    
596
/* pc.c */
597
void pc_init(int ram_size, int vga_ram_size, int boot_device,
598
             DisplayState *ds, const char **fd_filename, int snapshot,
599
             const char *kernel_filename, const char *kernel_cmdline,
600
             const char *initrd_filename);
601

    
602
/* ppc.c */
603
void ppc_init (int ram_size, int vga_ram_size, int boot_device,
604
               DisplayState *ds, const char **fd_filename, int snapshot,
605
               const char *kernel_filename, const char *kernel_cmdline,
606
               const char *initrd_filename);
607
void ppc_prep_init (int ram_size, int vga_ram_size, int boot_device,
608
                    DisplayState *ds, const char **fd_filename, int snapshot,
609
                    const char *kernel_filename, const char *kernel_cmdline,
610
                    const char *initrd_filename);
611
void ppc_chrp_init(int ram_size, int vga_ram_size, int boot_device,
612
                   DisplayState *ds, const char **fd_filename, int snapshot,
613
                   const char *kernel_filename, const char *kernel_cmdline,
614
                   const char *initrd_filename);
615
#ifdef TARGET_PPC
616
ppc_tb_t *cpu_ppc_tb_init (CPUState *env, uint32_t freq);
617
#endif
618
void PREP_debug_write (void *opaque, uint32_t addr, uint32_t val);
619

    
620
extern CPUWriteMemoryFunc *PPC_io_write[];
621
extern CPUReadMemoryFunc *PPC_io_read[];
622
extern int prep_enabled;
623

    
624
/* NVRAM helpers */
625
#include "hw/m48t59.h"
626

    
627
void NVRAM_set_byte (m48t59_t *nvram, uint32_t addr, uint8_t value);
628
uint8_t NVRAM_get_byte (m48t59_t *nvram, uint32_t addr);
629
void NVRAM_set_word (m48t59_t *nvram, uint32_t addr, uint16_t value);
630
uint16_t NVRAM_get_word (m48t59_t *nvram, uint32_t addr);
631
void NVRAM_set_lword (m48t59_t *nvram, uint32_t addr, uint32_t value);
632
uint32_t NVRAM_get_lword (m48t59_t *nvram, uint32_t addr);
633
void NVRAM_set_string (m48t59_t *nvram, uint32_t addr,
634
                       const unsigned char *str, uint32_t max);
635
int NVRAM_get_string (m48t59_t *nvram, uint8_t *dst, uint16_t addr, int max);
636
void NVRAM_set_crc (m48t59_t *nvram, uint32_t addr,
637
                    uint32_t start, uint32_t count);
638
int PPC_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size,
639
                          const unsigned char *arch,
640
                          uint32_t RAM_size, int boot_device,
641
                          uint32_t kernel_image, uint32_t kernel_size,
642
                          uint32_t cmdline, uint32_t cmdline_size,
643
                          uint32_t initrd_image, uint32_t initrd_size,
644
                          uint32_t NVRAM_image);
645

    
646
/* adb.c */
647

    
648
#define MAX_ADB_DEVICES 16
649

    
650
typedef struct ADBDevice ADBDevice;
651

    
652
typedef void ADBDeviceReceivePacket(ADBDevice *d, const uint8_t *buf, int len);
653

    
654
struct ADBDevice {
655
    struct ADBBusState *bus;
656
    int devaddr;
657
    int handler;
658
    ADBDeviceReceivePacket *receive_packet;
659
    void *opaque;
660
};
661

    
662
typedef struct ADBBusState {
663
    ADBDevice devices[MAX_ADB_DEVICES];
664
    int nb_devices;
665
} ADBBusState;
666

    
667
void adb_receive_packet(ADBBusState *s, const uint8_t *buf, int len);
668
void adb_send_packet(ADBBusState *s, const uint8_t *buf, int len);
669

    
670
ADBDevice *adb_register_device(ADBBusState *s, int devaddr, 
671
                               ADBDeviceReceivePacket *receive_packet, 
672
                               void *opaque);
673
void adb_kbd_init(ADBBusState *bus);
674
void adb_mouse_init(ADBBusState *bus);
675

    
676
/* cuda.c */
677

    
678
extern ADBBusState adb_bus;
679
int cuda_init(void);
680

    
681
/* monitor.c */
682
void monitor_init(void);
683
void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
684
void term_flush(void);
685
void term_print_help(void);
686

    
687
/* gdbstub.c */
688

    
689
#define DEFAULT_GDBSTUB_PORT 1234
690

    
691
int gdbserver_start(int port);
692

    
693
#endif /* VL_H */