Changeset c6588ce in mainline for kernel/genarch


Ignore:
Timestamp:
2012-05-05T08:12:17Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ee04c28
Parents:
2cc7f16 (diff), d21e935c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

Location:
kernel/genarch
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/include/ofw/ofw_tree.h

    r2cc7f16 rc6588ce  
    6767
    6868extern void ofw_tree_init(ofw_tree_node_t *);
    69 extern void ofw_tree_print(void);
     69extern void ofw_sysinfo_map(void);
    7070
    7171extern const char *ofw_tree_node_name(const ofw_tree_node_t *);
  • kernel/genarch/include/softint/division.h

    r2cc7f16 rc6588ce  
    3636#define KERN_DIVISION_H_
    3737
    38 /* 32bit integer division */
    39 int __divsi3(int a, int b);
     38extern int __divsi3(int, int);
     39extern long long __divdi3(long long, long long);
    4040
    41 /* 64bit integer division */
    42 long long __divdi3(long long a, long long b);
     41extern unsigned int __udivsi3(unsigned int, unsigned int);
     42extern unsigned long long __udivdi3(unsigned long long, unsigned long long);
    4343
    44 /* 32bit unsigned integer division */
    45 unsigned int __udivsi3(unsigned int a, unsigned int b);
     44extern int __modsi3(int, int);
     45extern long long __moddi3(long long, long long);
    4646
    47 /* 64bit unsigned integer division */
    48 unsigned long long __udivdi3(unsigned long long a, unsigned long long b);
     47extern unsigned int __umodsi3(unsigned int, unsigned int);
     48extern unsigned long long __umoddi3(unsigned long long, unsigned long long);
    4949
    50 /* 32bit remainder of the signed division */
    51 int __modsi3(int a, int b);
     50extern int __divmodsi3(int, int, int *);
     51extern unsigned int __udivmodsi3(unsigned int, unsigned int, unsigned int *);
    5252
    53 /* 64bit remainder of the signed division */
    54 long long __moddi3(long long a, long long b);
    55 
    56 /* 32bit remainder of the unsigned division */
    57 unsigned int __umodsi3(unsigned int a, unsigned int b);
    58 
    59 /* 64bit remainder of the unsigned division */
    60 unsigned long long __umoddi3(unsigned long long a, unsigned long long b);
    61 
    62 unsigned long long __udivmoddi3(unsigned long long a, unsigned long long b, unsigned long long *c);
     53extern long long __divmoddi3(long long, long long, long long *);
     54extern unsigned long long __udivmoddi3(unsigned long long, unsigned long long,
     55    unsigned long long *);
    6356
    6457#endif
  • kernel/genarch/include/softint/multiplication.h

    r2cc7f16 rc6588ce  
    2929/** @addtogroup genarch
    3030 * @{
    31  */ 
     31 */
    3232/**
    3333 * @file
    3434 */
    3535
    36 #ifndef __SOFTINT_MULTIPLICATION_H__
    37 #define __SOFTINT_MULTIPLICATION_H__
     36#ifndef KERN_MULTIPLICATION_H_
     37#define KERN_MULTIPLICATION_H_
    3838
    3939/* 64 bit multiplication */
    40 long long __muldi3(long long a, long long b);
     40extern long long __muldi3(long long, long long);
    4141
    4242#endif
     
    4444/** @}
    4545 */
    46 
    47 
  • kernel/genarch/src/fb/fb.c

    r2cc7f16 rc6588ce  
    390390                            instance->position / instance->cols, false);
    391391                        instance->position++;
    392                 } while ((instance->position % 8)
    393                     && (instance->position < instance->cols * instance->rows));
     392                } while (((instance->position % instance->cols) % 8 != 0) &&
     393                    (instance->position < instance->cols * instance->rows));
    394394                break;
    395395        default:
  • kernel/genarch/src/ofw/ofw_tree.c

    r2cc7f16 rc6588ce  
    3838#include <genarch/ofw/ofw_tree.h>
    3939#include <mm/slab.h>
     40#include <sysinfo/sysinfo.h>
    4041#include <memstr.h>
    4142#include <str.h>
     
    6566    const char *name)
    6667{
    67         size_t i;
    68        
    69         for (i = 0; i < node->properties; i++) {
     68        for (size_t i = 0; i < node->properties; i++) {
    7069                if (str_cmp(node->property[i].name, name) == 0)
    7170                        return &node->property[i];
     
    104103    const char *name)
    105104{
    106         ofw_tree_node_t *cur;
    107        
    108105        /*
    109106         * Try to find the disambigued name.
    110107         */
    111         for (cur = node->child; cur; cur = cur->peer) {
     108        for (ofw_tree_node_t *cur = node->child; cur; cur = cur->peer) {
    112109                if (str_cmp(cur->da_name, name) == 0)
    113110                        return cur;
     
    121118         * are not always fully-qualified.
    122119         */
    123         for (cur = node->child; cur; cur = cur->peer) {
     120        for (ofw_tree_node_t *cur = node->child; cur; cur = cur->peer) {
    124121                if (str_cmp(ofw_tree_node_name(cur), name) == 0)
    125122                        return cur;
     
    141138    const char *dtype)
    142139{
    143         ofw_tree_node_t *cur;
    144        
    145         for (cur = node->child; cur; cur = cur->peer) {
     140        for (ofw_tree_node_t *cur = node->child; cur; cur = cur->peer) {
    146141                ofw_tree_property_t *prop =
    147142                    ofw_tree_getprop(cur, "device_type");
     
    172167    phandle handle)
    173168{
    174         ofw_tree_node_t *cur;
    175        
    176         for (cur = root; cur; cur = cur->peer) {
     169        for (ofw_tree_node_t *cur = root; cur; cur = cur->peer) {
    177170                if (cur->node_handle == handle)
    178171                        return cur;
    179172               
    180173                if (cur->child) {
    181                         ofw_tree_node_t *node
    182                             = ofw_tree_find_node_by_handle(cur->child, handle);
     174                        ofw_tree_node_t *node =
     175                            ofw_tree_find_node_by_handle(cur->child, handle);
    183176                        if (node)
    184177                                return node;
     
    201194    const char *dtype)
    202195{
    203         ofw_tree_node_t *cur;
    204        
    205         for (cur = node->peer; cur; cur = cur->peer) {
     196        for (ofw_tree_node_t *cur = node->peer; cur; cur = cur->peer) {
    206197                ofw_tree_property_t *prop =
    207198                    ofw_tree_getprop(cur, "device_type");
     
    229220    const char *name)
    230221{
    231         ofw_tree_node_t *cur;
    232        
    233         for (cur = node->peer; cur; cur = cur->peer) {
    234                 ofw_tree_property_t *prop
    235                     = ofw_tree_getprop(cur, "name");
     222        for (ofw_tree_node_t *cur = node->peer; cur; cur = cur->peer) {
     223                ofw_tree_property_t *prop =
     224                    ofw_tree_getprop(cur, "name");
    236225               
    237226                if ((!prop) || (!prop->value))
     
    259248       
    260249        ofw_tree_node_t *node = ofw_root;
    261         size_t i;
    262250        size_t j;
    263251       
    264         for (i = 1; (i < str_size(path)) && (node); i = j + 1) {
     252        for (size_t i = 1; (i < str_size(path)) && (node); i = j + 1) {
    265253                for (j = i; (j < str_size(path)) && (path[j] != '/'); j++);
    266254               
     
    294282    const char *dtype, ofw_tree_walker_t walker, void *arg)
    295283{
    296         ofw_tree_node_t *cur;
    297        
    298         for (cur = node; cur; cur = cur->peer) {
     284        for (ofw_tree_node_t *cur = node; cur; cur = cur->peer) {
    299285                ofw_tree_property_t *prop =
    300286                    ofw_tree_getprop(cur, "device_type");
     
    334320}
    335321
    336 /** Print OpenFirmware device subtree rooted in a node.
     322/** Get OpenFirmware node properties.
     323 *
     324 * @param item    Sysinfo item (unused).
     325 * @param size    Size of the returned data.
     326 * @param dry_run Do not get the data, just calculate the size.
     327 * @param data    OpenFirmware node.
     328 *
     329 * @return Data containing a serialized dump of all node
     330 *         properties. If the return value is not NULL, it
     331 *         should be freed in the context of the sysinfo request.
     332 *
     333 */
     334static void *ofw_sysinfo_properties(struct sysinfo_item *item, size_t *size,
     335    bool dry_run, void *data)
     336{
     337        ofw_tree_node_t *node = (ofw_tree_node_t *) data;
     338       
     339        /* Compute serialized data size */
     340        *size = 0;
     341        for (size_t i = 0; i < node->properties; i++)
     342                *size += str_size(node->property[i].name) + 1 +
     343                    sizeof(node->property[i].size) + node->property[i].size;
     344       
     345        if (dry_run)
     346                return NULL;
     347       
     348        void *dump = malloc(*size, FRAME_ATOMIC);
     349        if (dump == NULL) {
     350                *size = 0;
     351                return NULL;
     352        }
     353       
     354        /* Serialize the data */
     355        size_t pos = 0;
     356        for (size_t i = 0; i < node->properties; i++) {
     357                /* Property name */
     358                str_cpy(dump + pos, *size - pos, node->property[i].name);
     359                pos += str_size(node->property[i].name) + 1;
     360               
     361                /* Value size */
     362                memcpy(dump + pos, &node->property[i].size,
     363                    sizeof(node->property[i].size));
     364                pos += sizeof(node->property[i].size);
     365               
     366                /* Value */
     367                memcpy(dump + pos, node->property[i].value,
     368                    node->property[i].size);
     369                pos += node->property[i].size;
     370        }
     371       
     372        return ((void *) dump);
     373}
     374
     375/** Map OpenFirmware device subtree rooted in a node into sysinfo.
    337376 *
    338377 * Child nodes are processed recursively and peer nodes are processed
     
    343382 *
    344383 */
    345 static void ofw_tree_node_print(ofw_tree_node_t *node, const char *path)
     384static void ofw_tree_node_sysinfo(ofw_tree_node_t *node, const char *path)
    346385{
    347386        char *cur_path = (char *) malloc(PATH_MAX_LEN, 0);
    348         ofw_tree_node_t *cur;
    349        
    350         for (cur = node; cur; cur = cur->peer) {
    351                 if ((cur->parent) && (path)) {
    352                         snprintf(cur_path, PATH_MAX_LEN, "%s/%s", path, cur->da_name);
    353                         printf("%s\n", cur_path);
    354                 } else {
    355                         snprintf(cur_path, PATH_MAX_LEN, "%s", cur->da_name);
    356                         printf("/\n");
    357                 }
     387       
     388        for (ofw_tree_node_t *cur = node; cur; cur = cur->peer) {
     389                if ((cur->parent) && (path))
     390                        snprintf(cur_path, PATH_MAX_LEN, "%s.%s", path, cur->da_name);
     391                else
     392                        snprintf(cur_path, PATH_MAX_LEN, "firmware.%s", cur->da_name);
     393               
     394                sysinfo_set_item_gen_data(cur_path, NULL, ofw_sysinfo_properties,
     395                    (void *) cur);
    358396               
    359397                if (cur->child)
    360                         ofw_tree_node_print(cur->child, cur_path);
     398                        ofw_tree_node_sysinfo(cur->child, cur_path);
    361399        }
    362400       
     
    364402}
    365403
    366 /** Print the structure of the OpenFirmware device tree. */
    367 void ofw_tree_print(void)
    368 {
    369         ofw_tree_node_print(ofw_root, NULL);
     404/** Map the OpenFirmware device tree into sysinfo. */
     405void ofw_sysinfo_map(void)
     406{
     407        ofw_tree_node_sysinfo(ofw_root, NULL);
    370408}
    371409
  • kernel/genarch/src/softint/division.c

    r2cc7f16 rc6588ce  
    2727 */
    2828
    29 /** @addtogroup genarch 
     29/** @addtogroup genarch
    3030 * @{
    3131 */
     
    3535#include <genarch/softint/division.h>
    3636
    37 #define ABSVAL(x) ((x) > 0 ? (x) : -(x))
    38 #define SGN(x) ((x) >= 0 ? 1 : 0)
    39                                      
     37#define ABSVAL(x)  ((x) > 0 ? (x) : -(x))
     38#define SGN(x)     ((x) >= 0 ? 1 : 0)
     39
    4040static unsigned int divandmod32(unsigned int a, unsigned int b,
    4141    unsigned int *remainder)
     
    5656                return 0;
    5757        }
    58 
     58       
    5959        for (; steps > 0; steps--) {
    6060                /* shift one bit to remainder */
     
    6868                a <<= 1;
    6969        }
    70 
     70       
    7171        return result;
    7272}
    73 
    7473
    7574static unsigned long long divandmod64(unsigned long long a,
     
    7776{
    7877        unsigned long long result;
    79         int steps = sizeof(unsigned long long) * 8; 
     78        int steps = sizeof(unsigned long long) * 8;
    8079       
    8180        *remainder = 0;
     
    9190                return 0;
    9291        }
    93 
     92       
    9493        for (; steps > 0; steps--) {
    9594                /* shift one bit to remainder */
     
    103102                a <<= 1;
    104103        }
    105 
     104       
    106105        return result;
    107106}
    108107
    109108/* 32bit integer division */
    110 int __divsi3(int a, int b)
    111 {
    112         unsigned int rem;
    113         int result;
    114        
    115         result = (int) divandmod32(ABSVAL(a), ABSVAL(b), &rem);
    116 
     109int __divsi3(int a, int b)
     110{
     111        unsigned int rem;
     112        int result = (int) divandmod32(ABSVAL(a), ABSVAL(b), &rem);
     113       
    117114        if (SGN(a) == SGN(b))
    118115                return result;
     116       
    119117        return -result;
    120118}
    121119
    122120/* 64bit integer division */
    123 long long __divdi3(long long a, long long b)
    124 {
    125         unsigned long long rem;
    126         long long result;
    127        
    128         result = (long long) divandmod64(ABSVAL(a), ABSVAL(b), &rem);
    129 
     121long long __divdi3(long long a, long long b)
     122{
     123        unsigned long long rem;
     124        long long result = (long long) divandmod64(ABSVAL(a), ABSVAL(b), &rem);
     125       
    130126        if (SGN(a) == SGN(b))
    131127                return result;
     128       
    132129        return -result;
    133130}
     
    143140unsigned long long __udivdi3(unsigned long long a, unsigned long long b)
    144141{
    145         unsigned long long  rem;
     142        unsigned long long rem;
    146143        return divandmod64(a, b, &rem);
    147144}
     
    154151       
    155152        /* if divident is negative, remainder must be too */
    156         if (!(SGN(a))) {
     153        if (!(SGN(a)))
    157154                return -((int) rem);
    158         }
    159155       
    160156        return (int) rem;
     
    162158
    163159/* 64bit remainder of the signed division */
    164 long long __moddi3(long long a,long long b)
     160long long __moddi3(long long a, long long b)
    165161{
    166162        unsigned long long rem;
     
    168164       
    169165        /* if divident is negative, remainder must be too */
    170         if (!(SGN(a))) {
     166        if (!(SGN(a)))
    171167                return -((long long) rem);
    172         }
    173168       
    174169        return (long long) rem;
     
    191186}
    192187
     188int __divmodsi3(int a, int b, int *c)
     189{
     190        unsigned int rem;
     191        int result = (int) divandmod32(ABSVAL(a), ABSVAL(b), &rem);
     192       
     193        if (SGN(a) == SGN(b)) {
     194                *c = rem;
     195                return result;
     196        }
     197       
     198        *c = -rem;
     199        return -result;
     200}
     201
     202unsigned int __udivmodsi3(unsigned int a, unsigned int b,
     203    unsigned int *c)
     204{
     205        return divandmod32(a, b, c);
     206}
     207
     208long long __divmoddi3(long long a, long long b, long long *c)
     209{
     210        unsigned long long rem;
     211        long long result = (int) divandmod64(ABSVAL(a), ABSVAL(b), &rem);
     212       
     213        if (SGN(a) == SGN(b)) {
     214                *c = rem;
     215                return result;
     216        }
     217       
     218        *c = -rem;
     219        return -result;
     220}
     221
    193222unsigned long long __udivmoddi3(unsigned long long a, unsigned long long b,
    194223    unsigned long long *c)
  • kernel/genarch/src/softint/multiplication.c

    r2cc7f16 rc6588ce  
    2929/** @addtogroup genarch
    3030 * @{
    31  */ 
     31 */
    3232/**
    3333 * @file
     
    130130
    131131        return result;
    132 }       
     132}
    133133
    134134/** @}
Note: See TracChangeset for help on using the changeset viewer.