Changeset a35b458 in mainline for boot/genarch/src/ofw.c


Ignore:
Timestamp:
2018-03-02T20:10:49Z (8 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.
Note: See TracChangeset for help on using the changeset viewer.