summaryrefslogtreecommitdiffstats
path: root/meta-agl-bsp/meta-rcar-gen3/recipes-kernel
AgeCommit message (Expand)AuthorFilesLines
2017-07-12Add ath9k_htc driver to rcar-gen3 for demosScott Murray2-0/+3
2017-06-29Fix CVE-2017-1000364 by backporting the patches for gen3Jan-Simon Möller4-0/+1048
2017-05-12linux-renesas: Applies Smack patch for bluetoothJosé Bollo2-0/+57
2017-04-20meta-rcar-gen3: add CONFIG_INPUT_UINPUT to bluetooth.cfgMatt Ranostay1-0/+5
2017-03-19[rcar-gen3] Disable ipv6Ronan Le Martret2-1/+6
2017-03-19[rcar-gen3] Rename kernel-module-uvcs recipesRonan Le Martret1-0/+0
2017-02-06Add bluetooth support to renesas rcar-gen3.Builder2-1/+33
2017-01-02Fix to get netboot activated also for renesas gen3Romain Forlot3-1/+6
2016-12-06add namespace to config kernelRonan2-0/+8
2016-11-23meta-rcar-gen3: autoload mmp modulesYannick Gicquel4-0/+4
2016-11-16meta-rcar-gen3: gles: support for AGL toolchainYannick Gicquel1-0/+4
light .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
#include <bitfield/bitfield.h>
#include <bitfield/8byte.h>
#include <stddef.h>
#include <limits.h>
#include <string.h>

#define EIGHTBYTE_BIT (8 * sizeof(uint64_t))

uint64_t bitmask(const uint8_t bit_count) {
    return (((uint64_t)0x1) << bit_count) - 1;
}

static uint16_t bits_to_bytes(uint32_t bits) {
    uint8_t byte_count = bits / CHAR_BIT;
    if(bits % CHAR_BIT != 0) {
        ++byte_count;
    }
    return byte_count;
}

uint64_t get_bit_field(uint64_t source, const uint16_t startBit,
        const uint16_t bit_count, bool big_endian) {
    uint8_t result[8] = {0};
    if(!big_endian) {
        source = __builtin_bswap64(source);
    }
    copyBitsRightAligned((const uint8_t*)&source, sizeof(source), startBit,
            bit_count, result, sizeof(result));
    uint64_t int_result = 0;

    if(!big_endian) {
        // we need to swap the byte order of the array to get it into a
        // uint64_t, but it's been right aligned so we have to be more careful
        for(int i = 0; i < bits_to_bytes(bit_count); i++) {
            int_result |= result[bits_to_bytes(bit_count) - i - 1] << (CHAR_BIT * i);
        }
    } else {
        int_result = *(uint64_t*)result;
    }
    return int_result;
}

/**
 * TODO it would be nice to have a warning if you call with this a value that
 * won't fit in the number of bits you've specified it should use.
 */
void set_bit_field(uint64_t* destination, uint64_t value, const uint16_t offset,
        const uint16_t bit_count) {
    int shiftDistance = EIGHTBYTE_BIT - offset - bit_count;
    value <<= shiftDistance;
    *destination &= ~(bitmask(bit_count) << shiftDistance);
    *destination |= value;
}

uint8_t nth_byte(const uint64_t source, const uint16_t byte_index) {
    return (source >> (EIGHTBYTE_BIT - ((byte_index + 1) * CHAR_BIT))) & 0xFF;
}