Commit a37af2891ba7c81d1fc60deb7167b24f26006ef8
1 parent
044ef8ea
Remove some uses of phys_ram_base (initial patch by Ian Jackson)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4455 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
23 additions
and
23 deletions
hw/pc.c
... | ... | @@ -507,7 +507,7 @@ static void load_linux(const char *kernel_filename, |
507 | 507 | int setup_size, kernel_size, initrd_size, cmdline_size; |
508 | 508 | uint32_t initrd_max; |
509 | 509 | uint8_t header[1024]; |
510 | - uint8_t *real_addr, *prot_addr, *cmdline_addr, *initrd_addr; | |
510 | + target_phys_addr_t real_addr, prot_addr, cmdline_addr, initrd_addr; | |
511 | 511 | FILE *f, *fi; |
512 | 512 | |
513 | 513 | /* Align to 16 bytes as a paranoia measure */ |
... | ... | @@ -533,19 +533,19 @@ static void load_linux(const char *kernel_filename, |
533 | 533 | |
534 | 534 | if (protocol < 0x200 || !(header[0x211] & 0x01)) { |
535 | 535 | /* Low kernel */ |
536 | - real_addr = phys_ram_base + 0x90000; | |
537 | - cmdline_addr = phys_ram_base + 0x9a000 - cmdline_size; | |
538 | - prot_addr = phys_ram_base + 0x10000; | |
536 | + real_addr = 0x90000; | |
537 | + cmdline_addr = 0x9a000 - cmdline_size; | |
538 | + prot_addr = 0x10000; | |
539 | 539 | } else if (protocol < 0x202) { |
540 | 540 | /* High but ancient kernel */ |
541 | - real_addr = phys_ram_base + 0x90000; | |
542 | - cmdline_addr = phys_ram_base + 0x9a000 - cmdline_size; | |
543 | - prot_addr = phys_ram_base + 0x100000; | |
541 | + real_addr = 0x90000; | |
542 | + cmdline_addr = 0x9a000 - cmdline_size; | |
543 | + prot_addr = 0x100000; | |
544 | 544 | } else { |
545 | 545 | /* High and recent kernel */ |
546 | - real_addr = phys_ram_base + 0x10000; | |
547 | - cmdline_addr = phys_ram_base + 0x20000; | |
548 | - prot_addr = phys_ram_base + 0x100000; | |
546 | + real_addr = 0x10000; | |
547 | + cmdline_addr = 0x20000; | |
548 | + prot_addr = 0x100000; | |
549 | 549 | } |
550 | 550 | |
551 | 551 | #if 0 |
... | ... | @@ -553,9 +553,9 @@ static void load_linux(const char *kernel_filename, |
553 | 553 | "qemu: real_addr = %#zx\n" |
554 | 554 | "qemu: cmdline_addr = %#zx\n" |
555 | 555 | "qemu: prot_addr = %#zx\n", |
556 | - real_addr-phys_ram_base, | |
557 | - cmdline_addr-phys_ram_base, | |
558 | - prot_addr-phys_ram_base); | |
556 | + real_addr, | |
557 | + cmdline_addr, | |
558 | + prot_addr); | |
559 | 559 | #endif |
560 | 560 | |
561 | 561 | /* highest address for loading the initrd */ |
... | ... | @@ -568,10 +568,10 @@ static void load_linux(const char *kernel_filename, |
568 | 568 | initrd_max = ram_size-ACPI_DATA_SIZE-1; |
569 | 569 | |
570 | 570 | /* kernel command line */ |
571 | - pstrcpy((char*)cmdline_addr, 4096, kernel_cmdline); | |
571 | + pstrcpy_targphys(cmdline_addr, 4096, kernel_cmdline); | |
572 | 572 | |
573 | 573 | if (protocol >= 0x202) { |
574 | - stl_p(header+0x228, cmdline_addr-phys_ram_base); | |
574 | + stl_p(header+0x228, cmdline_addr); | |
575 | 575 | } else { |
576 | 576 | stw_p(header+0x20, 0xA33F); |
577 | 577 | stw_p(header+0x22, cmdline_addr-real_addr); |
... | ... | @@ -605,24 +605,24 @@ static void load_linux(const char *kernel_filename, |
605 | 605 | } |
606 | 606 | |
607 | 607 | initrd_size = get_file_size(fi); |
608 | - initrd_addr = phys_ram_base + ((initrd_max-initrd_size) & ~4095); | |
608 | + initrd_addr = (initrd_max-initrd_size) & ~4095; | |
609 | 609 | |
610 | 610 | fprintf(stderr, "qemu: loading initrd (%#x bytes) at %#zx\n", |
611 | - initrd_size, initrd_addr-phys_ram_base); | |
611 | + initrd_size, initrd_addr); | |
612 | 612 | |
613 | - if (fread(initrd_addr, 1, initrd_size, fi) != initrd_size) { | |
613 | + if (!fread_targphys_ok(initrd_addr, initrd_size, fi)) { | |
614 | 614 | fprintf(stderr, "qemu: read error on initial ram disk '%s'\n", |
615 | 615 | initrd_filename); |
616 | 616 | exit(1); |
617 | 617 | } |
618 | 618 | fclose(fi); |
619 | 619 | |
620 | - stl_p(header+0x218, initrd_addr-phys_ram_base); | |
620 | + stl_p(header+0x218, initrd_addr); | |
621 | 621 | stl_p(header+0x21c, initrd_size); |
622 | 622 | } |
623 | 623 | |
624 | 624 | /* store the finalized header and load the rest of the kernel */ |
625 | - memcpy(real_addr, header, 1024); | |
625 | + cpu_physical_memory_write(real_addr, header, 1024); | |
626 | 626 | |
627 | 627 | setup_size = header[0x1f1]; |
628 | 628 | if (setup_size == 0) |
... | ... | @@ -631,8 +631,8 @@ static void load_linux(const char *kernel_filename, |
631 | 631 | setup_size = (setup_size+1)*512; |
632 | 632 | kernel_size -= setup_size; /* Size of protected-mode code */ |
633 | 633 | |
634 | - if (fread(real_addr+1024, 1, setup_size-1024, f) != setup_size-1024 || | |
635 | - fread(prot_addr, 1, kernel_size, f) != kernel_size) { | |
634 | + if (!fread_targphys_ok(real_addr+1024, setup_size-1024, f) || | |
635 | + !fread_targphys_ok(prot_addr, kernel_size, f)) { | |
636 | 636 | fprintf(stderr, "qemu: read error on kernel '%s'\n", |
637 | 637 | kernel_filename); |
638 | 638 | exit(1); |
... | ... | @@ -640,7 +640,7 @@ static void load_linux(const char *kernel_filename, |
640 | 640 | fclose(f); |
641 | 641 | |
642 | 642 | /* generate bootsector to set up the initial register state */ |
643 | - real_seg = (real_addr-phys_ram_base) >> 4; | |
643 | + real_seg = real_addr >> 4; | |
644 | 644 | seg[0] = seg[2] = seg[3] = seg[4] = seg[4] = real_seg; |
645 | 645 | seg[1] = real_seg+0x20; /* CS */ |
646 | 646 | memset(gpr, 0, sizeof gpr); | ... | ... |