Home | History | Annotate | Download | only in goldfish
      1 /* Copyright (C) 2007-2008 The Android Open Source Project
      2 **
      3 ** This software is licensed under the terms of the GNU General Public
      4 ** License version 2, as published by the Free Software Foundation, and
      5 ** may be copied, distributed, and modified under those terms.
      6 **
      7 ** This program is distributed in the hope that it will be useful,
      8 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
      9 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     10 ** GNU General Public License for more details.
     11 */
     12 #ifndef GOLDFISH_DEVICE_H
     13 #define GOLDFISH_DEVICE_H
     14 
     15 #include "config.h"
     16 #include "exec/cpu-common.h"
     17 
     18 struct goldfish_device {
     19     struct goldfish_device *next;
     20     struct goldfish_device *prev;
     21     uint32_t reported_state;
     22     void *cookie;
     23     const char *name;
     24     uint32_t id;
     25     uint32_t base; // filled in by goldfish_device_add if 0
     26     uint32_t size;
     27     uint32_t irq; // filled in by goldfish_device_add if 0
     28     uint32_t irq_count;
     29 };
     30 
     31 
     32 void goldfish_device_set_irq(struct goldfish_device *dev, int irq, int level);
     33 int goldfish_device_add(struct goldfish_device *dev,
     34                        CPUReadMemoryFunc **mem_read,
     35                        CPUWriteMemoryFunc **mem_write,
     36                        void *opaque);
     37 
     38 int goldfish_add_device_no_io(struct goldfish_device *dev);
     39 
     40 void goldfish_device_init(qemu_irq *pic, uint32_t base, uint32_t size, uint32_t irq, uint32_t irq_count);
     41 int goldfish_device_bus_init(uint32_t base, uint32_t irq);
     42 
     43 // device init functions:
     44 qemu_irq *goldfish_interrupt_init(uint32_t base, qemu_irq parent_irq, qemu_irq parent_fiq);
     45 void goldfish_timer_and_rtc_init(uint32_t timerbase, int timerirq);
     46 int goldfish_tty_add(CharDriverState *cs, int id, uint32_t base, int irq);
     47 void goldfish_fb_init(int id);
     48 void goldfish_audio_init(uint32_t base, int id, const char* input_source);
     49 void goldfish_battery_init(int has_battery);
     50 void goldfish_battery_set_prop(int ac, int property, int value);
     51 void goldfish_battery_display(void (* callback)(void *data, const char* string), void *data);
     52 void goldfish_mmc_init(uint32_t base, int id, BlockDriverState* bs);
     53 int goldfish_guest_is_64bit();
     54 
     55 // these do not add a device
     56 void trace_dev_init();
     57 void events_dev_init(uint32_t base, qemu_irq irq);
     58 void nand_dev_init(uint32_t base);
     59 
     60 #ifdef TARGET_I386
     61 /* Maximum IRQ number available for a device on x86. */
     62 #define GFD_MAX_IRQ      16
     63 /* IRQ reserved for keyboard. */
     64 #define GFD_KBD_IRQ      1
     65 /* IRQ reserved for RTC. */
     66 #define GFD_RTC_IRQ      8
     67 /* IRQ reserved for mouse. */
     68 #define GFD_MOUSE_IRQ    12
     69 /* IRQ reserved for error (raising an exception in TB code). */
     70 #define GFD_ERR_IRQ      13
     71 #else
     72 /* Maximum IRQ number available for a device on ARM. */
     73 #define GFD_MAX_IRQ     32
     74 #endif
     75 
     76 static inline void uint64_set_low(uint64_t *addr, uint32 value)
     77 {
     78     *addr = (*addr & ~(0xFFFFFFFFULL)) | value;
     79 }
     80 
     81 static inline void uint64_set_high(uint64_t *addr, uint32 value)
     82 {
     83     *addr = (*addr & 0xFFFFFFFFULL) | ((uint64_t)value << 32);
     84 }
     85 
     86 #endif  /* GOLDFISH_DEVICE_H */
     87