]> rtime.felk.cvut.cz Git - mf6xx.git/commitdiff
Qemu: Coding style.
authorRostislav Lisovy <lisovy@gmail.com>
Fri, 27 Jan 2012 16:30:22 +0000 (17:30 +0100)
committerRostislav Lisovy <lisovy@gmail.com>
Fri, 27 Jan 2012 16:30:22 +0000 (17:30 +0100)
src/qemu/hw/mf624.c

index 8416ee080429b403a1c5ccdc6ed4d89e8b46c65f..8c804d8ca75d0adda329280a0df2d4792de30094 100644 (file)
@@ -1,8 +1,8 @@
-/* 
+/*
  * Humusoft MF624 DAQ card implementation
- * 
+ *
  * Copyright (C) 2011 Rostislav Lisovy (lisovy@gmail.com)
- * 
+ *
  * Licensed under GPLv2 license
  */
 #include "hw.h"
@@ -10,7 +10,7 @@
 #include "qemu-thread.h"
 #include <string.h>
 #include <unistd.h>
-#include <sys/types.h> 
+#include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <sys/socket.h>
@@ -30,7 +30,7 @@
 #define INTCSR_off                     0x4C
 #define GPIOC_off                      0x54
 
-/* BAR2 */ 
+/* BAR2 */
 #define ADDATA_off                     0x00
 #define ADCTRL_off                     0x00
 #define ADDATA1_off                    0x02
@@ -106,8 +106,8 @@ typedef struct {
        uint32_t port;
        int addr;
 
-        /* The real voltage which is on inputs od A/D convertors.
-       Until new conversion is started, there is still old value in ADC registers*/    
+       /* The real voltage which is on inputs od A/D convertors.
+       Until new conversion is started, there is still old value in ADC registers*/
        unsigned int real_world_AD0; //Value in "ADC internal" format
        unsigned int real_world_AD1;
        unsigned int real_world_AD2;
@@ -121,15 +121,15 @@ typedef struct {
        unsigned int BAR0_mem_table_index;
        unsigned int BAR2_mem_table_index;
        unsigned int BAR4_mem_table_index;
-       
+
        // Internal registers values
        BAR0_t BAR0;
        BAR2_t BAR2;
        BAR4_t BAR4;
 
 
-       int ADDATA_FIFO[8]; //this array tells us which ADCs are being converted        
-       unsigned int ADDATA_FIFO_POSITION; //ADDATA is FIFO register; 
+       int ADDATA_FIFO[8]; //this array tells us which ADCs are being converted
+       unsigned int ADDATA_FIFO_POSITION; //ADDATA is FIFO register;
                                //We need to know, position in this FIFO =
                                //Which value will come next
 } mf624_state_t;
@@ -164,7 +164,7 @@ static void mf624_init_registers(mf624_state_t* s)
 
        //Initialize all registers to default values
        s->BAR0.INTCSR = INTCSR_default_value;
-       s->BAR0.GPIOC = GPIOC_default_value; 
+       s->BAR0.GPIOC = GPIOC_default_value;
        s->BAR2.ADDATA = 0x0;
        s->BAR2.ADCTRL = 0x0;
        s->BAR2.ADDATA1 = 0x0;
@@ -222,7 +222,7 @@ static void socket_read(mf624_state_t* dev)
                        perror("read()");
                        return;
                }
-               
+
                if (received_length == 0) {
                        printf("Error while reading from socket. Client disconnected?\n");
                        return;
@@ -260,7 +260,7 @@ static void socket_read(mf624_state_t* dev)
                        }
                        else {
                                printf("reg = %s; val = %f\n", reg, val);
-                       } 
+                       }
                }
        }
 }
@@ -272,7 +272,7 @@ static void* init_socket(void* ptr)
        struct sockaddr_in addr_srv;
        int port;
        int yes = 1;
-       
+
        mf624_state_t* dev = (mf624_state_t*) ptr;
 
        dev->socket_tmp = -1;
@@ -283,7 +283,7 @@ static void* init_socket(void* ptr)
                perror("socket()");
                return NULL;
        }
-       
+
        if (setsockopt(dev->socket_srv, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1) {
                perror("setsockopt()");
                return NULL;
@@ -299,7 +299,7 @@ static void* init_socket(void* ptr)
                perror("bind()");
                return NULL;
        }
-       
+
        if (listen(dev->socket_srv, 5) == -1) {
                perror("listen()");
                return NULL;
@@ -315,10 +315,10 @@ static void* init_socket(void* ptr)
                }
 
                printf("Client connected\n");
-       
-               socket_read(dev); // should run forever if everything is OK; 
+
+               socket_read(dev); // should run forever if everything is OK;
                                // If error occurs (client disconnected), returns here
-               
+
                close(dev->socket_tmp);
        }
 
@@ -336,7 +336,7 @@ static void mf624_BAR0_write32(void *opaque, target_phys_addr_t addr, uint32_t v
                        s->BAR0.INTCSR = (value & 0x7FF) | INTCSR_default_value; // Only first 11 bits are writable
                        socket_write(s, "INTCSR", s->BAR0.INTCSR);
                        break;
-                       
+
                case GPIOC_off:
                        //Don't write anywhere else than into these two bits
                        s->BAR0.GPIOC = (value & (GPIOC_LDAC_mask | GPIOC_DACEN_mask)) | GPIOC_default_value;
@@ -354,7 +354,7 @@ static void mf624_BAR0_write32(void *opaque, target_phys_addr_t addr, uint32_t v
                                socket_write(s, "DA6", dacinternal_to_volts(s->BAR2.DA6));
                                socket_write(s, "DA7", dacinternal_to_volts(s->BAR2.DA7));
                        }
-                       
+
                        //Is output forced to GND?
                        if (!(s->BAR0.GPIOC & GPIOC_DACEN_mask))
                        {
@@ -369,7 +369,7 @@ static void mf624_BAR0_write32(void *opaque, target_phys_addr_t addr, uint32_t v
                                socket_write(s, "DA7", dacinternal_to_volts(GND));
                        }
                        break;
-                       
+
                default:
                        printf("mf624_BAR0_write32(): addr = " TARGET_FMT_plx "; value = %d\n", addr, value);
                        break;
@@ -418,7 +418,7 @@ static uint32_t mf624_BAR2_read16(void *opaque, target_phys_addr_t addr)
                                                s->ADDATA_FIFO_POSITION = i; // Move to next AD to be read
                                        }
                                }
-                               
+
                                switch (s->ADDATA_FIFO_POSITION)
                                {
                                        case 0:
@@ -464,7 +464,7 @@ static uint32_t mf624_BAR2_read16(void *opaque, target_phys_addr_t addr)
                case ADSTART_off:
                        s->BAR0.GPIOC |= GPIOC_EOLC_mask; // Conversion in progress
                        s->ADDATA_FIFO_POSITION = 0;
-                       for (i = 0; i < 5000; i++) 
+                       for (i = 0; i < 5000; i++)
                                ; // Small delay simulating real conversion
 
                        // Check before assignement, if particular ADC is enabled
@@ -476,10 +476,10 @@ static uint32_t mf624_BAR2_read16(void *opaque, target_phys_addr_t addr)
                        s->BAR2.ADDATA5 = (s->BAR2.ADCTRL & (1 << 5)) ? s->real_world_AD5 : s->BAR2.ADDATA5;
                        s->BAR2.ADDATA6 = (s->BAR2.ADCTRL & (1 << 6)) ? s->real_world_AD6 : s->BAR2.ADDATA6;
                        s->BAR2.ADDATA7 = (s->BAR2.ADCTRL & (1 << 7)) ? s->real_world_AD7 : s->BAR2.ADDATA7;
-                       
+
                        //All channels converted
                        s->BAR0.GPIOC &= ~ GPIOC_EOLC_mask;
-                       
+
                        return 0xFFFF; // Semirandom value
 
                default:
@@ -515,7 +515,7 @@ static void mf624_BAR2_write16(void *opaque, target_phys_addr_t addr, uint32_t v
 
                case DA1_off:
                        s->BAR2.DA1 = value;
-                       if (!(s->BAR0.GPIOC & GPIOC_LDAC_mask) && 
+                       if (!(s->BAR0.GPIOC & GPIOC_LDAC_mask) &&
                                (s->BAR0.GPIOC & GPIOC_DACEN_mask)) {
                                socket_write(s, "DA1", dacinternal_to_volts(s->BAR2.DA1));
                        }
@@ -523,7 +523,7 @@ static void mf624_BAR2_write16(void *opaque, target_phys_addr_t addr, uint32_t v
 
                case DA2_off:
                        s->BAR2.DA2 = value;
-                       if (!(s->BAR0.GPIOC & GPIOC_LDAC_mask) && 
+                       if (!(s->BAR0.GPIOC & GPIOC_LDAC_mask) &&
                                (s->BAR0.GPIOC & GPIOC_DACEN_mask)) {
                                socket_write(s, "DA2", dacinternal_to_volts(s->BAR2.DA2));
                        }
@@ -531,7 +531,7 @@ static void mf624_BAR2_write16(void *opaque, target_phys_addr_t addr, uint32_t v
 
                case DA3_off:
                        s->BAR2.DA3 = value;
-                       if (!(s->BAR0.GPIOC & GPIOC_LDAC_mask) && 
+                       if (!(s->BAR0.GPIOC & GPIOC_LDAC_mask) &&
                                (s->BAR0.GPIOC & GPIOC_DACEN_mask)) {
                                socket_write(s, "DA3", dacinternal_to_volts(s->BAR2.DA3));
                        }
@@ -539,7 +539,7 @@ static void mf624_BAR2_write16(void *opaque, target_phys_addr_t addr, uint32_t v
 
                case DA4_off:
                        s->BAR2.DA4 = value;
-                       if (!(s->BAR0.GPIOC & GPIOC_LDAC_mask) && 
+                       if (!(s->BAR0.GPIOC & GPIOC_LDAC_mask) &&
                                (s->BAR0.GPIOC & GPIOC_DACEN_mask)) {
                                socket_write(s, "DA4", dacinternal_to_volts(s->BAR2.DA4));
                        }
@@ -547,7 +547,7 @@ static void mf624_BAR2_write16(void *opaque, target_phys_addr_t addr, uint32_t v
 
                case DA5_off:
                        s->BAR2.DA5 = value;
-                       if (!(s->BAR0.GPIOC & GPIOC_LDAC_mask) && 
+                       if (!(s->BAR0.GPIOC & GPIOC_LDAC_mask) &&
                                (s->BAR0.GPIOC & GPIOC_DACEN_mask)) {
                                socket_write(s, "DA5", dacinternal_to_volts(s->BAR2.DA5));
                        }
@@ -555,7 +555,7 @@ static void mf624_BAR2_write16(void *opaque, target_phys_addr_t addr, uint32_t v
 
                case DA6_off:
                        s->BAR2.DA6 = value;
-                       if (!(s->BAR0.GPIOC & GPIOC_LDAC_mask) && 
+                       if (!(s->BAR0.GPIOC & GPIOC_LDAC_mask) &&
                                (s->BAR0.GPIOC & GPIOC_DACEN_mask)) {
                                socket_write(s, "DA6", dacinternal_to_volts(s->BAR2.DA6));
                        }
@@ -563,7 +563,7 @@ static void mf624_BAR2_write16(void *opaque, target_phys_addr_t addr, uint32_t v
 
                case DA7_off:
                        s->BAR2.DA7 = value;
-                       if (!(s->BAR0.GPIOC & GPIOC_LDAC_mask) && 
+                       if (!(s->BAR0.GPIOC & GPIOC_LDAC_mask) &&
                                (s->BAR0.GPIOC & GPIOC_DACEN_mask)) {
                                socket_write(s, "DA7", dacinternal_to_volts(s->BAR2.DA7));
                        }
@@ -646,7 +646,7 @@ static CPUReadMemoryFunc * const mf624_BAR0_read[3] = {
        NULL, /* read16 */
        mf624_BAR0_read32,
 };
+
 static CPUWriteMemoryFunc * const mf624_BAR0_write[3] = {
        NULL, /* write8 */
        NULL, /* write16 */
@@ -658,7 +658,7 @@ static CPUReadMemoryFunc * const mf624_BAR2_read[3] = {
        mf624_BAR2_read16,
        NULL, /* read32 */
 };
+
 static CPUWriteMemoryFunc * const mf624_BAR2_write[3] = {
        NULL, /* write8 */
        mf624_BAR2_write16,
@@ -670,7 +670,7 @@ static CPUReadMemoryFunc * const mf624_BAR4_read[3] = {
        NULL, /* read16 */
        mf624_BAR4_read32,
 };
+
 static CPUWriteMemoryFunc * const mf624_BAR4_write[3] = {
        NULL, /* write8 */
        NULL, /* write16 */
@@ -679,7 +679,7 @@ static CPUWriteMemoryFunc * const mf624_BAR4_write[3] = {
 
 
 //-----------------------------------------------------------------------------
-       
+
 static void mf624_map(PCIDevice *pci_dev, int region_num,
                        pcibus_t addr, pcibus_t size, int type)
 {