Revision 5fafdf24 hw/m48t59.c

b/hw/m48t59.c
1 1
/*
2 2
 * QEMU M48T59 and M48T08 NVRAM emulation for PPC PREP and Sparc platforms
3
 * 
3
 *
4 4
 * Copyright (c) 2003-2005, 2007 Jocelyn Mayer
5
 * 
5
 *
6 6
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 7
 * of this software and associated documentation files (the "Software"), to deal
8 8
 * in the Software without restriction, including without limitation the rights
......
90 90
static void set_time (m48t59_t *NVRAM, struct tm *tm)
91 91
{
92 92
    time_t now, new_time;
93
    
93
   
94 94
    new_time = mktime(tm);
95 95
    now = time(NULL);
96 96
    NVRAM->time_offset = new_time - now;
......
104 104
    m48t59_t *NVRAM = opaque;
105 105

  
106 106
    qemu_set_irq(NVRAM->IRQ, 1);
107
    if ((NVRAM->buffer[0x1FF5] & 0x80) == 0 && 
107
    if ((NVRAM->buffer[0x1FF5] & 0x80) == 0 &&
108 108
	(NVRAM->buffer[0x1FF4] & 0x80) == 0 &&
109 109
	(NVRAM->buffer[0x1FF3] & 0x80) == 0 &&
110 110
	(NVRAM->buffer[0x1FF2] & 0x80) == 0) {
......
208 208

  
209 209
    if (addr > 0x1FF8 && addr < 0x2000)
210 210
	NVRAM_PRINTF("%s: 0x%08x => 0x%08x\n", __func__, addr, val);
211
    if (NVRAM->type == 8 && 
211
    if (NVRAM->type == 8 &&
212 212
        (addr >= 0x1ff0 && addr <= 0x1ff7))
213 213
        goto do_write;
214 214
    switch (addr) {
......
364 364
    struct tm tm;
365 365
    uint32_t retval = 0xFF;
366 366

  
367
    if (NVRAM->type == 8 && 
367
    if (NVRAM->type == 8 &&
368 368
        (addr >= 0x1ff0 && addr <= 0x1ff7))
369 369
        goto do_read;
370 370
    switch (addr) {
......
430 430
    case 0x1FFF:
431 431
        /* year */
432 432
        get_time(NVRAM, &tm);
433
        if (NVRAM->type == 8) 
433
        if (NVRAM->type == 8)
434 434
            retval = toBCD(tm.tm_year - 68); // Base year is 1968
435 435
        else
436 436
            retval = toBCD(tm.tm_year);
......
510 510
static void nvram_writeb (void *opaque, target_phys_addr_t addr, uint32_t value)
511 511
{
512 512
    m48t59_t *NVRAM = opaque;
513
    
513
   
514 514
    addr -= NVRAM->mem_base;
515 515
    m48t59_write(NVRAM, addr, value & 0xff);
516 516
}
......
518 518
static void nvram_writew (void *opaque, target_phys_addr_t addr, uint32_t value)
519 519
{
520 520
    m48t59_t *NVRAM = opaque;
521
    
521
   
522 522
    addr -= NVRAM->mem_base;
523 523
    m48t59_write(NVRAM, addr, (value >> 8) & 0xff);
524 524
    m48t59_write(NVRAM, addr + 1, value & 0xff);
......
527 527
static void nvram_writel (void *opaque, target_phys_addr_t addr, uint32_t value)
528 528
{
529 529
    m48t59_t *NVRAM = opaque;
530
    
530
   
531 531
    addr -= NVRAM->mem_base;
532 532
    m48t59_write(NVRAM, addr, (value >> 24) & 0xff);
533 533
    m48t59_write(NVRAM, addr + 1, (value >> 16) & 0xff);
......
539 539
{
540 540
    m48t59_t *NVRAM = opaque;
541 541
    uint32_t retval;
542
    
542
   
543 543
    addr -= NVRAM->mem_base;
544 544
    retval = m48t59_read(NVRAM, addr);
545 545
    return retval;
......
549 549
{
550 550
    m48t59_t *NVRAM = opaque;
551 551
    uint32_t retval;
552
    
552
   
553 553
    addr -= NVRAM->mem_base;
554 554
    retval = m48t59_read(NVRAM, addr) << 8;
555 555
    retval |= m48t59_read(NVRAM, addr + 1);

Also available in: Unified diff