Changeset 5191


Ignore:
Timestamp:
Mar 5, 2010 7:27:19 PM (3 years ago)
Author:
myles
Message:
  1. Move run_bios prototype to device.h
  2. Use time.h for get_time() and move tb_freq into functions.c
  3. Move read_io and write_io to io.c and make them static
  4. Make a couple of functions static in interrupt.c
  5. Refactor a cast from char[] to u64 to get rid of potential alignment problems and a warning

Signed-off-by: Myles Watson <mylesgw@…>
Acked-by: Stefan Reinauer <stepan@…>

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/devices/pci_device.c

    r5136 r5191  
    653653{ 
    654654#if CONFIG_PCI_ROM_RUN == 1 || CONFIG_VGA_ROM_RUN == 1 
    655         void run_bios(struct device *dev, unsigned long addr); 
    656655        struct rom_header *rom, *ram; 
    657656 
  • trunk/src/include/device/device.h

    r4925 r5191  
    118118void disable_children(struct bus *bus); 
    119119 
     120/* Option ROM helper functions */ 
     121void run_bios(struct device *dev, unsigned long addr); 
     122 
    120123/* Helper functions */ 
    121124device_t find_dev_path(struct bus *parent, struct device_path *path); 
  • trunk/util/x86emu/yabel/compat/functions.c

    r5185 r5191  
    1919#include "../debug.h" 
    2020#include "../biosemu.h" 
     21#include "../compat/time.h" 
    2122 
    2223#define VMEM_SIZE (1024 * 1024) /* 1 MB */ 
     
    5354} 
    5455 
     56unsigned long tb_freq = 0; 
     57 
    5558u64 get_time(void) 
    5659{ 
     
    6568    return act; 
    6669} 
    67  
    68 unsigned int 
    69 read_io(void *addr, size_t sz) 
    70 { 
    71         unsigned int ret; 
    72         /* since we are using inb instructions, we need the port number as 16bit value */ 
    73         u16 port = (u16)(u32) addr; 
    74  
    75         switch (sz) { 
    76         case 1: 
    77                 asm volatile ("inb %1, %b0" : "=a"(ret) : "d" (port)); 
    78                 break; 
    79         case 2: 
    80                 asm volatile ("inw %1, %w0" : "=a"(ret) : "d" (port)); 
    81                 break; 
    82         case 4: 
    83                 asm volatile ("inl %1, %0" : "=a"(ret) : "d" (port)); 
    84                 break; 
    85         default: 
    86                 ret = 0; 
    87         } 
    88  
    89         return ret; 
    90 } 
    91  
    92 int 
    93 write_io(void *addr, unsigned int value, size_t sz) 
    94 { 
    95         u16 port = (u16)(u32) addr; 
    96         switch (sz) { 
    97         /* since we are using inb instructions, we need the port number as 16bit value */ 
    98         case 1: 
    99                 asm volatile ("outb %b0, %1" : : "a"(value), "d" (port)); 
    100                 break; 
    101         case 2: 
    102                 asm volatile ("outw %w0, %1" : : "a"(value), "d" (port)); 
    103                 break; 
    104         case 4: 
    105                 asm volatile ("outl %0, %1" : : "a"(value), "d" (port)); 
    106                 break; 
    107         default: 
    108                 return -1; 
    109         } 
    110  
    111         return 0; 
    112 } 
    113  
  • trunk/util/x86emu/yabel/compat/time.h

    r4532 r5191  
    1414 
    1515/* TODO: check how this works in x86 */ 
    16 static unsigned long tb_freq = 0; 
     16extern unsigned long tb_freq; 
     17u64 get_time(void); 
    1718#endif  
  • trunk/util/x86emu/yabel/interrupt.c

    r5185 r5191  
    3232 
    3333//setup to run the code at the address, that the Interrupt Vector points to... 
    34 void 
     34static void 
    3535setupInt(int intNum) 
    3636{ 
     
    5151 
    5252// handle int10 (VGA BIOS Interrupt) 
    53 void 
     53static void 
    5454handleInt10(void) 
    5555{ 
     
    208208; 
    209209 
    210 void 
     210static void 
    211211translate_keycode(u64 * keycode) 
    212212{ 
     
    234234 
    235235// handle int16 (Keyboard BIOS Interrupt) 
    236 void 
     236static void 
    237237handleInt16(void) 
    238238{ 
     
    320320 
    321321// handle int1a (PCI BIOS Interrupt) 
    322 void 
     322static void 
    323323handleInt1a(void) 
    324324{ 
  • trunk/util/x86emu/yabel/io.c

    r5185 r5191  
    2525#endif 
    2626 
    27 // those are defined in net-snk/oflib/pci.c 
    28 extern unsigned int read_io(void *, size_t); 
    29 extern int write_io(void *, unsigned int, size_t); 
    30  
    31 //defined in net-snk/kernel/timer.c 
    32 extern u64 get_time(void); 
     27static unsigned int 
     28read_io(void *addr, size_t sz) 
     29{ 
     30        unsigned int ret; 
     31        /* since we are using inb instructions, we need the port number as 16bit value */ 
     32        u16 port = (u16)(u32) addr; 
     33 
     34        switch (sz) { 
     35        case 1: 
     36                asm volatile ("inb %1, %b0" : "=a"(ret) : "d" (port)); 
     37                break; 
     38        case 2: 
     39                asm volatile ("inw %1, %w0" : "=a"(ret) : "d" (port)); 
     40                break; 
     41        case 4: 
     42                asm volatile ("inl %1, %0" : "=a"(ret) : "d" (port)); 
     43                break; 
     44        default: 
     45                ret = 0; 
     46        } 
     47 
     48        return ret; 
     49} 
     50 
     51static int 
     52write_io(void *addr, unsigned int value, size_t sz) 
     53{ 
     54        u16 port = (u16)(u32) addr; 
     55        switch (sz) { 
     56        /* since we are using inb instructions, we need the port number as 16bit value */ 
     57        case 1: 
     58                asm volatile ("outb %b0, %1" : : "a"(value), "d" (port)); 
     59                break; 
     60        case 2: 
     61                asm volatile ("outw %w0, %1" : : "a"(value), "d" (port)); 
     62                break; 
     63        case 4: 
     64                asm volatile ("outl %0, %1" : : "a"(value), "d" (port)); 
     65                break; 
     66        default: 
     67                return -1; 
     68        } 
     69 
     70        return 0; 
     71} 
    3372 
    3473#ifdef CONFIG_ARCH_X86 
  • trunk/util/x86emu/yabel/mem.c

    r5185 r5191  
    159159#define DEBUG_CHECK_VMEM_WRITE(_addr, _val) 
    160160#endif 
    161  
    162 //defined in net-snk/kernel/timer.c 
    163 extern u64 get_time(void); 
    164161 
    165162void update_time(u32); 
  • trunk/util/x86emu/yabel/vbe.c

    r5185 r5191  
    571571        } 
    572572#endif 
    573         if (*((u64 *) ddc_info.edid_block_zero) != 
    574             (u64) 0x00FFFFFFFFFFFF00ULL) { 
     573/* This could fail because of alignment issues, so use a longer form. 
     574        *((u64 *) ddc_info.edid_block_zero) != (u64) 0x00FFFFFFFFFFFF00ULL 
     575*/ 
     576        if (ddc_info.edid_block_zero[0] != 0x00 || 
     577            ddc_info.edid_block_zero[1] != 0xFF || 
     578            ddc_info.edid_block_zero[2] != 0xFF || 
     579            ddc_info.edid_block_zero[3] != 0xFF || 
     580            ddc_info.edid_block_zero[4] != 0xFF || 
     581            ddc_info.edid_block_zero[5] != 0xFF || 
     582            ddc_info.edid_block_zero[6] != 0xFF || 
     583            ddc_info.edid_block_zero[7] != 0x00 ) { 
    575584                // invalid EDID signature... probably no monitor 
    576585 
Note: See TracChangeset for help on using the changeset viewer.