mirror of
https://github.com/Qortal/Brooklyn.git
synced 2025-01-30 23:02:18 +00:00
7d3018da4c
* NVME, SATA NAND Security added * Qortal Core exception fetcher is now redone. * Update DT overlays for firmware * Fix for bvb clockj settings * Fix for no audio for sissy desktop porn watchers -_- ( thanks crowetic for watching gay porn and reporting me that bug asshat ) * Normalize the fetch() stream while doing a peer to peer handshake for nodes * Fix for RNG token editing error while performing a SHA256 encryption * Now under voltage errors will blink red led constantly for 5 minutes then go solid. * Improve kernel thread scaling for Qortal 2.0 core * HDMI circuit is now enabled at power up instead. * Added KMS * Added line replication instead of interpolation for VC4 GPU resulting in slightly better frame rates * Fix for long and doubles * Backplane clock is now set at standard rate * Capped HVEC clocks * Add support for Creative Cinema webcam for donkers who like sharing dick pics. *looks at crowetic* * More scanline XGA modes for people who have weird ass monitors of all sorts. * TX/RX flow control support is now 100% stable. No lags over 1Gbps ethernet. ( Hello Qortal 3.0 ) * Using flush cache instead of fetch for QC 2.0 resulting in performance gains * VC4 clock is now enforced for desktop oriented images. * Ondemand governor now waits for 2 seconds instead of 0.5ms to scale down to the lowest safest clock freq preventing lags to the core. * Timeout of OC set at 35ms from 90ms resulting in way better clocks and sync for Qortal 2.0 core
129 lines
2.5 KiB
C
129 lines
2.5 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
*
|
|
* Copyright (C) 2019-2021 Paragon Software GmbH, All rights reserved.
|
|
*
|
|
*/
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include "ntfs_fs.h"
|
|
|
|
#define BITS_IN_SIZE_T (sizeof(size_t) * 8)
|
|
|
|
/*
|
|
* fill_mask[i] - first i bits are '1' , i = 0,1,2,3,4,5,6,7,8
|
|
* fill_mask[i] = 0xFF >> (8-i)
|
|
*/
|
|
static const u8 fill_mask[] = { 0x00, 0x01, 0x03, 0x07, 0x0F,
|
|
0x1F, 0x3F, 0x7F, 0xFF };
|
|
|
|
/*
|
|
* zero_mask[i] - first i bits are '0' , i = 0,1,2,3,4,5,6,7,8
|
|
* zero_mask[i] = 0xFF << i
|
|
*/
|
|
static const u8 zero_mask[] = { 0xFF, 0xFE, 0xFC, 0xF8, 0xF0,
|
|
0xE0, 0xC0, 0x80, 0x00 };
|
|
|
|
/*
|
|
* are_bits_clear
|
|
*
|
|
* Return: True if all bits [bit, bit+nbits) are zeros "0".
|
|
*/
|
|
bool are_bits_clear(const ulong *lmap, size_t bit, size_t nbits)
|
|
{
|
|
size_t pos = bit & 7;
|
|
const u8 *map = (u8 *)lmap + (bit >> 3);
|
|
|
|
if (pos) {
|
|
if (8 - pos >= nbits)
|
|
return !nbits || !(*map & fill_mask[pos + nbits] &
|
|
zero_mask[pos]);
|
|
|
|
if (*map++ & zero_mask[pos])
|
|
return false;
|
|
nbits -= 8 - pos;
|
|
}
|
|
|
|
pos = ((size_t)map) & (sizeof(size_t) - 1);
|
|
if (pos) {
|
|
pos = sizeof(size_t) - pos;
|
|
if (nbits >= pos * 8) {
|
|
for (nbits -= pos * 8; pos; pos--, map++) {
|
|
if (*map)
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
for (pos = nbits / BITS_IN_SIZE_T; pos; pos--, map += sizeof(size_t)) {
|
|
if (*((size_t *)map))
|
|
return false;
|
|
}
|
|
|
|
for (pos = (nbits % BITS_IN_SIZE_T) >> 3; pos; pos--, map++) {
|
|
if (*map)
|
|
return false;
|
|
}
|
|
|
|
pos = nbits & 7;
|
|
if (pos && (*map & fill_mask[pos]))
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
/*
|
|
* are_bits_set
|
|
*
|
|
* Return: True if all bits [bit, bit+nbits) are ones "1".
|
|
*/
|
|
bool are_bits_set(const ulong *lmap, size_t bit, size_t nbits)
|
|
{
|
|
u8 mask;
|
|
size_t pos = bit & 7;
|
|
const u8 *map = (u8 *)lmap + (bit >> 3);
|
|
|
|
if (pos) {
|
|
if (8 - pos >= nbits) {
|
|
mask = fill_mask[pos + nbits] & zero_mask[pos];
|
|
return !nbits || (*map & mask) == mask;
|
|
}
|
|
|
|
mask = zero_mask[pos];
|
|
if ((*map++ & mask) != mask)
|
|
return false;
|
|
nbits -= 8 - pos;
|
|
}
|
|
|
|
pos = ((size_t)map) & (sizeof(size_t) - 1);
|
|
if (pos) {
|
|
pos = sizeof(size_t) - pos;
|
|
if (nbits >= pos * 8) {
|
|
for (nbits -= pos * 8; pos; pos--, map++) {
|
|
if (*map != 0xFF)
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
for (pos = nbits / BITS_IN_SIZE_T; pos; pos--, map += sizeof(size_t)) {
|
|
if (*((size_t *)map) != MINUS_ONE_T)
|
|
return false;
|
|
}
|
|
|
|
for (pos = (nbits % BITS_IN_SIZE_T) >> 3; pos; pos--, map++) {
|
|
if (*map != 0xFF)
|
|
return false;
|
|
}
|
|
|
|
pos = nbits & 7;
|
|
if (pos) {
|
|
mask = fill_mask[pos];
|
|
if ((*map & mask) != mask)
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|