Commit 897b4c6c4e63afebdd41de0f1a19e17ab1f4c2b8

Authored by j_mayer
1 parent 64330148

Give an opaque to the m48t59 direct access routines to make it easier

to use another NVRAM with the same API.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3474 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 2 changed files with 13 additions and 7 deletions
hw/m48t59.c
... ... @@ -199,8 +199,9 @@ static void set_up_watchdog (m48t59_t *NVRAM, uint8_t value)
199 199 }
200 200  
201 201 /* Direct access to NVRAM */
202   -void m48t59_write (m48t59_t *NVRAM, uint32_t addr, uint32_t val)
  202 +void m48t59_write (void *opaque, uint32_t addr, uint32_t val)
203 203 {
  204 + m48t59_t *NVRAM = opaque;
204 205 struct tm tm;
205 206 int tmp;
206 207  
... ... @@ -357,8 +358,9 @@ void m48t59_write (m48t59_t *NVRAM, uint32_t addr, uint32_t val)
357 358 }
358 359 }
359 360  
360   -uint32_t m48t59_read (m48t59_t *NVRAM, uint32_t addr)
  361 +uint32_t m48t59_read (void *opaque, uint32_t addr)
361 362 {
  363 + m48t59_t *NVRAM = opaque;
362 364 struct tm tm;
363 365 uint32_t retval = 0xFF;
364 366  
... ... @@ -451,13 +453,17 @@ uint32_t m48t59_read (m48t59_t *NVRAM, uint32_t addr)
451 453 return retval;
452 454 }
453 455  
454   -void m48t59_set_addr (m48t59_t *NVRAM, uint32_t addr)
  456 +void m48t59_set_addr (void *opaque, uint32_t addr)
455 457 {
  458 + m48t59_t *NVRAM = opaque;
  459 +
456 460 NVRAM->addr = addr;
457 461 }
458 462  
459   -void m48t59_toggle_lock (m48t59_t *NVRAM, int lock)
  463 +void m48t59_toggle_lock (void *opaque, int lock)
460 464 {
  465 + m48t59_t *NVRAM = opaque;
  466 +
461 467 NVRAM->lock ^= 1 << lock;
462 468 }
463 469  
... ...
hw/m48t59.h
... ... @@ -3,9 +3,9 @@
3 3  
4 4 typedef struct m48t59_t m48t59_t;
5 5  
6   -void m48t59_write (m48t59_t *NVRAM, uint32_t addr, uint32_t val);
7   -uint32_t m48t59_read (m48t59_t *NVRAM, uint32_t addr);
8   -void m48t59_toggle_lock (m48t59_t *NVRAM, int lock);
  6 +void m48t59_write (void *private, uint32_t addr, uint32_t val);
  7 +uint32_t m48t59_read (void *private, uint32_t addr);
  8 +void m48t59_toggle_lock (void *private, int lock);
9 9 m48t59_t *m48t59_init (qemu_irq IRQ, target_phys_addr_t mem_base,
10 10 uint32_t io_base, uint16_t size,
11 11 int type);
... ...