fix compile error and warning
authorSon Hyunjun <hj79.son@samsung.com>
Thu, 8 Mar 2012 03:02:40 +0000 (12:02 +0900)
committerSon Hyunjun <hj79.son@samsung.com>
Thu, 8 Mar 2012 03:02:40 +0000 (12:02 +0900)
tizen/src/hw/maru_overlay.c
tizen/src/hw/maru_overlay.h [new file with mode: 0644]
tizen/src/hw/maru_pci_ids.h [new file with mode: 0644]

index 9a455a9..7d3cca1 100644 (file)
@@ -37,7 +37,8 @@
  */
 #include "pc.h"
 #include "pci.h"
-#include "pci_ids.h"
+#include "maru_pci_ids.h"
+#include "maru_overlay.h"
 
 #define OVERLAY_MEM_SIZE       (8192 * 1024)   // 4MB(overlay0) + 4MB(overlay1)
 #define OVERLAY_REG_SIZE       256
@@ -62,20 +63,19 @@ uint16_t overlay1_top;
 uint16_t overlay1_width;
 uint16_t overlay1_height;
 
-uint8_t* overlay_ptr;  // pointer in qemu space
-
 typedef struct OverlayState {
-    PCIDevice dev;
+    PCIDevice       dev;
     
-    ram_addr_t vram_offset;
+    ram_addr_t      vram_offset;
+
+    MemoryRegion    mem_addr;
+    MemoryRegion    mmio_addr;
 
-    int overlay_mmio;
+    uint8_t*        overlay_ptr;
 
-    uint32_t mem_addr; // guest addr
-    uint32_t mmio_addr;        // guest addr
 } OverlayState;
 
-static uint32_t overlay_reg_read(void *opaque, target_phys_addr_t addr)
+static uint64_t overlay_reg_read(void *opaque, target_phys_addr_t addr, unsigned size)
 {
     switch (addr) {
     case OVERLAY_POWER:
@@ -97,21 +97,23 @@ static uint32_t overlay_reg_read(void *opaque, target_phys_addr_t addr)
         return overlay1_width | overlay1_height << 16;
         break;
     default:
-        fprintf(stderr, "wrong overlay register read - addr : %d\n", addr);
+        fprintf(stderr, "wrong overlay register read - addr : %d\n", (int)addr);
         break;
     }
 
     return 0;
 }
 
-static void overlay_reg_write(void *opaque, target_phys_addr_t addr, uint32_t val)
+static void overlay_reg_write(void *opaque, target_phys_addr_t addr, uint64_t val, unsigned size)
 {
+    OverlayState *state = (OverlayState*)opaque;
+
     switch (addr) {
     case OVERLAY_POWER:
         overlay0_power = val;
         if( !overlay0_power ) {
                // clear the last overlay area.
-               memset( overlay_ptr, 0x00, ( OVERLAY_MEM_SIZE / 2 ) );
+               memset( state->overlay_ptr, 0x00, ( OVERLAY_MEM_SIZE / 2 ) );
         }
         break;
     case OVERLAY_POSITION:
@@ -126,7 +128,7 @@ static void overlay_reg_write(void *opaque, target_phys_addr_t addr, uint32_t va
         overlay1_power = val;
         if( !overlay1_power ) {
                // clear the last overlay area.
-               memset( overlay_ptr + OVERLAY1_REG_OFFSET , 0x00, ( OVERLAY_MEM_SIZE / 2 ) );
+               memset( state->overlay_ptr + OVERLAY1_REG_OFFSET , 0x00, ( OVERLAY_MEM_SIZE / 2 ) );
         }
         break;
     case OVERLAY1_REG_OFFSET + OVERLAY_POSITION:
@@ -138,45 +140,17 @@ static void overlay_reg_write(void *opaque, target_phys_addr_t addr, uint32_t va
         overlay1_height = val >> 16;
         break;
     default:
-        fprintf(stderr, "wrong overlay register write - addr : %d\n", addr);
+        fprintf(stderr, "wrong overlay register write - addr : %d\n", (int)addr);
         break;
     }
 }
 
-static CPUReadMemoryFunc * const overlay_reg_readfn[3] = {
-    overlay_reg_read,
-    overlay_reg_read,
-    overlay_reg_read,
-};
-
-static CPUWriteMemoryFunc * const overlay_reg_writefn[3] = {
-    overlay_reg_write,
-    overlay_reg_write,
-    overlay_reg_write,
+static const MemoryRegionOps overlay_mmio_ops = {
+    .read = overlay_reg_read,
+    .write = overlay_reg_write,
+    .endianness = DEVICE_LITTLE_ENDIAN,
 };
 
-static void overlay_mem_map(PCIDevice *dev, int region_num,
-                              pcibus_t addr, pcibus_t size, int type)
-{
-    OverlayState *s = DO_UPCAST(OverlayState, dev, dev);
-
-    cpu_register_physical_memory(addr, OVERLAY_MEM_SIZE,
-                                s->vram_offset);
-
-    s->mem_addr = addr;
-}
-
-static void overlay_mmio_map(PCIDevice *dev, int region_num,
-                              pcibus_t addr, pcibus_t size, int type)
-{
-    OverlayState *s = DO_UPCAST(OverlayState, dev, dev);
-    
-    cpu_register_physical_memory(addr, OVERLAY_REG_SIZE,
-                                 s->overlay_mmio);
-    
-    s->mmio_addr = addr;
-}
-
 static int overlay_initfn(PCIDevice *dev)
 {
     OverlayState *s = DO_UPCAST(OverlayState, dev, dev);
@@ -186,21 +160,16 @@ static int overlay_initfn(PCIDevice *dev)
     pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_VIRTUAL_OVERLAY);
     pci_config_set_class(pci_conf, PCI_CLASS_DISPLAY_OTHER);
 
-    s->vram_offset = qemu_ram_alloc(NULL, "overlay.vram", OVERLAY_MEM_SIZE);
-    overlay_ptr = qemu_get_ram_ptr(s->vram_offset);
+    memory_region_init_ram(&s->mem_addr, NULL, "overlay.ram", OVERLAY_MEM_SIZE);
+    s->overlay_ptr = memory_region_get_ram_ptr(&s->mem_addr);
+
+    memory_region_init_io (&s->mmio_addr, &overlay_mmio_ops, s, "overlay-mmio", OVERLAY_MEM_SIZE);
 
-    s->overlay_mmio = cpu_register_io_memory(overlay_reg_readfn,
-                                             overlay_reg_writefn, s,
-                                             DEVICE_LITTLE_ENDIAN);
     /* setup memory space */
     /* memory #0 device memory (overlay surface) */
     /* memory #1 memory-mapped I/O */
-    pci_register_bar(&s->dev, 0, OVERLAY_MEM_SIZE,
-                    PCI_BASE_ADDRESS_MEM_PREFETCH, overlay_mem_map);
-
-    pci_register_bar(&s->dev, 1, OVERLAY_REG_SIZE,
-                     PCI_BASE_ADDRESS_SPACE_MEMORY, overlay_mmio_map);
+    pci_register_bar(&s->dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mem_addr);
+    pci_register_bar(&s->dev, 1, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->mmio_addr);
 
     return 0;
 }
diff --git a/tizen/src/hw/maru_overlay.h b/tizen/src/hw/maru_overlay.h
new file mode 100644 (file)
index 0000000..465820f
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * 
+ *
+ * Copyright (C) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * DoHyung Hong <don.hong@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Hyunjun Son <hj79.son@samsung.com>
+ * SangJin Kim <sangjin3.kim@samsung.com>
+ * MunKyu Im <munkyu.im@samsung.com>
+ * KiTae Kim <kt920.kim@samsung.com>
+ * JinHyung Jo <jinhyung.jo@samsung.com>
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * JiHye Kim <jihye1128.kim@samsung.com>
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+#ifndef MARU_OVERLAY_H_
+#define MARU_OVERLAY_H_
+
+int pci_overlay_init( PCIBus *bus );
+
+#endif /* MARU_OVERLAY_H_ */
diff --git a/tizen/src/hw/maru_pci_ids.h b/tizen/src/hw/maru_pci_ids.h
new file mode 100644 (file)
index 0000000..1e99484
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * 
+ *
+ * Copyright (C) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * DoHyung Hong <don.hong@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Hyunjun Son <hj79.son@samsung.com>
+ * SangJin Kim <sangjin3.kim@samsung.com>
+ * MunKyu Im <munkyu.im@samsung.com>
+ * KiTae Kim <kt920.kim@samsung.com>
+ * JinHyung Jo <jinhyung.jo@samsung.com>
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * JiHye Kim <jihye1128.kim@samsung.com>
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * DongKyun Yun <dk77.yun@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+#ifndef MARU_PCI_IDS_H_
+#define MARU_PCI_IDS_H_
+
+#define PCI_VENDOR_ID_TIZEN              0xC9B5
+#define PCI_DEVICE_ID_VIRTUAL_OVERLAY    0x1010
+#define PCI_DEVICE_ID_VIRTUAL_BRIGHTNESS 0x1014
+#define PCI_DEVICE_ID_VIRTUAL_CAMERA     0x1018
+#define PCI_DEVICE_ID_VIRTUAL_CODEC      0x101C
+
+#endif /* MARU_PCI_IDS_H_ */