Changeset a35b458 in mainline for boot/genarch/src


Ignore:
Timestamp:
2018-03-02T20:10:49Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

Location:
boot/genarch/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • boot/genarch/src/division.c

    r3061bc1 ra35b458  
    4040        unsigned int result;
    4141        int steps = sizeof(unsigned int) * 8;
    42        
     42
    4343        *remainder = 0;
    4444        result = 0;
    45        
     45
    4646        if (b == 0) {
    4747                /* FIXME: division by zero */
    4848                return 0;
    4949        }
    50        
     50
    5151        if (a < b) {
    5252                *remainder = a;
    5353                return 0;
    5454        }
    55        
     55
    5656        for (; steps > 0; steps--) {
    5757                /* shift one bit to remainder */
    5858                *remainder = ((*remainder) << 1) | (( a >> 31) & 0x1);
    5959                result <<= 1;
    60                
     60
    6161                if (*remainder >= b) {
    6262                        *remainder -= b;
     
    6565                a <<= 1;
    6666        }
    67        
     67
    6868        return result;
    6969}
     
    7474        unsigned long long result;
    7575        int steps = sizeof(unsigned long long) * 8;
    76        
     76
    7777        *remainder = 0;
    7878        result = 0;
    79        
     79
    8080        if (b == 0) {
    8181                /* FIXME: division by zero */
    8282                return 0;
    8383        }
    84        
     84
    8585        if (a < b) {
    8686                *remainder = a;
    8787                return 0;
    8888        }
    89        
     89
    9090        for (; steps > 0; steps--) {
    9191                /* shift one bit to remainder */
    9292                *remainder = ((*remainder) << 1) | ((a >> 63) & 0x1);
    9393                result <<= 1;
    94                
     94
    9595                if (*remainder >= b) {
    9696                        *remainder -= b;
     
    9999                a <<= 1;
    100100        }
    101        
     101
    102102        return result;
    103103}
     
    108108        unsigned int rem;
    109109        int result = (int) divandmod32(ABSVAL(a), ABSVAL(b), &rem);
    110        
     110
    111111        if (SGN(a) == SGN(b))
    112112                return result;
    113        
     113
    114114        return -result;
    115115}
     
    120120        unsigned long long rem;
    121121        long long result = (long long) divandmod64(ABSVAL(a), ABSVAL(b), &rem);
    122        
     122
    123123        if (SGN(a) == SGN(b))
    124124                return result;
    125        
     125
    126126        return -result;
    127127}
     
    146146        unsigned int rem;
    147147        divandmod32(a, b, &rem);
    148        
     148
    149149        /* if divident is negative, remainder must be too */
    150150        if (!(SGN(a)))
    151151                return -((int) rem);
    152        
     152
    153153        return (int) rem;
    154154}
     
    159159        unsigned long long rem;
    160160        divandmod64(a, b, &rem);
    161        
     161
    162162        /* if divident is negative, remainder must be too */
    163163        if (!(SGN(a)))
    164164                return -((long long) rem);
    165        
     165
    166166        return (long long) rem;
    167167}
     
    187187        unsigned int rem;
    188188        int result = (int) divandmod32(ABSVAL(a), ABSVAL(b), &rem);
    189        
     189
    190190        if (SGN(a) == SGN(b)) {
    191191                *c = rem;
    192192                return result;
    193193        }
    194        
     194
    195195        *c = -rem;
    196196        return -result;
     
    207207        unsigned long long rem;
    208208        long long result = (int) divandmod64(ABSVAL(a), ABSVAL(b), &rem);
    209        
     209
    210210        if (SGN(a) == SGN(b)) {
    211211                *c = rem;
    212212                return result;
    213213        }
    214        
     214
    215215        *c = -rem;
    216216        return -result;
  • boot/genarch/src/multiplication.c

    r3061bc1 ra35b458  
    5050        unsigned int b1 = b >> 16;
    5151        unsigned int b2 = b & UINT16_MAX;
    52        
     52
    5353        unsigned long long t1 = a1 * b1;
    5454        unsigned long long t2 = a1 * b2;
    5555        t2 += a2 * b1;
    5656        unsigned long long t3 = a2 * b2;
    57        
     57
    5858        t3 = (((t1 << 16) + t2) << 16) + t3;
    59        
     59
    6060        return t3;
    6161}
     
    6767{
    6868        char neg = 0;
    69        
     69
    7070        if (a < 0) {
    7171                neg = !neg;
    7272                a = -a;
    7373        }
    74        
     74
    7575        if (b < 0) {
    7676                neg = !neg;
    7777                b = -b;
    7878        }
    79        
     79
    8080        unsigned long long a1 = a >> 32;
    8181        unsigned long long b1 = b >> 32;
    82        
     82
    8383        unsigned long long a2 = a & (UINT32_MAX);
    8484        unsigned long long b2 = b & (UINT32_MAX);
    85        
     85
    8686        if (SOFTINT_CHECK_OF && (a1 != 0) && (b1 != 0)) {
    8787                /* Error (overflow) */
    8888                return (neg ? INT64_MIN : INT64_MAX);
    8989        }
    90        
     90
    9191        /* (if OF checked) a1 or b1 is zero => result fits in 64 bits,
    9292         * no need to another overflow check
    9393         */
    9494        unsigned long long t1 = mul(a1, b2) + mul(b1, a2);
    95        
     95
    9696        if ((SOFTINT_CHECK_OF) && (t1 > UINT32_MAX)) {
    9797                /* Error (overflow) */
    9898                return (neg ? INT64_MIN : INT64_MAX);
    9999        }
    100        
     100
    101101        t1 = t1 << 32;
    102102        unsigned long long t2 = mul(a2, b2);
    103103        t2 += t1;
    104        
     104
    105105        /* t2 & (1ull << 63) - if this bit is set in unsigned long long,
    106106         * result does not fit in signed one
     
    110110                return (neg ? INT64_MIN : INT64_MAX);
    111111        }
    112        
     112
    113113        long long result = t2;
    114114        if (neg)
    115115                result = -result;
    116        
     116
    117117        return result;
    118118}
  • boot/genarch/src/ofw.c

    r3061bc1 ra35b458  
    6262        if (ofw_chosen == (phandle) -1)
    6363                halt();
    64        
     64
    6565        if ((ofw_ret_t) ofw_get_property(ofw_chosen, "stdout", &ofw_stdout,
    6666            sizeof(ofw_stdout)) <= 0)
    6767                ofw_stdout = 0;
    68        
     68
    6969        ofw_root = ofw_find_device("/");
    7070        if (ofw_root == (phandle) -1) {
     
    7272                halt();
    7373        }
    74        
     74
    7575        if ((ofw_ret_t) ofw_get_property(ofw_chosen, "mmu", &ofw_mmu,
    7676            sizeof(ofw_mmu)) <= 0) {
     
    8383                halt();
    8484        }
    85        
     85
    8686        ofw_memory = ofw_find_device("/memory");
    8787        if (ofw_memory == (phandle) -1) {
     
    110110        args.nargs = nargs;
    111111        args.nret = nret;
    112        
     112
    113113        va_list list;
    114114        va_start(list, rets);
    115        
     115
    116116        size_t i;
    117117        for (i = 0; i < nargs; i++)
    118118                args.args[i] = va_arg(list, ofw_arg_t);
    119        
     119
    120120        va_end(list);
    121        
     121
    122122        for (i = 0; i < nret; i++)
    123123                args.args[i + nargs] = 0;
    124        
     124
    125125        (void) ofw(&args);
    126        
     126
    127127        for (i = 1; i < nret; i++)
    128128                rets[i - 1] = args.args[i + nargs];
    129        
     129
    130130        return args.args[nargs];
    131131}
     
    161161{
    162162        ofw_prop_t ret = 1;
    163        
     163
    164164        if ((ofw_ret_t) ofw_get_property(device, "#address-cells", &ret,
    165165            sizeof(ret)) <= 0)
     
    167167                    sizeof(ret)) <= 0)
    168168                        ret = OFW_ADDRESS_CELLS;
    169        
     169
    170170        return (size_t) ret;
    171171}
     
    174174{
    175175        ofw_prop_t ret = 1;
    176        
     176
    177177        if ((ofw_ret_t) ofw_get_property(device, "#size-cells", &ret,
    178178            sizeof(ret)) <= 0)
     
    180180                    sizeof(ret)) <= 0)
    181181                        ret = OFW_SIZE_CELLS;
    182        
     182
    183183        return (size_t) ret;
    184184}
     
    198198        if (ofw_stdout == 0)
    199199                return;
    200        
     200
    201201        ofw_call("write", 3, 1, NULL, ofw_stdout, &ch, 1);
    202202}
     
    210210                halt();
    211211        }
    212        
     212
    213213        if (result[0] == false) {
    214214                printf("Error: Unable to translate virtual address %p, halting.\n",
     
    216216                halt();
    217217        }
    218        
     218
    219219#ifdef __32_BITS__
    220220        return (void *) result[2];
    221221#endif
    222        
     222
    223223#ifdef __64_BITS__
    224224        return (void *) ((result[2] << 32) | result[3]);
     
    235235                halt();
    236236        }
    237        
     237
    238238        return (void *) addr;
    239239}
     
    252252{
    253253        void *addr = ofw_claim_virt_internal(NULL, len, alignment);
    254        
     254
    255255        if (addr == NULL) {
    256256                printf("Error: Unable to claim %zu bytes in virtual memory, halting.\n",
     
    258258                halt();
    259259        }
    260        
     260
    261261        return addr;
    262262}
     
    276276         * purposes.
    277277         */
    278        
     278
    279279#ifdef __32_BITS__
    280280        ofw_arg_t retaddr[1];
     
    284284                halt();
    285285        }
    286        
     286
    287287        return (void *) retaddr[0];
    288288#endif
    289        
     289
    290290#ifdef __64_BITS__
    291291        ofw_arg_t retaddr[2];
     
    296296                halt();
    297297        }
    298        
     298
    299299        return (void *) ((retaddr[0] << 32) | retaddr[1]);
    300300#endif
     
    319319                halt();
    320320        }
    321        
     321
    322322        return addr;
    323323}
     
    328328        ofw_arg_t phys_hi;
    329329        ofw_arg_t phys_lo;
    330        
     330
    331331#ifdef __32_BITS__
    332332        phys_hi = (ofw_arg_t) phys;
    333333        phys_lo = 0;
    334334#endif
    335        
     335
    336336#ifdef __64_BITS__
    337337        phys_hi = (ofw_arg_t) phys >> 32;
    338338        phys_lo = (ofw_arg_t) phys & 0xffffffff;
    339339#endif
    340        
     340
    341341        ofw_arg_t ret = ofw_call("call-method", 7, 1, NULL, "map", ofw_mmu, mode,
    342342            ALIGN_UP(size, PAGE_SIZE), virt, phys_hi, phys_lo);
    343        
     343
    344344        if (ret != 0) {
    345345                printf("Error: Unable to map %p to %p (size %zu), halting.\n",
     
    360360        size_t sc = ofw_get_size_cells(ofw_memory) /
    361361            (sizeof(uintptr_t) / sizeof(uint32_t));
    362        
     362
    363363        uintptr_t buf[((ac + sc) * MEMMAP_MAX_RECORDS)];
    364        
     364
    365365        /* The number of bytes read */
    366366        ofw_ret_t ret = (ofw_ret_t) ofw_get_property(ofw_memory, "reg", buf,
     
    370370                halt();
    371371        }
    372        
     372
    373373        size_t pos;
    374374        map->total = 0;
     
    378378                void *start = (void *) (buf[pos + ac - 1]);
    379379                uintptr_t size = buf[pos + ac + sc - 1];
    380                
     380
    381381                /*
    382382                 * This is a hot fix of the issue which occurs on machines
     
    389389                    map->zones[map->cnt - 1].size < start))
    390390                        break;
    391                
     391
    392392                if (size > 0) {
    393393                        map->zones[map->cnt].start = start;
     
    397397                }
    398398        }
    399        
     399
    400400        if (map->total == 0) {
    401401                printf("Error: No physical memory detected, halting.\n");
     
    421421                *base_pa = ofw_claim_phys_any(size, PAGE_SIZE);
    422422        } while (*base_pa <= min_pa);
    423        
     423
    424424        *base = ofw_claim_virt_any(size, PAGE_SIZE);
    425425        ofw_map(*base_pa, *base, ALIGN_UP(size, PAGE_SIZE), (ofw_arg_t) -1);
     
    433433            OFW_TREE_PROPERTY_MAX_VALUELEN) <= 0)
    434434                return;
    435        
     435
    436436        device_type[OFW_TREE_PROPERTY_MAX_VALUELEN - 1] = '\0';
    437437        if (str_cmp(device_type, "display") != 0)
    438438                return;
    439        
     439
    440440        /* Check for 8 bit depth */
    441441        ofw_prop_t depth;
     
    443443            sizeof(depth)) <= 0)
    444444                depth = 0;
    445        
     445
    446446        /* Get device path */
    447447        ofw_arg_t len = ofw_package_to_path(handle, path, OFW_TREE_PATH_MAX_LEN);
    448448        if (len == (ofw_arg_t) -1)
    449449                return;
    450        
     450
    451451        path[len] = '\0';
    452        
     452
    453453        /* Open the display to initialize it */
    454454        ihandle screen = ofw_open(path);
    455455        if (screen == (ihandle) -1)
    456456                return;
    457        
     457
    458458        if (depth == 8) {
    459459                /* Setup the palette so that the (inverted) 3:2:3 scheme is usable */
     
    470470        while ((current != 0) && (current != (phandle) -1)) {
    471471                ofw_setup_screen(current);
    472                
     472
    473473                /*
    474474                 * Recursively process the potential child node.
     
    477477                if ((child != 0) && (child != (phandle) -1))
    478478                        ofw_setup_screens_internal(child);
    479                
     479
    480480                /*
    481481                 * Iteratively process the next peer node.
     
    493493                        continue;
    494494                }
    495                
     495
    496496                /*
    497497                 * No more peers on this level.
  • boot/genarch/src/ofw_tree.c

    r3061bc1 ra35b458  
    6565        if (addr)
    6666                addr[size] = '\0';
    67        
     67
    6868        return addr;
    6969}
     
    9898                current_node->property = NULL;
    9999                current_node->device = NULL;
    100                
     100
    101101                /*
    102102                 * Get the disambigued name.
     
    105105                if (len == (size_t) -1)
    106106                        return;
    107                
     107
    108108                path[len] = '\0';
    109                
     109
    110110                /* Find last slash */
    111111                size_t i;
    112112                for (i = len; (i > 0) && (path[i - 1] != '/'); i--);
    113                
     113
    114114                /* Do not include the slash */
    115115                len -= i;
    116                
     116
    117117                /* Add space for trailing '\0' */
    118118                char *da_name = ofw_tree_space_alloc(len + 1);
    119119                if (!da_name)
    120120                        return;
    121                
     121
    122122                memcpy(da_name, &path[i], len);
    123123                da_name[len] = '\0';
    124124                current_node->da_name = (char *) balloc_rebase(da_name);
    125                
     125
    126126                /*
    127127                 * Recursively process the potential child node.
     
    137137                        }
    138138                }
    139                
     139
    140140                /*
    141141                 * Count properties.
     
    146146                        memcpy(name, name2, OFW_TREE_PROPERTY_MAX_NAMELEN);
    147147                }
    148                
     148
    149149                if (!current_node->properties)
    150150                        return;
    151                
     151
    152152                /*
    153153                 * Copy properties.
     
    157157                if (!property)
    158158                        return;
    159                
     159
    160160                name[0] = '\0';
    161161                for (i = 0; ofw_next_property(current, name, name2) == 1; i++) {
    162162                        if (i == current_node->properties)
    163163                                break;
    164                        
     164
    165165                        memcpy(name, name2, OFW_TREE_PROPERTY_MAX_NAMELEN);
    166166                        memcpy(property[i].name, name, OFW_TREE_PROPERTY_MAX_NAMELEN);
    167167                        property[i].name[OFW_TREE_PROPERTY_MAX_NAMELEN - 1] = '\0';
    168                        
     168
    169169                        size_t size = ofw_get_proplen(current, name);
    170170                        property[i].size = size;
    171                        
     171
    172172                        if (size) {
    173173                                void *buf = ofw_tree_space_alloc(size);
     
    182182                                property[i].value = NULL;
    183183                }
    184                
     184
    185185                /* Just in case we ran out of memory. */
    186186                current_node->properties = i;
    187187                current_node->property = (ofw_tree_property_t *) balloc_rebase(property);
    188                
     188
    189189                /*
    190190                 * Iteratively process the next peer node.
     
    207207                        }
    208208                }
    209                
     209
    210210                /*
    211211                 * No more peers on this level.
     
    225225        if (root)
    226226                ofw_tree_node_process(root, NULL, ofw_root);
    227        
     227
    228228        /*
    229229         * The firmware client interface does not automatically include the
     
    241241                }
    242242        }
    243        
     243
    244244        return (ofw_tree_node_t *) balloc_rebase(root);
    245245}
Note: See TracChangeset for help on using the changeset viewer.