~jderose/ubuntu/raring/qemu/vde-again

« back to all changes in this revision

Viewing changes to hw/ppc_prep.c

  • Committer: Bazaar Package Importer
  • Author(s): Aurelien Jarno, Aurelien Jarno
  • Date: 2009-03-22 10:13:17 UTC
  • mfrom: (1.2.1 upstream) (6.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20090322101317-iigjtnu5qil35dtb
Tags: 0.10.1-1
[ Aurelien Jarno ]
* New upstream stable release:
  - patches/80_stable-branch.patch: remove.
* debian/control: 
  - Remove depends on proll.
  - Move depends on device-tree-compiler to build-depends.
  - Bump Standards-Version to 3.8.1 (no changes).
* patches/82_qemu-img_decimal.patch: new patch from upstream to make
  qemu-img accept sizes with decimal values (closes: bug#501400).

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include "pci.h"
32
32
#include "ppc.h"
33
33
#include "boards.h"
 
34
#include "qemu-log.h"
34
35
 
35
36
//#define HARD_DEBUG_PPC_IO
36
37
//#define DEBUG_PPC_IO
44
45
#define KERNEL_LOAD_ADDR 0x01000000
45
46
#define INITRD_LOAD_ADDR 0x01800000
46
47
 
47
 
extern int loglevel;
48
 
extern FILE *logfile;
49
 
 
50
48
#if defined (HARD_DEBUG_PPC_IO) && !defined (DEBUG_PPC_IO)
51
49
#define DEBUG_PPC_IO
52
50
#endif
54
52
#if defined (HARD_DEBUG_PPC_IO)
55
53
#define PPC_IO_DPRINTF(fmt, args...)                     \
56
54
do {                                                     \
57
 
    if (loglevel & CPU_LOG_IOPORT) {                     \
58
 
        fprintf(logfile, "%s: " fmt, __func__ , ##args); \
 
55
    if (qemu_loglevel_mask(CPU_LOG_IOPORT)) {            \
 
56
        qemu_log("%s: " fmt, __func__ , ##args); \
59
57
    } else {                                             \
60
58
        printf("%s : " fmt, __func__ , ##args);          \
61
59
    }                                                    \
62
60
} while (0)
63
61
#elif defined (DEBUG_PPC_IO)
64
 
#define PPC_IO_DPRINTF(fmt, args...)                     \
65
 
do {                                                     \
66
 
    if (loglevel & CPU_LOG_IOPORT) {                     \
67
 
        fprintf(logfile, "%s: " fmt, __func__ , ##args); \
68
 
    }                                                    \
69
 
} while (0)
 
62
#define PPC_IO_DPRINTF(fmt, args...) qemu_log_mask(CPU_LOG_IOPORT, ## __VA_ARGS__)
70
63
#else
71
64
#define PPC_IO_DPRINTF(fmt, args...) do { } while (0)
72
65
#endif
86
79
/* ISA IO ports bridge */
87
80
#define PPC_IO_BASE 0x80000000
88
81
 
 
82
#if 0
89
83
/* Speaker port 0x61 */
90
 
int speaker_data_on;
91
 
int dummy_refresh_clock;
 
84
static int speaker_data_on;
 
85
static int dummy_refresh_clock;
 
86
#endif
92
87
 
93
88
static void speaker_ioport_write (void *opaque, uint32_t addr, uint32_t val)
94
89
{
122
117
{
123
118
    uint32_t retval = 0;
124
119
 
125
 
    if (addr == 0xBFFFFFF0)
 
120
    if ((addr & 0xf) == 0)
126
121
        retval = pic_intack_read(isa_pic);
127
122
//   printf("%s: 0x" PADDRX " <= %08" PRIx32 "\n", __func__, addr, retval);
128
123
 
520
515
    return ret;
521
516
}
522
517
 
523
 
CPUWriteMemoryFunc *PPC_prep_io_write[] = {
 
518
static CPUWriteMemoryFunc *PPC_prep_io_write[] = {
524
519
    &PPC_prep_io_writeb,
525
520
    &PPC_prep_io_writew,
526
521
    &PPC_prep_io_writel,
527
522
};
528
523
 
529
 
CPUReadMemoryFunc *PPC_prep_io_read[] = {
 
524
static CPUReadMemoryFunc *PPC_prep_io_read[] = {
530
525
    &PPC_prep_io_readb,
531
526
    &PPC_prep_io_readw,
532
527
    &PPC_prep_io_readl,
535
530
#define NVRAM_SIZE        0x2000
536
531
 
537
532
/* PowerPC PREP hardware initialisation */
538
 
static void ppc_prep_init (int ram_size, int vga_ram_size,
539
 
                           const char *boot_device, DisplayState *ds,
 
533
static void ppc_prep_init (ram_addr_t ram_size, int vga_ram_size,
 
534
                           const char *boot_device,
540
535
                           const char *kernel_filename,
541
536
                           const char *kernel_cmdline,
542
537
                           const char *initrd_filename,
548
543
    m48t59_t *m48t59;
549
544
    int PPC_io_memory;
550
545
    int linux_boot, i, nb_nics1, bios_size;
551
 
    unsigned long bios_offset;
 
546
    ram_addr_t ram_offset, vga_ram_offset, bios_offset;
552
547
    uint32_t kernel_base, kernel_size, initrd_base, initrd_size;
553
548
    PCIBus *pci_bus;
554
549
    qemu_irq *i8259;
558
553
    BlockDriverState *fd[MAX_FD];
559
554
 
560
555
    sysctrl = qemu_mallocz(sizeof(sysctrl_t));
561
 
    if (sysctrl == NULL)
562
 
        return;
563
556
 
564
557
    linux_boot = (kernel_filename != NULL);
565
558
 
580
573
            cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL);
581
574
        }
582
575
        qemu_register_reset(&cpu_ppc_reset, env);
583
 
        register_savevm("cpu", 0, 3, cpu_save, cpu_load, env);
584
576
        envs[i] = env;
585
577
    }
586
578
 
587
579
    /* allocate RAM */
588
 
    cpu_register_physical_memory(0, ram_size, IO_MEM_RAM);
 
580
    ram_offset = qemu_ram_alloc(ram_size);
 
581
    cpu_register_physical_memory(0, ram_size, ram_offset);
 
582
 
 
583
    /* allocate VGA RAM */
 
584
    vga_ram_offset = qemu_ram_alloc(vga_ram_size);
589
585
 
590
586
    /* allocate and load BIOS */
591
 
    bios_offset = ram_size + vga_ram_size;
 
587
    bios_offset = qemu_ram_alloc(BIOS_SIZE);
592
588
    if (bios_name == NULL)
593
589
        bios_name = BIOS_FILENAME;
594
590
    snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
661
657
    cpu_register_physical_memory(0x80000000, 0x00800000, PPC_io_memory);
662
658
 
663
659
    /* init basic PC hardware */
664
 
    pci_vga_init(pci_bus, ds, phys_ram_base + ram_size, ram_size,
665
 
                 vga_ram_size, 0, 0);
 
660
    pci_vga_init(pci_bus, phys_ram_base + vga_ram_offset,
 
661
                 vga_ram_offset, vga_ram_size, 0, 0);
666
662
    //    openpic = openpic_init(0x00000000, 0xF0000000, 1);
667
663
    //    pit = pit_init(0x40, i8259[0]);
668
 
    rtc_init(0x70, i8259[8]);
 
664
    rtc_init(0x70, i8259[8], 2000);
669
665
 
670
 
    serial_init(0x3f8, i8259[4], serial_hds[0]);
 
666
    serial_init(0x3f8, i8259[4], 115200, serial_hds[0]);
671
667
    nb_nics1 = nb_nics;
672
668
    if (nb_nics1 > NE2000_NB_MAX)
673
669
        nb_nics1 = NE2000_NB_MAX;
674
670
    for(i = 0; i < nb_nics1; i++) {
675
 
        if (nd_table[i].model == NULL
676
 
            || strcmp(nd_table[i].model, "ne2k_isa") == 0) {
 
671
        if (nd_table[i].model == NULL) {
 
672
            nd_table[i].model = "ne2k_isa";
 
673
        }
 
674
        if (strcmp(nd_table[i].model, "ne2k_isa") == 0) {
677
675
            isa_ne2000_init(ne2000_io[i], i8259[ne2000_irq[i]], &nd_table[i]);
678
676
        } else {
679
 
            pci_nic_init(pci_bus, &nd_table[i], -1);
 
677
            pci_nic_init(pci_bus, &nd_table[i], -1, "ne2k_pci");
680
678
        }
681
679
    }
682
680
 
761
759
}
762
760
 
763
761
QEMUMachine prep_machine = {
764
 
    "prep",
765
 
    "PowerPC PREP platform",
766
 
    ppc_prep_init,
 
762
    .name = "prep",
 
763
    .desc = "PowerPC PREP platform",
 
764
    .init = ppc_prep_init,
 
765
    .ram_require = BIOS_SIZE + VGA_RAM_SIZE,
 
766
    .max_cpus = MAX_CPUS,
767
767
};