Give parse_macaddr() external linkage
PATCH 3/4 Give parse_macaddr() external linkage
In reply to a message not in the archiveThis is to make it available for the machine description stuff in the following commit.
--- net.c | 2 +- net.h | 1 + 2 files changed, 2 insertions(+), 1 deletions(-)
net.c +1 -1
@@ -158,7 +158,7 @@ static void hex_dump(FILE *f, const uint8_t *buf, int size) }#endif -static int parse_macaddr (uint8_t *macaddr,const char *p) +int parse_macaddr (uint8_t *macaddr,const char *p) {int i;char *last_char;
net.h +1 -0
@@ -61,6 +61,7 @@ int qemu_can_send_packet(VLANClientState *vc);ssize_t qemu_sendv_packet (VLANClientState *vc,const struct iovec *iov,int iovcnt);void qemu_send_packet (VLANClientState *vc,const uint8_t *buf,int size); +int parse_macaddr (uint8_t *macaddr,const char *p);void qemu_format_nic_info_str (VLANClientState *vc,uint8_t macaddr[6 ]);void qemu_check_nic_model (NICInfo *nd,const char *model); void qemu_check_nic_model_list(NICInfo *nd, const char * const *models,
Signature · 1 line
1.6.0.6
PATCH 1/4 Confine use of global rtc_state to PC CMOS functions
In reply to a message not in the archivePass the state as argument to cmos_init() and cmos_init_hd(). cmos_init() still needs to save it in rtc_state for use by cmos_set_s3_resume().
--- hw/pc.c | 20 +++++++++++--------- 1 files changed, 11 insertions(+), 9 deletions(-)
hw/pc.c +11 -9
@@ -169,9 +169,9 @@ static int cmos_get_fd_drive_type(int fd0)return val; } -static void cmos_init_hd (int type_ofs,int info_ofs,BlockDriverState *hd) +static void cmos_init_hd (RTCState *s, +int type_ofs,int info_ofs,BlockDriverState *hd) { -RTCState *s = rtc_state;int cylinders, heads, sectors;bdrv_get_geometry_hint (hd, &cylinders, &heads, §ors);rtc_set_memory (s, type_ofs,47 );
@@ -232,10 +232,10 @@ static int pc_boot_set(void *opaque, const char *boot_device) }/* hd_table must contain 4 block drivers */ -static void cmos_init (ram_addr_t ram_size,ram_addr_t above_4g_mem_size, +static void cmos_init (RTCState *s, +ram_addr_t ram_size,ram_addr_t above_4g_mem_size,const char *boot_device,BlockDriverState **hd_table) { -RTCState *s = rtc_state;int nbds, bds[3 ] = {0 , };int val;int fd0, fd1, nb;
@@ -324,9 +324,9 @@ static void cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,rtc_set_memory (s,0x12 , (hd_table[0 ] ?0xf0 :0 ) | (hd_table[1 ] ?0x0f :0 ));if (hd_table[0 ]) -cmos_init_hd (0x19 ,0x1b , hd_table[0 ]); +cmos_init_hd (s,0x19 ,0x1b , hd_table[0 ]);if (hd_table[1 ]) -cmos_init_hd (0x1a ,0x24 , hd_table[1 ]); +cmos_init_hd (s,0x1a ,0x24 , hd_table[1 ]); val =0 ;for (i =0 ; i <4 ; i++) {
@@ -353,6 +353,7 @@ static void cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size, } }rtc_set_memory (s,0x39 , val); + rtc_state = s;/* for cmos_set_s3_resume() */ }void ioport_set_a20 (int enable)
@@ -822,6 +823,7 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,int bios_size, isa_bios_size, oprom_area_size;PCIBus *pci_bus;int piix3_devfn =-1 ; +RTCState *rtc;CPUState *env;qemu_irq *cpu_irq;qemu_irq *i8259;
@@ -990,9 +992,9 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size, } } - rtc_state =rtc_init (0x70 , i8259[8 ],2000 ); + rtc =rtc_init (0x70 , i8259[8 ],2000 ); -qemu_register_boot_set (pc_boot_set, rtc_state); +qemu_register_boot_set (pc_boot_set, rtc);register_ioport_read (0x92 ,1 ,1 , ioport92_read,NULL );register_ioport_write (0x92 ,1 ,1 , ioport92_write,NULL );
@@ -1071,7 +1073,7 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size, } floppy_controller =fdctrl_init (i8259[6 ],2 ,0 ,0x3f0 , fd); -cmos_init (below_4g_mem_size, above_4g_mem_size, boot_device, hd); +cmos_init (rtc, below_4g_mem_size, above_4g_mem_size, boot_device, hd);if (pci_enabled && usb_enabled) {usb_uhci_piix3_init (pci_bus, piix3_devfn +2 );
Signature · 1 line
1.6.0.6
PATCH 2/4 Remove global floppy_controller
In reply to a message not in the archiveChange cmos_init() to take the floppy drive types as arguments instead of getting them through global floppy_controller.
Change fdctrl_get_drive_type() to take a BlockDriverState argument. Factor fd_format() out of fd_revalidate() to make that possible.
Use it to compute the new arguments for cmos_init().
--- hw/fdc.c | 76 ++++++++++++++++++++++++++++++++++--------------------------- hw/fdc.h | 2 +- hw/pc.c | 15 +++++------ 3 files changed, 50 insertions(+), 43 deletions(-)
hw/fdc.c +42 -34
@@ -231,12 +231,51 @@ static const fd_format_t fd_formats[] = { { FDRIVE_DRV_NONE, FDRIVE_DISK_NONE, -1, -1, 0, NULL, }, }; -/* Revalidate a disk drive after a disk change */ -static void fd_revalidate (fdrive_t *drv) +static const fd_format_t *fd_format (BlockDriverState *bs, +fdrive_type_t prev_type) {const fd_format_t *parse;uint64_t nb_sectors, size;int i, first_match, match; + +bdrv_get_geometry (bs, &nb_sectors); + match =-1 ; + first_match =-1 ; +for (i =0 ;; i++) { + parse = &fd_formats[i]; +if (parse->drive ==FDRIVE_DRV_NONE ) +break ; +if (prev_type == parse->drive || + prev_type ==FDRIVE_DRV_NONE ) { + size = (parse->max_head +1 ) * parse->max_track * + parse->last_sect; +if (nb_sectors == size) { + match = i; +break ; + } +if (first_match ==-1 ) + first_match = i; + } + } +if (match ==-1 ) { +if (first_match ==-1 ) + match =1 ; +else + match = first_match; + parse = &fd_formats[match]; + } +return parse; +} + +int fdctrl_get_drive_type (BlockDriverState *bs) +{ +return bs ?fd_format (bs,FDRIVE_DRV_NONE )->drive :FDRIVE_DRV_NONE ; +} + +/* Revalidate a disk drive after a disk change */ +static void fd_revalidate (fdrive_t *drv) +{ +const fd_format_t *parse;int nb_heads, max_track, last_sect, ro;FLOPPY_DPRINTF ("revalidate\n" );
@@ -247,32 +286,7 @@ static void fd_revalidate (fdrive_t *drv)FLOPPY_DPRINTF ("User defined disk (%d %d %d)" , nb_heads -1 , max_track, last_sect); }else { -bdrv_get_geometry (drv->bs, &nb_sectors); - match =-1 ; - first_match =-1 ; -for (i =0 ;; i++) { - parse = &fd_formats[i]; -if (parse->drive ==FDRIVE_DRV_NONE ) -break ; -if (drv->drive == parse->drive || - drv->drive ==FDRIVE_DRV_NONE ) { - size = (parse->max_head +1 ) * parse->max_track * - parse->last_sect; -if (nb_sectors == size) { - match = i; -break ; - } -if (first_match ==-1 ) - first_match = i; - } - } -if (match ==-1 ) { -if (first_match ==-1 ) - match =1 ; -else - match = first_match; - parse = &fd_formats[match]; - } + parse =fd_format (drv->bs, drv->drive); nb_heads = parse->max_head +1 ; max_track = parse->max_track; last_sect = parse->last_sect;
@@ -735,12 +749,6 @@ static void fdctrl_handle_tc(void *opaque, int irq, int level) } } -/* XXX: may change if moved to bdrv */ -int fdctrl_get_drive_type (fdctrl_t *fdctrl,int drive_num) -{ -return fdctrl->drives[drive_num].drive; -} -/* Change IRQ state */ static void fdctrl_reset_irq (fdctrl_t *fdctrl) {
hw/fdc.h +1 -1
@@ -8,4 +8,4 @@ fdctrl_t *fdctrl_init (qemu_irq irq, int dma_chann, int mem_mapped, BlockDriverState **fds);fdctrl_t *sun4m_fdctrl_init (qemu_irq irq,target_phys_addr_t io_base,BlockDriverState **fds,qemu_irq *fdc_tc); -int fdctrl_get_drive_type (fdctrl_t *fdctrl,int drive_num); +int fdctrl_get_drive_type (BlockDriverState *bs);
hw/pc.c +7 -8
@@ -56,7 +56,6 @@#define MAX_IDE_BUS 2 -static fdctrl_t *floppy_controller;static RTCState *rtc_state;static PITState *pit;static IOAPICState *ioapic;
@@ -234,11 +233,12 @@ static int pc_boot_set(void *opaque, const char *boot_device)/* hd_table must contain 4 block drivers */ static void cmos_init (RTCState *s,ram_addr_t ram_size,ram_addr_t above_4g_mem_size, -const char *boot_device,BlockDriverState **hd_table) +const char *boot_device,BlockDriverState **hd_table, +int fd0,int fd1) {int nbds, bds[3 ] = {0 , };int val; -int fd0, fd1, nb; +int nb;int i;/* various important CMOS locations needed by PC/Bochs bios */
@@ -294,9 +294,6 @@ static void cmos_init(RTCState *s,/* floppy type */ - fd0 =fdctrl_get_drive_type (floppy_controller,0 ); - fd1 =fdctrl_get_drive_type (floppy_controller,1 ); - val = (cmos_get_fd_drive_type (fd0) <<4 ) |cmos_get_fd_drive_type (fd1);rtc_set_memory (s,0x10 , val);
@@ -1071,9 +1068,11 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,else fd[i] =NULL ; } - floppy_controller =fdctrl_init (i8259[6 ],2 ,0 ,0x3f0 , fd); +fdctrl_init (i8259[6 ],2 ,0 ,0x3f0 , fd); -cmos_init (rtc, below_4g_mem_size, above_4g_mem_size, boot_device, hd); +cmos_init (rtc, below_4g_mem_size, above_4g_mem_size, boot_device, hd, +fdctrl_get_drive_type (fd[0 ]), +fdctrl_get_drive_type (fd[1 ]));if (pci_enabled && usb_enabled) {usb_uhci_piix3_init (pci_bus, piix3_devfn +2 );
Signature · 1 line
1.6.0.6
PATCH 4/4 Machine description as data
In reply to a message not in the archive--- Makefile | 1 + Makefile.target | 7 +- dt-fdt.c | 123 +++++++ dt-host.c | 176 +++++++++ dt.c | 600 +++++++++++++++++++++++++++++++ dt.h | 150 ++++++++ hw/boards.h | 3 + hw/pc.c | 53 ++-- hw/pcdt.c | 941 +++++++++++++++++++++++++++++++++++++++++++++++++ hw/pcidt.c | 67 ++++ hw/pcint.h | 47 +++ target-i386/machine.c | 1 + tree.c | 285 +++++++++++++++ tree.h | 41 +++ 14 files changed, 2464 insertions(+), 31 deletions(-) create mode 100644 dt-fdt.c create mode 100644 dt-host.c create mode 100644 dt.c create mode 100644 dt.h create mode 100644 hw/pcdt.c create mode 100644 hw/pcidt.c create mode 100644 hw/pcint.h create mode 100644 tree.c create mode 100644 tree.h
Makefile +1 -0
@@ -100,6 +100,7 @@ OBJS+=bt-hci-csr.o OBJS+=buffered_file.o migration.o migration-tcp.o net.o qemu-sockets.o OBJS+=qemu-char.o aio.o net-checksum.o savevm.o cache-utils.o OBJS+=msmouse.o ps2.o +OBJS+=tree.o ifdef CONFIG_BRLAPI OBJS+= baum.o
Makefile.target +6 -1
@@ -503,6 +503,10 @@ OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o machine.o dma-helpers.o # need to fix this properly OBJS+=virtio.o virtio-blk.o virtio-balloon.o virtio-net.o virtio-console.o OBJS+=fw_cfg.o +OBJS+=dt.o dt-host.o pcidt.o +ifdef FDT_LIBS +OBJS+= dt-fdt.o +endif ifdef CONFIG_KVM OBJS+=kvm.o kvm-all.o endif
@@ -534,6 +538,7 @@ endif ifdef CONFIG_OSS LIBS += $(CONFIG_OSS_LIB) endif +LIBS+= $(FDT_LIBS) SOUND_HW = sb16.o es1370.o ac97.o ifdef CONFIG_ADLIB
@@ -588,6 +593,7 @@ OBJS+= ide.o pckbd.o vga.o $(SOUND_HW) dma.o OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o OBJS+= cirrus_vga.o apic.o ioapic.o parallel.o acpi.o piix_pci.o OBJS+= usb-uhci.o vmmouse.o vmport.o vmware_vga.o hpet.o +OBJS+= pcdt.o OBJS += device-hotplug.o pci-hotplug.o smbios.o CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE endif
@@ -611,7 +617,6 @@ OBJS+= ppc440.o ppc440_bamboo.o OBJS+= ppce500_pci.o ppce500_mpc8544ds.o ifdef FDT_LIBS OBJS+= device_tree.o -LIBS+= $(FDT_LIBS) endif ifdef CONFIG_KVM OBJS+= kvm_ppc.o
dt-fdt.c new file +123 -0
123 lines not on this page · raw message
dt-host.c new file +176 -0
176 lines not on this page · raw message
dt.c new file +600 -0
600 lines not on this page · raw message
dt.h new file +150 -0
150 lines not on this page · raw message
hw/boards.h +3 -0
@@ -32,6 +32,9 @@ extern QEMUMachine axisdev88_machine;extern QEMUMachine pc_machine;extern QEMUMachine isapc_machine; +/* pcdt.c */ +extern QEMUMachine pcdt_machine; +/* xen_machine.c */ extern QEMUMachine xenpv_machine;
hw/pc.c +23 -30
137 lines not on this page · raw message
hw/pcdt.c new file +941 -0
941 lines not on this page · raw message
hw/pcidt.c new file +67 -0
67 lines not on this page · raw message
hw/pcint.h new file +47 -0
47 lines not on this page · raw message
target-i386/machine.c +1 -0
@@ -7,6 +7,7 @@void register_machines (void ) { +qemu_register_machine (&pcdt_machine);qemu_register_machine (&pc_machine);qemu_register_machine (&isapc_machine);#ifdef CONFIG_XEN
tree.c new file +285 -0
285 lines not on this page · raw message
tree.h new file +41 -0
41 lines not on this page · raw message
Signature · 1 line
1.6.0.6
Re: [Qemu-devel] [PATCH 1/4] Confine use of global rtc_state to PC CMOS functions
In reply to Markus ArmbrusterQuoted 3 lines · Markus Armbruster
Pass the state as argument to
cmos_init()andcmos_init_hd().
cmos_init()still needs to save it inrtc_statefor use bycmos_set_s3_resume().
pc.c could pass acpi an opaque handle (former rtc_state) at init or acpi could export a function to set the handle, called by pc.c. Then cmos_set_s3_resume could take a state parameter.
Re: [Qemu-devel] [PATCH 2/4] Remove global floppy_controller
In reply to Markus ArmbrusterQuoted 7 lines · Markus Armbruster
Change
cmos_init()to take the floppy drive types as arguments instead
of getting them through globalfloppy_controller.Change
fdctrl_get_drive_type()to take a BlockDriverState argument. Factorfd_format()out offd_revalidate()to make that possible.Use it to compute the new arguments for
cmos_init().
Looks OK.
Re: [Qemu-devel] [PATCH 1/4] Confine use of global rtc_state to PC CMOS functions
In reply to Blue SwirlQuoted 8 lines · Blue Swirl
Quoted 3 lines · Markus Armbruster
Pass the state as argument to
cmos_init()andcmos_init_hd().
cmos_init()still needs to save it inrtc_statefor use bycmos_set_s3_resume().
pc.ccould pass acpi an opaque handle (formerrtc_state) at init or acpi could export a function to set the handle, called bypc.c. Thencmos_set_s3_resumecould take a state parameter.
We'd just move a global variable from pc.c to acpi.c, wouldn't we? Could you explain why that's a better place?
Passing rtc_state to piix4_pm_init() doesn't work well for pcdt.c, because we'd have to pass it from RTC device to PIIX3 ACPI device somehow, creating one of those ugly "non-tree" device dependencies, i.e. one that doesn't follow device tree or interrupt tree edges. Your other idea (a function to set the handle) allows me to keep the two devices decoupled, provided I can set the handle even before piix4_pm_init().
Re: [Qemu-devel] [PATCH 1/4] Confine use of global rtc_state to PC CMOS functions
Quoted 7 lines · Markus Armbruster
Quoted 5 lines · Blue Swirl
Quoted 3 lines · Markus Armbruster
Pass the state as argument to
cmos_init()andcmos_init_hd().
cmos_init()still needs to save it inrtc_statefor use bycmos_set_s3_resume().
Quoted 7 lines
Quoted 3 lines
pc.ccould pass acpi an opaque handle (formerrtc_state) at init or acpi could export a function to set the handle, called bypc.c. Thencmos_set_s3_resumecould take a state parameter.We'd just move a global variable from
pc.ctoacpi.c, wouldn't we?
Could you explain why that's a better place?
No, acpi would only have an opaque pointer to the variable stored in PIIX4PMState, the "owner" would still be pc.c.
Quoted 7 lines
Passing
rtc_statetopiix4_pm_init()doesn't work well forpcdt.c, because we'd have to pass it from RTC device to PIIX3 ACPI device somehow, creating one of those ugly "non-tree" device dependencies, i.e. one that doesn't follow device tree or interrupt tree edges. Your other idea (a function to set the handle) allows me to keep the two devices decoupled, provided I can set the handle even beforepiix4_pm_init().
Still one idea: a signal (qemu_irq) could be used to convey the s3 resume condition. That may be another tree.
Setting the handle before piix4_pm_init will fail if the handle is going to be stored in PIIX4PMState, but the setup can be reversed:piix4_pm_init can call a function to get the handle.
Re: [Qemu-devel] [PATCH 1/4] Confine use of global rtc_state to PC CMOS functions
Sorry for the sloooow respons, I was on vacation.
Quoted 13 lines · Blue Swirl
Quoted 12 lines · Markus Armbruster
Quoted 8 lines · Blue Swirl
Quoted 3 lines · Markus Armbruster
Pass the state as argument to
cmos_init()andcmos_init_hd().
cmos_init()still needs to save it inrtc_statefor use bycmos_set_s3_resume().
pc.ccould pass acpi an opaque handle (formerrtc_state) at init or acpi could export a function to set the handle, called bypc.c. Thencmos_set_s3_resumecould take a state parameter.
Quoted 5 lines
Quoted 2 lines
We'd just move a global variable from
pc.ctoacpi.c, wouldn't we?
Could you explain why that's a better place?No, acpi would only have an opaque pointer to the variable stored in PIIX4PMState, the "owner" would still be
pc.c.
Okay, so we'd just move a global variable from pc.c into only instance of struct PIIX4PMState, referenced from a global variable in acpi.c. The fact that it becomes opaque in the process isn't much of an improvement, isn't it?
Quoted 10 lines
Quoted 7 lines
Passing
rtc_statetopiix4_pm_init()doesn't work well forpcdt.c, because we'd have to pass it from RTC device to PIIX3 ACPI device somehow, creating one of those ugly "non-tree" device dependencies, i.e. one that doesn't follow device tree or interrupt tree edges. Your other idea (a function to set the handle) allows me to keep the two devices decoupled, provided I can set the handle even beforepiix4_pm_init().Still one idea: a signal (
qemu_irq) could be used to convey the s3 resume condition. That may be another tree.
Hmm.
How does the hardware do it? Does it update CMOS all by itself?
Quoted 2 lines
Setting the handle before
piix4_pm_initwill fail if the handle is going to be stored in PIIX4PMState,
Correct.
Quoted 2 lines
but the setup can be reversed:
piix4_pm_initcan call a function to get the handle.
Where from?
A global variable in pc.c? But then we create global state in acpi.c without reducing it in pc.c.
In the context of pcdt.c: creates the same non-tree device dependency, only in the opposite direction.
Re: [Qemu-devel] [PATCH 1/4] Confine use of global rtc_state to PC CMOS functions
Quoted 21 lines · Markus Armbruster
Sorry for the sloooow respons, I was on vacation.
Quoted 16 lines · Blue Swirl
Quoted 14 lines · Markus Armbruster
Quoted 8 lines · Blue Swirl
Quoted 3 lines · Markus Armbruster
Pass the state as argument to
cmos_init()andcmos_init_hd().
cmos_init()still needs to save it inrtc_statefor use bycmos_set_s3_resume().
pc.ccould pass acpi an opaque handle (formerrtc_state) at init or acpi could export a function to set the handle, called bypc.c. Thencmos_set_s3_resumecould take a state parameter.We'd just move a global variable from
pc.ctoacpi.c, wouldn't we?
Could you explain why that's a better place?
Quoted 8 lines
Quoted 2 lines
No, acpi would only have an opaque pointer to the variable stored in PIIX4PMState, the "owner" would still be
pc.c.Okay, so we'd just move a global variable from
pc.cinto only instance
of struct PIIX4PMState, referenced from a global variable inacpi.c. The fact that it becomes opaque in the process isn't much of an improvement, isn't it?
Yes it is, acpi.c does not need to know about rtc_state internals.
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Passing
rtc_statetopiix4_pm_init()doesn't work well forpcdt.c, because we'd have to pass it from RTC device to PIIX3 ACPI device somehow, creating one of those ugly "non-tree" device dependencies, i.e. one that doesn't follow device tree or interrupt tree edges. Your other idea (a function to set the handle) allows me to keep the two devices decoupled, provided I can set the handle even beforepiix4_pm_init().
Quoted 7 lines
Quoted 2 lines
Still one idea: a signal (
qemu_irq) could be used to convey the s3 resume condition. That may be another tree.Hmm.
How does the hardware do it? Does it update CMOS all by itself?
Just guessing: there could be a signal wire from the power management chip to CMOS GPIO pin and this would be visible in a CMOS register.
Quoted 7 lines
Quoted 2 lines
Setting the handle before
piix4_pm_initwill fail if the handle is going to be stored in PIIX4PMState,Correct.
Quoted 8 lines
Quoted 2 lines
but the setup can be reversed:
piix4_pm_initcan call a function to get the handle.Where from?
A global variable in
pc.c? But then we create global state inacpi.cwithout reducing it inpc.c.
pc.c is the "owner" of most devices, so that's OK. acpi.c only has a handle.
Quoted 2 lines
In the context of
pcdt.c: creates the same non-tree device dependency, only in the opposite direction.
I don't see how you can avoid it. Maybe power management wants a tree of its own.
Re: [Qemu-devel] [PATCH 1/4] Confine use of global rtc_state to PC CMOS functions
In reply to Markus ArmbrusterQuoted 2 lines · Markus Armbruster
How does the hardware do it? Does it update CMOS all by itself?
I'm guessing the hardware only makes this present in a chipset register. The BIOS reads the registers and writes the CMOS memory (which is likely on the same chip, but...).
Would be best to adopt that.
Signature · 1 line
error compiling committee.c: too many arguments to function