Diff for /qemu/hw/omap_uart.c between versions 1.1.1.1 and 1.1.1.4

version 1.1.1.1, 2018/04/24 18:29:32 version 1.1.1.4, 2018/04/24 19:48:32
Line 22 Line 22
 #include "omap.h"  #include "omap.h"
 /* We use pc-style serial ports.  */  /* We use pc-style serial ports.  */
 #include "pc.h"  #include "pc.h"
   #include "exec-memory.h"
   
 /* UARTs */  /* UARTs */
 struct omap_uart_s {  struct omap_uart_s {
       MemoryRegion iomem;
     target_phys_addr_t base;      target_phys_addr_t base;
     SerialState *serial; /* TODO */      SerialState *serial; /* TODO */
     struct omap_target_agent_s *ta;      struct omap_target_agent_s *ta;
Line 51  void omap_uart_reset(struct omap_uart_s  Line 53  void omap_uart_reset(struct omap_uart_s 
   
 struct omap_uart_s *omap_uart_init(target_phys_addr_t base,  struct omap_uart_s *omap_uart_init(target_phys_addr_t base,
                 qemu_irq irq, omap_clk fclk, omap_clk iclk,                  qemu_irq irq, omap_clk fclk, omap_clk iclk,
                 qemu_irq txdma, qemu_irq rxdma, CharDriverState *chr)                  qemu_irq txdma, qemu_irq rxdma,
                   const char *label, CharDriverState *chr)
 {  {
     struct omap_uart_s *s = (struct omap_uart_s *)      struct omap_uart_s *s = (struct omap_uart_s *)
             qemu_mallocz(sizeof(struct omap_uart_s));              g_malloc0(sizeof(struct omap_uart_s));
   
     s->base = base;      s->base = base;
     s->fclk = fclk;      s->fclk = fclk;
     s->irq = irq;      s->irq = irq;
 #ifdef TARGET_WORDS_BIGENDIAN      s->serial = serial_mm_init(get_system_memory(), base, 2, irq,
     s->serial = serial_mm_init(base, 2, irq, omap_clk_getrate(fclk)/16,                                 omap_clk_getrate(fclk)/16,
                                chr ?: qemu_chr_open("null", "null", NULL), 1,                                 chr ?: qemu_chr_new(label, "null", NULL),
                                1);                                 DEVICE_NATIVE_ENDIAN);
 #else  
     s->serial = serial_mm_init(base, 2, irq, omap_clk_getrate(fclk)/16,  
                                chr ?: qemu_chr_open("null", "null", NULL), 1,  
                                0);  
 #endif  
     return s;      return s;
 }  }
   
 static uint32_t omap_uart_read(void *opaque, target_phys_addr_t addr)  static uint64_t omap_uart_read(void *opaque, target_phys_addr_t addr,
                                  unsigned size)
 {  {
     struct omap_uart_s *s = (struct omap_uart_s *) opaque;      struct omap_uart_s *s = (struct omap_uart_s *) opaque;
   
     addr &= 0xff;      if (size == 4) {
           return omap_badwidth_read8(opaque, addr);
       }
   
     switch (addr) {      switch (addr) {
     case 0x20:  /* MDR1 */      case 0x20:  /* MDR1 */
         return s->mdr[0];          return s->mdr[0];
Line 106  static uint32_t omap_uart_read(void *opa Line 108  static uint32_t omap_uart_read(void *opa
 }  }
   
 static void omap_uart_write(void *opaque, target_phys_addr_t addr,  static void omap_uart_write(void *opaque, target_phys_addr_t addr,
                 uint32_t value)                              uint64_t value, unsigned size)
 {  {
     struct omap_uart_s *s = (struct omap_uart_s *) opaque;      struct omap_uart_s *s = (struct omap_uart_s *) opaque;
   
     addr &= 0xff;      if (size == 4) {
           return omap_badwidth_write8(opaque, addr, value);
       }
   
     switch (addr) {      switch (addr) {
     case 0x20:  /* MDR1 */      case 0x20:  /* MDR1 */
         s->mdr[0] = value & 0x7f;          s->mdr[0] = value & 0x7f;
Line 148  static void omap_uart_write(void *opaque Line 153  static void omap_uart_write(void *opaque
     }      }
 }  }
   
 static CPUReadMemoryFunc * const omap_uart_readfn[] = {  static const MemoryRegionOps omap_uart_ops = {
     omap_uart_read,      .read = omap_uart_read,
     omap_uart_read,      .write = omap_uart_write,
     omap_badwidth_read8,      .endianness = DEVICE_NATIVE_ENDIAN,
 };  };
   
 static CPUWriteMemoryFunc * const omap_uart_writefn[] = {  struct omap_uart_s *omap2_uart_init(MemoryRegion *sysmem,
     omap_uart_write,                  struct omap_target_agent_s *ta,
     omap_uart_write,  
     omap_badwidth_write8,  
 };  
   
 struct omap_uart_s *omap2_uart_init(struct omap_target_agent_s *ta,  
                 qemu_irq irq, omap_clk fclk, omap_clk iclk,                  qemu_irq irq, omap_clk fclk, omap_clk iclk,
                 qemu_irq txdma, qemu_irq rxdma, CharDriverState *chr)                  qemu_irq txdma, qemu_irq rxdma,
                   const char *label, CharDriverState *chr)
 {  {
     target_phys_addr_t base = omap_l4_attach(ta, 0, 0);      target_phys_addr_t base = omap_l4_attach(ta, 0, NULL);
     struct omap_uart_s *s = omap_uart_init(base, irq,      struct omap_uart_s *s = omap_uart_init(base, irq,
                     fclk, iclk, txdma, rxdma, chr);                      fclk, iclk, txdma, rxdma, label, chr);
     int iomemtype = cpu_register_io_memory(omap_uart_readfn,  
                     omap_uart_writefn, s);      memory_region_init_io(&s->iomem, &omap_uart_ops, s, "omap.uart", 0x100);
   
     s->ta = ta;      s->ta = ta;
   
     cpu_register_physical_memory(base + 0x20, 0x100, iomemtype);      memory_region_add_subregion(sysmem, base + 0x20, &s->iomem);
   
     return s;      return s;
 }  }
Line 180  struct omap_uart_s *omap2_uart_init(stru Line 181  struct omap_uart_s *omap2_uart_init(stru
 void omap_uart_attach(struct omap_uart_s *s, CharDriverState *chr)  void omap_uart_attach(struct omap_uart_s *s, CharDriverState *chr)
 {  {
     /* TODO: Should reuse or destroy current s->serial */      /* TODO: Should reuse or destroy current s->serial */
 #ifdef TARGET_WORDS_BIGENDIAN      s->serial = serial_mm_init(get_system_memory(), s->base, 2, s->irq,
     s->serial = serial_mm_init(s->base, 2, s->irq,  
                                omap_clk_getrate(s->fclk) / 16,  
                                chr ?: qemu_chr_open("null", "null", NULL), 1,  
                                1);  
 #else  
     s->serial = serial_mm_init(s->base, 2, s->irq,  
                                omap_clk_getrate(s->fclk) / 16,                                 omap_clk_getrate(s->fclk) / 16,
                                chr ?: qemu_chr_open("null", "null", NULL), 1,                                 chr ?: qemu_chr_new("null", "null", NULL),
                                0);                                 DEVICE_NATIVE_ENDIAN);
 #endif  
 }  }

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.4


unix.superglobalmegacorp.com