blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
721
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
57
| license_type
stringclasses 2
values | repo_name
stringlengths 5
91
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 321
values | visit_date
timestamp[ns]date 2016-08-12 09:31:09
2023-09-06 10:45:07
| revision_date
timestamp[ns]date 2010-09-28 14:01:40
2023-09-06 06:22:19
| committer_date
timestamp[ns]date 2010-09-28 14:01:40
2023-09-06 06:22:19
| github_id
int64 426
681M
| star_events_count
int64 101
243k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 23
values | gha_event_created_at
timestamp[ns]date 2012-06-28 18:51:49
2023-09-14 21:59:16
⌀ | gha_created_at
timestamp[ns]date 2008-02-11 22:55:26
2023-08-10 11:14:58
⌀ | gha_language
stringclasses 147
values | src_encoding
stringclasses 26
values | language
stringclasses 2
values | is_vendor
bool 2
classes | is_generated
bool 2
classes | length_bytes
int64 6
10.2M
| extension
stringclasses 115
values | filename
stringlengths 3
113
| content
stringlengths 6
10.2M
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
9cc5bc0631b75133b5b8d9908fbe4f107a842516
|
cf56b5fcf51fddb219c47f5f006d8595a4483c57
|
/src/components/cl/ucc_cl.h
|
b9b4a94dd4bb9c4efb1da244298ebcfc1314ad7c
|
[
"BSD-3-Clause"
] |
permissive
|
openucx/ucc
|
3b39fbd849a7850c559b60eaec7882292f8a5eca
|
f89cd7557e6ebb19b4c6ebd529647d8b42c30657
|
refs/heads/master
| 2023-08-18T03:18:54.072899
| 2023-08-17T18:05:44
| 2023-08-17T18:05:44
| 282,490,868
| 150
| 57
|
BSD-3-Clause
| 2023-09-12T09:49:18
| 2020-07-25T17:18:51
|
C
|
UTF-8
|
C
| false
| false
| 4,775
|
h
|
ucc_cl.h
|
/**
* Copyright (c) 2020, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*
* See file LICENSE for terms.
*/
#include "config.h"
#ifndef UCC_CL_H_
#define UCC_CL_H_
#include "components/base/ucc_base_iface.h"
#include "ucc_cl_type.h"
#include "utils/ucc_parser.h"
#include "core/ucc_context.h"
/** CL (collective layer) is an internal collective interface reflecting the
public UCC API and extensions to support modularity, the composition of
multiple collective implementations, and functionality that bridges the
gap between hardware implementation of communication primitives and the
programming models.
The CL layer will build upon TL for the communication transport requirements.
The CL can include a basic implementation, which provides minimal
functionality over the TL, or can provide more optimized implementation such
as hierarchical implementation that leverages multiple TL components.
The different implementations of CL are realized as different CL components.
The CL components are loaded dynamically, and their names should match the
predefined pattern “ucc_cl_.so”. The CL that is used for a given application
invocation can be selected with the UCC_CLS lib parameter.
*/
typedef struct ucc_cl_lib ucc_cl_lib_t;
typedef struct ucc_cl_iface ucc_cl_iface_t;
typedef struct ucc_cl_context ucc_cl_context_t;
typedef struct ucc_cl_team ucc_cl_team_t;
typedef struct ucc_tl_context ucc_tl_context_t;
typedef struct ucc_cl_lib_config {
ucc_base_lib_config_t super;
ucc_cl_iface_t *iface;
ucc_config_allow_list_t tls;
} ucc_cl_lib_config_t;
extern ucc_config_field_t ucc_cl_lib_config_table[];
typedef struct ucc_cl_context_config {
ucc_base_ctx_config_t super;
ucc_cl_lib_t *cl_lib;
} ucc_cl_context_config_t;
extern ucc_config_field_t ucc_cl_context_config_table[];
ucc_status_t ucc_cl_context_config_read(ucc_cl_lib_t *cl_lib,
const ucc_context_config_t *config,
ucc_cl_context_config_t **cl_config);
ucc_status_t ucc_cl_lib_config_read(ucc_cl_iface_t *iface,
const char *full_prefix,
ucc_cl_lib_config_t **cl_config);
typedef struct ucc_cl_iface {
ucc_component_iface_t super;
ucc_cl_type_t type;
ucc_config_global_list_entry_t cl_lib_config;
ucc_config_global_list_entry_t cl_context_config;
ucc_base_lib_iface_t lib;
ucc_base_context_iface_t context;
ucc_base_team_iface_t team;
ucc_base_coll_iface_t coll;
ucc_base_coll_alg_info_t * alg_info[UCC_COLL_TYPE_NUM];
} ucc_cl_iface_t;
typedef struct ucc_cl_lib {
ucc_base_lib_t super;
ucc_cl_iface_t *iface;
ucc_config_names_list_t tls;
ucc_config_names_array_t tls_forced; /*< set of TLs that are
requested explicitly */
} ucc_cl_lib_t;
UCC_CLASS_DECLARE(ucc_cl_lib_t, ucc_cl_iface_t *, const ucc_cl_lib_config_t *);
typedef struct ucc_cl_context {
ucc_base_context_t super;
ucc_tl_context_t **tl_ctxs;
unsigned n_tl_ctxs;
} ucc_cl_context_t;
UCC_CLASS_DECLARE(ucc_cl_context_t, const ucc_cl_context_config_t *,
ucc_context_t *);
typedef struct ucc_cl_team {
ucc_base_team_t super;
} ucc_cl_team_t;
UCC_CLASS_DECLARE(ucc_cl_team_t, ucc_cl_context_t *,
const ucc_base_team_params_t *);
typedef struct ucc_cl_lib_attr {
ucc_base_lib_attr_t super;
ucc_config_names_array_t *tls;
ucc_config_names_array_t *tls_forced;
} ucc_cl_lib_attr_t;
#define UCC_CL_IFACE_DECLARE(_name, _NAME) \
UCC_BASE_IFACE_DECLARE(CL_, cl_, _name, _NAME) \
__attribute__((constructor)) static void ucc_cl_ ## _name ## \
_iface_construct(void) { \
ucc_cl_ ## _name .super.type = UCC_CL_ ## _NAME; \
} \
#define UCC_CL_CTX_IFACE(_cl_ctx) \
(ucc_derived_of((_cl_ctx)->super.lib, ucc_cl_lib_t))->iface
#define UCC_CL_TEAM_IFACE(_cl_team) \
(ucc_derived_of((_cl_team)->super.context->lib, ucc_cl_lib_t))->iface
#define UCC_CL_TEAM_LIB(_cl_team) (_cl_team)->super.super.context->lib
#define UCC_CL_TEAM_CTX(_cl_team) (_cl_team)->super.super.context
#define UCC_CL_TEAM_SIZE(_cl_team) (_cl_team)->super.super.params.size
#define UCC_CL_TEAM_RANK(_cl_team) (_cl_team)->super.super.params.rank
#endif
|
c43a3cb08dc25fc8b99631cda499637022848510
|
9f01cf4f599af5ef184b0a0c5ddc9a5ae6e249bf
|
/engine/source/gamelib/font.c
|
b06d04af23a97425bf77082119fef4128f38e871
|
[] |
permissive
|
DCurrent/openbor
|
89f348ce7a93519f420ac6602d1fea615703f4ca
|
7f6f17507078848be625e6d1c1b4f41823151387
|
refs/heads/master
| 2023-09-03T12:41:21.059545
| 2022-04-22T20:39:58
| 2022-04-22T20:39:58
| 86,879,076
| 817
| 127
|
BSD-3-Clause
| 2023-09-13T11:47:20
| 2017-04-01T03:06:14
|
C
|
UTF-8
|
C
| false
| false
| 11,470
|
c
|
font.c
|
/*
* OpenBOR - http://www.chronocrash.com
* -----------------------------------------------------------------------
* All rights reserved, see LICENSE in OpenBOR root for details.
*
* Copyright (c) 2004 - 2014 OpenBOR Team
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include "types.h"
#include "screen.h"
#include "loadimg.h"
#include "bitmap.h"
#include "sprite.h"
#include "spriteq.h"
#include "font.h"
s_font **fonts[MAX_FONTS];
static char b[1024];
void _font_unload(s_font *font)
{
int i;
for(i = 0; i < 256; i++)
{
if(font->token[i] != NULL)
{
if(font->token[i]->mask != NULL)
{
free(font->token[i]->mask);
}
free(font->token[i]);
}
font->token[i] = NULL;
}
free(font);
}
void font_unload(int which)
{
int j, max;
s_font **sets, *font;
which %= MAX_FONTS;
sets = fonts[which];
if(!sets)
{
return;
}
max = (sets[0] && sets[0]->mbs) ? 256 : 1;
for(j = 0; j < max; j++)
{
font = sets[j];
if(!font)
{
continue;
}
_font_unload(font);
sets[j] = NULL;
}
free(sets);
fonts[which] = NULL;
}
int _font_load(s_font *font, char *filename, char *packfile)
{
int x, y;
int index = 0;
int size;
int cx = 0, cy = 0;
s_bitmap *bitmap = NULL;
s_screen *screen = NULL;
int rval = 0;
int tw, th;
if(!loadscreen(filename, packfile, NULL, pixelformat, &screen))
{
goto err;
}
font->width = tw = screen->width / 16;
font->height = th = screen->height / 16;
if(!(bitmap = allocbitmap(tw, th, pixelformat)))
{
goto err;
}
if(bitmap->palette && screen->palette)
{
memcpy(bitmap->palette, screen->palette, PAL_BYTES);
}
// grab tokens
for(y = 0; y < 16; y++)
{
for(x = 0; x < 16; x++)
{
getbitmap(x * tw, y * th, tw, th, bitmap, screen);
clipbitmap(bitmap, &cx, NULL, &cy, NULL);
if(index > 0)
{
bitmap->palette = NULL;
}
size = fakey_encodesprite(bitmap);
font->token[index] = (s_sprite *)malloc(size);
if(!font->token[index])
{
goto err;
}
encodesprite(-cx, -cy, bitmap, font->token[index]);
font->token_width[index] = font->mono ? tw : (font->token[index]->width + (tw / 10));
if(font->token_width[index] <= 1)
{
font->token_width[index] = tw / 3;
}
if(index > 0)
{
font->token[index]->palette = font->token[0]->palette ;
font->token[index]->pixelformat = screen->pixelformat ;
}
++index;
}
}
rval = 1;
err:
freebitmap(bitmap);
freescreen(&screen);
return rval;
}
int _font_loadmask(s_font *font, char *filename, char *packfile)
{
int x, y;
int index = 0;
int size;
int cx = 0, cy = 0;
s_bitmap *bitmap = NULL;
s_screen *screen = NULL;
int rval = 0;
int tw, th;
int cw;
if(!loadscreen(filename, packfile, NULL, pixelformat, &screen))
{
goto err;
}
tw = screen->width / 16;
th = screen->height / 16;
if(tw != font->width || th != font->height)
{
goto err;
}
if(!(bitmap = allocbitmap(tw, th, pixelformat)))
{
goto err;
}
if(bitmap->palette && screen->palette)
{
memcpy(bitmap->palette, screen->palette, PAL_BYTES);
}
// grab tokens
for(y = 0; y < 16; y++)
{
for(x = 0; x < 16; x++)
{
getbitmap(x * tw, y * th, tw, th, bitmap, screen);
clipbitmap(bitmap, &cx, NULL, &cy, NULL);
if(index > 0)
{
bitmap->palette = NULL;
}
size = fakey_encodesprite(bitmap);
if(!font->token[index])
{
goto err;
}
if(font->token[index]->mask)
{
goto err;
}
font->token[index]->mask = (s_sprite *)malloc(size);
if(!font->token[index]->mask)
{
goto err;
}
encodesprite(-cx, -cy, bitmap, font->token[index]->mask);
cw = font->mono ? tw : (font->token[index]->mask->width + (tw / 10));
if(cw <= 1)
{
cw = tw / 3;
}
if(cw != font->token_width[index])
{
goto err;
}
if(index > 0)
{
//font->token[index]->mask->palette = font->token[0]->mask->palette ;
font->token[index]->mask->pixelformat = screen->pixelformat ;
}
++index;
}
}
rval = 1;
err:
freebitmap(bitmap);
freescreen(&screen);
return rval;
}
int font_load(int which, char *filename, char *packfile, int flags)
{
s_font **sets, *font;
int i, max;
which %= MAX_FONTS;
font_unload(which);
max = (flags & FONT_MBS) ? 256 : 1;
// UT: 129 should be enough for mbs, use 256 to keep the logic simpler
fonts[which] = sets = malloc(sizeof(s_font *)*max);
memset(sets, 0, sizeof(s_font *)*max);
for(i = 0; i < max; i++)
{
if(i == 1)
{
i = 128;
}
font = malloc(sizeof(s_font));
memset(font, 0, sizeof(s_font));
font->mono = ((flags & FONT_MONO) != 0);
font->mbs = ((flags & FONT_MBS) != 0);
if(font->mbs)
{
sprintf(b, "%s/%02x", filename, i);
}
else
{
strcpy(b, filename);
}
if(!_font_load(font, b, packfile))
{
_font_unload(font);
font = NULL;
}
sets[i] = font;
}
if(sets[0] == NULL)
{
font_unload(which);
return 0;
}
return 1;
}
// loads an alpha mask for an already-loaded font
int font_loadmask(int which, char *filename, char *packfile, int flags)
{
s_font **sets, *font;
int i, max, ret = 0;
which %= MAX_FONTS;
sets = fonts[which];
if(!sets)
{
return 0;
}
max = (flags & FONT_MBS) ? 256 : 1;
for(i = 0; i < max; i++)
{
if(i == 1)
{
i = 128;
}
font = sets[i];
if(!font)
{
continue;
}
if(font->mbs)
{
sprintf(b, "%s/%02x", filename, i);
}
else
{
strcpy(b, filename);
}
if(!_font_loadmask(font, b, packfile))
{
;//return 0;
}
else
{
ret = 1;
}
}
return ret;
}
int fontmonowidth(int which)
{
s_font **sets;
which %= MAX_FONTS;
sets = fonts[which];
if(!sets || !sets[0])
{
return 0;
}
return sets[0]->width;
}
int fontheight(int which)
{
s_font **sets;
which %= MAX_FONTS;
sets = fonts[which];
if(!sets || !sets[0])
{
return 0;
}
return sets[0]->height;
}
int font_string_width(int which, char *format, ...)
{
int w = 0;
char *buf = b, c;
va_list arglist;
s_font **sets, *font;
int mbs, index;
which %= MAX_FONTS;
sets = fonts[which];
if(!sets || !format)
{
return 0;
}
mbs = sets[0]->mbs;
va_start(arglist, format);
vsprintf(buf, format, arglist);
va_end(arglist);
if(!mbs)
{
font = sets[0];
if(font)
while(*buf)
{
w += font->token_width[((int)(*buf)) & 0xFF];
buf++;
}
}
else
{
while((c = *buf))
{
if((c & 0x80) && buf[1])
{
index = (unsigned char)c;
buf++;
}
else
{
index = 0;
}
font = sets[index];
if(font)
{
w += font->token_width[((int)(*buf)) & 0xFF];
}
buf++;
}
}
return w;
}
// Caskey, Damon V.
// 2016-11-21
//
// Works as a wrapper for font_string_width.
// Accepts pointer to an array of strings,
// number of elements, and font. Returns
// the width of largest string.
//
// Note this function is unessesary when
// the number of string elements is small
// or known in feeeder function as
// font_string_width() is variadic.
int font_string_width_max(char **strings, int elements, int font)
{
int i; // Cursor.
int width_temp; // String width in loop instance.
int result; // Final result.
// Initialize variables.
width_temp = 0;
result = 0;
// Loop each string element, get its font
// width and keep if the result is larger
// than previous. When finished result will
// be the width of longest string.
for (i = 0; i < elements; i++)
{
width_temp = font_string_width(font, strings[i]);
if (width_temp > result)
{
result = width_temp;
}
}
return result;
}
void font_printf(int x, int y, int which, int layeroffset, char *format, ...)
{
char *buf = b, c;
va_list arglist;
int ox = x;
s_font **sets, *font;
int mbs, index, w, lf;
which %= MAX_FONTS;
sets = fonts[which];
if(!sets)
{
return;
}
mbs = sets[0]->mbs;
va_start(arglist, format);
vsprintf(buf, format, arglist);
va_end(arglist);
while((c = *buf))
{
lf = (c == '\n');
if(mbs && (c & 0x80) && buf[1])
{
index = (unsigned char)c;
buf++;
}
else
{
index = 0;
}
font = sets[index];
if(font)
{
if(lf)
{
x = ox;
y += font->height;
}
else
{
w = font->token_width[((int)(*buf)) & 0xFF];
spriteq_add_frame(x, y, FONT_LAYER + layeroffset, font->token[((int)(*buf)) & 0xFF], NULL, 0);
x += w;
}
}
buf++;
}
}
// Print to a screen rather than queueing the sprites
void screen_printf(s_screen *screen, int x, int y, int which, char *format, ...)
{
char *buf = b, c;
va_list arglist;
int ox = x;
s_font **sets, *font;
int mbs, index, w, lf;
which %= MAX_FONTS;
sets = fonts[which];
if(!sets)
{
return;
}
mbs = sets[0]->mbs;
va_start(arglist, format);
vsprintf(buf, format, arglist);
va_end(arglist);
while((c = *buf))
{
lf = (c == '\n');
if(mbs && (c & 0x80) && buf[1])
{
index = (unsigned char)c;
buf++;
}
else
{
index = 0;
}
font = sets[index];
if(font)
{
if(lf)
{
x = ox;
y += font->height;
}
else
{
w = font->token_width[((int)(*buf)) & 0xFF];
putsprite(x, y, font->token[((int)(*buf)) & 0xFF], screen, NULL);
x += w;
}
}
buf++;
}
}
|
7fdc5b559b338d1dfff55c9e9388abbaac85a874
|
1598858ecbcaa8a03feec79f2cbb39e0bb9add3f
|
/Silicon/MeteorlakePkg/Library/GpioV2Lib/GpioV2Init.c
|
8e4911bd2f5e8558f10f75def1c3d7261e8bffe1
|
[
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference",
"BSD-2-Clause-Patent"
] |
permissive
|
slimbootloader/slimbootloader
|
def5dc5a4743d74d7349d79710b758c476e33cc6
|
ec5c39e35a3ab798c6509652869d2e951ede7b61
|
refs/heads/master
| 2023-08-25T08:53:17.422999
| 2023-08-23T12:18:51
| 2023-08-24T16:52:21
| 148,708,107
| 379
| 196
|
NOASSERTION
| 2023-09-14T05:49:16
| 2018-09-13T23:07:33
|
C
|
UTF-8
|
C
| false
| false
| 39,576
|
c
|
GpioV2Init.c
|
/** @file
This file contains routines for GPIO
Copyright (c) 2020 - 2023, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <Uefi/UefiBaseType.h>
#include <GpioConfig.h>
#include <Library/GpioV2Lib.h>
#include <Library/GpioSiLib.h>
#include <Library/PchSbiAccessLib.h>
#include <Library/ConfigDataLib.h>
#include <Include/GpioV2Config.h>
#include <GpioV2PinsMtlSoc.h>
#include <Library/PrintLib.h>
#include <Library/MtlSocGpioTopologyLib.h>
#include <Base.h>
#include <Library/BaseLib.h>
#define GPIO_DEBUG_INFO DEBUG_VERBOSE
#define GPIO_DEBUG_ERROR DEBUG_VERBOSE
/**
This procedure verifies if requested GpioGroup definition is ment for platform that it is used on
@param[in] GpioServices Gpio Services
@param[in] GpioGroup GPIO pad
@param[out] IsValid Pointer to a buffer for validation information, TRUE or FALSE
@retval EFI_SUCCESS The function completed successfully
@retval EFI_INVALID_PARAMETER Invalid group or pad number
**/
EFI_STATUS
EFIAPI
IsGroupValid (
IN GPIOV2_PAD_GROUP GpioGroup,
OUT BOOLEAN *IsValid
)
{
UINT32 ChipsetId;
UINT32 CommunityIndex;
UINT32 GroupIndex;
ChipsetId = GPIOV2_PAD_GET_CHIPSETID (GpioGroup);
CommunityIndex = GPIOV2_PAD_GET_COMMUNITY_INDEX (GpioGroup);
GroupIndex = GPIOV2_PAD_GET_GROUP_INDEX (GpioGroup);
*IsValid = FALSE;
if (ChipsetId != GPIOV2_MTL_SOC_M_CHIPSET_ID) {
DEBUG((DEBUG_ERROR, "[GPIOV2][IsGroupValid] Error: wrong ChipsetId; com:%d,grp:%d id: 0x%x (exp: 0x%x)\n", CommunityIndex, GroupIndex, ChipsetId, GPIOV2_MTL_SOC_M_CHIPSET_ID));
ASSERT(FALSE);
return EFI_SUCCESS;
}
if (CommunityIndex >= MtlSocGpioGetCommunitiesNum(0)) {
DEBUG((DEBUG_ERROR, "[GPIOV2][IsGroupValid] Error: wrong community index; com:%d (max: %d)\n", CommunityIndex, MtlSocGpioGetCommunitiesNum(0)));
ASSERT(FALSE);
return EFI_SUCCESS;
}
if (GroupIndex >= MtlSocGpioGetCommunities(CommunityIndex)->GroupsNum) {
DEBUG((DEBUG_ERROR, "[GPIOV2][IsGroupValid] Error: wrong group index; g:%d (max: %d)\n", GroupIndex, MtlSocGpioGetCommunities(CommunityIndex)->GroupsNum));
ASSERT(FALSE);
return EFI_SUCCESS;
}
*IsValid = TRUE;
return EFI_SUCCESS;
}
/**
This procedure verifies if requested GpioPad definition is ment for platform that it is used on
@param[in] GpioServices Gpio Services
@param[in] GpioPad GPIO pad
@param[out] IsValid Pointer to a buffer for validation information, TRUE or FALSE
@retval EFI_SUCCESS The function completed successfully
@retval EFI_INVALID_PARAMETER Invalid group or pad number
**/
EFI_STATUS
EFIAPI
IsPadValid (
IN GPIOV2_PAD GpioPad,
OUT BOOLEAN *IsValid
)
{
UINT32 CommunityIndex;
UINT32 GroupIndex;
UINT32 PadIndex;
if ((IsValid == NULL)) {
ASSERT (FALSE);
return EFI_INVALID_PARAMETER;
}
IsGroupValid ((GPIOV2_PAD_GROUP)GpioPad, IsValid);
if (*IsValid != TRUE) {
ASSERT(FALSE);
return EFI_SUCCESS;
}
CommunityIndex = GPIOV2_PAD_GET_COMMUNITY_INDEX (GpioPad);
GroupIndex = GPIOV2_PAD_GET_GROUP_INDEX (GpioPad);
PadIndex = GPIOV2_PAD_GET_PAD_INDEX (GpioPad);
if (PadIndex >= MtlSocGpioGetGroups(CommunityIndex,GroupIndex).PadsNum) {
DEBUG((DEBUG_WARN, "[GPIOV2][IsPadValid] Error: Pad 0x%x, wrong pad index\n", GpioPad));
*IsValid = FALSE;
ASSERT(FALSE);
return EFI_SUCCESS;
}
return EFI_SUCCESS;
}
/**
This procedure retrieves name of requested Gpio Pad
@param[in] GPIOV2_SERVICES Gpio Services
@param[in] GpioPad Gpio Pad. Please refer to GpioPinsYYY.h - where YYY name of the platform (eg. MTL, EBG, ...)
@param[in] NameBufferLength Maximum number of characters to be stored in NameBuffer
@param[out] NameBuffer Pointer to a buffer for Gpio Pad name
@retval EFI_SUCCESS The function completed successfully
@retval EFI_INVALID_PARAMETER Invalid group or pad number
**/
EFI_STATUS
EFIAPI
GetPadName (
IN GPIOV2_PAD GpioPad,
IN UINT32 NameBufferLength,
OUT CHAR8 *NameBuffer
)
{
UINT32 PadIndex;
UINT32 CommunityIndex;
UINT32 GroupIndex;
if ( (NameBuffer == NULL)) {
ASSERT (FALSE);
return EFI_INVALID_PARAMETER;
}
if (GpioPad == GPIOV2_PAD_NONE) {
AsciiSPrint (NameBuffer, NameBufferLength, "No muxing");
return EFI_SUCCESS;
}
CommunityIndex = GPIOV2_PAD_GET_COMMUNITY_INDEX (GpioPad);
GroupIndex = GPIOV2_PAD_GET_GROUP_INDEX (GpioPad);
PadIndex = GPIOV2_PAD_GET_PAD_INDEX (GpioPad);
if (AsciiSPrint (NameBuffer, NameBufferLength, "%a_%02d",
MtlSocGpioGetGroups(CommunityIndex,GroupIndex).Name,
PadIndex) == 0) {
ASSERT(FALSE);
return EFI_INVALID_PARAMETER;
}
return EFI_SUCCESS;
}
/**
This procedure retrieves register offset
@param[in] GPIOV2_SERVICES Gpio Services
@param[in] Register Register for which user want to retrieve offset. Please refer to GpioV2Pad.h
@param[in] GpioPad Gpio Pad. Please refer to GpioPinsYYY.h - where YYY name of the platform (eg. MTL, EBG, ...)
@param[out] RegisterOffset Pointer to a buffer for register offset
@retval EFI_SUCCESS The function completed successfully
@retval EFI_INVALID_PARAMETER Invalid group or pad number
**/
EFI_STATUS
EFIAPI
GetRegisterOffset (
IN GPIOV2_REGISTER Register,
IN GPIOV2_PAD GpioPad,
OUT UINT32 *RegisterOffset
)
{
UINT32 CommunityIndex;
UINT32 GroupIndex;
UINT32 PadIndex;
ASSERT (RegisterOffset != NULL);
if (RegisterOffset == NULL) {
return EFI_INVALID_PARAMETER;
}
*RegisterOffset = 0;
CommunityIndex = GPIOV2_PAD_GET_COMMUNITY_INDEX (GpioPad);
GroupIndex = GPIOV2_PAD_GET_GROUP_INDEX (GpioPad);
PadIndex = GPIOV2_PAD_GET_PAD_INDEX (GpioPad);
switch (Register) {
case GpioV2PadOwnReg:
*RegisterOffset = MtlSocGpioGetGroups(CommunityIndex,GroupIndex).RegisterOffsets.PadOwn + (PadIndex / 8) * 0x04;
break;
case GpioV2PadCfgLockReg:
*RegisterOffset = MtlSocGpioGetGroups(CommunityIndex,GroupIndex).RegisterOffsets.PadCfgLock;
break;
case GpioV2PadCfgLockTxReg:
*RegisterOffset = MtlSocGpioGetGroups(CommunityIndex,GroupIndex).RegisterOffsets.PadCfgLockTx;
break;
case GpioV2PadHostOwnReg:
*RegisterOffset = MtlSocGpioGetGroups(CommunityIndex,GroupIndex).RegisterOffsets.HostOwn;
break;
case GpioV2GpiIsReg:
*RegisterOffset = MtlSocGpioGetGroups(CommunityIndex,GroupIndex).RegisterOffsets.GpiIs;
break;
case GpioV2GpiIeReg:
*RegisterOffset = MtlSocGpioGetGroups(CommunityIndex,GroupIndex).RegisterOffsets.GpiIe;
break;
case GpioV2GpiGpeStsReg:
*RegisterOffset = MtlSocGpioGetGroups(CommunityIndex,GroupIndex).RegisterOffsets.GpiGpeSts;
break;
case GpioV2GpiGpeEnReg:
*RegisterOffset = MtlSocGpioGetGroups(CommunityIndex,GroupIndex).RegisterOffsets.GpiGpeEn;
break;
case GpioV2SmiStsReg:
*RegisterOffset = MtlSocGpioGetGroups(CommunityIndex,GroupIndex).RegisterOffsets.SmiSts;
break;
case GpioV2SmiEnReg:
*RegisterOffset = MtlSocGpioGetGroups(CommunityIndex,GroupIndex).RegisterOffsets.SmiEn;
break;
case GpioV2NmiStsReg:
*RegisterOffset = MtlSocGpioGetGroups(CommunityIndex,GroupIndex).RegisterOffsets.NmiSts;
break;
case GpioV2NmiEnReg:
*RegisterOffset = MtlSocGpioGetGroups(CommunityIndex,GroupIndex).RegisterOffsets.NmiEn;
break;
case GpioV2Dw0Reg:
*RegisterOffset = MtlSocGpioGetGroups(CommunityIndex,GroupIndex).RegisterOffsets.Dw0 + PadIndex * 0x10;
break;
case GpioV2Dw1Reg:
*RegisterOffset = MtlSocGpioGetGroups(CommunityIndex,GroupIndex).RegisterOffsets.Dw0 + 0x04 + PadIndex * 0x10;
break;
case GpioV2Dw2Reg:
*RegisterOffset = MtlSocGpioGetGroups(CommunityIndex,GroupIndex).RegisterOffsets.Dw0 + 0x08 + PadIndex * 0x10;
break;
case GpioV2MiscCfg:
*RegisterOffset = MtlSocGpioGetCommunities(CommunityIndex)->RegisterOffsets.MiscCfg;
break;
case GpioV2AcReg:
*RegisterOffset = MtlSocGpioGetCommunities(CommunityIndex)->RegisterOffsets.AcSaiGrup0RcpDw0;
break;
default:
ASSERT(FALSE);
return EFI_INVALID_PARAMETER;
}
return EFI_SUCCESS;
}
P2SB_SIDEBAND_REGISTER_ACCESS
GetP2sbAddress (
IN UINT32 CommunityIndex
)
{
if (CommunityIndex == 0) {
return *((P2SB_SIDEBAND_REGISTER_ACCESS*)(UINTN)PcdGet32(PcdP2sb0Ptr));
} else if (CommunityIndex == 1) {
return *((P2SB_SIDEBAND_REGISTER_ACCESS*)(UINTN)PcdGet32(PcdP2sb1Ptr));
} else if (CommunityIndex == 2) {
return *((P2SB_SIDEBAND_REGISTER_ACCESS*)(UINTN)PcdGet32(PcdP2sb2Ptr));
} else if (CommunityIndex == 3) {
return *((P2SB_SIDEBAND_REGISTER_ACCESS*)(UINTN)PcdGet32(PcdP2sb3Ptr));
} else if (CommunityIndex == 4) {
return *((P2SB_SIDEBAND_REGISTER_ACCESS*)(UINTN)PcdGet32(PcdP2sb4Ptr));
} else {
return *((P2SB_SIDEBAND_REGISTER_ACCESS*)(UINTN)PcdGet32(PcdP2sb0Ptr));
}
}
/**
This procedure will set GPIO mode
@param[in] GPIOV2_SERVICES Gpio Services
@param[in] GpioPad Gpio Pad. Please refer to GpioPinsYYY.h - where YYY name of the platform (eg. MTL, EBG, ...)
@param[in] PadModeValue GPIO pad mode value
@retval EFI_SUCCESS The function completed successfully
@retval EFI_INVALID_PARAMETER Invalid group or pad number
**/
EFI_STATUS
EFIAPI
SetPadMode (
IN GPIOV2_PAD GpioPad,
IN GPIOV2_PAD_MODE PadMode
)
{
UINT32 AndValue;
UINT32 OrValue;
UINT32 CommunityIndex;
UINT32 RegisterOffset;
BOOLEAN PadValid;
P2SB_SIDEBAND_REGISTER_ACCESS P2sbPtr;
IsPadValid (GpioPad, &PadValid);
if (PadValid != TRUE) {
ASSERT (FALSE);
return EFI_INVALID_PARAMETER;
}
CommunityIndex = GPIOV2_PAD_GET_COMMUNITY_INDEX (GpioPad);
P2sbPtr = GetP2sbAddress(CommunityIndex);
if (PadMode != GpioV2PadModeHardwareDefault) {
AndValue = (UINT32)~(GPIOV2_PAD_MODE_MASK << GPIOV2_PAD_MODE_DW0_POS);
OrValue = ((PadMode >> 1) & GPIOV2_PAD_MODE_MASK) << GPIOV2_PAD_MODE_DW0_POS;
GetRegisterOffset (
GpioV2Dw0Reg,
GpioPad,
&RegisterOffset
);
P2sbPtr.Access.AndThenOr32 (
&(P2sbPtr.Access),
RegisterOffset,
AndValue,
OrValue
);
}
return EFI_SUCCESS;
}
/**
This procedure sets host ownership configuration for requested Gpio Pad
@param[in] GpioServices Gpio Services
@param[in] GpioPad GPIO pad
@param[in] Ownership Host ownership, please refer to GpioV2Pad.h
@retval EFI_SUCCESS The function completed successfully
@retval EFI_INVALID_PARAMETER Invalid group or pad number
**/
EFI_STATUS
EFIAPI
SetHostOwnership (
IN GPIOV2_PAD GpioPad,
IN GPIOV2_HOSTSW_OWN HostOnwership
)
{
UINT32 AndValue;
UINT32 OrValue;
UINT32 CommunityIndex;
UINT32 PadIndex;
UINT32 RegisterOffset;
P2SB_SIDEBAND_REGISTER_ACCESS P2sbPtr;
CommunityIndex = GPIOV2_PAD_GET_COMMUNITY_INDEX (GpioPad);
PadIndex = GPIOV2_PAD_GET_PAD_INDEX (GpioPad);
P2sbPtr = GetP2sbAddress(CommunityIndex);
if (HostOnwership != GpioV2HostOwnDefault) {
GetRegisterOffset (
GpioV2PadHostOwnReg,
GpioPad,
&RegisterOffset
);
AndValue = (UINT32)~(GPIOV2_PAD_HOST_OWNERSHIP_MASK << PadIndex);
OrValue = ((HostOnwership >> 1) & GPIOV2_PAD_HOST_OWNERSHIP_MASK) << PadIndex;
P2sbPtr.Access.AndThenOr32 (
&(P2sbPtr.Access),
RegisterOffset,
AndValue,
OrValue
);
}
return EFI_SUCCESS;
}
/**
This procedure sets Gpio Pad output state
@param[in] GpioServices Gpio Services
@param[in] GpioPad GPIO pad
@param[in] OutputState GpioV2StateLow - output state low, GpioV2StateHigh - output state high
@retval EFI_SUCCESS The function completed successfully
@retval EFI_INVALID_PARAMETER Invalid group or pad number
**/
EFI_STATUS
EFIAPI
SetTx (
IN GPIOV2_PAD GpioPad,
IN GPIOV2_PAD_STATE OutputState
)
{
UINT32 AndValue;
UINT32 OrValue;
UINT32 CommunityIndex;
UINT32 RegisterOffset;
P2SB_SIDEBAND_REGISTER_ACCESS P2sbPtr;
CommunityIndex = GPIOV2_PAD_GET_COMMUNITY_INDEX (GpioPad);
P2sbPtr = GetP2sbAddress(CommunityIndex);
if (OutputState != GpioV2StateDefault) {
GetRegisterOffset (
GpioV2Dw0Reg,
GpioPad,
&RegisterOffset
);
AndValue = (UINT32)~(GPIOV2_PAD_OUTPUT_STATE_MASK << GPIOV2_PAD_OUTPUT_STATE_DW0_POS);
OrValue = ((OutputState >> 1) & GPIOV2_PAD_OUTPUT_STATE_MASK) << GPIOV2_PAD_OUTPUT_STATE_DW0_POS;
P2sbPtr.Access.AndThenOr32 (
&(P2sbPtr.Access),
RegisterOffset,
AndValue,
OrValue
);
}
return EFI_SUCCESS;
}
/**
This procedure sets TX buffer for requested Gpio Pad as enabled or disabled
@param[in] GpioServices Gpio Services
@param[in] GpioPad GPIO pad
@param[in] TxDisabled True - TX buffer disabled, False - TX buffer enabled
@retval EFI_SUCCESS The function completed successfully
@retval EFI_INVALID_PARAMETER Invalid group or pad number
**/
EFI_STATUS
EFIAPI
SetTxDisable (
IN GPIOV2_PAD GpioPad,
IN BOOLEAN TxDisabled
)
{
UINT32 AndValue;
UINT32 OrValue;
UINT32 CommunityIndex;
UINT32 RegisterOffset;
P2SB_SIDEBAND_REGISTER_ACCESS P2sbPtr;
CommunityIndex = GPIOV2_PAD_GET_COMMUNITY_INDEX (GpioPad);
P2sbPtr = GetP2sbAddress(CommunityIndex);
GetRegisterOffset (
GpioV2Dw0Reg,
GpioPad,
&RegisterOffset
);
AndValue = (UINT32)~(GPIOV2_PAD_TX_DISABLE_MASK << GPIOV2_PAD_TX_DISABLE_DW0_POS);
OrValue = (TxDisabled & GPIOV2_PAD_TX_DISABLE_MASK) << GPIOV2_PAD_TX_DISABLE_DW0_POS;
P2sbPtr.Access.AndThenOr32 (
&(P2sbPtr.Access),
RegisterOffset,
AndValue,
OrValue
);
return EFI_SUCCESS;
}
/**
This procedure sets Rx buffer for requested Gpio Pad as enabled or disabled
@param[in] GpioServices Gpio Services
@param[in] GpioPad GPIO pad
@param[in] TxDisabled True - TX buffer disabled, False - TX buffer enabled
@retval EFI_SUCCESS The function completed successfully
@retval EFI_INVALID_PARAMETER Invalid group or pad number
**/
EFI_STATUS
EFIAPI
SetRxDisable (
IN GPIOV2_PAD GpioPad,
IN BOOLEAN RxDisabled
)
{
UINT32 AndValue;
UINT32 OrValue;
UINT32 CommunityIndex;
UINT32 RegisterOffset;
P2SB_SIDEBAND_REGISTER_ACCESS P2sbPtr;
CommunityIndex = GPIOV2_PAD_GET_COMMUNITY_INDEX (GpioPad);
P2sbPtr = GetP2sbAddress(CommunityIndex);
GetRegisterOffset (
GpioV2Dw0Reg,
GpioPad,
&RegisterOffset
);
AndValue = (UINT32)~(GPIOV2_PAD_RX_DISABLE_MASK << GPIOV2_PAD_RX_DISABLE_DW0_POS);
OrValue = (RxDisabled & GPIOV2_PAD_RX_DISABLE_MASK) << GPIOV2_PAD_RX_DISABLE_DW0_POS;
P2sbPtr.Access.AndThenOr32 (
&(P2sbPtr.Access),
RegisterOffset,
AndValue,
OrValue
);
return EFI_SUCCESS;
}
/**
This procedure will set GPIO enable or disable input inversion on rquested pad
@param[in] GPIOV2_SERVICES Gpio Services
@param[in] GpioPad GPIO pad
@param[in] InputInversion GpioV2InputInversionEnable or GpioV2InputInversionDisable, please refer to GpioV2Pad.h
@retval EFI_SUCCESS The function completed successfully
@retval EFI_INVALID_PARAMETER Invalid group or pad number
**/
EFI_STATUS
EFIAPI
SetInputInversion (
IN GPIOV2_PAD GpioPad,
IN GPIOV2_PAD_INPUT_INVERSION InputInversion
)
{
UINT32 AndValue;
UINT32 OrValue;
UINT32 CommunityIndex;
UINT32 RegisterOffset;
P2SB_SIDEBAND_REGISTER_ACCESS P2sbPtr;
CommunityIndex = GPIOV2_PAD_GET_COMMUNITY_INDEX (GpioPad);
P2sbPtr = GetP2sbAddress(CommunityIndex);
if (InputInversion != GpioV2InputInversionHardwareDefault) {
AndValue = (UINT32)~(GPIOV2_PAD_INPUT_INVERSION_MASK << GPIOV2_PAD_INPUT_INVERSION_DW0_POS);
OrValue = ((InputInversion >> 1) & GPIOV2_PAD_INPUT_INVERSION_MASK) << GPIOV2_PAD_INPUT_INVERSION_DW0_POS;
GetRegisterOffset (
GpioV2Dw0Reg,
GpioPad,
&RegisterOffset
);
P2sbPtr.Access.AndThenOr32 (
&(P2sbPtr.Access),
RegisterOffset,
AndValue,
OrValue
);
}
return EFI_SUCCESS;
}
/**
This procedure sets NMI Enable for requested Gpio Pad
@param[in] GpioServices Gpio Services
@param[in] GpioPad GPIO pad
@param[in] NmiEn NMI Enable, TRUE or FALSE
@retval EFI_SUCCESS The function completed successfully
@retval EFI_INVALID_PARAMETER Invalid group or pad number
**/
EFI_STATUS
EFIAPI
SetNmiEn (
IN GPIOV2_PAD GpioPad,
IN BOOLEAN NmiEn
)
{
UINT32 AndValue;
UINT32 OrValue;
UINT32 CommunityIndex;
UINT32 PadIndex;
UINT32 RegisterOffset;
P2SB_SIDEBAND_REGISTER_ACCESS P2sbPtr;
CommunityIndex = GPIOV2_PAD_GET_COMMUNITY_INDEX (GpioPad);
PadIndex = GPIOV2_PAD_GET_PAD_INDEX (GpioPad);
P2sbPtr = GetP2sbAddress(CommunityIndex);
GetRegisterOffset (
GpioV2NmiEnReg,
GpioPad,
&RegisterOffset
);
AndValue = (UINT32)~(GPIOV2_PAD_NMI_EN_MASK << PadIndex);
if (NmiEn) {
OrValue = 0x01 << PadIndex;
} else {
OrValue = 0x0;
}
P2sbPtr.Access.AndThenOr32 (
&(P2sbPtr.Access),
RegisterOffset,
AndValue,
OrValue
);
return EFI_SUCCESS;
}
/**
This procedure sets SMI Enable configuration for requested Gpio Pad
@param[in] GpioServices Gpio Services
@param[in] GpioPad GPIO pad
@param[in] SmiEn SMI Enable, TRUE or FALSE
@retval EFI_SUCCESS The function completed successfully
@retval EFI_INVALID_PARAMETER Invalid group or pad number
**/
EFI_STATUS
EFIAPI
SetSmiEn (
IN GPIOV2_PAD GpioPad,
IN BOOLEAN SmiEn
)
{
UINT32 AndValue;
UINT32 OrValue;
UINT32 CommunityIndex;
UINT32 PadIndex;
UINT32 RegisterOffset;
P2SB_SIDEBAND_REGISTER_ACCESS P2sbPtr;
CommunityIndex = GPIOV2_PAD_GET_COMMUNITY_INDEX (GpioPad);
PadIndex = GPIOV2_PAD_GET_PAD_INDEX (GpioPad);
P2sbPtr = GetP2sbAddress(CommunityIndex);
GetRegisterOffset (
GpioV2SmiEnReg,
GpioPad,
&RegisterOffset
);
AndValue = (UINT32)~(GPIOV2_PAD_SMI_EN_MASK << PadIndex);
OrValue = (SmiEn & GPIOV2_PAD_SMI_EN_MASK) << PadIndex;
P2sbPtr.Access.AndThenOr32 (
&(P2sbPtr.Access),
RegisterOffset,
AndValue,
OrValue
);
return EFI_SUCCESS;
}
/**
This procedure sets GPI GPE Enable configuration for requested Gpio Pad
@param[in] GpioServices Gpio Services
@param[in] GpioPad GPIO pad
@param[in] GpiIe GPI GPE Enable, TRUE or FALSE
@retval EFI_SUCCESS The function completed successfully
@retval EFI_INVALID_PARAMETER Invalid group or pad number
**/
EFI_STATUS
EFIAPI
SetGpiGpeEn (
IN GPIOV2_PAD GpioPad,
IN BOOLEAN GpiGpeEn
)
{
UINT32 AndValue;
UINT32 OrValue;
UINT32 CommunityIndex;
UINT32 PadIndex;
UINT32 RegisterOffset;
P2SB_SIDEBAND_REGISTER_ACCESS P2sbPtr;
CommunityIndex = GPIOV2_PAD_GET_COMMUNITY_INDEX (GpioPad);
PadIndex = GPIOV2_PAD_GET_PAD_INDEX (GpioPad);
P2sbPtr = GetP2sbAddress(CommunityIndex);
GetRegisterOffset (
GpioV2GpiGpeEnReg,
GpioPad,
&RegisterOffset
);
AndValue = (UINT32)~(GPIOV2_PAD_GPI_GPE_EN_MASK << PadIndex);
OrValue = (GpiGpeEn & GPIOV2_PAD_GPI_GPE_EN_MASK) << PadIndex;
P2sbPtr.Access.AndThenOr32 (
&(P2sbPtr.Access),
RegisterOffset,
AndValue,
OrValue
);
return EFI_SUCCESS;
}
/**
This procedure sets Gpi Enable configuration for requested Gpio Pad
@param[in] GpioServices Gpio Services
@param[in] GpioPad GPIO pad
@param[in] GpiIe GPI Enable, TRUE or FALSE
@retval EFI_SUCCESS The function completed successfully
@retval EFI_INVALID_PARAMETER Invalid group or pad number
**/
EFI_STATUS
EFIAPI
SetGpiIe (
IN GPIOV2_PAD GpioPad,
IN BOOLEAN GpiIe
)
{
UINT32 AndValue;
UINT32 OrValue;
UINT32 CommunityIndex;
UINT32 PadIndex;
UINT32 RegisterOffset;
P2SB_SIDEBAND_REGISTER_ACCESS P2sbPtr;
CommunityIndex = GPIOV2_PAD_GET_COMMUNITY_INDEX (GpioPad);
PadIndex = GPIOV2_PAD_GET_PAD_INDEX (GpioPad);
P2sbPtr = GetP2sbAddress(CommunityIndex);
GetRegisterOffset (
GpioV2GpiIeReg,
GpioPad,
&RegisterOffset
);
AndValue = (UINT32)~(GPIOV2_PAD_GPI_IE_MASK << PadIndex);
OrValue = (GpiIe & GPIOV2_PAD_GPI_IE_MASK) << PadIndex;
P2sbPtr.Access.AndThenOr32 (
&(P2sbPtr.Access),
RegisterOffset,
AndValue,
OrValue
);
return EFI_SUCCESS;
}
/**
This procedure sets GPIROUTNMI bit (17th bit in DW0) for requested Gpio Pad
@param[in] GpioServices GPIO Controller
@param[in] GpioPad GPIO pad
@param[in] Enable TRUE or FALSE, either enable or disable 17 bit in DW0
@retval EFI_SUCCESS The function completed successfully
@retval EFI_INVALID_PARAMETER Invalid group or pad number
**/
EFI_STATUS
EFIAPI
SetRouteNmi (
IN GPIOV2_PAD GpioPad,
IN BOOLEAN Enable
)
{
UINT32 AndValue;
UINT32 OrValue;
UINT32 CommunityIndex;
UINT32 RegisterOffset;
P2SB_SIDEBAND_REGISTER_ACCESS P2sbPtr;
CommunityIndex = GPIOV2_PAD_GET_COMMUNITY_INDEX (GpioPad);
P2sbPtr = GetP2sbAddress(CommunityIndex);
AndValue = (UINT32)~(GPIOV2_PAD_GPIROUTNMI_DW0_MASK << GPIOV2_PAD_GPIROUTNMI_DW0_POS);
if (Enable) {
OrValue = 0x1 << GPIOV2_PAD_GPIROUTNMI_DW0_POS;
} else {
OrValue = 0x0;
}
GetRegisterOffset (
GpioV2Dw0Reg,
GpioPad,
&RegisterOffset
);
P2sbPtr.Access.AndThenOr32 (
&(P2sbPtr.Access),
RegisterOffset,
AndValue,
OrValue
);
return EFI_SUCCESS;
}
/**
This procedure sets GPIROUTSMI bit (18th bit in DW0) for requested Gpio Pad
@param[in] GpioServices GPIO Controller
@param[in] GpioPad GPIO pad
@param[in] Enable TRUE or FALSE, either enable or disable 18 bit in DW0
@retval EFI_SUCCESS The function completed successfully
@retval EFI_INVALID_PARAMETER Invalid group or pad number
**/
EFI_STATUS
EFIAPI
SetRouteSmi (
IN GPIOV2_PAD GpioPad,
IN BOOLEAN Enable
)
{
UINT32 AndValue;
UINT32 OrValue;
UINT32 CommunityIndex;
UINT32 RegisterOffset;
P2SB_SIDEBAND_REGISTER_ACCESS P2sbPtr;
CommunityIndex = GPIOV2_PAD_GET_COMMUNITY_INDEX (GpioPad);
P2sbPtr = GetP2sbAddress(CommunityIndex);
AndValue = (UINT32)~(GPIOV2_PAD_GPIROUTSMI_DW0_MASK << GPIOV2_PAD_GPIROUTSMI_DW0_POS);
if (Enable) {
OrValue = 0x1 << GPIOV2_PAD_GPIROUTSMI_DW0_POS;
} else {
OrValue = 0x0;
}
GetRegisterOffset (
GpioV2Dw0Reg,
GpioPad,
&RegisterOffset
);
P2sbPtr.Access.AndThenOr32 (
&(P2sbPtr.Access),
RegisterOffset,
AndValue,
OrValue
);
return EFI_SUCCESS;
}
/**
This procedure sets GPIROUTIOXAPIC bit (20th bit in DW0) for requested Gpio Pad
@param[in] GpioServices GPIO Controller
@param[in] GpioPad GPIO pad
@param[in] Enable TRUE or FALSE, either enable or disable 20th bit in DW0
@retval EFI_SUCCESS The function completed successfully
@retval EFI_INVALID_PARAMETER Invalid group or pad number
**/
EFI_STATUS
EFIAPI
SetRouteIoxApic (
IN GPIOV2_PAD GpioPad,
IN BOOLEAN Enable
)
{
UINT32 AndValue;
UINT32 OrValue;
UINT32 CommunityIndex;
UINT32 RegisterOffset;
P2SB_SIDEBAND_REGISTER_ACCESS P2sbPtr;
CommunityIndex = GPIOV2_PAD_GET_COMMUNITY_INDEX (GpioPad);
P2sbPtr = GetP2sbAddress(CommunityIndex);
AndValue = (UINT32)~(GPIOV2_PAD_GPIROUTIOXAPIC_DW0_MASK << GPIOV2_PAD_GPIROUTIOXAPIC_DW0_POS);
if (Enable) {
OrValue = 0x1 << GPIOV2_PAD_GPIROUTIOXAPIC_DW0_POS;
} else {
OrValue = 0x0;
}
GetRegisterOffset (
GpioV2Dw0Reg,
GpioPad,
&RegisterOffset
);
P2sbPtr.Access.AndThenOr32 (
&(P2sbPtr.Access),
RegisterOffset,
AndValue,
OrValue
);
return EFI_SUCCESS;
}
/**
This procedure sets RxEv configuration for requested Gpio Pad
@param[in] GpioServices Gpio Services
@param[in] GpioPad GPIO pad
@param[in] RxEvCfg RxEv configuration
@retval EFI_SUCCESS The function completed successfully
@retval EFI_INVALID_PARAMETER Invalid group or pad number
**/
EFI_STATUS
EFIAPI
SetRxEvCfg (
IN GPIOV2_PAD GpioPad,
IN GPIOV2_RXEVCFG RxEvCfg
)
{
UINT32 AndValue;
UINT32 OrValue;
UINT32 CommunityIndex;
UINT32 RegisterOffset;
P2SB_SIDEBAND_REGISTER_ACCESS P2sbPtr;
if (RxEvCfg != GpioV2IntRxEvCfgDefault) {
CommunityIndex = GPIOV2_PAD_GET_COMMUNITY_INDEX (GpioPad);
P2sbPtr = GetP2sbAddress(CommunityIndex);
AndValue = (UINT32)~(GPIOV2_PAD_RXEV_MASK << GPIOV2_PAD_RXEV_DW0_POS);
OrValue = ((RxEvCfg >> 1) & GPIOV2_PAD_RXEV_MASK) << GPIOV2_PAD_RXEV_DW0_POS;
GetRegisterOffset (
GpioV2Dw0Reg,
GpioPad,
&RegisterOffset
);
P2sbPtr.Access.AndThenOr32 (
&(P2sbPtr.Access),
RegisterOffset,
AndValue,
OrValue
);
}
return EFI_SUCCESS;
}
/**
This procedure sets GPIROUTSCI bit (19th bit in DW0) for requested Gpio Pad
@param[in] GpioServices GPIO Controller
@param[in] GpioPad GPIO pad
@param[in] Enable TRUE or FALSE, either enable or disable 19 bit in DW0
@retval EFI_SUCCESS The function completed successfully
@retval EFI_INVALID_PARAMETER Invalid group or pad number
**/
EFI_STATUS
EFIAPI
SetRouteSci (
IN GPIOV2_PAD GpioPad,
IN BOOLEAN Enable
)
{
UINT32 AndValue;
UINT32 OrValue;
UINT32 CommunityIndex;
UINT32 RegisterOffset;
P2SB_SIDEBAND_REGISTER_ACCESS P2sbPtr;
CommunityIndex = GPIOV2_PAD_GET_COMMUNITY_INDEX (GpioPad);
P2sbPtr = GetP2sbAddress(CommunityIndex);
AndValue = (UINT32)~(GPIOV2_PAD_GPIROUTSCI_DW0_MASK << GPIOV2_PAD_GPIROUTSCI_DW0_POS);
if (Enable) {
OrValue = 0x1 << GPIOV2_PAD_GPIROUTSCI_DW0_POS;
} else {
OrValue = 0x0;
}
GetRegisterOffset (
GpioV2Dw0Reg,
GpioPad,
&RegisterOffset
);
P2sbPtr.Access.AndThenOr32 (
&(P2sbPtr.Access),
RegisterOffset,
AndValue,
OrValue
);
return EFI_SUCCESS;
}
/**
This procedure sets Reset Configuration for requested Gpio Pad
@param[in] GpioServices Gpio Services
@param[in] GpioPad GPIO pad
@param[in] ResetConfig Reset Configuration - please refer to GpioV2Pad.h (GPIOV2_RESET_CONFIG)
@retval EFI_SUCCESS The function completed successfully
@retval EFI_INVALID_PARAMETER Invalid group or pad number
**/
EFI_STATUS
EFIAPI
SetResetConfig (
IN GPIOV2_PAD GpioPad,
IN GPIOV2_RESET_CONFIG ResetConfig
)
{
UINT32 AndValue;
UINT32 OrValue;
UINT32 CommunityIndex;
UINT32 RegisterOffset;
P2SB_SIDEBAND_REGISTER_ACCESS P2sbPtr;
CommunityIndex = GPIOV2_PAD_GET_COMMUNITY_INDEX (GpioPad);
P2sbPtr = GetP2sbAddress(CommunityIndex);
if (ResetConfig == GpioV2ResetHostDeep) {
}
if (ResetConfig != GpioV2ResetDefault) {
GetRegisterOffset (
GpioV2Dw0Reg,
GpioPad,
&RegisterOffset
);
AndValue = (UINT32)~(GPIOV2_PAD_RESET_CONFIG_MASK << GPIOV2_PAD_RESET_CONFIG_DW0_POS);
OrValue = ((ResetConfig >> 1) & GPIOV2_PAD_RESET_CONFIG_MASK) << GPIOV2_PAD_RESET_CONFIG_DW0_POS;
P2sbPtr.Access.AndThenOr32 (
&(P2sbPtr.Access),
RegisterOffset,
AndValue,
OrValue
);
}
return EFI_SUCCESS;
}
/**
This procedure sets termination configuration for requested Gpio Pad
@param[in] GpioServices Gpio Services
@param[in] GpioPad GPIO pad
@param[in] TerminationConfig Termination configuration, please refer to GpioV2Pad.h
@retval EFI_SUCCESS The function completed successfully
@retval EFI_INVALID_PARAMETER Invalid group or pad number
**/
EFI_STATUS
EFIAPI
SetTerminationConfig (
IN GPIOV2_PAD GpioPad,
IN GPIOV2_TERMINATION_CONFIG TerminationConfig
)
{
UINT32 AndValue;
UINT32 OrValue;
UINT32 CommunityIndex;
UINT32 RegisterOffset;
P2SB_SIDEBAND_REGISTER_ACCESS P2sbPtr;
CommunityIndex = GPIOV2_PAD_GET_COMMUNITY_INDEX (GpioPad);
P2sbPtr = GetP2sbAddress(CommunityIndex);
if (TerminationConfig == GpioV2TermDefault) {
}
if (TerminationConfig != GpioV2TermDefault) {
GetRegisterOffset (
GpioV2Dw1Reg,
GpioPad,
&RegisterOffset
);
AndValue = (UINT32)~(GPIOV2_PAD_TERMINATION_CONFIG_MASK << GPIOV2_PAD_TERMINATION_CONFIG_DW1_POS);
OrValue = ((TerminationConfig >> 1) & GPIOV2_PAD_TERMINATION_CONFIG_MASK) << GPIOV2_PAD_TERMINATION_CONFIG_DW1_POS;
P2sbPtr.Access.AndThenOr32 (
&(P2sbPtr.Access),
RegisterOffset,
AndValue,
OrValue
);
}
return EFI_SUCCESS;
}
/**
Store unlock data.
@param[in] GpioInterface GPIO interface
@param[in] GpioPad GPIO pad
@param[in] LockCfg Pad config lock policy
@param[in] LockTx Pad Tx lock policy
**/
VOID
GpioV2StoreUnlockData (
IN GPIOV2_PAD GpioPad,
IN GPIOV2_PAD_LOCK LockCfg,
IN GPIOV2_PAD_LOCK LockTx
)
{
UINT32 Index;
UINT32 ComIndex;
UINT32 GrpIndex;
UINT32 GlobalGroupIndex;
CHAR8 PadName[GPIOV2_NAME_LENGTH_MAX];
ComIndex = GPIOV2_PAD_GET_COMMUNITY_INDEX (GpioPad);
GrpIndex = GPIOV2_PAD_GET_GROUP_INDEX (GpioPad);
GlobalGroupIndex = GrpIndex;
for (Index = 0; Index < ComIndex; Index++) {
GlobalGroupIndex += 1;
}
GetPadName (GpioPad, sizeof (PadName), PadName);
DEBUG ((DEBUG_INFO, "[GPIOV2] [UNLOCK] [SELECT] %a ", PadName));
if (LockCfg == GpioV2Unlock) {
DEBUG ((DEBUG_INFO, "CFG"));
}
if (LockTx == GpioV2Unlock) {
DEBUG ((DEBUG_INFO, " TX"));
}
DEBUG ((DEBUG_INFO, "\n"));
}
/**
This procedure will set GPIO mode for HDA SNDW functionality
@param[in] GpioServices Gpio Services
@param[in] GpioPad Gpio Pad
@param[in] PadConfig Gpio Pad configuration - please refer to GPIOV2_CONFIG in GpioV2Config.h
@retval EFI_SUCCESS The function completed successfully
@retval EFI_INVALID_PARAMETER Invalid group or pad number
**/
EFI_STATUS
EFIAPI
ConfigurePad (
IN GPIOV2_PAD GpioPad,
IN GPIOV2_CONFIG *PadConfig
)
{
EFI_STATUS Status = EFI_SUCCESS;
CHAR8 PadName[GPIOV2_NAME_LENGTH_MAX];
GetPadName (GpioPad, sizeof (PadName), PadName);
SetPadMode (GpioPad, PadConfig->PadMode);
if ((PadConfig->InterruptConfig >> 1) & (GpioV2IntSmi >> 1)) {
SetHostOwnership (GpioPad, GpioV2HostOwnGpio);
} else {
SetHostOwnership (GpioPad, PadConfig->HostOwn);
}
//
// Make sure we set a Tx state before setting a direction to avoid glitches on the GPIO line.
// A glitch can happen if by default Tx of the GPIO pad is disabled and Tx state is set to drive
// the pad low but signal on the board is pulled up. When BIOS wants to take control over the GPIO pad
// and enable the Tx and set the Tx state to high to match the platform default signal state we need to make
// sure tha Tx is programed to high before we enable Tx otherwise signal on the board will experience a
// very quick glitch which can lead to a number of problems.
//
SetTx (GpioPad, PadConfig->OutputState);
if (PadConfig->Direction != GpioV2DirDefault) {
switch (PadConfig->Direction) {
case GpioV2DirInOut:
SetTxDisable (GpioPad, FALSE);
SetRxDisable (GpioPad, FALSE);
SetInputInversion (GpioPad, GpioV2InputInversionDisable);
break;
case GpioV2DirInInvOut:
SetTxDisable (GpioPad, FALSE);
SetRxDisable (GpioPad, FALSE);
SetInputInversion (GpioPad, GpioV2InputInversionEnable);
break;
case GpioV2DirIn:
SetTxDisable (GpioPad, TRUE);
SetRxDisable (GpioPad, FALSE);
SetInputInversion (GpioPad, GpioV2InputInversionDisable);
break;
case GpioV2DirInInv:
SetTxDisable (GpioPad, TRUE);
SetRxDisable (GpioPad, FALSE);
SetInputInversion (GpioPad, GpioV2InputInversionEnable);
break;
case GpioV2DirOut:
SetTxDisable (GpioPad, FALSE);
SetRxDisable ( GpioPad, TRUE);
SetInputInversion (GpioPad, GpioV2InputInversionDisable);
break;
case GpioV2DirNone:
SetTxDisable (GpioPad, TRUE);
SetRxDisable (GpioPad, TRUE);
SetInputInversion (GpioPad, GpioV2InputInversionDisable);
break;
case GpioV2DirDefault:
default:
break;
}
}
if (PadConfig->InterruptConfig != GpioV2IntDefault) {
//
// All Interrupt/wake events turned off by default
//
SetNmiEn (GpioPad, FALSE);
SetSmiEn (GpioPad, FALSE);
SetGpiGpeEn (GpioPad, FALSE);
SetGpiIe (GpioPad, FALSE);
if ((PadConfig->InterruptConfig >> 1) & (GpioV2IntNmi >> 1)) {
SetNmiEn (GpioPad, TRUE);
SetRouteNmi (GpioPad, TRUE);
}
if ((PadConfig->InterruptConfig >> 1) & (GpioV2IntSmi >> 1)) {
SetSmiEn (GpioPad, TRUE);
SetRouteSmi (GpioPad, TRUE);
}
if ((PadConfig->InterruptConfig >> 1) & (GpioV2IntSci >> 1)) {
SetGpiGpeEn (GpioPad, TRUE);
SetRouteSci (GpioPad, TRUE);
}
if ((PadConfig->InterruptConfig >> 1) & (GpioV2IntApic >> 1)) {
SetGpiIe (GpioPad, TRUE);
SetRouteIoxApic (GpioPad, TRUE);
}
if ((PadConfig->InterruptConfig >> 1) & (GpioV2IntLevel >> 1)) {
SetRxEvCfg (GpioPad, GpioV2IntRxEvCfgLevel);
} else if ((PadConfig->InterruptConfig >> 1) & (GpioV2IntEdge >> 1)) {
SetRxEvCfg (GpioPad, GpioV2IntRxEvCfgEdge);
} else if ((PadConfig->InterruptConfig >> 1) & (GpioV2IntLvlEdgDis >> 1)) {
SetRxEvCfg (GpioPad, GpioV2IntRxEvCfgDisable);
} else if ((PadConfig->InterruptConfig >> 1) & (GpioV2IntBothEdge >> 1)) {
SetRxEvCfg (GpioPad, GpioV2IntRxEvCfgLevelEdge);
}
}
SetResetConfig (GpioPad, PadConfig->ResetConfig);
SetTerminationConfig (GpioPad, PadConfig->TerminationConfig);
//
// Store unlock data
//
if ( ((PadConfig->Direction == GpioV2DirOut) || (PadConfig->Direction == GpioV2DirInOut) || (PadConfig->Direction == GpioV2DirInInvOut)) &&
(PadConfig->PadMode == GpioV2PadModeGpio) &&
(PadConfig->LockTx == GpioV2LockHardwareDefault) ) {
GpioV2StoreUnlockData (GpioPad,
PadConfig->LockConfig,
GpioV2Unlock );
} else if ( (PadConfig->LockConfig == GpioV2Unlock) ||
(PadConfig->LockTx == GpioV2Unlock) ) {
GpioV2StoreUnlockData (GpioPad,
PadConfig->LockConfig,
PadConfig->LockTx );
}
if (PadConfig->OtherSettings != GpioV2RxRaw1Default) {
// TO BE DONE
}
return Status;
}
EFI_STATUS
GetGpioV2ServicesFromPad (
IN GPIOV2_PAD GpioPad
)
{
UINT8 ChipsetId;
CHAR8 Hid[GPIOV2_CONTROLLER_HID_LENGTH + 1] = {0};
UINT32 Uid;
ChipsetId = GPIOV2_PAD_GET_CHIPSETID (GpioPad);
Uid = 0xFFFFFFFF;
switch (ChipsetId) {
case GPIOV2_MTL_SOC_M_CHIPSET_ID:
CopyMem (Hid, GPIO_HID_MTL_SOC_M, GPIOV2_CONTROLLER_HID_LENGTH);
Uid = 0;
break;
default:
break;
}
if (Uid == 0xFFFFFFFF) {
//
// Did not find a match Chipset ID from PAD.
//
ASSERT (FALSE);
return EFI_NOT_FOUND;
}
if ((Hid == 0) &&
(Uid == 0xFFFFFFFF)) {
return EFI_SUCCESS;
}
return EFI_SUCCESS;
}
/**
This procedure will initialize all GPIO pads based on PadInitConfigTable
@param[in] GpioProtocol GPIO Protocol
@param[in] PadInitConfigTable Pointer to PadInitConfigTable
@param[in] PadInitConfigTableSize Size of PadInitConfigTable
@retval Status
**/
EFI_STATUS
EFIAPI
ConfigurePads (
IN GPIOV2_INIT_CONFIG *GpioPadsConfigTable,
IN UINT32 GpioPadsConfigTableSize
)
{
UINT32 Index;
EFI_STATUS Status;
Status = EFI_SUCCESS;
for (Index = 0; Index < GpioPadsConfigTableSize; Index++) {
Status = ConfigurePad (
GpioPadsConfigTable[Index].GpioPad,
&GpioPadsConfigTable[Index].GpioConfig
);
if (Status != EFI_SUCCESS) {
ASSERT(FALSE);
break;
}
}
return Status;
}
EFI_STATUS
GpioV2ConfigurePads (
IN GPIOV2_INIT_CONFIG *GpioPadsConfigTable,
IN UINT32 GpioPadsConfigTableSize
)
{
EFI_STATUS Status;
if ((GpioPadsConfigTable == NULL) || (GpioPadsConfigTableSize == 0)) {
return EFI_INVALID_PARAMETER;
}
//
// All pads in PadInitConfigTable should belong to the same ChipsetId.
//
Status = GetGpioV2ServicesFromPad (GpioPadsConfigTable[0].GpioPad);
if (EFI_ERROR (Status)) {
return Status;
}
return ConfigurePads (GpioPadsConfigTable, GpioPadsConfigTableSize);
}
/**
Configure the GPIO pins, available as part of platform specific GPIO CFG DATA.
If the pins are not part of GPIO CFG DATA, call GpioConfigurePads() directly
with the appropriate arguments.
@param Tag Tag ID of the Gpio Cfg data item
@param Entries Number of entries in Gpio Table
@param DataBuffer Pointer to the Gpio Table to be programmed
@retval EFI_SUCCESS The function completed successfully
@retval EFI_NOT_FOUND If Gpio Config Data cant be found
**/
EFI_STATUS
EFIAPI
ConfigureGpioV2 (
IN UINT16 Tag,
IN GPIOV2_INIT_CONFIG *GpioTable,
IN UINT16 GpioTableCount
)
{
ARRAY_CFG_HDR *GpioCfgCurrHdr;
ARRAY_CFG_HDR *GpioCfgBaseHdr;
EFI_STATUS Status;
//
// If no Tag provided, check for GpioTable info;
// If Tag provided, GpioTable params are don't care
//
if (Tag == CDATA_NO_TAG) {
DEBUG ((DEBUG_INFO, "ConfigureGpio() Start\n"));
Status = GpioV2ConfigurePads (GpioTable, GpioTableCount);
ASSERT_EFI_ERROR (Status);
DEBUG ((DEBUG_INFO, "ConfigureGpio() End\n"));
return EFI_SUCCESS;
}
//
// Find the GPIO CFG HDR
//
GpioCfgCurrHdr = (ARRAY_CFG_HDR *)FindConfigDataByTag (Tag);
if (GpioCfgCurrHdr == NULL) {
return EFI_NOT_FOUND;
}
GpioCfgBaseHdr = NULL;
//
// Find the GPIO CFG Data based on Platform ID
// GpioTableData is the start of the GPIO entries
//
if (GpioCfgCurrHdr->BaseTableId < 16) {
GpioCfgBaseHdr = (ARRAY_CFG_HDR *)FindConfigDataByPidTag (GpioCfgCurrHdr->BaseTableId, Tag);
if (GpioCfgBaseHdr == NULL) {
DEBUG ((GPIO_DEBUG_ERROR, "Cannot find base GPIO table for platform ID %d\n", GpioCfgCurrHdr->BaseTableId));
return EFI_NOT_FOUND;
}
if (GpioCfgCurrHdr->ItemSize != GpioCfgBaseHdr->ItemSize) {
DEBUG ((GPIO_DEBUG_ERROR, "Inconsistent GPIO item size\n"));
return EFI_LOAD_ERROR;
}
}
return EFI_SUCCESS;
}
|
c4ce6e350cfa879e1896e25251d7f491936e0a70
|
096e73c45295249e5fd7807927a8d78abf2e9be5
|
/Chapter-01/p5.c
|
565a3e9676a6dfd19d4988e2d332333c8d4050e7
|
[] |
no_license
|
MeiK2333/apue
|
7d7b14aceb095649743c74997fb3912431047e2c
|
466e7aebd2e383989ae3ba4f08d78240336e82c6
|
refs/heads/master
| 2022-06-27T12:38:41.105851
| 2022-05-20T09:13:23
| 2022-05-20T09:13:23
| 130,294,216
| 403
| 122
| null | 2022-05-20T09:13:24
| 2018-04-20T01:54:04
|
C
|
UTF-8
|
C
| false
| false
| 129
|
c
|
p5.c
|
#include <stdio.h>
const int max = ~(1 << 31);
int main() {
printf("%f\n", max * 1.0 / 100 / 60 / 60 / 24);
return 0;
}
|
0a90f555bf2116a8a6519e8e87492b84bca68f23
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/kernel/extable.c
|
67460b93b1a1cb8d60294cd90c2972ab97fd80e8
|
[
"Linux-syscall-note",
"GPL-2.0-only",
"GPL-1.0-or-later",
"LicenseRef-scancode-free-unknown",
"Apache-2.0"
] |
permissive
|
OLIMEX/DIY-LAPTOP
|
ae82f4ee79c641d9aee444db9a75f3f6709afa92
|
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
|
refs/heads/rel3
| 2023-08-04T01:54:19.483792
| 2023-04-03T07:18:12
| 2023-04-03T07:18:12
| 80,094,055
| 507
| 92
|
Apache-2.0
| 2023-04-03T07:05:59
| 2017-01-26T07:25:50
|
C
|
UTF-8
|
C
| false
| false
| 3,931
|
c
|
extable.c
|
/* Rewritten by Rusty Russell, on the backs of many others...
Copyright (C) 2001 Rusty Russell, 2002 Rusty Russell IBM.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <linux/ftrace.h>
#include <linux/memory.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/init.h>
#include <asm/sections.h>
#include <asm/uaccess.h>
/*
* mutex protecting text section modification (dynamic code patching).
* some users need to sleep (allocating memory...) while they hold this lock.
*
* NOT exported to modules - patching kernel text is a really delicate matter.
*/
DEFINE_MUTEX(text_mutex);
extern struct exception_table_entry __start___ex_table[];
extern struct exception_table_entry __stop___ex_table[];
/* Cleared by build time tools if the table is already sorted. */
u32 __initdata main_extable_sort_needed = 1;
/* Sort the kernel's built-in exception table */
void __init sort_main_extable(void)
{
if (main_extable_sort_needed) {
pr_notice("Sorting __ex_table...\n");
sort_extable(__start___ex_table, __stop___ex_table);
}
}
/* Given an address, look for it in the exception tables. */
const struct exception_table_entry *search_exception_tables(unsigned long addr)
{
const struct exception_table_entry *e;
e = search_extable(__start___ex_table, __stop___ex_table-1, addr);
if (!e)
e = search_module_extables(addr);
return e;
}
static inline int init_kernel_text(unsigned long addr)
{
if (addr >= (unsigned long)_sinittext &&
addr <= (unsigned long)_einittext)
return 1;
return 0;
}
int core_kernel_text(unsigned long addr)
{
if (addr >= (unsigned long)_stext &&
addr <= (unsigned long)_etext)
return 1;
if (system_state == SYSTEM_BOOTING &&
init_kernel_text(addr))
return 1;
return 0;
}
/**
* core_kernel_data - tell if addr points to kernel data
* @addr: address to test
*
* Returns true if @addr passed in is from the core kernel data
* section.
*
* Note: On some archs it may return true for core RODATA, and false
* for others. But will always be true for core RW data.
*/
int core_kernel_data(unsigned long addr)
{
if (addr >= (unsigned long)_sdata &&
addr < (unsigned long)_edata)
return 1;
return 0;
}
int __kernel_text_address(unsigned long addr)
{
if (core_kernel_text(addr))
return 1;
if (is_module_text_address(addr))
return 1;
/*
* There might be init symbols in saved stacktraces.
* Give those symbols a chance to be printed in
* backtraces (such as lockdep traces).
*
* Since we are after the module-symbols check, there's
* no danger of address overlap:
*/
if (init_kernel_text(addr))
return 1;
return 0;
}
int kernel_text_address(unsigned long addr)
{
if (core_kernel_text(addr))
return 1;
return is_module_text_address(addr);
}
/*
* On some architectures (PPC64, IA64) function pointers
* are actually only tokens to some data that then holds the
* real function address. As a result, to find if a function
* pointer is part of the kernel text, we need to do some
* special dereferencing first.
*/
int func_ptr_is_kernel_text(void *ptr)
{
unsigned long addr;
addr = (unsigned long) dereference_function_descriptor(ptr);
if (core_kernel_text(addr))
return 1;
return is_module_text_address(addr);
}
|
66cf842df3323bd795295d94935130f9524485cf
|
0149ed842327e3133fc2fe7b49d6ee2e27c22021
|
/shared/source/aub_mem_dump/aub_data.h
|
a00a3db5b23a2009bc7d1c1fb6e33e890c235193
|
[
"MIT"
] |
permissive
|
intel/compute-runtime
|
17f1c3dd3e1120895c6217b1e6c311d88a09902e
|
869e3ec9f83a79ca4ac43a18d21847183c63e037
|
refs/heads/master
| 2023-09-03T07:28:16.591743
| 2023-09-02T02:04:35
| 2023-09-02T02:24:33
| 105,299,354
| 1,027
| 262
|
MIT
| 2023-08-25T11:06:41
| 2017-09-29T17:26:43
|
C++
|
UTF-8
|
C
| false
| false
| 168
|
h
|
aub_data.h
|
/*
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
struct AubGTTData {
bool present;
bool localMemory;
};
|
58a3f2f708460b7d3a9e6604b53b6886d0aff110
|
6432ea7a083ff6ba21ea17af9ee47b9c371760f7
|
/stage0/stdlib/Init/SizeOf.c
|
7d215a97ecbc6820460d6c9a107c396d74332989
|
[
"Apache-2.0",
"LLVM-exception",
"NCSA",
"LGPL-3.0-only",
"LicenseRef-scancode-inner-net-2.0",
"BSD-3-Clause",
"LGPL-2.0-or-later",
"Spencer-94",
"LGPL-2.1-or-later",
"HPND",
"LicenseRef-scancode-pcre",
"ISC",
"LGPL-2.1-only",
"LicenseRef-scancode-other-permissive",
"SunPro",
"CMU-Mach"
] |
permissive
|
leanprover/lean4
|
4bdf9790294964627eb9be79f5e8f6157780b4cc
|
f1f9dc0f2f531af3312398999d8b8303fa5f096b
|
refs/heads/master
| 2023-08-30T01:57:45.786981
| 2023-08-29T23:14:28
| 2023-08-29T23:14:28
| 129,571,436
| 2,827
| 311
|
Apache-2.0
| 2023-09-14T18:29:16
| 2018-04-15T02:49:20
|
Lean
|
UTF-8
|
C
| false
| false
| 2,965
|
c
|
SizeOf.c
|
// Lean compiler output
// Module: Init.SizeOf
// Imports: Init.Tactics
#include <lean/lean.h>
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wunused-parameter"
#pragma clang diagnostic ignored "-Wunused-label"
#elif defined(__GNUC__) && !defined(__CLANG__)
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunused-label"
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif
#ifdef __cplusplus
extern "C" {
#endif
LEAN_EXPORT lean_object* l_default_sizeOf(lean_object*, lean_object*);
LEAN_EXPORT lean_object* l_instSizeOfNat___boxed(lean_object*);
LEAN_EXPORT lean_object* l_instSizeOfForAllUnit___rarg(lean_object*, lean_object*);
LEAN_EXPORT lean_object* l_default_sizeOf___boxed(lean_object*, lean_object*);
LEAN_EXPORT lean_object* l_instSizeOfNat(lean_object*);
LEAN_EXPORT lean_object* l_instSizeOfForAllUnit(lean_object*);
LEAN_EXPORT lean_object* l_instSizeOf(lean_object*);
static lean_object* l_instSizeOf___closed__1;
LEAN_EXPORT lean_object* l_default_sizeOf(lean_object* x_1, lean_object* x_2) {
_start:
{
lean_object* x_3;
x_3 = lean_unsigned_to_nat(0u);
return x_3;
}
}
LEAN_EXPORT lean_object* l_default_sizeOf___boxed(lean_object* x_1, lean_object* x_2) {
_start:
{
lean_object* x_3;
x_3 = l_default_sizeOf(x_1, x_2);
lean_dec(x_2);
return x_3;
}
}
static lean_object* _init_l_instSizeOf___closed__1() {
_start:
{
lean_object* x_1;
x_1 = lean_alloc_closure((void*)(l_default_sizeOf___boxed), 2, 1);
lean_closure_set(x_1, 0, lean_box(0));
return x_1;
}
}
LEAN_EXPORT lean_object* l_instSizeOf(lean_object* x_1) {
_start:
{
lean_object* x_2;
x_2 = l_instSizeOf___closed__1;
return x_2;
}
}
LEAN_EXPORT lean_object* l_instSizeOfNat(lean_object* x_1) {
_start:
{
lean_inc(x_1);
return x_1;
}
}
LEAN_EXPORT lean_object* l_instSizeOfNat___boxed(lean_object* x_1) {
_start:
{
lean_object* x_2;
x_2 = l_instSizeOfNat(x_1);
lean_dec(x_1);
return x_2;
}
}
LEAN_EXPORT lean_object* l_instSizeOfForAllUnit___rarg(lean_object* x_1, lean_object* x_2) {
_start:
{
lean_object* x_3; lean_object* x_4; lean_object* x_5;
x_3 = lean_box(0);
x_4 = lean_apply_1(x_2, x_3);
x_5 = lean_apply_1(x_1, x_4);
return x_5;
}
}
LEAN_EXPORT lean_object* l_instSizeOfForAllUnit(lean_object* x_1) {
_start:
{
lean_object* x_2;
x_2 = lean_alloc_closure((void*)(l_instSizeOfForAllUnit___rarg), 2, 0);
return x_2;
}
}
lean_object* initialize_Init_Tactics(uint8_t builtin, lean_object*);
static bool _G_initialized = false;
LEAN_EXPORT lean_object* initialize_Init_SizeOf(uint8_t builtin, lean_object* w) {
lean_object * res;
if (_G_initialized) return lean_io_result_mk_ok(lean_box(0));
_G_initialized = true;
res = initialize_Init_Tactics(builtin, lean_io_mk_world());
if (lean_io_result_is_error(res)) return res;
lean_dec_ref(res);
l_instSizeOf___closed__1 = _init_l_instSizeOf___closed__1();
lean_mark_persistent(l_instSizeOf___closed__1);
return lean_io_result_mk_ok(lean_box(0));
}
#ifdef __cplusplus
}
#endif
|
c1eda31bf328e5adb5dad05c42d1cc468df2fa19
|
e1cddfd754d952134e72dfd03522c5ea4fb6008e
|
/src/vlib/threads.c
|
4b70642d3cbfd84eb415493ff1b8788183394675
|
[
"Apache-2.0"
] |
permissive
|
FDio/vpp
|
0ad30fa1bec2975ffa6b66b45c9f4f32163123b6
|
f234b0d4626d7e686422cc9dfd25958584f4931e
|
refs/heads/master
| 2023-08-31T16:09:04.068646
| 2022-03-14T09:49:15
| 2023-08-31T09:50:00
| 96,556,718
| 1,048
| 630
|
Apache-2.0
| 2023-06-21T05:39:17
| 2017-07-07T16:29:40
|
C
|
UTF-8
|
C
| false
| false
| 48,633
|
c
|
threads.c
|
/*
* Copyright (c) 2015 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define _GNU_SOURCE
#include <signal.h>
#include <math.h>
#include <vppinfra/format.h>
#include <vppinfra/time_range.h>
#include <vppinfra/interrupt.h>
#include <vppinfra/linux/sysfs.h>
#include <vlib/vlib.h>
#include <vlib/threads.h>
#include <vlib/stats/stats.h>
u32
vl (void *p)
{
return vec_len (p);
}
vlib_worker_thread_t *vlib_worker_threads;
vlib_thread_main_t vlib_thread_main;
/*
* Barrier tracing can be enabled on a normal build to collect information
* on barrier use, including timings and call stacks. Deliberately not
* keyed off CLIB_DEBUG, because that can add significant overhead which
* imapacts observed timings.
*/
static inline void
barrier_trace_sync (f64 t_entry, f64 t_open, f64 t_closed)
{
if (!vlib_worker_threads->barrier_elog_enabled)
return;
ELOG_TYPE_DECLARE (e) = {
.format = "bar-trace-%s-#%d",
.format_args = "T4i4",
};
struct
{
u32 caller, count, t_entry, t_open, t_closed;
} *ed = 0;
ed = ELOG_DATA (&vlib_global_main.elog_main, e);
ed->count = (int) vlib_worker_threads[0].barrier_sync_count;
ed->caller = elog_string (&vlib_global_main.elog_main,
(char *) vlib_worker_threads[0].barrier_caller);
ed->t_entry = (int) (1000000.0 * t_entry);
ed->t_open = (int) (1000000.0 * t_open);
ed->t_closed = (int) (1000000.0 * t_closed);
}
static inline void
barrier_trace_sync_rec (f64 t_entry)
{
if (!vlib_worker_threads->barrier_elog_enabled)
return;
ELOG_TYPE_DECLARE (e) = {
.format = "bar-syncrec-%s-#%d",
.format_args = "T4i4",
};
struct
{
u32 caller, depth;
} *ed = 0;
ed = ELOG_DATA (&vlib_global_main.elog_main, e);
ed->depth = (int) vlib_worker_threads[0].recursion_level - 1;
ed->caller = elog_string (&vlib_global_main.elog_main,
(char *) vlib_worker_threads[0].barrier_caller);
}
static inline void
barrier_trace_release_rec (f64 t_entry)
{
if (!vlib_worker_threads->barrier_elog_enabled)
return;
ELOG_TYPE_DECLARE (e) = {
.format = "bar-relrrec-#%d",
.format_args = "i4",
};
struct
{
u32 depth;
} *ed = 0;
ed = ELOG_DATA (&vlib_global_main.elog_main, e);
ed->depth = (int) vlib_worker_threads[0].recursion_level;
}
static inline void
barrier_trace_release (f64 t_entry, f64 t_closed_total, f64 t_update_main)
{
if (!vlib_worker_threads->barrier_elog_enabled)
return;
ELOG_TYPE_DECLARE (e) = {
.format = "bar-rel-#%d-e%d-u%d-t%d",
.format_args = "i4i4i4i4",
};
struct
{
u32 count, t_entry, t_update_main, t_closed_total;
} *ed = 0;
ed = ELOG_DATA (&vlib_global_main.elog_main, e);
ed->t_entry = (int) (1000000.0 * t_entry);
ed->t_update_main = (int) (1000000.0 * t_update_main);
ed->t_closed_total = (int) (1000000.0 * t_closed_total);
ed->count = (int) vlib_worker_threads[0].barrier_sync_count;
/* Reset context for next trace */
vlib_worker_threads[0].barrier_context = NULL;
}
uword
os_get_nthreads (void)
{
return vec_len (vlib_thread_stacks);
}
void
vlib_set_thread_name (char *name)
{
int pthread_setname_np (pthread_t __target_thread, const char *__name);
int rv;
pthread_t thread = pthread_self ();
if (thread)
{
rv = pthread_setname_np (thread, name);
if (rv)
clib_warning ("pthread_setname_np returned %d", rv);
}
}
static int
sort_registrations_by_no_clone (void *a0, void *a1)
{
vlib_thread_registration_t **tr0 = a0;
vlib_thread_registration_t **tr1 = a1;
return ((i32) ((*tr0)->no_data_structure_clone)
- ((i32) ((*tr1)->no_data_structure_clone)));
}
/* Called early in the init sequence */
clib_error_t *
vlib_thread_init (vlib_main_t * vm)
{
vlib_thread_main_t *tm = &vlib_thread_main;
vlib_worker_thread_t *w;
vlib_thread_registration_t *tr;
u32 n_vlib_mains = 1;
u32 first_index = 1;
u32 i;
uword *avail_cpu;
u32 stats_num_worker_threads_dir_index;
stats_num_worker_threads_dir_index =
vlib_stats_add_gauge ("/sys/num_worker_threads");
ASSERT (stats_num_worker_threads_dir_index != ~0);
/* get bitmaps of active cpu cores and sockets */
tm->cpu_core_bitmap =
clib_sysfs_list_to_bitmap ("/sys/devices/system/cpu/online");
tm->cpu_socket_bitmap =
clib_sysfs_list_to_bitmap ("/sys/devices/system/node/online");
avail_cpu = clib_bitmap_dup (tm->cpu_core_bitmap);
/* skip cores */
for (i = 0; i < tm->skip_cores; i++)
{
uword c = clib_bitmap_first_set (avail_cpu);
if (c == ~0)
return clib_error_return (0, "no available cpus to skip");
avail_cpu = clib_bitmap_set (avail_cpu, c, 0);
}
/* grab cpu for main thread */
if (tm->main_lcore != ~0)
{
if (clib_bitmap_get (avail_cpu, tm->main_lcore) == 0)
return clib_error_return (0, "cpu %u is not available to be used"
" for the main thread", tm->main_lcore);
avail_cpu = clib_bitmap_set (avail_cpu, tm->main_lcore, 0);
}
/* assume that there is socket 0 only if there is no data from sysfs */
if (!tm->cpu_socket_bitmap)
tm->cpu_socket_bitmap = clib_bitmap_set (0, 0, 1);
/* pin main thread to main_lcore */
if (tm->main_lcore != ~0)
{
cpu_set_t cpuset;
CPU_ZERO (&cpuset);
CPU_SET (tm->main_lcore, &cpuset);
pthread_setaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset);
}
/* Set up thread 0 */
vec_validate_aligned (vlib_worker_threads, 0, CLIB_CACHE_LINE_BYTES);
vec_set_len (vlib_worker_threads, 1);
w = vlib_worker_threads;
w->thread_mheap = clib_mem_get_heap ();
w->thread_stack = vlib_thread_stacks[0];
w->cpu_id = tm->main_lcore;
w->lwp = syscall (SYS_gettid);
w->thread_id = pthread_self ();
tm->n_vlib_mains = 1;
vlib_get_thread_core_numa (w, w->cpu_id);
if (tm->sched_policy != ~0)
{
struct sched_param sched_param;
if (!sched_getparam (w->lwp, &sched_param))
{
if (tm->sched_priority != ~0)
sched_param.sched_priority = tm->sched_priority;
sched_setscheduler (w->lwp, tm->sched_policy, &sched_param);
}
}
/* assign threads to cores and set n_vlib_mains */
tr = tm->next;
while (tr)
{
vec_add1 (tm->registrations, tr);
tr = tr->next;
}
vec_sort_with_function (tm->registrations, sort_registrations_by_no_clone);
for (i = 0; i < vec_len (tm->registrations); i++)
{
int j;
tr = tm->registrations[i];
tr->first_index = first_index;
first_index += tr->count;
n_vlib_mains += (tr->no_data_structure_clone == 0) ? tr->count : 0;
/* construct coremask */
if (tr->use_pthreads || !tr->count)
continue;
if (tr->coremask)
{
uword c;
/* *INDENT-OFF* */
clib_bitmap_foreach (c, tr->coremask) {
if (clib_bitmap_get(avail_cpu, c) == 0)
return clib_error_return (0, "cpu %u is not available to be used"
" for the '%s' thread",c, tr->name);
avail_cpu = clib_bitmap_set(avail_cpu, c, 0);
}
/* *INDENT-ON* */
}
else
{
for (j = 0; j < tr->count; j++)
{
/* Do not use CPU 0 by default - leave it to the host and IRQs */
uword avail_c0 = clib_bitmap_get (avail_cpu, 0);
avail_cpu = clib_bitmap_set (avail_cpu, 0, 0);
uword c = clib_bitmap_first_set (avail_cpu);
/* Use CPU 0 as a last resort */
if (c == ~0 && avail_c0)
{
c = 0;
avail_c0 = 0;
}
if (c == ~0)
return clib_error_return (0,
"no available cpus to be used for"
" the '%s' thread", tr->name);
avail_cpu = clib_bitmap_set (avail_cpu, 0, avail_c0);
avail_cpu = clib_bitmap_set (avail_cpu, c, 0);
tr->coremask = clib_bitmap_set (tr->coremask, c, 1);
}
}
}
clib_bitmap_free (avail_cpu);
tm->n_vlib_mains = n_vlib_mains;
vlib_stats_set_gauge (stats_num_worker_threads_dir_index, n_vlib_mains - 1);
/*
* Allocate the remaining worker threads, and thread stack vector slots
* from now on, calls to os_get_nthreads() will return the correct
* answer.
*/
vec_validate_aligned (vlib_worker_threads, first_index - 1,
CLIB_CACHE_LINE_BYTES);
vec_validate (vlib_thread_stacks, vec_len (vlib_worker_threads) - 1);
return 0;
}
vlib_frame_queue_t *
vlib_frame_queue_alloc (int nelts)
{
vlib_frame_queue_t *fq;
fq = clib_mem_alloc_aligned (sizeof (*fq), CLIB_CACHE_LINE_BYTES);
clib_memset (fq, 0, sizeof (*fq));
fq->nelts = nelts;
fq->vector_threshold = 2 * VLIB_FRAME_SIZE;
vec_validate_aligned (fq->elts, nelts - 1, CLIB_CACHE_LINE_BYTES);
if (nelts & (nelts - 1))
{
fformat (stderr, "FATAL: nelts MUST be a power of 2\n");
abort ();
}
return (fq);
}
void vl_msg_api_handler_no_free (void *) __attribute__ ((weak));
void
vl_msg_api_handler_no_free (void *v)
{
}
/* To be called by vlib worker threads upon startup */
void
vlib_worker_thread_init (vlib_worker_thread_t * w)
{
vlib_thread_main_t *tm = vlib_get_thread_main ();
/*
* Note: disabling signals in worker threads as follows
* prevents the api post-mortem dump scheme from working
* {
* sigset_t s;
* sigfillset (&s);
* pthread_sigmask (SIG_SETMASK, &s, 0);
* }
*/
clib_mem_set_heap (w->thread_mheap);
if (vec_len (tm->thread_prefix) && w->registration->short_name)
{
w->name = format (0, "%v_%s_%d%c", tm->thread_prefix,
w->registration->short_name, w->instance_id, '\0');
vlib_set_thread_name ((char *) w->name);
}
if (!w->registration->use_pthreads)
{
/* Initial barrier sync, for both worker and i/o threads */
clib_atomic_fetch_add (vlib_worker_threads->workers_at_barrier, 1);
while (*vlib_worker_threads->wait_at_barrier)
;
clib_atomic_fetch_add (vlib_worker_threads->workers_at_barrier, -1);
}
}
void *
vlib_worker_thread_bootstrap_fn (void *arg)
{
vlib_worker_thread_t *w = arg;
w->lwp = syscall (SYS_gettid);
w->thread_id = pthread_self ();
__os_thread_index = w - vlib_worker_threads;
if (CLIB_DEBUG > 0)
{
void *frame_addr = __builtin_frame_address (0);
if (frame_addr < (void *) w->thread_stack ||
frame_addr > (void *) w->thread_stack + VLIB_THREAD_STACK_SIZE)
{
/* heap is not set yet */
fprintf (stderr, "thread stack is not set properly\n");
exit (1);
}
}
w->thread_function (arg);
return 0;
}
void
vlib_get_thread_core_numa (vlib_worker_thread_t * w, unsigned cpu_id)
{
const char *sys_cpu_path = "/sys/devices/system/cpu/cpu";
const char *sys_node_path = "/sys/devices/system/node/node";
clib_bitmap_t *nbmp = 0, *cbmp = 0;
u32 node;
u8 *p = 0;
int core_id = -1, numa_id = -1;
p = format (p, "%s%u/topology/core_id%c", sys_cpu_path, cpu_id, 0);
clib_sysfs_read ((char *) p, "%d", &core_id);
vec_reset_length (p);
/* *INDENT-OFF* */
clib_sysfs_read ("/sys/devices/system/node/online", "%U",
unformat_bitmap_list, &nbmp);
clib_bitmap_foreach (node, nbmp) {
p = format (p, "%s%u/cpulist%c", sys_node_path, node, 0);
clib_sysfs_read ((char *) p, "%U", unformat_bitmap_list, &cbmp);
if (clib_bitmap_get (cbmp, cpu_id))
numa_id = node;
vec_reset_length (cbmp);
vec_reset_length (p);
}
/* *INDENT-ON* */
vec_free (nbmp);
vec_free (cbmp);
vec_free (p);
w->core_id = core_id;
w->numa_id = numa_id;
}
static clib_error_t *
vlib_launch_thread_int (void *fp, vlib_worker_thread_t * w, unsigned cpu_id)
{
clib_mem_main_t *mm = &clib_mem_main;
vlib_thread_main_t *tm = &vlib_thread_main;
pthread_t worker;
pthread_attr_t attr;
cpu_set_t cpuset;
void *(*fp_arg) (void *) = fp;
void *numa_heap;
w->cpu_id = cpu_id;
vlib_get_thread_core_numa (w, cpu_id);
/* Set up NUMA-bound heap if indicated */
if (mm->per_numa_mheaps[w->numa_id] == 0)
{
/* If the user requested a NUMA heap, create it... */
if (tm->numa_heap_size)
{
clib_mem_set_numa_affinity (w->numa_id, 1 /* force */ );
numa_heap = clib_mem_create_heap (0 /* DIY */ , tm->numa_heap_size,
1 /* is_locked */ ,
"numa %u heap", w->numa_id);
clib_mem_set_default_numa_affinity ();
mm->per_numa_mheaps[w->numa_id] = numa_heap;
}
else
{
/* Or, use the main heap */
mm->per_numa_mheaps[w->numa_id] = w->thread_mheap;
}
}
CPU_ZERO (&cpuset);
CPU_SET (cpu_id, &cpuset);
if (pthread_attr_init (&attr))
return clib_error_return_unix (0, "pthread_attr_init");
if (pthread_attr_setstack (&attr, w->thread_stack,
VLIB_THREAD_STACK_SIZE))
return clib_error_return_unix (0, "pthread_attr_setstack");
if (pthread_create (&worker, &attr, fp_arg, (void *) w))
return clib_error_return_unix (0, "pthread_create");
if (pthread_setaffinity_np (worker, sizeof (cpu_set_t), &cpuset))
return clib_error_return_unix (0, "pthread_setaffinity_np");
if (pthread_attr_destroy (&attr))
return clib_error_return_unix (0, "pthread_attr_destroy");
return 0;
}
static clib_error_t *
start_workers (vlib_main_t * vm)
{
vlib_global_main_t *vgm = vlib_get_global_main ();
vlib_main_t *fvm = vlib_get_first_main ();
int i, j;
vlib_worker_thread_t *w;
vlib_main_t *vm_clone;
void *oldheap;
vlib_thread_main_t *tm = &vlib_thread_main;
vlib_thread_registration_t *tr;
vlib_node_runtime_t *rt;
u32 n_vlib_mains = tm->n_vlib_mains;
u32 worker_thread_index;
u32 stats_err_entry_index = fvm->error_main.stats_err_entry_index;
clib_mem_heap_t *main_heap = clib_mem_get_per_cpu_heap ();
vlib_stats_register_mem_heap (main_heap);
vec_reset_length (vlib_worker_threads);
/* Set up the main thread */
vec_add2_aligned (vlib_worker_threads, w, 1, CLIB_CACHE_LINE_BYTES);
w->elog_track.name = "main thread";
elog_track_register (vlib_get_elog_main (), &w->elog_track);
if (vec_len (tm->thread_prefix))
{
w->name = format (0, "%v_main%c", tm->thread_prefix, '\0');
vlib_set_thread_name ((char *) w->name);
}
vgm->elog_main.lock =
clib_mem_alloc_aligned (CLIB_CACHE_LINE_BYTES, CLIB_CACHE_LINE_BYTES);
vgm->elog_main.lock[0] = 0;
clib_callback_data_init (&vm->vlib_node_runtime_perf_callbacks,
&vm->worker_thread_main_loop_callback_lock);
vec_validate_aligned (vgm->vlib_mains, n_vlib_mains - 1,
CLIB_CACHE_LINE_BYTES);
vec_set_len (vgm->vlib_mains, 0);
vec_add1_aligned (vgm->vlib_mains, vm, CLIB_CACHE_LINE_BYTES);
if (n_vlib_mains > 1)
{
vlib_worker_threads->wait_at_barrier =
clib_mem_alloc_aligned (sizeof (u32), CLIB_CACHE_LINE_BYTES);
vlib_worker_threads->workers_at_barrier =
clib_mem_alloc_aligned (sizeof (u32), CLIB_CACHE_LINE_BYTES);
vlib_worker_threads->node_reforks_required =
clib_mem_alloc_aligned (sizeof (u32), CLIB_CACHE_LINE_BYTES);
/* We'll need the rpc vector lock... */
clib_spinlock_init (&vm->pending_rpc_lock);
/* Ask for an initial barrier sync */
*vlib_worker_threads->workers_at_barrier = 0;
*vlib_worker_threads->wait_at_barrier = 1;
/* Without update or refork */
*vlib_worker_threads->node_reforks_required = 0;
vgm->need_vlib_worker_thread_node_runtime_update = 0;
/* init timing */
vm->barrier_epoch = 0;
vm->barrier_no_close_before = 0;
worker_thread_index = 1;
clib_spinlock_init (&vm->worker_thread_main_loop_callback_lock);
for (i = 0; i < vec_len (tm->registrations); i++)
{
vlib_node_main_t *nm, *nm_clone;
int k;
tr = tm->registrations[i];
if (tr->count == 0)
continue;
for (k = 0; k < tr->count; k++)
{
vlib_node_t *n;
u64 **c;
vec_add2 (vlib_worker_threads, w, 1);
/* Currently unused, may not really work */
if (tr->mheap_size)
w->thread_mheap = clib_mem_create_heap (0, tr->mheap_size,
/* unlocked */ 0,
"%s%d heap",
tr->name, k);
else
w->thread_mheap = main_heap;
w->thread_stack =
vlib_thread_stack_init (w - vlib_worker_threads);
w->thread_function = tr->function;
w->thread_function_arg = w;
w->instance_id = k;
w->registration = tr;
w->elog_track.name =
(char *) format (0, "%s %d", tr->name, k + 1);
vec_add1 (w->elog_track.name, 0);
elog_track_register (vlib_get_elog_main (), &w->elog_track);
if (tr->no_data_structure_clone)
continue;
/* Fork vlib_global_main et al. Look for bugs here */
oldheap = clib_mem_set_heap (w->thread_mheap);
vm_clone = clib_mem_alloc_aligned (sizeof (*vm_clone),
CLIB_CACHE_LINE_BYTES);
clib_memcpy (vm_clone, vlib_get_first_main (),
sizeof (*vm_clone));
vm_clone->thread_index = worker_thread_index;
vm_clone->pending_rpc_requests = 0;
vec_validate (vm_clone->pending_rpc_requests, 0);
vec_set_len (vm_clone->pending_rpc_requests, 0);
clib_memset (&vm_clone->random_buffer, 0,
sizeof (vm_clone->random_buffer));
clib_spinlock_init
(&vm_clone->worker_thread_main_loop_callback_lock);
clib_callback_data_init
(&vm_clone->vlib_node_runtime_perf_callbacks,
&vm_clone->worker_thread_main_loop_callback_lock);
nm = &vlib_get_first_main ()->node_main;
nm_clone = &vm_clone->node_main;
/* fork next frames array, preserving node runtime indices */
nm_clone->next_frames = vec_dup_aligned (nm->next_frames,
CLIB_CACHE_LINE_BYTES);
for (j = 0; j < vec_len (nm_clone->next_frames); j++)
{
vlib_next_frame_t *nf = &nm_clone->next_frames[j];
u32 save_node_runtime_index;
u32 save_flags;
save_node_runtime_index = nf->node_runtime_index;
save_flags = nf->flags & VLIB_FRAME_NO_FREE_AFTER_DISPATCH;
vlib_next_frame_init (nf);
nf->node_runtime_index = save_node_runtime_index;
nf->flags = save_flags;
}
/* fork the frame dispatch queue */
nm_clone->pending_frames = 0;
vec_validate (nm_clone->pending_frames, 10);
vec_set_len (nm_clone->pending_frames, 0);
/* fork nodes */
nm_clone->nodes = 0;
/* Allocate all nodes in single block for speed */
n = clib_mem_alloc_no_fail (vec_len (nm->nodes) * sizeof (*n));
for (j = 0; j < vec_len (nm->nodes); j++)
{
clib_memcpy (n, nm->nodes[j], sizeof (*n));
/* none of the copied nodes have enqueue rights given out */
n->owner_node_index = VLIB_INVALID_NODE_INDEX;
clib_memset (&n->stats_total, 0, sizeof (n->stats_total));
clib_memset (&n->stats_last_clear, 0,
sizeof (n->stats_last_clear));
vec_add1 (nm_clone->nodes, n);
n++;
}
nm_clone->nodes_by_type[VLIB_NODE_TYPE_INTERNAL] =
vec_dup_aligned (nm->nodes_by_type[VLIB_NODE_TYPE_INTERNAL],
CLIB_CACHE_LINE_BYTES);
vec_foreach (rt,
nm_clone->nodes_by_type[VLIB_NODE_TYPE_INTERNAL])
{
vlib_node_t *n = vlib_get_node (vm, rt->node_index);
/* copy initial runtime_data from node */
if (n->runtime_data && n->runtime_data_bytes > 0)
clib_memcpy (rt->runtime_data, n->runtime_data,
clib_min (VLIB_NODE_RUNTIME_DATA_SIZE,
n->runtime_data_bytes));
}
nm_clone->nodes_by_type[VLIB_NODE_TYPE_INPUT] =
vec_dup_aligned (nm->nodes_by_type[VLIB_NODE_TYPE_INPUT],
CLIB_CACHE_LINE_BYTES);
clib_interrupt_init (
&nm_clone->input_node_interrupts,
vec_len (nm_clone->nodes_by_type[VLIB_NODE_TYPE_INPUT]));
clib_interrupt_init (
&nm_clone->pre_input_node_interrupts,
vec_len (nm_clone->nodes_by_type[VLIB_NODE_TYPE_PRE_INPUT]));
vec_foreach (rt, nm_clone->nodes_by_type[VLIB_NODE_TYPE_INPUT])
{
vlib_node_t *n = vlib_get_node (vm, rt->node_index);
/* copy initial runtime_data from node */
if (n->runtime_data && n->runtime_data_bytes > 0)
clib_memcpy (rt->runtime_data, n->runtime_data,
clib_min (VLIB_NODE_RUNTIME_DATA_SIZE,
n->runtime_data_bytes));
}
nm_clone->nodes_by_type[VLIB_NODE_TYPE_PRE_INPUT] =
vec_dup_aligned (nm->nodes_by_type[VLIB_NODE_TYPE_PRE_INPUT],
CLIB_CACHE_LINE_BYTES);
vec_foreach (rt,
nm_clone->nodes_by_type[VLIB_NODE_TYPE_PRE_INPUT])
{
vlib_node_t *n = vlib_get_node (vm, rt->node_index);
/* copy initial runtime_data from node */
if (n->runtime_data && n->runtime_data_bytes > 0)
clib_memcpy (rt->runtime_data, n->runtime_data,
clib_min (VLIB_NODE_RUNTIME_DATA_SIZE,
n->runtime_data_bytes));
}
nm_clone->processes = vec_dup_aligned (nm->processes,
CLIB_CACHE_LINE_BYTES);
/* Create per-thread frame freelist */
nm_clone->frame_sizes = 0;
nm_clone->node_by_error = nm->node_by_error;
/* Packet trace buffers are guaranteed to be empty, nothing to do here */
clib_mem_set_heap (oldheap);
vec_add1_aligned (vgm->vlib_mains, vm_clone,
CLIB_CACHE_LINE_BYTES);
/* Switch to the stats segment ... */
vlib_stats_validate (stats_err_entry_index, worker_thread_index,
vec_len (fvm->error_main.counters) - 1);
c = vlib_stats_get_entry_data_pointer (stats_err_entry_index);
vm_clone->error_main.counters = c[worker_thread_index];
vm_clone->error_main.counters_last_clear = vec_dup_aligned (
vlib_get_first_main ()->error_main.counters_last_clear,
CLIB_CACHE_LINE_BYTES);
worker_thread_index++;
}
}
}
else
{
/* only have non-data-structure copy threads to create... */
for (i = 0; i < vec_len (tm->registrations); i++)
{
tr = tm->registrations[i];
for (j = 0; j < tr->count; j++)
{
vec_add2 (vlib_worker_threads, w, 1);
if (tr->mheap_size)
{
w->thread_mheap = clib_mem_create_heap (0, tr->mheap_size,
/* locked */ 0,
"%s%d heap",
tr->name, j);
}
else
w->thread_mheap = main_heap;
w->thread_stack =
vlib_thread_stack_init (w - vlib_worker_threads);
w->thread_function = tr->function;
w->thread_function_arg = w;
w->instance_id = j;
w->elog_track.name =
(char *) format (0, "%s %d", tr->name, j + 1);
w->registration = tr;
vec_add1 (w->elog_track.name, 0);
elog_track_register (vlib_get_elog_main (), &w->elog_track);
}
}
}
worker_thread_index = 1;
for (i = 0; i < vec_len (tm->registrations); i++)
{
clib_error_t *err;
int j;
tr = tm->registrations[i];
if (tr->use_pthreads || tm->use_pthreads)
{
for (j = 0; j < tr->count; j++)
{
w = vlib_worker_threads + worker_thread_index++;
err = vlib_launch_thread_int (vlib_worker_thread_bootstrap_fn,
w, 0);
if (err)
clib_error_report (err);
}
}
else
{
uword c;
/* *INDENT-OFF* */
clib_bitmap_foreach (c, tr->coremask) {
w = vlib_worker_threads + worker_thread_index++;
err = vlib_launch_thread_int (vlib_worker_thread_bootstrap_fn,
w, c);
if (err)
clib_error_report (err);
}
/* *INDENT-ON* */
}
}
vlib_worker_thread_barrier_sync (vm);
{
clib_error_t *err;
err = vlib_call_init_exit_functions (
vm, &vgm->num_workers_change_function_registrations, 1 /* call_once */,
1 /* is_global */);
if (err)
clib_error_report (err);
}
vlib_worker_thread_barrier_release (vm);
return 0;
}
VLIB_MAIN_LOOP_ENTER_FUNCTION (start_workers);
static inline void
worker_thread_node_runtime_update_internal (void)
{
int i, j;
vlib_main_t *vm;
vlib_node_main_t *nm, *nm_clone;
vlib_main_t *vm_clone;
vlib_node_runtime_t *rt;
ASSERT (vlib_get_thread_index () == 0);
vm = vlib_get_first_main ();
nm = &vm->node_main;
ASSERT (*vlib_worker_threads->wait_at_barrier == 1);
/*
* Scrape all runtime stats, so we don't lose node runtime(s) with
* pending counts, or throw away worker / io thread counts.
*/
for (j = 0; j < vec_len (nm->nodes); j++)
{
vlib_node_t *n;
n = nm->nodes[j];
vlib_node_sync_stats (vm, n);
}
for (i = 1; i < vlib_get_n_threads (); i++)
{
vlib_node_t *n;
vm_clone = vlib_get_main_by_index (i);
nm_clone = &vm_clone->node_main;
for (j = 0; j < vec_len (nm_clone->nodes); j++)
{
n = nm_clone->nodes[j];
rt = vlib_node_get_runtime (vm_clone, n->index);
vlib_node_runtime_sync_stats (vm_clone, rt, 0, 0, 0);
}
}
/* Per-worker clone rebuilds are now done on each thread */
}
void
vlib_worker_thread_node_refork (void)
{
vlib_main_t *vm, *vm_clone;
vlib_node_main_t *nm, *nm_clone;
vlib_node_t **old_nodes_clone;
vlib_node_runtime_t *rt, *old_rt;
u64 **c;
vlib_node_t *new_n_clone;
int j;
vm = vlib_get_first_main ();
nm = &vm->node_main;
vm_clone = vlib_get_main ();
nm_clone = &vm_clone->node_main;
/* Re-clone error heap */
u64 *old_counters_all_clear = vm_clone->error_main.counters_last_clear;
clib_memcpy_fast (&vm_clone->error_main, &vm->error_main,
sizeof (vm->error_main));
j = vec_len (vm->error_main.counters) - 1;
c = vlib_stats_get_entry_data_pointer (vm->error_main.stats_err_entry_index);
vm_clone->error_main.counters = c[vm_clone->thread_index];
vec_validate_aligned (old_counters_all_clear, j, CLIB_CACHE_LINE_BYTES);
vm_clone->error_main.counters_last_clear = old_counters_all_clear;
for (j = 0; j < vec_len (nm_clone->next_frames); j++)
{
vlib_next_frame_t *nf = &nm_clone->next_frames[j];
if ((nf->flags & VLIB_FRAME_IS_ALLOCATED) && nf->frame != NULL)
{
vlib_frame_t *f = nf->frame;
nf->frame = NULL;
vlib_frame_free (vm_clone, f);
}
}
vec_free (nm_clone->next_frames);
nm_clone->next_frames = vec_dup_aligned (nm->next_frames,
CLIB_CACHE_LINE_BYTES);
for (j = 0; j < vec_len (nm_clone->next_frames); j++)
{
vlib_next_frame_t *nf = &nm_clone->next_frames[j];
u32 save_node_runtime_index;
u32 save_flags;
save_node_runtime_index = nf->node_runtime_index;
save_flags = nf->flags & VLIB_FRAME_NO_FREE_AFTER_DISPATCH;
vlib_next_frame_init (nf);
nf->node_runtime_index = save_node_runtime_index;
nf->flags = save_flags;
}
old_nodes_clone = nm_clone->nodes;
nm_clone->nodes = 0;
/* re-fork nodes */
/* Allocate all nodes in single block for speed */
new_n_clone =
clib_mem_alloc_no_fail (vec_len (nm->nodes) * sizeof (*new_n_clone));
for (j = 0; j < vec_len (nm->nodes); j++)
{
vlib_node_t *new_n = nm->nodes[j];
clib_memcpy_fast (new_n_clone, new_n, sizeof (*new_n));
/* none of the copied nodes have enqueue rights given out */
new_n_clone->owner_node_index = VLIB_INVALID_NODE_INDEX;
if (j >= vec_len (old_nodes_clone))
{
/* new node, set to zero */
clib_memset (&new_n_clone->stats_total, 0,
sizeof (new_n_clone->stats_total));
clib_memset (&new_n_clone->stats_last_clear, 0,
sizeof (new_n_clone->stats_last_clear));
}
else
{
vlib_node_t *old_n_clone = old_nodes_clone[j];
/* Copy stats if the old data is valid */
clib_memcpy_fast (&new_n_clone->stats_total,
&old_n_clone->stats_total,
sizeof (new_n_clone->stats_total));
clib_memcpy_fast (&new_n_clone->stats_last_clear,
&old_n_clone->stats_last_clear,
sizeof (new_n_clone->stats_last_clear));
/* keep previous node state */
new_n_clone->state = old_n_clone->state;
new_n_clone->flags = old_n_clone->flags;
}
vec_add1 (nm_clone->nodes, new_n_clone);
new_n_clone++;
}
/* Free the old node clones */
clib_mem_free (old_nodes_clone[0]);
vec_free (old_nodes_clone);
/* re-clone internal nodes */
old_rt = nm_clone->nodes_by_type[VLIB_NODE_TYPE_INTERNAL];
nm_clone->nodes_by_type[VLIB_NODE_TYPE_INTERNAL] =
vec_dup_aligned (nm->nodes_by_type[VLIB_NODE_TYPE_INTERNAL],
CLIB_CACHE_LINE_BYTES);
vec_foreach (rt, nm_clone->nodes_by_type[VLIB_NODE_TYPE_INTERNAL])
{
vlib_node_t *n = vlib_get_node (vm, rt->node_index);
/* copy runtime_data, will be overwritten later for existing rt */
if (n->runtime_data && n->runtime_data_bytes > 0)
clib_memcpy_fast (rt->runtime_data, n->runtime_data,
clib_min (VLIB_NODE_RUNTIME_DATA_SIZE,
n->runtime_data_bytes));
}
for (j = 0; j < vec_len (old_rt); j++)
{
rt = vlib_node_get_runtime (vm_clone, old_rt[j].node_index);
rt->state = old_rt[j].state;
rt->flags = old_rt[j].flags;
clib_memcpy_fast (rt->runtime_data, old_rt[j].runtime_data,
VLIB_NODE_RUNTIME_DATA_SIZE);
}
vec_free (old_rt);
/* re-clone input nodes */
old_rt = nm_clone->nodes_by_type[VLIB_NODE_TYPE_INPUT];
nm_clone->nodes_by_type[VLIB_NODE_TYPE_INPUT] =
vec_dup_aligned (nm->nodes_by_type[VLIB_NODE_TYPE_INPUT],
CLIB_CACHE_LINE_BYTES);
clib_interrupt_resize (
&nm_clone->input_node_interrupts,
vec_len (nm_clone->nodes_by_type[VLIB_NODE_TYPE_INPUT]));
clib_interrupt_resize (
&nm_clone->pre_input_node_interrupts,
vec_len (nm_clone->nodes_by_type[VLIB_NODE_TYPE_PRE_INPUT]));
vec_foreach (rt, nm_clone->nodes_by_type[VLIB_NODE_TYPE_INPUT])
{
vlib_node_t *n = vlib_get_node (vm, rt->node_index);
/* copy runtime_data, will be overwritten later for existing rt */
if (n->runtime_data && n->runtime_data_bytes > 0)
clib_memcpy_fast (rt->runtime_data, n->runtime_data,
clib_min (VLIB_NODE_RUNTIME_DATA_SIZE,
n->runtime_data_bytes));
}
for (j = 0; j < vec_len (old_rt); j++)
{
rt = vlib_node_get_runtime (vm_clone, old_rt[j].node_index);
rt->state = old_rt[j].state;
rt->flags = old_rt[j].flags;
clib_memcpy_fast (rt->runtime_data, old_rt[j].runtime_data,
VLIB_NODE_RUNTIME_DATA_SIZE);
}
vec_free (old_rt);
/* re-clone pre-input nodes */
old_rt = nm_clone->nodes_by_type[VLIB_NODE_TYPE_PRE_INPUT];
nm_clone->nodes_by_type[VLIB_NODE_TYPE_PRE_INPUT] =
vec_dup_aligned (nm->nodes_by_type[VLIB_NODE_TYPE_PRE_INPUT],
CLIB_CACHE_LINE_BYTES);
vec_foreach (rt, nm_clone->nodes_by_type[VLIB_NODE_TYPE_PRE_INPUT])
{
vlib_node_t *n = vlib_get_node (vm, rt->node_index);
/* copy runtime_data, will be overwritten later for existing rt */
if (n->runtime_data && n->runtime_data_bytes > 0)
clib_memcpy_fast (rt->runtime_data, n->runtime_data,
clib_min (VLIB_NODE_RUNTIME_DATA_SIZE,
n->runtime_data_bytes));
}
for (j = 0; j < vec_len (old_rt); j++)
{
rt = vlib_node_get_runtime (vm_clone, old_rt[j].node_index);
rt->state = old_rt[j].state;
rt->flags = old_rt[j].flags;
clib_memcpy_fast (rt->runtime_data, old_rt[j].runtime_data,
VLIB_NODE_RUNTIME_DATA_SIZE);
}
vec_free (old_rt);
vec_free (nm_clone->processes);
nm_clone->processes = vec_dup_aligned (nm->processes,
CLIB_CACHE_LINE_BYTES);
nm_clone->node_by_error = nm->node_by_error;
}
void
vlib_worker_thread_node_runtime_update (void)
{
/*
* Make a note that we need to do a node runtime update
* prior to releasing the barrier.
*/
vlib_global_main.need_vlib_worker_thread_node_runtime_update = 1;
}
u32
unformat_sched_policy (unformat_input_t * input, va_list * args)
{
u32 *r = va_arg (*args, u32 *);
if (0);
#define _(v,f,s) else if (unformat (input, s)) *r = SCHED_POLICY_##f;
foreach_sched_policy
#undef _
else
return 0;
return 1;
}
static clib_error_t *
cpu_config (vlib_main_t * vm, unformat_input_t * input)
{
vlib_thread_registration_t *tr;
uword *p;
vlib_thread_main_t *tm = &vlib_thread_main;
u8 *name;
uword *bitmap;
u32 count;
tm->thread_registrations_by_name = hash_create_string (0, sizeof (uword));
tm->n_thread_stacks = 1; /* account for main thread */
tm->sched_policy = ~0;
tm->sched_priority = ~0;
tm->main_lcore = ~0;
tr = tm->next;
while (tr)
{
hash_set_mem (tm->thread_registrations_by_name, tr->name, (uword) tr);
tr = tr->next;
}
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (input, "use-pthreads"))
tm->use_pthreads = 1;
else if (unformat (input, "thread-prefix %v", &tm->thread_prefix))
;
else if (unformat (input, "main-core %u", &tm->main_lcore))
;
else if (unformat (input, "skip-cores %u", &tm->skip_cores))
;
else if (unformat (input, "numa-heap-size %U",
unformat_memory_size, &tm->numa_heap_size))
;
else if (unformat (input, "coremask-%s %U", &name,
unformat_bitmap_mask, &bitmap) ||
unformat (input, "corelist-%s %U", &name,
unformat_bitmap_list, &bitmap))
{
p = hash_get_mem (tm->thread_registrations_by_name, name);
if (p == 0)
return clib_error_return (0, "no such thread type '%s'", name);
tr = (vlib_thread_registration_t *) p[0];
if (tr->use_pthreads)
return clib_error_return (0,
"corelist cannot be set for '%s' threads",
name);
if (tr->count)
return clib_error_return
(0, "core placement of '%s' threads is already configured",
name);
tr->coremask = bitmap;
tr->count = clib_bitmap_count_set_bits (tr->coremask);
}
else
if (unformat
(input, "scheduler-policy %U", unformat_sched_policy,
&tm->sched_policy))
;
else if (unformat (input, "scheduler-priority %u", &tm->sched_priority))
;
else if (unformat (input, "%s %u", &name, &count))
{
p = hash_get_mem (tm->thread_registrations_by_name, name);
if (p == 0)
return clib_error_return (0, "no such thread type 3 '%s'", name);
tr = (vlib_thread_registration_t *) p[0];
if (tr->fixed_count)
return clib_error_return
(0, "number of '%s' threads not configurable", name);
if (tr->count)
return clib_error_return
(0, "number of '%s' threads is already configured", name);
tr->count = count;
}
else
break;
}
if (tm->sched_priority != ~0)
{
if (tm->sched_policy == SCHED_FIFO || tm->sched_policy == SCHED_RR)
{
u32 prio_max = sched_get_priority_max (tm->sched_policy);
u32 prio_min = sched_get_priority_min (tm->sched_policy);
if (tm->sched_priority > prio_max)
tm->sched_priority = prio_max;
if (tm->sched_priority < prio_min)
tm->sched_priority = prio_min;
}
else
{
return clib_error_return
(0,
"scheduling priority (%d) is not allowed for `normal` scheduling policy",
tm->sched_priority);
}
}
tr = tm->next;
if (!tm->thread_prefix)
tm->thread_prefix = format (0, "vpp");
while (tr)
{
tm->n_thread_stacks += tr->count;
tm->n_pthreads += tr->count * tr->use_pthreads;
tm->n_threads += tr->count * (tr->use_pthreads == 0);
tr = tr->next;
}
return 0;
}
VLIB_EARLY_CONFIG_FUNCTION (cpu_config, "cpu");
/*
* Enforce minimum open time to minimize packet loss due to Rx overflow,
* based on a test based heuristic that barrier should be open for at least
* 3 time as long as it is closed (with an upper bound of 1ms because by that
* point it is probably too late to make a difference)
*/
#ifndef BARRIER_MINIMUM_OPEN_LIMIT
#define BARRIER_MINIMUM_OPEN_LIMIT 0.001
#endif
#ifndef BARRIER_MINIMUM_OPEN_FACTOR
#define BARRIER_MINIMUM_OPEN_FACTOR 3
#endif
void
vlib_worker_thread_initial_barrier_sync_and_release (vlib_main_t * vm)
{
f64 deadline;
f64 now = vlib_time_now (vm);
u32 count = vlib_get_n_threads () - 1;
/* No worker threads? */
if (count == 0)
return;
deadline = now + BARRIER_SYNC_TIMEOUT;
*vlib_worker_threads->wait_at_barrier = 1;
while (*vlib_worker_threads->workers_at_barrier != count)
{
if ((now = vlib_time_now (vm)) > deadline)
{
fformat (stderr, "%s: worker thread deadlock\n", __FUNCTION__);
os_panic ();
}
CLIB_PAUSE ();
}
*vlib_worker_threads->wait_at_barrier = 0;
}
/**
* Return true if the wroker thread barrier is held
*/
u8
vlib_worker_thread_barrier_held (void)
{
if (vlib_get_n_threads () < 2)
return (1);
return (*vlib_worker_threads->wait_at_barrier == 1);
}
void
vlib_worker_thread_barrier_sync_int (vlib_main_t * vm, const char *func_name)
{
f64 deadline;
f64 now;
f64 t_entry;
f64 t_open;
f64 t_closed;
f64 max_vector_rate;
u32 count;
int i;
if (vlib_get_n_threads () < 2)
return;
ASSERT (vlib_get_thread_index () == 0);
vlib_worker_threads[0].barrier_caller = func_name;
count = vlib_get_n_threads () - 1;
/* Record entry relative to last close */
now = vlib_time_now (vm);
t_entry = now - vm->barrier_epoch;
/* Tolerate recursive calls */
if (++vlib_worker_threads[0].recursion_level > 1)
{
barrier_trace_sync_rec (t_entry);
return;
}
if (PREDICT_FALSE (vec_len (vm->barrier_perf_callbacks) != 0))
clib_call_callbacks (vm->barrier_perf_callbacks, vm,
vm->clib_time.last_cpu_time, 0 /* enter */ );
/*
* Need data to decide if we're working hard enough to honor
* the barrier hold-down timer.
*/
max_vector_rate = 0.0;
for (i = 1; i < vlib_get_n_threads (); i++)
{
vlib_main_t *ovm = vlib_get_main_by_index (i);
max_vector_rate = clib_max (max_vector_rate,
(f64) vlib_last_vectors_per_main_loop (ovm));
}
vlib_worker_threads[0].barrier_sync_count++;
/* Enforce minimum barrier open time to minimize packet loss */
ASSERT (vm->barrier_no_close_before <= (now + BARRIER_MINIMUM_OPEN_LIMIT));
/*
* If any worker thread seems busy, which we define
* as a vector rate above 10, we enforce the barrier hold-down timer
*/
if (max_vector_rate > 10.0)
{
while (1)
{
now = vlib_time_now (vm);
/* Barrier hold-down timer expired? */
if (now >= vm->barrier_no_close_before)
break;
if ((vm->barrier_no_close_before - now)
> (2.0 * BARRIER_MINIMUM_OPEN_LIMIT))
{
clib_warning
("clock change: would have waited for %.4f seconds",
(vm->barrier_no_close_before - now));
break;
}
}
}
/* Record time of closure */
t_open = now - vm->barrier_epoch;
vm->barrier_epoch = now;
deadline = now + BARRIER_SYNC_TIMEOUT;
*vlib_worker_threads->wait_at_barrier = 1;
while (*vlib_worker_threads->workers_at_barrier != count)
{
if ((now = vlib_time_now (vm)) > deadline)
{
fformat (stderr, "%s: worker thread deadlock\n", __FUNCTION__);
os_panic ();
}
}
t_closed = now - vm->barrier_epoch;
barrier_trace_sync (t_entry, t_open, t_closed);
}
void
vlib_worker_thread_barrier_release (vlib_main_t * vm)
{
vlib_global_main_t *vgm = vlib_get_global_main ();
f64 deadline;
f64 now;
f64 minimum_open;
f64 t_entry;
f64 t_closed_total;
f64 t_update_main = 0.0;
int refork_needed = 0;
if (vlib_get_n_threads () < 2)
return;
ASSERT (vlib_get_thread_index () == 0);
now = vlib_time_now (vm);
t_entry = now - vm->barrier_epoch;
if (--vlib_worker_threads[0].recursion_level > 0)
{
barrier_trace_release_rec (t_entry);
return;
}
/* Update (all) node runtimes before releasing the barrier, if needed */
if (vgm->need_vlib_worker_thread_node_runtime_update)
{
/*
* Lock stat segment here, so we's safe when
* rebuilding the stat segment node clones from the
* stat thread...
*/
vlib_stats_segment_lock ();
/* Do stats elements on main thread */
worker_thread_node_runtime_update_internal ();
vgm->need_vlib_worker_thread_node_runtime_update = 0;
/* Do per thread rebuilds in parallel */
refork_needed = 1;
clib_atomic_fetch_add (vlib_worker_threads->node_reforks_required,
(vlib_get_n_threads () - 1));
now = vlib_time_now (vm);
t_update_main = now - vm->barrier_epoch;
}
deadline = now + BARRIER_SYNC_TIMEOUT;
/*
* Note when we let go of the barrier.
* Workers can use this to derive a reasonably accurate
* time offset. See vlib_time_now(...)
*/
vm->time_last_barrier_release = vlib_time_now (vm);
CLIB_MEMORY_STORE_BARRIER ();
*vlib_worker_threads->wait_at_barrier = 0;
while (*vlib_worker_threads->workers_at_barrier > 0)
{
if ((now = vlib_time_now (vm)) > deadline)
{
fformat (stderr, "%s: worker thread deadlock\n", __FUNCTION__);
os_panic ();
}
}
/* Wait for reforks before continuing */
if (refork_needed)
{
now = vlib_time_now (vm);
deadline = now + BARRIER_SYNC_TIMEOUT;
while (*vlib_worker_threads->node_reforks_required > 0)
{
if ((now = vlib_time_now (vm)) > deadline)
{
fformat (stderr, "%s: worker thread refork deadlock\n",
__FUNCTION__);
os_panic ();
}
}
vlib_stats_segment_unlock ();
}
t_closed_total = now - vm->barrier_epoch;
minimum_open = t_closed_total * BARRIER_MINIMUM_OPEN_FACTOR;
if (minimum_open > BARRIER_MINIMUM_OPEN_LIMIT)
{
minimum_open = BARRIER_MINIMUM_OPEN_LIMIT;
}
vm->barrier_no_close_before = now + minimum_open;
/* Record barrier epoch (used to enforce minimum open time) */
vm->barrier_epoch = now;
barrier_trace_release (t_entry, t_closed_total, t_update_main);
if (PREDICT_FALSE (vec_len (vm->barrier_perf_callbacks) != 0))
clib_call_callbacks (vm->barrier_perf_callbacks, vm,
vm->clib_time.last_cpu_time, 1 /* leave */ );
}
static void
vlib_worker_sync_rpc (void *args)
{
ASSERT (vlib_thread_is_main_w_barrier ());
vlib_worker_threads->wait_before_barrier = 0;
}
void
vlib_workers_sync (void)
{
if (PREDICT_FALSE (!vlib_num_workers ()))
return;
if (!(*vlib_worker_threads->wait_at_barrier) &&
!clib_atomic_swap_rel_n (&vlib_worker_threads->wait_before_barrier, 1))
{
u32 thread_index = vlib_get_thread_index ();
vlib_rpc_call_main_thread (vlib_worker_sync_rpc, (u8 *) &thread_index,
sizeof (thread_index));
}
/* Wait until main thread asks for barrier */
while (!(*vlib_worker_threads->wait_at_barrier))
;
/* Stop before barrier and make sure all threads are either
* at worker barrier or the barrier before it */
clib_atomic_fetch_add (&vlib_worker_threads->workers_before_barrier, 1);
while (vlib_num_workers () > (*vlib_worker_threads->workers_at_barrier +
vlib_worker_threads->workers_before_barrier))
;
}
void
vlib_workers_continue (void)
{
if (PREDICT_FALSE (!vlib_num_workers ()))
return;
clib_atomic_fetch_add (&vlib_worker_threads->done_work_before_barrier, 1);
/* Wait until all workers are done with work before barrier */
while (vlib_worker_threads->done_work_before_barrier <
vlib_worker_threads->workers_before_barrier)
;
clib_atomic_fetch_add (&vlib_worker_threads->done_work_before_barrier, -1);
clib_atomic_fetch_add (&vlib_worker_threads->workers_before_barrier, -1);
}
/**
* Wait until each of the workers has been once around the track
*/
void
vlib_worker_wait_one_loop (void)
{
vlib_global_main_t *vgm = vlib_get_global_main ();
ASSERT (vlib_get_thread_index () == 0);
if (vlib_get_n_threads () < 2)
return;
if (vlib_worker_thread_barrier_held ())
return;
u32 *counts = 0;
u32 ii;
vec_validate (counts, vlib_get_n_threads () - 1);
/* record the current loop counts */
vec_foreach_index (ii, vgm->vlib_mains)
counts[ii] = vgm->vlib_mains[ii]->main_loop_count;
/* spin until each changes, apart from the main thread, or we'd be
* a while */
for (ii = 1; ii < vec_len (counts); ii++)
{
while (counts[ii] == vgm->vlib_mains[ii]->main_loop_count)
CLIB_PAUSE ();
}
vec_free (counts);
return;
}
void
vlib_worker_thread_fn (void *arg)
{
vlib_global_main_t *vgm = vlib_get_global_main ();
vlib_worker_thread_t *w = (vlib_worker_thread_t *) arg;
vlib_main_t *vm = vlib_get_main ();
clib_error_t *e;
ASSERT (vm->thread_index == vlib_get_thread_index ());
vlib_worker_thread_init (w);
clib_time_init (&vm->clib_time);
clib_mem_set_heap (w->thread_mheap);
vm->worker_init_functions_called = hash_create (0, 0);
e = vlib_call_init_exit_functions_no_sort (
vm, &vgm->worker_init_function_registrations, 1 /* call_once */,
0 /* is_global */);
if (e)
clib_error_report (e);
vlib_worker_loop (vm);
}
/* *INDENT-OFF* */
VLIB_REGISTER_THREAD (worker_thread_reg, static) = {
.name = "workers",
.short_name = "wk",
.function = vlib_worker_thread_fn,
};
/* *INDENT-ON* */
extern clib_march_fn_registration
*vlib_frame_queue_dequeue_with_aux_fn_march_fn_registrations;
extern clib_march_fn_registration
*vlib_frame_queue_dequeue_fn_march_fn_registrations;
u32
vlib_frame_queue_main_init (u32 node_index, u32 frame_queue_nelts)
{
vlib_thread_main_t *tm = vlib_get_thread_main ();
vlib_main_t *vm = vlib_get_main ();
vlib_frame_queue_main_t *fqm;
vlib_frame_queue_t *fq;
vlib_node_t *node;
int i;
u32 num_threads;
if (frame_queue_nelts == 0)
frame_queue_nelts = FRAME_QUEUE_MAX_NELTS;
num_threads = 1 /* main thread */ + tm->n_threads;
ASSERT (frame_queue_nelts >= 8 + num_threads);
vec_add2 (tm->frame_queue_mains, fqm, 1);
node = vlib_get_node (vm, fqm->node_index);
ASSERT (node);
if (node->aux_offset)
{
fqm->frame_queue_dequeue_fn =
CLIB_MARCH_FN_VOID_POINTER (vlib_frame_queue_dequeue_with_aux_fn);
}
else
{
fqm->frame_queue_dequeue_fn =
CLIB_MARCH_FN_VOID_POINTER (vlib_frame_queue_dequeue_fn);
}
fqm->node_index = node_index;
fqm->frame_queue_nelts = frame_queue_nelts;
vec_validate (fqm->vlib_frame_queues, tm->n_vlib_mains - 1);
vec_set_len (fqm->vlib_frame_queues, 0);
for (i = 0; i < tm->n_vlib_mains; i++)
{
fq = vlib_frame_queue_alloc (frame_queue_nelts);
vec_add1 (fqm->vlib_frame_queues, fq);
}
return (fqm - tm->frame_queue_mains);
}
void
vlib_process_signal_event_mt_helper (vlib_process_signal_event_mt_args_t *
args)
{
ASSERT (vlib_get_thread_index () == 0);
vlib_process_signal_event (vlib_get_main (), args->node_index,
args->type_opaque, args->data);
}
void *rpc_call_main_thread_cb_fn;
void
vlib_rpc_call_main_thread (void *callback, u8 * args, u32 arg_size)
{
if (rpc_call_main_thread_cb_fn)
{
void (*fp) (void *, u8 *, u32) = rpc_call_main_thread_cb_fn;
(*fp) (callback, args, arg_size);
}
else
clib_warning ("BUG: rpc_call_main_thread_cb_fn NULL!");
}
clib_error_t *
threads_init (vlib_main_t * vm)
{
const vlib_thread_main_t *tm = vlib_get_thread_main ();
if (tm->main_lcore == ~0 && tm->n_vlib_mains > 1)
return clib_error_return (0, "Configuration error, a main core must "
"be specified when using worker threads");
return 0;
}
VLIB_INIT_FUNCTION (threads_init);
static clib_error_t *
show_clock_command_fn (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
{
int verbose = 0;
clib_timebase_t _tb, *tb = &_tb;
(void) unformat (input, "verbose %=", &verbose, 1);
clib_timebase_init (tb, 0 /* GMT */ , CLIB_TIMEBASE_DAYLIGHT_NONE,
&vm->clib_time);
vlib_cli_output (vm, "%U, %U GMT", format_clib_time, &vm->clib_time,
verbose, format_clib_timebase_time,
clib_timebase_now (tb));
vlib_cli_output (vm, "Time last barrier release %.9f",
vm->time_last_barrier_release);
foreach_vlib_main ()
{
vlib_cli_output (vm, "%d: %U", this_vlib_main->thread_index,
format_clib_time, &this_vlib_main->clib_time, verbose);
vlib_cli_output (vm, "Thread %d offset %.9f error %.9f",
this_vlib_main->thread_index,
this_vlib_main->time_offset,
vm->time_last_barrier_release -
this_vlib_main->time_last_barrier_release);
}
return 0;
}
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (f_command, static) =
{
.path = "show clock",
.short_help = "show clock",
.function = show_clock_command_fn,
};
/* *INDENT-ON* */
vlib_thread_main_t *
vlib_get_thread_main_not_inline (void)
{
return vlib_get_thread_main ();
}
/*
* fd.io coding-style-patch-verification: ON
*
* Local Variables:
* eval: (c-set-style "gnu")
* End:
*/
|
4f77f30ca775b4050dc4da07aaee7d5717940b42
|
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
|
/sys/arch/i386/pnpbios/pnpbios.c
|
9d4115a668d7e0e7f434130688a5209cc117f9d6
|
[] |
no_license
|
NetBSD/src
|
1a9cbc22ed778be638b37869ed4fb5c8dd616166
|
23ee83f7c0aea0777bd89d8ebd7f0cde9880d13c
|
refs/heads/trunk
| 2023-08-31T13:24:58.105962
| 2023-08-27T15:50:47
| 2023-08-27T15:50:47
| 88,439,547
| 656
| 348
| null | 2023-07-20T20:07:24
| 2017-04-16T20:03:43
| null |
UTF-8
|
C
| false
| false
| 37,431
|
c
|
pnpbios.c
|
/* $NetBSD: pnpbios.c,v 1.77 2021/08/07 16:18:55 thorpej Exp $ */
/*
* Copyright (c) 2000 Jason R. Thorpe. All rights reserved.
* Copyright (c) 2000 Christian E. Hopps. All rights reserved.
* Copyright (c) 1999
* Matthias Drochner. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* PnP BIOS documentation is available at the following locations.
*
* http://www.microsoft.com/hwdev/download/respec/pnpbios.zip
* http://www.microsoft.com/hwdev/download/respec/biosclar.zip
* http://www.microsoft.com/hwdev/download/resources/specs/devids.txt
*
* PNPBIOSEVENTS is unfinished. After coding what I did I discovered
* I had no platforms to test on so someone else will need to finish
* it. I didn't want to toss the code though
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pnpbios.c,v 1.77 2021/08/07 16:18:55 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/malloc.h>
#include <sys/kernel.h>
#include <sys/kthread.h>
#include <uvm/uvm_extern.h>
#include <machine/isa_machdep.h>
#include <machine/segments.h>
#include <dev/isa/isareg.h>
#include <dev/isapnp/isapnpreg.h>
#include <arch/i386/pnpbios/pnpbiosvar.h>
#include <arch/i386/pnpbios/pnpbiosreg.h>
#include "opt_pnpbios.h"
#include "locators.h"
#ifdef PNPBIOSVERBOSE
int pnpbiosverbose = 1;
#else
int pnpbiosverbose = 0;
#endif
#ifdef PNPBIOSDEBUG
#ifdef PNPBIOSDEBUG_VALUE
int pnpbiosdebug = PNPBIOSDEBUG_VALUE;
#else
int pnpbiosdebug = 1;
#endif
#define DPRINTF(x) if (pnpbiosdebug) aprint_normal x
#else
#define DPRINTF(x)
#endif
#ifdef PNPBIOSEVENTSDEBUG
#define EDPRINTF(x) aprint_normal x
#else
#define EDPRINTF(x)
#endif
struct pnpbios_softc {
device_t sc_dev;
isa_chipset_tag_t sc_ic;
lwp_t *sc_evthread;
int sc_version;
int sc_control;
#ifdef PNPBIOSEVENTS
uint8_t * sc_evaddr;
int sc_threadrun;
int sc_docked;
#endif
};
#define PNPGET4(p) ((p)[0] + ((p)[1] << 8) + \
((p)[2] << 16) + ((p)[3] << 24))
/* bios calls */
#if 0
/* XXX these are not called */
static int pnpbios_getapmtable(uint8_t *, size_t *);
static int pnpbios_setnode(int, int,
const uint8_t *, size_t);
#endif
static int pnpbios_getnode(int, int *,
uint8_t *, size_t);
static int pnpbios_getnumnodes(int *, size_t *);
#ifdef PNPBIOSEVENTS
static int pnpbios_getdockinfo(struct pnpdockinfo *);
static int pnpbios_getevent(uint16_t *);
static void pnpbios_event_thread(void *);
static int pnpbios_sendmessage(int);
#endif
/* configuration stuff */
static void * pnpbios_mapit(paddr_t, u_long, vm_prot_t);
static void * pnpbios_find(void);
static int pnpbios_match(device_t, cfdata_t, void *);
static void pnpbios_attach(device_t, device_t, void *);
static void pnpbios_printres(struct pnpresources *);
static int pnpbios_print(void *aux, const char *);
static void pnpbios_id_to_string(uint32_t, char *);
static int pnpbios_attachnode(struct pnpbios_softc *,
int, const uint8_t *,
size_t, int);
static int pnp_scan(const uint8_t **, size_t,
struct pnpresources *, int);
extern int pnpbioscall(int);
static void pnpbios_enumerate(struct pnpbios_softc *);
#ifdef PNPBIOSEVENTS
static int pnpbios_update_dock_status(struct pnpbios_softc *);
#endif
/* scanning functions */
static int pnp_compatid(struct pnpresources *, const void *, size_t);
static int pnp_newirq(struct pnpresources *, const void *, size_t);
static int pnp_newdma(struct pnpresources *, const void *, size_t);
static int pnp_newioport(struct pnpresources *, const void *, size_t);
static int pnp_newfixedioport(struct pnpresources *, const void *, size_t);
#ifdef PNPBIOSDEBUG
static int pnp_debugdump(struct pnpresources *, const void *, size_t);
#endif
/*
* small resource types (beginning with 1)
*/
static const struct{
int (*handler)(struct pnpresources *, const void *, size_t);
int minlen, maxlen;
} smallrescs[] = {
{0, 2, 2}, /* PnP version number */
{0, 5, 6}, /* logical device id */
{pnp_compatid, 4, 4}, /* compatible device id */
{pnp_newirq, 2, 3}, /* irq descriptor */
{pnp_newdma, 2, 2}, /* DMA descriptor */
{0, 0, 1}, /* start dep */
{0, 0, 0}, /* end dep */
{pnp_newioport, 7, 7}, /* io descriptor */
{pnp_newfixedioport, 3, 3}, /* fixed io descriptor */
{0, -1, -1}, /* reserved */
{0, -1, -1},
{0, -1, -1},
{0, -1, -1},
{0, 1, 7}, /* vendor defined */
{0, 1, 1} /* end */
};
CFATTACH_DECL_NEW(pnpbios, sizeof(struct pnpbios_softc),
pnpbios_match, pnpbios_attach, NULL, NULL);
/*
* Private stack and return value buffer. Spec (1.0a, ch. 4.3) says that
* 1024 bytes must be available to the BIOS function.
*/
#define PNPBIOS_BUFSIZE 4096
int pnpbios_enabled = 1;
size_t pnpbios_entry;
char *pnpbios_scratchbuf;
/*
* There can be only one of these, and the i386 ISA code needs to
* reference this.
*/
struct pnpbios_softc *pnpbios_softc;
#define PNPBIOS_SIGNATURE ('$' | ('P' << 8) | ('n' << 16) | ('P' << 24))
static void *
pnpbios_find(void)
{
char *p, *c;
uint8_t cksum;
size_t structlen;
for (p = (char *)ISA_HOLE_VADDR(0xf0000);
p <= (char *)ISA_HOLE_VADDR(0xffff0);
p += 16) {
if (*(int *)p != PNPBIOS_SIGNATURE)
continue;
structlen = *(uint8_t *)(p + 5);
if ((structlen < 0x21) ||
((p + structlen - 1) > (char *)ISA_HOLE_VADDR(0xfffff)))
continue;
cksum = 0;
for (c = p; c < p + structlen; c++)
cksum += *(uint8_t *)c;
if (cksum != 0)
continue;
if (*(char *)(p + 4) != 0x10) {
printf("unknown version %x\n", *(char *)(p + 4));
continue;
}
return (p);
}
return (0);
}
int
pnpbios_probe(void)
{
return (pnpbios_find() != 0);
}
static int
pnpbios_match(device_t parent, cfdata_t match, void *aux)
{
/* There can be only one! */
if (pnpbios_softc != NULL)
return (0);
return (pnpbios_enabled);
}
static void *
pnpbios_mapit(paddr_t addr, u_long len, vm_prot_t prot)
{
paddr_t startpa, pa, endpa;
vaddr_t startva, va;
pa = startpa = x86_trunc_page(addr);
endpa = x86_round_page(addr + len);
va = startva = uvm_km_alloc(kernel_map, endpa - startpa, 0,
UVM_KMF_VAONLY);
if (!startva)
return (0);
for (; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE)
pmap_kenter_pa(va, pa, prot, 0);
pmap_update(pmap_kernel());
return ((void *)(startva + (vaddr_t)(addr - startpa)));
}
static void
pnpbios_attach(device_t parent, device_t self, void *aux)
{
struct pnpbios_softc *sc = device_private(self);
struct pnpbios_attach_args *paa = aux;
char *p;
unsigned int codepbase, datapbase, evaddrp;
void *codeva, *datava;
extern char pnpbiostramp[], epnpbiostramp[];
int res, num, size;
#ifdef PNPBIOSEVENTS
int evtype;
#endif
aprint_naive("\n");
pnpbios_softc = sc;
sc->sc_dev = self;
sc->sc_ic = paa->paa_ic;
p = pnpbios_find();
if (!p)
panic("pnpbios_attach: disappeared");
sc->sc_version = *(uint8_t *)(p + 0x04);
sc->sc_control = *(uint8_t *)(p + 0x06);
evaddrp = *(uint32_t *)(p + 0x09);
codepbase = *(uint32_t *)(p + 0x13);
datapbase = *(uint32_t *)(p + 0x1d);
pnpbios_entry = *(uint16_t *)(p + 0x11);
if (pnpbiosverbose) {
aprint_normal(": code %x, data %x, entry %x, control %x,"
" eventp %x\n%s",
codepbase, datapbase, pnpbios_entry, sc->sc_control,
(unsigned int)evaddrp, device_xname(self));
}
#ifdef PNPBIOSEVENTS
/* if we have an event mechnism queue a thread to deal with them */
evtype = (sc->sc_control & PNP_IC_CONTORL_EVENT_MASK);
if (evtype == PNP_IC_CONTROL_EVENT_POLL) {
sc->sc_evaddr = pnpbios_mapit(evaddrp, PAGE_SIZE,
VM_PROT_READ | VM_PROT_WRITE);
if (!sc->sc_evaddr)
aprint_error_dev(self, "couldn't map event flag 0x%08x\n",
evaddrp);
}
#endif
codeva = pnpbios_mapit(codepbase, 0x10000,
VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE);
datava = pnpbios_mapit(datapbase, 0x10000,
VM_PROT_READ | VM_PROT_WRITE);
if (codeva == 0 || datava == 0) {
aprint_error(": no vm for mapping\n");
return;
}
pnpbios_scratchbuf = malloc(PNPBIOS_BUFSIZE, M_DEVBUF, M_WAITOK);
setsegment(&gdtstore[GPNPBIOSCODE_SEL].sd, codeva, 0xffff,
SDT_MEMERA, SEL_KPL, 0, 0);
setsegment(&gdtstore[GPNPBIOSDATA_SEL].sd, datava, 0xffff,
SDT_MEMRWA, SEL_KPL, 0, 0);
setsegment(&gdtstore[GPNPBIOSSCRATCH_SEL].sd,
pnpbios_scratchbuf, PNPBIOS_BUFSIZE - 1,
SDT_MEMRWA, SEL_KPL, 0, 0);
setsegment(&gdtstore[GPNPBIOSTRAMP_SEL].sd,
pnpbiostramp, epnpbiostramp - pnpbiostramp - 1,
SDT_MEMERA, SEL_KPL, 1, 0);
res = pnpbios_getnumnodes(&num, &size);
if (res) {
aprint_error(": pnpbios_getnumnodes: error %d\n", res);
return;
}
aprint_normal(": nodes %d, max len %d\n", num, size);
#ifdef PNPBIOSEVENTS
EDPRINTF(("%s: event flag vaddr 0x%08x\n", device_xname(self),
(int)sc->sc_evaddr));
/* Set initial dock status. */
sc->sc_docked = -1;
(void) pnpbios_update_dock_status(sc);
#endif
/* Enumerate the device nodes. */
pnpbios_enumerate(sc);
#ifdef PNPBIOSEVENTS
/* if we have an event mechnism queue a thread to deal with them */
/* XXX need to update with irq if we do that */
if (evtype != PNP_IC_CONTROL_EVENT_NONE) {
if (evtype != PNP_IC_CONTROL_EVENT_POLL || sc->sc_evaddr) {
sc->sc_threadrun = 1;
config_pending_incr(sc->sc_dev);
if (kthread_create(PRI_NONE, 0, NULL,
pnpbios_event_thread, sc, &sc->sc_evthread,
"%s", device_xname(self)))
panic("pnpbios: create event thread");
}
}
#endif
}
static void
pnpbios_enumerate(struct pnpbios_softc *sc)
{
int res, num, i, size, idx, dynidx;
struct pnpdevnode *dn;
uint8_t *buf;
res = pnpbios_getnumnodes(&num, &size);
if (res) {
aprint_error_dev(sc->sc_dev, "pnpbios_getnumnodes: error %d\n",
res);
return;
}
buf = malloc(size, M_DEVBUF, M_WAITOK);
/*
* Loop through the list of indices getting data and match/attaching
* each as appropriate.
*
* Unfortunately, some BIOSes seem to have fatal bugs getting the
* dynamic (i.e. currently active) configuration, for instance some
* Sony VAIO laptops, including the PCG-Z505HE. They don't have such a
* problem with that static (i.e. next boot time) configuration,
* however. The workaround is to get the static configuration for all
* indices, and only get dynamic configuration for devices where the
* match is positive.
*
* This seems to work conveniently as the indices that cause
* crashes (and it seems to vary from machine to machine) do not
* seem to be for devices that NetBSD's pnpbios supports.
*/
idx = 0;
for (i = 0; i < num && idx != 0xff; i++) {
DPRINTF(("%s: getting info for index %d\n",
device_xname(sc->sc_dev), idx));
dynidx = idx;
res = pnpbios_getnode(PNP_CF_DEVCONF_STATIC, &idx, buf, size);
if (res) {
aprint_error_dev(sc->sc_dev, "index %d error %d "
"getting static configuration\n", idx, res);
continue;
}
dn = (struct pnpdevnode *)buf;
if (!pnpbios_attachnode(sc, dn->dn_handle, buf, dn->dn_size, 1)) {
DPRINTF(("%s handle %d: no match from static config\n",
device_xname(sc->sc_dev), dn->dn_handle));
continue;
}
res = pnpbios_getnode(PNP_CF_DEVCONF_DYNAMIC, &dynidx, buf, size);
if (res) {
aprint_error_dev(sc->sc_dev, "index %d error %d "
"getting dynamic configuration\n", dynidx, res);
continue;
}
dn = (struct pnpdevnode *)buf;
if (!pnpbios_attachnode(sc, dn->dn_handle, buf, dn->dn_size, 0)) {
DPRINTF(("%s handle %d: no match from dynamic config\n",
device_xname(sc->sc_dev), dn->dn_handle));
continue;
}
}
if (i != num)
aprint_error_dev(sc->sc_dev, "got only %d nodes\n", i);
if (idx != 0xff)
aprint_error_dev(sc->sc_dev, "last index %d\n", idx);
free(buf, M_DEVBUF);
}
#ifdef PNPBIOSEVENTS
static int
pnpbios_update_dock_status(struct pnpbios_softc *sc)
{
struct pnpdockinfo di;
const char *when, *style;
int res, odocked = sc->sc_docked;
res = pnpbios_getdockinfo(&di);
if (res == PNP_RC_SYSTEM_NOT_DOCKED) {
sc->sc_docked = 0;
if (odocked != sc->sc_docked)
printf("%s: not docked\n", device_xname(sc->sc_dev));
} else if (res) {
EDPRINTF(("%s: dockinfo failed 0x%02x\n",
device_xname(sc->sc_dev), res));
} else {
sc->sc_docked = 1;
if (odocked != sc->sc_docked) {
char idstr[8];
pnpbios_id_to_string(di.di_id, idstr);
printf("%s: dock id %s", device_xname(sc->sc_dev), idstr);
if (pnpbiosverbose) {
if (di.di_serial != -1)
printf(", serial number %d",
di.di_serial);
}
switch (di.di_cap & PNP_DI_DOCK_STYLE_MASK) {
case PNP_DI_DOCK_STYLE_SUPRISE:
style = "surprise";
break;
case PNP_DI_DOCK_STYLE_VCR:
style = "controlled";
break;
default:
style = "<style unknown>";
break;
}
switch (di.di_cap & PNP_DI_DOCK_WHEN_MASK) {
case PNP_DI_DOCK_WHEN_NO_POWER:
when = "cold";
break;
case PNP_DI_DOCK_WHEN_SUSPENDED:
when = "warm";
break;
case PNP_DI_DOCK_WHEN_RUNNING:
when = "hot";
break;
case PNP_DI_DOCK_WHEN_RESERVED:
when = "<reserved>";
break;
default:
when = "<dock type unknown>";
break;
}
printf(", %s %s docking\n", style, when);
}
}
return (odocked);
}
#endif
static int
pnpbios_getnumnodes(int *nump, size_t *sizep)
{
int res;
short *help = (short *)(pnpbios_scratchbuf + PNPBIOS_BUFSIZE);
*--help = GSEL(GPNPBIOSDATA_SEL, SEL_KPL);
*--help = GSEL(GPNPBIOSSCRATCH_SEL, SEL_KPL);
*--help = 2; /* buffer offset for node size */
*--help = GSEL(GPNPBIOSSCRATCH_SEL, SEL_KPL);
*--help = 0; /* buffer offset for numnodes */
*--help = PNP_FC_GET_NUM_NODES;
res = pnpbioscall(((char *)help) - pnpbios_scratchbuf);
if (res)
return (res);
*nump = *(short *)(pnpbios_scratchbuf + 0);
*sizep = *(short *)(pnpbios_scratchbuf + 2);
return (0);
}
static int
pnpbios_getnode(int flags, int *idxp, uint8_t *buf, size_t len)
{
int res;
short *help = (short *)(pnpbios_scratchbuf + PNPBIOS_BUFSIZE);
*--help = GSEL(GPNPBIOSDATA_SEL, SEL_KPL);
*--help = flags;
*--help = GSEL(GPNPBIOSSCRATCH_SEL, SEL_KPL);
*--help = 2; /* buffer offset for node data */
*--help = GSEL(GPNPBIOSSCRATCH_SEL, SEL_KPL);
*--help = 0; /* buffer offset for index in/out */
*--help = PNP_FC_GET_DEVICE_NODE;
*(short *)(pnpbios_scratchbuf + 0) = *idxp;
res = pnpbioscall(((char *)help) - pnpbios_scratchbuf);
if (res)
return (res);
*idxp = *(short *)(pnpbios_scratchbuf + 0);
memcpy(buf, pnpbios_scratchbuf + 2, len);
return (0);
}
#if 0
/* XXX - pnpbios_setnode() is never called. */
static int
pnpbios_setnode(int flags, int idx, const uint8_t *buf, size_t len)
{
short *help = (short *)(pnpbios_scratchbuf + PNPBIOS_BUFSIZE);
*--help = GSEL(GPNPBIOSDATA_SEL, SEL_KPL);
*--help = flags;
*--help = GSEL(GPNPBIOSSCRATCH_SEL, SEL_KPL);
*--help = 0; /* buffer offset for node data */
*--help = idx;
*--help = PNP_FC_SET_DEVICE_NODE;
memcpy(pnpbios_scratchbuf, buf, len);
return (pnpbioscall(((void *)help) - pnpbios_scratchbuf));
}
#endif /* 0 */
#ifdef PNPBIOSEVENTS
static int
pnpbios_getevent(uint16_t *event)
{
int res;
short *help = (short *)(pnpbios_scratchbuf + PNPBIOS_BUFSIZE);
*--help = GSEL(GPNPBIOSDATA_SEL, SEL_KPL);
*--help = GSEL(GPNPBIOSSCRATCH_SEL, SEL_KPL);
*--help = 0; /* buffer offset for message data */
*--help = PNP_FC_GET_EVENT;
res = pnpbioscall(((void *)help) - pnpbios_scratchbuf);
*event = pnpbios_scratchbuf[0] + (pnpbios_scratchbuf[1] << 8);
return (res);
}
static int
pnpbios_sendmessage(int msg)
{
short *help = (short *)(pnpbios_scratchbuf + PNPBIOS_BUFSIZE);
*--help = GSEL(GPNPBIOSDATA_SEL, SEL_KPL);
*--help = msg;
*--help = PNP_FC_SEND_MESSAGE;
return (pnpbioscall(((void *)help) - pnpbios_scratchbuf));
}
static int
pnpbios_getdockinfo(struct pnpdockinfo *di)
{
int res;
short *help = (short *)(pnpbios_scratchbuf + PNPBIOS_BUFSIZE);
*--help = GSEL(GPNPBIOSDATA_SEL, SEL_KPL);
*--help = GSEL(GPNPBIOSSCRATCH_SEL, SEL_KPL);
*--help = 0; /* buffer offset for dock info */
*--help = PNP_FC_GET_DOCK_INFO;
res = pnpbioscall(((void *)help) - pnpbios_scratchbuf);
memcpy(di, pnpbios_scratchbuf, sizeof(*di));
return (res);
}
#endif /* PNPBIOSEVENTS */
#if 0
/* XXX - pnpbios_getapmtable() is not called. */
/* XXX we don't support more than PNPBIOS_BUFSIZE - (stacklen + 2) */
static int
pnpbios_getapmtable(uint8_t *tab, size_t *len)
{
short *help = (short *)(pnpbios_scratchbuf + PNPBIOS_BUFSIZE);
size_t origlen, stacklen;
int res;
*--help = GSEL(GPNPBIOSDATA_SEL, SEL_KPL);
*--help = GSEL(GPNPBIOSSCRATCH_SEL, SEL_KPL);
*--help = 2; /* buffer offset for table */
*--help = GSEL(GPNPBIOSSCRATCH_SEL, SEL_KPL);
*--help = 0; /* buffer offset for length */
*--help = PNP_FC_GET_APM_TABLE;
origlen = *len;
stacklen = (void *)help - pnpbios_scratchbuf;
if (origlen > PNPBIOS_BUFSIZE - stacklen - 2)
origlen = PNPBIOS_BUFSIZE - stacklen - 2;
*(uint16_t *)(pnpbios_scratchbuf) = origlen;
res = pnpbioscall(((void *)help) - pnpbios_scratchbuf);
*len = *(uint16_t *)pnpbios_scratchbuf;
if (res)
return (res);
if (origlen && *len > origlen) {
printf("pnpbios: returned apm table exceed requested size\n");
return (PNP_RC_BUFFER_TOO_SMALL);
}
memcpy(tab, pnpbios_scratchbuf + 2, *len);
return (0);
}
#endif
static void
pnpbios_id_to_string(uint32_t pnpid, char *s)
{
uint8_t *id;
id = (uint8_t *)&pnpid;
*s++ = 'A' + (id[0] >> 2) - 1;
*s++ = 'A' + ((id[0] & 3) << 3) + (id[1] >> 5) - 1;
*s++ = 'A' + (id[1] & 0x1f) - 1;
*s++ = HEXDIGITS[id[2] >> 4];
*s++ = HEXDIGITS[id[2] & 0x0f];
*s++ = HEXDIGITS[id[3] >> 4];
*s++ = HEXDIGITS[id[3] & 0x0f];
*s = '\0';
}
static void
pnpbios_printres(struct pnpresources *r)
{
struct pnp_mem *mem;
struct pnp_io *io;
struct pnp_irq *irq;
struct pnp_dma *dma;
int p = 0;
mem = SIMPLEQ_FIRST(&r->mem);
if (mem) {
aprint_normal("mem");
do {
aprint_normal(" %x", mem->minbase);
if (mem->len > 1)
aprint_normal("-%x",
mem->minbase + mem->len - 1);
} while ((mem = SIMPLEQ_NEXT(mem, next)));
p++;
}
io = SIMPLEQ_FIRST(&r->io);
if (io) {
if (p++)
aprint_normal(", ");
aprint_normal("io");
do {
aprint_normal(" %x", io->minbase);
if (io->len > 1)
aprint_normal("-%x",
io->minbase + io->len - 1);
} while ((io = SIMPLEQ_NEXT(io, next)));
}
irq = SIMPLEQ_FIRST(&r->irq);
if (irq) {
if (p++)
aprint_normal(", ");
aprint_normal("irq");
do {
aprint_normal(" %d", ffs(irq->mask) - 1);
} while ((irq = SIMPLEQ_NEXT(irq, next)));
}
dma = SIMPLEQ_FIRST(&r->dma);
if (dma) {
if (p)
aprint_normal(", ");
aprint_normal("DMA");
do {
aprint_normal(" %d", ffs(dma->mask) - 1);
} while ((dma = SIMPLEQ_NEXT(dma, next)));
}
}
static int
pnpbios_print(void *aux, const char *pnp)
{
struct pnpbiosdev_attach_args *aa = aux;
if (pnp)
return (QUIET);
aprint_normal(" index %d (%s", aa->idx, aa->primid);
if (aa->resc->longname)
aprint_normal(", %s", aa->resc->longname);
if (aa->idstr != aa->primid)
aprint_normal(", attached as %s", aa->idstr);
aprint_normal(")");
return (0);
}
void
pnpbios_print_devres(device_t dev, struct pnpbiosdev_attach_args *aa)
{
aprint_normal_dev(dev, "");
pnpbios_printres(aa->resc);
aprint_normal("\n");
}
static int
pnpbios_attachchild(struct pnpbios_softc *sc,
struct pnpbiosdev_attach_args *aa, int matchonly)
{
int locs[PNPBIOSCF_NLOCS];
locs[PNPBIOSCF_INDEX] = aa->idx;
if (matchonly)
return (config_search(sc->sc_dev, aa,
CFARGS(.submatch = config_stdsubmatch,
.locators = locs)) != NULL);
else
return (config_found(sc->sc_dev, aa, pnpbios_print,
CFARGS(.submatch = config_stdsubmatch,
.locators = locs)) != NULL);
}
static int
pnpbios_attachnode(struct pnpbios_softc *sc, int idx, const uint8_t *buf,
size_t len, int matchonly)
{
const struct pnpdevnode *dn;
const uint8_t *p;
char idstr[8];
struct pnpresources r, s;
struct pnpbiosdev_attach_args aa;
struct pnp_compatid *compatid;
int res, i;
dn = (const struct pnpdevnode *)buf;
pnpbios_id_to_string(dn->dn_product, idstr);
p = (const u_char *)(dn + 1);
DPRINTF(("%s (%s): type 0x%02x subtype "
"0x%02x dpi 0x%02x attr 0x%04x:\n",
idstr, matchonly ? "static" : "dynamic", dn->dn_type,
dn->dn_subtype, dn->dn_dpi, dn->dn_attr));
DPRINTF(("%s: allocated config scan:\n", idstr));
res = pnp_scan(&p, len - 12, &r, 0);
if (res < 0) {
aprint_error("error in config data\n");
goto dump;
}
/*
* the following is consistency check only for now
*/
DPRINTF(("\tpossible config scan:\n"));
res = pnp_scan(&p, len - (p - buf), &s, 0);
if (res < 0) {
aprint_error("error in possible configuration\n");
goto dump;
}
DPRINTF(("\tcompat id scan:\n"));
res = pnp_scan(&p, len - (p - buf), &s, 0);
if (res < 0) {
aprint_error("error in compatible ID\n");
goto dump;
}
if (p != buf + len) {
aprint_error_dev(sc->sc_dev, "length mismatch in node %d:"
" used %d of %d Bytes\n",
idx, p - buf, len);
if (p > buf + len) {
/* XXX shouldn't happen - pnp_scan should catch it */
goto dump;
}
/* Crappy BIOS: Buffer is not fully used. Be generous. */
}
if (r.nummem + r.numio + r.numirq + r.numdma == 0) {
if (pnpbiosverbose) {
aprint_normal("%s", idstr);
if (r.longname)
aprint_normal(", %s", r.longname);
compatid = s.compatids;
while (compatid) {
aprint_normal(", %s", compatid->idstr);
compatid = compatid->next;
}
aprint_normal(" at %s index %d disabled\n",
device_xname(sc->sc_dev), idx);
}
return 0;
}
aa.pbt = 0; /* XXX placeholder */
aa.idx = idx;
aa.resc = &r;
aa.ic = sc->sc_ic;
aa.primid = idstr;
/* first try the specific device ID */
aa.idstr = idstr;
if (pnpbios_attachchild(sc, &aa, matchonly))
return -1;
/* if no driver was found, try compatible IDs */
compatid = s.compatids;
while (compatid) {
aa.idstr = compatid->idstr;
if (pnpbios_attachchild(sc, &aa, matchonly))
return -1;
compatid = compatid->next;
}
if (pnpbiosverbose) {
aprint_normal("%s", idstr);
if (r.longname)
aprint_normal(", %s", r.longname);
compatid = s.compatids;
while (compatid) {
aprint_normal(", %s", compatid->idstr);
compatid = compatid->next;
}
aprint_normal(" (");
pnpbios_printres(&r);
aprint_normal(") at %s index %d ignored\n",
device_xname(sc->sc_dev), idx);
}
return 0;
/* XXX should free resource lists */
dump:
i = 0;
#ifdef PNPBIOSDEBUG
/* print some useful info */
if (len >= sizeof(*dn)) {
aprint_normal("%s idx %d size %d type 0x%x:0x%x:0x%x attr 0x%x\n",
idstr, dn->dn_handle, dn->dn_size, dn->dn_type,
dn->dn_subtype, dn->dn_dpi, dn->dn_attr);
i += sizeof(*dn);
}
#endif
for (; i < len; i++)
aprint_normal(" %02x", buf[i]);
aprint_normal("\n");
return 0;
}
static int
pnp_scan(const uint8_t **bufp, size_t maxlen,
struct pnpresources *r, int in_depends)
{
const void *start;
const uint8_t *p;
struct pnp_mem *mem;
int tag, type, len;
char *idstr;
int i;
p = *bufp;
memset(r, 0, sizeof(*r));
SIMPLEQ_INIT(&r->mem);
SIMPLEQ_INIT(&r->io);
SIMPLEQ_INIT(&r->irq);
SIMPLEQ_INIT(&r->dma);
for (;;) {
if (p >= *bufp + maxlen) {
aprint_normal("pnp_scanresources: end of buffer\n");
return (-1);
}
start = p;
tag = *p;
if (tag & ISAPNP_LARGE_TAG) {
len = *(const uint16_t *)(p + 1);
p += sizeof(struct pnplargeres) + len;
switch (tag) {
case ISAPNP_TAG_MEM_RANGE_DESC: {
const struct pnpmem16rangeres *res = start;
if (len != sizeof(*res) - 3) {
aprint_normal("pnp_scan: bad mem desc\n");
return (-1);
}
mem = malloc(sizeof(struct pnp_mem),
M_DEVBUF, M_WAITOK);
mem->flags = res->r_flags;
mem->minbase = res->r_minbase << 8;
mem->maxbase = res->r_maxbase << 8;
mem->align = res->r_align;
if (mem->align == 0)
mem->align = 0x10000;
mem->len = res->r_len << 8;
DPRINTF(("\ttag memrange "));
goto gotmem;
}
case ISAPNP_TAG_ANSI_IDENT_STRING: {
const struct pnpansiidentres *res = start;
if (in_depends)
aprint_normal("ID in dep?\n");
idstr = malloc(len + 1, M_DEVBUF, M_WAITOK);
for (i = 0; i < len; i++)
idstr[i] = res->r_id[i];
idstr[len] = '\0';
DPRINTF(("\ttag ansiident %s\n", idstr));
if (idstr[0] == '\0') {
/* disabled device */
free(idstr, M_DEVBUF);
break;
}
r->longname = idstr;
break;
}
case ISAPNP_TAG_MEM32_RANGE_DESC: {
const struct pnpmem32rangeres *res = start;
if (len != sizeof(*res) - 3) {
aprint_normal("pnp_scan: bad mem32 desc\n");
return (-1);
}
mem = malloc(sizeof(struct pnp_mem),
M_DEVBUF, M_WAITOK);
mem->flags = res->r_flags;
mem->minbase = res->r_minbase;
mem->maxbase = res->r_maxbase;
mem->align = res->r_align;
mem->len = res->r_len;
DPRINTF(("\ttag mem32range "));
goto gotmem;
}
case ISAPNP_TAG_FIXED_MEM32_RANGE_DESC: {
const struct pnpfixedmem32rangeres *res = start;
if (len != sizeof(*res) - 3) {
aprint_normal("pnp_scan: bad mem32 desc\n");
return (-1);
}
mem = malloc(sizeof(struct pnp_mem),
M_DEVBUF, M_WAITOK);
mem->flags = res->r_flags;
mem->minbase = res->r_base;
mem->maxbase = mem->minbase;
mem->align = 0;
mem->len = res->r_len;
DPRINTF(("\ttag fixedmem32range "));
gotmem:
if (mem->len == 0) { /* disabled */
DPRINTF(("zeroed\n"));
free(mem, M_DEVBUF);
break;
}
SIMPLEQ_INSERT_TAIL(&r->mem, mem, next);
r->nummem++;
DPRINTF(("flags %02x min %08x max %08x "
"align %08x len %08x\n", mem->flags,
mem->minbase, mem->maxbase, mem->align,
mem->len));
break;
}
case ISAPNP_TAG_UNICODE_IDENT_STRING:
case ISAPNP_TAG_VENDOR_DEFINED:
default:
#ifdef PNPBIOSDEBUG
pnp_debugdump(r, start, len);
#endif
break;
}
} else {
type = (tag >> 3) & 0x0f;
len = tag & 0x07;
p += 1 + len;
if (type == 0 ||
len < smallrescs[type - 1].minlen ||
len > smallrescs[type - 1].maxlen) {
aprint_normal("pnp_scan: bad small resource\n");
return (-1);
}
if (type == ISAPNP_TAG_END) {
#ifdef PNPBIOSDEBUG
const struct pnpendres *res = start;
#endif
if (in_depends) {
/*
* this seems to occur and is
* an optimization to not require
* the end dep in a depend
* that ends the section
*/
p -= 1 + len;
}
DPRINTF(("\ttag end cksum %02x\n",
res->r_cksum));
break;
}
if (type == ISAPNP_TAG_DEP_START) {
#ifdef PNPBIOSDEBUG
const struct pnpdepstartres *res = start;
#endif
struct pnpresources *new, *last;
int rv;
DPRINTF(("\ttag startdep flags %02x\n",
len ? res->r_pri : ISAPNP_DEP_ACCEPTABLE));
if (r->dependent_link) {
aprint_normal("second dep?\n");
return (-1);
}
/* XXX not sure about this */
if (in_depends) {
*bufp = p;
return (1);
}
last = r;
do {
new = malloc(sizeof(*new),
M_DEVBUF, M_WAITOK);
rv = pnp_scan(&p, maxlen - (p - *bufp),
new, 1);
if (rv < 0) {
aprint_normal("error in"
" dependent function\n");
free(new, M_DEVBUF);
return (-1);
}
last->dependent_link = new;
last = new;
} while (rv > 0);
continue;
}
if (type == ISAPNP_TAG_DEP_END) {
DPRINTF(("\ttag enddep\n"));
if (!in_depends) {
aprint_normal("tag %d end dep?\n", tag);
return (-1);
}
break;
}
if (!smallrescs[type - 1].handler) {
#ifdef PNPBIOSDEBUG
pnp_debugdump(r, start, len);
#endif
} else if (
(*smallrescs[type - 1].handler)(r, start, len))
return (-1);
}
}
*bufp = p;
return (0);
}
static int
pnp_newirq(struct pnpresources *r, const void *vres, size_t len)
{
const struct pnpirqres *res;
struct pnp_irq *irq;
res = vres;
if (res->r_mask == 0) { /* disabled */
DPRINTF(("\ttag irq zeroed\n"));
return (0);
}
irq = malloc(sizeof(struct pnp_irq), M_DEVBUF, M_WAITOK);
irq->mask = res->r_mask;
if (len > 2)
irq->flags = res->r_info;
else
irq->flags = 0x01;
SIMPLEQ_INSERT_TAIL(&r->irq, irq, next);
r->numirq++;
DPRINTF(("\ttag irq flags %02x mask %04x\n", irq->flags,irq->mask));
return (0);
}
static int
pnp_newdma(struct pnpresources *r, const void *vres, size_t len)
{
const struct pnpdmares *res;
struct pnp_dma *dma;
res = vres;
if (res->r_mask == 0) { /* disabled */
DPRINTF(("\ttag DMA zeroed\n"));
return (0);
}
dma = malloc(sizeof(struct pnp_dma), M_DEVBUF, M_WAITOK);
dma->mask = res->r_mask;
dma->flags = res->r_flags;
SIMPLEQ_INSERT_TAIL(&r->dma, dma, next);
r->numdma++;
DPRINTF(("\ttag DMA flags %02x mask %02x\n", dma->flags,dma->mask));
return (0);
}
static int
pnp_newioport(struct pnpresources *r, const void *vres, size_t len)
{
const struct pnpportres *res;
struct pnp_io *io;
res = vres;
if (res->r_len == 0) { /* disabled */
DPRINTF(("\ttag io zeroed\n"));
return (0);
}
io = malloc(sizeof(struct pnp_io), M_DEVBUF, M_WAITOK);
io->flags = res->r_flags;
io->minbase = res->r_minbase;
io->maxbase = res->r_maxbase;
io->align = res->r_align;
io->len = res->r_len;
SIMPLEQ_INSERT_TAIL(&r->io, io, next);
r->numio++;
DPRINTF(("\ttag io flags %02x min %04x max %04x align "
"0x%02x len 0x%02x\n", io->flags, io->minbase, io->maxbase,
io->align, io->len));
return (0);
}
static int
pnp_newfixedioport(struct pnpresources *r, const void *vres,
size_t len)
{
const struct pnpfixedportres *res;
struct pnp_io *io;
res = vres;
if (res->r_len == 0) { /* disabled */
DPRINTF(("\ttag fixedio zeroed\n"));
return (0);
}
io = malloc(sizeof(struct pnp_io), M_DEVBUF, M_WAITOK);
io->flags = 1; /* 10 bit decoding */
io->minbase = io->maxbase = res->r_base;
io->align = 1;
io->len = res->r_len;
SIMPLEQ_INSERT_TAIL(&r->io, io, next);
r->numio++;
DPRINTF(("\ttag fixedio flags %02x base %04x align %02x len %02x\n",
io->flags, io->minbase, io->align, io->len));
return (0);
}
static int
pnp_compatid(struct pnpresources *r, const void *vres, size_t len)
{
const struct pnpcompatres *res;
struct pnp_compatid *id;
res = vres;
id = malloc(sizeof(*id), M_DEVBUF, M_WAITOK);
pnpbios_id_to_string(res->r_id, id->idstr);
id->next = r->compatids;
r->compatids = id;
DPRINTF(("\ttag compatid %s\n", id->idstr));
return (0);
}
#ifdef PNPBIOSDEBUG
static int
pnp_debugdump(struct pnpresources *r, const void *vres, size_t len)
{
const uint8_t *res = vres;
int type, i;
if (res[0] & ISAPNP_LARGE_TAG) {
type = res[0] & 0x7f;
aprint_normal("\tTAG %02x len %04x %s",
type, len, len ? "data" : "");
i = 3;
} else {
type = (res[0] >> 3) & 0x0f;
aprint_normal("\tTAG %02x len %02x %s",
type, len, len ? "data" : "");
i = 1;
}
for (; i < len; i++)
aprint_normal(" %02x", res[i]);
aprint_normal("\n");
return (0);
}
#endif
int
pnpbios_io_map(pnpbios_tag_t pbt, struct pnpresources *resc,
int idx, bus_space_tag_t *tagp, bus_space_handle_t *hdlp)
{
struct pnp_io *io;
if (idx >= resc->numio)
return (EINVAL);
io = SIMPLEQ_FIRST(&resc->io);
while (idx--)
io = SIMPLEQ_NEXT(io, next);
*tagp = x86_bus_space_io;
return (bus_space_map(x86_bus_space_io, io->minbase, io->len,
0, hdlp));
}
void
pnpbios_io_unmap(pnpbios_tag_t pbt, struct pnpresources *resc,
int idx, bus_space_tag_t tag, bus_space_handle_t hdl)
{
struct pnp_io *io;
if (idx >= resc->numio)
return;
io = SIMPLEQ_FIRST(&resc->io);
while (idx--)
io = SIMPLEQ_NEXT(io, next);
bus_space_unmap(tag, hdl, io->len);
}
int
pnpbios_getiobase(pnpbios_tag_t pbt, struct pnpresources *resc,
int idx, bus_space_tag_t *tagp, int *basep)
{
struct pnp_io *io;
if (idx >= resc->numio)
return (EINVAL);
io = SIMPLEQ_FIRST(&resc->io);
while (idx--)
io = SIMPLEQ_NEXT(io, next);
if (tagp)
*tagp = x86_bus_space_io;
if (basep)
*basep = io->minbase;
return (0);
}
int
pnpbios_getiosize(pnpbios_tag_t pbt, struct pnpresources *resc,
int idx, int *sizep)
{
struct pnp_io *io;
if (idx >= resc->numio)
return (EINVAL);
io = SIMPLEQ_FIRST(&resc->io);
while (idx--)
io = SIMPLEQ_NEXT(io, next);
if (sizep)
*sizep = io->len;
return (0);
}
void *
pnpbios_intr_establish(pnpbios_tag_t pbt, struct pnpresources *resc,
int idx, int level, int (*fcn)(void *), void *arg)
{
struct pnp_irq *irq;
int irqnum, type;
if (idx >= resc->numirq)
return (0);
irq = SIMPLEQ_FIRST(&resc->irq);
while (idx--)
irq = SIMPLEQ_NEXT(irq, next);
irqnum = ffs(irq->mask) - 1;
type = (irq->flags & 0x0c) ? IST_LEVEL : IST_EDGE;
return (isa_intr_establish(0, irqnum, type, level, fcn, arg));
}
int
pnpbios_getirqnum(pnpbios_tag_t pbt, struct pnpresources *resc,
int idx, int *irqp, int *istp)
{
struct pnp_irq *irq;
if (idx >= resc->numirq)
return (EINVAL);
irq = SIMPLEQ_FIRST(&resc->irq);
while (idx--)
irq = SIMPLEQ_NEXT(irq, next);
if (irqp != NULL)
*irqp = ffs(irq->mask) - 1;
if (istp != NULL)
*istp = (irq->flags & 0x0c) ? IST_LEVEL : IST_EDGE;
return (0);
}
int
pnpbios_getdmachan(pnpbios_tag_t pbt, struct pnpresources *resc,
int idx, int *chanp)
{
struct pnp_dma *dma;
if (idx >= resc->numdma)
return (EINVAL);
dma = SIMPLEQ_FIRST(&resc->dma);
while (idx--)
dma = SIMPLEQ_NEXT(dma, next);
*chanp = ffs(dma->mask) - 1;
return (0);
}
#ifdef PNPBIOSEVENTS
static void
pnpbios_event_thread(void *arg)
{
struct pnpbios_softc *sc;
uint16_t event;
u_int evflag;
int rv, poll;
sc = arg;
if ((sc->sc_control & PNP_IC_CONTORL_EVENT_MASK)
!= PNP_IC_CONTROL_EVENT_POLL)
poll = 0;
else {
poll = hz;
rv = pnpbios_sendmessage(PNP_CM_PNP_OS_ACTIVE);
EDPRINTF(("pnpbios: os active returns 0x%02x\n", rv));
}
config_pending_decr(sc->sc_dev);
goto start;
while (sc->sc_threadrun) {
/* maybe we have an event */
if (!poll)
(void)tsleep(pnpbios_event_thread, PWAIT,
"pnpbiosevent", 0);
else if (((evflag = *sc->sc_evaddr) & 0x01) == 0) {
if (evflag)
EDPRINTF(("pnpbios: evflags 0x%02x\n", evflag));
(void)tsleep(pnpbios_event_thread, PWAIT,
"pnpbiosevent", poll);
continue;
} else {
EDPRINTF(("pnpbios: evflags 0x%02x\n", evflag));
}
start:
if ((rv = pnpbios_getevent(&event))) {
EDPRINTF(("pnpbios: getevent rc: 0x%02x\n", rv));
#ifdef DIAGNOSTIC
if (rv != PNP_RC_EVENTS_NOT_PENDING)
printf("%s: getevent failed: %d\n",
device_xname(sc->sc_dev), rv);
#endif
continue;
}
switch (event) {
case PNP_EID_ABOUT_TO_CHANGE_CONFIG:
EDPRINTF(("pnpbios: about to change event\n"));
/*
* The system is about to be docked or undocked.
* Acknowledge the event, so that the procedure
* can continue.
* XXX When should we ever send an ABORT?
*/
pnpbios_sendmessage(PNP_RM_OK);
break;
case PNP_EID_DOCK_CHANGED:
{
int odocked;
EDPRINTF(("pnpbios: dock changed event\n"));
odocked = pnpbios_update_dock_status(sc);
if (odocked == sc->sc_docked)
break;
switch (sc->sc_docked) {
case 0:
/* We have been undocked. */
/* XXX detach devices XXX */
break;
case 1:
/* We have been docked. */
/* XXX attach devices XXX */
break;
default:
/* getdockinfo failed! */
printf("%s: dock changed event, but unable "
"to get dock info; event ignored\n",
device_xname(sc->sc_dev));
}
break;
}
case PNP_EID_SYSTEM_DEVICE_CHANGED:
EDPRINTF(("pnpbios: system device changed event\n"));
break;
case PNP_EID_CONFIG_CHANGE_FAILED:
EDPRINTF(("pnpbios: config changed event\n"));
break;
case PNP_EID_UNKNOWN_SYSTEM_EVENT:
#ifdef DIAGNOSTIC
printf("%s: \"unknown system event\"\n",
device_xname(sc->sc_dev));
#endif
break;
default:
#ifdef DIAGNOSTIC
if (event & PNP_EID_OEM_DEFINED_BIT)
printf("%s: vendor defined event 0x%04x\n",
device_xname(sc->sc_dev), event);
else
printf("%s: unknown event 0x%04x\n",
device_xname(sc->sc_dev), event);
#endif
break;
}
}
pnpbios_sendmessage(PNP_CM_PNP_OS_INACTIVE);
kthread_exit(0);
}
#endif /* PNPBIOSEVENTS */
|
bb673bf3f53b8088eb0797009c93c9a34b80acce
|
8838eb997879add5759b6dfb23f9a646464e53ca
|
/src/drivers/net/r6040/r6040.h
|
62d21f036d498d5434316c8697794fb0079d8822
|
[
"BSD-2-Clause"
] |
permissive
|
embox/embox
|
d6aacec876978522f01cdc4b8de37a668c6f4c80
|
98e3c06e33f3fdac10a29c069c20775568e0a6d1
|
refs/heads/master
| 2023-09-04T03:02:20.165042
| 2023-09-02T14:55:31
| 2023-09-02T14:55:31
| 33,078,138
| 1,087
| 325
|
BSD-2-Clause
| 2023-09-14T16:58:34
| 2015-03-29T15:27:48
|
C
|
UTF-8
|
C
| false
| false
| 607
|
h
|
r6040.h
|
/**
* @file
* @brief r6040 ethernet driver
*
* @date 03.07.11
* @author Nikolay Korotkiy
*/
#ifndef NET_R6040_H_
#define NET_R6040_H_
#include <net/netdevice.h>
#define R6040_RX_DESCRIPTORS 32
extern void r6040_rx_enable(void);
extern int r6040_open(struct net_device *dev);
/* queue packet for transmission */
extern void r6040_tx(unsigned char* pkt, size_t length);
/* Returns size of pkt, or zero if none received */
extern size_t r6040_rx(unsigned char* pkt, size_t max_len);
extern unsigned short r6040_mdio_read(int, int);
extern int r6040_wait_linkup(void);
#endif /* NET_R6040_H_ */
|
c65a32690e0a87cd49c009e8b8a4ef2d00eaf207
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/sound/soc/kirkwood/kirkwood.h
|
4d92637ddb3fd878f86e4d4525fbd024d94b2618
|
[
"LicenseRef-scancode-free-unknown",
"Apache-2.0",
"Linux-syscall-note",
"GPL-2.0-only",
"GPL-1.0-or-later"
] |
permissive
|
OLIMEX/DIY-LAPTOP
|
ae82f4ee79c641d9aee444db9a75f3f6709afa92
|
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
|
refs/heads/rel3
| 2023-08-04T01:54:19.483792
| 2023-04-03T07:18:12
| 2023-04-03T07:18:12
| 80,094,055
| 507
| 92
|
Apache-2.0
| 2023-04-03T07:05:59
| 2017-01-26T07:25:50
|
C
|
UTF-8
|
C
| false
| false
| 4,587
|
h
|
kirkwood.h
|
/*
* kirkwood.h
*
* (c) 2010 Arnaud Patard <apatard@mandriva.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*/
#ifndef _KIRKWOOD_AUDIO_H
#define _KIRKWOOD_AUDIO_H
#define KIRKWOOD_RECORD_WIN 0
#define KIRKWOOD_PLAYBACK_WIN 1
#define KIRKWOOD_MAX_AUDIO_WIN 2
#define KIRKWOOD_AUDIO_WIN_BASE_REG(win) (0xA00 + ((win)<<3))
#define KIRKWOOD_AUDIO_WIN_CTRL_REG(win) (0xA04 + ((win)<<3))
#define KIRKWOOD_RECCTL 0x1000
#define KIRKWOOD_RECCTL_SPDIF_EN (1<<11)
#define KIRKWOOD_RECCTL_I2S_EN (1<<10)
#define KIRKWOOD_RECCTL_PAUSE (1<<9)
#define KIRKWOOD_RECCTL_MUTE (1<<8)
#define KIRKWOOD_RECCTL_BURST_MASK (3<<5)
#define KIRKWOOD_RECCTL_BURST_128 (2<<5)
#define KIRKWOOD_RECCTL_BURST_32 (1<<5)
#define KIRKWOOD_RECCTL_MONO (1<<4)
#define KIRKWOOD_RECCTL_MONO_CHAN_RIGHT (1<<3)
#define KIRKWOOD_RECCTL_MONO_CHAN_LEFT (0<<3)
#define KIRKWOOD_RECCTL_SIZE_MASK (7<<0)
#define KIRKWOOD_RECCTL_SIZE_16 (7<<0)
#define KIRKWOOD_RECCTL_SIZE_16_C (3<<0)
#define KIRKWOOD_RECCTL_SIZE_20 (2<<0)
#define KIRKWOOD_RECCTL_SIZE_24 (1<<0)
#define KIRKWOOD_RECCTL_SIZE_32 (0<<0)
#define KIRKWOOD_REC_BUF_ADDR 0x1004
#define KIRKWOOD_REC_BUF_SIZE 0x1008
#define KIRKWOOD_REC_BYTE_COUNT 0x100C
#define KIRKWOOD_PLAYCTL 0x1100
#define KIRKWOOD_PLAYCTL_PLAY_BUSY (1<<16)
#define KIRKWOOD_PLAYCTL_BURST_MASK (3<<11)
#define KIRKWOOD_PLAYCTL_BURST_128 (2<<11)
#define KIRKWOOD_PLAYCTL_BURST_32 (1<<11)
#define KIRKWOOD_PLAYCTL_PAUSE (1<<9)
#define KIRKWOOD_PLAYCTL_SPDIF_MUTE (1<<8)
#define KIRKWOOD_PLAYCTL_MONO_MASK (3<<5)
#define KIRKWOOD_PLAYCTL_MONO_BOTH (3<<5)
#define KIRKWOOD_PLAYCTL_MONO_OFF (0<<5)
#define KIRKWOOD_PLAYCTL_I2S_MUTE (1<<7)
#define KIRKWOOD_PLAYCTL_SPDIF_EN (1<<4)
#define KIRKWOOD_PLAYCTL_I2S_EN (1<<3)
#define KIRKWOOD_PLAYCTL_SIZE_MASK (7<<0)
#define KIRKWOOD_PLAYCTL_SIZE_16 (7<<0)
#define KIRKWOOD_PLAYCTL_SIZE_16_C (3<<0)
#define KIRKWOOD_PLAYCTL_SIZE_20 (2<<0)
#define KIRKWOOD_PLAYCTL_SIZE_24 (1<<0)
#define KIRKWOOD_PLAYCTL_SIZE_32 (0<<0)
#define KIRKWOOD_PLAY_BUF_ADDR 0x1104
#define KIRKWOOD_PLAY_BUF_SIZE 0x1108
#define KIRKWOOD_PLAY_BYTE_COUNT 0x110C
#define KIRKWOOD_DCO_CTL 0x1204
#define KIRKWOOD_DCO_CTL_OFFSET_MASK (0xFFF<<2)
#define KIRKWOOD_DCO_CTL_OFFSET_0 (0x800<<2)
#define KIRKWOOD_DCO_CTL_FREQ_MASK (3<<0)
#define KIRKWOOD_DCO_CTL_FREQ_11 (0<<0)
#define KIRKWOOD_DCO_CTL_FREQ_12 (1<<0)
#define KIRKWOOD_DCO_CTL_FREQ_24 (2<<0)
#define KIRKWOOD_DCO_SPCR_STATUS 0x120c
#define KIRKWOOD_DCO_SPCR_STATUS_DCO_LOCK (1<<16)
#define KIRKWOOD_CLOCKS_CTRL 0x1230
#define KIRKWOOD_MCLK_SOURCE_MASK (3<<0)
#define KIRKWOOD_MCLK_SOURCE_DCO (0<<0)
#define KIRKWOOD_MCLK_SOURCE_EXTCLK (3<<0)
#define KIRKWOOD_ERR_CAUSE 0x1300
#define KIRKWOOD_ERR_MASK 0x1304
#define KIRKWOOD_INT_CAUSE 0x1308
#define KIRKWOOD_INT_MASK 0x130C
#define KIRKWOOD_INT_CAUSE_PLAY_BYTES (1<<14)
#define KIRKWOOD_INT_CAUSE_REC_BYTES (1<<13)
#define KIRKWOOD_INT_CAUSE_DMA_PLAY_END (1<<7)
#define KIRKWOOD_INT_CAUSE_DMA_PLAY_3Q (1<<6)
#define KIRKWOOD_INT_CAUSE_DMA_PLAY_HALF (1<<5)
#define KIRKWOOD_INT_CAUSE_DMA_PLAY_1Q (1<<4)
#define KIRKWOOD_INT_CAUSE_DMA_REC_END (1<<3)
#define KIRKWOOD_INT_CAUSE_DMA_REC_3Q (1<<2)
#define KIRKWOOD_INT_CAUSE_DMA_REC_HALF (1<<1)
#define KIRKWOOD_INT_CAUSE_DMA_REC_1Q (1<<0)
#define KIRKWOOD_REC_BYTE_INT_COUNT 0x1310
#define KIRKWOOD_PLAY_BYTE_INT_COUNT 0x1314
#define KIRKWOOD_BYTE_INT_COUNT_MASK 0xffffff
#define KIRKWOOD_I2S_PLAYCTL 0x2508
#define KIRKWOOD_I2S_RECCTL 0x2408
#define KIRKWOOD_I2S_CTL_JUST_MASK (0xf<<26)
#define KIRKWOOD_I2S_CTL_LJ (0<<26)
#define KIRKWOOD_I2S_CTL_I2S (5<<26)
#define KIRKWOOD_I2S_CTL_RJ (8<<26)
#define KIRKWOOD_I2S_CTL_SIZE_MASK (3<<30)
#define KIRKWOOD_I2S_CTL_SIZE_16 (3<<30)
#define KIRKWOOD_I2S_CTL_SIZE_20 (2<<30)
#define KIRKWOOD_I2S_CTL_SIZE_24 (1<<30)
#define KIRKWOOD_I2S_CTL_SIZE_32 (0<<30)
#define KIRKWOOD_AUDIO_BUF_MAX (16*1024*1024)
/* Theses values come from the marvell alsa driver */
/* need to find where they come from */
#define KIRKWOOD_SND_MIN_PERIODS 8
#define KIRKWOOD_SND_MAX_PERIODS 16
#define KIRKWOOD_SND_MIN_PERIOD_BYTES 0x4000
#define KIRKWOOD_SND_MAX_PERIOD_BYTES 0x4000
struct kirkwood_dma_data {
void __iomem *io;
struct clk *clk;
struct clk *extclk;
uint32_t ctl_play;
uint32_t ctl_rec;
int irq;
int burst;
};
#endif
|
6151cf892a96e02b9c16f02fa5aaa2923f40f0a9
|
6f247f5400c6a840b6dfcb12388116dc3bb7bd49
|
/envydis/ctx.c
|
eb206e1ce1690fcf205be452346aa253ce4f4052
|
[
"MIT"
] |
permissive
|
envytools/envytools
|
c062fbc3b8af90d3df9c6e0f57e9abbfc5690d01
|
e11d670a70ae0455261ead53cdd09c321974cc64
|
refs/heads/master
| 2023-08-26T23:44:47.131591
| 2022-04-30T21:15:56
| 2022-04-30T21:15:56
| 11,620,001
| 402
| 103
|
MIT
| 2022-12-07T01:35:18
| 2013-07-23T21:43:43
|
C
|
UTF-8
|
C
| false
| false
| 14,010
|
c
|
ctx.c
|
/*
* Copyright (C) 2009-2011 Marcelina Kościelnicka <mwk@0x04.net>
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "dis-intern.h"
#define F_NV40 1
#define F_G80 2
#define F_CALLRET 4
/*
* PGRAPH registers of interest, G80
*
* 0x400040: disables subunits of PGRAPH. or at least disables access to them
* through MMIO. each bit corresponds to a unit, and the full mask
* is 0x7fffff. writing 1 to a given bit disables the unit, 0
* enables.
* 0x400300: some sort of status register... shows 0xe when execution stopped,
* 0xX3 when running or paused.
* 0x400304: control register. For writes:
* bit 0: start execution
* bit 1: resume execution
* bit 4: pause execution
* For reads:
* bit 0: prog running or paused
* 0x400308: Next opcode to execute, or the exit opcode if program exitted.
* 0x40030c: RO alias of PC for some reason
* 0x400310: PC. Readable and writable. In units of single insns.
* 0x40031c: register $ra (20-bit), holding parameters to various stuff.
* 0x400320: WO, CMD register. Writing here launches a cmd, see below.
* 0x400324: code upload index, WO. selects address to write in ctxprog code,
* counted in whole insns.
* 0x400328: code upload, WO. writes given insn to code segment and
* autoincrements upload address.
* 0x40032c: current channel RAMIN address, shifted right by 12 bits. bit 31 == valid
* 0x400330: next channel RAMIN address, shifted right by 12 bits. bit 31 == valid
* 0x400334: $r register, offset in RAMIN context to read/write with opcode 1.
* in units of 32-bit words.
* 0x400338: register $rb (20-bit), holding parameters to various stuff.
* Used on NVAx with values 0-9 to
* select TP number to read/write with G[0x8000]. Maybe generic
* PGRAPH offset? Also set to 0x8ffff in one place for some reason.
* 0x40033c: Some other register. Set with opcode 0x600007. Related to and
* modified by opcode 8. Setting with opcode 0x600007 always ands
* contents with 0xffff8 for some reason.
* 0x400784: channel RAMIN address used for memory reads/writes. needs to be
* flushed with CMD 4 after it's changed.
* 0x400824: Flags, 0x00-0x1f, RW
* 0x400828: Flags, 0x20-0x3f, RW
* 0x40082c: Flags, 0x40-0x5f, RO... this is some sort of hardware status
* 0x400830: Flags, 0x60-0x7f, RW
*
* How execution works:
*
* Execution can be in one of 3 states: stopped, running, and paused.
* Initially, it's stopped. The only way to start execution is to poke 0x400304
* with bit 0 set. When you do this, the uc starts executing opcodes from
* current PC. The only way to stop execution is to use CMD 0xc.
* Note that CMD 0xc resets PC to 0, so ctxprog will start over from there
* next time, unless you poke PC before that. Running <-> paused transition
* happens by poking 0x400304 with the appropriate bit set to 1. Poking with
* *both* bits set to 1 causes it to reload the opcode register from current
* PC, but nothing else happens. This can be used to read the code segment.
* Poking with bits 4 and 0 set together causes it to start with paused state.
*
* Oh, also, PC has 9 valid bits. So you can have ctxprogs of max. 512 insns.
*
* CMD: These are some special operations that can be launched either from
* host by poking the CMD number to 0x400320, or by ctxprog by running opcode
* 6 with the CMD number in its immediate field. See tabcmd.
*
*/
/*
* PGRAPH registers of interest, NV40
*
* 0x400040: disables subunits of PGRAPH. or at least disables access to them
* through MMIO. each bit corresponds to a unit, and the full mask
* is 0x7fffff. writing 1 to a given bit disables the unit, 0
* enables.
* 0x400300: some sort of status register... shows 0xe when execution stopped,
* 0xX3 when running or paused.
* 0x400304: control register. Writing 1 startx prog, writing 2 kills it.
* 0x400308: Current PC+opcode. PC is in high 8 bits, opcode is in low 24 bits.
* 0x400310: Flags 0-0xf, RW
* 0x400314: Flags 0x20-0x2f, RW
* 0x400318: Flags 0x60-0x6f, RO, hardware status
* 0x40031c: the scratch register, written by opcode 2, holding params to
* various stuff.
* 0x400324: code upload index, RW. selects address to write in ctxprog code,
* counted in whole insns.
* 0x400328: code upload. writes given insn to code segment and
* autoincrements upload address. RW, but returns something crazy on
* read
* 0x40032c: current channel RAMIN address, shifted right by 12 bits. bit 24 == valid
* 0x400330: next channel RAMIN address, shifted right by 12 bits. bit 24 == valid
* 0x400338: Some register, set with opcode 3
* 0x400784: channel RAMIN address used for memory reads/writes. needs to be
* flushed with CMD 4 after it's changed.
*
*/
/*
* Code target field
*
* This field represents a code address and is used for branching and the
* likes. Target is counted in 32-bit words from the start of microcode.
*/
static struct rbitfield ctargoff = { 8, 9 };
#define BTARG atombtarg, &ctargoff
#define CTARG atomctarg, &ctargoff
/* Register fields */
static struct reg ra_r = { 0, "ra" };
static struct reg rb_r = { 0, "rb" };
#define RA atomreg, &ra_r
#define RB atomreg, &rb_r
/*
* Misc number fields
*
* Used for plain numerical arguments.
*/
static struct bitfield scratchbitoff = { 0, 5 };
static struct bitfield flagoff = { 0, 7 };
static struct bitfield gsize4off = { 14, 6 };
static struct bitfield gsize5off = { 16, 4 };
static struct bitfield immoff = { 0, 20 };
static struct bitfield rmaskoff = { 0, 16 };
static struct bitfield ridxoff = { 16, 4 };
static struct bitfield xstart4off = { 3, 7 };
static struct bitfield xstart5off = { 8, 11 };
static struct bitfield xmaskoff = { 0, 8 };
static struct bitfield cmdoff = { 0, 5 };
#define SCRATCHBIT atomimm, &scratchbitoff
#define FLAG atomimm, &flagoff
#define GSIZE4 atomimm, &gsize4off
#define GSIZE5 atomimm, &gsize5off
#define IMM atomimm, &immoff
#define RMASK atomimm, &rmaskoff
#define RIDX atomimm, &ridxoff
#define XSTART4 atomimm, &xstart4off
#define XSTART5 atomimm, &xstart5off
#define XMASK atomimm, &xmaskoff
#define CMD atomimm, &cmdoff
/*
* Memory fields
*/
// BF, offset shift, 'l'
static struct rbitfield pgmem4_imm = { { 0, 14 }, RBF_UNSIGNED, 2 };
static struct rbitfield pgmem5_imm = { { 0, 16 }, RBF_UNSIGNED, 2 };
static struct mem pgmem4_m = { "G", 0, 0, &pgmem4_imm };
static struct mem pgmem5_m = { "G", 0, 0, &pgmem5_imm };
#define PGRAPH4 atommem, &pgmem4_m
#define PGRAPH5 atommem, &pgmem5_m
static struct insn tabrpred[] = {
{ 0x00, 0x7f, N("dirsave") }, // the direction flag; 0: read from memory, 1: write to memory
{ 0x03, 0x7f, N("ctxfreeze"), .fmask = F_G80 }, // disallows all modification of context, so that S/R can proceed
{ 0x05, 0x7f, N("swsavereq") }, // SW defined
{ 0x06, 0x7f, N("swrestorereq") }, // SW defined
{ 0x09, 0x7f, N("swxferreq") }, // SW defined
{ 0x1c, 0x7f, N("pm0"), .fmask = F_G80 },
{ 0x1d, 0x7f, N("pm1"), .fmask = F_G80 },
{ 0x1e, 0x7f, N("pm2"), .fmask = F_G80 },
{ 0x1f, 0x7f, N("pm3"), .fmask = F_G80 },
// NV40 hardware RO flags
{ 0x60, 0x7f, N("idle"), .fmask = F_NV40 },
{ 0x64, 0x7f, N("hwsavereq"), .fmask = F_NV40 },
{ 0x65, 0x7f, N("hwrestorereq"), .fmask = F_NV40 },
{ 0x66, 0x7f, N("state3d"), .fmask = F_NV40 }, // wired straight to the CTX_USER bit.
{ 0x68, 0x7f, .fmask = F_NV40 }, // always
{ 0x69, 0x7f, N("timeridle"), .fmask = F_NV40 },
// G80 hardware RO flags
{ 0x40, 0x7f, N("idle"), .fmask = F_G80 },
{ 0x44, 0x7f, N("hwsavereq"), .fmask = F_G80 },
{ 0x45, 0x7f, N("hwrestorereq"), .fmask = F_G80 },
{ 0x4a, 0x7f, N("binddmaack"), .fmask = F_G80 }, // bind ctx dma CMD finished with loading new address... or something like that, it seems to be turned back off *very shortly* after the CMD. only check it with a wait right after cmd. weird.
{ 0x4b, 0x7f, N("xferbusy"), .fmask = F_G80 }, // RAMIN xfer in progress
{ 0x4c, 0x7f, N("timeridle"), .fmask = F_G80 },
{ 0x4d, 0x7f, .fmask = F_G80 }, // always
{ 0x4f, 0x7f, N("intrpending"), .fmask = F_G80 },
// G80 scratch reg
{ 0x60, 0x60, N("scratch"), SCRATCHBIT, .fmask = F_G80 },
// unknown
{ 0x00, 0x00, N("flag"), FLAG, OOPS },
};
static struct insn tabpred[] = {
{ 0x80, 0x80, N("not"), T(rpred) },
{ 0x00, 0x80, T(rpred) },
{ 0, 0, OOPS },
};
static struct insn tabcmd4[] = {
{ 0x07, 0x1f, C("BIND_CHANNEL") }, // copies 330 [new channel] to 784 [channel used for ctx RAM access]
{ 0x09, 0x1f, C("FINISH_CHSW") }, // movs new channel RAMIN address to current channel RAMIN address, making PFIFO happy
{ 0x0a, 0x1f, C("SET_CTX_POINTER") }, // copies scratch to 334
{ 0x0b, 0x1f, C("START_TIMER") }, // sets the timer to count down $ra cycles
{ 0x0c, 0x1f, C("CLEAR_RESET") }, // undoes all reset commands
{ 0x0d, 0x1f, C("HALT") }, // halt execution *without* resetting PC to 0
{ 0x0e, 0x1f, C("END") }, // halts program execution, resets PC to 0
{ 0x0f, 0x1f, C("INTR") }, // trigger context switch interrupt and halt
{ 0, 0, OOPS, CMD },
};
static struct insn tabcmd5[] = {
{ 0x04, 0x1f, C("BIND_CTX_DMA") }, // rebinds DMA object for ctx access
{ 0x05, 0x1f, C("BIND_CHANNEL") }, // copies 330 [new channel] to 784 [channel used for MMU accesses]
{ 0x06, 0x1f, C("SET_REG_POINTER") }, // copies scratch to 334
{ 0x07, 0x1f, C("SET_XFER_POINTER") }, // copies scratch to 33c, anding it with 0xffff8
{ 0x08, 0x1f, C("START_TIMER") },
{ 0x09, 0x1f, C("CLEAR_RESET") },
{ 0x0a, 0x1f, C("HALT") },
{ 0x0b, 0x1f, C("INTR") },
{ 0x0c, 0x1f, C("END") },
{ 0x0d, 0x1f, C("FINISH_CHSW") },
// 0x11 seen
// 0x16 seen on G200+
{ 0, 0, OOPS, CMD },
};
static struct insn tabxarea4[] = {
{ 0x000001, 0x000007, N("main") },
{ 0x000002, 0x000007, N("unk2") },
{ 0, 0, OOPS },
};
static struct insn tabxarea5[] = {
{ 0x000000, 0x080000, N("main") },
{ 0x080000, 0x080000, N("mp") },
{ 0, 0, OOPS },
};
static struct insn tabm[] = {
{ 0x000000, 0xf00000, N("nop") },
{ 0x100000, 0xff0000, N("reg"), PGRAPH5, RA, .fmask = F_G80 },
{ 0x100000, 0xf00000, N("reg"), PGRAPH5, GSIZE5, .fmask = F_G80 },
{ 0x100000, 0xffc000, N("reg"), PGRAPH4, RA, .fmask = F_NV40 },
{ 0x100000, 0xf00000, N("reg"), PGRAPH4, GSIZE4, .fmask = F_NV40 },
{ 0x200000, 0xf00000, N("li"), RA, IMM }, // moves 20-bit immediate to $ra
{ 0x300000, 0xf00000, N("li"), RB, IMM }, // moves 20-bit immediate to $rb
{ 0x400000, 0xfc0000, N("jmp"), T(pred), BTARG }, // jumps if condition true
{ 0x440000, 0xfc0000, N("call"), T(pred), CTARG, .fmask = F_CALLRET }, // calls if condition true
{ 0x480000, 0xfc0000, N("ret"), T(pred), .fmask = F_CALLRET }, // rets if condition true
{ 0x500000, 0xf00000, N("waitfor"), T(pred) }, // waits until condition true.
{ 0x600000, 0xf00000, N("cmd"), T(cmd5), .fmask = F_G80 }, // runs a CMD.
{ 0x600000, 0xf00000, N("cmd"), T(cmd4), .fmask = F_NV40 }, // runs a CMD.
{ 0x700000, 0xf00080, N("clear"), T(rpred) }, // clears given flag
{ 0x700080, 0xf00080, N("set"), T(rpred) }, // sets given flag
{ 0x800000, 0xf00000, N("xfer"), T(xarea4), XSTART4, .fmask = F_NV40 },
{ 0x800000, 0xf00000, N("xfer"), T(xarea5), XMASK, .fmask = F_G80 },
{ 0x900000, 0xf00000, N("reset"), RIDX, RMASK }, // ors 0x40 with given immediate.
{ 0xa00000, 0xf00000, N("ldsr"), PGRAPH5, .fmask = F_G80 }, // movs given PGRAPH register to 0x400830 aka the scratch reg.
{ 0xc00000, 0xf00000, N("seek"), T(xarea5), XMASK, XSTART5, .fmask = F_G80 },
{ 0, 0, OOPS },
};
static struct insn tabroot[] = {
{ 0, 0, OP1B, T(m) },
};
static void ctx_prep(struct disisa *isa) {
isa->vardata = vardata_new("ctxisa");
int f_nv40op = vardata_add_feature(isa->vardata, "nv40op", "NV40 family exclusive opcodes");
int f_g80op = vardata_add_feature(isa->vardata, "g80op", "G80 family exclusive opcodes");
int f_callret = vardata_add_feature(isa->vardata, "callret", "call and ret ops");
if (f_nv40op == -1 || f_g80op == -1 || f_callret == -1)
abort();
int vs_chipset = vardata_add_varset(isa->vardata, "chipset", "GPU chipset");
if (vs_chipset == -1)
abort();
int v_nv40 = vardata_add_variant(isa->vardata, "nv40", "NV40:G80", vs_chipset);
int v_g80 = vardata_add_variant(isa->vardata, "g80", "G80:G200", vs_chipset);
int v_g200 = vardata_add_variant(isa->vardata, "g200", "G200:GF100", vs_chipset);
if (v_nv40 == -1 || v_g80 == -1 || v_g200 == -1)
abort();
vardata_variant_feature(isa->vardata, v_nv40, f_nv40op);
vardata_variant_feature(isa->vardata, v_g80, f_g80op);
vardata_variant_feature(isa->vardata, v_g200, f_g80op);
vardata_variant_feature(isa->vardata, v_g200, f_callret);
if (vardata_validate(isa->vardata))
abort();
}
struct disisa ctx_isa_s = {
tabroot,
1,
1,
4,
.prep = ctx_prep,
};
|
7ad225fa5a3f87c1c0d79044a9577dce425c8459
|
06f2e78f4d736c8ac9cb7e98a5abcc28ed4f25b2
|
/public/xash3d_mathlib.c
|
7ec72ebe6a9c699fd268330f8fdf4f756c2fd926
|
[] |
no_license
|
FWGS/xash3d-fwgs
|
07a1002396f43754b49521681cc771c0d89051ed
|
435b95fc5ab3fc5b1a79212ffdc901a47769d056
|
refs/heads/master
| 2023-09-01T05:20:48.112400
| 2023-08-31T05:40:24
| 2023-08-31T05:40:24
| 127,814,982
| 1,078
| 275
| null | 2023-09-12T17:49:04
| 2018-04-02T21:33:02
|
C
|
UTF-8
|
C
| false
| false
| 18,567
|
c
|
xash3d_mathlib.c
|
/*
xash3d_mathlib.c - internal mathlib
Copyright (C) 2010 Uncle Mike
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#include "port.h"
#include "xash3d_types.h"
#include "const.h"
#include "com_model.h"
#include "xash3d_mathlib.h"
#include "eiface.h"
#define NUM_HULL_ROUNDS ARRAYSIZE( hull_table )
#define HULL_PRECISION 4
vec3_t vec3_origin = { 0, 0, 0 };
static word hull_table[] = { 2, 4, 6, 8, 12, 16, 18, 24, 28, 32, 36, 40, 48, 54, 56, 60, 64, 72, 80, 112, 120, 128, 140, 176 };
int boxpnt[6][4] =
{
{ 0, 4, 6, 2 }, // +X
{ 0, 1, 5, 4 }, // +Y
{ 0, 2, 3, 1 }, // +Z
{ 7, 5, 1, 3 }, // -X
{ 7, 3, 2, 6 }, // -Y
{ 7, 6, 4, 5 }, // -Z
};
// pre-quantized table normals from Quake1
const float m_bytenormals[NUMVERTEXNORMALS][3] =
{
#include "anorms.h"
};
/*
=================
anglemod
=================
*/
float anglemod( float a )
{
a = (360.0f / 65536) * ((int)(a*(65536/360.0f)) & 65535);
return a;
}
word FloatToHalf( float v )
{
unsigned int i = FloatAsUint( v );
unsigned int e = (i >> 23) & 0x00ff;
unsigned int m = i & 0x007fffff;
unsigned short h;
if( e <= 127 - 15 )
h = ((m | 0x00800000) >> (127 - 14 - e)) >> 13;
else h = (i >> 13) & 0x3fff;
h |= (i >> 16) & 0xc000;
return h;
}
float HalfToFloat( word h )
{
unsigned int f = (h << 16) & 0x80000000;
unsigned int em = h & 0x7fff;
if( em > 0x03ff )
{
f |= (em << 13) + ((127 - 15) << 23);
}
else
{
unsigned int m = em & 0x03ff;
if( m != 0 )
{
unsigned int e = (em >> 10) & 0x1f;
while(( m & 0x0400 ) == 0 )
{
m <<= 1;
e--;
}
m &= 0x3ff;
f |= ((e + (127 - 14)) << 23) | (m << 13);
}
}
return UintAsFloat( f );
}
/*
=================
RoundUpHullSize
round the hullsize to nearest 'right' value
=================
*/
void RoundUpHullSize( vec3_t size )
{
int i, j;
for( i = 0; i < 3; i++)
{
qboolean negative = false;
float result, value;
value = size[i];
if( value < 0.0f ) negative = true;
value = Q_ceil( fabs( value ));
result = Q_ceil( size[i] );
// lookup hull table to find nearest supposed value
for( j = 0; j < NUM_HULL_ROUNDS; j++ )
{
if( value > hull_table[j] )
continue; // ceil only
if( negative )
{
result = ( value - hull_table[j] );
if( result <= HULL_PRECISION )
{
result = -hull_table[j];
break;
}
}
else
{
result = ( value - hull_table[j] );
if( result <= HULL_PRECISION )
{
result = hull_table[j];
break;
}
}
}
size[i] = result;
}
}
/*
=================
SignbitsForPlane
fast box on planeside test
=================
*/
int SignbitsForPlane( const vec3_t normal )
{
int bits, i;
for( bits = i = 0; i < 3; i++ )
if( normal[i] < 0.0f ) bits |= 1<<i;
return bits;
}
/*
=================
PlaneTypeForNormal
=================
*/
int PlaneTypeForNormal( const vec3_t normal )
{
if( normal[0] == 1.0f )
return PLANE_X;
if( normal[1] == 1.0f )
return PLANE_Y;
if( normal[2] == 1.0f )
return PLANE_Z;
return PLANE_NONAXIAL;
}
/*
=================
NearestPOW
=================
*/
int NearestPOW( int value, qboolean roundDown )
{
int n = 1;
if( value <= 0 ) return 1;
while( n < value ) n <<= 1;
if( roundDown )
{
if( n > value ) n >>= 1;
}
return n;
}
/*
=================
rsqrt
=================
*/
float rsqrt( float number )
{
int i;
float x, y;
if( number == 0.0f )
return 0.0f;
x = number * 0.5f;
i = FloatAsInt( number ); // evil floating point bit level hacking
i = 0x5f3759df - (i >> 1); // what the fuck?
y = IntAsFloat( i );
y = y * (1.5f - (x * y * y)); // first iteration
return y;
}
/*
==============
VectorCompareEpsilon
==============
*/
qboolean VectorCompareEpsilon( const vec3_t vec1, const vec3_t vec2, vec_t epsilon )
{
vec_t ax, ay, az;
ax = fabs( vec1[0] - vec2[0] );
ay = fabs( vec1[1] - vec2[1] );
az = fabs( vec1[2] - vec2[2] );
if(( ax <= epsilon ) && ( ay <= epsilon ) && ( az <= epsilon ))
return true;
return false;
}
float VectorNormalizeLength2( const vec3_t v, vec3_t out )
{
float length, ilength;
length = v[0] * v[0] + v[1] * v[1] + v[2] * v[2];
length = sqrt( length );
if( length )
{
ilength = 1.0f / length;
out[0] = v[0] * ilength;
out[1] = v[1] * ilength;
out[2] = v[2] * ilength;
}
return length;
}
void VectorVectors( const vec3_t forward, vec3_t right, vec3_t up )
{
float d;
right[0] = forward[2];
right[1] = -forward[0];
right[2] = forward[1];
d = DotProduct( forward, right );
VectorMA( right, -d, forward, right );
VectorNormalize( right );
CrossProduct( right, forward, up );
VectorNormalize( up );
}
/*
=================
AngleVectors
=================
*/
void GAME_EXPORT AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up )
{
float sr, sp, sy, cr, cp, cy;
SinCos( DEG2RAD( angles[YAW] ), &sy, &cy );
SinCos( DEG2RAD( angles[PITCH] ), &sp, &cp );
SinCos( DEG2RAD( angles[ROLL] ), &sr, &cr );
if( forward )
{
forward[0] = cp * cy;
forward[1] = cp * sy;
forward[2] = -sp;
}
if( right )
{
right[0] = (-1.0f * sr * sp * cy + -1.0f * cr * -sy );
right[1] = (-1.0f * sr * sp * sy + -1.0f * cr * cy );
right[2] = (-1.0f * sr * cp);
}
if( up )
{
up[0] = (cr * sp * cy + -sr * -sy );
up[1] = (cr * sp * sy + -sr * cy );
up[2] = (cr * cp);
}
}
/*
=================
VectorAngles
=================
*/
void GAME_EXPORT VectorAngles( const float *forward, float *angles )
{
float tmp, yaw, pitch;
if( !forward || !angles )
{
if( angles ) VectorClear( angles );
return;
}
if( forward[1] == 0 && forward[0] == 0 )
{
// fast case
yaw = 0;
if( forward[2] > 0 )
pitch = 90.0f;
else pitch = 270.0f;
}
else
{
yaw = ( atan2( forward[1], forward[0] ) * 180 / M_PI_F );
if( yaw < 0 ) yaw += 360;
tmp = sqrt( forward[0] * forward[0] + forward[1] * forward[1] );
pitch = ( atan2( forward[2], tmp ) * 180 / M_PI_F );
if( pitch < 0 ) pitch += 360;
}
VectorSet( angles, pitch, yaw, 0 );
}
/*
=================
VectorsAngles
=================
*/
void VectorsAngles( const vec3_t forward, const vec3_t right, const vec3_t up, vec3_t angles )
{
float pitch, cpitch, yaw, roll;
pitch = -asin( forward[2] );
cpitch = cos( pitch );
if( fabs( cpitch ) > EQUAL_EPSILON ) // gimball lock?
{
cpitch = 1.0f / cpitch;
pitch = RAD2DEG( pitch );
yaw = RAD2DEG( atan2( forward[1] * cpitch, forward[0] * cpitch ));
roll = RAD2DEG( atan2( -right[2] * cpitch, up[2] * cpitch ));
}
else
{
pitch = forward[2] > 0 ? -90.0f : 90.0f;
yaw = RAD2DEG( atan2( right[0], -right[1] ));
roll = 180.0f;
}
angles[PITCH] = pitch;
angles[YAW] = yaw;
angles[ROLL] = roll;
}
//
// bounds operations
//
/*
=================
ClearBounds
=================
*/
void ClearBounds( vec3_t mins, vec3_t maxs )
{
// make bogus range
mins[0] = mins[1] = mins[2] = 999999.0f;
maxs[0] = maxs[1] = maxs[2] = -999999.0f;
}
/*
=================
AddPointToBounds
=================
*/
void AddPointToBounds( const vec3_t v, vec3_t mins, vec3_t maxs )
{
float val;
int i;
for( i = 0; i < 3; i++ )
{
val = v[i];
if( val < mins[i] ) mins[i] = val;
if( val > maxs[i] ) maxs[i] = val;
}
}
/*
=================
ExpandBounds
=================
*/
void ExpandBounds( vec3_t mins, vec3_t maxs, float offset )
{
mins[0] -= offset;
mins[1] -= offset;
mins[2] -= offset;
maxs[0] += offset;
maxs[1] += offset;
maxs[2] += offset;
}
/*
=================
BoundsIntersect
=================
*/
qboolean BoundsIntersect( const vec3_t mins1, const vec3_t maxs1, const vec3_t mins2, const vec3_t maxs2 )
{
if( mins1[0] > maxs2[0] || mins1[1] > maxs2[1] || mins1[2] > maxs2[2] )
return false;
if( maxs1[0] < mins2[0] || maxs1[1] < mins2[1] || maxs1[2] < mins2[2] )
return false;
return true;
}
/*
=================
BoundsAndSphereIntersect
=================
*/
qboolean BoundsAndSphereIntersect( const vec3_t mins, const vec3_t maxs, const vec3_t origin, float radius )
{
if( mins[0] > origin[0] + radius || mins[1] > origin[1] + radius || mins[2] > origin[2] + radius )
return false;
if( maxs[0] < origin[0] - radius || maxs[1] < origin[1] - radius || maxs[2] < origin[2] - radius )
return false;
return true;
}
/*
=================
SphereIntersect
=================
*/
qboolean SphereIntersect( const vec3_t vSphereCenter, float fSphereRadiusSquared, const vec3_t vLinePt, const vec3_t vLineDir )
{
float a, b, c, insideSqr;
vec3_t p;
// translate sphere to origin.
VectorSubtract( vLinePt, vSphereCenter, p );
a = DotProduct( vLineDir, vLineDir );
b = 2.0f * DotProduct( p, vLineDir );
c = DotProduct( p, p ) - fSphereRadiusSquared;
insideSqr = b * b - 4.0f * a * c;
if( insideSqr <= 0.000001f )
return false;
return true;
}
/*
=================
PlaneIntersect
find point where ray
was intersect with plane
=================
*/
void PlaneIntersect( const mplane_t *plane, const vec3_t p0, const vec3_t p1, vec3_t out )
{
float distToPlane = PlaneDiff( p0, plane );
float planeDotRay = DotProduct( plane->normal, p1 );
float sect = -(distToPlane) / planeDotRay;
VectorMA( p0, sect, p1, out );
}
/*
=================
RadiusFromBounds
=================
*/
float RadiusFromBounds( const vec3_t mins, const vec3_t maxs )
{
vec3_t corner;
int i;
for( i = 0; i < 3; i++ )
{
corner[i] = fabs( mins[i] ) > fabs( maxs[i] ) ? fabs( mins[i] ) : fabs( maxs[i] );
}
return VectorLength( corner );
}
//
// studio utils
//
/*
====================
AngleQuaternion
====================
*/
void AngleQuaternion( const vec3_t angles, vec4_t q, qboolean studio )
{
float sr, sp, sy, cr, cp, cy;
if( studio )
{
SinCos( angles[ROLL] * 0.5f, &sy, &cy );
SinCos( angles[YAW] * 0.5f, &sp, &cp );
SinCos( angles[PITCH] * 0.5f, &sr, &cr );
}
else
{
SinCos( DEG2RAD( angles[YAW] ) * 0.5f, &sy, &cy );
SinCos( DEG2RAD( angles[PITCH] ) * 0.5f, &sp, &cp );
SinCos( DEG2RAD( angles[ROLL] ) * 0.5f, &sr, &cr );
}
q[0] = sr * cp * cy - cr * sp * sy; // X
q[1] = cr * sp * cy + sr * cp * sy; // Y
q[2] = cr * cp * sy - sr * sp * cy; // Z
q[3] = cr * cp * cy + sr * sp * sy; // W
}
/*
====================
QuaternionAngle
====================
*/
void QuaternionAngle( const vec4_t q, vec3_t angles )
{
matrix3x4 mat;
Matrix3x4_FromOriginQuat( mat, q, vec3_origin );
Matrix3x4_AnglesFromMatrix( mat, angles );
}
/*
====================
QuaternionAlign
make sure quaternions are within 180 degrees of one another,
if not, reverse q
====================
*/
void QuaternionAlign( const vec4_t p, const vec4_t q, vec4_t qt )
{
// decide if one of the quaternions is backwards
float a = 0.0f;
float b = 0.0f;
int i;
for( i = 0; i < 4; i++ )
{
a += (p[i] - q[i]) * (p[i] - q[i]);
b += (p[i] + q[i]) * (p[i] + q[i]);
}
if( a > b )
{
for( i = 0; i < 4; i++ )
qt[i] = -q[i];
}
else
{
for( i = 0; i < 4; i++ )
qt[i] = q[i];
}
}
/*
====================
QuaternionSlerpNoAlign
====================
*/
void QuaternionSlerpNoAlign( const vec4_t p, const vec4_t q, float t, vec4_t qt )
{
float omega, cosom, sinom, sclp, sclq;
int i;
// 0.0 returns p, 1.0 return q.
cosom = p[0] * q[0] + p[1] * q[1] + p[2] * q[2] + p[3] * q[3];
if(( 1.0f + cosom ) > 0.000001f )
{
if(( 1.0f - cosom ) > 0.000001f )
{
omega = acos( cosom );
sinom = sin( omega );
sclp = sin( (1.0f - t) * omega) / sinom;
sclq = sin( t * omega ) / sinom;
}
else
{
sclp = 1.0f - t;
sclq = t;
}
for( i = 0; i < 4; i++ )
{
qt[i] = sclp * p[i] + sclq * q[i];
}
}
else
{
qt[0] = -q[1];
qt[1] = q[0];
qt[2] = -q[3];
qt[3] = q[2];
sclp = sin(( 1.0f - t ) * ( 0.5f * M_PI_F ));
sclq = sin( t * ( 0.5f * M_PI_F ));
for( i = 0; i < 3; i++ )
{
qt[i] = sclp * p[i] + sclq * qt[i];
}
}
}
/*
====================
QuaternionSlerp
Quaternion sphereical linear interpolation
====================
*/
void QuaternionSlerp( const vec4_t p, const vec4_t q, float t, vec4_t qt )
{
vec4_t q2;
// 0.0 returns p, 1.0 return q.
// decide if one of the quaternions is backwards
QuaternionAlign( p, q, q2 );
QuaternionSlerpNoAlign( p, q2, t, qt );
}
/*
==================
BoxOnPlaneSide
Returns 1, 2, or 1 + 2
==================
*/
int BoxOnPlaneSide( const vec3_t emins, const vec3_t emaxs, const mplane_t *p )
{
float dist1, dist2;
int sides = 0;
// general case
switch( p->signbits )
{
case 0:
dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
dist2 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
break;
case 1:
dist1 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
break;
case 2:
dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
dist2 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
break;
case 3:
dist1 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
break;
case 4:
dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
dist2 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
break;
case 5:
dist1 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
break;
case 6:
dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
dist2 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
break;
case 7:
dist1 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
break;
default:
// shut up compiler
dist1 = dist2 = 0;
break;
}
if( dist1 >= p->dist )
sides = 1;
if( dist2 < p->dist )
sides |= 2;
return sides;
}
/*
====================
StudioSlerpBones
====================
*/
void R_StudioSlerpBones( int numbones, vec4_t q1[], float pos1[][3], const vec4_t q2[], const float pos2[][3], float s )
{
int i;
s = bound( 0.0f, s, 1.0f );
for( i = 0; i < numbones; i++ )
{
QuaternionSlerp( q1[i], q2[i], s, q1[i] );
VectorLerp( pos1[i], s, pos2[i], pos1[i] );
}
}
/*
====================
StudioCalcBoneQuaternion
====================
*/
void R_StudioCalcBoneQuaternion( int frame, float s, const mstudiobone_t *pbone, const mstudioanim_t *panim, const float *adj, vec4_t q )
{
vec3_t angles1;
vec3_t angles2;
int j, k;
for( j = 0; j < 3; j++ )
{
if( !panim || panim->offset[j+3] == 0 )
{
angles2[j] = angles1[j] = pbone->value[j+3]; // default;
}
else
{
mstudioanimvalue_t *panimvalue = (mstudioanimvalue_t *)((byte *)panim + panim->offset[j+3]);
k = frame;
// debug
if( panimvalue->num.total < panimvalue->num.valid )
k = 0;
// find span of values that includes the frame we want
while( panimvalue->num.total <= k )
{
k -= panimvalue->num.total;
panimvalue += panimvalue->num.valid + 1;
// debug
if( panimvalue->num.total < panimvalue->num.valid )
k = 0;
}
// bah, missing blend!
if( panimvalue->num.valid > k )
{
angles1[j] = panimvalue[k+1].value;
if( panimvalue->num.valid > k + 1 )
{
angles2[j] = panimvalue[k+2].value;
}
else
{
if( panimvalue->num.total > k + 1 )
angles2[j] = angles1[j];
else angles2[j] = panimvalue[panimvalue->num.valid+2].value;
}
}
else
{
angles1[j] = panimvalue[panimvalue->num.valid].value;
if( panimvalue->num.total > k + 1 )
angles2[j] = angles1[j];
else angles2[j] = panimvalue[panimvalue->num.valid+2].value;
}
angles1[j] = pbone->value[j+3] + angles1[j] * pbone->scale[j+3];
angles2[j] = pbone->value[j+3] + angles2[j] * pbone->scale[j+3];
}
if( pbone->bonecontroller[j+3] != -1 && adj != NULL )
{
angles1[j] += adj[pbone->bonecontroller[j+3]];
angles2[j] += adj[pbone->bonecontroller[j+3]];
}
}
if( !VectorCompare( angles1, angles2 ))
{
vec4_t q1, q2;
AngleQuaternion( angles1, q1, true );
AngleQuaternion( angles2, q2, true );
QuaternionSlerp( q1, q2, s, q );
}
else
{
AngleQuaternion( angles1, q, true );
}
}
/*
====================
StudioCalcBonePosition
====================
*/
void R_StudioCalcBonePosition( int frame, float s, const mstudiobone_t *pbone, const mstudioanim_t *panim, const float *adj, vec3_t pos )
{
vec3_t origin1;
vec3_t origin2;
int j, k;
for( j = 0; j < 3; j++ )
{
if( !panim || panim->offset[j] == 0 )
{
origin2[j] = origin1[j] = pbone->value[j]; // default;
}
else
{
mstudioanimvalue_t *panimvalue = (mstudioanimvalue_t *)((byte *)panim + panim->offset[j]);
k = frame;
// debug
if( panimvalue->num.total < panimvalue->num.valid )
k = 0;
// find span of values that includes the frame we want
while( panimvalue->num.total <= k )
{
k -= panimvalue->num.total;
panimvalue += panimvalue->num.valid + 1;
// debug
if( panimvalue->num.total < panimvalue->num.valid )
k = 0;
}
// bah, missing blend!
if( panimvalue->num.valid > k )
{
origin1[j] = panimvalue[k+1].value;
if( panimvalue->num.valid > k + 1 )
{
origin2[j] = panimvalue[k+2].value;
}
else
{
if( panimvalue->num.total > k + 1 )
origin2[j] = origin1[j];
else origin2[j] = panimvalue[panimvalue->num.valid+2].value;
}
}
else
{
origin1[j] = panimvalue[panimvalue->num.valid].value;
if( panimvalue->num.total > k + 1 )
origin2[j] = origin1[j];
else origin2[j] = panimvalue[panimvalue->num.valid+2].value;
}
origin1[j] = pbone->value[j] + origin1[j] * pbone->scale[j];
origin2[j] = pbone->value[j] + origin2[j] * pbone->scale[j];
}
if( pbone->bonecontroller[j] != -1 && adj != NULL )
{
origin1[j] += adj[pbone->bonecontroller[j]];
origin2[j] += adj[pbone->bonecontroller[j]];
}
}
if( !VectorCompare( origin1, origin2 ))
{
VectorLerp( origin1, s, origin2, pos );
}
else
{
VectorCopy( origin1, pos );
}
}
|
6d6e87cf22f3cf57709d9faed8bc30a418a575e0
|
88ae8695987ada722184307301e221e1ba3cc2fa
|
/third_party/angle/src/libANGLE/renderer/d3d/d3d11/shaders/compiled/passthrough2d11vs.h
|
fdeae67ad92d14f4b755b4deda4e28708f834afe
|
[
"Apache-2.0",
"LGPL-2.0-or-later",
"MIT",
"GPL-1.0-or-later",
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
iridium-browser/iridium-browser
|
71d9c5ff76e014e6900b825f67389ab0ccd01329
|
5ee297f53dc7f8e70183031cff62f37b0f19d25f
|
refs/heads/master
| 2023-08-03T16:44:16.844552
| 2023-07-20T15:17:00
| 2023-07-23T16:09:30
| 220,016,632
| 341
| 40
|
BSD-3-Clause
| 2021-08-13T13:54:45
| 2019-11-06T14:32:31
| null |
UTF-8
|
C
| false
| false
| 5,078
|
h
|
passthrough2d11vs.h
|
#if 0
//
// Generated by Microsoft (R) HLSL Shader Compiler 10.1
//
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION 0 xy 0 NONE float xy
// TEXCOORD 0 xy 1 NONE float xy
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION 0 xyzw 0 POS float xyzw
// TEXCOORD 0 xy 1 NONE float xy
//
//
// Runtime generated constant mappings:
//
// Target Reg Constant Description
// ---------- --------------------------------------------------
// c0 Vertex Shader position offset
//
//
// Level9 shader bytecode:
//
vs_2_x
def c1, 0, 1, 0, 0
dcl_texcoord v0
dcl_texcoord1 v1
add oPos.xy, v0, c0
mov oPos.zw, c1.xyxy
mov oT0.xy, v1
// approximately 3 instruction slots used
vs_4_0
dcl_input v0.xy
dcl_input v1.xy
dcl_output_siv o0.xyzw, position
dcl_output o1.xy
mov o0.xy, v0.xyxx
mov o0.zw, l(0,0,0,1.000000)
mov o1.xy, v1.xyxx
ret
// Approximately 4 instruction slots used
#endif
const BYTE g_VS_Passthrough2D[] = {
68, 88, 66, 67, 157, 119, 222, 216, 39, 186, 195, 24, 174, 138, 22, 73, 223, 185, 107,
36, 1, 0, 0, 0, 204, 2, 0, 0, 6, 0, 0, 0, 56, 0, 0, 0, 200, 0,
0, 0, 88, 1, 0, 0, 212, 1, 0, 0, 32, 2, 0, 0, 116, 2, 0, 0, 65,
111, 110, 57, 136, 0, 0, 0, 136, 0, 0, 0, 0, 2, 254, 255, 96, 0, 0, 0,
40, 0, 0, 0, 0, 0, 36, 0, 0, 0, 36, 0, 0, 0, 36, 0, 0, 0, 36,
0, 1, 0, 36, 0, 0, 0, 0, 0, 1, 2, 254, 255, 81, 0, 0, 5, 1, 0,
15, 160, 0, 0, 0, 0, 0, 0, 128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 31,
0, 0, 2, 5, 0, 0, 128, 0, 0, 15, 144, 31, 0, 0, 2, 5, 0, 1, 128,
1, 0, 15, 144, 2, 0, 0, 3, 0, 0, 3, 192, 0, 0, 228, 144, 0, 0, 228,
160, 1, 0, 0, 2, 0, 0, 12, 192, 1, 0, 68, 160, 1, 0, 0, 2, 0, 0,
3, 224, 1, 0, 228, 144, 255, 255, 0, 0, 83, 72, 68, 82, 136, 0, 0, 0, 64,
0, 1, 0, 34, 0, 0, 0, 95, 0, 0, 3, 50, 16, 16, 0, 0, 0, 0, 0,
95, 0, 0, 3, 50, 16, 16, 0, 1, 0, 0, 0, 103, 0, 0, 4, 242, 32, 16,
0, 0, 0, 0, 0, 1, 0, 0, 0, 101, 0, 0, 3, 50, 32, 16, 0, 1, 0,
0, 0, 54, 0, 0, 5, 50, 32, 16, 0, 0, 0, 0, 0, 70, 16, 16, 0, 0,
0, 0, 0, 54, 0, 0, 8, 194, 32, 16, 0, 0, 0, 0, 0, 2, 64, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 63, 54, 0, 0,
5, 50, 32, 16, 0, 1, 0, 0, 0, 70, 16, 16, 0, 1, 0, 0, 0, 62, 0,
0, 1, 83, 84, 65, 84, 116, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 68, 69, 70, 68, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 0, 0, 0, 0, 4,
254, 255, 0, 1, 0, 0, 28, 0, 0, 0, 77, 105, 99, 114, 111, 115, 111, 102, 116,
32, 40, 82, 41, 32, 72, 76, 83, 76, 32, 83, 104, 97, 100, 101, 114, 32, 67, 111,
109, 112, 105, 108, 101, 114, 32, 49, 48, 46, 49, 0, 73, 83, 71, 78, 76, 0, 0,
0, 2, 0, 0, 0, 8, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 3, 3, 0, 0, 65, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 3, 3, 0, 0,
80, 79, 83, 73, 84, 73, 79, 78, 0, 84, 69, 88, 67, 79, 79, 82, 68, 0, 171,
171, 79, 83, 71, 78, 80, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 56, 0,
0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 15,
0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0,
1, 0, 0, 0, 3, 12, 0, 0, 83, 86, 95, 80, 79, 83, 73, 84, 73, 79, 78,
0, 84, 69, 88, 67, 79, 79, 82, 68, 0, 171, 171, 171};
|
ea267eb45b624c99301caad1bf5584937768cae9
|
091a6200be74bf6577c86f623665bcc24e16b02b
|
/Arcade_Synth_Controller/midi_to_freq.h
|
3ad25dada604d00794ecdf6bfbd2ff4141829a71
|
[
"MIT"
] |
permissive
|
adafruit/Adafruit_Learning_System_Guides
|
b5f7bce40a16da64e7a79d4b39de032f2cca41d4
|
5eaa7a15a437c533b89f359a25983e24bb6b5438
|
refs/heads/main
| 2023-09-05T18:31:41.621956
| 2023-09-05T15:36:09
| 2023-09-05T15:36:09
| 105,065,494
| 937
| 937
|
MIT
| 2023-09-12T18:48:53
| 2017-09-27T20:22:44
|
C
|
UTF-8
|
C
| false
| false
| 1,813
|
h
|
midi_to_freq.h
|
// SPDX-FileCopyrightText: 2022 John Park for Adafruit Industries
//
// SPDX-License-Identifier: MIT
// from Audio/examples/Synthesis/PlaySynthMusic
// This is for the Teensy Audio library which specifies
// frequencies as floating point. See make_notetab.xlsx
const float tune_frequencies2_PGM[128] =
{
8.1758, 8.6620, 9.1770, 9.7227, 10.3009, 10.9134, 11.5623, 12.2499,
12.9783, 13.7500, 14.5676, 15.4339, 16.3516, 17.3239, 18.3540, 19.4454,
20.6017, 21.8268, 23.1247, 24.4997, 25.9565, 27.5000, 29.1352, 30.8677,
32.7032, 34.6478, 36.7081, 38.8909, 41.2034, 43.6535, 46.2493, 48.9994,
51.9131, 55.0000, 58.2705, 61.7354, 65.4064, 69.2957, 73.4162, 77.7817,
82.4069, 87.3071, 92.4986, 97.9989, 103.8262, 110.0000, 116.5409, 123.4708,
130.8128, 138.5913, 146.8324, 155.5635, 164.8138, 174.6141, 184.9972, 195.9977,
207.6523, 220.0000, 233.0819, 246.9417, 261.6256, 277.1826, 293.6648, 311.1270,
329.6276, 349.2282, 369.9944, 391.9954, 415.3047, 440.0000, 466.1638, 493.8833,
523.2511, 554.3653, 587.3295, 622.2540, 659.2551, 698.4565, 739.9888, 783.9909,
830.6094, 880.0000, 932.3275, 987.7666, 1046.5023, 1108.7305, 1174.6591, 1244.5079,
1318.5102, 1396.9129, 1479.9777, 1567.9817, 1661.2188, 1760.0000, 1864.6550, 1975.5332,
2093.0045, 2217.4610, 2349.3181, 2489.0159, 2637.0205, 2793.8259, 2959.9554, 3135.9635,
3322.4376, 3520.0000, 3729.3101, 3951.0664, 4186.0090, 4434.9221, 4698.6363, 4978.0317,
5274.0409, 5587.6517, 5919.9108, 6271.9270, 6644.8752, 7040.0000, 7458.6202, 7902.1328,
8372.0181, 8869.8442, 9397.2726, 9956.0635, 10548.0818, 11175.3034, 11839.8215, 12543.8540
};
|
cbad78e5c1292eaa102e4d6e9af70f0922e924a9
|
1cab595bbad73391188c5d02a0a6d700f810ef0d
|
/mcp251xfd/mcp251xfd-dev-coredump.c
|
0349d223900b28355bde99bc0e5597d6dddb27cb
|
[] |
no_license
|
linux-can/can-utils
|
072580688ac6ad1744c59b3ecdfcafa1c4951e9f
|
33b2ae6f88681ebe8a362a88c8e60dc03b620313
|
refs/heads/master
| 2023-09-01T11:49:20.696331
| 2023-08-28T14:19:46
| 2023-08-28T14:19:46
| 31,673,071
| 2,062
| 729
| null | 2023-09-10T20:06:31
| 2015-03-04T18:34:07
|
C
|
UTF-8
|
C
| false
| false
| 5,739
|
c
|
mcp251xfd-dev-coredump.c
|
// SPDX-License-Identifier: GPL-2.0
//
// Microchip MCP251xFD Family CAN controller debug tool
//
// Copyright (c) 2020, 2021 Pengutronix,
// Marc Kleine-Budde <kernel@pengutronix.de>
//
#include <endian.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#include <linux/kernel.h>
#include "lib.h"
#include "mcp251xfd.h"
#include "mcp251xfd-dump-userspace.h"
struct mcp251xfd_dump_iter {
const void *start;
const struct mcp251xfd_dump_object_header *hdr;
const void *object_start;
const void *object_end;
};
const char *
get_object_type_str(enum mcp251xfd_dump_object_type object_type)
{
switch (object_type) {
case MCP251XFD_DUMP_OBJECT_TYPE_REG:
return "REG";
case MCP251XFD_DUMP_OBJECT_TYPE_TEF:
return "TEF";
case MCP251XFD_DUMP_OBJECT_TYPE_RX:
return "RX";
case MCP251XFD_DUMP_OBJECT_TYPE_TX:
return "TX";
case MCP251XFD_DUMP_OBJECT_TYPE_END:
return "END";
default:
return "<unknown>";
}
}
static __attribute__((__unused__)) const char *
get_ring_key_str(enum mcp251xfd_dump_object_ring_key key)
{
switch (key) {
case MCP251XFD_DUMP_OBJECT_RING_KEY_HEAD:
return "head";
case MCP251XFD_DUMP_OBJECT_RING_KEY_TAIL:
return "tail";
case MCP251XFD_DUMP_OBJECT_RING_KEY_BASE:
return "base";
case MCP251XFD_DUMP_OBJECT_RING_KEY_NR:
return "nr";
case MCP251XFD_DUMP_OBJECT_RING_KEY_FIFO_NR:
return "fifo-nr";
case MCP251XFD_DUMP_OBJECT_RING_KEY_OBJ_NUM:
return "obj-num";
case MCP251XFD_DUMP_OBJECT_RING_KEY_OBJ_SIZE:
return "obj-size";
default:
return "<unknown>";
}
}
static int
do_dev_coredump_read_reg(const struct mcp251xfd_priv *priv,
const struct mcp251xfd_dump_iter *iter,
struct mcp251xfd_mem *mem)
{
const struct mcp251xfd_dump_object_reg *object;
for (object = iter->object_start;
(void *)(object + 1) <= iter->object_end;
object++) {
uint32_t reg, val;
reg = le32toh(object->reg);
val = le32toh(object->val);
pr_debug("%s: offset=0x%04zx reg=0x%04x - val=0x%08x\n",
__func__,
(void *)object - iter->start,
reg, val);
if (reg > ARRAY_SIZE(mem->buf))
return -EINVAL;
*(uint32_t *)(mem->buf + reg) = val;
}
return 0;
}
static int
do_dev_coredump_read_ring(const struct mcp251xfd_priv *priv,
const struct mcp251xfd_dump_iter *iter,
struct mcp251xfd_ring *ring)
{
const struct mcp251xfd_dump_object_reg *object;
for (object = iter->object_start;
(void *)(object + 1) <= iter->object_end;
object++) {
enum mcp251xfd_dump_object_ring_key key;
uint32_t val;
key = le32toh(object->reg);
val = le32toh(object->val);
pr_debug("%s: offset=0x%04zx key=0x%02x: %8s - val=0x%08x\n",
__func__,
(void *)object - iter->start,
key, get_ring_key_str(key), val);
switch (key) {
case MCP251XFD_DUMP_OBJECT_RING_KEY_HEAD:
ring->head = val;
break;
case MCP251XFD_DUMP_OBJECT_RING_KEY_TAIL:
ring->tail = val;
break;
case MCP251XFD_DUMP_OBJECT_RING_KEY_BASE:
ring->base = val;
break;
case MCP251XFD_DUMP_OBJECT_RING_KEY_NR:
ring->nr = val;
break;
case MCP251XFD_DUMP_OBJECT_RING_KEY_FIFO_NR:
ring->fifo_nr = val;
break;
case MCP251XFD_DUMP_OBJECT_RING_KEY_OBJ_NUM:
ring->obj_num = val;
break;
case MCP251XFD_DUMP_OBJECT_RING_KEY_OBJ_SIZE:
ring->obj_size = val;
break;
default:
continue;
}
}
return 0;
}
static int
do_dev_coredump_read(struct mcp251xfd_priv *priv,
struct mcp251xfd_mem *mem,
const void *dump, size_t dump_len)
{
struct mcp251xfd_dump_iter iter[] = {
{
.start = dump,
.hdr = dump,
},
};
while ((void *)(iter->hdr + 1) <= iter->start + dump_len &&
le32toh(iter->hdr->magic) == MCP251XFD_DUMP_MAGIC) {
const struct mcp251xfd_dump_object_header *hdr = iter->hdr;
enum mcp251xfd_dump_object_type object_type;
struct mcp251xfd_ring ring;
size_t object_offset, object_len;
int err;
object_type = le32toh(hdr->type);
object_offset = le32toh(hdr->offset);
object_len = le32toh(hdr->len);
if (object_offset + object_len > dump_len)
return -EFAULT;
iter->object_start = iter->start + object_offset;
iter->object_end = iter->object_start + object_len;
mcp251xfd_dump_ring_init(&ring);
pr_debug("%s: hdr=0x%04zx type=0x%08x: %8s - offset=0x%04zx len=0x%04zx end=0x%04zx\n",
__func__,
(void *)iter->hdr - iter->start,
object_type, get_object_type_str(object_type),
object_offset, object_len, object_offset + object_len);
switch (object_type) {
case MCP251XFD_DUMP_OBJECT_TYPE_REG:
err = do_dev_coredump_read_reg(priv, iter, mem);
break;
case MCP251XFD_DUMP_OBJECT_TYPE_TEF:
case MCP251XFD_DUMP_OBJECT_TYPE_RX:
case MCP251XFD_DUMP_OBJECT_TYPE_TX:
err = do_dev_coredump_read_ring(priv, iter, &ring);
if (err)
return err;
if (ring.fifo_nr >= ARRAY_SIZE(priv->ring))
return -EINVAL;
priv->ring[ring.fifo_nr] = ring;
break;
case MCP251XFD_DUMP_OBJECT_TYPE_END:
return 0;
default:
return -EINVAL;
}
if (err)
return err;
iter->hdr++;
}
return -EINVAL;
}
int mcp251xfd_dev_coredump_read(struct mcp251xfd_priv *priv,
struct mcp251xfd_mem *mem,
const char *dump_path)
{
struct stat statbuf;
size_t dump_len;
void *dump;
int fd, err;
fd = open(dump_path, O_RDONLY);
if (fd < 0)
return -errno;
err = fstat(fd, &statbuf);
if (err < 0) {
err = -errno;
goto out_close;
}
dump_len = statbuf.st_size;
dump = mmap(NULL, dump_len, PROT_READ, MAP_SHARED, fd, 0x0);
if (dump == MAP_FAILED) {
err = -errno;
goto out_close;
}
err = do_dev_coredump_read(priv, mem, dump, dump_len);
munmap(dump, dump_len);
out_close:
close(fd);
return err;
}
|
1ce54e61dc5c88f06a123f04a18b0257ad46d1b6
|
e814383d36a10839104efaa4df277996ab220fa3
|
/opal/util/if.c
|
c16d3e693442aa0df6fcdc88b5c8be51b037e132
|
[
"mpich2",
"BSD-3-Clause-Open-MPI"
] |
permissive
|
open-mpi/ompi
|
a1d7483ae1d83dd8fd8ae3ee95e832e0a0ee04e3
|
1edfdb025c4450f694600083ad871cf06c8d45cd
|
refs/heads/main
| 2023-09-01T01:30:02.040705
| 2023-08-29T17:32:18
| 2023-08-29T17:32:18
| 24,107,001
| 2,008
| 973
|
NOASSERTION
| 2023-09-14T20:59:26
| 2014-09-16T16:08:30
|
C
|
UTF-8
|
C
| false
| false
| 20,903
|
c
|
if.c
|
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2009 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2010-2022 Cisco Systems, Inc. All rights reserved
* Copyright (c) 2014-2017 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2015-2016 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "opal_config.h"
#include <string.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <errno.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_SYS_SOCKIO_H
# include <sys/sockio.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_NET_IF_H
# include <net/if.h>
#endif
#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif
#ifdef HAVE_IFADDRS_H
# include <ifaddrs.h>
#endif
#include <ctype.h>
#include "opal/class/opal_list.h"
#include "opal/constants.h"
#include "opal/util/argv.h"
#include "opal/util/if.h"
#include "opal/util/net.h"
#include "opal/util/output.h"
#include "opal/util/show_help.h"
#include "opal/util/string_copy.h"
#include "opal/mca/if/base/base.h"
#ifdef HAVE_STRUCT_SOCKADDR_IN
# ifndef MIN
# define MIN(a, b) ((a) < (b) ? (a) : (b))
# endif
/*
* Look for interface by name and returns its address
* as a dotted decimal formatted string.
*/
int opal_ifnametoaddr(const char *if_name, struct sockaddr *addr, int length)
{
opal_if_t *intf;
OPAL_LIST_FOREACH (intf, &opal_if_list, opal_if_t) {
if (strcmp(intf->if_name, if_name) == 0) {
memcpy(addr, &intf->if_addr, length);
return OPAL_SUCCESS;
}
}
return OPAL_ERROR;
}
/*
* Look for interface by name and returns its
* corresponding opal_list index.
*/
int opal_ifnametoindex(const char *if_name)
{
opal_if_t *intf;
OPAL_LIST_FOREACH (intf, &opal_if_list, opal_if_t) {
if (strcmp(intf->if_name, if_name) == 0) {
return intf->if_index;
}
}
return -1;
}
/*
* Look for interface by name and returns its
* corresponding kernel index.
*/
int opal_ifnametokindex(const char *if_name)
{
opal_if_t *intf;
OPAL_LIST_FOREACH (intf, &opal_if_list, opal_if_t) {
if (strcmp(intf->if_name, if_name) == 0) {
return intf->if_kernel_index;
}
}
return -1;
}
/*
* Look for interface by opal_list index and returns its
* corresponding kernel index.
*/
int opal_ifindextokindex(int if_index)
{
opal_if_t *intf;
OPAL_LIST_FOREACH (intf, &opal_if_list, opal_if_t) {
if (if_index == intf->if_index) {
return intf->if_kernel_index;
}
}
return -1;
}
/*
* Attempt to resolve the address (given as either IPv4/IPv6 string
* or hostname) and lookup corresponding interface.
*/
int opal_ifaddrtoname(const char *if_addr, char *if_name, int length)
{
opal_if_t *intf;
int error;
struct addrinfo hints, *res = NULL, *r;
/* if the user asked us not to resolve interfaces, then just return */
if (opal_if_do_not_resolve) {
/* return not found so ifislocal will declare
* the node to be non-local
*/
return OPAL_ERR_NOT_FOUND;
}
memset(&hints, 0, sizeof(hints));
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
error = getaddrinfo(if_addr, NULL, &hints, &res);
if (error) {
if (NULL != res) {
freeaddrinfo(res);
}
return OPAL_ERR_NOT_FOUND;
}
for (r = res; r != NULL; r = r->ai_next) {
OPAL_LIST_FOREACH (intf, &opal_if_list, opal_if_t) {
if (AF_INET == r->ai_family) {
struct sockaddr_in ipv4;
struct sockaddr_in *inaddr;
inaddr = (struct sockaddr_in *) &intf->if_addr;
memcpy(&ipv4, r->ai_addr, r->ai_addrlen);
if (inaddr->sin_addr.s_addr == ipv4.sin_addr.s_addr) {
opal_string_copy(if_name, intf->if_name, length);
freeaddrinfo(res);
return OPAL_SUCCESS;
}
}
# if OPAL_ENABLE_IPV6
else {
if (IN6_ARE_ADDR_EQUAL(&((struct sockaddr_in6 *) &intf->if_addr)->sin6_addr,
&((struct sockaddr_in6 *) r->ai_addr)->sin6_addr)) {
opal_string_copy(if_name, intf->if_name, length);
freeaddrinfo(res);
return OPAL_SUCCESS;
}
}
# endif
}
}
if (NULL != res) {
freeaddrinfo(res);
}
/* if we get here, it wasn't found */
return OPAL_ERR_NOT_FOUND;
}
/*
* Attempt to resolve the address (given as either IPv4/IPv6 string
* or hostname) and return the kernel index of the interface
* on the same network as the specified address
*/
int opal_ifaddrtokindex(const char *if_addr)
{
opal_if_t *intf;
int error;
struct addrinfo hints, *res = NULL, *r;
int if_kernel_index;
size_t len;
memset(&hints, 0, sizeof(hints));
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
error = getaddrinfo(if_addr, NULL, &hints, &res);
if (error) {
if (NULL != res) {
freeaddrinfo(res);
}
return OPAL_ERR_NOT_FOUND;
}
for (r = res; r != NULL; r = r->ai_next) {
OPAL_LIST_FOREACH (intf, &opal_if_list, opal_if_t) {
if (AF_INET == r->ai_family && AF_INET == intf->af_family) {
struct sockaddr_in ipv4;
len = (r->ai_addrlen < sizeof(struct sockaddr_in)) ? r->ai_addrlen
: sizeof(struct sockaddr_in);
memcpy(&ipv4, r->ai_addr, len);
if (opal_net_samenetwork((struct sockaddr *) &ipv4,
(struct sockaddr *) &intf->if_addr, intf->if_mask)) {
if_kernel_index = intf->if_kernel_index;
freeaddrinfo(res);
return if_kernel_index;
}
}
# if OPAL_ENABLE_IPV6
else if (AF_INET6 == r->ai_family && AF_INET6 == intf->af_family) {
struct sockaddr_in6 ipv6;
len = (r->ai_addrlen < sizeof(struct sockaddr_in6)) ? r->ai_addrlen
: sizeof(struct sockaddr_in6);
memcpy(&ipv6, r->ai_addr, len);
if (opal_net_samenetwork((struct sockaddr *) ((struct sockaddr_in6 *) &intf
->if_addr),
(struct sockaddr *) &ipv6, intf->if_mask)) {
if_kernel_index = intf->if_kernel_index;
freeaddrinfo(res);
return if_kernel_index;
}
}
# endif
}
}
if (NULL != res) {
freeaddrinfo(res);
}
return OPAL_ERR_NOT_FOUND;
}
/*
* Return the number of discovered interface.
*/
int opal_ifcount(void)
{
return opal_list_get_size(&opal_if_list);
}
/*
* Return the opal_list interface index for the first
* interface in our list.
*/
int opal_ifbegin(void)
{
opal_if_t *intf;
intf = (opal_if_t *) opal_list_get_first(&opal_if_list);
if (NULL != intf) {
return intf->if_index;
}
return (-1);
}
/*
* Located the current position in the list by if_index and
* return the interface index of the next element in our list
* (if it exists).
*/
int opal_ifnext(int if_index)
{
opal_if_t *intf;
OPAL_LIST_FOREACH (intf, &opal_if_list, opal_if_t) {
if (intf->if_index == if_index) {
do {
opal_if_t *if_next = (opal_if_t *) opal_list_get_next(intf);
opal_if_t *if_end = (opal_if_t *) opal_list_get_end(&opal_if_list);
if (if_next == if_end) {
return -1;
}
intf = if_next;
} while (intf->if_index == if_index);
return intf->if_index;
}
}
return (-1);
}
/*
* Lookup the interface by opal_list index and return the
* primary address assigned to the interface.
*/
int opal_ifindextoaddr(int if_index, struct sockaddr *if_addr, unsigned int length)
{
opal_if_t *intf;
OPAL_LIST_FOREACH (intf, &opal_if_list, opal_if_t) {
if (intf->if_index == if_index) {
memcpy(if_addr, &intf->if_addr, MIN(length, sizeof(intf->if_addr)));
return OPAL_SUCCESS;
}
}
return OPAL_ERROR;
}
/*
* Lookup the interface by opal_list kindex and return the
* primary address assigned to the interface.
*/
int opal_ifkindextoaddr(int if_kindex, struct sockaddr *if_addr, unsigned int length)
{
opal_if_t *intf;
OPAL_LIST_FOREACH (intf, &opal_if_list, opal_if_t) {
if (intf->if_kernel_index == if_kindex) {
memcpy(if_addr, &intf->if_addr, MIN(length, sizeof(intf->if_addr)));
return OPAL_SUCCESS;
}
}
return OPAL_ERROR;
}
/*
* Lookup the interface by opal_list index and return the
* network mask assigned to the interface.
*/
int opal_ifindextomask(int if_index, uint32_t *if_mask, int length)
{
opal_if_t *intf;
OPAL_LIST_FOREACH (intf, &opal_if_list, opal_if_t) {
if (intf->if_index == if_index) {
memcpy(if_mask, &intf->if_mask, length);
return OPAL_SUCCESS;
}
}
return OPAL_ERROR;
}
/*
* Lookup the interface by opal_list index and return the
* MAC assigned to the interface.
*/
int opal_ifindextomac(int if_index, uint8_t mac[6])
{
opal_if_t *intf;
OPAL_LIST_FOREACH (intf, &opal_if_list, opal_if_t) {
if (intf->if_index == if_index) {
memcpy(mac, &intf->if_mac, 6);
return OPAL_SUCCESS;
}
}
return OPAL_ERROR;
}
/*
* Lookup the interface by opal_list index and return the
* MTU assigned to the interface.
*/
int opal_ifindextomtu(int if_index, int *mtu)
{
opal_if_t *intf;
OPAL_LIST_FOREACH (intf, &opal_if_list, opal_if_t) {
if (intf->if_index == if_index) {
*mtu = intf->ifmtu;
return OPAL_SUCCESS;
}
}
return OPAL_ERROR;
}
/*
* Lookup the interface by opal_list index and return the
* flags assigned to the interface.
*/
int opal_ifindextoflags(int if_index, uint32_t *if_flags)
{
opal_if_t *intf;
OPAL_LIST_FOREACH (intf, &opal_if_list, opal_if_t) {
if (intf->if_index == if_index) {
memcpy(if_flags, &intf->if_flags, sizeof(uint32_t));
return OPAL_SUCCESS;
}
}
return OPAL_ERROR;
}
/*
* Lookup the interface by opal_list index and return
* the associated name.
*/
int opal_ifindextoname(int if_index, char *if_name, int length)
{
opal_if_t *intf;
OPAL_LIST_FOREACH (intf, &opal_if_list, opal_if_t) {
if (intf->if_index == if_index) {
opal_string_copy(if_name, intf->if_name, length);
return OPAL_SUCCESS;
}
}
return OPAL_ERROR;
}
/*
* Lookup the interface by kernel index and return
* the associated name.
*/
int opal_ifkindextoname(int if_kindex, char *if_name, int length)
{
opal_if_t *intf;
OPAL_LIST_FOREACH (intf, &opal_if_list, opal_if_t) {
if (intf->if_kernel_index == if_kindex) {
opal_string_copy(if_name, intf->if_name, length);
return OPAL_SUCCESS;
}
}
return OPAL_ERROR;
}
# define ADDRLEN 100
bool opal_ifislocal(const char *hostname)
{
# if OPAL_ENABLE_IPV6
char addrname[NI_MAXHOST]; /* should be larger than ADDRLEN, but I think
they really mean IFNAMESIZE */
# else
char addrname[ADDRLEN + 1];
# endif
if (OPAL_SUCCESS == opal_ifaddrtoname(hostname, addrname, ADDRLEN)) {
return true;
}
return false;
}
static int parse_ipv4_dots(const char *addr, uint32_t *net, int *dots)
{
const char *start = addr, *end;
uint32_t n[] = {0, 0, 0, 0};
int i;
/* now assemble the address */
for (i = 0; i < 4; i++) {
n[i] = strtoul(start, (char **) &end, 10);
if (end == start) {
/* this is not an error, but indicates that
* we were given a partial address - e.g.,
* 192.168 - usually indicating an IP range
* in CIDR notation. So just return what we have
*/
break;
}
/* did we read something sensible? */
if (n[i] > 255) {
return OPAL_ERR_NETWORK_NOT_PARSEABLE;
}
/* skip all the . */
for (start = end; '\0' != *start; start++) {
if ('.' != *start) {
break;
}
}
}
*dots = i;
*net = OPAL_IF_ASSEMBLE_NETWORK(n[0], n[1], n[2], n[3]);
return OPAL_SUCCESS;
}
int opal_iftupletoaddr(const char *inaddr, uint32_t *net, uint32_t *mask)
{
int pval, dots, rc = OPAL_SUCCESS;
const char *ptr;
/* if a mask was desired... */
if (NULL != mask) {
/* set default */
*mask = 0xFFFFFFFF;
/* if entry includes mask, split that off */
if (NULL != (ptr = strchr(inaddr, '/'))) {
ptr = ptr + 1; /* skip the / */
/* is the mask a tuple? */
if (NULL != strchr(ptr, '.')) {
/* yes - extract mask from it */
rc = parse_ipv4_dots(ptr, mask, &dots);
} else {
/* no - must be an int telling us how much of the addr to use: e.g., /16
* For more information please read https://en.wikipedia.org/wiki/Subnetwork.
*/
pval = strtol(ptr, NULL, 10);
if ((pval > 31) || (pval < 1)) {
opal_output(0, "opal_iftupletoaddr: unknown mask");
return OPAL_ERR_NETWORK_NOT_PARSEABLE;
}
*mask = 0xFFFFFFFF << (32 - pval);
}
} else {
/* use the number of dots to determine it */
for (ptr = inaddr, pval = 0; '\0' != *ptr; ptr++) {
if ('.' == *ptr) {
pval++;
}
}
/* if we have three dots, then we have four
* fields since it is a full address, so the
* default netmask is fine
*/
if (3 == pval) {
*mask = 0xFFFFFFFF;
} else if (2 == pval) { /* 2 dots */
*mask = 0xFFFFFF00;
} else if (1 == pval) { /* 1 dot */
*mask = 0xFFFF0000;
} else if (0 == pval) { /* no dots */
*mask = 0xFF000000;
} else {
opal_output(0, "opal_iftupletoaddr: unknown mask");
return OPAL_ERR_NETWORK_NOT_PARSEABLE;
}
}
}
/* if network addr is desired... */
if (NULL != net) {
/* now assemble the address */
rc = parse_ipv4_dots(inaddr, net, &dots);
}
return rc;
}
/*
* Determine if the specified interface is loopback
*/
bool opal_ifisloopback(int if_index)
{
opal_if_t *intf;
OPAL_LIST_FOREACH (intf, &opal_if_list, opal_if_t) {
if (intf->if_index == if_index) {
if ((intf->if_flags & IFF_LOOPBACK) != 0) {
return true;
}
}
}
return false;
}
/* Determine if an interface matches any entry in the given list, taking
* into account that the list entries could be given as named interfaces,
* IP addrs, or subnet+mask
*/
int opal_ifmatches(int kidx, char **nets)
{
bool named_if;
int i, rc;
size_t j;
int kindex;
struct sockaddr_in inaddr;
uint32_t addr, netaddr, netmask;
/* get the address info for the given network in case we need it */
if (OPAL_SUCCESS
!= (rc = opal_ifkindextoaddr(kidx, (struct sockaddr *) &inaddr, sizeof(inaddr)))) {
return rc;
}
addr = ntohl(inaddr.sin_addr.s_addr);
for (i = 0; NULL != nets[i]; i++) {
/* if the specified interface contains letters in it, then it
* was given as an interface name and not an IP tuple
*/
named_if = false;
for (j = 0; j < strlen(nets[i]); j++) {
if (isalpha(nets[i][j]) && '.' != nets[i][j]) {
named_if = true;
break;
}
}
if (named_if) {
if (0 > (kindex = opal_ifnametokindex(nets[i]))) {
continue;
}
if (kindex == kidx) {
return OPAL_SUCCESS;
}
} else {
if (OPAL_SUCCESS != (rc = opal_iftupletoaddr(nets[i], &netaddr, &netmask))) {
opal_show_help("help-opal-util.txt", "invalid-net-mask", true, nets[i]);
return rc;
}
if (netaddr == (addr & netmask)) {
return OPAL_SUCCESS;
}
}
}
/* get here if not found */
return OPAL_ERR_NOT_FOUND;
}
void opal_ifgetaliases(char ***aliases)
{
opal_if_t *intf;
char ipv4[INET_ADDRSTRLEN];
struct sockaddr_in *addr;
# if OPAL_ENABLE_IPV6
char ipv6[INET6_ADDRSTRLEN];
struct sockaddr_in6 *addr6;
# endif
/* set default answer */
*aliases = NULL;
OPAL_LIST_FOREACH (intf, &opal_if_list, opal_if_t) {
addr = (struct sockaddr_in *) &intf->if_addr;
/* ignore purely loopback interfaces */
if ((intf->if_flags & IFF_LOOPBACK) != 0) {
continue;
}
if (addr->sin_family == AF_INET) {
inet_ntop(AF_INET, &(addr->sin_addr.s_addr), ipv4, INET_ADDRSTRLEN);
opal_argv_append_nosize(aliases, ipv4);
}
# if OPAL_ENABLE_IPV6
else {
addr6 = (struct sockaddr_in6 *) &intf->if_addr;
inet_ntop(AF_INET6, &(addr6->sin6_addr), ipv6, INET6_ADDRSTRLEN);
opal_argv_append_nosize(aliases, ipv6);
}
# endif
}
}
#else /* HAVE_STRUCT_SOCKADDR_IN */
/* if we don't have struct sockaddr_in, we don't have traditional
ethernet devices. Just make everything a no-op error call */
int opal_ifnametoaddr(const char *if_name, struct sockaddr *if_addr, int size)
{
return OPAL_ERR_NOT_SUPPORTED;
}
int opal_ifaddrtoname(const char *if_addr, char *if_name, int size)
{
return OPAL_ERR_NOT_SUPPORTED;
}
int opal_ifnametoindex(const char *if_name)
{
return OPAL_ERR_NOT_SUPPORTED;
}
int opal_ifnametokindex(const char *if_name)
{
return OPAL_ERR_NOT_SUPPORTED;
}
int opal_ifindextokindex(int if_index)
{
return OPAL_ERR_NOT_SUPPORTED;
}
int opal_ifcount(void)
{
return OPAL_ERR_NOT_SUPPORTED;
}
int opal_ifbegin(void)
{
return OPAL_ERR_NOT_SUPPORTED;
}
int opal_ifnext(int if_index)
{
return OPAL_ERR_NOT_SUPPORTED;
}
int opal_ifindextoname(int if_index, char *if_name, int length)
{
return OPAL_ERR_NOT_SUPPORTED;
}
int opal_ifkindextoname(int kif_index, char *if_name, int length)
{
return OPAL_ERR_NOT_SUPPORTED;
}
int opal_ifindextoaddr(int if_index, struct sockaddr *if_addr, unsigned int length)
{
return OPAL_ERR_NOT_SUPPORTED;
}
int opal_ifindextomask(int if_index, uint32_t *if_addr, int length)
{
return OPAL_ERR_NOT_SUPPORTED;
}
bool opal_ifislocal(const char *hostname)
{
return false;
}
int opal_iftupletoaddr(const char *inaddr, uint32_t *net, uint32_t *mask)
{
return 0;
}
int opal_ifmatches(int idx, char **nets)
{
return OPAL_ERR_NOT_SUPPORTED;
}
void opal_ifgetaliases(char ***aliases)
{
/* set default answer */
*aliases = NULL;
}
#endif /* HAVE_STRUCT_SOCKADDR_IN */
|
236923abcf6025050ab9474dc6068f5491f03577
|
88ae8695987ada722184307301e221e1ba3cc2fa
|
/third_party/xnnpack/src/src/xnnpack/vscaleexpminusmax.h
|
afb864b7995d091abfc5dfdf162bbcd1217d25a0
|
[
"Apache-2.0",
"LGPL-2.0-or-later",
"MIT",
"GPL-1.0-or-later",
"BSD-3-Clause",
"LicenseRef-scancode-generic-cla"
] |
permissive
|
iridium-browser/iridium-browser
|
71d9c5ff76e014e6900b825f67389ab0ccd01329
|
5ee297f53dc7f8e70183031cff62f37b0f19d25f
|
refs/heads/master
| 2023-08-03T16:44:16.844552
| 2023-07-20T15:17:00
| 2023-07-23T16:09:30
| 220,016,632
| 341
| 40
|
BSD-3-Clause
| 2021-08-13T13:54:45
| 2019-11-06T14:32:31
| null |
UTF-8
|
C
| false
| false
| 3,156
|
h
|
vscaleexpminusmax.h
|
// Copyright 2019 Google LLC
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.
#pragma once
#include <stddef.h>
#include <stdint.h>
#include <xnnpack/common.h>
#ifdef __cplusplus
extern "C" {
#endif
#define DECLARE_F32_VSCALEEXPMINUSMAX_UKERNEL_FUNCTION(fn_name) \
XNN_INTERNAL void fn_name( \
size_t n, \
const float* input, \
float* output, \
float scale, \
float max);
DECLARE_F32_VSCALEEXPMINUSMAX_UKERNEL_FUNCTION(xnn_f32_vscaleexpminusmax_ukernel__avx2_p5_x8)
DECLARE_F32_VSCALEEXPMINUSMAX_UKERNEL_FUNCTION(xnn_f32_vscaleexpminusmax_ukernel__avx2_p5_x16)
DECLARE_F32_VSCALEEXPMINUSMAX_UKERNEL_FUNCTION(xnn_f32_vscaleexpminusmax_ukernel__avx2_p5_x24)
DECLARE_F32_VSCALEEXPMINUSMAX_UKERNEL_FUNCTION(xnn_f32_vscaleexpminusmax_ukernel__avx2_p5_x32)
DECLARE_F32_VSCALEEXPMINUSMAX_UKERNEL_FUNCTION(xnn_f32_vscaleexpminusmax_ukernel__avx2_p5_x40)
DECLARE_F32_VSCALEEXPMINUSMAX_UKERNEL_FUNCTION(xnn_f32_vscaleexpminusmax_ukernel__avx2_p5_x48)
DECLARE_F32_VSCALEEXPMINUSMAX_UKERNEL_FUNCTION(xnn_f32_vscaleexpminusmax_ukernel__avx2_p5_x56)
DECLARE_F32_VSCALEEXPMINUSMAX_UKERNEL_FUNCTION(xnn_f32_vscaleexpminusmax_ukernel__avx2_p5_x64)
DECLARE_F32_VSCALEEXPMINUSMAX_UKERNEL_FUNCTION(xnn_f32_vscaleexpminusmax_ukernel__avx2_p5_x72)
DECLARE_F32_VSCALEEXPMINUSMAX_UKERNEL_FUNCTION(xnn_f32_vscaleexpminusmax_ukernel__avx2_p5_x80)
DECLARE_F32_VSCALEEXPMINUSMAX_UKERNEL_FUNCTION(xnn_f32_vscaleexpminusmax_ukernel__avx2_p5_x88)
DECLARE_F32_VSCALEEXPMINUSMAX_UKERNEL_FUNCTION(xnn_f32_vscaleexpminusmax_ukernel__avx2_p5_x96)
DECLARE_F32_VSCALEEXPMINUSMAX_UKERNEL_FUNCTION(xnn_f32_vscaleexpminusmax_ukernel__avx512f_p5_scalef_x16)
DECLARE_F32_VSCALEEXPMINUSMAX_UKERNEL_FUNCTION(xnn_f32_vscaleexpminusmax_ukernel__avx512f_p5_scalef_x32)
DECLARE_F32_VSCALEEXPMINUSMAX_UKERNEL_FUNCTION(xnn_f32_vscaleexpminusmax_ukernel__avx512f_p5_scalef_x48)
DECLARE_F32_VSCALEEXPMINUSMAX_UKERNEL_FUNCTION(xnn_f32_vscaleexpminusmax_ukernel__avx512f_p5_scalef_x64)
DECLARE_F32_VSCALEEXPMINUSMAX_UKERNEL_FUNCTION(xnn_f32_vscaleexpminusmax_ukernel__avx512f_p5_scalef_x80)
DECLARE_F32_VSCALEEXPMINUSMAX_UKERNEL_FUNCTION(xnn_f32_vscaleexpminusmax_ukernel__avx512f_p5_scalef_x96)
DECLARE_F32_VSCALEEXPMINUSMAX_UKERNEL_FUNCTION(xnn_f32_vscaleexpminusmax_ukernel__avx512f_p5_scalef_x112)
DECLARE_F32_VSCALEEXPMINUSMAX_UKERNEL_FUNCTION(xnn_f32_vscaleexpminusmax_ukernel__avx512f_p5_scalef_x128)
DECLARE_F32_VSCALEEXPMINUSMAX_UKERNEL_FUNCTION(xnn_f32_vscaleexpminusmax_ukernel__avx512f_p5_scalef_x144)
DECLARE_F32_VSCALEEXPMINUSMAX_UKERNEL_FUNCTION(xnn_f32_vscaleexpminusmax_ukernel__avx512f_p5_scalef_x160)
DECLARE_F32_VSCALEEXPMINUSMAX_UKERNEL_FUNCTION(xnn_f32_vscaleexpminusmax_ukernel__avx512f_p5_scalef_x176)
DECLARE_F32_VSCALEEXPMINUSMAX_UKERNEL_FUNCTION(xnn_f32_vscaleexpminusmax_ukernel__avx512f_p5_scalef_x192)
#ifdef __cplusplus
} /* extern "C" */
#endif
|
883c8106d34b9ae53106c67889a4213935710770
|
47cf1713963956b5cd247500b25da54544921534
|
/src/cordova-plugin-userbase/src/libscrypt/main.c
|
ab5acecf298807ee5732dfd85ccaae5bde5a4845
|
[
"BSD-2-Clause",
"MIT"
] |
permissive
|
smallbets/userbase
|
0ed057153418c1be1108991554223e1d882f0fd4
|
9dd581d20fd8f00296b141729d032d974df587b0
|
refs/heads/master
| 2023-08-05T22:30:33.724918
| 2023-07-28T06:18:33
| 2023-07-28T06:18:33
| 188,504,618
| 771
| 65
|
MIT
| 2023-03-02T02:16:47
| 2019-05-25T00:58:14
|
JavaScript
|
UTF-8
|
C
| false
| false
| 7,253
|
c
|
main.c
|
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include "b64.h"
#include "crypto_scrypt-hexconvert.h"
#include "libscrypt.h"
#define REF1 "fdbabe1c9d3472007856e7190d01e9fe7c6ad7cbc8237830e77376634b3731622eaf30d92e22a3886ff109279d9830dac727afb94a83ee6d8360cbdfa2cc0640"
#define REF2 "7023bdcb3afd7348461c06cd81fd38ebfda8fbba904f8e3ea9b543f6545da1f2d5432955613f0fcf62d49705242a9af9e61e85dc0d651e40dfcf017b45575887"
int main()
{
uint8_t hashbuf[SCRYPT_HASH_LEN];
char outbuf[132];
char mcf[SCRYPT_MCF_LEN];
char mcf2[SCRYPT_MCF_LEN];
char saltbuf[64];
int retval;
/**
* libscrypt_scrypt(passwd, passwdlen, salt, saltlen, N, r, p, buf, buflen):
* password; duh
* N: CPU AND RAM cost (first modifier)
* r: RAM Cost
* p: CPU cost (parallelisation)
* In short, N is your main performance modifier. Values of r = 8, p = 1 are
* standard unless you want to modify the CPU/RAM ratio.
int libscrypt_scrypt(const uint8_t *, size_t, const uint8_t *, size_t, uint64_t,
uint32_t, uint32_t, uint8_t *, size_t);
*/
printf("TEST ONE: Direct call to reference function with password 'password' and salt 'NaCL'\n");
retval = libscrypt_scrypt((uint8_t*)"password",strlen("password"), (uint8_t*)"NaCl", strlen("NaCl"), 1024, 8, 16, hashbuf, sizeof(hashbuf));
if(retval != 0)
{
printf("TEST ONE FAILED: Failed to create hash of \"password\"\\n");
exit(EXIT_FAILURE);
}
printf("TEST ONE: SUCCESSFUL\n");
printf("TEST ONE and a half: Review errno on invalid input\n");
retval = libscrypt_scrypt((uint8_t*)"password",strlen("password"), (uint8_t*)"NaCl", strlen("NaCl"), 47, 1, 1, hashbuf, sizeof(hashbuf));
if(retval != -1)
{
printf("TEST ONE FAILED: Failed to detect invalid input\n");
exit(EXIT_FAILURE);
}
printf("TEST ONE and a half: Successfully failed on error: %s\n", strerror(errno));
/* Convert the binary string to hex representation. Outbuf must be
* at least sizeof(hashbuf) * 2 + 1
* Returns 0 on fail, 1 on success
*/
printf("TEST TWO: Convert binary output to hex\n");
retval = libscrypt_hexconvert(hashbuf, sizeof(hashbuf), outbuf, sizeof(outbuf));
if(!retval)
{
printf("TEST TWO: FAILED\n");
exit(EXIT_FAILURE);
}
printf("TEST TWO: SUCCESSFUL, Hex output is:\n%s\n", outbuf);
printf("TEST THREE: Compare hex output to reference hash output\n");
/* REF1 is a reference vector from Colin's implementation. */
if(strcmp(outbuf, REF1) != 0)
{
printf("TEST THREE: FAILED to match reference on hash\n");
exit(EXIT_FAILURE);
}
else
{
printf("TEST THREE: SUCCESSUL, Test vector matched!\n");
}
printf("TEST FOUR: Direct call to reference function with pleaseletmein password and SodiumChloride as salt\n");
/* Tests 4-6 repeat tests 1-3 with a different reference vector */
retval = libscrypt_scrypt((uint8_t*)"pleaseletmein",strlen("pleaseletmein"), (uint8_t*)"SodiumChloride", strlen("SodiumChloride"), 16384, 8, 1, hashbuf, sizeof(hashbuf));
if(retval != 0)
{
printf("TEST FOUR FAILED: Failed to create hash of 'pleaseletmein'\n");
exit(EXIT_FAILURE);
}
printf("TEST FOUR: SUCCESSFUL\n");
/* Convert the binary string to hex representation. Outbuf must be
* at least sizeof(hashbuf) * 2 + 1
*/
printf("TEST FIVE: Convert binary output to hex\n");
retval = libscrypt_hexconvert(hashbuf, sizeof(hashbuf), outbuf, sizeof(outbuf));
if(!retval)
{
printf("TEST FIVE: FAILED\n");
exit(EXIT_FAILURE);
}
printf("TEST FIVE: SUCCESSFUL, Hex output is:\n%s\n", outbuf);
printf("TEST SIX: Compare hex output to reference hash output\n");
if(strcmp(outbuf, REF2) != 0)
{
printf("TEST SIX: FAILED to match reference on hash\n");
exit(EXIT_FAILURE);
}
else
{
printf("TEST SIX: SUCCESSUL, Test vector matched!\n");
}
/* This function will convert the binary output to BASE64. Although
* we converted to hex for the reference vectors, BASE64 is more useful.
* Returns -1 on error, else returns length.
* Correct buffer length can be determined using the below function if
retuired.
* char* dest = (char*) malloc(modp_b64_encode_len);
* Note that this is not an exported function
*/
printf("TEST SEVEN: BASE64 encoding the salt and hash output\n");
retval = libscrypt_b64_encode(hashbuf, sizeof(hashbuf), outbuf, sizeof(outbuf));
if(retval == -1)
{
printf("TEST SEVEN FAILED\n");
exit(EXIT_FAILURE);
}
retval = libscrypt_b64_encode((unsigned char*)"SodiumChloride", strlen("SodiumChloride"), saltbuf, sizeof(saltbuf));
if(retval == -1)
{
printf("TEST SEVEN FAILED\n");
exit(EXIT_FAILURE);
}
printf("TEST SEVEN: SUCCESSFUL\n");
printf("TEST EIGHT: Create an MCF format output\n");
/* Creates a standard format output
* int crypto_scrypt_mcf(uint32_t N, uint32_t r, uint32_t p, char *salt, char *hash, char *mcf);
* Returns 0 on error, most likely reason is log2(N) not an integer.
*/
retval = libscrypt_mcf(16384, 8, 1, saltbuf, outbuf, mcf);
if(!retval)
{
printf("TEST EIGHT FAILED\n");
exit(EXIT_FAILURE);
}
printf("TEST EIGHT: SUCCESSFUL, calculated mcf\n%s\n", mcf);
/* Since later calls to scrypt_check() butcher mcf, make a second */
strcpy(mcf2, mcf);
/* Couldn't be simpler - for a given mcf, check is the password is valid
* Returns < 0 on failure to calculate hash
* 0 if password incorrect
* >1 if password correct
*/
printf("TEST NINE: Password verify on given MCF\n");
retval = libscrypt_check(mcf, "pleaseletmein");
if(retval < 0)
{
printf("TEST NINE: FAILED, hash failed to calculate\n");
exit(EXIT_FAILURE);
}
if(retval == 0)
{
printf("TEST NINE: FAILED, claimed pleaseletmein hash claimed did not verify\n");
exit(EXIT_FAILURE);
}
/* retval >0 is a success */
printf("TEST NINE: SUCCESSFUL, tested pleaseletmein password\n");
printf("TEST TEN: Password verify on same MCF, incorrect password\n");
retval = libscrypt_check(mcf2, "pleasefailme");
if(retval < 0)
{
printf("TEST TEN: FAILED, hash failed to calculate\n");
exit(EXIT_FAILURE);
}
if(retval > 0)
{
printf("TEST TEN: FAILED, fail hash has passed\n");
exit(EXIT_FAILURE);
}
printf("TEST TEN: SUCCESSFUL, refused incorrect password\n");
printf("TEST ELEVEN: Testing salt generator\n");
retval = libscrypt_salt_gen((uint8_t*)saltbuf, SCRYPT_SALT_LEN);
if(retval == -1)
{
printf("TEST ELEVEN (salt generate) FAILED\n");
exit(EXIT_FAILURE);
}
retval = libscrypt_b64_encode((uint8_t*)saltbuf, SCRYPT_SALT_LEN, outbuf, sizeof(outbuf));
if(retval == -1)
{
printf("TEST ELEVEN (b64 encode) FAILED\n");
exit(EXIT_FAILURE);
}
printf("TEST ELEVEN: SUCCESSFUL, Generated %s\n", outbuf);
printf("TEST TWELVE: Simple hash creation\n");
retval = libscrypt_hash(outbuf, "My cats's breath smells like cat food", SCRYPT_N, SCRYPT_r, SCRYPT_p);
if(!retval)
{
printf("TEST TWELVE: FAILED, Failed to create simple hash\n");
exit(EXIT_FAILURE);
}
printf("TEST TWELVE: SUCCESSFUL. Received the following from simple hash:\n%s\n", outbuf);
printf("TEST THIRTEEN: Verify test twelve's hash\n");
retval = libscrypt_check(outbuf, "My cats's breath smells like cat food");
if (retval != 1) {
printf("TEST THIRTEEN: FAILED, hash not verified\n");
exit(EXIT_FAILURE);
}
printf("TEST THIRTEEN: SUCCESSFUL\n");
return 0;
}
|
69279d84b0d1a3a0906e5fbf4096ffd09ea1ec37
|
99bdb3251fecee538e0630f15f6574054dfc1468
|
/bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_port_disp.c
|
30da608bdc184e76bd067347cc267d555f75f2c5
|
[
"Zlib",
"LicenseRef-scancode-proprietary-license",
"MIT",
"BSD-3-Clause",
"X11",
"BSD-4-Clause-UC",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] |
permissive
|
RT-Thread/rt-thread
|
03a7c52c2aeb1b06a544143b0e803d72f47d1ece
|
3602f891211904a27dcbd51e5ba72fefce7326b2
|
refs/heads/master
| 2023-09-01T04:10:20.295801
| 2023-08-31T16:20:55
| 2023-08-31T16:20:55
| 7,408,108
| 9,599
| 5,805
|
Apache-2.0
| 2023-09-14T13:37:26
| 2013-01-02T14:49:21
|
C
|
UTF-8
|
C
| false
| false
| 2,350
|
c
|
lv_port_disp.c
|
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-10-18 Meco Man The first version
*/
#include <lvgl.h>
#include <board.h>
#include <drv_lcd.h>
// #define MY_DISP_HOR_RES LCD_W
// #define DISP_BUFFER_LINES 70
/*A static or global variable to store the buffers*/
static lv_disp_draw_buf_t disp_buf;
/*Descriptor of a display driver*/
static lv_disp_drv_t disp_drv;
/*Static or global buffer(s). The second buffer is optional*/
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
#pragma location=0x68000000
lv_color_t buf_1[LCD_H * LCD_W];
#elif defined ( __CC_ARM ) /* MDK ARM Compiler */
__attribute__((at(0x68000000))) lv_color_t buf_1[LCD_H * LCD_W];
#elif defined ( __clang__ ) /* MDK ARM Compiler v6 */
__attribute__((section(".ARM.__at_0x68000000"))) lv_color_t buf_1[LCD_H * LCD_W];
#elif defined ( __GNUC__ ) /* GNU Compiler */
lv_color_t buf_1[LCD_H * LCD_W] __attribute__((section(".MCUlcdgrambysram")));
#ifdef RT_USING_MEMHEAP_AS_HEAP
#error "You should modify this logic, such as use 'rt_malloc' to create lvgl buf"
#endif
#endif
/*Flush the content of the internal buffer the specific area on the display
*You can use DMA or any hardware acceleration to do this operation in the background but
*'lv_disp_flush_ready()' has to be called when finished.*/
static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
{
/* color_p is a buffer pointer; the buffer is provided by LVGL */
lcd_fill_array(area->x1, area->y1, area->x2, area->y2, color_p);
/*IMPORTANT!!!
*Inform the graphics library that you are ready with the flushing*/
lv_disp_flush_ready(disp_drv);
}
void lv_port_disp_init(void)
{
/*Initialize `disp_buf` with the buffer(s). With only one buffer use NULL instead buf_2 */
lv_disp_draw_buf_init(&disp_buf, buf_1, NULL, LCD_H * LCD_W);
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
/*Set the resolution of the display*/
disp_drv.hor_res = LCD_W;
disp_drv.ver_res = LCD_H;
/*Set a display buffer*/
disp_drv.draw_buf = &disp_buf;
/*Used to copy the buffer's content to the display*/
disp_drv.flush_cb = disp_flush;
/*Finally register the driver*/
lv_disp_drv_register(&disp_drv);
}
|
32856a66aa5e17db481d7911e92505f0da58f65d
|
a6f47c6b702055aa2cc1a9ee051017320a8c602b
|
/thirdparty/libvpx/vpx_mem/vpx_mem.c
|
b261fc0da11787570dd4c0b7bc7a448004feb5be
|
[
"FTL",
"Zlib",
"MIT",
"BSD-3-Clause",
"Bitstream-Vera",
"CC0-1.0",
"MPL-2.0",
"OFL-1.1",
"CC-BY-4.0",
"LicenseRef-scancode-unknown-license-reference",
"Unlicense",
"BSL-1.0",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"LicenseRef-scancode-free-unknown",
"Libpng"
] |
permissive
|
Stary2001/godot
|
849ca3045a687d9b34de7cc24a8b6d26f89f95bc
|
00c6ce9716ed542997bc2b59136bceb3729db970
|
refs/heads/3.5.2-stable_switch
| 2023-05-25T08:38:55.387308
| 2023-04-14T23:07:10
| 2023-04-23T20:32:29
| 148,190,960
| 306
| 38
|
MIT
| 2023-05-19T20:10:22
| 2018-09-10T17:11:15
|
C++
|
UTF-8
|
C
| false
| false
| 2,593
|
c
|
vpx_mem.c
|
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "vpx_mem.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "include/vpx_mem_intrnl.h"
#include "vpx/vpx_integer.h"
void *vpx_memalign(size_t align, size_t size) {
void *addr,
* x = NULL;
addr = malloc(size + align - 1 + ADDRESS_STORAGE_SIZE);
if (addr) {
x = align_addr((unsigned char *)addr + ADDRESS_STORAGE_SIZE, (int)align);
/* save the actual malloc address */
((size_t *)x)[-1] = (size_t)addr;
}
return x;
}
void *vpx_malloc(size_t size) {
return vpx_memalign(DEFAULT_ALIGNMENT, size);
}
void *vpx_calloc(size_t num, size_t size) {
void *x;
x = vpx_memalign(DEFAULT_ALIGNMENT, num * size);
if (x)
memset(x, 0, num * size);
return x;
}
void *vpx_realloc(void *memblk, size_t size) {
void *addr,
* new_addr = NULL;
int align = DEFAULT_ALIGNMENT;
/*
The realloc() function changes the size of the object pointed to by
ptr to the size specified by size, and returns a pointer to the
possibly moved block. The contents are unchanged up to the lesser
of the new and old sizes. If ptr is null, realloc() behaves like
malloc() for the specified size. If size is zero (0) and ptr is
not a null pointer, the object pointed to is freed.
*/
if (!memblk)
new_addr = vpx_malloc(size);
else if (!size)
vpx_free(memblk);
else {
addr = (void *)(((size_t *)memblk)[-1]);
memblk = NULL;
new_addr = realloc(addr, size + align + ADDRESS_STORAGE_SIZE);
if (new_addr) {
addr = new_addr;
new_addr = (void *)(((size_t)
((unsigned char *)new_addr + ADDRESS_STORAGE_SIZE) + (align - 1)) &
(size_t) - align);
/* save the actual malloc address */
((size_t *)new_addr)[-1] = (size_t)addr;
}
}
return new_addr;
}
void vpx_free(void *memblk) {
if (memblk) {
void *addr = (void *)(((size_t *)memblk)[-1]);
free(addr);
}
}
#if CONFIG_VP9_HIGHBITDEPTH
void *vpx_memset16(void *dest, int val, size_t length) {
size_t i;
uint16_t *dest16 = (uint16_t *)dest;
for (i = 0; i < length; i++)
*dest16++ = val;
return dest;
}
#endif // CONFIG_VP9_HIGHBITDEPTH
|
be845ec35b9afd07c6cf6af0a121d578646d99c6
|
39963c49c030b0c30f43f878e9a7e1081ad7783c
|
/include/visionaray/math/simd/simd.h
|
bd6f1ef79d183bd06215866b7f2e519fe3cc8899
|
[
"MIT"
] |
permissive
|
szellmann/visionaray
|
f93e9fb58ad93ed4a601000af2cb60d8757954eb
|
e2ac5cc7f78642223b0670dce781a4a6125e7071
|
refs/heads/master
| 2023-09-06T05:14:27.266396
| 2023-09-03T01:04:56
| 2023-09-03T01:04:56
| 29,935,622
| 446
| 42
|
MIT
| 2020-10-16T17:28:43
| 2015-01-27T21:24:30
|
C++
|
UTF-8
|
C
| false
| false
| 368
|
h
|
simd.h
|
// This file is distributed under the MIT license.
// See the LICENSE file for details.
#pragma once
#ifndef VSNRAY_MATH_SIMD_H
#define VSNRAY_MATH_SIMD_H 1
#include "avx.h"
#include "avx512.h"
#include "builtin.h"
#include "forward.h"
#include "gather.h"
#include "neon.h"
#include "sse.h"
#include "trans.h"
#include "type_traits.h"
#endif // VSNRAY_MATH_SIMD_H
|
292981ca29c677bace7e55c551e8c4f4fc624e92
|
8b98cd47f934d2a4a8d0b2842d3277b01f3fb7fa
|
/libraries/hds/fortran_interface.c
|
2b0cdc024439de80ecbc50a26223692e7fedb349
|
[] |
no_license
|
Starlink/starlink
|
1cc03b85eb78330a3622003b26b69c1733df50fe
|
2c374b3e97c9cebcc8f3bd2f8b4bb326eefe061a
|
refs/heads/master
| 2023-07-26T09:32:27.987319
| 2023-07-05T23:56:27
| 2023-07-05T23:56:27
| 5,169,323
| 139
| 45
| null | 2022-11-18T13:29:32
| 2012-07-24T18:15:25
|
Fortran
|
UTF-8
|
C
| false
| false
| 171,583
|
c
|
fortran_interface.c
|
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include "f77.h" /* F77 <-> C interface macros */
#include "hds1_types.h"
#define HDS_INTERNAL_INCLUDES 1
#include "hds.h" /* HDS C interface */
#include "dat_par.h" /* DAT__ constant definitions */
#include "ems.h"
#include "ems_par.h"
#include "dat_err.h"
#include "hds_fortran.h" /* Fortran import/export */
#define TRUE 1
#define FALSE 0
#define SAI__OK 0
/* ------------------------------------------ */
/* Routines that have no hdsdim arguments */
/* ------------------------------------------ */
F77_SUBROUTINE(dat_annul)( CHARACTER(locator),
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*===========================*/
/* DAT_ANNUL - Annul locator */
/*===========================*/
/* Local variable */
HDSLoc *locator_c = NULL;
/* Enter routine. */
/* Import the locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Call pure C routine */
datAnnul( &locator_c, status);
/* Export returned locator */
datExportFloc( &locator_c, 1, locator_length, locator, status );
}
F77_SUBROUTINE(dat_ccopy)( CHARACTER(locator1),
CHARACTER(locator2),
CHARACTER(name),
CHARACTER(locator3),
F77_INTEGER_TYPE *status
TRAIL(locator1)
TRAIL(locator2)
TRAIL(name)
TRAIL(locator3) )
{
/*======================================*/
/* DAT_CCOPY - copy one structure level */
/*======================================*/
/* Local variables. */
HDSLoc *locator1_c = NULL;
HDSLoc *locator2_c = NULL;
HDSLoc *locator3_c = NULL;
char name_c[DAT__SZNAM+1];
/* Enter routine. */
/* Import maxmimum length strings */
cnfImpn( name, name_length, DAT__SZNAM, name_c);
/* Import the input locator strings */
datImportFloc( locator1, locator1_length, &locator1_c, status );
datImportFloc( locator2, locator2_length, &locator2_c, status );
/* Call pure C routine */
datCcopy( locator1_c, locator2_c, name_c, &locator3_c, status);
/* Export returned locator */
datExportFloc( &locator3_c, 1, locator3_length, locator3, status );
}
F77_SUBROUTINE(dat_cctyp)( INTEGER(size), CHARACTER(type)
TRAIL(type) )
{
/*============================================*/
/* DAT_CCTYP - Determine _CHAR*nnnn type */
/*============================================*/
char type_c[DAT__SZTYP+1];
datCctyp( *size, type_c );
cnfExprt( type_c, type, type_length );
}
F77_SUBROUTINE(dat_chscn)( CHARACTER(name),
INTEGER(status)
TRAIL(name) )
{
/*============================================================*/
/* DAT_CHSCN - Check and HDS component name for standard form */
/*============================================================*/
/* Local variables */
char * name_c;
/* Check status */
if (*status != SAI__OK) return;
/* import name into C */
name_c = cnfCreim( name, name_length );
/* Validate */
datChscn( name_c, status );
/* free allocated memory */
cnfFree( name_c );
}
F77_SUBROUTINE(dat_clen)( CHARACTER(locator),
F77_INTEGER_TYPE *clen,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*===========================================*/
/* DAT_CLEN - Obtain character string length */
/*===========================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
size_t len_c;
/* Enter routine. */
/* Import the locator string */
datImportFloc( locator, locator_length, &locator_c, status);
/* Call pure C routine */
datClen( locator_c, &len_c, status);
*clen = (F77_INTEGER_TYPE)len_c;
}
F77_SUBROUTINE(dat_clone)( CHARACTER(locator1),
CHARACTER(locator2),
F77_INTEGER_TYPE *status
TRAIL(locator1)
TRAIL(locator2) )
{
/*===========================*/
/* DAT_CLONE - clone locator */
/*===========================*/
/* Local variables */
HDSLoc *locator1_c = NULL;
HDSLoc *locator2_c = NULL;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator1, locator1_length, &locator1_c, status );
/* Call pure C routine */
datClone( locator1_c, &locator2_c, status);
/* Export the returned locator */
datExportFloc( &locator2_c, 1, locator2_length, locator2, status );
}
F77_SUBROUTINE(dat_coerc)( CHARACTER(locator1),
F77_INTEGER_TYPE *ndim,
CHARACTER(locator2),
F77_INTEGER_TYPE *status
TRAIL(locator1)
TRAIL(locator2) )
{
/*=================================*/
/* DAT_COERC - coerce object shape */
/*=================================*/
/* Local variables. */
HDSLoc *locator1_c = NULL;
HDSLoc *locator2_c = NULL;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator1, locator1_length, &locator1_c, status);
/* Call pure C routine */
datCoerc( locator1_c, *ndim, &locator2_c, status);
/* Export the returned locator */
datExportFloc( &locator2_c, 1, locator2_length, locator2, status );
}
F77_SUBROUTINE(dat_copy)( CHARACTER(locator1),
CHARACTER(locator2),
CHARACTER(name),
F77_INTEGER_TYPE *status
TRAIL(locator1)
TRAIL(locator2)
TRAIL(name) )
{
/*========================*/
/* DAT_COPY - copy object */
/*========================*/
/* Local variables. */
HDSLoc *locator1_c = NULL;
HDSLoc *locator2_c = NULL;
char name_c[DAT__SZNAM+1];
/* Enter routine. */
/* Import name string */
cnfImpn( name, name_length, DAT__SZNAM, name_c);
/* Import the locator strings */
datImportFloc( locator1, locator1_length, &locator1_c, status);
datImportFloc( locator2, locator2_length, &locator2_c, status);
/* Call pure C routine */
datCopy( locator1_c, locator2_c, name_c, status);
}
F77_SUBROUTINE(dat_cut)( CHARACTER(loc1),
CHARACTER(str),
CHARACTER(loc2),
F77_INTEGER_TYPE *status
TRAIL(loc1)
TRAIL(str)
TRAIL(loc2) )
{
/*==================================================*/
/* DAT_CUT - Cut a cell or slice from an HDS object */
/*==================================================*/
/* Local variables. */
char *str_c;
HDSLoc *loc1_c = NULL;
HDSLoc *loc2_c = NULL;
/* Create a null terminated copy of the supplied string. */
str_c = cnfCreim( str, str_length );
/* Import the input locator string. Translated DAT__ROOT to NULL since
datImportFloc doesnot recognised DAT_ROOT. */
if( strncmp( DAT__ROOT, loc1, loc1_length ) ) {
datImportFloc( loc1, loc1_length, &loc1_c, status );
}
/* Call pure C routine */
datCut( loc1_c, str_c, &loc2_c, status);
/* Free the null-terminated buffers. */
cnfFree( str_c );
/* Export the returned locator */
datExportFloc( &loc2_c, 1, loc2_length, loc2, status );
}
F77_SUBROUTINE(dat_drep)( CHARACTER(locator),
CHARACTER(format),
CHARACTER(order),
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(format)
TRAIL(order) )
{
/*=============================================================*/
/* DAT_DREP - Obtain primitive data representation information */
/*=============================================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char *format_c;
char *order_c;
/* Enter routine. */
/* Import the locator string */
datImportFloc( locator, locator_length, &locator_c, status);
/* Call pure C routine */
datDrep( locator_c, &format_c, &order_c, status);
/* Export the returned C strings to the FORTRAN variables */
if( *status == SAI__OK )
{
cnfExprt( format_c, format, format_length );
cnfExprt( order_c, order, order_length );
}
}
F77_SUBROUTINE(dat_dsame)( CHARACTER(loc1),
CHARACTER(loc2),
LOGICAL(same),
INTEGER(status )
TRAIL(loc1)
TRAIL(loc2) )
{
/*=============================================================*/
/* DAT_DSAME - Are two primitive data representations the same?*/
/*=============================================================*/
/* Local variables. */
HDSLoc *loc1_c = NULL;
HDSLoc *loc2_c = NULL;
hdsbool_t same_c;
/* Import the locator strings */
datImportFloc( loc1, loc1_length, &loc1_c, status);
datImportFloc( loc2, loc2_length, &loc2_c, status);
/* Call pure C routine */
datDsame( loc1_c, loc2_c, &same_c, status);
if( same_c )
*same = F77_TRUE;
else
*same = F77_FALSE;
}
F77_SUBROUTINE(dat_erase)( CHARACTER(locator),
CHARACTER(name),
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(name) )
{
/*=========================================*/
/* DAT_ERASE - Erase object */
/*=========================================*/
/* Local variables. */
char name_c[DAT__SZNAM+1];
HDSLoc * locator_c = NULL;
/* Enter routine. */
/* Import name string */
cnfImpn( name, name_length, DAT__SZNAM, name_c);
/* Import the locator string */
datImportFloc( locator, locator_length, &locator_c, status);
/* Call pure C routine */
datErase( locator_c, name_c, status);
}
F77_SUBROUTINE(dat_ermsg)( F77_INTEGER_TYPE *status,
F77_INTEGER_TYPE *length,
CHARACTER(msg)
TRAIL(msg) )
{
/*============================================================*/
/* DAT_ERMSG - Translate a status value into an error message */
/*============================================================*/
/* Local variables. */
char msg_c[EMS__SZMSG+1];
size_t length_c;
/* Enter routine. */
/* Call pure C routine */
datErmsg( *status, &length_c, msg_c );
/* Export the returned C string to FORTRAN variable */
*length = (F77_INTEGER_TYPE)length_c;
cnfExprt( msg_c, msg, msg_length );
}
F77_SUBROUTINE(dat_find)( CHARACTER(locator1),
CHARACTER(name),
CHARACTER(locator2),
F77_INTEGER_TYPE *status
TRAIL(locator1)
TRAIL(name)
TRAIL(locator2) )
{
/*=================================*/
/* DAT_FIND - Find named component */
/*=================================*/
/* Local variables. */
char name_c[DAT__SZNAM+1];
HDSLoc *locator1_c = NULL;
HDSLoc *locator2_c = NULL;
/* Enter routine. */
/* Import name string */
cnfImpn( name, name_length, DAT__SZNAM, name_c);
/* Import the input locator string */
datImportFloc( locator1, locator1_length, &locator1_c, status );
/* Call pure C routine */
datFind( locator1_c, name_c, &locator2_c, status);
/* Export the returned locator */
datExportFloc( &locator2_c, 1, locator2_length, locator2, status );
}
/* ================================== */
/* datGet0x */
/* ================================== */
F77_SUBROUTINE(dat_get0c)( CHARACTER(locator),
CHARACTER(value),
INTEGER(status)
TRAIL(locator)
TRAIL(value) )
{
HDSLoc * locator_c = NULL;
int cvalue_length;
char * value_c;
cvalue_length = value_length + 1;
value_c = cnfCreat( cvalue_length );
datImportFloc( locator, locator_length, &locator_c, status );
datGet0C( locator_c, value_c, cvalue_length, status );
cnfExprt( value_c, value, value_length );
cnfFree(value_c);
}
F77_SUBROUTINE(dat_get0d)( CHARACTER(locator),
DOUBLE(value),
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
datImportFloc( locator, locator_length, &locator_c, status );
datGet0D( locator_c, value, status );
}
F77_SUBROUTINE(dat_get0r)( CHARACTER(locator),
REAL(value),
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
datImportFloc( locator, locator_length, &locator_c, status );
datGet0R( locator_c, value, status );
}
F77_SUBROUTINE(dat_get0i)( CHARACTER(locator),
INTEGER(value),
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
datImportFloc( locator, locator_length, &locator_c, status );
datGet0I( locator_c, value, status );
}
F77_SUBROUTINE(dat_get0k)( CHARACTER(locator),
INTEGER8(value),
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
datImportFloc( locator, locator_length, &locator_c, status );
datGet0K( locator_c, value, status );
}
F77_SUBROUTINE(dat_get0l)( CHARACTER(locator),
LOGICAL(value),
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
datImportFloc( locator, locator_length, &locator_c, status );
datGet0L( locator_c, value, status );
}
F77_SUBROUTINE(dat_index)( CHARACTER(locator1),
F77_INTEGER_TYPE *index,
CHARACTER(locator2),
F77_INTEGER_TYPE *status
TRAIL(locator1)
TRAIL(locator2) )
{
/*=======================================*/
/* DAT_INDEX - Index into component list */
/*=======================================*/
/* Local variables. */
HDSLoc *locator1_c = NULL;
HDSLoc *locator2_c = NULL;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator1, locator1_length, &locator1_c, status);
/* Call pure C routine */
datIndex( locator1_c, *index, &locator2_c, status);
/*Export the returned locator */
datExportFloc( &locator2_c, 1, locator2_length, locator2, status );
}
F77_SUBROUTINE(dat_len)( CHARACTER(locator),
F77_INTEGER_TYPE *len,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*====================================*/
/* DAT_LEN - Inquire primitive length */
/*====================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
size_t len_c;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status);
/* Call pure C routine */
datLen( locator_c, &len_c, status );
*len = (F77_INTEGER_TYPE)len_c;
}
F77_SUBROUTINE(dat_lock)( CHARACTER(locator),
F77_LOGICAL_TYPE *recurs,
F77_LOGICAL_TYPE *readonly,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*========================================================= */
/* DAT_LOCK - Lock an object for use by the current thread. */
/*========================================================= */
/* Local variables */
HDSLoc * locator_c = NULL;
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status);
/* Call pure C routine */
datLock( locator_c, F77_ISTRUE( *recurs ), F77_ISTRUE( *readonly ), status );
}
F77_SUBROUTINE(dat_locked)( CHARACTER(locator),
F77_LOGICAL_TYPE *recurs,
F77_INTEGER_TYPE *reply,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/* =======================================================================*/
/* dat_locked - See of an object is locked for use by the current thread. */
/* =======================================================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
/* Import the input locator string. */
datImportFloc( locator, locator_length, &locator_c, status);
/* Call pure C routine. */
*reply = datLocked( locator_c, F77_ISTRUE( *recurs ), status);
}
F77_SUBROUTINE(dat_move)( CHARACTER(locator1),
CHARACTER(locator2),
CHARACTER(name),
F77_INTEGER_TYPE *status
TRAIL(locator1)
TRAIL(locator2)
TRAIL(name) )
{
/*========================*/
/* DAT_MOVE - Move object */
/*========================*/
/* Local variables. */
HDSLoc *locator1_c = NULL;
HDSLoc *locator2_c = NULL;
char name_c[DAT__SZNAM+1];
/* Enter routine. */
/* Since the input locator is modified for output, abort early
to prevent datExportFloc trashing the locator on bad status */
if (*status != SAI__OK) return;
/* Import the first locator string */
datImportFloc( locator1, locator1_length, &locator1_c, status );
/* Import the second locator string */
datImportFloc( locator2, locator2_length, &locator2_c, status );
/* Import "name" to C string */
cnfImpn( name, name_length, DAT__SZNAM, name_c );
/* Call pure C routine */
datMove( &locator1_c, locator2_c, name_c, status );
/* Export returned locator - will be now DAT__NOLOC */
datExportFloc( &locator1_c, 1, locator1_length, locator1, status );
}
F77_SUBROUTINE(dat_msg)( CHARACTER(token), CHARACTER(locator)
TRAIL(token) TRAIL(locator) )
{
/*====================================================*/
/* DAT_MSG - Associate a locator with a message token */
/*====================================================*/
char token_c[EMS__SZTOK+1];
HDSLoc * locator_c = NULL;
int status = SAI__OK;
int lstat;
int locok;
/* Get the current error status, then start a new error reporting context. */
emsStat( &lstat );
emsMark();
/* Try to import the locator */
datImportFloc( locator, locator_length, &locator_c, &status );
/* Was the locator imported successfully? */
locok = ( status == SAI__OK );
/* If the initial status was bad ignore any error that occurred
importing the locator. */
if( !locok && lstat != SAI__OK ) emsAnnul(&status);
/* Release the current error context. */
emsRlse();
/* If the locator was imported successfully... */
if( locok ) {
/* Import "token" to C string */
cnfImpn( token, token_length, EMS__SZTOK, token_c );
/* Call datMsg itself but only if status is good */
datMsg( token_c, locator_c );
}
}
F77_SUBROUTINE(dat_name)( CHARACTER(locator),
CHARACTER(name),
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(name) )
{
/*================================*/
/* DAT_NAME - Enquire object name */
/*================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char name_c[DAT__SZNAM+1];
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Call pure C routine */
name_c[0] = '\0';
datName( locator_c, name_c, status );
/* Export returned name to FORTRAN string */
cnfExpn( name_c, DAT__SZNAM, name, name_length );
}
F77_SUBROUTINE(dat_ncomp)( CHARACTER(locator),
F77_INTEGER_TYPE *ncomp,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*==========================================*/
/* DAT_NCOMP - Inquire number of components */
/*==========================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Call pure C routine */
datNcomp( locator_c, ncomp, status );
}
F77_SUBROUTINE(dat_new0)( CHARACTER(locator),
CHARACTER(name),
CHARACTER(type),
INTEGER(status)
TRAIL(locator)
TRAIL(name)
TRAIL(type) )
{
/*========================================*/
/* DAT_NEW0 - Create new scalar component */
/*========================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
char name_c[DAT__SZNAM+1];
char type_c[DAT__SZTYP+1];
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import "name" and "type" to C string */
cnfImpn( name, name_length, DAT__SZNAM, name_c );
cnfImpn( type, type_length, DAT__SZNAM, type_c );
datNew0( locator_c, name_c, type_c, status );
}
F77_SUBROUTINE(dat_new0d)( CHARACTER(locator),
CHARACTER(name),
INTEGER(status)
TRAIL(locator)
TRAIL(name) )
{
/*========================================*/
/* DAT_NEW0D - Create new double scalar component */
/*========================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
char name_c[DAT__SZNAM+1];
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import "name" and "type" to C string */
cnfImpn( name, name_length, DAT__SZNAM, name_c );
datNew0D( locator_c, name_c, status );
}
F77_SUBROUTINE(dat_new0i)( CHARACTER(locator),
CHARACTER(name),
INTEGER(status)
TRAIL(locator)
TRAIL(name) )
{
/*========================================*/
/* DAT_NEW0I - Create new integer scalar component */
/*========================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
char name_c[DAT__SZNAM+1];
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import "name" and "type" to C string */
cnfImpn( name, name_length, DAT__SZNAM, name_c );
datNew0I( locator_c, name_c, status );
}
F77_SUBROUTINE(dat_new0k)( CHARACTER(locator),
CHARACTER(name),
INTEGER(status)
TRAIL(locator)
TRAIL(name) )
{
/*========================================*/
/* DAT_NEW0K - Create new 64-bit integer scalar component */
/*========================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
char name_c[DAT__SZNAM+1];
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import "name" and "type" to C string */
cnfImpn( name, name_length, DAT__SZNAM, name_c );
datNew0K( locator_c, name_c, status );
}
F77_SUBROUTINE(dat_new0r)( CHARACTER(locator),
CHARACTER(name),
INTEGER(status)
TRAIL(locator)
TRAIL(name) )
{
/*========================================*/
/* DAT_NEW0R - Create new real scalar component */
/*========================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
char name_c[DAT__SZNAM+1];
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import "name" and "type" to C string */
cnfImpn( name, name_length, DAT__SZNAM, name_c );
datNew0R( locator_c, name_c, status );
}
F77_SUBROUTINE(dat_new0l)( CHARACTER(locator),
CHARACTER(name),
INTEGER(status)
TRAIL(locator)
TRAIL(name) )
{
/*========================================*/
/* DAT_NEW0L - Create new logical scalar component */
/*========================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
char name_c[DAT__SZNAM+1];
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import "name" and "type" to C string */
cnfImpn( name, name_length, DAT__SZNAM, name_c );
datNew0L( locator_c, name_c, status );
}
F77_SUBROUTINE(dat_new0c)( CHARACTER(locator),
CHARACTER(name),
INTEGER(len),
INTEGER(status)
TRAIL(locator)
TRAIL(name) )
{
/*========================================*/
/* DAT_NEW0C - Create new _CHAR scalar component */
/*========================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
char name_c[DAT__SZNAM+1];
size_t len_c;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import "name" and "type" to C string */
cnfImpn( name, name_length, DAT__SZNAM, name_c );
len_c = *len;
datNew0C( locator_c, name_c, len_c, status );
}
F77_SUBROUTINE(dat_nolock)( CHARACTER(locator),
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*============================================================== */
/* DAT_NOLOCK - Prevent lock checks being performed on an object */
/*============================================================== */
/* Local variables */
HDSLoc *locator_c = NULL;
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Call pure C routine */
datNolock( locator_c, status );
}
F77_SUBROUTINE(dat_paren)( CHARACTER(locator1),
CHARACTER(locator2),
F77_INTEGER_TYPE *status
TRAIL(locator1)
TRAIL(locator2) )
{
/*=====================================*/
/* DAT_PAREN - Locate parent structure */
/*=====================================*/
/* Local variables. */
HDSLoc *locator1_c = NULL;
HDSLoc *locator2_c = NULL;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator1, locator1_length, &locator1_c, status );
/* Call pure C routine */
datParen( locator1_c, &locator2_c, status );
/* Export returned locator to FORTRAN string */
datExportFloc( &locator2_c, 1, locator2_length, locator2, status );
}
F77_SUBROUTINE(dat_prec)( CHARACTER(locator),
INTEGER(nbytes),
INTEGER(status)
TRAIL(locator) )
{
/*==========================================*/
/* DAT_PREC - Enquire object primitive size */
/*==========================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
size_t nbytes_c;
/* Enter routine. */
if ( *status != SAI__OK ) return;
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Call pure C routine */
nbytes_c = (size_t)*nbytes;
datPrec( locator_c, &nbytes_c, status );
*nbytes = nbytes_c;
}
F77_SUBROUTINE(dat_prim)( CHARACTER(locator),
F77_LOGICAL_TYPE *reply,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*=====================================*/
/* DAT_PRIM - Enquire object primitive */
/*=====================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
int reply_c;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Call pure C routine */
datPrim( locator_c, &reply_c, status );
/* Set FORTRAN locical return */
if( reply_c )
*reply = F77_TRUE;
else
*reply = F77_FALSE;
}
F77_SUBROUTINE(dat_prmry)( F77_LOGICAL_TYPE *set,
CHARACTER(locator),
F77_LOGICAL_TYPE *prmry,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*==========================================================*/
/* DAT_PRMRY - Set/Enquire primary/secondary locator status */
/*==========================================================*/
/* Local variables. */
HDSLoc *locator_c = NULL;
int set_c;
int primary_c;
/* Since the input locator is modified for output, abort early
to prevent datExportFloc trashing the locator on bad status */
if (*status != SAI__OK) return;
/* Enter routine. */
if ( F77_ISTRUE( *set ) ) {
set_c = TRUE;
if( F77_ISTRUE( *prmry ) )
primary_c = TRUE;
else
primary_c = FALSE;
} else {
set_c = FALSE;
primary_c = FALSE;
}
/* Import the locator string (given and returned) */
datImportFloc( locator, locator_length, &locator_c, status);
/* Call pure C routine */
datPrmry( set_c, &locator_c, &primary_c, status );
/* Export returned locator - may be set to DAT__NOLOC */
datExportFloc( &locator_c, 1, locator_length, locator, status );
/* Set FORTRAN logical return */
if( F77_ISFALSE( *set ) )
{
if (primary_c)
*prmry = F77_TRUE;
else
*prmry = F77_FALSE;
}
}
F77_SUBROUTINE(dat_put0c)( CHARACTER(locator),
CHARACTER(value),
INTEGER(status)
TRAIL(locator)
TRAIL(value) )
{
HDSLoc * locator_c = NULL;
char * value_c;
value_c = cnfCreim( value, value_length );
datImportFloc( locator, locator_length, &locator_c, status );
datPut0C( locator_c, value_c, status );
cnfFree(value_c);
}
F77_SUBROUTINE(dat_put0d)( CHARACTER(locator),
DOUBLE(value),
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
datImportFloc( locator, locator_length, &locator_c, status );
datPut0D( locator_c, *value, status );
}
F77_SUBROUTINE(dat_put0r)( CHARACTER(locator),
REAL(value),
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
datImportFloc( locator, locator_length, &locator_c, status );
datPut0R( locator_c, *value, status );
}
F77_SUBROUTINE(dat_put0i)( CHARACTER(locator),
INTEGER(value),
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
datImportFloc( locator, locator_length, &locator_c, status );
datPut0I( locator_c, *value, status );
}
F77_SUBROUTINE(dat_put0k)( CHARACTER(locator),
INTEGER8(value),
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
datImportFloc( locator, locator_length, &locator_c, status );
datPut0K( locator_c, *value, status );
}
F77_SUBROUTINE(dat_put0l)( CHARACTER(locator),
LOGICAL(value),
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
datImportFloc( locator, locator_length, &locator_c, status );
datPut0L( locator_c, *value, status );
}
F77_SUBROUTINE(dat_ref)( CHARACTER(locator),
CHARACTER(ref),
INTEGER(reflen),
INTEGER(status)
TRAIL(locator)
TRAIL(ref) )
{
/*============================================*/
/* DAT_REF - Get reference name of HDS object */
/*============================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
char *ref_c;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
ref_c = cnfCreat( ref_length + 1 );
datRef( locator_c, ref_c, ref_length + 1, status );
if (*status == SAI__OK || *status == DAT__TRUNC) {
cnfExprt( ref_c, ref, ref_length );
/* We know that ref_c can't be longer than ref_length */
*reflen = strlen( ref_c );
} else {
cnfExprt( " ", ref, ref_length);
*reflen = 1;
}
cnfFree( ref_c );
}
F77_SUBROUTINE(dat_refct)( CHARACTER(locator),
F77_INTEGER_TYPE *refct,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*====================================================*/
/* DAT_REFCT - Enquire container file reference count */
/*====================================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Call pure C routine */
datRefct( locator_c, refct, status );
}
F77_SUBROUTINE(dat_renam)( CHARACTER(locator),
CHARACTER(name),
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(name) )
{
/*==============================*/
/* DAT_RENAM - Rename an object */
/*==============================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char name_c[DAT__SZNAM+1];
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import "name" to C string */
cnfImpn( name, name_length, DAT__SZNAM, name_c );
/* Call pure C routine */
datRenam( locator_c, name_c, status );
}
F77_SUBROUTINE(dat_reset)( CHARACTER(locator),
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*================================*/
/* DAT_RESET - Reset object state */
/*================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Call pure C routine */
datReset( locator_c, status );
}
F77_SUBROUTINE(dat_retyp)( CHARACTER(locator),
CHARACTER(type),
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(type) )
{
/*================================*/
/* DAT_RETYP - Change object type */
/*================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char type_c[DAT__SZTYP+1];
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import "type" to C string */
cnfImpn( type, type_length, DAT__SZTYP, type_c );
/* Call pure C routine */
datRetyp( locator_c, type_c, status);
}
F77_SUBROUTINE(dat_state)( CHARACTER(locator),
F77_LOGICAL_TYPE *reply,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*==================================*/
/* DAT_STATE - Enquire object state */
/*==================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
int reply_c;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Call pure C routine */
datState( locator_c, &reply_c, status );
/* Set FORTRAN locical return */
if( reply_c )
*reply = F77_TRUE;
else
*reply = F77_FALSE;
}
F77_SUBROUTINE(dat_struc)( CHARACTER(locator),
F77_LOGICAL_TYPE *reply,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*======================================*/
/* DAT_STRUC - Enquire object structure */
/*======================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
int reply_c = 0;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Call pure C routine */
datStruc( locator_c, &reply_c, status );
/* Set FORTRAN locical return */
if( reply_c )
*reply = F77_TRUE;
else
*reply = F77_FALSE;
}
F77_SUBROUTINE(dat_there)( CHARACTER(locator),
CHARACTER(name),
F77_LOGICAL_TYPE *reply,
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(name) )
{
/*=========================================*/
/* DAT_THERE - Enquire component existence */
/*=========================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char name_c[DAT__SZNAM+1];
int reply_c = FALSE;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import "name" string */
cnfImpn( name, name_length, DAT__SZNAM, name_c);
/* Call pure C routine */
datThere( locator_c, name_c, &reply_c, status );
/* Set FORTRAN locical return */
if( reply_c )
*reply = F77_TRUE;
else
*reply = F77_FALSE;
}
F77_SUBROUTINE(dat_type)( CHARACTER(locator),
CHARACTER(type),
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(type) )
{
/*================================*/
/* DAT_TYPE - Enquire object type */
/*================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char type_c[DAT__SZTYP+1];
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Call pure C routine */
datType( locator_c, type_c, status );
/* Export returned type name to FORTRAN */
cnfExpn( type_c, DAT__SZNAM, type, type_length );
}
F77_SUBROUTINE(dat_unlock)( CHARACTER(locator),
F77_LOGICAL_TYPE *recurs,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*============================================================== */
/* DAT_UNLOCK - Unlock an object so another thread can lock it. */
/*============================================================== */
/* Local variables */
HDSLoc * locator_c = NULL;
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status);
/* Call pure C routine */
datUnlock( locator_c, F77_ISTRUE( *recurs ), status );
}
F77_SUBROUTINE(dat_unmap)( CHARACTER(locator),
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*==========================*/
/* DAT_UNMAP - Unmap object */
/*==========================*/
/* Local variables. */
HDSLoc *locator_c = NULL;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Call pure C routine */
datUnmap( locator_c, status );
}
F77_SUBROUTINE(dat_valid)( CHARACTER(locator),
F77_LOGICAL_TYPE *reply,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*===================================*/
/* DAT_VALID - Enquire locator valid */
/*===================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
int reply_c = FALSE;
/* Enter routine. */
/* Any errors triggered by this routine should be annulled
and simply set "reply" to false intead */
*reply = F77_FALSE;
if ( *status != SAI__OK ) return;
emsMark();
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status);
/* Call pure C routine */
datValid( locator_c, &reply_c, status );
/* clear any bad status and set valid to FALSE */
if ( *status != SAI__OK ) {
reply_c = FALSE;
emsAnnul( status );
}
emsRlse();
/* Set FORTRAN logical return */
if( reply_c )
*reply = F77_TRUE;
else
*reply = F77_FALSE;
}
F77_SUBROUTINE(dat_vec)( CHARACTER(locator1),
CHARACTER(locator2),
F77_INTEGER_TYPE *status
TRAIL(locator1)
TRAIL(locator2) )
{
/*============================*/
/* DAT_VEC - Vectorise object */
/*============================*/
/* Local variables. */
HDSLoc *locator1_c = NULL;
HDSLoc *locator2_c = NULL;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator1, locator1_length, &locator1_c, status );
/* Call pure C routine */
datVec( locator1_c, &locator2_c, status );
/* Export returned locator */
datExportFloc( &locator2_c, 1, locator2_length, locator2, status );
}
F77_SUBROUTINE(dat_where)( CHARACTER(locator),
F77_INTEGER_TYPE *block,
F77_INTEGER_TYPE *offset,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*===============================================*/
/* DAT_WHERE Find primitive position in HDS file */
/*===============================================*/
if (*status == SAI__OK) {
*status = DAT__FATAL;
emsRep("","DAT_WHERE is not supported in this implementation",
status);
}
return;
}
F77_SUBROUTINE(hds_copy)( CHARACTER(locator),
CHARACTER(file),
CHARACTER(name),
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(file)
TRAIL(name) )
{
/*===================================================*/
/* HDS_COPY - Copy an object to a new container file */
/*===================================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char *file_c;
char name_c[DAT__SZNAM+1];
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import FILE argument to C string */
file_c = cnfCreim( file, file_length );
/* Import "name" to C string */
cnfImpn( name, name_length, DAT__SZNAM, name_c );
/* Call pure C routine */
hdsCopy( locator_c, file_c, name_c, status );
/* Free allocated string memory. */
cnfFree( file_c );
}
F77_SUBROUTINE(hds_erase)( CHARACTER(locator),
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*==================================*/
/* HDS_ERASE - Erase container file */
/*==================================*/
/* Local variables. */
HDSLoc *locator_c = NULL;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Call pure C routine */
hdsErase( &locator_c, status );
/* Export the locator (will be DAT__NOLOC) */
datExportFloc( &locator_c, 1, locator_length, locator, status );
}
F77_SUBROUTINE(hds_ewild) ( F77_INTEGER_TYPE *iwld,
F77_INTEGER_TYPE *status )
{
/*================================================================*/
/* HDS_EWILD - End a wild card search for HDS container files */
/*================================================================*/
/* Enter routine. */
/* Call pure C routine */
hdsEwild( iwld, status );
}
F77_SUBROUTINE(hds_find)( CHARACTER(locator1),
CHARACTER(name),
CHARACTER(mode),
CHARACTER(locator2),
F77_INTEGER_TYPE *status
TRAIL(locator1)
TRAIL(name)
TRAIL(mode)
TRAIL(locator2) )
{
/*=========================================*/
/* HDS_FIND - Find named component or path */
/*=========================================*/
/* Local variables. */
char *mode_c;
char *name_c;
HDSLoc *locator1_c = NULL;
HDSLoc *locator2_c = NULL;
/* Create a null terminated copy of the supplied name/path. */
name_c = cnfCreim( name, name_length );
/* Create a null terminated copy of the supplied mode. */
mode_c = cnfCreim( mode, mode_length );
/* Import the input locator string. Translated DAT__ROOT to NULL since
datImportFloc doesnot recognised DAT_ROOT. */
if( strncmp( DAT__ROOT, locator1, locator1_length ) ) {
datImportFloc( locator1, locator1_length, &locator1_c, status );
}
/* Call pure C routine */
hdsFind( locator1_c, name_c, mode_c, &locator2_c, status);
/* Free the null-terminated buffers. */
cnfFree( name_c );
cnfFree( mode_c );
/* Export the returned locator */
datExportFloc( &locator2_c, 1, locator2_length, locator2, status );
}
F77_SUBROUTINE(hds_flush)( CHARACTER(group),
F77_INTEGER_TYPE *status
TRAIL(group) )
{
/*=================================*/
/* HDS_FLUSH - Flush locator group */
/*==================================*/
/* Local variables. */
char group_c[DAT__SZGRP+1];
/* Enter routine. */
/* Import the maximum length strings */
cnfImpn( group, group_length, DAT__SZGRP, group_c );
/* Call pure C routine */
hdsFlush( group_c, status );
}
F77_SUBROUTINE(hds_free)( CHARACTER(locator),
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*================================*/
/* HDS_FREE - Free container file */
/*================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Call pure C routine */
hdsFree( locator_c, status );
}
F77_SUBROUTINE(hds_group)( CHARACTER(locator),
CHARACTER(group),
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(group) )
{
/*===================================*/
/* HDS_GROUP - Enquire locator group */
/*===================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char group_c [DAT__SZGRP+1];;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Call pure C routine */
hdsGroup( locator_c, group_c, status );
/* Export returned group name to FORTRAN string */
cnfExpn( group_c, DAT__SZGRP, group, group_length);
}
F77_SUBROUTINE(hds_gtune) ( CHARACTER(param_str),
F77_INTEGER_TYPE *value,
F77_INTEGER_TYPE *status
TRAIL(param_str) )
{
/*=========================================*/
/* HDS_GTUNE - Get HDS tuning parameter */
/*=========================================*/
/* Local variables. */
char *param_str_c;
/* Enter routine. */
/* Import PARAM argument to C string */
param_str_c = cnfCreim( param_str, param_str_length );
/* Call pure C routine */
hdsGtune( param_str_c, value, status );
/* Free allocated string memory. */
cnfFree( param_str_c );
}
F77_SUBROUTINE(hds_link)( CHARACTER(locator),
CHARACTER(group),
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(group) )
{
/*==================================*/
/* HDS_LINK - Link locator to group */
/*==================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char group_c[DAT__SZGRP+1];
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import the group name string */
cnfImpn( group, group_length, DAT__SZGRP, group_c );
/* Call pure C routine */
hdsLink( locator_c, group_c, status );
}
F77_SUBROUTINE(hds_lock)( CHARACTER(locator),
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*================================*/
/* HDS_LOCK - Lock container file */
/*================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Call pure C routine */
hdsLock( locator_c, status );
}
F77_SUBROUTINE(hds_open)( CHARACTER(file),
CHARACTER(mode),
CHARACTER(locator),
F77_INTEGER_TYPE *status
TRAIL(file)
TRAIL(mode)
TRAIL(locator) )
{
/*=========================================*/
/* HDS_OPEN - Open existing container file */
/*=========================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char *file_c;
char mode_c[DAT__SZMOD + 1];
/* Enter routine. */
/* Import FILE argument to C string */
file_c = cnfCreim( file, file_length );
/* Import maxmimum length strings */
cnfImpn( mode, mode_length, DAT__SZMOD, mode_c );
/* Call pure C routine */
hdsOpen( file_c, mode_c, &locator_c, status );
/* Export returned locator */
datExportFloc( &locator_c, 1, locator_length, locator, status );
/* Free allocated string memory. */
cnfFree( file_c );
}
F77_SUBROUTINE(hds_infoi)( CHARACTER(locator),
CHARACTER(topic),
CHARACTER(extra),
INTEGER(result),
F77_INTEGER_TYPE *status
TRAIL(locator) TRAIL(topic) TRAIL(extra) )
{
/*================================*/
/* HDS_INFOI - Obtain HDS statistics */
/*================================*/
/* Local variables. */
char *topic_c;
char *extra_c;
HDSLoc * locator_c = NULL;
/* Enter routine. */
/* Import TOPIC and EXTRA argument to C string */
topic_c = cnfCreim( topic, topic_length );
extra_c = cnfCreim( extra, extra_length );
/* Import locator - NOLOC is valid but datImportFloc
will get upset with NOLOC */
if (strncmp(DAT__NOLOC, locator, locator_length) == 0) {
locator_c = NULL;
} else {
datImportFloc( locator, locator_length, &locator_c, status );
}
/* Call pure C routine */
hdsInfoI( locator_c, topic_c, extra_c, result, status);
/* Free allocated string memory. */
cnfFree( topic_c );
cnfFree( extra_c );
}
F77_SUBROUTINE(hds_show)( CHARACTER(topic),
F77_INTEGER_TYPE *status
TRAIL(topic) )
{
/*================================*/
/* HDS_SHOW - Show HDS statistics */
/*================================*/
/* Local variables. */
char *topic_c;
/* Enter routine. */
/* Import TOPIC argument to C string */
topic_c = cnfCreim( topic, topic_length );
/* Call pure C routine */
hdsShow( topic_c, status);
/* Free allocated string memory. */
cnfFree( topic_c );
}
F77_SUBROUTINE(hds_state) (int *state,
int *status )
{
/*================================================*/
/* HDS_STATE - Enquire the current state of HDS */
/*================================================*/
/* Call pure C routine */
hdsState( state, status );
}
F77_SUBROUTINE(hds_stop) ( F77_INTEGER_TYPE *status )
{
/*=============================*/
/* HDS_STOP - Close down HDS */
/*=============================*/
/* Call pure C routine */
hdsStop( status );
}
F77_SUBROUTINE(hds_trace)( CHARACTER(locator),
F77_INTEGER_TYPE *nlev,
CHARACTER(path),
CHARACTER(file),
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(path)
TRAIL(file) )
{
/*===============================*/
/* HDS_TRACE - Trace object path */
/*===============================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char path_c[2048];
char file_c[2048];
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Call pure C routine */
hdsTrace( locator_c, nlev, path_c, file_c, status,
sizeof(path_c), sizeof(file_c) );
/* Export the returned C strings to the FORTRAN variables */
cnfExprt( path_c, path, path_length );
cnfExprt( file_c, file, file_length );
}
F77_SUBROUTINE(hds_tune) ( CHARACTER(param_str),
F77_INTEGER_TYPE *value,
F77_INTEGER_TYPE *status
TRAIL(param_str) )
{
/*=========================================*/
/* HDS_TUNE - Set HDS tuning parameter */
/*=========================================*/
/* Local variables. */
char *param_str_c;
/* Enter routine. */
/* Import PARAM argument to C string */
param_str_c = cnfCreim( param_str, param_str_length );
/* Call pure C routine */
hdsTune( param_str_c, *value, status );
/* Free allocated string memory. */
cnfFree( param_str_c );
}
F77_SUBROUTINE(hds_wild) ( CHARACTER(fspec),
CHARACTER(mode),
F77_INTEGER_TYPE *iwld,
CHARACTER(locator),
F77_INTEGER_TYPE *status
TRAIL(fspec)
TRAIL(mode)
TRAIL(locator) )
{
/*=================================================================*/
/* HDS_WILD - Perform a wild-card search for HDS container files */
/*=================================================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char *fspec_c;
char *mode_c;
/* Enter routine. */
/* Import FSPEC argument to C string */
fspec_c = cnfCreim( fspec, fspec_length );
/* Import FSPEC argument to C string */
mode_c = cnfCreim( mode, mode_length );
/* Call pure C routine */
hdsWild( fspec_c, mode_c, iwld, &locator_c, status );
/* Export returned locator */
datExportFloc( &locator_c, 1, locator_length, locator, status );
/* Free allocated string memory. */
cnfFree( fspec_c );
cnfFree( mode_c );
}
/* ---------------------------------------------------------- */
/* Routines that have 32 bit hdsdim (INTEGER*4) arguments */
/* ---------------------------------------------------------- */
F77_SUBROUTINE(dat_alter)( CHARACTER(locator),
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE dims[],
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*==================================*/
/* DAT_ALTER - Alter size of object */
/*==================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datAlter( locator_c, *ndim, cdims, status );
}
F77_SUBROUTINE(dat_basic)( CHARACTER(locator),
CHARACTER(mode),
F77_POINTER_TYPE *pntr,
F77_INTEGER_TYPE *len,
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(mode) )
{
/*===============================================*/
/* DAT_BASIC - Map data (in basic machine units) */
/*===============================================*/
/* Local variables. */
char mode_c[DAT__SZMOD+1];
unsigned char *cpntr = NULL; /* initialise in case of bad return status */
HDSLoc * locator_c = NULL;
size_t len_c = 0;
/* Enter routine. */
/* Import the locator and mode strings */
datImportFloc( locator, locator_length, &locator_c, status );
cnfImpn( mode, mode_length, DAT__SZMOD, mode_c);
/* Call pure C routine */
datBasic( locator_c, mode_c, &cpntr, &len_c, status);
*len = (F77_INTEGER_TYPE) len_c; /* ignore truncation */
/* Export the C pointer as a FORTRAN pointer */
*pntr = cnfFptr( cpntr );
}
F77_SUBROUTINE(dat_cell)( CHARACTER(locator1),
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE subs[],
CHARACTER(locator2),
F77_INTEGER_TYPE *status
TRAIL(locator1)
TRAIL(locator2) )
{
/*============================================*/
/* DAT_CELL - Locate a "cell" (array element) */
/*============================================*/
/* Local variables. */
HDSLoc *locator1_c = NULL;
HDSLoc *locator2_c = NULL;
hdsdim subsbuf[DAT__MXDIM];
hdsdim *csubs;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator1, locator1_length, &locator1_c, status);
/* Ensure that array subscripts are correct */
csubs = hdsDimF2C( *ndim, subs, subsbuf, status );
/* Call pure C routine */
datCell( locator1_c, *ndim, csubs, &locator2_c, status);
/* Export returned locator */
datExportFloc( &locator2_c, 1, locator2_length, locator2, status );
}
F77_SUBROUTINE(dat_get)( CHARACTER(locator),
CHARACTER(type),
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE dims[],
F77_BYTE_TYPE values[],
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(type)
TRAIL(values))
{
/*=============================*/
/* DAT_GET - Read primitive(s) */
/*=============================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char type_c[DAT__SZTYP+1];
int ischar = 0;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import FORTRAN to C string */
cnfImpn( type, type_length, DAT__SZTYP, type_c);
/* Special case _CHAR since fortran is telling us the length */
if (strncmp(type,"_CHAR",5) == 0) ischar = 1;
/* Import the locator string */
datImportFloc( locator, locator_length, &locator_c, status);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C( *ndim, dims, dimbuf, status );
/* Call pure C routine */
if (ischar) {
datGetC( locator_c, *ndim, cdims, (char*)values, values_length, status );
} else {
datGet( locator_c, type_c, *ndim, cdims, values, status);
}
}
F77_SUBROUTINE(dat_getc)( CHARACTER(locator),
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE dims[],
CHARACTER(values),
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(values)
)
{
/*====================================*/
/* DAT_GETC - Read _CHAR primitive(s) */
/*====================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datGetC( locator_c, *ndim, cdims, values, values_length, status);
}
F77_SUBROUTINE(dat_getd)( CHARACTER(locator),
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE dims[],
F77_DOUBLE_TYPE values[],
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*======================================*/
/* DAT_GETD - Read _DOUBLE primitive(s) */
/*======================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datGetD( locator_c, *ndim, cdims, values, status);
}
F77_SUBROUTINE(dat_geti)( CHARACTER(locator),
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE dims[],
F77_INTEGER_TYPE *values,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*=======================================*/
/* DAT_GETI - Read _INTEGER primitive(s) */
/*=======================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datGetI( locator_c, *ndim, cdims, values, status);
}
F77_SUBROUTINE(dat_getk)( CHARACTER(locator),
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE dims[],
F77_INTEGER8_TYPE *values,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*=======================================*/
/* DAT_GETK - Read _INT64 primitive(s) */
/*=======================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datGetK( locator_c, *ndim, cdims, values, status);
}
F77_SUBROUTINE(dat_getl)( CHARACTER(locator),
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE dims[],
F77_LOGICAL_TYPE *values,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*=======================================*/
/* DAT_GETL - Read _LOGICAL primitive(s) */
/*=======================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datGetL( locator_c, *ndim, cdims, values, status);
}
F77_SUBROUTINE(dat_getr)( CHARACTER(locator),
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE dims[],
F77_REAL_TYPE *values,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*====================================*/
/* DAT_GETR - Read _REAL primitive(s) */
/*====================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datGetR( locator_c, *ndim, cdims, values, status);
}
/*=======================================*/
/* DAT_GET1x - Get 1D array values */
/*=======================================*/
F77_SUBROUTINE(dat_get1c)( CHARACTER(locator),
INTEGER(maxval),
CHARACTER(values),
INTEGER(actval),
INTEGER(status)
TRAIL(locator)
TRAIL(values) )
{
/* Note that we can not call datGet1C here because that is too C specific.
Must instead go directly to datGetC */
HDSLoc * locator_c = NULL;
hdsdim dims[1];
size_t actval_c = 0;
datImportFloc( locator, locator_length, &locator_c, status );
if (*status == SAI__OK) {
datSize( locator_c, &actval_c, status );
if (*status == SAI__OK && (size_t)*maxval < actval_c) {
*status = DAT__BOUND;
emsSeti( "IN", (int)*maxval );
emsSeti( "SZ", (int)actval_c );
emsRep( "DAT_GET1C_ERR", "DAT_GET1C: Bounds mismatch: ^IN < ^SZ", status);
} else {
dims[0] = actval_c;
datGetC(locator_c, 1, dims, values, values_length, status);
}
}
*actval = actval_c;
}
F77_SUBROUTINE(dat_get1d)( CHARACTER(locator),
INTEGER(maxval),
F77_DOUBLE_TYPE *values,
INTEGER(actval),
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
size_t actval_c = 0;
datImportFloc( locator, locator_length, &locator_c, status );
datGet1D( locator_c, *maxval, values, &actval_c, status);
*actval = actval_c;
}
F77_SUBROUTINE(dat_get1i)( CHARACTER(locator),
INTEGER(maxval),
F77_INTEGER_TYPE *values,
INTEGER(actval),
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
size_t actval_c = 0;
datImportFloc( locator, locator_length, &locator_c, status );
datGet1I( locator_c, *maxval, values, &actval_c, status);
*actval = actval_c;
}
F77_SUBROUTINE(dat_get1k)( CHARACTER(locator),
INTEGER(maxval),
F77_INTEGER8_TYPE *values,
INTEGER(actval),
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
size_t actval_c = 0;
datImportFloc( locator, locator_length, &locator_c, status );
datGet1K( locator_c, *maxval, values, &actval_c, status);
*actval = actval_c;
}
F77_SUBROUTINE(dat_get1r)( CHARACTER(locator),
INTEGER(maxval),
F77_REAL_TYPE *values,
INTEGER(actval),
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
size_t actval_c = 0;
datImportFloc( locator, locator_length, &locator_c, status );
datGet1R( locator_c, *maxval, values, &actval_c, status);
*actval = actval_c;
}
F77_SUBROUTINE(dat_get1l)( CHARACTER(locator),
INTEGER(maxval),
F77_LOGICAL_TYPE *values,
INTEGER(actval),
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
size_t actval_c = 0;
datImportFloc( locator, locator_length, &locator_c, status );
datGet1L( locator_c, *maxval, values, &actval_c, status);
*actval = actval_c;
}
/*=======================================*/
/* DAT_GETVx - Get vectorized array values */
/*=======================================*/
F77_SUBROUTINE(dat_getvd)( CHARACTER(locator),
INTEGER(maxval),
F77_DOUBLE_TYPE *values,
INTEGER(actval),
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
size_t actval_c = 0;
datImportFloc( locator, locator_length, &locator_c, status );
datGetVD( locator_c, *maxval, values, &actval_c, status);
*actval = actval_c;
}
F77_SUBROUTINE(dat_getvi)( CHARACTER(locator),
INTEGER(maxval),
F77_INTEGER_TYPE *values,
INTEGER(actval),
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
size_t actval_c = 0;
datImportFloc( locator, locator_length, &locator_c, status );
datGetVI( locator_c, *maxval, values, &actval_c, status);
*actval = actval_c;
}
F77_SUBROUTINE(dat_getvk)( CHARACTER(locator),
INTEGER(maxval),
F77_INTEGER8_TYPE *values,
INTEGER(actval),
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
size_t actval_c = 0;
datImportFloc( locator, locator_length, &locator_c, status );
datGetVK( locator_c, *maxval, values, &actval_c, status);
*actval = actval_c;
}
F77_SUBROUTINE(dat_getvr)( CHARACTER(locator),
INTEGER(maxval),
F77_REAL_TYPE *values,
INTEGER(actval),
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
size_t actval_c = 0;
datImportFloc( locator, locator_length, &locator_c, status );
datGetVR( locator_c, *maxval, values, &actval_c, status);
*actval = actval_c;
}
F77_SUBROUTINE(dat_getvl)( CHARACTER(locator),
INTEGER(maxval),
F77_LOGICAL_TYPE *values,
INTEGER(actval),
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
size_t actval_c = 0;
datImportFloc( locator, locator_length, &locator_c, status );
datGetVL( locator_c, *maxval, values, &actval_c, status);
*actval = actval_c;
}
/* Note that for dat_getvc we call the *Fortran* interface version
of dat_get1c since that includes all the correct bounds checking
and also deals with a char buffer rather than char ** */
F77_SUBROUTINE(dat_getvc)( CHARACTER(locator),
INTEGER(maxval),
CHARACTER(values),
INTEGER(actval),
INTEGER(status)
TRAIL(locator)
TRAIL(values) )
{
HDSLoc * locator_c = NULL;
HDSLoc *vecloc_c = NULL;
char vecloc[DAT__SZLOC];
int vecloc_length = DAT__SZLOC;
if (*status != SAI__OK) return;
/* Import the fortran locator */
datImportFloc( locator, locator_length, &locator_c, status );
/* Vectorize it */
datVec( locator_c, &vecloc_c, status );
/* Export the new locator back to Fortran style */
datExportFloc( &vecloc_c, 0, DAT__SZLOC, vecloc, status );
/* Call Fortran dat_put1c since that does all the bounds checking.
We do not need to lock a mutex because we know that this is
calling C code in this file.
*/
F77_CALL(dat_get1c)( CHARACTER_ARG(vecloc), INTEGER_ARG(maxval),
CHARACTER_ARG(values), INTEGER_ARG(actval), INTEGER_ARG(status)
TRAIL_ARG(vecloc) TRAIL_ARG(values) );
/* Now annul the vector locator */
datAnnul( &vecloc_c, status );
}
F77_SUBROUTINE(dat_map)( CHARACTER(locator),
CHARACTER(type),
CHARACTER(mode),
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE dims[],
F77_POINTER_TYPE *pntr,
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(type)
TRAIL(mode) )
{
/*============================*/
/* DAT_MAP - Map primitive(s) */
/*============================*/
/* Local variables. */
HDSLoc *locator_c = NULL;
char type_c[DAT__SZTYP+1];
char mode_c[DAT__SZMOD+1];
void *cpntr = NULL; /* initialise in case of bad return status */
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import FORTRAN to C strings */
cnfImpn( type, type_length, DAT__SZTYP, type_c);
cnfImpn( mode, mode_length, DAT__SZMOD, mode_c);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datMap( locator_c, type_c, mode_c, *ndim, cdims, &cpntr, status);
/* Export the C pointer as a FORTRAN POINTER */
*pntr = cnfFptr( cpntr );
}
F77_SUBROUTINE(dat_mapc)( CHARACTER(locator),
CHARACTER(mode),
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE dims[],
F77_POINTER_TYPE *pntr,
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(mode) )
{
/*===================================*/
/* DAT_MAPC - Map _CHAR primitive(s) */
/*===================================*/
/* Local variables. */
HDSLoc *locator_c = NULL;
char mode_c[DAT__SZMOD+1];
unsigned char *cpntr = NULL; /* Initialise in case of bad return status */
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status);
/* Import mode string */
cnfImpn( mode, mode_length, DAT__SZMOD, mode_c);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datMapC( locator_c, mode_c, *ndim, cdims, &cpntr, status);
/* Export the C pointer as a FORTRAN POINTER */
*pntr = cnfFptr( cpntr );
}
F77_SUBROUTINE(dat_mapd)( CHARACTER(locator),
CHARACTER(mode),
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE dims[],
F77_POINTER_TYPE *pntr,
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(mode) )
{
/*=====================================*/
/* DAT_MAPD - Map _DOUBLE primitive(s) */
/*=====================================*/
/* Local variables. */
HDSLoc *locator_c = NULL;
char mode_c[DAT__SZMOD+1];
double *cpntr = NULL; /* initialise in case of bad return status */
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import mode string */
cnfImpn( mode, mode_length, DAT__SZMOD, mode_c);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datMapD( locator_c, mode_c, *ndim, cdims, &cpntr, status);
/* Export the C pointer as a FORTRAN POINTER */
*pntr = cnfFptr( cpntr );
}
F77_SUBROUTINE(dat_mapi)( CHARACTER(locator),
CHARACTER(mode),
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE dims[],
F77_POINTER_TYPE *pntr,
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(mode) )
{
/*======================================*/
/* DAT_MAPI - Map _INTEGER primitive(s) */
/*======================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char mode_c[DAT__SZMOD+1];
int *cpntr = NULL; /* initialise in case of bad return status */
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import mode string */
cnfImpn( mode, mode_length, DAT__SZMOD, mode_c);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datMapI( locator_c, mode_c, *ndim, cdims, &cpntr, status);
/* Export the C pointer as a FORTRAN POINTER */
*pntr = cnfFptr( cpntr );
}
F77_SUBROUTINE(dat_mapk)( CHARACTER(locator),
CHARACTER(mode),
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE dims[],
F77_POINTER_TYPE *pntr,
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(mode) )
{
/*======================================*/
/* DAT_MAPK - Map _INT64 primitive(s) */
/*======================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char mode_c[DAT__SZMOD+1];
int *cpntr = NULL; /* initialise in case of bad return status */
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import mode string */
cnfImpn( mode, mode_length, DAT__SZMOD, mode_c);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datMapK( locator_c, mode_c, *ndim, cdims, &cpntr, status);
/* Export the C pointer as a FORTRAN POINTER */
*pntr = cnfFptr( cpntr );
}
F77_SUBROUTINE(dat_mapl)( CHARACTER(locator),
CHARACTER(mode),
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE dims[],
F77_POINTER_TYPE *pntr,
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(mode) )
{
/*======================================*/
/* DAT_MAPL - Map _LOGICAL primitive(s) */
/*======================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char mode_c[DAT__SZMOD+1];
int *cpntr = NULL; /* initialise in case of bad return status */
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import mode string */
cnfImpn( mode, mode_length, DAT__SZMOD, mode_c);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datMapL( locator_c, mode_c, *ndim, cdims, &cpntr, status);
/* Export the C pointer as a FORTRAN POINTER */
*pntr = cnfFptr( cpntr );
}
F77_SUBROUTINE(dat_mapr)( CHARACTER(locator),
CHARACTER(mode),
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE dims[],
F77_POINTER_TYPE *pntr,
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(mode) )
{
/*===================================*/
/* DAT_MAPR - Map _REAL primitive(s) */
/*===================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char mode_c[DAT__SZMOD+1];
float *cpntr = NULL; /* initialise in case of bad return status */
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import mode string */
cnfImpn( mode, mode_length, DAT__SZMOD, mode_c);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datMapR( locator_c, mode_c, *ndim, cdims, &cpntr, status );
/* Export the C pointer as a FORTRAN POINTER */
*pntr = cnfFptr( cpntr );
}
F77_SUBROUTINE(dat_mapn)( CHARACTER(locator),
CHARACTER(type),
CHARACTER(mode),
INTEGER(ndim),
F77_POINTER_TYPE *pntr,
F77_INTEGER_TYPE dims[],
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(type)
TRAIL(mode) )
{
/*============================*/
/* DAT_MAP - Map primitive(s) */
/*============================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char type_c[DAT__SZTYP+1];
char mode_c[DAT__SZMOD+1];
void *cpntr = NULL; /* initialise in case of bad return status */
hdsdim cdims[DAT__MXDIM];
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import FORTRAN to C strings */
cnfImpn( type, type_length, DAT__SZTYP, type_c);
cnfImpn( mode, mode_length, DAT__SZMOD, mode_c);
/* Call pure C routine */
datMapN( locator_c, type_c, mode_c, *ndim, &cpntr, cdims, status);
/* Handle copying to Fortran dims */
(void)hdsDimC2F( *ndim, cdims, dims, status );
/* Export the C pointer as a FORTRAN POINTER */
*pntr = cnfFptr( cpntr );
}
F77_SUBROUTINE(dat_mapv)( CHARACTER(locator),
CHARACTER(type),
CHARACTER(mode),
F77_POINTER_TYPE *pntr,
F77_INTEGER_TYPE *actval,
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(type)
TRAIL(mode) )
{
/*=====================================*/
/* DAT_MAPV - Map vectorized primitive(s) */
/*=====================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char mode_c[DAT__SZMOD+1];
char type_c[DAT__SZTYP+1];
void *cpntr = NULL; /* initialise in case of bad return status */
size_t actval_c;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import mode and type string */
cnfImpn( mode, mode_length, DAT__SZMOD, mode_c);
cnfImpn( type, type_length, DAT__SZTYP, type_c);
datMapV( locator_c, type_c, mode_c, &cpntr, &actval_c, status);
/* Export the C pointer as a FORTRAN POINTER */
*pntr = cnfFptr( cpntr );
*actval = (F77_INTEGER_TYPE) actval_c;
}
F77_SUBROUTINE(dat_mould)( CHARACTER(locator),
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE dims[],
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*==================================*/
/* DAT_MOULD - Alter shape of object */
/*==================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datMould( locator_c, *ndim, cdims, status );
}
F77_SUBROUTINE(dat_new)( CHARACTER(locator),
CHARACTER(name),
CHARACTER(type),
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE dims[],
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(name)
TRAIL(type) )
{
/*================================*/
/* DAT_NEW - Create new component */
/*================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char name_c[DAT__SZNAM+1];
char type_c[DAT__SZTYP+1];
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import FORTRAN to C strings */
cnfImpn( name, name_length, DAT__SZNAM, name_c);
cnfImpn( type, type_length, DAT__SZTYP, type_c);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datNew( locator_c, name_c, type_c, *ndim, cdims, status);
}
F77_SUBROUTINE(dat_newc)( CHARACTER(locator),
CHARACTER(name),
F77_INTEGER_TYPE *len,
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE dims[],
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(name) )
{
/*============================================*/
/* DAT_NEWC - Create new _CHAR type component */
/*============================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
char name_c[DAT__SZNAM+1];
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import "name" to C string */
cnfImpn( name, name_length, DAT__SZNAM, name_c );
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datNewC( locator_c, name_c, *len, *ndim, cdims, status );
}
F77_SUBROUTINE(dat_new1)( CHARACTER(locator),
CHARACTER(name),
CHARACTER(type),
INTEGER(len),
INTEGER(status)
TRAIL(locator)
TRAIL(name)
TRAIL(type) )
{
/*========================================*/
/* DAT_NEW1 - Create new vector component */
/*========================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
char name_c[DAT__SZNAM+1];
char type_c[DAT__SZTYP+1];
size_t len_c;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import "name" and "type" to C string */
cnfImpn( name, name_length, DAT__SZNAM, name_c );
cnfImpn( type, type_length, DAT__SZNAM, type_c );
len_c = *len;
datNew1( locator_c, name_c, type_c, len_c, status );
}
F77_SUBROUTINE(dat_new1d)( CHARACTER(locator),
CHARACTER(name),
INTEGER(len),
INTEGER(status)
TRAIL(locator)
TRAIL(name) )
{
/*========================================*/
/* DAT_NEW1D - Create new vector double component */
/*========================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
char name_c[DAT__SZNAM+1];
size_t len_c;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import "name" to C string */
cnfImpn( name, name_length, DAT__SZNAM, name_c );
len_c = *len;
datNew1D( locator_c, name_c, len_c, status );
}
F77_SUBROUTINE(dat_new1i)( CHARACTER(locator),
CHARACTER(name),
INTEGER(len),
INTEGER(status)
TRAIL(locator)
TRAIL(name) )
{
/*========================================*/
/* DAT_NEW1I - Create new vector integer component */
/*========================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
char name_c[DAT__SZNAM+1];
size_t len_c;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import "name" to C string */
cnfImpn( name, name_length, DAT__SZNAM, name_c );
len_c = *len;
datNew1I( locator_c, name_c, len_c, status );
}
F77_SUBROUTINE(dat_new1k)( CHARACTER(locator),
CHARACTER(name),
INTEGER(len),
INTEGER(status)
TRAIL(locator)
TRAIL(name) )
{
/*========================================*/
/* DAT_NEW1K - Create new vector 64-bit integer component */
/*========================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
char name_c[DAT__SZNAM+1];
size_t len_c;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import "name" to C string */
cnfImpn( name, name_length, DAT__SZNAM, name_c );
len_c = *len;
datNew1K( locator_c, name_c, len_c, status );
}
F77_SUBROUTINE(dat_new1l)( CHARACTER(locator),
CHARACTER(name),
INTEGER(len),
INTEGER(status)
TRAIL(locator)
TRAIL(name) )
{
/*========================================*/
/* DAT_NEW1L - Create new vector logical component */
/*========================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
char name_c[DAT__SZNAM+1];
size_t len_c;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import "name" to C string */
cnfImpn( name, name_length, DAT__SZNAM, name_c );
len_c = *len;
datNew1L( locator_c, name_c, len_c, status );
}
F77_SUBROUTINE(dat_new1r)( CHARACTER(locator),
CHARACTER(name),
INTEGER(len),
INTEGER(status)
TRAIL(locator)
TRAIL(name) )
{
/*========================================*/
/* DAT_NEW1R - Create new vector double component */
/*========================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
char name_c[DAT__SZNAM+1];
size_t len_c;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import "name" to C string */
cnfImpn( name, name_length, DAT__SZNAM, name_c );
len_c = *len;
datNew1R( locator_c, name_c, len_c, status );
}
F77_SUBROUTINE(dat_new1c)( CHARACTER(locator),
CHARACTER(name),
INTEGER(len),
INTEGER(nelem),
INTEGER(status)
TRAIL(locator)
TRAIL(name) )
{
/*========================================*/
/* DAT_NEW1C - Create new vector string component */
/*========================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
char name_c[DAT__SZNAM+1];
size_t len_c;
size_t nelem_c;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import "name" to C string */
cnfImpn( name, name_length, DAT__SZNAM, name_c );
len_c = *len;
nelem_c = *nelem;
datNew1C( locator_c, name_c, len_c, nelem_c, status );
}
F77_SUBROUTINE(dat_putc)( CHARACTER(locator),
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE dims[],
CHARACTER(values),
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(values) )
{
/*==================================*/
/* DAT_PUTC - Write _CHAR primitive */
/*==================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C( *ndim, dims, dimbuf, status );
/* Call C routine */
datPutC( locator_c, *ndim, cdims, values, values_length, status);
}
F77_SUBROUTINE(dat_putd)( CHARACTER(locator),
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE dims[],
F77_DOUBLE_TYPE *values,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*=====================================*/
/* DAT_PUTD - Write _DOUBLE primitives */
/*=====================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datPutD( locator_c, *ndim, cdims, values, status );
}
F77_SUBROUTINE(dat_puti)( CHARACTER(locator),
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE dims[],
F77_INTEGER_TYPE *values,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*======================================*/
/* DAT_PUTI - Write _INTEGER primitives */
/*======================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datPutI( locator_c, *ndim, cdims, values, status );
}
F77_SUBROUTINE(dat_putk)( CHARACTER(locator),
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE dims[],
F77_INTEGER8_TYPE *values,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*======================================*/
/* DAT_PUTI - Write _INTEGER primitives */
/*======================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datPutK( locator_c, *ndim, cdims, values, status );
}
F77_SUBROUTINE(dat_putr)( CHARACTER(locator),
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE dims[],
F77_REAL_TYPE *values,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*===================================*/
/* DAT_PUTR - Write _REAL primitives */
/*===================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datPutR( locator_c, *ndim, cdims, values, status );
}
F77_SUBROUTINE(dat_putl)( CHARACTER(locator),
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE dims[],
F77_LOGICAL_TYPE *values,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*======================================*/
/* DAT_PUTL - Write _LOGICAL primitives */
/*======================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datPutL( locator_c, *ndim, cdims, values, status );
}
F77_SUBROUTINE(dat_put)( CHARACTER(locator),
CHARACTER(type),
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE dims[],
F77_BYTE_TYPE values[],
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(type)
TRAIL(values)
)
{
/*===========================*/
/* DAT_PUT - Write primitive */
/*===========================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char type_c[DAT__SZTYP+1];
int ischar = 0;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import "type" string */
cnfImpn( type, type_length, DAT__SZTYP, type_c );
/* Special case _CHAR since fortran is telling us the length */
/* This may not be needed if the type string is _CHAR*nnn */
if (strncmp(type,"_CHAR",5) == 0) ischar = 1;
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C( *ndim, dims, dimbuf, status );
/* Call pure C routine */
if (ischar) {
datPutC( locator_c, *ndim, cdims, (char *)values, values_length, status );
} else {
datPut( locator_c, type_c, *ndim, cdims, values, status );
}
}
F77_SUBROUTINE(dat_put1c)( CHARACTER(locator),
INTEGER(nval),
CHARACTER(values),
INTEGER(status)
TRAIL(locator)
TRAIL(values) )
{
HDSLoc * locator_c = NULL;
hdsdim dims[1];
size_t actvals;
if (*status != SAI__OK) return;
datImportFloc( locator, locator_length, &locator_c, status );
/* No C equivalent to call directly so we just call datPutC
after some bounds checking */
datSize( locator_c, &actvals, status );
if ( *status == SAI__OK ) {
if (actvals != (size_t)*nval) {
*status = DAT__BOUND;
emsSeti( "NV", *nval );
emsSetu( "SZ", actvals );
emsRep("DAT_PUT1C_ERR", "DAT_PUT1C: Bounds mismatch (^NV != ^SZ)", status );
} else {
dims[0] = *nval;
datPutC( locator_c, 1, dims, values, (size_t)values_length, status );
}
}
}
F77_SUBROUTINE(dat_put1d)( CHARACTER(locator),
INTEGER(nval),
F77_DOUBLE_TYPE *values,
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
datImportFloc( locator, locator_length, &locator_c, status );
datPut1D( locator_c, (size_t)*nval, values, status );
}
F77_SUBROUTINE(dat_put1i)( CHARACTER(locator),
INTEGER(nval),
F77_INTEGER_TYPE *values,
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
datImportFloc( locator, locator_length, &locator_c, status );
datPut1I( locator_c, (size_t)*nval, values, status );
}
F77_SUBROUTINE(dat_put1k)( CHARACTER(locator),
INTEGER(nval),
F77_INTEGER8_TYPE *values,
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
datImportFloc( locator, locator_length, &locator_c, status );
datPut1K( locator_c, (size_t)*nval, values, status );
}
F77_SUBROUTINE(dat_put1r)( CHARACTER(locator),
INTEGER(nval),
F77_REAL_TYPE *values,
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
datImportFloc( locator, locator_length, &locator_c, status );
datPut1R( locator_c, (size_t)*nval, values, status );
}
F77_SUBROUTINE(dat_put1l)( CHARACTER(locator),
INTEGER(nval),
F77_LOGICAL_TYPE *values,
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
datImportFloc( locator, locator_length, &locator_c, status );
datPut1L( locator_c, (size_t)*nval, values, status );
}
F77_SUBROUTINE(dat_putvd)( CHARACTER(locator),
INTEGER(nval),
F77_DOUBLE_TYPE *values,
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
datImportFloc( locator, locator_length, &locator_c, status );
datPutVD( locator_c, (size_t)*nval, values, status );
}
F77_SUBROUTINE(dat_putvi)( CHARACTER(locator),
INTEGER(nval),
F77_INTEGER_TYPE *values,
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
datImportFloc( locator, locator_length, &locator_c, status );
datPutVI( locator_c, (size_t)*nval, values, status );
}
F77_SUBROUTINE(dat_putvk)( CHARACTER(locator),
INTEGER(nval),
F77_INTEGER8_TYPE *values,
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
datImportFloc( locator, locator_length, &locator_c, status );
datPutVK( locator_c, (size_t)*nval, values, status );
}
F77_SUBROUTINE(dat_putvr)( CHARACTER(locator),
INTEGER(nval),
F77_REAL_TYPE *values,
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
datImportFloc( locator, locator_length, &locator_c, status );
datPutVR( locator_c, (size_t)*nval, values, status );
}
F77_SUBROUTINE(dat_putvl)( CHARACTER(locator),
INTEGER(nval),
F77_LOGICAL_TYPE *values,
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
datImportFloc( locator, locator_length, &locator_c, status );
datPutVL( locator_c, (size_t)*nval, values, status );
}
/* Note that for dat_putvc we call the *Fortran* interface version
of dat_put1c since that includes all the correct bounds checking
and also deals with a char buffer rather than char ** */
F77_SUBROUTINE(dat_putvc)( CHARACTER(locator),
INTEGER(nval),
CHARACTER(values),
INTEGER(status)
TRAIL(locator)
TRAIL(values) )
{
HDSLoc * locator_c = NULL;
HDSLoc *vecloc_c = NULL;
char vecloc[DAT__SZLOC];
int vecloc_length = DAT__SZLOC;
if (*status != SAI__OK) return;
/* Import the fortran locator */
datImportFloc( locator, locator_length, &locator_c, status );
/* Vectorize it */
datVec( locator_c, &vecloc_c, status );
/* Export the new locator back to Fortran style */
datExportFloc( &vecloc_c, 0, DAT__SZLOC, vecloc, status );
/* Call Fortran dat_put1c since that does all the bounds checking.
We do not need to lock a mutex because we know that this is
calling C code in this file.
*/
F77_CALL(dat_put1c)( CHARACTER_ARG(vecloc), INTEGER_ARG(nval),
CHARACTER_ARG(values), INTEGER_ARG(status)
TRAIL_ARG(vecloc) TRAIL_ARG(values) );
/* Now annul the vector locator */
datAnnul( &vecloc_c, status );
}
F77_SUBROUTINE(dat_shape)( CHARACTER(locator),
F77_INTEGER_TYPE *ndimx,
F77_INTEGER_TYPE dims[],
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*==================================*/
/* DAT_SHAPE - Enquire object shape */
/*==================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
hdsdim cdims[DAT__MXDIM];
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Call pure C routine */
datShape( locator_c, *ndimx, cdims, ndim, status );
/* Handle copying to Fortran dims */
(void)hdsDimC2F( *ndim, cdims, dims, status );
}
F77_SUBROUTINE(dat_size)( CHARACTER(locator),
F77_INTEGER_TYPE *size,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*================================*/
/* DAT_SIZE - Enquire object size */
/*================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
size_t size_c;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Call pure C routine */
datSize( locator_c, &size_c, status );
*size = (F77_INTEGER_TYPE) size_c;
}
F77_SUBROUTINE(dat_slice)( CHARACTER(locator1),
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE diml[],
F77_INTEGER_TYPE dimu[],
CHARACTER(locator2),
F77_INTEGER_TYPE *status
TRAIL(locator1)
TRAIL(locator2) )
{
/*=================================*/
/* DAT_SLICE - Locate object slice */
/*=================================*/
/* Local variables. */
HDSLoc *locator1_c = NULL;
HDSLoc *locator2_c = NULL;
hdsdim dimlbuf[DAT__MXDIM];
hdsdim dimubuf[DAT__MXDIM];
hdsdim * cldims;
hdsdim * cudims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator1, locator1_length, &locator1_c, status );
/* Ensure that array subscripts are correct */
cldims = hdsDimF2C( *ndim, diml, dimlbuf, status );
cudims = hdsDimF2C( *ndim, dimu, dimubuf, status );
/* Call pure C routine */
datSlice( locator1_c, *ndim, cldims, cudims, &locator2_c, status );
/* Export returned locator */
datExportFloc( &locator2_c, 1, locator2_length, locator2, status );
}
F77_SUBROUTINE(dat_temp)( CHARACTER(type),
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE dims[],
CHARACTER(locator),
F77_INTEGER_TYPE *status
TRAIL(type)
TRAIL(locator) )
{
/*====================================*/
/* DAT_TEMP - Create temporary object */
/*====================================*/
/* Local variables. */
HDSLoc *locator_c = NULL;
char type_c[DAT__SZTYP+1];
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import "type" to C string */
cnfImpn( type, type_length, DAT__SZTYP, type_c );
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datTemp( type_c, *ndim, cdims, &locator_c, status);
/* Export returned locator */
datExportFloc( &locator_c, 1, locator_length, locator, status );
}
F77_SUBROUTINE(hds_new)( CHARACTER(file),
CHARACTER(name),
CHARACTER(type),
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE dims[],
CHARACTER(locator),
F77_INTEGER_TYPE *status
TRAIL(file)
TRAIL(name)
TRAIL(type)
TRAIL(locator) )
{
/*=====================================*/
/* HDS_NEW - Create new container file */
/*=====================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char *file_c;
char name_c[DAT__SZNAM + 1];
char type_c[DAT__SZTYP + 1];
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import FILE argument to C string */
file_c = cnfCreim( file, file_length );
/* Import FORTRAN to C strings */
cnfImpn( name, name_length, DAT__SZNAM, name_c);
cnfImpn( type, type_length, DAT__SZTYP, type_c);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C( *ndim, dims, dimbuf, status );
/* Call pure C routine */
hdsNew( file_c, name_c, type_c, *ndim, cdims, &locator_c, status );
/* Export returned locator */
datExportFloc( &locator_c, 1, locator_length, locator, status );
/* Free allocated string memory. */
cnfFree( file_c );
}
/* ---------------------------------------------------------- */
/* Routines that have 64 bit hdsdim (INTEGER*8) arguments */
/* ---------------------------------------------------------- */
F77_SUBROUTINE(dat_alter8)( CHARACTER(locator),
F77_INTEGER_TYPE *ndim,
F77_INTEGER8_TYPE dims[],
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*===================================*/
/* DAT_ALTER8 - Alter size of object */
/*===================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C8( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datAlter( locator_c, *ndim, cdims, status );
}
F77_SUBROUTINE(dat_basic8)( CHARACTER(locator),
CHARACTER(mode),
F77_POINTER_TYPE *pntr,
F77_INTEGER8_TYPE *len,
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(mode) )
{
/*================================================*/
/* DAT_BASIC8 - Map data (in basic machine units) */
/*================================================*/
/* Local variables. */
char mode_c[DAT__SZMOD+1];
unsigned char *cpntr = NULL; /* initialise in case of bad return status */
HDSLoc * locator_c = NULL;
size_t len_c = 0;
/* Enter routine. */
/* Import the locator and mode strings */
datImportFloc( locator, locator_length, &locator_c, status );
cnfImpn( mode, mode_length, DAT__SZMOD, mode_c);
/* Call pure C routine */
datBasic( locator_c, mode_c, &cpntr, &len_c, status);
*len = (F77_INTEGER8_TYPE) len_c;
/* Export the C pointer as a FORTRAN pointer */
*pntr = cnfFptr( cpntr );
}
F77_SUBROUTINE(dat_cell8)( CHARACTER(locator1),
F77_INTEGER_TYPE *ndim,
F77_INTEGER8_TYPE subs[],
CHARACTER(locator2),
F77_INTEGER_TYPE *status
TRAIL(locator1)
TRAIL(locator2) )
{
/*=============================================*/
/* DAT_CELL8 - Locate a "cell" (array element) */
/*=============================================*/
/* Local variables. */
HDSLoc *locator1_c = NULL;
HDSLoc *locator2_c = NULL;
hdsdim subsbuf[DAT__MXDIM];
hdsdim *csubs;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator1, locator1_length, &locator1_c, status);
/* Ensure that array subscripts are correct */
csubs = hdsDimF2C8( *ndim, subs, subsbuf, status );
/* Call pure C routine */
datCell( locator1_c, *ndim, csubs, &locator2_c, status);
/* Export returned locator */
datExportFloc( &locator2_c, 1, locator2_length, locator2, status );
}
F77_SUBROUTINE(dat_get8)( CHARACTER(locator),
CHARACTER(type),
F77_INTEGER_TYPE *ndim,
F77_INTEGER8_TYPE dims[],
F77_BYTE_TYPE values[],
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(type)
TRAIL(values))
{
/*==============================*/
/* DAT_GET8 - Read primitive(s) */
/*==============================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char type_c[DAT__SZTYP+1];
int ischar = 0;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import FORTRAN to C string */
cnfImpn( type, type_length, DAT__SZTYP, type_c);
/* Special case _CHAR since fortran is telling us the length */
if (strncmp(type,"_CHAR",5) == 0) ischar = 1;
/* Import the locator string */
datImportFloc( locator, locator_length, &locator_c, status);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C8( *ndim, dims, dimbuf, status );
/* Call pure C routine */
if (ischar) {
datGetC( locator_c, *ndim, cdims, (char*)values, values_length, status );
} else {
datGet( locator_c, type_c, *ndim, cdims, values, status);
}
}
F77_SUBROUTINE(dat_getc8)( CHARACTER(locator),
F77_INTEGER_TYPE *ndim,
F77_INTEGER8_TYPE dims[],
CHARACTER(values),
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(values)
)
{
/*=====================================*/
/* DAT_GETC8 - Read _CHAR primitive(s) */
/*=====================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C8( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datGetC( locator_c, *ndim, cdims, values, values_length, status);
}
F77_SUBROUTINE(dat_getd8)( CHARACTER(locator),
F77_INTEGER_TYPE *ndim,
F77_INTEGER8_TYPE dims[],
F77_DOUBLE_TYPE values[],
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*=======================================*/
/* DAT_GETD8 - Read _DOUBLE primitive(s) */
/*=======================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C8( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datGetD( locator_c, *ndim, cdims, values, status);
}
F77_SUBROUTINE(dat_geti8)( CHARACTER(locator),
F77_INTEGER_TYPE *ndim,
F77_INTEGER8_TYPE dims[],
F77_INTEGER_TYPE *values,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*========================================*/
/* DAT_GETI8 - Read _INTEGER primitive(s) */
/*========================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C8( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datGetI( locator_c, *ndim, cdims, values, status);
}
F77_SUBROUTINE(dat_getk8)( CHARACTER(locator),
F77_INTEGER_TYPE *ndim,
F77_INTEGER8_TYPE dims[],
F77_INTEGER8_TYPE *values,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*========================================*/
/* DAT_GETK8 - Read _INT64 primitive(s) */
/*========================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C8( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datGetK( locator_c, *ndim, cdims, values, status);
}
F77_SUBROUTINE(dat_getl8)( CHARACTER(locator),
F77_INTEGER_TYPE *ndim,
F77_INTEGER8_TYPE dims[],
F77_LOGICAL_TYPE *values,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*========================================*/
/* DAT_GETL8 - Read _LOGICAL primitive(s) */
/*========================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C8( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datGetL( locator_c, *ndim, cdims, values, status);
}
F77_SUBROUTINE(dat_getr8)( CHARACTER(locator),
F77_INTEGER_TYPE *ndim,
F77_INTEGER8_TYPE dims[],
F77_REAL_TYPE *values,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*=====================================*/
/* DAT_GETR8 - Read _REAL primitive(s) */
/*=====================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C8( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datGetR( locator_c, *ndim, cdims, values, status);
}
/*========================================*/
/* DAT_GET1x8 - Get 1D array values */
/*========================================*/
F77_SUBROUTINE(dat_get1c8)( CHARACTER(locator),
INTEGER8(maxval),
CHARACTER(values),
INTEGER8(actval),
INTEGER(status)
TRAIL(locator)
TRAIL(values) )
{
/* Note that we can not call datGet1C here because that is too C specific.
Must instead go directly to datGetC */
HDSLoc * locator_c = NULL;
hdsdim dims[1];
size_t actval_c = 0;
datImportFloc( locator, locator_length, &locator_c, status );
if (*status == SAI__OK) {
datSize( locator_c, &actval_c, status );
if (*status == SAI__OK && (size_t)*maxval < actval_c) {
*status = DAT__BOUND;
emsSetk( "IN", *maxval );
emsSetk( "SZ", (int64_t)actval_c );
emsRep( "DAT_GET1C_ERR", "DAT_GET1C: Bounds mismatch: ^IN < ^SZ", status);
} else {
dims[0] = actval_c;
datGetC(locator_c, 1, dims, values, values_length, status);
}
}
*actval = actval_c;
}
F77_SUBROUTINE(dat_get1d8)( CHARACTER(locator),
INTEGER8(maxval),
F77_DOUBLE_TYPE *values,
INTEGER8(actval),
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
size_t actval_c = 0;
datImportFloc( locator, locator_length, &locator_c, status );
datGet1D( locator_c, *maxval, values, &actval_c, status);
*actval = actval_c;
}
F77_SUBROUTINE(dat_get1i8)( CHARACTER(locator),
INTEGER8(maxval),
F77_INTEGER_TYPE *values,
INTEGER8(actval),
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
size_t actval_c = 0;
datImportFloc( locator, locator_length, &locator_c, status );
datGet1I( locator_c, *maxval, values, &actval_c, status);
*actval = actval_c;
}
F77_SUBROUTINE(dat_get1k8)( CHARACTER(locator),
INTEGER8(maxval),
F77_INTEGER8_TYPE *values,
INTEGER8(actval),
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
size_t actval_c = 0;
datImportFloc( locator, locator_length, &locator_c, status );
datGet1K( locator_c, *maxval, values, &actval_c, status);
*actval = actval_c;
}
F77_SUBROUTINE(dat_get1r8)( CHARACTER(locator),
INTEGER8(maxval),
F77_REAL_TYPE *values,
INTEGER8(actval),
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
size_t actval_c = 0;
datImportFloc( locator, locator_length, &locator_c, status );
datGet1R( locator_c, *maxval, values, &actval_c, status);
*actval = actval_c;
}
F77_SUBROUTINE(dat_get1l8)( CHARACTER(locator),
INTEGER8(maxval),
F77_LOGICAL_TYPE *values,
INTEGER8(actval),
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
size_t actval_c = 0;
datImportFloc( locator, locator_length, &locator_c, status );
datGet1L( locator_c, *maxval, values, &actval_c, status);
*actval = actval_c;
}
/*=======================================*/
/* DAT_GETVx - Get vectorized array values */
/*=======================================*/
F77_SUBROUTINE(dat_getvd8)( CHARACTER(locator),
INTEGER8(maxval),
F77_DOUBLE_TYPE *values,
INTEGER8(actval),
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
size_t actval_c = 0;
datImportFloc( locator, locator_length, &locator_c, status );
datGetVD( locator_c, *maxval, values, &actval_c, status);
*actval = actval_c;
}
F77_SUBROUTINE(dat_getvi8)( CHARACTER(locator),
INTEGER8(maxval),
F77_INTEGER_TYPE *values,
INTEGER8(actval),
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
size_t actval_c = 0;
datImportFloc( locator, locator_length, &locator_c, status );
datGetVI( locator_c, *maxval, values, &actval_c, status);
*actval = actval_c;
}
F77_SUBROUTINE(dat_getvk8)( CHARACTER(locator),
INTEGER8(maxval),
F77_INTEGER8_TYPE *values,
INTEGER8(actval),
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
size_t actval_c = 0;
datImportFloc( locator, locator_length, &locator_c, status );
datGetVK( locator_c, *maxval, values, &actval_c, status);
*actval = actval_c;
}
F77_SUBROUTINE(dat_getvr8)( CHARACTER(locator),
INTEGER8(maxval),
F77_REAL_TYPE *values,
INTEGER8(actval),
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
size_t actval_c = 0;
datImportFloc( locator, locator_length, &locator_c, status );
datGetVR( locator_c, *maxval, values, &actval_c, status);
*actval = actval_c;
}
F77_SUBROUTINE(dat_getvl8)( CHARACTER(locator),
INTEGER8(maxval),
F77_LOGICAL_TYPE *values,
INTEGER8(actval),
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
size_t actval_c = 0;
datImportFloc( locator, locator_length, &locator_c, status );
datGetVL( locator_c, *maxval, values, &actval_c, status);
*actval = actval_c;
}
/* Note that for dat_getvc we call the *Fortran* interface version
of dat_get1c since that includes all the correct bounds checking
and also deals with a char buffer rather than char ** */
F77_SUBROUTINE(dat_getvc8)( CHARACTER(locator),
INTEGER8(maxval),
CHARACTER(values),
INTEGER8(actval),
INTEGER(status)
TRAIL(locator)
TRAIL(values) )
{
HDSLoc * locator_c = NULL;
HDSLoc *vecloc_c = NULL;
char vecloc[DAT__SZLOC];
int vecloc_length = DAT__SZLOC;
if (*status != SAI__OK) return;
/* Import the fortran locator */
datImportFloc( locator, locator_length, &locator_c, status );
/* Vectorize it */
datVec( locator_c, &vecloc_c, status );
/* Export the new locator back to Fortran style */
datExportFloc( &vecloc_c, 0, DAT__SZLOC, vecloc, status );
/* Call Fortran dat_put1c since that does all the bounds checking.
We do not need to lock a mutex because we know that this is
calling C code in this file.
*/
F77_CALL(dat_get1c8)( CHARACTER_ARG(vecloc), INTEGER8_ARG(maxval),
CHARACTER_ARG(values), INTEGER8_ARG(actval), INTEGER_ARG(status)
TRAIL_ARG(vecloc) TRAIL_ARG(values) );
/* Now annul the vector locator */
datAnnul( &vecloc_c, status );
}
F77_SUBROUTINE(dat_map8)( CHARACTER(locator),
CHARACTER(type),
CHARACTER(mode),
F77_INTEGER_TYPE *ndim,
F77_INTEGER8_TYPE dims[],
F77_POINTER_TYPE *pntr,
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(type)
TRAIL(mode) )
{
/*=============================*/
/* DAT_MAP8 - Map primitive(s) */
/*=============================*/
/* Local variables. */
HDSLoc *locator_c = NULL;
char type_c[DAT__SZTYP+1];
char mode_c[DAT__SZMOD+1];
void *cpntr = NULL; /* initialise in case of bad return status */
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import FORTRAN to C strings */
cnfImpn( type, type_length, DAT__SZTYP, type_c);
cnfImpn( mode, mode_length, DAT__SZMOD, mode_c);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C8( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datMap( locator_c, type_c, mode_c, *ndim, cdims, &cpntr, status);
/* Export the C pointer as a FORTRAN POINTER */
*pntr = cnfFptr( cpntr );
}
F77_SUBROUTINE(dat_mapc8)( CHARACTER(locator),
CHARACTER(mode),
F77_INTEGER_TYPE *ndim,
F77_INTEGER8_TYPE dims[],
F77_POINTER_TYPE *pntr,
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(mode) )
{
/*====================================*/
/* DAT_MAPC8 - Map _CHAR primitive(s) */
/*====================================*/
/* Local variables. */
HDSLoc *locator_c = NULL;
char mode_c[DAT__SZMOD+1];
unsigned char *cpntr = NULL; /* Initialise in case of bad return status */
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status);
/* Import mode string */
cnfImpn( mode, mode_length, DAT__SZMOD, mode_c);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C8( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datMapC( locator_c, mode_c, *ndim, cdims, &cpntr, status);
/* Export the C pointer as a FORTRAN POINTER */
*pntr = cnfFptr( cpntr );
}
F77_SUBROUTINE(dat_mapd8)( CHARACTER(locator),
CHARACTER(mode),
F77_INTEGER_TYPE *ndim,
F77_INTEGER8_TYPE dims[],
F77_POINTER_TYPE *pntr,
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(mode) )
{
/*======================================*/
/* DAT_MAPD8 - Map _DOUBLE primitive(s) */
/*======================================*/
/* Local variables. */
HDSLoc *locator_c = NULL;
char mode_c[DAT__SZMOD+1];
double *cpntr = NULL; /* initialise in case of bad return status */
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import mode string */
cnfImpn( mode, mode_length, DAT__SZMOD, mode_c);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C8( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datMapD( locator_c, mode_c, *ndim, cdims, &cpntr, status);
/* Export the C pointer as a FORTRAN POINTER */
*pntr = cnfFptr( cpntr );
}
F77_SUBROUTINE(dat_mapi8)( CHARACTER(locator),
CHARACTER(mode),
F77_INTEGER_TYPE *ndim,
F77_INTEGER8_TYPE dims[],
F77_POINTER_TYPE *pntr,
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(mode) )
{
/*=======================================*/
/* DAT_MAPI8 - Map _INTEGER primitive(s) */
/*=======================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char mode_c[DAT__SZMOD+1];
int *cpntr = NULL; /* initialise in case of bad return status */
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import mode string */
cnfImpn( mode, mode_length, DAT__SZMOD, mode_c);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C8( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datMapI( locator_c, mode_c, *ndim, cdims, &cpntr, status);
/* Export the C pointer as a FORTRAN POINTER */
*pntr = cnfFptr( cpntr );
}
F77_SUBROUTINE(dat_mapk8)( CHARACTER(locator),
CHARACTER(mode),
F77_INTEGER_TYPE *ndim,
F77_INTEGER8_TYPE dims[],
F77_POINTER_TYPE *pntr,
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(mode) )
{
/*=======================================*/
/* DAT_MAPK8 - Map _INT64 primitive(s) */
/*=======================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char mode_c[DAT__SZMOD+1];
int *cpntr = NULL; /* initialise in case of bad return status */
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import mode string */
cnfImpn( mode, mode_length, DAT__SZMOD, mode_c);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C8( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datMapK( locator_c, mode_c, *ndim, cdims, &cpntr, status);
/* Export the C pointer as a FORTRAN POINTER */
*pntr = cnfFptr( cpntr );
}
F77_SUBROUTINE(dat_mapl8)( CHARACTER(locator),
CHARACTER(mode),
F77_INTEGER_TYPE *ndim,
F77_INTEGER8_TYPE dims[],
F77_POINTER_TYPE *pntr,
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(mode) )
{
/*=======================================*/
/* DAT_MAPL8 - Map _LOGICAL primitive(s) */
/*=======================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char mode_c[DAT__SZMOD+1];
int *cpntr = NULL; /* initialise in case of bad return status */
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import mode string */
cnfImpn( mode, mode_length, DAT__SZMOD, mode_c);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C8( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datMapL( locator_c, mode_c, *ndim, cdims, &cpntr, status);
/* Export the C pointer as a FORTRAN POINTER */
*pntr = cnfFptr( cpntr );
}
F77_SUBROUTINE(dat_mapr8)( CHARACTER(locator),
CHARACTER(mode),
F77_INTEGER_TYPE *ndim,
F77_INTEGER8_TYPE dims[],
F77_POINTER_TYPE *pntr,
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(mode) )
{
/*====================================*/
/* DAT_MAPR8 - Map _REAL primitive(s) */
/*====================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char mode_c[DAT__SZMOD+1];
float *cpntr = NULL; /* initialise in case of bad return status */
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import mode string */
cnfImpn( mode, mode_length, DAT__SZMOD, mode_c);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C8( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datMapR( locator_c, mode_c, *ndim, cdims, &cpntr, status );
/* Export the C pointer as a FORTRAN POINTER */
*pntr = cnfFptr( cpntr );
}
F77_SUBROUTINE(dat_mapn8)( CHARACTER(locator),
CHARACTER(type),
CHARACTER(mode),
INTEGER(ndim),
F77_POINTER_TYPE *pntr,
F77_INTEGER8_TYPE dims[],
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(type)
TRAIL(mode) )
{
/*==============================*/
/* DAT_MAPN8 - Map primitive(s) */
/*==============================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char type_c[DAT__SZTYP+1];
char mode_c[DAT__SZMOD+1];
void *cpntr = NULL; /* initialise in case of bad return status */
hdsdim cdims[DAT__MXDIM];
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import FORTRAN to C strings */
cnfImpn( type, type_length, DAT__SZTYP, type_c);
cnfImpn( mode, mode_length, DAT__SZMOD, mode_c);
/* Call pure C routine */
datMapN( locator_c, type_c, mode_c, *ndim, &cpntr, cdims, status);
/* Handle copying to Fortran dims */
(void)hdsDimC2F8( *ndim, cdims, dims, status );
/* Export the C pointer as a FORTRAN POINTER */
*pntr = cnfFptr( cpntr );
}
F77_SUBROUTINE(dat_mapv8)( CHARACTER(locator),
CHARACTER(type),
CHARACTER(mode),
F77_POINTER_TYPE *pntr,
F77_INTEGER8_TYPE *actval,
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(type)
TRAIL(mode) )
{
/*=========================================*/
/* DAT_MAPV8 - Map vectorized primitive(s) */
/*=========================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char mode_c[DAT__SZMOD+1];
char type_c[DAT__SZTYP+1];
void *cpntr = NULL; /* initialise in case of bad return status */
size_t actval_c;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import mode and type string */
cnfImpn( mode, mode_length, DAT__SZMOD, mode_c);
cnfImpn( type, type_length, DAT__SZTYP, type_c);
datMapV( locator_c, type_c, mode_c, &cpntr, &actval_c, status);
/* Export the C pointer as a FORTRAN POINTER */
*pntr = cnfFptr( cpntr );
*actval = (F77_INTEGER8_TYPE) actval_c;
}
F77_SUBROUTINE(dat_mould8)( CHARACTER(locator),
F77_INTEGER_TYPE *ndim,
F77_INTEGER8_TYPE dims[],
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*====================================*/
/* DAT_MOULD8 - Alter shape of object */
/*====================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C8( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datMould( locator_c, *ndim, cdims, status );
}
F77_SUBROUTINE(dat_new8)( CHARACTER(locator),
CHARACTER(name),
CHARACTER(type),
F77_INTEGER_TYPE *ndim,
F77_INTEGER8_TYPE dims[],
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(name)
TRAIL(type) )
{
/*=================================*/
/* DAT_NEW8 - Create new component */
/*=================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char name_c[DAT__SZNAM+1];
char type_c[DAT__SZTYP+1];
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import FORTRAN to C strings */
cnfImpn( name, name_length, DAT__SZNAM, name_c);
cnfImpn( type, type_length, DAT__SZTYP, type_c);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C8( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datNew( locator_c, name_c, type_c, *ndim, cdims, status);
}
F77_SUBROUTINE(dat_newc8)( CHARACTER(locator),
CHARACTER(name),
F77_INTEGER_TYPE *len,
F77_INTEGER_TYPE *ndim,
F77_INTEGER8_TYPE dims[],
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(name) )
{
/*=============================================*/
/* DAT_NEWC8 - Create new _CHAR type component */
/*=============================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
char name_c[DAT__SZNAM+1];
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import "name" to C string */
cnfImpn( name, name_length, DAT__SZNAM, name_c );
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C8( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datNewC( locator_c, name_c, *len, *ndim, cdims, status );
}
F77_SUBROUTINE(dat_new18)( CHARACTER(locator),
CHARACTER(name),
CHARACTER(type),
INTEGER8(len),
INTEGER(status)
TRAIL(locator)
TRAIL(name)
TRAIL(type) )
{
/*========================================*/
/* DAT_NEW1 - Create new vector component */
/*========================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
char name_c[DAT__SZNAM+1];
char type_c[DAT__SZTYP+1];
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import "name" and "type" to C string */
cnfImpn( name, name_length, DAT__SZNAM, name_c );
cnfImpn( type, type_length, DAT__SZNAM, type_c );
datNew1( locator_c, name_c, type_c, *len, status );
}
F77_SUBROUTINE(dat_new1d8)( CHARACTER(locator),
CHARACTER(name),
INTEGER8(len),
INTEGER(status)
TRAIL(locator)
TRAIL(name) )
{
/*=================================================*/
/* DAT_NEW1D8 - Create new vector double component */
/*=================================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
char name_c[DAT__SZNAM+1];
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import "name" to C string */
cnfImpn( name, name_length, DAT__SZNAM, name_c );
datNew1D( locator_c, name_c, *len, status );
}
F77_SUBROUTINE(dat_new1i8)( CHARACTER(locator),
CHARACTER(name),
INTEGER8(len),
INTEGER(status)
TRAIL(locator)
TRAIL(name) )
{
/*==================================================*/
/* DAT_NEW1I8 - Create new vector integer component */
/*==================================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
char name_c[DAT__SZNAM+1];
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import "name" to C string */
cnfImpn( name, name_length, DAT__SZNAM, name_c );
datNew1I( locator_c, name_c, *len, status );
}
F77_SUBROUTINE(dat_new1k8)( CHARACTER(locator),
CHARACTER(name),
INTEGER8(len),
INTEGER(status)
TRAIL(locator)
TRAIL(name) )
{
/*=========================================================*/
/* DAT_NEW1K8 - Create new vector 64-bit integer component */
/*=========================================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
char name_c[DAT__SZNAM+1];
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import "name" to C string */
cnfImpn( name, name_length, DAT__SZNAM, name_c );
datNew1K( locator_c, name_c, *len, status );
}
F77_SUBROUTINE(dat_new1l8)( CHARACTER(locator),
CHARACTER(name),
INTEGER8(len),
INTEGER(status)
TRAIL(locator)
TRAIL(name) )
{
/*==================================================*/
/* DAT_NEW1L8 - Create new vector logical component */
/*==================================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
char name_c[DAT__SZNAM+1];
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import "name" to C string */
cnfImpn( name, name_length, DAT__SZNAM, name_c );
datNew1L( locator_c, name_c, *len, status );
}
F77_SUBROUTINE(dat_new1r8)( CHARACTER(locator),
CHARACTER(name),
INTEGER8(len),
INTEGER(status)
TRAIL(locator)
TRAIL(name) )
{
/*=================================================*/
/* DAT_NEW1R8 - Create new vector double component */
/*=================================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
char name_c[DAT__SZNAM+1];
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import "name" to C string */
cnfImpn( name, name_length, DAT__SZNAM, name_c );
datNew1R( locator_c, name_c, *len, status );
}
F77_SUBROUTINE(dat_new1c8)( CHARACTER(locator),
CHARACTER(name),
INTEGER8(len),
INTEGER(nelem),
INTEGER(status)
TRAIL(locator)
TRAIL(name) )
{
/*=================================================*/
/* DAT_NEW1C8 - Create new vector string component */
/*=================================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
char name_c[DAT__SZNAM+1];
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import "name" to C string */
cnfImpn( name, name_length, DAT__SZNAM, name_c );
datNew1C( locator_c, name_c, *len, *nelem, status );
}
F77_SUBROUTINE(dat_putc8)( CHARACTER(locator),
F77_INTEGER_TYPE *ndim,
F77_INTEGER8_TYPE dims[],
CHARACTER(values),
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(values) )
{
/*===================================*/
/* DAT_PUTC8 - Write _CHAR primitive */
/*===================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C8( *ndim, dims, dimbuf, status );
/* Call C routine */
datPutC( locator_c, *ndim, cdims, values, values_length, status);
}
F77_SUBROUTINE(dat_putd8)( CHARACTER(locator),
F77_INTEGER_TYPE *ndim,
F77_INTEGER8_TYPE dims[],
F77_DOUBLE_TYPE *values,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*======================================*/
/* DAT_PUTD8 - Write _DOUBLE primitives */
/*======================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C8( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datPutD( locator_c, *ndim, cdims, values, status );
}
F77_SUBROUTINE(dat_puti8)( CHARACTER(locator),
F77_INTEGER_TYPE *ndim,
F77_INTEGER8_TYPE dims[],
F77_INTEGER_TYPE *values,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*=======================================*/
/* DAT_PUTI8 - Write _INTEGER primitives */
/*=======================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C8( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datPutI( locator_c, *ndim, cdims, values, status );
}
F77_SUBROUTINE(dat_putr8)( CHARACTER(locator),
F77_INTEGER_TYPE *ndim,
F77_INTEGER8_TYPE dims[],
F77_REAL_TYPE *values,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*====================================*/
/* DAT_PUTR8 - Write _REAL primitives */
/*====================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C8( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datPutR( locator_c, *ndim, cdims, values, status );
}
F77_SUBROUTINE(dat_putl8)( CHARACTER(locator),
F77_INTEGER_TYPE *ndim,
F77_INTEGER8_TYPE dims[],
F77_LOGICAL_TYPE *values,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*=======================================*/
/* DAT_PUTL8 - Write _LOGICAL primitives */
/*=======================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C8( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datPutL( locator_c, *ndim, cdims, values, status );
}
F77_SUBROUTINE(dat_put8)( CHARACTER(locator),
CHARACTER(type),
F77_INTEGER_TYPE *ndim,
F77_INTEGER8_TYPE dims[],
F77_BYTE_TYPE values[],
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(type)
TRAIL(values)
)
{
/*============================*/
/* DAT_PUT8 - Write primitive */
/*============================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char type_c[DAT__SZTYP+1];
int ischar = 0;
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import "type" string */
cnfImpn( type, type_length, DAT__SZTYP, type_c );
/* Special case _CHAR since fortran is telling us the length */
/* This may not be needed if the type string is _CHAR*nnn */
if (strncmp(type,"_CHAR",5) == 0) ischar = 1;
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C8( *ndim, dims, dimbuf, status );
/* Call pure C routine */
if (ischar) {
datPutC( locator_c, *ndim, cdims, (char *)values, values_length, status );
} else {
datPut( locator_c, type_c, *ndim, cdims, values, status );
}
}
F77_SUBROUTINE(dat_put1c8)( CHARACTER(locator),
INTEGER8(nval),
CHARACTER(values),
INTEGER(status)
TRAIL(locator)
TRAIL(values) )
{
HDSLoc * locator_c = NULL;
hdsdim dims[1];
size_t actvals;
if (*status != SAI__OK) return;
datImportFloc( locator, locator_length, &locator_c, status );
/* No C equivalent to call directly so we just call datPutC
after some bounds checking */
datSize( locator_c, &actvals, status );
if ( *status == SAI__OK ) {
if (actvals != (size_t)*nval) {
*status = DAT__BOUND;
emsSetk( "NV", *nval );
emsSetu( "SZ", actvals );
emsRep("DAT_PUT1C_ERR", "DAT_PUT1C: Bounds mismatch (^NV != ^SZ)", status );
} else {
dims[0] = *nval;
datPutC( locator_c, 1, dims, values, (size_t)values_length, status );
}
}
}
F77_SUBROUTINE(dat_put1d8)( CHARACTER(locator),
INTEGER8(nval),
F77_DOUBLE_TYPE *values,
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
datImportFloc( locator, locator_length, &locator_c, status );
datPut1D( locator_c, (size_t)*nval, values, status );
}
F77_SUBROUTINE(dat_put1i8)( CHARACTER(locator),
INTEGER8(nval),
F77_INTEGER_TYPE *values,
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
datImportFloc( locator, locator_length, &locator_c, status );
datPut1I( locator_c, (size_t)*nval, values, status );
}
F77_SUBROUTINE(dat_put1k8)( CHARACTER(locator),
INTEGER8(nval),
F77_INTEGER8_TYPE *values,
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
datImportFloc( locator, locator_length, &locator_c, status );
datPut1K( locator_c, (size_t)*nval, values, status );
}
F77_SUBROUTINE(dat_put1r8)( CHARACTER(locator),
INTEGER8(nval),
F77_REAL_TYPE *values,
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
datImportFloc( locator, locator_length, &locator_c, status );
datPut1R( locator_c, (size_t)*nval, values, status );
}
F77_SUBROUTINE(dat_put1l8)( CHARACTER(locator),
INTEGER8(nval),
F77_LOGICAL_TYPE *values,
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
datImportFloc( locator, locator_length, &locator_c, status );
datPut1L( locator_c, (size_t)*nval, values, status );
}
F77_SUBROUTINE(dat_putvd8)( CHARACTER(locator),
INTEGER8(nval),
F77_DOUBLE_TYPE *values,
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
datImportFloc( locator, locator_length, &locator_c, status );
datPutVD( locator_c, (size_t)*nval, values, status );
}
F77_SUBROUTINE(dat_putvi8)( CHARACTER(locator),
INTEGER8(nval),
F77_INTEGER_TYPE *values,
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
datImportFloc( locator, locator_length, &locator_c, status );
datPutVI( locator_c, (size_t)*nval, values, status );
}
F77_SUBROUTINE(dat_putvk8)( CHARACTER(locator),
INTEGER8(nval),
F77_INTEGER8_TYPE *values,
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
datImportFloc( locator, locator_length, &locator_c, status );
datPutVK( locator_c, (size_t)*nval, values, status );
}
F77_SUBROUTINE(dat_putvr8)( CHARACTER(locator),
INTEGER8(nval),
F77_REAL_TYPE *values,
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
datImportFloc( locator, locator_length, &locator_c, status );
datPutVR( locator_c, (size_t)*nval, values, status );
}
F77_SUBROUTINE(dat_putvl8)( CHARACTER(locator),
INTEGER8(nval),
F77_LOGICAL_TYPE *values,
INTEGER(status)
TRAIL(locator) )
{
HDSLoc * locator_c = NULL;
datImportFloc( locator, locator_length, &locator_c, status );
datPutVL( locator_c, (size_t)*nval, values, status );
}
/* Note that for dat_putvc we call the *Fortran* interface version
of dat_put1c since that includes all the correct bounds checking
and also deals with a char buffer rather than char ** */
F77_SUBROUTINE(dat_putvc8)( CHARACTER(locator),
INTEGER8(nval),
CHARACTER(values),
INTEGER(status)
TRAIL(locator)
TRAIL(values) )
{
HDSLoc * locator_c = NULL;
HDSLoc *vecloc_c = NULL;
char vecloc[DAT__SZLOC];
int vecloc_length = DAT__SZLOC;
if (*status != SAI__OK) return;
/* Import the fortran locator */
datImportFloc( locator, locator_length, &locator_c, status );
/* Vectorize it */
datVec( locator_c, &vecloc_c, status );
/* Export the new locator back to Fortran style */
datExportFloc( &vecloc_c, 0, DAT__SZLOC, vecloc, status );
/* Call Fortran dat_put1c since that does all the bounds checking.
We do not need to lock a mutex because we know that this is
calling C code in this file.
*/
F77_CALL(dat_put1c8)( CHARACTER_ARG(vecloc), INTEGER8_ARG(nval),
CHARACTER_ARG(values), INTEGER_ARG(status)
TRAIL_ARG(vecloc) TRAIL_ARG(values) );
/* Now annul the vector locator */
datAnnul( &vecloc_c, status );
}
F77_SUBROUTINE(dat_shape8)( CHARACTER(locator),
F77_INTEGER_TYPE *ndimx,
F77_INTEGER8_TYPE dims[],
F77_INTEGER_TYPE *ndim,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*===================================*/
/* DAT_SHAPE8 - Enquire object shape */
/*===================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
hdsdim cdims[DAT__MXDIM];
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Call pure C routine */
datShape( locator_c, *ndimx, cdims, ndim, status );
/* Handle copying to Fortran dims */
(void)hdsDimC2F8( *ndim, cdims, dims, status );
}
F77_SUBROUTINE(dat_size8)( CHARACTER(locator),
F77_INTEGER8_TYPE *size,
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*=================================*/
/* DAT_SIZE8 - Enquire object size */
/*=================================*/
/* Local variables */
HDSLoc * locator_c = NULL;
size_t size_c;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Call pure C routine */
datSize( locator_c, &size_c, status );
*size = (F77_INTEGER8_TYPE) size_c;
}
F77_SUBROUTINE(dat_slice8)( CHARACTER(locator1),
F77_INTEGER_TYPE *ndim,
F77_INTEGER8_TYPE diml[],
F77_INTEGER8_TYPE dimu[],
CHARACTER(locator2),
F77_INTEGER_TYPE *status
TRAIL(locator1)
TRAIL(locator2) )
{
/*==================================*/
/* DAT_SLICE8 - Locate object slice */
/*==================================*/
/* Local variables. */
HDSLoc *locator1_c = NULL;
HDSLoc *locator2_c = NULL;
hdsdim dimlbuf[DAT__MXDIM];
hdsdim dimubuf[DAT__MXDIM];
hdsdim * cldims;
hdsdim * cudims;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator1, locator1_length, &locator1_c, status );
/* Ensure that array subscripts are correct */
cldims = hdsDimF2C8( *ndim, diml, dimlbuf, status );
cudims = hdsDimF2C8( *ndim, dimu, dimubuf, status );
/* Call pure C routine */
datSlice( locator1_c, *ndim, cldims, cudims, &locator2_c, status );
/* Export returned locator */
datExportFloc( &locator2_c, 1, locator2_length, locator2, status );
}
F77_SUBROUTINE(dat_temp8)( CHARACTER(type),
F77_INTEGER_TYPE *ndim,
F77_INTEGER8_TYPE dims[],
CHARACTER(locator),
F77_INTEGER_TYPE *status
TRAIL(type)
TRAIL(locator) )
{
/*=====================================*/
/* DAT_TEMP8 - Create temporary object */
/*=====================================*/
/* Local variables. */
HDSLoc *locator_c = NULL;
char type_c[DAT__SZTYP+1];
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import "type" to C string */
cnfImpn( type, type_length, DAT__SZTYP, type_c );
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C8( *ndim, dims, dimbuf, status );
/* Call pure C routine */
datTemp( type_c, *ndim, cdims, &locator_c, status);
/* Export returned locator */
datExportFloc( &locator_c, 1, locator_length, locator, status );
}
F77_SUBROUTINE(hds_new8)( CHARACTER(file),
CHARACTER(name),
CHARACTER(type),
F77_INTEGER_TYPE *ndim,
F77_INTEGER8_TYPE dims[],
CHARACTER(locator),
F77_INTEGER_TYPE *status
TRAIL(file)
TRAIL(name)
TRAIL(type)
TRAIL(locator) )
{
/*======================================*/
/* HDS_NEW8 - Create new container file */
/*======================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
char *file_c;
char name_c[DAT__SZNAM + 1];
char type_c[DAT__SZTYP + 1];
hdsdim dimbuf[DAT__MXDIM];
hdsdim * cdims;
/* Enter routine. */
/* Import FILE argument to C string */
file_c = cnfCreim( file, file_length );
/* Import FORTRAN to C strings */
cnfImpn( name, name_length, DAT__SZNAM, name_c);
cnfImpn( type, type_length, DAT__SZTYP, type_c);
/* Ensure that array subscripts are correct */
cdims = hdsDimF2C8( *ndim, dims, dimbuf, status );
/* Call pure C routine */
hdsNew( file_c, name_c, type_c, *ndim, cdims, &locator_c, status );
/* Export returned locator */
datExportFloc( &locator_c, 1, locator_length, locator, status );
/* Free allocated string memory. */
cnfFree( file_c );
}
/* ---------------------------------------------- */
/* Deprecated routines! */
/* ---------------------------------------------- */
F77_SUBROUTINE(dat_conv)( CHARACTER(locator),
CHARACTER(type),
F77_LOGICAL_TYPE *reply,
F77_INTEGER_TYPE *status
TRAIL(locator)
TRAIL(type))
{
/*=========================================*/
/* DAT_CONV - Enquire conversion possible? */
/*=========================================*/
/* Local variables. */
HDSLoc * locator_c = NULL;
int reply_c;
char type_c[DAT__SZTYP+1];
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Import "type" to C string */
cnfImpn( type, type_length, DAT__SZTYP, type_c);
/* Call pure C routine */
datConv( locator_c, type_c, &reply_c, status );
/* Set FORTRAN logical return */
if( reply_c )
*reply = F77_TRUE;
else
*reply = F77_FALSE;
}
F77_SUBROUTINE(hds_close)( CHARACTER(locator),
F77_INTEGER_TYPE *status
TRAIL(locator) )
{
/*======================================================*/
/* HDS_CLOSE - Close container file (Obselete routine!) */
/*======================================================*/
/* Local variables. */
HDSLoc *locator_c = NULL;
/* Enter routine. */
/* Import the input locator string */
datImportFloc( locator, locator_length, &locator_c, status );
/* Call pure C routine */
hdsClose( &locator_c, status );
/* Export nulled locator */
datExportFloc( &locator_c, 1, locator_length, locator, status );
}
/*==============================================*/
/* Obsolete routines that have no C counterpart */
/*==============================================*/
F77_SUBROUTINE(dat_rcera)( CHARACTER(locator), CHARACTER(cname), INTEGER(status)
TRAIL(locator) TRAIL(cname) )
{
/*=============================================*/
/* DAT_RCERA - recursive erase (use DAT_ERASE) */
/*=============================================*/
HDSLoc * locator_c = NULL;
char cname_c[DAT__SZNAM+1];
printf("DAT_RCERA() is deprecated. Please use DAT_ERASE instead\n");
cnfImpn( cname, cname_length, DAT__SZNAM, cname_c);
datImportFloc( locator, locator_length, &locator_c, status );
datErase( locator_c, cname_c, status );
return;
}
F77_SUBROUTINE(dat_tune) ( CHARACTER(name),
INTEGER(value),
INTEGER(status)
TRAIL(name) )
{
/*=========================================*/
/* DAT_TUNE - Set HDS tuning parameter */
/* Obsoleted by HDS_TUNE */
/*=========================================*/
/* Local variables. */
char *name_c;
/* Enter routine. */
if (*status != SAI__OK ) return;
printf("DAT_TUNE is obsoleted by HDS_TUNE\n");
/* Import NAME argument to C string */
name_c = cnfCreim( name, name_length );
/* Call pure C routine */
if (strncmp(name_c, "NCOMP", 5) == 0 ) {
hdsTune( name_c, *value, status );
} else {
emsSetc( "NM", name_c );
emsRep("DAT_TUNE_ERR", "Unrecognized tuning parameter (^NM)",
status );
}
/* Free allocated string memory. */
cnfFree( name_c );
}
F77_SUBROUTINE(dat_rcopy)( CHARACTER(locator1),
CHARACTER(locator2),
CHARACTER(name),
INTEGER(status)
TRAIL(locator1)
TRAIL(locator2)
TRAIL(name) )
{
/*===================================*/
/* DAT_RCOPY - Recursive copy object */
/* Obsoleted by DAT_COPY */
/*===================================*/
/* Local variables. */
HDSLoc *locator1_c = NULL;
HDSLoc *locator2_c = NULL;
char name_c[DAT__SZNAM+1];
/* Enter routine. */
printf("DAT_RCOPY() is deprecated. Please use DAT_ERASE instead\n");
/* Import name string */
cnfImpn( name, name_length, DAT__SZNAM, name_c);
/* Import the locator strings */
datImportFloc( locator1, locator1_length, &locator1_c, status);
datImportFloc( locator2, locator2_length, &locator2_c, status);
/* Call pure C routine */
datCopy( locator1_c, locator2_c, name_c, status);
}
F77_SUBROUTINE(dat_ertxt)(CHARACTER(text), INTEGER(status) TRAIL(text) )
{
/*==================================================*/
/* DAT_ERTXT - Report Error */
/* Obsolete as HDS now reports errors using EMS */
/*==================================================*/
/* Local Variables: */
char msg[EMS__SZMSG+1]; /* Pointer error buffer */
size_t lmsg; /* Length of error message */
char *text_c; /* Input text */
text_c = cnfCreim( text, text_length );
/* Get textual translation of the error code */
datErmsg( *status, &lmsg, msg );
/* Mark the EMS error stack to prevent interaction with any message
* tokens already defined and define a token for the text and the error
* message. */
emsMark();
emsSetc( "TEXT", text );
emsSetc( "MSG", msg );
/* Report the message and release the error stack. */
emsRep( "HDS_ERROR", "^TEXT: ^MSG", status );
emsRlse();
cnfFree( text_c );
}
F77_SUBROUTINE(dat_erdsc)( CHARACTER(locator), INTEGER(status) TRAIL(locator) )
{
/*==================================================*/
/* DAT_ERDSC - Report Object Error */
/* Obsolete as HDS now reports errors using EMS */
/*==================================================*/
/* Local variables : */
HDSLoc * locator_c = NULL;
char file[EMS__SZMSG+1]; /* Container file name */
char msg[EMS__SZMSG+1]; /* Error message */
char name[EMS__SZMSG+1]; /* Object pathname */
int lstat; /* Local status */
size_t lmsg; /* Length of error message */
int nlev; /* Number of object levels */
/* Mark the EMS error stack to prevent interaction with any message
tokens already defined. */
emsMark();
/* Import locator using local status */
lstat = SAI__OK;
datImportFloc( locator, locator_length, &locator_c, &lstat );
/* obtain the object name. */
hdsTrace( locator_c, &nlev, name, file, &lstat, sizeof(name), sizeof(file) );
/* If the name could not be obtained, then annul the error and
substitute an appropriate message. */
if (lstat != SAI__OK ) {
strcpy( name, "<Unknown object>" );
emsAnnul( &lstat );
}
/* Obtain a textual translation of the error code. */
datErmsg( *status, &lmsg, msg );
/* Define tokens for the object name and the error message. */
emsSetc( "NAME", name );
emsSetnc( "MSG", msg, lmsg );
/* Report the message and release the error stack. */
emsRep( "HDS_ERROR", "^NAME: ^MSG", status );
emsRlse();
}
F77_SUBROUTINE(dat_erdsn)( CHARACTER(locator), CHARACTER(cmp),
INTEGER(status) TRAIL(locator) TRAIL(cmp) )
{
/*==================================================*/
/* DAT_ERDSN - Report component Error */
/* Obsolete as HDS now reports errors using EMS */
/*==================================================*/
/* Local variables : */
HDSLoc * locator_c = NULL;
char cmp_c[DAT__SZNAM+1];
char file[EMS__SZMSG+1]; /* Container file name */
char msg[EMS__SZMSG+1]; /* Error message */
char name[EMS__SZMSG+1]; /* Object pathname */
int lstat; /* Local status */
size_t lmsg; /* Length of error message */
int nlev; /* Number of object levels */
/* Import the component name */
cnfImpn( cmp, cmp_length, DAT__SZNAM, cmp_c);
/* Mark the EMS error stack to prevent interaction with any message
tokens already defined. */
emsMark();
/* Import locator using local status */
lstat = SAI__OK;
datImportFloc( locator, locator_length, &locator_c, &lstat );
/* obtain the object name. */
hdsTrace( locator_c, &nlev, name, file, &lstat, sizeof(name), sizeof(file) );
/* If the name could not be obtained, then annul the error and
substitute an appropriate message. */
if (lstat != SAI__OK ) {
strcpy( name, "<Unknown structure>" );
emsAnnul( &lstat );
}
/* Obtain a textual translation of the error code. */
datErmsg( *status, &lmsg, msg );
/* Define tokens for the object name, component name and the error message. */
emsSetc( "NAME", name );
emsSetnc( "MSG", msg, lmsg );
emsSetc("CMP", cmp_c );
/* Report the message and release the error stack. */
emsRep( "HDS_ERROR", "^NAME.^CMP: ^MSG", status );
emsRlse();
}
|
e0931d23e459a0d44bb3c56e2bf7c4f5150816c7
|
961deb12b1050a6883ce6c9427836b908ca91875
|
/aosp/libavb1.1/src/avb/c/avb_hash_descriptor.c
|
3a6b8c8809118294aa3b7e044d270ed97ee4b4ee
|
[
"Apache-2.0"
] |
permissive
|
cfig/Android_boot_image_editor
|
04ff01545ff7ee4df2c02c529280e5362496abf0
|
82ff5215b7eb4bb6198ca024267c454f1e7958da
|
refs/heads/master
| 2023-09-01T13:32:20.862861
| 2023-07-14T14:52:53
| 2023-07-14T15:41:55
| 56,238,465
| 834
| 197
|
Apache-2.0
| 2022-07-29T00:19:36
| 2016-04-14T13:12:18
|
C
|
UTF-8
|
C
| false
| false
| 2,554
|
c
|
avb_hash_descriptor.c
|
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "avb_hash_descriptor.h"
#include "avb_util.h"
bool avb_hash_descriptor_validate_and_byteswap(const AvbHashDescriptor* src,
AvbHashDescriptor* dest) {
uint64_t expected_size;
avb_memcpy(dest, src, sizeof(AvbHashDescriptor));
if (!avb_descriptor_validate_and_byteswap((const AvbDescriptor*)src,
(AvbDescriptor*)dest))
return false;
if (dest->parent_descriptor.tag != AVB_DESCRIPTOR_TAG_HASH) {
avb_error("Invalid tag for hash descriptor.\n");
return false;
}
dest->image_size = avb_be64toh(dest->image_size);
dest->partition_name_len = avb_be32toh(dest->partition_name_len);
dest->salt_len = avb_be32toh(dest->salt_len);
dest->digest_len = avb_be32toh(dest->digest_len);
dest->flags = avb_be32toh(dest->flags);
/* Check that partition_name, salt, and digest are fully contained. */
expected_size = sizeof(AvbHashDescriptor) - sizeof(AvbDescriptor);
if (!avb_safe_add_to(&expected_size, dest->partition_name_len) ||
!avb_safe_add_to(&expected_size, dest->salt_len) ||
!avb_safe_add_to(&expected_size, dest->digest_len)) {
avb_error("Overflow while adding up sizes.\n");
return false;
}
if (expected_size > dest->parent_descriptor.num_bytes_following) {
avb_error("Descriptor payload size overflow.\n");
return false;
}
return true;
}
|
dd4d9115d0f209bd7128251ef448b64b706f1ec4
|
03b2c80dbc41e904b167d504666e27d798da5447
|
/src/sequence_range.c
|
b24b816dd85b1325c0d11f6120fe4728dbf8f99b
|
[
"Unlicense"
] |
permissive
|
nptcl/npt
|
7c1570b497cdce0b8971cb445fbc04cb500232d3
|
aa714a2370ac9fa5348c2fc96159b40b9de3de07
|
refs/heads/master
| 2023-03-20T09:13:54.669118
| 2022-07-02T11:17:44
| 2022-07-02T11:17:44
| 171,985,905
| 160
| 12
|
Unlicense
| 2023-03-11T01:36:37
| 2019-02-22T03:11:34
|
C
|
UTF-8
|
C
| false
| false
| 9,564
|
c
|
sequence_range.c
|
#include "array_access.h"
#include "array_value.h"
#include "condition.h"
#include "cons.h"
#include "cons_list.h"
#include "integer.h"
#include "sequence.h"
#include "sequence_range.h"
/*
* save/load
*/
void save_sequence_range(struct sequence_range *ptr)
{
ptr->save_pos = ptr->pos;
ptr->save_list = ptr->list;
ptr->save_prev = ptr->prev;
ptr->save_size = ptr->size;
ptr->save_end = ptr->end;
ptr->save_index = ptr->index;
}
void load_sequence_range(struct sequence_range *ptr)
{
ptr->pos = ptr->save_pos;
ptr->list = ptr->save_list;
ptr->prev = ptr->save_prev;
ptr->size = ptr->save_size;
ptr->end = ptr->save_end;
ptr->index = ptr->save_index;
}
/*
* build
*/
int build_sequence_range_(struct sequence_range *ptr,
addr pos, addr start, addr end)
{
int listp;
addr list, prev;
size_t index1, index2, size;
clearpoint(ptr);
Return(listp_sequence_(pos, &listp));
ptr->pos = list = pos;
ptr->listp = listp;
if (start == Nil || start == Unbound)
start = fixnumh(0);
if (end == Nil)
end = Unbound;
if (listp) {
Return(list_start_end_sequence_(&list, &prev, start, end, &index1, &index2));
ptr->list = list;
ptr->prev = prev;
ptr->start = index1;
ptr->endp = (end != Unbound);
if (ptr->endp) {
ptr->end = index2;
ptr->size = index2 - index1;
}
else {
ptr->end = 0;
ptr->size = 0;
}
ptr->index = index1;
}
else {
Return(length_sequence_(pos, 1, &size));
Return(size_start_end_sequence_(start, end, size, &index1, &index2, NULL));
ptr->prev = Nil;
ptr->start = index1;
ptr->endp = 1;
ptr->end = index2;
ptr->size = index2 - index1;
ptr->index = index1;
}
save_sequence_range(ptr);
return 0;
}
static int build_sequence_range_force_vector_(struct sequence_range *ptr,
addr pos, addr start, addr end)
{
size_t index1, index2, size;
clearpoint(ptr);
ptr->pos = pos;
ptr->listp = 0;
if (start == Nil || start == Unbound)
start = fixnumh(0);
if (end == Nil)
end = Unbound;
Return(length_sequence_(pos, 1, &size));
Return(size_start_end_sequence_(start, end, size, &index1, &index2, NULL));
ptr->prev = Nil;
ptr->start = index1;
ptr->endp = 1;
ptr->end = index2;
ptr->size = index2 - index1;
ptr->index = index1;
save_sequence_range(ptr);
return 0;
}
static struct sequence_range *sequence_range_local(LocalRoot local)
{
return (struct sequence_range *)lowlevel_local(local,
sizeoft(struct sequence_range));
}
int make_sequence_range_(LocalRoot local,
addr pos, addr start, addr end, struct sequence_range **ret)
{
struct sequence_range *ptr;
ptr = sequence_range_local(local);
Return(build_sequence_range_(ptr, pos, start, end));
return Result(ret, ptr);
}
static int start_end_sequence_range_(
addr list, size_t index1, size_t index2, addr end, size_t *ret)
{
size_t size;
for (size = 0; ; size++, index1++) {
if (end != Nil && end != Unbound) {
if (index2 <= index1)
break;
if (list == Nil) {
*ret = 0;
return fmte_(":END ~A "
"must be less than equal to list length.", end, NULL);
}
}
else if (list == Nil) {
break;
}
if (! consp(list)) {
*ret = 0;
return fmte_("Don't accept the dotted list ~S.", list, NULL);
}
GetCdr(list, &list);
}
return Result(ret, size);
}
int build_sequence_range_endp_(struct sequence_range *ptr,
addr list, addr start, addr end)
{
Return(build_sequence_range_(ptr, list, start, end));
if (! ptr->endp) {
Return(length_list_safe_(ptr->list, &(ptr->size)));
ptr->end = ptr->start + ptr->size;
ptr->endp = 1;
}
return 0;
}
int make_sequence_range_endp_(LocalRoot local,
addr list, addr start, addr end, struct sequence_range **ret)
{
struct sequence_range *ptr;
ptr = sequence_range_local(local);
Return(build_sequence_range_endp_(ptr, list, start, end));
return Result(ret, ptr);
}
int build_sequence_range_vector2_(LocalRoot local,
struct sequence_range *ptr, addr list, addr start, addr end,
addr *root, addr *tail)
{
int check;
addr pos, value;
size_t index1, index2, size, i;
/* vector */
Return(listp_sequence_(list, &check));
if (! check)
return build_sequence_range_(ptr, list, start, end);
/* list */
Return(list_start_end_sequence_(&list, NULL, start, end, &index1, &index2));
Return(start_end_sequence_range_(list, index1, index2, end, &size));
if (root)
*root = list;
vector_local(local, &pos, size);
for (i = 0; i < size; i++) {
GetCons(list, &value, &list);
setarray(pos, i, value);
}
if (tail)
*tail = list;
return build_sequence_range_(ptr, pos, fixnumh(0), Nil);
}
int build_sequence_range_vector_(LocalRoot local,
struct sequence_range *ptr, addr list, addr start, addr end)
{
return build_sequence_range_vector2_(local, ptr, list, start, end, NULL, NULL);
}
int make_sequence_range_vector_(LocalRoot local,
addr list, addr start, addr end, struct sequence_range **ret)
{
struct sequence_range *ptr;
ptr = sequence_range_local(local);
Return(build_sequence_range_vector_(local, ptr, list, start, end));
return Result(ret, ptr);
}
int make_sequence_range_mismatch_(LocalRoot local,
addr list, addr start, addr end, struct sequence_range **ret)
{
struct sequence_range *ptr;
ptr = sequence_range_local(local);
Return(build_sequence_range_force_vector_(ptr, list, start, end));
return Result(ret, ptr);
}
static int getlist_sequence_range_(struct sequence_range *ptr, addr *value, int *ret)
{
if (! ptr->endp) {
if (ptr->list == Nil)
return Result(ret, 1);
else
goto normal;
}
if (ptr->index < ptr->end) {
if (ptr->list == Nil)
goto error;
else
goto normal;
}
return Result(ret, 1);
normal:
Return_getcar(ptr->list, value);
return Result(ret, 0);
error:
*ret = 0;
return fmte_(":END ~A must be less than equal to list length.",
intsizeh(ptr->end), NULL);
}
/*
* access
*/
int get_sequence_range_(struct sequence_range *ptr, addr *value, int *ret)
{
/* list */
if (ptr->listp)
return getlist_sequence_range_(ptr, value, ret);
/* vector */
if (ptr->end <= ptr->index)
return Result(ret, 1);
Return(getelt_sequence_(NULL, ptr->pos, ptr->index, value));
return Result(ret, 0);
}
int getnext_sequence_range_(struct sequence_range *ptr, addr *value, int *ret)
{
int check;
if (ptr->listp) {
Return(getlist_sequence_range_(ptr, value, &check));
if (! check) {
ptr->prev = ptr->list;
Return_getcons(ptr->list, value, &(ptr->list));
ptr->index++;
}
return Result(ret, check);
}
else {
if (ptr->end <= ptr->index)
return Result(ret, 1);
Return(getelt_sequence_(NULL, ptr->pos, ptr->index++, value));
return Result(ret, 0);
}
}
int next_sequence_range_(struct sequence_range *ptr, int *ret)
{
addr temp;
return getnext_sequence_range_(ptr, &temp, ret);
}
int endp_sequence_range(struct sequence_range *ptr)
{
if (ptr->endp)
return ptr->end <= ptr->index;
else
return ptr->list == Nil;
}
int set_sequence_range_(struct sequence_range *ptr, addr value)
{
Check(endp_sequence_range(ptr), "endp error");
if (ptr->listp) {
SetCar(ptr->list, value);
return 0;
}
else {
return setelt_sequence_(ptr->pos, ptr->index, value);
}
}
int getinplace_sequence_range_(struct sequence_range *ptr, struct array_value *ret)
{
Check(endp_sequence_range(ptr), "endp error");
if (ptr->listp) {
ret->type = ARRAY_TYPE_T;
GetCar(ptr->list, &(ret->value.object));
return 0;
}
else {
return getelt_inplace_sequence_(ptr->pos, ptr->index, ret);
}
}
int setinplace_sequence_range_(LocalRoot local,
struct sequence_range *ptr, const struct array_value *str)
{
addr value;
Check(endp_sequence_range(ptr), "endp error");
if (ptr->listp) {
Return(arrayvalue_alloc_(local, &value, str));
SetCar(ptr->list, value);
return 0;
}
else {
return setelt_inplace_sequence_(local, ptr->pos, ptr->index, str);
}
}
/*
* reverse
*/
void reverse_sequence_range(struct sequence_range *ptr)
{
Check(ptr->listp, "type error");
ptr->index = ptr->end;
}
int endp_reverse_sequence_range(struct sequence_range *ptr)
{
Check(ptr->listp, "type error");
return ptr->index <= ptr->start;
}
int next_reverse_sequence_range_(struct sequence_range *ptr, int *ret)
{
Check(ptr->listp, "type error");
if (endp_reverse_sequence_range(ptr))
return Result(ret, 1);
ptr->index--;
return Result(ret, 0);
}
int get_reverse_sequence_range_(struct sequence_range *ptr, addr *value, int *ret)
{
Check(ptr->listp, "type error");
if (endp_reverse_sequence_range(ptr))
return Result(ret, 1);
Return(getelt_sequence_(NULL, ptr->pos, ptr->index - 1, value));
return Result(ret, 0);
}
int getnext_reverse_sequence_range_(
struct sequence_range *ptr, addr *value, int *ret)
{
Check(ptr->listp, "type error");
if (endp_reverse_sequence_range(ptr))
return Result(ret, 1);
ptr->index--;
Return(getelt_sequence_(NULL, ptr->pos, ptr->index, value));
return Result(ret, 0);
}
int set_reverse_sequence_range_(struct sequence_range *ptr, addr value)
{
Check(endp_reverse_sequence_range(ptr), "endp error");
Check(ptr->listp, "type error");
return setelt_sequence_(ptr->pos, ptr->index - 1, value);
}
/*
* remove
*/
int remove_sequence_range_(struct sequence_range *ptr)
{
Check(! ptr->listp, "type error");
Check(ptr->list == Nil, "list error");
if (ptr->endp) {
if (ptr->end <= ptr->index)
return fmte_(":end size error", NULL);
ptr->end--;
ptr->size--;
}
if (ptr->prev == Nil) {
Return_getcdr(ptr->list, &(ptr->list));
ptr->pos = ptr->list;
}
else {
Return_getcdr(ptr->list, &(ptr->list));
Return_setcdr(ptr->prev, ptr->list);
}
return 0;
}
|
063ee64d992e8b96b713e4956578692aa099f98c
|
7f6c235b0598353549959c18f69eefd20b766907
|
/include/_DEVELOPMENT/sccz80/arch/zx.h
|
a56811f65d54cbdaa324ce7210042f573adb5455
|
[
"ClArtistic"
] |
permissive
|
z88dk/z88dk
|
46dfd4905f36d99333173cadd0a660839befc9f0
|
8b07f37cc43c5d9ffe69b563c80763491d8faff7
|
refs/heads/master
| 2023-09-04T19:29:49.254958
| 2023-09-03T20:51:24
| 2023-09-03T20:51:24
| 54,035,569
| 820
| 263
|
NOASSERTION
| 2023-09-05T11:09:04
| 2016-03-16T13:48:16
|
Assembly
|
UTF-8
|
C
| false
| false
| 12,409
|
h
|
zx.h
|
// automatically generated by m4 from headers in proto subdir
#ifndef __ARCH_ZX_H__
#define __ARCH_ZX_H__
#include <arch.h>
#include <stddef.h>
#include <rect.h>
// COMMON CONSTANTS
#define INK_BLACK 0x00
#define INK_BLUE 0x01
#define INK_RED 0x02
#define INK_MAGENTA 0x03
#define INK_GREEN 0x04
#define INK_CYAN 0x05
#define INK_YELLOW 0x06
#define INK_WHITE 0x07
#define PAPER_BLACK 0x00
#define PAPER_BLUE 0x08
#define PAPER_RED 0x10
#define PAPER_MAGENTA 0x18
#define PAPER_GREEN 0x20
#define PAPER_CYAN 0x28
#define PAPER_YELLOW 0x30
#define PAPER_WHITE 0x38
#define BRIGHT 0x40
#define FLASH 0x80
// GLOBAL VARIABLES
extern unsigned char GLOBAL_ZX_PORT_FE;
extern unsigned char GLOBAL_ZX_PORT_1FFD;
extern unsigned char GLOBAL_ZX_PORT_7FFD;
// IO MAPPED REGISTERS
#ifdef __CLANG
extern unsigned char IO_FE;
extern unsigned char IO_1FFD;
extern unsigned char IO_7FFD;
#else
__sfr __at 0xfe IO_FE;
__sfr __banked __at 0x1ffd IO_1FFD;
__sfr __banked __at 0x7ffd IO_7FFD;
#endif
// tape i/o
struct zxtapehdr
{
unsigned char hdtype; // 0 = program, 1 = num array, 2 = char array, 3 = code/binary
unsigned char hdname[10]; // space padded
unsigned int hdlen; // ELINE - PROG, length field, length field, length in bytes
unsigned int hdadd; // starting line number 0x8000 = none, lsb=0 msb=id, lsb=0 msb=id, address
unsigned int hdvars; // VARS - PROG, 0, 0, 0
};
#define ZXT_TYPE_HEADER 0
#define ZXT_TYPE_DATA 0xff
extern unsigned char __LIB__ zx_tape_load_block(void *dst,unsigned int len,unsigned char type) __smallc;
extern unsigned char __LIB__ zx_tape_load_block_callee(void *dst,unsigned int len,unsigned char type) __smallc __z88dk_callee;
#define zx_tape_load_block(a,b,c) zx_tape_load_block_callee(a,b,c)
extern unsigned char __LIB__ zx_tape_save_block(void *src,unsigned int len,unsigned char type) __smallc;
extern unsigned char __LIB__ zx_tape_save_block_callee(void *src,unsigned int len,unsigned char type) __smallc __z88dk_callee;
#define zx_tape_save_block(a,b,c) zx_tape_save_block_callee(a,b,c)
extern unsigned char __LIB__ zx_tape_verify_block(void *dst,unsigned int len,unsigned char type) __smallc;
extern unsigned char __LIB__ zx_tape_verify_block_callee(void *dst,unsigned int len,unsigned char type) __smallc __z88dk_callee;
#define zx_tape_verify_block(a,b,c) zx_tape_verify_block_callee(a,b,c)
// miscellaneous
extern void __LIB__ zx_border(unsigned char colour) __smallc __z88dk_fastcall;
extern void __LIB__ zx_cls(unsigned char attr) __smallc __z88dk_fastcall;
extern void __LIB__ zx_cls_attr(unsigned char attr) __smallc __z88dk_fastcall;
extern void __LIB__ zx_cls_pix(unsigned char pix) __smallc __z88dk_fastcall;
extern void __LIB__ zx_cls_wc(struct r_Rect8 *r,unsigned char attr) __smallc;
extern void __LIB__ zx_cls_wc_callee(struct r_Rect8 *r,unsigned char attr) __smallc __z88dk_callee;
#define zx_cls_wc(a,b) zx_cls_wc_callee(a,b)
extern void __LIB__ zx_cls_wc_attr(struct r_Rect8 *r,unsigned char attr) __smallc;
extern void __LIB__ zx_cls_wc_attr_callee(struct r_Rect8 *r,unsigned char attr) __smallc __z88dk_callee;
#define zx_cls_wc_attr(a,b) zx_cls_wc_attr_callee(a,b)
extern void __LIB__ zx_cls_wc_pix(struct r_Rect8 *r,unsigned char pix) __smallc;
extern void __LIB__ zx_cls_wc_pix_callee(struct r_Rect8 *r,unsigned char pix) __smallc __z88dk_callee;
#define zx_cls_wc_pix(a,b) zx_cls_wc_pix_callee(a,b)
extern void __LIB__ zx_scroll_up(unsigned char rows,unsigned char attr) __smallc;
extern void __LIB__ zx_scroll_up_callee(unsigned char rows,unsigned char attr) __smallc __z88dk_callee;
#define zx_scroll_up(a,b) zx_scroll_up_callee(a,b)
extern void __LIB__ zx_scroll_up_attr(unsigned char rows,unsigned char attr) __smallc;
extern void __LIB__ zx_scroll_up_attr_callee(unsigned char rows,unsigned char attr) __smallc __z88dk_callee;
#define zx_scroll_up_attr(a,b) zx_scroll_up_attr_callee(a,b)
extern void __LIB__ zx_scroll_up_pix(unsigned char rows,unsigned char pix) __smallc;
extern void __LIB__ zx_scroll_up_pix_callee(unsigned char rows,unsigned char pix) __smallc __z88dk_callee;
#define zx_scroll_up_pix(a,b) zx_scroll_up_pix_callee(a,b)
extern void __LIB__ zx_scroll_wc_up(struct r_Rect8 *r,unsigned char rows,unsigned char attr) __smallc;
extern void __LIB__ zx_scroll_wc_up_callee(struct r_Rect8 *r,unsigned char rows,unsigned char attr) __smallc __z88dk_callee;
#define zx_scroll_wc_up(a,b,c) zx_scroll_wc_up_callee(a,b,c)
extern void __LIB__ zx_scroll_wc_up_attr(struct r_Rect8 *r,unsigned char rows,unsigned char attr) __smallc;
extern void __LIB__ zx_scroll_wc_up_attr_callee(struct r_Rect8 *r,unsigned char rows,unsigned char attr) __smallc __z88dk_callee;
#define zx_scroll_wc_up_attr(a,b,c) zx_scroll_wc_up_attr_callee(a,b,c)
extern void __LIB__ zx_scroll_wc_up_pix(struct r_Rect8 *r,unsigned char rows,unsigned char pix) __smallc;
extern void __LIB__ zx_scroll_wc_up_pix_callee(struct r_Rect8 *r,unsigned char rows,unsigned char pix) __smallc __z88dk_callee;
#define zx_scroll_wc_up_pix(a,b,c) zx_scroll_wc_up_pix_callee(a,b,c)
#ifdef __CLANG
extern void __LIB__ zx_visit_wc_attr(struct r_Rect8 *r,void (*visit)(unsigned char *)) __smallc;
extern void __LIB__ zx_visit_wc_attr_callee(struct r_Rect8 *r,void (*visit)(unsigned char *)) __smallc __z88dk_callee;
#define zx_visit_wc_attr(a,b) zx_visit_wc_attr_callee(a,b)
extern void __LIB__ zx_visit_wc_pix(struct r_Rect8 *r,void (*visit)(unsigned char *)) __smallc;
extern void __LIB__ zx_visit_wc_pix_callee(struct r_Rect8 *r,void (*visit)(unsigned char *)) __smallc __z88dk_callee;
#define zx_visit_wc_pix(a,b) zx_visit_wc_pix_callee(a,b)
#endif
#ifdef __SDCC
extern void __LIB__ zx_visit_wc_attr(struct r_Rect8 *r,void (*visit)(unsigned char *)) __smallc;
extern void __LIB__ zx_visit_wc_attr_callee(struct r_Rect8 *r,void (*visit)(unsigned char *)) __smallc __z88dk_callee;
#define zx_visit_wc_attr(a,b) zx_visit_wc_attr_callee(a,b)
extern void __LIB__ zx_visit_wc_pix(struct r_Rect8 *r,void (*visit)(unsigned char *)) __smallc;
extern void __LIB__ zx_visit_wc_pix_callee(struct r_Rect8 *r,void (*visit)(unsigned char *)) __smallc __z88dk_callee;
#define zx_visit_wc_pix(a,b) zx_visit_wc_pix_callee(a,b)
#endif
#ifdef __SCCZ80
extern void __LIB__ zx_visit_wc_attr(struct r_Rect8 *r,void *visit) __smallc;
extern void __LIB__ zx_visit_wc_attr_callee(struct r_Rect8 *r,void *visit) __smallc __z88dk_callee;
#define zx_visit_wc_attr(a,b) zx_visit_wc_attr_callee(a,b)
extern void __LIB__ zx_visit_wc_pix(struct r_Rect8 *r,void *visit) __smallc;
extern void __LIB__ zx_visit_wc_pix_callee(struct r_Rect8 *r,void *visit) __smallc __z88dk_callee;
#define zx_visit_wc_pix(a,b) zx_visit_wc_pix_callee(a,b)
#endif
// display
// In the following, screen address refers to a pixel address within the display file while
// attribute address refers to the attributes area.
//
// Function names are constructed from the following atoms:
//
// saddr = screen address
// aaddr = attribute address
//
// px = pixel x coordinate (0..255)
// py = pixel y coordinate (0..191)
// pxy = pixel (x,y) coordinate
//
// cx = character x coordinate (0..31)
// cy = character y coordinate (0..23)
// cxy = character (x,y) coordinate
//
// So for example:
//
// zx_saddr2cy(saddr) will return the character y coordinate corresponding to the given screen address
// zx_saddr2aaddr(saddr) will return the attribute address corresponding to the given screen address
// zx_pxy2aaddr(px,py) will return the attribute address corresponding to the given (x,y) pixel coordinate
//
// Some functions will return with carry flag set if coordinates or addresses move out of
// bounds. In these cases the special z88dk keywords iferror() and ifnerror() can be used
// to test the carry flag and determine if invalid results are returned. Check with the
// wiki documentation or the asm source files to see which functions support this. If
// comments in the asm source file do not mention this, it is not supported.
extern unsigned char __LIB__ zx_aaddr2cx(void *aaddr) __smallc __z88dk_fastcall;
extern unsigned char __LIB__ zx_aaddr2cy(void *aaddr) __smallc __z88dk_fastcall;
extern unsigned char __LIB__ zx_aaddr2px(void *aaddr) __smallc __z88dk_fastcall;
extern unsigned char __LIB__ zx_aaddr2py(void *aaddr) __smallc __z88dk_fastcall;
extern unsigned char __LIB__ *zx_aaddr2saddr(void *aaddr) __smallc __z88dk_fastcall;
extern unsigned char __LIB__ *zx_aaddrcdown(void *aaddr) __smallc __z88dk_fastcall;
extern unsigned char __LIB__ *zx_aaddrcleft(void *aaddr) __smallc __z88dk_fastcall;
extern unsigned char __LIB__ *zx_aaddrcright(void *aaddr) __smallc __z88dk_fastcall;
extern unsigned char __LIB__ *zx_aaddrcup(void *aaddr) __smallc __z88dk_fastcall;
extern unsigned char __LIB__ zx_bitmask2px(unsigned char bitmask) __smallc __z88dk_fastcall;
extern unsigned char __LIB__ *zx_cxy2aaddr(unsigned char x,unsigned char y) __smallc;
extern unsigned char __LIB__ *zx_cxy2aaddr_callee(unsigned char x,unsigned char y) __smallc __z88dk_callee;
#define zx_cxy2aaddr(a,b) zx_cxy2aaddr_callee(a,b)
extern unsigned char __LIB__ *zx_cxy2saddr(unsigned char x,unsigned char y) __smallc;
extern unsigned char __LIB__ *zx_cxy2saddr_callee(unsigned char x,unsigned char y) __smallc __z88dk_callee;
#define zx_cxy2saddr(a,b) zx_cxy2saddr_callee(a,b)
extern unsigned char __LIB__ *zx_cy2aaddr(unsigned char y) __smallc __z88dk_fastcall;
extern unsigned char __LIB__ *zx_cy2saddr(unsigned char y) __smallc __z88dk_fastcall;
extern unsigned char __LIB__ zx_px2bitmask(unsigned char x) __smallc __z88dk_fastcall;
extern unsigned char __LIB__ *zx_pxy2aaddr(unsigned char x,unsigned char y) __smallc;
extern unsigned char __LIB__ *zx_pxy2aaddr_callee(unsigned char x,unsigned char y) __smallc __z88dk_callee;
#define zx_pxy2aaddr(a,b) zx_pxy2aaddr_callee(a,b)
extern unsigned char __LIB__ *zx_pxy2saddr(unsigned char x,unsigned char y) __smallc;
extern unsigned char __LIB__ *zx_pxy2saddr_callee(unsigned char x,unsigned char y) __smallc __z88dk_callee;
#define zx_pxy2saddr(a,b) zx_pxy2saddr_callee(a,b)
extern unsigned char __LIB__ *zx_py2aaddr(unsigned char y) __smallc __z88dk_fastcall;
extern unsigned char __LIB__ *zx_py2saddr(unsigned char y) __smallc __z88dk_fastcall;
extern unsigned char __LIB__ *zx_saddr2aaddr(void *saddr) __smallc __z88dk_fastcall;
extern unsigned char __LIB__ zx_saddr2cx(void *saddr) __smallc __z88dk_fastcall;
extern unsigned char __LIB__ zx_saddr2cy(void *saddr) __smallc __z88dk_fastcall;
extern unsigned int __LIB__ zx_saddr2px(void *saddr) __smallc __z88dk_fastcall;
extern unsigned int __LIB__ zx_saddr2py(void *saddr) __smallc __z88dk_fastcall;
extern unsigned char __LIB__ *zx_saddrcdown(void *saddr) __smallc __z88dk_fastcall;
extern unsigned char __LIB__ *zx_saddrcleft(void *saddr) __smallc __z88dk_fastcall;
extern unsigned char __LIB__ *zx_saddrcright(void *saddr) __smallc __z88dk_fastcall;
extern unsigned char __LIB__ *zx_saddrcup(void *saddr) __smallc __z88dk_fastcall;
extern unsigned char __LIB__ *zx_saddrpdown(void *saddr) __smallc __z88dk_fastcall;
extern unsigned char __LIB__ *zx_saddrpleft(void *saddr,unsigned char bitmask) __smallc;
extern unsigned char __LIB__ *zx_saddrpleft_callee(void *saddr,unsigned char bitmask) __smallc __z88dk_callee;
#define zx_saddrpleft(a,b) zx_saddrpleft_callee(a,b)
extern unsigned char __LIB__ *zx_saddrpright(void *saddr,unsigned char bitmask) __smallc;
extern unsigned char __LIB__ *zx_saddrpright_callee(void *saddr,unsigned char bitmask) __smallc __z88dk_callee;
#define zx_saddrpright(a,b) zx_saddrpright_callee(a,b)
extern unsigned char __LIB__ *zx_saddrpup(void *saddr) __smallc __z88dk_fastcall;
// graphics
extern int __LIB__ zx_pattern_fill(unsigned char x,unsigned char y,void *pattern,unsigned int depth) __smallc;
extern int __LIB__ zx_pattern_fill_callee(unsigned char x,unsigned char y,void *pattern,unsigned int depth) __smallc __z88dk_callee;
#define zx_pattern_fill(a,b,c,d) zx_pattern_fill_callee(a,b,c,d)
#endif
|
f18b25259d3944e27312cef4d42ed91d1b498edc
|
eb9bfc910667d3ce3e9a93d7f928619d224d4f86
|
/plc4c/generated-sources/s7/include/cotp_parameter.h
|
6b310ef403c67b8cca4ee3a02c23ed768fabaeb2
|
[
"Unlicense",
"Apache-2.0"
] |
permissive
|
apache/plc4x
|
ae2e60cf98e742c410f9ee691b1e2eaecd405f96
|
a05857e0dd18951223293e73beaaa1c46f6c78ab
|
refs/heads/develop
| 2023-09-04T13:54:26.459699
| 2023-09-04T12:24:37
| 2023-09-04T12:24:37
| 114,859,883
| 842
| 362
|
Apache-2.0
| 2023-09-08T06:46:49
| 2017-12-20T08:00:09
|
Java
|
UTF-8
|
C
| false
| false
| 3,985
|
h
|
cotp_parameter.h
|
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#ifndef PLC4C_S7_READ_WRITE_COTP_PARAMETER_H_
#define PLC4C_S7_READ_WRITE_COTP_PARAMETER_H_
#include <stdbool.h>
#include <stdint.h>
#include <plc4c/spi/context.h>
#include <plc4c/spi/read_buffer.h>
#include <plc4c/spi/write_buffer.h>
#include <plc4c/utils/list.h>
#include "cotp_tpdu_size.h"
// Code generated by code-generation. DO NOT EDIT.
// Structure used to contain the discriminator values for discriminated types using this as a parent
struct plc4c_s7_read_write_cotp_parameter_discriminator {
uint8_t parameterType;
};
typedef struct plc4c_s7_read_write_cotp_parameter_discriminator plc4c_s7_read_write_cotp_parameter_discriminator;
// Enum assigning each subtype an individual id.
enum plc4c_s7_read_write_cotp_parameter_type {
plc4c_s7_read_write_cotp_parameter_type_plc4c_s7_read_write_cotp_parameter_tpdu_size = 0,
plc4c_s7_read_write_cotp_parameter_type_plc4c_s7_read_write_cotp_parameter_calling_tsap = 1,
plc4c_s7_read_write_cotp_parameter_type_plc4c_s7_read_write_cotp_parameter_called_tsap = 2,
plc4c_s7_read_write_cotp_parameter_type_plc4c_s7_read_write_cotp_parameter_checksum = 3,
plc4c_s7_read_write_cotp_parameter_type_plc4c_s7_read_write_cotp_parameter_disconnect_additional_information = 4};
typedef enum plc4c_s7_read_write_cotp_parameter_type plc4c_s7_read_write_cotp_parameter_type;
// Function to get the discriminator values for a given type.
plc4c_s7_read_write_cotp_parameter_discriminator plc4c_s7_read_write_cotp_parameter_get_discriminator(plc4c_s7_read_write_cotp_parameter_type type);
struct plc4c_s7_read_write_cotp_parameter {
/* This is an abstract type so this property saves the type of this typed union */
plc4c_s7_read_write_cotp_parameter_type _type;
/* Properties */
union {
struct { /* COTPParameterTpduSize */
plc4c_s7_read_write_cotp_tpdu_size cotp_parameter_tpdu_size_tpdu_size;
};
struct { /* COTPParameterCallingTsap */
uint16_t cotp_parameter_calling_tsap_tsap_id;
};
struct { /* COTPParameterCalledTsap */
uint16_t cotp_parameter_called_tsap_tsap_id;
};
struct { /* COTPParameterChecksum */
uint8_t cotp_parameter_checksum_crc;
};
struct { /* COTPParameterDisconnectAdditionalInformation */
plc4c_list* cotp_parameter_disconnect_additional_information_data;
};
};
};
typedef struct plc4c_s7_read_write_cotp_parameter plc4c_s7_read_write_cotp_parameter;
// Create an empty NULL-struct
plc4c_s7_read_write_cotp_parameter plc4c_s7_read_write_cotp_parameter_null();
plc4c_return_code plc4c_s7_read_write_cotp_parameter_parse(plc4x_spi_context ctx, plc4c_spi_read_buffer* readBuffer, uint8_t rest, plc4c_s7_read_write_cotp_parameter** message);
plc4c_return_code plc4c_s7_read_write_cotp_parameter_serialize(plc4x_spi_context ctx, plc4c_spi_write_buffer* writeBuffer, plc4c_s7_read_write_cotp_parameter* message);
uint16_t plc4c_s7_read_write_cotp_parameter_length_in_bytes(plc4x_spi_context ctx, plc4c_s7_read_write_cotp_parameter* message);
uint16_t plc4c_s7_read_write_cotp_parameter_length_in_bits(plc4x_spi_context ctx, plc4c_s7_read_write_cotp_parameter* message);
#endif // PLC4C_S7_READ_WRITE_COTP_PARAMETER_H_
|
04835254c6a28897895e103de37a4f9a9e2e2428
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/u-boot_new/board/renesas/rsk7203/rsk7203.c
|
8800371b00427b5bf0f4cc08c97adcc3bdbcb0aa
|
[
"GPL-2.0-or-later",
"LicenseRef-scancode-free-unknown",
"Apache-2.0"
] |
permissive
|
OLIMEX/DIY-LAPTOP
|
ae82f4ee79c641d9aee444db9a75f3f6709afa92
|
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
|
refs/heads/rel3
| 2023-08-04T01:54:19.483792
| 2023-04-03T07:18:12
| 2023-04-03T07:18:12
| 80,094,055
| 507
| 92
|
Apache-2.0
| 2023-04-03T07:05:59
| 2017-01-26T07:25:50
|
C
|
UTF-8
|
C
| false
| false
| 1,542
|
c
|
rsk7203.c
|
/*
* Copyright (C) 2008 Nobuhiro Iwamatsu
* Copyright (C) 2008 Renesas Solutions Corp.
*
* u-boot/board/rsk7203/rsk7203.c
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
#include <net.h>
#include <netdev.h>
#include <asm/io.h>
#include <asm/processor.h>
DECLARE_GLOBAL_DATA_PTR;
int checkboard(void)
{
puts("BOARD: Renesas Technology RSK7203\n");
return 0;
}
int board_init(void)
{
return 0;
}
int dram_init(void)
{
gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE;
printf("DRAM: %dMB\n", CONFIG_SYS_SDRAM_SIZE / (1024 * 1024));
return 0;
}
void led_set_state(unsigned short value)
{
}
/*
* The RSK board has the SMSC9118 wired up 'incorrectly'.
* Byte-swapping is necessary, and so poor performance is inevitable.
* This problem cannot evade by the swap function of CHIP, this can
* evade by software Byte-swapping.
* And this has problem by FIFO access only. pkt_data_pull/pkt_data_push
* functions necessary to solve this problem.
*/
u32 pkt_data_pull(struct eth_device *dev, u32 addr)
{
volatile u16 *addr_16 = (u16 *)(dev->iobase + addr);
return (u32)((swab16(*addr_16) << 16) & 0xFFFF0000)\
| swab16(*(addr_16 + 1));
}
void pkt_data_push(struct eth_device *dev, u32 addr, u32 val)
{
addr += dev->iobase;
*(volatile u16 *)(addr + 2) = swab16((u16)val);
*(volatile u16 *)(addr) = swab16((u16)(val >> 16));
}
int board_eth_init(bd_t *bis)
{
int rc = 0;
#ifdef CONFIG_SMC911X
rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
#endif
return rc;
}
|
cc048d72f107129b6a3e07ccb2659cc7c60b48f3
|
4805a71711625735215cc1a773a85712be305b59
|
/docs/examples/userguide/memoryviews/C_func_file.c
|
39445df50e3c3afd68c26762c7af4168fd544e68
|
[
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
cython/cython
|
0a75b75b7eaf19eeedaaebca9d49adb603e3e8f5
|
6ba3daf319d94058de74e8e7f53f932092b38441
|
refs/heads/master
| 2023-09-04T11:09:56.569277
| 2023-09-04T07:45:47
| 2023-09-04T07:45:47
| 1,099,265
| 8,352
| 1,704
|
Apache-2.0
| 2023-09-14T06:33:34
| 2010-11-21T07:44:20
|
Python
|
UTF-8
|
C
| false
| false
| 172
|
c
|
C_func_file.c
|
#include "C_func_file.h"
void multiply_by_10_in_C(double arr[], unsigned int n)
{
unsigned int i;
for (i = 0; i < n; i++) {
arr[i] *= 10;
}
}
|
f1f2c37b079dc3a6a4c1f0d8224f696b7621aeb5
|
317410b28757af216145d23259d63fc96d07f613
|
/apps/hid/board/br30/board_config.h
|
a2364c28eca90fc481749a8e39a48639bb84ea36
|
[
"Apache-2.0"
] |
permissive
|
Jieli-Tech/fw-AC63_BT_SDK
|
48c757dca7e8000ec763bf5466583a4cd8c4a11c
|
393d63758081d56f0bf0a39ac596bee32c33d493
|
refs/heads/master
| 2023-07-18T02:14:56.187266
| 2023-06-21T03:14:20
| 2023-06-21T03:14:20
| 272,586,610
| 113
| 76
|
Apache-2.0
| 2022-10-20T23:07:31
| 2020-06-16T02:02:15
|
C
|
UTF-8
|
C
| false
| false
| 529
|
h
|
board_config.h
|
#ifndef BOARD_CONFIG_H
#define BOARD_CONFIG_H
/*
* 板级配置选择
*/
#define CONFIG_BOARD_AC637N_DEMO
// #define CONFIG_BOARD_AC6376F_DEMO
// #define CONFIG_BOARD_AC6373B_MOUSE
// #define CONFIG_BOARD_AC6379B_MOUSE
// #define CONFIG_BOARD_AC6379B_KEYFOB
// #define CONFIG_BOARD_AC6376F_MOUSE
#include "board_ac637n_demo_cfg.h"
#include "board_ac6376f_demo_cfg.h"
#include "board_ac6373b_mouse_cfg.h"
#include "board_ac6379b_mouse_cfg.h"
#include "board_ac6379b_keyfob_cfg.h"
#include "board_ac6376f_mouse_cfg.h"
#endif
|
767472cf5718346ff83611e60b728d40fb347f77
|
ae31542273a142210a1ff30fb76ed9d45d38eba9
|
/src/backend/executor/execUtils.c
|
1ac1f6b5c54117ff7629086c4151d8459a935dd1
|
[
"Apache-2.0",
"LicenseRef-scancode-generic-cla",
"PostgreSQL",
"OpenSSL",
"LicenseRef-scancode-stream-benchmark",
"ISC",
"LicenseRef-scancode-openssl",
"LicenseRef-scancode-other-copyleft",
"LicenseRef-scancode-ssleay-windows",
"BSD-2-Clause",
"Python-2.0"
] |
permissive
|
greenplum-db/gpdb
|
8334837bceb2d5d51a684500793d11b190117c6a
|
2c0f8f0fb24a2d7a7da114dc80f5f5a2712fca50
|
refs/heads/main
| 2023-08-22T02:03:03.806269
| 2023-08-21T22:59:53
| 2023-08-22T01:17:10
| 44,781,140
| 6,417
| 2,082
|
Apache-2.0
| 2023-09-14T20:33:42
| 2015-10-23T00:25:17
|
C
|
UTF-8
|
C
| false
| false
| 66,280
|
c
|
execUtils.c
|
/*-------------------------------------------------------------------------
*
* execUtils.c
* miscellaneous executor utility routines
*
* Portions Copyright (c) 2005-2008, Greenplum inc
* Portions Copyright (c) 2012-Present VMware, Inc. or its affiliates.
* Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* src/backend/executor/execUtils.c
*
*-------------------------------------------------------------------------
*/
/*
* INTERFACE ROUTINES
* CreateExecutorState Create/delete executor working state
* FreeExecutorState
* CreateExprContext
* CreateStandaloneExprContext
* FreeExprContext
* ReScanExprContext
*
* ExecAssignExprContext Common code for plan node init routines.
* etc
*
* ExecOpenScanRelation Common code for scan node init routines.
*
* ExecInitRangeTable Set up executor's range-table-related data.
*
* ExecGetRangeTableRelation Fetch Relation for a rangetable entry.
*
* executor_errposition Report syntactic position of an error.
*
* RegisterExprContextCallback Register function shutdown callback
* UnregisterExprContextCallback Deregister function shutdown callback
*
* GetAttributeByName Runtime extraction of columns from tuples.
* GetAttributeByNum
*
* NOTES
* This file has traditionally been the place to stick misc.
* executor support stuff that doesn't really go anyplace else.
*/
#include "postgres.h"
#include "pgstat.h"
#include "access/genam.h"
#include "access/heapam.h"
#include "access/parallel.h"
#include "access/relscan.h"
#include "access/table.h"
#include "access/tableam.h"
#include "access/transam.h"
#include "catalog/index.h"
#include "executor/execdebug.h"
#include "executor/execUtils.h"
#include "executor/executor.h"
#include "executor/execPartition.h"
#include "jit/jit.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "nodes/nodeFuncs.h"
#include "parser/parsetree.h"
#include "partitioning/partdesc.h"
#include "storage/lmgr.h"
#include "utils/builtins.h"
#include "utils/memutils.h"
#include "utils/rel.h"
#include "utils/typcache.h"
#include "nodes/primnodes.h"
#include "nodes/execnodes.h"
#include "cdb/cdbutil.h"
#include "cdb/cdbvars.h"
#include "cdb/cdbdisp_query.h"
#include "cdb/cdbdispatchresult.h"
#include "cdb/ml_ipc.h"
#include "cdb/cdbmotion.h"
#include "cdb/cdbsreh.h"
#include "cdb/memquota.h"
#include "executor/instrument.h"
#include "executor/spi.h"
#include "utils/elog.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "storage/ipc.h"
#include "cdb/cdbllize.h"
#include "utils/guc.h"
#include "utils/workfile_mgr.h"
#include "utils/metrics_utils.h"
#include "cdb/memquota.h"
static bool tlist_matches_tupdesc(PlanState *ps, List *tlist, Index varno, TupleDesc tupdesc);
static void ShutdownExprContext(ExprContext *econtext, bool isCommit);
/* ----------------------------------------------------------------
* Executor state and memory management functions
* ----------------------------------------------------------------
*/
/* ----------------
* CreateExecutorState
*
* Create and initialize an EState node, which is the root of
* working storage for an entire Executor invocation.
*
* Principally, this creates the per-query memory context that will be
* used to hold all working data that lives till the end of the query.
* Note that the per-query context will become a child of the caller's
* CurrentMemoryContext.
* ----------------
*/
EState *
CreateExecutorState(void)
{
EState *estate;
MemoryContext qcontext;
MemoryContext oldcontext;
/*
* Create the per-query context for this Executor run.
*/
qcontext = AllocSetContextCreate(CurrentMemoryContext,
"ExecutorState",
ALLOCSET_DEFAULT_SIZES);
MemoryContextDeclareAccountingRoot(qcontext);
/*
* Make the EState node within the per-query context. This way, we don't
* need a separate pfree() operation for it at shutdown.
*/
oldcontext = MemoryContextSwitchTo(qcontext);
estate = makeNode(EState);
/*
* Initialize all fields of the Executor State structure
*/
estate->es_direction = ForwardScanDirection;
estate->es_snapshot = InvalidSnapshot; /* caller must initialize this */
estate->es_crosscheck_snapshot = InvalidSnapshot; /* no crosscheck */
estate->es_range_table = NIL;
estate->es_range_table_array = NULL;
estate->es_range_table_size = 0;
estate->es_relations = NULL;
estate->es_rowmarks = NULL;
estate->es_plannedstmt = NULL;
estate->es_junkFilter = NULL;
estate->es_output_cid = (CommandId) 0;
estate->es_result_relations = NULL;
estate->es_num_result_relations = 0;
estate->es_result_relation_info = NULL;
estate->es_root_result_relations = NULL;
estate->es_num_root_result_relations = 0;
estate->es_tuple_routing_result_relations = NIL;
estate->es_trig_target_relations = NIL;
estate->es_param_list_info = NULL;
estate->es_param_exec_vals = NULL;
estate->es_queryEnv = NULL;
estate->es_query_cxt = qcontext;
estate->es_tupleTable = NIL;
estate->es_processed = 0;
estate->es_top_eflags = 0;
estate->es_instrument = 0;
estate->es_finished = false;
estate->es_exprcontexts = NIL;
estate->es_subplanstates = NIL;
estate->es_auxmodifytables = NIL;
estate->es_per_tuple_exprcontext = NULL;
estate->es_sourceText = NULL;
estate->es_use_parallel_mode = false;
estate->es_jit_flags = 0;
estate->es_jit = NULL;
estate->es_sliceTable = NULL;
estate->interconnect_context = NULL;
estate->motionlayer_context = NULL;
estate->es_interconnect_is_setup = false;
estate->active_recv_id = -1;
estate->es_got_eos = false;
estate->cancelUnfinished = false;
estate->dispatcherState = NULL;
estate->currentSliceId = 0;
estate->eliminateAliens = false;
estate->gp_bypass_unique_check = false;
/*
* Return the executor state structure
*/
MemoryContextSwitchTo(oldcontext);
return estate;
}
/* ----------------
* FreeExecutorState
*
* Release an EState along with all remaining working storage.
*
* Note: this is not responsible for releasing non-memory resources, such as
* open relations or buffer pins. But it will shut down any still-active
* ExprContexts within the EState and deallocate associated JITed expressions.
* That is sufficient cleanup for situations where the EState has only been
* used for expression evaluation, and not to run a complete Plan.
*
* This can be called in any memory context ... so long as it's not one
* of the ones to be freed.
*
* In Greenplum, this also clears the PartitionState, even though that's a
* non-memory resource, as that can be allocated for expression evaluation even
* when there is no Plan.
* ----------------
*/
void
FreeExecutorState(EState *estate)
{
/*
* Shut down and free any remaining ExprContexts. We do this explicitly
* to ensure that any remaining shutdown callbacks get called (since they
* might need to release resources that aren't simply memory within the
* per-query memory context).
*/
while (estate->es_exprcontexts)
{
/*
* XXX: seems there ought to be a faster way to implement this than
* repeated list_delete(), no?
*/
FreeExprContext((ExprContext *) linitial(estate->es_exprcontexts),
true);
/* FreeExprContext removed the list link for us */
}
estate->dispatcherState = NULL;
/* release JIT context, if allocated */
if (estate->es_jit)
{
jit_release_context(estate->es_jit);
estate->es_jit = NULL;
}
/* release partition directory, if allocated */
if (estate->es_partition_directory)
{
DestroyPartitionDirectory(estate->es_partition_directory);
estate->es_partition_directory = NULL;
}
/*
* Free the per-query memory context, thereby releasing all working
* memory, including the EState node itself.
*/
MemoryContextDelete(estate->es_query_cxt);
}
/*
* Internal implementation for CreateExprContext() and CreateWorkExprContext()
* that allows control over the AllocSet parameters.
*/
static ExprContext *
CreateExprContextInternal(EState *estate, Size minContextSize,
Size initBlockSize, Size maxBlockSize)
{
ExprContext *econtext;
MemoryContext oldcontext;
/* Create the ExprContext node within the per-query memory context */
oldcontext = MemoryContextSwitchTo(estate->es_query_cxt);
econtext = makeNode(ExprContext);
/* Initialize fields of ExprContext */
econtext->ecxt_scantuple = NULL;
econtext->ecxt_innertuple = NULL;
econtext->ecxt_outertuple = NULL;
econtext->ecxt_per_query_memory = estate->es_query_cxt;
/*
* Create working memory for expression evaluation in this context.
*/
econtext->ecxt_per_tuple_memory =
AllocSetContextCreate(estate->es_query_cxt,
"ExprContext",
minContextSize,
initBlockSize,
maxBlockSize);
econtext->ecxt_param_exec_vals = estate->es_param_exec_vals;
econtext->ecxt_param_list_info = estate->es_param_list_info;
econtext->ecxt_aggvalues = NULL;
econtext->ecxt_aggnulls = NULL;
econtext->caseValue_datum = (Datum) 0;
econtext->caseValue_isNull = true;
econtext->domainValue_datum = (Datum) 0;
econtext->domainValue_isNull = true;
econtext->ecxt_estate = estate;
econtext->ecxt_callbacks = NULL;
/*
* Link the ExprContext into the EState to ensure it is shut down when the
* EState is freed. Because we use lcons(), shutdowns will occur in
* reverse order of creation, which may not be essential but can't hurt.
*/
estate->es_exprcontexts = lcons(econtext, estate->es_exprcontexts);
MemoryContextSwitchTo(oldcontext);
return econtext;
}
/* ----------------
* CreateExprContext
*
* Create a context for expression evaluation within an EState.
*
* An executor run may require multiple ExprContexts (we usually make one
* for each Plan node, and a separate one for per-output-tuple processing
* such as constraint checking). Each ExprContext has its own "per-tuple"
* memory context.
*
* Note we make no assumption about the caller's memory context.
* ----------------
*/
ExprContext *
CreateExprContext(EState *estate)
{
return CreateExprContextInternal(estate, ALLOCSET_DEFAULT_SIZES);
}
/* ----------------
* CreateWorkExprContext
*
* Like CreateExprContext, but specifies the AllocSet sizes to be reasonable
* in proportion to work_mem. If the maximum block allocation size is too
* large, it's easy to skip right past work_mem with a single allocation.
* ----------------
*/
ExprContext *
CreateWorkExprContext(EState *estate)
{
Size minContextSize = ALLOCSET_DEFAULT_MINSIZE;
Size initBlockSize = ALLOCSET_DEFAULT_INITSIZE;
Size maxBlockSize = ALLOCSET_DEFAULT_MAXSIZE;
/* choose the maxBlockSize to be no larger than 1/16 of work_mem */
while (16 * maxBlockSize > work_mem * 1024L)
maxBlockSize >>= 1;
if (maxBlockSize < ALLOCSET_DEFAULT_INITSIZE)
maxBlockSize = ALLOCSET_DEFAULT_INITSIZE;
return CreateExprContextInternal(estate, minContextSize,
initBlockSize, maxBlockSize);
}
/* ----------------
* CreateStandaloneExprContext
*
* Create a context for standalone expression evaluation.
*
* An ExprContext made this way can be used for evaluation of expressions
* that contain no Params, subplans, or Var references (it might work to
* put tuple references into the scantuple field, but it seems unwise).
*
* The ExprContext struct is allocated in the caller's current memory
* context, which also becomes its "per query" context.
*
* It is caller's responsibility to free the ExprContext when done,
* or at least ensure that any shutdown callbacks have been called
* (ReScanExprContext() is suitable). Otherwise, non-memory resources
* might be leaked.
* ----------------
*/
ExprContext *
CreateStandaloneExprContext(void)
{
ExprContext *econtext;
/* Create the ExprContext node within the caller's memory context */
econtext = makeNode(ExprContext);
/* Initialize fields of ExprContext */
econtext->ecxt_scantuple = NULL;
econtext->ecxt_innertuple = NULL;
econtext->ecxt_outertuple = NULL;
econtext->ecxt_per_query_memory = CurrentMemoryContext;
/*
* Create working memory for expression evaluation in this context.
*/
econtext->ecxt_per_tuple_memory =
AllocSetContextCreate(CurrentMemoryContext,
"ExprContext",
ALLOCSET_DEFAULT_SIZES);
econtext->ecxt_param_exec_vals = NULL;
econtext->ecxt_param_list_info = NULL;
econtext->ecxt_aggvalues = NULL;
econtext->ecxt_aggnulls = NULL;
econtext->caseValue_datum = (Datum) 0;
econtext->caseValue_isNull = true;
econtext->domainValue_datum = (Datum) 0;
econtext->domainValue_isNull = true;
econtext->ecxt_estate = NULL;
econtext->ecxt_callbacks = NULL;
return econtext;
}
/* ----------------
* FreeExprContext
*
* Free an expression context, including calling any remaining
* shutdown callbacks.
*
* Since we free the temporary context used for expression evaluation,
* any previously computed pass-by-reference expression result will go away!
*
* If isCommit is false, we are being called in error cleanup, and should
* not call callbacks but only release memory. (It might be better to call
* the callbacks and pass the isCommit flag to them, but that would require
* more invasive code changes than currently seems justified.)
*
* Note we make no assumption about the caller's memory context.
* ----------------
*/
void
FreeExprContext(ExprContext *econtext, bool isCommit)
{
EState *estate;
/* Call any registered callbacks */
ShutdownExprContext(econtext, isCommit);
/* And clean up the memory used */
MemoryContextDelete(econtext->ecxt_per_tuple_memory);
/* Unlink self from owning EState, if any */
estate = econtext->ecxt_estate;
if (estate)
estate->es_exprcontexts = list_delete_ptr(estate->es_exprcontexts,
econtext);
/* And delete the ExprContext node */
pfree(econtext);
}
/*
* ReScanExprContext
*
* Reset an expression context in preparation for a rescan of its
* plan node. This requires calling any registered shutdown callbacks,
* since any partially complete set-returning-functions must be canceled.
*
* Note we make no assumption about the caller's memory context.
*/
void
ReScanExprContext(ExprContext *econtext)
{
/* Call any registered callbacks */
ShutdownExprContext(econtext, true);
/* And clean up the memory used */
MemoryContextReset(econtext->ecxt_per_tuple_memory);
}
/*
* Build a per-output-tuple ExprContext for an EState.
*
* This is normally invoked via GetPerTupleExprContext() macro,
* not directly.
*/
ExprContext *
MakePerTupleExprContext(EState *estate)
{
if (estate->es_per_tuple_exprcontext == NULL)
estate->es_per_tuple_exprcontext = CreateExprContext(estate);
return estate->es_per_tuple_exprcontext;
}
/* ----------------------------------------------------------------
* miscellaneous node-init support functions
*
* Note: all of these are expected to be called with CurrentMemoryContext
* equal to the per-query memory context.
* ----------------------------------------------------------------
*/
/* ----------------
* ExecAssignExprContext
*
* This initializes the ps_ExprContext field. It is only necessary
* to do this for nodes which use ExecQual or ExecProject
* because those routines require an econtext. Other nodes that
* don't have to evaluate expressions don't need to do this.
* ----------------
*/
void
ExecAssignExprContext(EState *estate, PlanState *planstate)
{
planstate->ps_ExprContext = CreateExprContext(estate);
}
/* ----------------
* ExecGetResultType
* ----------------
*/
TupleDesc
ExecGetResultType(PlanState *planstate)
{
return planstate->ps_ResultTupleDesc;
}
/*
* ExecGetResultSlotOps - information about node's type of result slot
*/
const TupleTableSlotOps *
ExecGetResultSlotOps(PlanState *planstate, bool *isfixed)
{
if (planstate->resultopsset && planstate->resultops)
{
if (isfixed)
*isfixed = planstate->resultopsfixed;
return planstate->resultops;
}
if (isfixed)
{
if (planstate->resultopsset)
*isfixed = planstate->resultopsfixed;
else if (planstate->ps_ResultTupleSlot)
*isfixed = TTS_FIXED(planstate->ps_ResultTupleSlot);
else
*isfixed = false;
}
if (!planstate->ps_ResultTupleSlot)
return &TTSOpsVirtual;
return planstate->ps_ResultTupleSlot->tts_ops;
}
/* ----------------
* ExecAssignProjectionInfo
*
* forms the projection information from the node's targetlist
*
* Notes for inputDesc are same as for ExecBuildProjectionInfo: supply it
* for a relation-scan node, can pass NULL for upper-level nodes
* ----------------
*/
void
ExecAssignProjectionInfo(PlanState *planstate,
TupleDesc inputDesc)
{
planstate->ps_ProjInfo =
ExecBuildProjectionInfo(planstate->plan->targetlist,
planstate->ps_ExprContext,
planstate->ps_ResultTupleSlot,
planstate,
inputDesc);
}
/* ----------------
* ExecConditionalAssignProjectionInfo
*
* as ExecAssignProjectionInfo, but store NULL rather than building projection
* info if no projection is required
* ----------------
*/
void
ExecConditionalAssignProjectionInfo(PlanState *planstate, TupleDesc inputDesc,
Index varno)
{
if (tlist_matches_tupdesc(planstate,
planstate->plan->targetlist,
varno,
inputDesc))
{
planstate->ps_ProjInfo = NULL;
planstate->resultopsset = planstate->scanopsset;
planstate->resultopsfixed = planstate->scanopsfixed;
planstate->resultops = planstate->scanops;
}
else
{
if (!planstate->ps_ResultTupleSlot)
{
ExecInitResultSlot(planstate, &TTSOpsVirtual);
planstate->resultops = &TTSOpsVirtual;
planstate->resultopsfixed = true;
planstate->resultopsset = true;
}
ExecAssignProjectionInfo(planstate, inputDesc);
}
}
static bool
tlist_matches_tupdesc(PlanState *ps, List *tlist, Index varno, TupleDesc tupdesc)
{
int numattrs = tupdesc->natts;
int attrno;
ListCell *tlist_item = list_head(tlist);
/* Check the tlist attributes */
for (attrno = 1; attrno <= numattrs; attrno++)
{
Form_pg_attribute att_tup = TupleDescAttr(tupdesc, attrno - 1);
Var *var;
if (tlist_item == NULL)
return false; /* tlist too short */
var = (Var *) ((TargetEntry *) lfirst(tlist_item))->expr;
if (!var || !IsA(var, Var))
return false; /* tlist item not a Var */
/* if these Asserts fail, planner messed up */
Assert(var->varno == varno);
Assert(var->varlevelsup == 0);
if (var->varattno != attrno)
return false; /* out of order */
if (att_tup->attisdropped)
return false; /* table contains dropped columns */
if (att_tup->atthasmissing)
return false; /* table contains cols with missing values */
/*
* Note: usually the Var's type should match the tupdesc exactly, but
* in situations involving unions of columns that have different
* typmods, the Var may have come from above the union and hence have
* typmod -1. This is a legitimate situation since the Var still
* describes the column, just not as exactly as the tupdesc does. We
* could change the planner to prevent it, but it'd then insert
* projection steps just to convert from specific typmod to typmod -1,
* which is pretty silly.
*/
if (var->vartype != att_tup->atttypid ||
(var->vartypmod != att_tup->atttypmod &&
var->vartypmod != -1))
return false; /* type mismatch */
tlist_item = lnext(tlist_item);
}
if (tlist_item)
return false; /* tlist too long */
return true;
}
/* ----------------
* ExecFreeExprContext
*
* A plan node's ExprContext should be freed explicitly during executor
* shutdown because there may be shutdown callbacks to call. (Other resources
* made by the above routines, such as projection info, don't need to be freed
* explicitly because they're just memory in the per-query memory context.)
*
* However ... there is no particular need to do it during ExecEndNode,
* because FreeExecutorState will free any remaining ExprContexts within
* the EState. Letting FreeExecutorState do it allows the ExprContexts to
* be freed in reverse order of creation, rather than order of creation as
* will happen if we delete them here, which saves O(N^2) work in the list
* cleanup inside FreeExprContext.
* ----------------
*/
void
ExecFreeExprContext(PlanState *planstate)
{
/*
* Per above discussion, don't actually delete the ExprContext. We do
* unlink it from the plan node, though.
*/
planstate->ps_ExprContext = NULL;
}
/* ----------------------------------------------------------------
* Scan node support
* ----------------------------------------------------------------
*/
/* ----------------
* ExecAssignScanType
* ----------------
*/
void
ExecAssignScanType(ScanState *scanstate, TupleDesc tupDesc)
{
TupleTableSlot *slot = scanstate->ss_ScanTupleSlot;
ExecSetSlotDescriptor(slot, tupDesc);
}
/* ----------------
* ExecCreateScanSlotFromOuterPlan
* ----------------
*/
void
ExecCreateScanSlotFromOuterPlan(EState *estate,
ScanState *scanstate,
const TupleTableSlotOps *tts_ops)
{
PlanState *outerPlan;
TupleDesc tupDesc;
outerPlan = outerPlanState(scanstate);
tupDesc = ExecGetResultType(outerPlan);
ExecInitScanTupleSlot(estate, scanstate, tupDesc, tts_ops);
}
/* ----------------------------------------------------------------
* ExecRelationIsTargetRelation
*
* Detect whether a relation (identified by rangetable index)
* is one of the target relations of the query.
*
* Note: This is currently no longer used in core. We keep it around
* because FDWs may wish to use it to determine if their foreign table
* is a target relation.
* ----------------------------------------------------------------
*/
bool
ExecRelationIsTargetRelation(EState *estate, Index scanrelid)
{
ResultRelInfo *resultRelInfos;
int i;
resultRelInfos = estate->es_result_relations;
for (i = 0; i < estate->es_num_result_relations; i++)
{
if (resultRelInfos[i].ri_RangeTableIndex == scanrelid)
return true;
}
return false;
}
/* ----------------------------------------------------------------
* ExecOpenScanRelation
*
* Open the heap relation to be scanned by a base-level scan plan node.
* This should be called during the node's ExecInit routine.
* ----------------------------------------------------------------
*/
Relation
ExecOpenScanRelation(EState *estate, Index scanrelid, int eflags)
{
Relation rel;
/* Open the relation. */
rel = ExecGetRangeTableRelation(estate, scanrelid);
/*
* Complain if we're attempting a scan of an unscannable relation, except
* when the query won't actually be run. This is a slightly klugy place
* to do this, perhaps, but there is no better place.
*/
if ((eflags & (EXEC_FLAG_EXPLAIN_ONLY | EXEC_FLAG_WITH_NO_DATA)) == 0 &&
!RelationIsScannable(rel))
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("materialized view \"%s\" has not been populated",
RelationGetRelationName(rel)),
errhint("Use the REFRESH MATERIALIZED VIEW command.")));
return rel;
}
/*
* ExecInitRangeTable
* Set up executor's range-table-related data
*
* We build an array from the range table list to allow faster lookup by RTI.
* (The es_range_table field is now somewhat redundant, but we keep it to
* avoid breaking external code unnecessarily.)
* This is also a convenient place to set up the parallel es_relations array.
*/
void
ExecInitRangeTable(EState *estate, List *rangeTable)
{
Index rti;
ListCell *lc;
/* Remember the range table List as-is */
estate->es_range_table = rangeTable;
/* Set up the equivalent array representation */
estate->es_range_table_size = list_length(rangeTable);
estate->es_range_table_array = (RangeTblEntry **)
palloc(estate->es_range_table_size * sizeof(RangeTblEntry *));
rti = 0;
foreach(lc, rangeTable)
{
estate->es_range_table_array[rti++] = lfirst_node(RangeTblEntry, lc);
}
/*
* Allocate an array to store an open Relation corresponding to each
* rangetable entry, and initialize entries to NULL. Relations are opened
* and stored here as needed.
*/
estate->es_relations = (Relation *)
palloc0(estate->es_range_table_size * sizeof(Relation));
/*
* es_rowmarks is also parallel to the es_range_table_array, but it's
* allocated only if needed.
*/
estate->es_rowmarks = NULL;
}
/*
* ExecGetRangeTableRelation
* Open the Relation for a range table entry, if not already done
*
* The Relations will be closed again in ExecEndPlan().
*/
Relation
ExecGetRangeTableRelation(EState *estate, Index rti)
{
Relation rel;
Assert(rti > 0 && rti <= estate->es_range_table_size);
rel = estate->es_relations[rti - 1];
if (rel == NULL)
{
/* First time through, so open the relation */
RangeTblEntry *rte = exec_rt_fetch(rti, estate);
Assert(rte->rtekind == RTE_RELATION);
/* GPDB: a QE process is not holding the locks yet, same as a parallel worker. */
if (!IsParallelWorker() && Gp_role != GP_ROLE_EXECUTE)
{
/*
* In a normal query, we should already have the appropriate lock,
* but verify that through an Assert. Since there's already an
* Assert inside table_open that insists on holding some lock, it
* seems sufficient to check this only when rellockmode is higher
* than the minimum.
*/
rel = table_open(rte->relid, NoLock);
Assert(rte->rellockmode == AccessShareLock ||
CheckRelationLockedByMe(rel, rte->rellockmode, false));
}
else
{
/*
* If we are a parallel worker, we need to obtain our own local
* lock on the relation. This ensures sane behavior in case the
* parent process exits before we do.
*/
rel = table_open(rte->relid, rte->rellockmode);
}
estate->es_relations[rti - 1] = rel;
}
return rel;
}
/*
* UpdateChangedParamSet
* Add changed parameters to a plan node's chgParam set
*/
void
UpdateChangedParamSet(PlanState *node, Bitmapset *newchg)
{
Bitmapset *parmset;
/*
* The plan node only depends on params listed in its allParam set. Don't
* include anything else into its chgParam set.
*/
parmset = bms_intersect(node->plan->allParam, newchg);
/*
* Keep node->chgParam == NULL if there's not actually any members; this
* allows the simplest possible tests in executor node files.
*/
if (!bms_is_empty(parmset))
node->chgParam = bms_join(node->chgParam, parmset);
else
bms_free(parmset);
}
/*
* executor_errposition
* Report an execution-time cursor position, if possible.
*
* This is expected to be used within an ereport() call. The return value
* is a dummy (always 0, in fact).
*
* The locations stored in parsetrees are byte offsets into the source string.
* We have to convert them to 1-based character indexes for reporting to
* clients. (We do things this way to avoid unnecessary overhead in the
* normal non-error case: computing character indexes would be much more
* expensive than storing token offsets.)
*/
void
executor_errposition(EState *estate, int location)
{
int pos;
/* No-op if location was not provided */
if (location < 0)
return;
/* Can't do anything if source text is not available */
if (estate == NULL || estate->es_sourceText == NULL)
return;
/* Convert offset to character number */
pos = pg_mbstrlen_with_len(estate->es_sourceText, location) + 1;
/* And pass it to the ereport mechanism */
errposition(pos);
}
/*
* Register a shutdown callback in an ExprContext.
*
* Shutdown callbacks will be called (in reverse order of registration)
* when the ExprContext is deleted or rescanned. This provides a hook
* for functions called in the context to do any cleanup needed --- it's
* particularly useful for functions returning sets. Note that the
* callback will *not* be called in the event that execution is aborted
* by an error.
*/
void
RegisterExprContextCallback(ExprContext *econtext,
ExprContextCallbackFunction function,
Datum arg)
{
ExprContext_CB *ecxt_callback;
/* Save the info in appropriate memory context */
ecxt_callback = (ExprContext_CB *)
MemoryContextAlloc(econtext->ecxt_per_query_memory,
sizeof(ExprContext_CB));
ecxt_callback->function = function;
ecxt_callback->arg = arg;
/* link to front of list for appropriate execution order */
ecxt_callback->next = econtext->ecxt_callbacks;
econtext->ecxt_callbacks = ecxt_callback;
}
/*
* Deregister a shutdown callback in an ExprContext.
*
* Any list entries matching the function and arg will be removed.
* This can be used if it's no longer necessary to call the callback.
*/
void
UnregisterExprContextCallback(ExprContext *econtext,
ExprContextCallbackFunction function,
Datum arg)
{
ExprContext_CB **prev_callback;
ExprContext_CB *ecxt_callback;
prev_callback = &econtext->ecxt_callbacks;
while ((ecxt_callback = *prev_callback) != NULL)
{
if (ecxt_callback->function == function && ecxt_callback->arg == arg)
{
*prev_callback = ecxt_callback->next;
pfree(ecxt_callback);
}
else
prev_callback = &ecxt_callback->next;
}
}
/*
* Call all the shutdown callbacks registered in an ExprContext.
*
* The callback list is emptied (important in case this is only a rescan
* reset, and not deletion of the ExprContext).
*
* If isCommit is false, just clean the callback list but don't call 'em.
* (See comment for FreeExprContext.)
*/
static void
ShutdownExprContext(ExprContext *econtext, bool isCommit)
{
ExprContext_CB *ecxt_callback;
MemoryContext oldcontext;
/* Fast path in normal case where there's nothing to do. */
if (econtext->ecxt_callbacks == NULL)
return;
/*
* Call the callbacks in econtext's per-tuple context. This ensures that
* any memory they might leak will get cleaned up.
*/
oldcontext = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory);
/*
* Call each callback function in reverse registration order.
*/
while ((ecxt_callback = econtext->ecxt_callbacks) != NULL)
{
econtext->ecxt_callbacks = ecxt_callback->next;
if (isCommit)
ecxt_callback->function(ecxt_callback->arg);
pfree(ecxt_callback);
}
MemoryContextSwitchTo(oldcontext);
}
/*
* fake_outer_params
* helper function to fake the nestloop's nestParams
* so that prefetch inner or prefetch joinqual will
* not encounter NULL pointer reference issue. It is
* only invoked in ExecNestLoop and ExecPrefetchJoinQual
* when the join is a nestloop join.
*/
void
fake_outer_params(JoinState *node)
{
ExprContext *econtext = node->ps.ps_ExprContext;
PlanState *inner = innerPlanState(node);
TupleTableSlot *outerTupleSlot = econtext->ecxt_outertuple;
NestLoop *nl = (NestLoop *) (node->ps.plan);
ListCell *lc = NULL;
/* only nestloop contains nestParams */
Assert(IsA(node->ps.plan, NestLoop));
/* econtext->ecxt_outertuple must have been set fakely. */
Assert(outerTupleSlot != NULL);
/*
* fetch the values of any outer Vars that must be passed to the
* inner scan, and store them in the appropriate PARAM_EXEC slots.
*/
foreach(lc, nl->nestParams)
{
NestLoopParam *nlp = (NestLoopParam *) lfirst(lc);
int paramno = nlp->paramno;
ParamExecData *prm;
prm = &(econtext->ecxt_param_exec_vals[paramno]);
/* Param value should be an OUTER_VAR var */
Assert(IsA(nlp->paramval, Var));
Assert(nlp->paramval->varno == OUTER_VAR);
Assert(nlp->paramval->varattno > 0);
prm->value = slot_getattr(outerTupleSlot,
nlp->paramval->varattno,
&(prm->isnull));
/* Flag parameter value as changed */
inner->chgParam = bms_add_member(inner->chgParam,
paramno);
}
}
/* ----------------------------------------------------------------
* CDB Slice Table utilities
* ----------------------------------------------------------------
*/
static void
FillSliceGangInfo(ExecSlice *slice, PlanSlice *ps)
{
int numsegments = ps->numsegments;
DirectDispatchInfo *dd = &ps->directDispatch;
switch (slice->gangType)
{
case GANGTYPE_UNALLOCATED:
/*
* It's either the root slice or an InitPlan slice that runs in
* the QD process, or really unused slice.
*/
slice->planNumSegments = 1;
break;
case GANGTYPE_PRIMARY_WRITER:
case GANGTYPE_PRIMARY_READER:
slice->planNumSegments = numsegments;
if (dd->isDirectDispatch)
{
slice->segments = list_copy(dd->contentIds);
}
else
{
int i;
slice->segments = NIL;
for (i = 0; i < numsegments; i++)
slice->segments = lappend_int(slice->segments, i % getgpsegmentCount());
}
break;
case GANGTYPE_ENTRYDB_READER:
slice->planNumSegments = 1;
slice->segments = list_make1_int(-1);
break;
case GANGTYPE_SINGLETON_READER:
slice->planNumSegments = 1;
slice->segments = list_make1_int(ps->segindex);
break;
default:
elog(ERROR, "unexpected gang type");
}
}
/*
* Create the executor slice table.
*
* The planner constructed a slice table, in plannedstmt->slices. Turn that
* into an "executor slice table", with slightly more information. The gangs
* to execute the slices will be set up later.
*/
SliceTable *
InitSliceTable(EState *estate, PlannedStmt *plannedstmt)
{
SliceTable *table;
int i;
int numSlices;
MemoryContext oldcontext;
numSlices = plannedstmt->numSlices;
Assert(numSlices > 0);
if (gp_max_slices > 0 && numSlices > gp_max_slices)
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("at most %d slices are allowed in a query, current number: %d",
gp_max_slices, numSlices),
errhint("rewrite your query or adjust GUC gp_max_slices")));
oldcontext = MemoryContextSwitchTo(estate->es_query_cxt);
table = makeNode(SliceTable);
table->instrument_options = INSTRUMENT_NONE;
table->hasMotions = false;
/*
* Initialize the executor slice table.
*
* We have most of the information in the planner slice table. In addition to that,
* we set up the parent-child relationships.
*/
table->slices = palloc0(sizeof(ExecSlice) * numSlices);
for (i = 0; i < numSlices; i++)
{
ExecSlice *currExecSlice = &table->slices[i];
PlanSlice *currPlanSlice = &plannedstmt->slices[i];
int parentIndex;
int rootIndex;
currExecSlice->sliceIndex = i;
currExecSlice->planNumSegments = currPlanSlice->numsegments;
currExecSlice->segments = NIL;
currExecSlice->primaryGang = NULL;
currExecSlice->primaryProcesses = NIL;
parentIndex = currPlanSlice->parentIndex;
if (parentIndex < -1 || parentIndex >= numSlices)
elog(ERROR, "invalid parent slice index %d", currPlanSlice->parentIndex);
if (parentIndex >= 0)
{
ExecSlice *parentExecSlice = &table->slices[parentIndex];
int counter;
/* Sending slice is a child of recv slice */
parentExecSlice->children = lappend_int(parentExecSlice->children, currPlanSlice->sliceIndex);
/* Find the root slice */
rootIndex = i;
counter = 0;
while (plannedstmt->slices[rootIndex].parentIndex >= 0)
{
rootIndex = plannedstmt->slices[rootIndex].parentIndex;
if (counter++ > numSlices)
elog(ERROR, "circular parent-child relationship in slice table");
}
table->hasMotions = true;
}
else
rootIndex = i;
/* find root of this slice. All the parents should be initialized already */
currExecSlice->parentIndex = parentIndex;
currExecSlice->rootIndex = rootIndex;
currExecSlice->gangType = currPlanSlice->gangType;
FillSliceGangInfo(currExecSlice, currPlanSlice);
}
table->numSlices = numSlices;
/*
* For CTAS although the data is distributed on part of the
* segments, the catalog changes must be dispatched to all the
* segments, so a full gang is required.
*/
if ((plannedstmt->intoClause != NULL || plannedstmt->copyIntoClause != NULL || plannedstmt->refreshClause))
{
if (table->slices[0].gangType == GANGTYPE_PRIMARY_WRITER)
{
int numsegments = getgpsegmentCount();
table->slices[0].segments = NIL;
for (i = 0; i < numsegments; i++)
table->slices[0].segments = lappend_int(table->slices[0].segments, i);
}
}
MemoryContextSwitchTo(oldcontext);
return table;
}
/*
* A forgiving slice table indexer that returns the indexed Slice* or NULL
*/
ExecSlice *
getCurrentSlice(EState *estate, int sliceIndex)
{
SliceTable *sliceTable = estate->es_sliceTable;
if (sliceTable &&
sliceIndex >= 0 &&
sliceIndex < sliceTable->numSlices)
return &sliceTable->slices[sliceIndex];
return NULL;
}
/* Should the slice run on the QD?
*
* N.B. Not the same as !sliceRunsOnQE(slice), when slice is NULL.
*/
bool
sliceRunsOnQD(ExecSlice *slice)
{
return (slice != NULL && slice->gangType == GANGTYPE_UNALLOCATED);
}
/* Should the slice run on a QE?
*
* N.B. Not the same as !sliceRunsOnQD(slice), when slice is NULL.
*/
bool
sliceRunsOnQE(ExecSlice *slice)
{
return (slice != NULL && slice->gangType != GANGTYPE_UNALLOCATED);
}
/* Forward declarations */
static bool AssignWriterGangFirst(CdbDispatcherState *ds, SliceTable *sliceTable, int sliceIndex);
static void InventorySliceTree(CdbDispatcherState *ds, SliceTable *sliceTable, int sliceIndex);
/*
* Function AssignGangs runs on the QD and finishes construction of the
* global slice table for a plan by assigning gangs allocated by the
* executor factory to the slices of the slice table.
*
* On entry, the executor slice table (at queryDesc->estate->es_sliceTable)
* has been initialized and has correct (by InitSliceTable function)
*
* Gang assignment involves taking an inventory of the requirements of
* each slice tree in the slice table, asking the executor factory to
* allocate a minimal set of gangs that can satisfy any of the slice trees,
* and associating the allocated gangs with slices in the slice table.
*
* On successful exit, the CDBProcess lists (primaryProcesses, mirrorProcesses)
* and the Gang pointers (primaryGang, mirrorGang) are set correctly in each
* slice in the slice table.
*/
void
AssignGangs(CdbDispatcherState *ds, QueryDesc *queryDesc)
{
SliceTable *sliceTable;
EState *estate;
int rootIdx;
estate = queryDesc->estate;
sliceTable = estate->es_sliceTable;
rootIdx = RootSliceIndex(queryDesc->estate);
/* cleanup processMap because initPlan and main Plan share the same slice table */
for (int i = 0; i < sliceTable->numSlices; i++)
sliceTable->slices[i].processesMap = NULL;
AssignWriterGangFirst(ds, sliceTable, rootIdx);
InventorySliceTree(ds, sliceTable, rootIdx);
}
/*
* AssignWriterGangFirst() - Try to assign writer gang first.
*
* For the gang allocation, our current implementation required the first
* allocated gang must be the writer gang.
* This has several reasons:
* - For lock holding, Because of our MPP structure, we assign a LockHolder
* for each segment when executing a query. lockHolder is the gang member that
* should hold and manage locks for this transaction. On the QEs, it should
* normally be the Writer gang member. More details please refer to
* lockHolderProcPtr in lock.c.
* - For SharedSnapshot among session's gang processes on a particular segment.
* During initPostgres(), reader QE will try to lookup the shared slot written
* by writer QE. More details please reger to sharedsnapshot.c.
*
* Normally, the writer slice will be assign writer gang first when iterate the
* slice table. But this is not true for writable CTE (with only one writer gang).
* For below statement:
*
* WITH updated AS (update tbl set rank = 6 where id = 5 returning rank)
* select * from tbl where rank in (select rank from updated);
* QUERY PLAN
* ----------------------------------------------------------------------------------------------
* Gather Motion 3:1 (slice1; segments: 3)
* -> Seq Scan on tbl
* Filter: (hashed SubPlan 1)
* SubPlan 1
* -> Broadcast Motion 1:3 (slice2; segments: 1)
* -> Update on tbl
* -> Seq Scan on tbl
* Filter: (id = 5)
* Slice 0: Dispatcher; root 0; parent -1; gang size 0
* Slice 1: Reader; root 0; parent 0; gang size 3
* Slice 2: Primary Writer; root 0; parent 1; gang size 1
*
* If we sill assign writer gang to Slice 1 here, the writer process will execute
* on reader gang. So, find the writer slice and assign writer gang first.
*/
static bool
AssignWriterGangFirst(CdbDispatcherState *ds, SliceTable *sliceTable, int sliceIndex)
{
ExecSlice *slice = &sliceTable->slices[sliceIndex];
if (slice->gangType == GANGTYPE_PRIMARY_WRITER)
{
Assert(slice->primaryGang == NULL);
Assert(slice->segments != NIL);
slice->primaryGang = AllocateGang(ds, slice->gangType, slice->segments);
setupCdbProcessList(slice);
return true;
}
else
{
ListCell *cell;
foreach(cell, slice->children)
{
int childIndex = lfirst_int(cell);
if (AssignWriterGangFirst(ds, sliceTable, childIndex))
return true;
}
}
return false;
}
/*
* Helper for AssignGangs takes a simple inventory of the gangs required
* by a slice tree. Recursive. Closely coupled with AssignGangs. Not
* generally useful.
*/
static void
InventorySliceTree(CdbDispatcherState *ds, SliceTable *sliceTable, int sliceIndex)
{
ExecSlice *slice = &sliceTable->slices[sliceIndex];
ListCell *cell;
if (slice->gangType == GANGTYPE_UNALLOCATED)
{
slice->primaryGang = NULL;
slice->primaryProcesses = getCdbProcessesForQD(true);
}
else if (!slice->primaryGang)
{
Assert(slice->segments != NIL);
slice->primaryGang = AllocateGang(ds, slice->gangType, slice->segments);
setupCdbProcessList(slice);
}
foreach(cell, slice->children)
{
int childIndex = lfirst_int(cell);
InventorySliceTree(ds, sliceTable, childIndex);
}
}
/*
* Choose the execution identity (who does this executor serve?).
* There are types:
*
* 1. No-Op (ignore) -- this occurs when the specified direction is
* NoMovementScanDirection or when Gp_role is GP_ROLE_DISPATCH
* and the current slice belongs to a QE.
*
* 2. Executor serves a Root Slice -- this occurs when Gp_role is
* GP_ROLE_UTILITY or the current slice is a root. It corresponds
* to the "normal" path through the executor in that we enter the plan
* at the top and count on the motion nodes at the fringe of the top
* slice to return without ever calling nodes below them.
*
* 3. Executor serves a Non-Root Slice on a QE -- this occurs when
* Gp_role is GP_ROLE_EXECUTE and the current slice is not a root
* slice. It corresponds to a QE running a slice with a motion node on
* top. The call, thus, returns no tuples (since they all go out
* on the interconnect to the receiver version of the motion node),
* but it does execute the indicated slice down to any fringe
* motion nodes (as in case 2).
*/
GpExecIdentity
getGpExecIdentity(QueryDesc *queryDesc,
ScanDirection direction,
EState *estate)
{
ExecSlice *currentSlice;
currentSlice = getCurrentSlice(estate, LocallyExecutingSliceIndex(estate));
if (currentSlice)
{
if (Gp_role == GP_ROLE_EXECUTE ||
sliceRunsOnQD(currentSlice))
currentSliceId = currentSlice->sliceIndex;
}
/* select the strategy */
if (direction == NoMovementScanDirection)
{
return GP_IGNORE;
}
else if (Gp_role == GP_ROLE_DISPATCH && sliceRunsOnQE(currentSlice))
{
return GP_IGNORE;
}
else if (Gp_role == GP_ROLE_EXECUTE && LocallyExecutingSliceIndex(estate) != RootSliceIndex(estate))
{
return GP_NON_ROOT_ON_QE;
}
else
{
return GP_ROOT_SLICE;
}
}
/*
* End the gp-specific part of the executor.
*
* In here we collect the dispatch results if there are any, tear
* down the interconnect if it is set-up.
*/
void mppExecutorFinishup(QueryDesc *queryDesc)
{
EState *estate;
ExecSlice *currentSlice;
int primaryWriterSliceIndex;
/* caller must have switched into per-query memory context already */
estate = queryDesc->estate;
currentSlice = getCurrentSlice(estate, LocallyExecutingSliceIndex(estate));
primaryWriterSliceIndex = PrimaryWriterSliceIndex(estate);
/* Teardown the Interconnect */
if (estate->es_interconnect_is_setup)
{
TeardownInterconnect(estate->interconnect_context, false);
estate->interconnect_context = NULL;
estate->es_interconnect_is_setup = false;
}
/*
* If we are finishing a query before all the tuples of the query
* plan were fetched we must call ExecSquelchNode before checking
* the dispatch results in order to tell we no longer
* need any more tuples.
*/
if (Gp_role == GP_ROLE_DISPATCH && !estate->es_got_eos &&
!(estate->es_top_eflags & EXEC_FLAG_EXPLAIN_ONLY))
{
ExecSquelchNode(queryDesc->planstate);
}
/*
* If QD, wait for QEs to finish and check their results.
*/
if (estate->dispatcherState && estate->dispatcherState->primaryResults)
{
CdbDispatchResults *pr = NULL;
CdbDispatcherState *ds = estate->dispatcherState;
DispatchWaitMode waitMode = DISPATCH_WAIT_NONE;
ErrorData *qeError = NULL;
/*
* Wait for completion of all QEs. We send a "graceful" query
* finish, not cancel signal. Since the query has succeeded,
* don't confuse QEs by sending erroneous message.
*/
if (estate->cancelUnfinished)
waitMode = DISPATCH_WAIT_FINISH;
cdbdisp_checkDispatchResult(ds, waitMode);
pr = cdbdisp_getDispatchResults(ds, &qeError);
if (qeError)
{
estate->dispatcherState = NULL;
FlushErrorState();
ThrowErrorData(qeError);
}
/* collect pgstat from QEs for current transaction level */
pgstat_combine_from_qe(pr, primaryWriterSliceIndex);
/* get num of rows processed from writer QEs. */
estate->es_processed +=
cdbdisp_sumCmdTuples(pr, primaryWriterSliceIndex);
/* sum up rejected rows if any (single row error handling only) */
cdbdisp_sumRejectedRows(pr);
/*
* Check and free the results of all gangs. If any QE had an
* error, report it and exit to our error handler via PG_THROW.
* NB: This call doesn't wait, because we already waited above.
*/
estate->dispatcherState = NULL;
cdbdisp_destroyDispatcherState(ds);
}
}
/*
* Cleanup the gp-specific parts of the query executor.
*
* Will normally be called after an error from within a CATCH block.
*/
void mppExecutorCleanup(QueryDesc *queryDesc)
{
CdbDispatcherState *ds;
EState *estate;
/* caller must have switched into per-query memory context already */
estate = queryDesc->estate;
ds = estate->dispatcherState;
/* GPDB hook for collecting query info */
if (query_info_collect_hook && QueryCancelCleanup)
(*query_info_collect_hook)(METRICS_QUERY_CANCELING, queryDesc);
/* Clean up the interconnect. */
if (estate->es_interconnect_is_setup)
{
TeardownInterconnect(estate->interconnect_context, true);
estate->es_interconnect_is_setup = false;
}
/*
* Request any commands still executing on qExecs to stop.
* Wait for them to finish and clean up the dispatching structures.
* Replace current error info with QE error info if more interesting.
*/
if (ds)
{
estate->dispatcherState = NULL;
CdbDispatchHandleError(ds);
}
/* GPDB hook for collecting query info */
if (query_info_collect_hook)
(*query_info_collect_hook)(QueryCancelCleanup ? METRICS_QUERY_CANCELED : METRICS_QUERY_ERROR, queryDesc);
ReportOOMConsumption();
/**
* Since there was an error, clean up the function scan stack.
*/
if (!IsResManagerMemoryPolicyNone())
{
SPI_InitMemoryReservation();
}
}
/**
* This method is used to determine how much memory a specific operator
* is supposed to use (in KB).
*/
uint64 PlanStateOperatorMemKB(const PlanState *ps)
{
Assert(ps);
Assert(ps->plan);
uint64 result = 0;
if (ps->plan->operatorMemKB == 0)
{
/**
* There are some statements that do not go through the resource queue and these
* plans dont get decorated with the operatorMemKB. Someday, we should fix resource queues.
*/
result = work_mem;
}
else
{
result = ps->plan->operatorMemKB;
}
return result;
}
/**
* Methods to find motionstate object within a planstate tree given a motion id (which is the same as slice index)
*/
typedef struct MotionStateFinderContext
{
int motionId; /* Input */
MotionState *motionState; /* Output */
} MotionStateFinderContext;
/**
* Walker method that finds motion state node within a planstate tree.
*/
static CdbVisitOpt
MotionStateFinderWalker(PlanState *node,
void *context)
{
Assert(context);
MotionStateFinderContext *ctx = (MotionStateFinderContext *) context;
if (IsA(node, MotionState))
{
MotionState *ms = (MotionState *) node;
Motion *m = (Motion *) ms->ps.plan;
if (m->motionID == ctx->motionId)
{
Assert(ctx->motionState == NULL);
ctx->motionState = ms;
return CdbVisit_Skip; /* don't visit subtree */
}
}
/* Continue walking */
return CdbVisit_Walk;
}
/**
* Given a slice index, find the motionstate that corresponds to this slice index. This will iterate over the planstate tree
* to get the right node.
*/
MotionState *
getMotionState(struct PlanState *ps, int sliceIndex)
{
Assert(ps);
Assert(sliceIndex > -1);
MotionStateFinderContext ctx;
ctx.motionId = sliceIndex;
ctx.motionState = NULL;
planstate_walk_node(ps, MotionStateFinderWalker, &ctx);
if (ctx.motionState == NULL)
elog(ERROR, "could not find MotionState for slice %d in executor tree", sliceIndex);
return ctx.motionState;
}
typedef struct MotionFinderContext
{
plan_tree_base_prefix base; /* Required prefix for plan_tree_walker/mutator */
int motionId; /* Input */
Motion *motion; /* Output */
} MotionFinderContext;
/*
* Walker to find a motion node that matches a particular motionID
*/
static bool
MotionFinderWalker(Plan *node,
void *context)
{
Assert(context);
MotionFinderContext *ctx = (MotionFinderContext *) context;
if (node == NULL)
return false;
if (IsA(node, Motion))
{
Motion *m = (Motion *) node;
if (m->motionID == ctx->motionId)
{
ctx->motion = m;
return true; /* found our node; no more visit */
}
}
/* Continue walking */
return plan_tree_walker((Node*)node, MotionFinderWalker, ctx, true);
}
/*
* Given the Plan and a Slice index, find the motion node that is the root of the slice's subtree.
*/
Motion *findSenderMotion(PlannedStmt *plannedstmt, int sliceIndex)
{
Assert(sliceIndex > -1);
Plan *planTree = plannedstmt->planTree;
MotionFinderContext ctx;
ctx.base.node = (Node*)plannedstmt;
ctx.motionId = sliceIndex;
ctx.motion = NULL;
MotionFinderWalker(planTree, &ctx);
return ctx.motion;
}
typedef struct SubPlanFinderContext
{
plan_tree_base_prefix base; /* Required prefix for plan_tree_walker/mutator */
Bitmapset *bms_subplans; /* Bitmapset for relevant subplans in current slice */
} SubPlanFinderContext;
/*
* Walker to find all the subplans in a PlanTree between 'node' and the next motion node
*/
static bool
SubPlanFinderWalker(Node *node, void *context)
{
SubPlanFinderContext *ctx = (SubPlanFinderContext *) context;
if (node == NULL)
return false;
/* don't recurse into other slices */
if (IsA(node, Motion))
return false;
if (IsA(node, SubPlan))
{
SubPlan *subplan = (SubPlan *) node;
int plan_id = subplan->plan_id;
if (!bms_is_member(plan_id, ctx->bms_subplans))
ctx->bms_subplans = bms_add_member(ctx->bms_subplans, plan_id);
else
return false;
}
/* Continue walking */
return plan_tree_walker(node, SubPlanFinderWalker, ctx, true);
}
/*
* Given a plan and a root motion node find all the subplans
* between 'root' and the next motion node in the tree
*/
Bitmapset *
getLocallyExecutableSubplans(PlannedStmt *plannedstmt, Plan *root_plan)
{
SubPlanFinderContext ctx;
ctx.base.node = (Node *) plannedstmt;
ctx.bms_subplans = NULL;
/*
* Note that we begin with plan_tree_walker(root_plan), not
* SubPlanFinderWalker(root_plan). SubPlanFinderWalker() will stop
* at a Motion, but a slice typically has a Motion at the top. We want
* to recurse into the children of the top Motion, as well as any
* initPlans, targetlist, and other fields on the Motion itself. They
* are all considered part of the sending slice.
*/
(void) plan_tree_walker((Node *) root_plan, SubPlanFinderWalker, &ctx, true);
return ctx.bms_subplans;
}
/*
* Copy PARAM_EXEC parameter values that were received from the QD into
* our EState.
*/
void
InstallDispatchedExecParams(QueryDispatchDesc *ddesc, EState *estate)
{
Assert(Gp_role == GP_ROLE_EXECUTE);
if (ddesc->paramInfo == NULL)
return;
for (int i = 0; i < ddesc->paramInfo->nExecParams; i++)
{
SerializedParamExecData *sprm = &ddesc->paramInfo->execParams[i];
ParamExecData *prmExec = &estate->es_param_exec_vals[i];
if (!sprm->isvalid)
continue; /* not dispatched */
prmExec->execPlan = NULL;
prmExec->value = sprm->value;
prmExec->isnull = sprm->isnull;
}
}
/**
* Provide index of locally executing slice
*/
int LocallyExecutingSliceIndex(EState *estate)
{
Assert(estate);
return (!estate->es_sliceTable ? 0 : estate->es_sliceTable->localSlice);
}
/**
* Provide index of slice being executed on the primary writer gang
*/
int
PrimaryWriterSliceIndex(EState *estate)
{
if (!estate->es_sliceTable)
return 0;
for (int i = 0; i < estate->es_sliceTable->numSlices; i++)
{
ExecSlice *slice = &estate->es_sliceTable->slices[i];
if (slice->gangType == GANGTYPE_PRIMARY_WRITER)
return slice->sliceIndex;
}
return 0;
}
/**
* Provide root slice of locally executing slice.
*/
int
RootSliceIndex(EState *estate)
{
int result = 0;
if (estate->es_sliceTable)
{
ExecSlice *localSlice = &estate->es_sliceTable->slices[LocallyExecutingSliceIndex(estate)];
result = localSlice->rootIndex;
Assert(result >= 0 && estate->es_sliceTable->numSlices);
}
return result;
}
#ifdef USE_ASSERT_CHECKING
/**
* Assert that slicetable is valid. Must be called after ExecInitMotion, which sets up the slice table
*/
void AssertSliceTableIsValid(SliceTable *st)
{
if (!st)
return;
for (int i = 0; i < st->numSlices; i++)
{
ExecSlice *s = &st->slices[i];
/* The n-th slice entry has sliceIndex of n */
Assert(s->sliceIndex == i && "slice index incorrect");
/*
* FIXME: Sometimes the planner produces a plan with unused SubPlans, which
* might contain Motion nodes. We remove unused SubPlans as part cdbllize(), but
* there is a scenario with Append nodes where they still occur.
* adjust_appendrel_attrs() makes copies of any SubPlans it encounters, which
* happens early in the planning, leaving any SubPlans in target list of the
* Append node to point to the original plan_id. The scan in cdbllize() doesn't
* eliminate such SubPlans. But set_plan_references() will replace any SubPlans
* in the Append's targetlist with references to the outputs of the child nodes,
* leaving the original SubPlan unused.
*
* For now, just tolerate unused slices.
*/
if (s->rootIndex == -1 && s->parentIndex == -1 && s->gangType == GANGTYPE_UNALLOCATED)
continue;
/* Parent slice index */
if (s->sliceIndex == s->rootIndex)
{
/* Current slice is a root slice. It will have parent index -1.*/
Assert(s->parentIndex == -1 && "expecting parent index of -1");
}
else
{
/* All other slices must have a valid parent index */
Assert(s->parentIndex >= 0 && s->parentIndex < st->numSlices && "slice's parent index out of range");
}
/* Current slice's children must consider it the parent */
ListCell *lc1 = NULL;
foreach (lc1, s->children)
{
int childIndex = lfirst_int(lc1);
Assert(childIndex >= 0 && childIndex < st->numSlices && "invalid child slice");
ExecSlice *sc = &st->slices[childIndex];
Assert(sc->parentIndex == s->sliceIndex && "slice's child does not consider it the parent");
}
/* Current slice must be in its parent's children list */
if (s->parentIndex >= 0)
{
ExecSlice *sp = &st->slices[s->parentIndex];
bool found = false;
foreach (lc1, sp->children)
{
int childIndex = lfirst_int(lc1);
Assert(childIndex >= 0 && childIndex < st->numSlices && "invalid child slice");
ExecSlice *sc = &st->slices[childIndex];
if (sc->sliceIndex == s->sliceIndex)
{
found = true;
break;
}
}
Assert(found && "slice's parent does not consider it a child");
}
}
}
#endif
/*
* GetAttributeByName
* GetAttributeByNum
*
* These functions return the value of the requested attribute
* out of the given tuple Datum.
* C functions which take a tuple as an argument are expected
* to use these. Ex: overpaid(EMP) might call GetAttributeByNum().
* Note: these are actually rather slow because they do a typcache
* lookup on each call.
*/
Datum
GetAttributeByName(HeapTupleHeader tuple, const char *attname, bool *isNull)
{
AttrNumber attrno;
Datum result;
Oid tupType;
int32 tupTypmod;
TupleDesc tupDesc;
HeapTupleData tmptup;
int i;
if (attname == NULL)
elog(ERROR, "invalid attribute name");
if (isNull == NULL)
elog(ERROR, "a NULL isNull pointer was passed");
if (tuple == NULL)
{
/* Kinda bogus but compatible with old behavior... */
*isNull = true;
return (Datum) 0;
}
tupType = HeapTupleHeaderGetTypeId(tuple);
tupTypmod = HeapTupleHeaderGetTypMod(tuple);
tupDesc = lookup_rowtype_tupdesc(tupType, tupTypmod);
attrno = InvalidAttrNumber;
for (i = 0; i < tupDesc->natts; i++)
{
Form_pg_attribute att = TupleDescAttr(tupDesc, i);
if (namestrcmp(&(att->attname), attname) == 0)
{
attrno = att->attnum;
break;
}
}
if (attrno == InvalidAttrNumber)
elog(ERROR, "attribute \"%s\" does not exist", attname);
/*
* heap_getattr needs a HeapTuple not a bare HeapTupleHeader. We set all
* the fields in the struct just in case user tries to inspect system
* columns.
*/
tmptup.t_len = HeapTupleHeaderGetDatumLength(tuple);
ItemPointerSetInvalid(&(tmptup.t_self));
tmptup.t_tableOid = InvalidOid;
tmptup.t_data = tuple;
result = heap_getattr(&tmptup,
attrno,
tupDesc,
isNull);
ReleaseTupleDesc(tupDesc);
return result;
}
Datum
GetAttributeByNum(HeapTupleHeader tuple,
AttrNumber attrno,
bool *isNull)
{
Datum result;
Oid tupType;
int32 tupTypmod;
TupleDesc tupDesc;
HeapTupleData tmptup;
if (!AttributeNumberIsValid(attrno))
elog(ERROR, "invalid attribute number %d", attrno);
if (isNull == NULL)
elog(ERROR, "a NULL isNull pointer was passed");
if (tuple == NULL)
{
/* Kinda bogus but compatible with old behavior... */
*isNull = true;
return (Datum) 0;
}
tupType = HeapTupleHeaderGetTypeId(tuple);
tupTypmod = HeapTupleHeaderGetTypMod(tuple);
tupDesc = lookup_rowtype_tupdesc(tupType, tupTypmod);
/*
* heap_getattr needs a HeapTuple not a bare HeapTupleHeader. We set all
* the fields in the struct just in case user tries to inspect system
* columns.
*/
tmptup.t_len = HeapTupleHeaderGetDatumLength(tuple);
ItemPointerSetInvalid(&(tmptup.t_self));
tmptup.t_tableOid = InvalidOid;
tmptup.t_data = tuple;
result = heap_getattr(&tmptup,
attrno,
tupDesc,
isNull);
ReleaseTupleDesc(tupDesc);
return result;
}
/*
* Number of items in a tlist (including any resjunk items!)
*/
int
ExecTargetListLength(List *targetlist)
{
/* This used to be more complex, but fjoins are dead */
return list_length(targetlist);
}
/*
* Number of items in a tlist, not including any resjunk items
*/
int
ExecCleanTargetListLength(List *targetlist)
{
int len = 0;
ListCell *tl;
foreach(tl, targetlist)
{
TargetEntry *curTle = lfirst_node(TargetEntry, tl);
if (!curTle->resjunk)
len++;
}
return len;
}
/*
* Return a relInfo's tuple slot for a trigger's OLD tuples.
*/
TupleTableSlot *
ExecGetTriggerOldSlot(EState *estate, ResultRelInfo *relInfo)
{
if (relInfo->ri_TrigOldSlot == NULL)
{
Relation rel = relInfo->ri_RelationDesc;
MemoryContext oldcontext = MemoryContextSwitchTo(estate->es_query_cxt);
relInfo->ri_TrigOldSlot =
ExecInitExtraTupleSlot(estate,
RelationGetDescr(rel),
table_slot_callbacks(rel));
MemoryContextSwitchTo(oldcontext);
}
return relInfo->ri_TrigOldSlot;
}
/*
* Return a relInfo's tuple slot for a trigger's NEW tuples.
*/
TupleTableSlot *
ExecGetTriggerNewSlot(EState *estate, ResultRelInfo *relInfo)
{
if (relInfo->ri_TrigNewSlot == NULL)
{
Relation rel = relInfo->ri_RelationDesc;
MemoryContext oldcontext = MemoryContextSwitchTo(estate->es_query_cxt);
relInfo->ri_TrigNewSlot =
ExecInitExtraTupleSlot(estate,
RelationGetDescr(rel),
table_slot_callbacks(rel));
MemoryContextSwitchTo(oldcontext);
}
return relInfo->ri_TrigNewSlot;
}
/*
* Return a relInfo's tuple slot for processing returning tuples.
*/
TupleTableSlot *
ExecGetReturningSlot(EState *estate, ResultRelInfo *relInfo)
{
if (relInfo->ri_ReturningSlot == NULL)
{
Relation rel = relInfo->ri_RelationDesc;
MemoryContext oldcontext = MemoryContextSwitchTo(estate->es_query_cxt);
relInfo->ri_ReturningSlot =
ExecInitExtraTupleSlot(estate,
RelationGetDescr(rel),
table_slot_callbacks(rel));
MemoryContextSwitchTo(oldcontext);
}
return relInfo->ri_ReturningSlot;
}
/* Return a bitmap representing columns being inserted */
Bitmapset *
ExecGetInsertedCols(ResultRelInfo *relinfo, EState *estate)
{
/*
* The columns are stored in the range table entry. If this ResultRelInfo
* represents a partition routing target, and doesn't have an entry of its
* own in the range table, fetch the parent's RTE and map the columns to
* the order they are in the partition.
*/
if (relinfo->ri_RangeTableIndex != 0)
{
RangeTblEntry *rte = exec_rt_fetch(relinfo->ri_RangeTableIndex, estate);
return rte->insertedCols;
}
else if (relinfo->ri_RootResultRelInfo)
{
ResultRelInfo *rootRelInfo = relinfo->ri_RootResultRelInfo;
RangeTblEntry *rte = exec_rt_fetch(rootRelInfo->ri_RangeTableIndex, estate);
PartitionRoutingInfo *partrouteinfo = relinfo->ri_PartitionInfo;
if (partrouteinfo->pi_RootToPartitionMap != NULL)
return execute_attr_map_cols(rte->insertedCols,
partrouteinfo->pi_RootToPartitionMap);
else
return rte->insertedCols;
}
else
{
/*
* The relation isn't in the range table and it isn't a partition
* routing target. This ResultRelInfo must've been created only for
* firing triggers and the relation is not being inserted into. (See
* ExecGetTriggerResultRel.)
*/
return NULL;
}
}
/* Return a bitmap representing columns being updated */
Bitmapset *
ExecGetUpdatedCols(ResultRelInfo *relinfo, EState *estate)
{
/* see ExecGetInsertedCols() */
if (relinfo->ri_RangeTableIndex != 0)
{
RangeTblEntry *rte = exec_rt_fetch(relinfo->ri_RangeTableIndex, estate);
return rte->updatedCols;
}
else if (relinfo->ri_RootResultRelInfo)
{
ResultRelInfo *rootRelInfo = relinfo->ri_RootResultRelInfo;
RangeTblEntry *rte = exec_rt_fetch(rootRelInfo->ri_RangeTableIndex, estate);
PartitionRoutingInfo *partrouteinfo = relinfo->ri_PartitionInfo;
if (partrouteinfo->pi_RootToPartitionMap != NULL)
return execute_attr_map_cols(rte->updatedCols,
partrouteinfo->pi_RootToPartitionMap);
else
return rte->updatedCols;
}
else
return NULL;
}
/* Return a bitmap representing generated columns being updated */
Bitmapset *
ExecGetExtraUpdatedCols(ResultRelInfo *relinfo, EState *estate)
{
/* see ExecGetInsertedCols() */
if (relinfo->ri_RangeTableIndex != 0)
{
RangeTblEntry *rte = exec_rt_fetch(relinfo->ri_RangeTableIndex, estate);
return rte->extraUpdatedCols;
}
else if (relinfo->ri_RootResultRelInfo)
{
ResultRelInfo *rootRelInfo = relinfo->ri_RootResultRelInfo;
RangeTblEntry *rte = exec_rt_fetch(rootRelInfo->ri_RangeTableIndex, estate);
PartitionRoutingInfo *partrouteinfo = relinfo->ri_PartitionInfo;
if (partrouteinfo->pi_RootToPartitionMap != NULL)
return execute_attr_map_cols(rte->extraUpdatedCols,
partrouteinfo->pi_RootToPartitionMap);
else
return rte->extraUpdatedCols;
}
else
return NULL;
}
/* Return columns being updated, including generated columns */
Bitmapset *
ExecGetAllUpdatedCols(ResultRelInfo *relinfo, EState *estate)
{
return bms_union(ExecGetUpdatedCols(relinfo, estate),
ExecGetExtraUpdatedCols(relinfo, estate));
}
/*
* During attribute re-mapping for heterogeneous partitions, we use
* this struct to identify which varno's attributes will be re-mapped.
* Using this struct as a *context* during expression tree walking, we
* can skip varattnos that do not belong to a given varno.
*/
typedef struct AttrMapContext
{
const AttrNumber *newattno; /* The mapping table to remap the varattno */
Index varno; /* Which rte's varattno to re-map */
} AttrMapContext;
/*
* Remaps the varattno of a varattno in a Var node using an attribute map.
*/
static bool
change_varattnos_varno_walker(Node *node, const AttrMapContext *attrMapCxt)
{
if (node == NULL)
return false;
if (IsA(node, Var))
{
Var *var = (Var *) node;
if (var->varlevelsup == 0 && (var->varno == attrMapCxt->varno) &&
var->varattno > 0)
{
/*
* ??? the following may be a problem when the node is multiply
* referenced though stringToNode() doesn't create such a node
* currently.
*/
Assert(attrMapCxt->newattno[var->varattno - 1] > 0);
var->varattno = var->varoattno = attrMapCxt->newattno[var->varattno - 1];
}
return false;
}
return expression_tree_walker(node, change_varattnos_varno_walker,
(void *) attrMapCxt);
}
/*
* Replace varattno values for a given varno RTE index in an expression
* tree according to the given map array, that is, varattno N is replaced
* by newattno[N-1]. It is caller's responsibility to ensure that the array
* is long enough to define values for all user varattnos present in the tree.
* System column attnos remain unchanged.
*
* Note that the passed node tree is modified in-place!
*/
void
change_varattnos_of_a_varno(Node *node, const AttrNumber *newattno, Index varno)
{
AttrMapContext attrMapCxt;
attrMapCxt.newattno = newattno;
attrMapCxt.varno = varno;
(void) change_varattnos_varno_walker(node, &attrMapCxt);
}
|
41baa4a5dafb94d5ab7fae9286415e7a3d8566d0
|
84a6935f61d7f8290b05263da044e28719c5560a
|
/tests/pthread_create_blocking_np/timing.h
|
0a1d3f60e16f90ff1878aa62b486c3c0c474dc4a
|
[
"BSD-2-Clause",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
Tarsnap/spiped
|
5d450a9bb406d9fde191960038f1a15eebd59039
|
f1e205868654c5d4ecd3ae1bfbad762a0b66f74f
|
refs/heads/master
| 2023-09-03T01:26:11.669796
| 2023-08-26T22:50:32
| 2023-08-26T22:50:32
| 36,114,883
| 840
| 73
|
NOASSERTION
| 2023-09-06T20:36:44
| 2015-05-23T08:47:44
|
C
|
UTF-8
|
C
| false
| false
| 204
|
h
|
timing.h
|
#ifndef TIMING_H_
#define TIMING_H_
/**
* check_timing(void):
* Check that pthread_create_blocking_np() results in the expected relative
* timing.
*/
int check_timing(void);
#endif /* !TIMING_H_ */
|
0ef449d91635a24502cc5d3cb4adfbaaaef98836
|
0ba9681b235b377b3f57d52532ab7212d4d4cd8a
|
/saw-remote-api/python/tests/saw/test-files/llvm_lax_pointer_ordering.c
|
b21eb7e67befac9115c97ac05a3ac79a1d9ab211
|
[
"BSD-3-Clause"
] |
permissive
|
GaloisInc/saw-script
|
d9a3eb7b05c1bcbcc319987223cd53b903b55b5d
|
79ddd800bec59528958ed6d7593304e2b17b7dfb
|
refs/heads/master
| 2023-09-01T09:47:31.415255
| 2023-08-30T11:26:08
| 2023-08-30T11:26:08
| 34,082,065
| 458
| 82
|
BSD-3-Clause
| 2023-09-14T16:23:09
| 2015-04-16T21:39:32
|
Haskell
|
UTF-8
|
C
| false
| false
| 215
|
c
|
llvm_lax_pointer_ordering.c
|
#include <stdint.h>
#include <stdlib.h>
const size_t LEN = 42;
void zip_with_add(uint64_t c[LEN], const uint64_t a[LEN], const uint64_t b[LEN]) {
for (size_t i = 0; i < LEN; i++) {
c[i] = a[i] + b[i];
}
}
|
391e470d226c30878c763522ebc6e34cf8aa4d71
|
99bdb3251fecee538e0630f15f6574054dfc1468
|
/bsp/stm32/libraries/STM32L0xx_HAL/STM32L0xx_HAL_Driver/Inc/stm32l0xx_hal_pwr_ex.h
|
e7e7f2514ed18ae6da1c117c54e51253e4380cf1
|
[
"Apache-2.0",
"Zlib",
"LicenseRef-scancode-proprietary-license",
"MIT",
"BSD-3-Clause",
"X11",
"BSD-4-Clause-UC",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
RT-Thread/rt-thread
|
03a7c52c2aeb1b06a544143b0e803d72f47d1ece
|
3602f891211904a27dcbd51e5ba72fefce7326b2
|
refs/heads/master
| 2023-09-01T04:10:20.295801
| 2023-08-31T16:20:55
| 2023-08-31T16:20:55
| 7,408,108
| 9,599
| 5,805
|
Apache-2.0
| 2023-09-14T13:37:26
| 2013-01-02T14:49:21
|
C
|
UTF-8
|
C
| false
| false
| 2,871
|
h
|
stm32l0xx_hal_pwr_ex.h
|
/**
******************************************************************************
* @file stm32l0xx_hal_pwr_ex.h
* @author MCD Application Team
* @brief Header file of PWR HAL Extension module.
******************************************************************************
* @attention
*
* <h2><center>© Copyright(c) 2016 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32L0xx_HAL_PWR_EX_H
#define __STM32L0xx_HAL_PWR_EX_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32l0xx_hal_def.h"
/** @addtogroup STM32L0xx_HAL_Driver
* @{
*/
/** @defgroup PWREx PWREx
* @{
*/
/** @defgroup PWREx_Exported_Macros PWREx Exported Macros
* @{
*/
/** @brief Macros to enable the Deep-sleep mode with Flash memory kept off.
* @note When entering low power mode (stop or standby only), if DS_EE_KOFF and RUN_PD of
* FLASH_ACR register are both set , the Flash memory will not be woken up
* when exiting from deep-sleep mode.
*/
#define __HAL_PWR_FLASHWAKEUP_ENABLE() CLEAR_BIT(PWR->CR, PWR_CR_DSEEKOFF)
/** @brief Macros to disable the Deep-sleep mode with Flash memory kept off.
* @note When entering low power mode (stop or standby only), if DS_EE_KOFF and RUN_PD of
* FLASH_ACR register are both set , the Flash memory will not be woken up
* when exiting from deep-sleep mode.
*/
#define __HAL_PWR_FLASHWAKEUP_DISABLE() SET_BIT(PWR->CR, PWR_CR_DSEEKOFF)
/**
* @}
*/
/** @defgroup PWREx_Exported_Functions PWREx Exported Functions
* @{
*/
uint32_t HAL_PWREx_GetVoltageRange(void);
void HAL_PWREx_EnableFastWakeUp(void);
void HAL_PWREx_DisableFastWakeUp(void);
void HAL_PWREx_EnableUltraLowPower(void);
void HAL_PWREx_DisableUltraLowPower(void);
void HAL_PWREx_EnableLowPowerRunMode(void);
HAL_StatusTypeDef HAL_PWREx_DisableLowPowerRunMode(void);
/**
* @}
*/
/* Define the private group ***********************************/
/**************************************************************/
/** @defgroup PWREx_Private PWREx Private
* @{
*/
/**
* @}
*/
/**************************************************************/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __STM32L0xx_HAL_PWR_EX_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
bb9d5a59f9304f5b8a3778fad0bd9bdba4b7d8cf
|
abe704eb3b53944cdd6505f922f58558e334c589
|
/components/utilities/xz/xz-embedded/userspace/xzminidec.c
|
ba07413125a17044b7f26c9c4b51675e18c1e8ea
|
[
"LicenseRef-scancode-public-domain",
"Apache-2.0"
] |
permissive
|
espressif/esp-iot-solution
|
c25079eb26a8f54ddacd23689a7288533c721916
|
2227f0ca21ab37df9cf9d74182fa84c52dffc76f
|
refs/heads/master
| 2023-09-01T15:06:17.000154
| 2023-08-31T10:26:21
| 2023-08-31T10:26:21
| 99,690,601
| 1,612
| 758
|
Apache-2.0
| 2023-09-08T08:43:59
| 2017-08-08T12:32:16
|
C
|
UTF-8
|
C
| false
| false
| 2,643
|
c
|
xzminidec.c
|
/*
* Simple XZ decoder command line tool
*
* Author: Lasse Collin <lasse.collin@tukaani.org>
*
* This file has been put into the public domain.
* You can do whatever you want with this file.
*/
/*
* This is really limited: Not all filters from .xz format are supported,
* only CRC32 is supported as the integrity check, and decoding of
* concatenated .xz streams is not supported. Thus, you may want to look
* at xzdec from XZ Utils if a few KiB bigger tool is not a problem.
*/
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include "xz.h"
static uint8_t in[BUFSIZ];
static uint8_t out[BUFSIZ];
int main(int argc, char **argv)
{
struct xz_buf b;
struct xz_dec *s;
enum xz_ret ret;
const char *msg;
if (argc >= 2 && strcmp(argv[1], "--help") == 0) {
fputs("Uncompress a .xz file from stdin to stdout.\n"
"Arguments other than `--help' are ignored.\n",
stdout);
return 0;
}
xz_crc32_init();
#ifdef XZ_USE_CRC64
xz_crc64_init();
#endif
/*
* Support up to 64 MiB dictionary. The actually needed memory
* is allocated once the headers have been parsed.
*/
s = xz_dec_init(XZ_DYNALLOC, 1 << 26);
if (s == NULL) {
msg = "Memory allocation failed\n";
goto error;
}
b.in = in;
b.in_pos = 0;
b.in_size = 0;
b.out = out;
b.out_pos = 0;
b.out_size = BUFSIZ;
while (true) {
if (b.in_pos == b.in_size) {
b.in_size = fread(in, 1, sizeof(in), stdin);
b.in_pos = 0;
}
ret = xz_dec_run(s, &b);
if (b.out_pos == sizeof(out)) {
if (fwrite(out, 1, b.out_pos, stdout) != b.out_pos) {
msg = "Write error\n";
goto error;
}
b.out_pos = 0;
}
if (ret == XZ_OK)
continue;
#ifdef XZ_DEC_ANY_CHECK
if (ret == XZ_UNSUPPORTED_CHECK) {
fputs(argv[0], stderr);
fputs(": ", stderr);
fputs("Unsupported check; not verifying "
"file integrity\n", stderr);
continue;
}
#endif
if (fwrite(out, 1, b.out_pos, stdout) != b.out_pos
|| fclose(stdout)) {
msg = "Write error\n";
goto error;
}
switch (ret) {
case XZ_STREAM_END:
xz_dec_end(s);
return 0;
case XZ_MEM_ERROR:
msg = "Memory allocation failed\n";
goto error;
case XZ_MEMLIMIT_ERROR:
msg = "Memory usage limit reached\n";
goto error;
case XZ_FORMAT_ERROR:
msg = "Not a .xz file\n";
goto error;
case XZ_OPTIONS_ERROR:
msg = "Unsupported options in the .xz headers\n";
goto error;
case XZ_DATA_ERROR:
case XZ_BUF_ERROR:
msg = "File is corrupt\n";
goto error;
default:
msg = "Bug!\n";
goto error;
}
}
error:
xz_dec_end(s);
fputs(argv[0], stderr);
fputs(": ", stderr);
fputs(msg, stderr);
return 1;
}
|
0517c0c955a0388898e4e98cbaf8e2b1ea9f9d8c
|
99bdb3251fecee538e0630f15f6574054dfc1468
|
/bsp/at32/libraries/usbfs_library/inc/usbd_core.h
|
74f521e17b0f4332d25d07ef4bd35ee9f71832f7
|
[
"Zlib",
"LicenseRef-scancode-proprietary-license",
"MIT",
"BSD-3-Clause",
"X11",
"BSD-4-Clause-UC",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] |
permissive
|
RT-Thread/rt-thread
|
03a7c52c2aeb1b06a544143b0e803d72f47d1ece
|
3602f891211904a27dcbd51e5ba72fefce7326b2
|
refs/heads/master
| 2023-09-01T04:10:20.295801
| 2023-08-31T16:20:55
| 2023-08-31T16:20:55
| 7,408,108
| 9,599
| 5,805
|
Apache-2.0
| 2023-09-14T13:37:26
| 2013-01-02T14:49:21
|
C
|
UTF-8
|
C
| false
| false
| 8,274
|
h
|
usbd_core.h
|
/**
**************************************************************************
* @file usbd_core.h
* @brief usb device core header file
**************************************************************************
* Copyright notice & Disclaimer
*
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* software is governed by this copyright notice and the following disclaimer.
*
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
* GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
* TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
* STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
* INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
*
**************************************************************************
*/
/* define to prevent recursive inclusion -------------------------------------*/
#ifndef __USBD_CORE_H
#define __USBD_CORE_H
#ifdef __cplusplus
extern "C" {
#endif
#include "usb_std.h"
/** @addtogroup USBD_drivers_core
* @{
*/
/** @defgroup USBD_core_exported_types
* @{
*/
#ifdef USE_OTG_DEVICE_MODE
/**
* @brief usb device event
*/
typedef enum
{
USBD_NOP_EVENT, /*!< usb device nop event */
USBD_RESET_EVENT, /*!< usb device reset event */
USBD_SUSPEND_EVENT, /*!< usb device suspend event */
USBD_WAKEUP_EVENT, /*!< usb device wakeup event */
USBD_DISCONNECT_EVNET, /*!< usb device disconnect event */
USBD_INISOINCOM_EVENT, /*!< usb device inisoincom event */
USBD_OUTISOINCOM_EVENT, /*!< usb device outisoincom event */
USBD_ERR_EVENT /*!< usb device error event */
}usbd_event_type;
/**
* @brief usb device descriptor struct
*/
typedef struct
{
uint16_t length; /*!< descriptor length */
uint8_t *descriptor; /*!< descriptor string */
}usbd_desc_t;
/**
* @brief usb device descriptor handler
*/
typedef struct
{
usbd_desc_t *(*get_device_descriptor)(void); /*!< get device descriptor callback */
usbd_desc_t *(*get_device_qualifier)(void); /*!< get device qualifier callback */
usbd_desc_t *(*get_device_configuration)(void); /*!< get device configuration callback */
usbd_desc_t *(*get_device_other_speed)(void); /*!< get device other speed callback */
usbd_desc_t *(*get_device_lang_id)(void); /*!< get device lang id callback */
usbd_desc_t *(*get_device_manufacturer_string)(void); /*!< get device manufacturer callback */
usbd_desc_t *(*get_device_product_string)(void); /*!< get device product callback */
usbd_desc_t *(*get_device_serial_string)(void); /*!< get device serial callback */
usbd_desc_t *(*get_device_interface_string)(void); /*!< get device interface string callback */
usbd_desc_t *(*get_device_config_string)(void); /*!< get device device config callback */
}usbd_desc_handler;
/**
* @brief usb device class handler
*/
typedef struct
{
usb_sts_type (*init_handler)(void *udev); /*!< usb class init handler */
usb_sts_type (*clear_handler)(void *udev); /*!< usb class clear handler */
usb_sts_type (*setup_handler)(void *udev, usb_setup_type *setup); /*!< usb class setup handler */
usb_sts_type (*ept0_tx_handler)(void *udev); /*!< usb class endpoint 0 tx complete handler */
usb_sts_type (*ept0_rx_handler)(void *udev); /*!< usb class endpoint 0 rx complete handler */
usb_sts_type (*in_handler)(void *udev, uint8_t ept_num); /*!< usb class in transfer complete handler */
usb_sts_type (*out_handler)(void *udev, uint8_t ept_num); /*!< usb class out transfer complete handler */
usb_sts_type (*sof_handler)(void *udev); /*!< usb class sof handler */
usb_sts_type (*event_handler)(void *udev, usbd_event_type event); /*!< usb class event handler */
void *pdata; /*!< usb class data pointer */
}usbd_class_handler;
/**
* @brief usb device core struct type
*/
typedef struct
{
usb_reg_type *usb_reg; /*!< usb register pointer */
usbd_class_handler *class_handler; /*!< usb device class handler pointer */
usbd_desc_handler *desc_handler; /*!< usb device descriptor handler pointer */
usb_ept_info ept_in[USB_EPT_MAX_NUM]; /*!< usb in endpoint infomation struct */
usb_ept_info ept_out[USB_EPT_MAX_NUM]; /*!< usb out endpoint infomation struct */
usb_setup_type setup; /*!< usb setup type struct */
uint8_t setup_buffer[12]; /*!< usb setup request buffer */
uint8_t ept0_sts; /*!< usb control endpoint 0 state */
uint8_t speed; /*!< usb speed */
uint16_t ept0_wlength; /*!< usb endpoint 0 transfer length */
usbd_conn_state conn_state; /*!< usb current connect state */
usbd_conn_state old_conn_state; /*!< usb save the previous connect state */
uint8_t device_addr; /*!< device address */
uint8_t remote_wakup; /*!< remote wakeup state */
uint8_t default_config; /*!< usb default config state */
uint8_t dev_config; /*!< usb device config state */
uint32_t config_status; /*!< usb configure status */
void *pdata;
}usbd_core_type;
void usbd_core_in_handler(usbd_core_type *udev, uint8_t ept_num);
void usbd_core_out_handler(usbd_core_type *udev, uint8_t ept_num);
void usbd_core_setup_handler(usbd_core_type *udev, uint8_t ept_num);
void usbd_ctrl_unsupport(usbd_core_type *udev);
void usbd_ctrl_send(usbd_core_type *udev, uint8_t *buffer, uint16_t len);
void usbd_ctrl_recv(usbd_core_type *udev, uint8_t *buffer, uint16_t len);
void usbd_ctrl_send_status(usbd_core_type *udev);
void usbd_ctrl_recv_status(usbd_core_type *udev);
void usbd_set_stall(usbd_core_type *udev, uint8_t ept_addr);
void usbd_clear_stall(usbd_core_type *udev, uint8_t ept_addr);
void usbd_ept_open(usbd_core_type *udev, uint8_t ept_addr, uint8_t ept_type, uint16_t maxpacket);
void usbd_ept_close(usbd_core_type *udev, uint8_t ept_addr);
void usbd_ept_send(usbd_core_type *udev, uint8_t ept_num, uint8_t *buffer, uint16_t len);
void usbd_ept_recv(usbd_core_type *udev, uint8_t ept_num, uint8_t *buffer, uint16_t len);
void usbd_connect(usbd_core_type *udev);
void usbd_disconnect(usbd_core_type *udev);
void usbd_set_device_addr(usbd_core_type *udev, uint8_t address);
uint32_t usbd_get_recv_len(usbd_core_type *udev, uint8_t ept_addr);
void usb_ept_defaut_init(usbd_core_type *udev);
usbd_conn_state usbd_connect_state_get(usbd_core_type *udev);
void usbd_remote_wakeup(usbd_core_type *udev);
void usbd_enter_suspend(usbd_core_type *udev);
void usbd_flush_tx_fifo(usbd_core_type *udev, uint8_t ept_num);
void usbd_fifo_alloc(usbd_core_type *udev);
usb_sts_type usbd_core_init(usbd_core_type *udev,
usb_reg_type *usb_reg,
uint8_t core_id);
#endif
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif
|
fb47915783936b53a88fdeb14aed21947b907fb8
|
c26d7b0ed875357278e61627da2da0650da77986
|
/src/cmd/uucp/versys.c
|
7b56c8c99273327ac7bd7723749552bf2d9416ba
|
[
"BSD-3-Clause"
] |
permissive
|
RetroBSD/retrobsd
|
5343d9e3c424637fc3ad5b03fe720b2744490025
|
486f81f6abff01c7dcc207235cd2979b226a95ff
|
refs/heads/master
| 2023-09-02T23:12:05.110883
| 2023-07-07T18:41:40
| 2023-07-07T18:41:40
| 18,598,087
| 282
| 59
|
BSD-3-Clause
| 2023-07-18T07:35:36
| 2014-04-09T13:25:46
|
C
|
UTF-8
|
C
| false
| false
| 2,805
|
c
|
versys.c
|
#if !defined(lint) && defined(DOSCCS)
static char sccsid[] = "@(#)versys.c 5.5.1 (2.11BSD) 1997/10/2";
#endif
#include "uucp.h"
#include <stdio.h>
#include <ctype.h>
/*LINTLIBRARY*/
char PhoneNumber[MAXPH];
/*
* verify system names n1 and n2
* return codes: SUCCESS | FAIL
*
* NOTE:
* the old calling sequence was versys(name) but is
* now versys(&name) so that we can perform aliasing!!!!
* See accompanying changes in uucp.c and uux.c
* -- Ray Essick, April 27, 1984
*/
versys(nameptr)
register char **nameptr;
{
register FILE *fp;
char line[BUFSIZ];
char *name;
DEBUG (11, "Before Alias: %s\n", *nameptr);
uualias (nameptr); /* alias expansion */
DEBUG (11, "After Alias: %s\n", *nameptr);
name = *nameptr; /* dereference */
if (strncmp(name, Myname, MAXBASENAME) == 0)
return SUCCESS;
fp = fopen(SYSFILE, "r");
ASSERT(fp != NULL, CANTOPEN, SYSFILE, 0);
PhoneNumber[0] = '\0';
while (cfgets(line, sizeof(line), fp) != NULL) {
char *targs[100];
getargs(line, targs, 100);
if (strncmp(name, targs[0], MAXBASENAME) == SAME) {
fclose(fp);
strncpy(PhoneNumber, targs[F_PHONE], MAXPH);
return SUCCESS;
}
}
fclose(fp);
return FAIL;
}
/*
* Works (sort of) like rhost(3) on 4.1[abc] Bsd systems.
*
* Looks for the host in the L.aliases file and returns the
* "standard" name by modifying the pointer. The returned
* value is saved with malloc(3) so it isn't zapped by
* subsequent calls.
*
* Returns:
* FAIL No L.aliases file
* SUCCESS Anything else
*/
uualias(hostptr)
char **hostptr; /* we change it */
{
FILE *Aliases; /* list of aliases */
char buf[BUFSIZ];
int atend;
char *p, *q;
char *koshername; /* "official" name */
if ((Aliases = fopen(ALIASFILE, "r")) == NULL) {
DEBUG(11, "No %s file\n", ALIASFILE);
return FAIL; /* no alias file */
}
DEBUG (11, "Alias expansion for %s\n", *hostptr);
while (cfgets(buf, sizeof (buf), Aliases)) {
p = &buf[0];
atend = 0;
DEBUG(11, "Alias line: %s\n", buf);
while (!atend) {
while (isspace(*p) && *p != '\n')
p++; /* skip white space */
q = p;
while (!isspace(*q) && *q != '\n')
q++; /* find end */
if (*q == '\n')
atend++; /* last entry */
*q = '\0';
DEBUG(11, "Compare against: %s\n", p);
if (strcmp(*hostptr, p) == 0)/* match? */ {
koshername = (char *)malloc((unsigned)strlen(buf) + 1);
strcpy(koshername, buf); /* save it */
fclose(Aliases);
DEBUG(4, "Alias: %s to ", *hostptr);
DEBUG(4, "%s\n", koshername);
*hostptr = koshername; /* correct one */
return SUCCESS; /* all is well */
}
p = q + 1; /* try next entry */
}
}
fclose(Aliases);
DEBUG(11, "Alias doesn't match %s, remains unchanged\n", *hostptr);
return SUCCESS; /* unchanged host */
}
|
03f1c6e3d061b4692d2c5a4fcbd84cbbaede082f
|
6d162c19c9f1dc1d03f330cad63d0dcde1df082d
|
/qrenderdoc/3rdparty/qt/include/QtWidgets/QUndoStack
|
6bd1e5e5b7272612dbfac4205122ca08605bb136
|
[
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"LGPL-2.0-or-later",
"LGPL-3.0-only",
"GPL-3.0-only",
"Python-2.0",
"LicenseRef-scancode-other-copyleft",
"LicenseRef-scancode-mit-old-style",
"LGPL-2.1-or-later",
"LGPL-2.1-only",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-other-permissive",
"bzip2-1.0.6",
"Bison-exception-2.2",
"MIT-open-group",
"X11",
"blessing",
"BSD-3-Clause",
"BSD-4.3TAHOE",
"GPL-2.0-only",
"LicenseRef-scancode-free-unknown",
"IJG",
"xlock",
"HPND",
"LicenseRef-scancode-xfree86-1.0",
"LicenseRef-scancode-pcre",
"Libpng",
"FTL",
"Zlib",
"GPL-1.0-or-later",
"libtiff",
"LicenseRef-scancode-ietf",
"LicenseRef-scancode-cavium-malloc",
"LicenseRef-scancode-public-domain",
"HPND-sell-variant",
"ICU",
"BSD-2-Clause",
"LicenseRef-scancode-lcs-telegraphics",
"dtoa",
"LicenseRef-scancode-mit-veillard-variant",
"LicenseRef-scancode-public-domain-disclaimer",
"GFDL-1.1-or-later",
"CC-BY-SA-4.0",
"CC-BY-SA-3.0",
"GFDL-1.3-or-later",
"OpenSSL"
] |
permissive
|
baldurk/renderdoc
|
24efbb84446a9d443bb9350013f3bfab9e9c5923
|
a214ffcaf38bf5319b2b23d3d014cf3772cda3c6
|
refs/heads/v1.x
| 2023-08-16T21:20:43.886587
| 2023-07-28T22:34:10
| 2023-08-15T09:09:40
| 17,253,131
| 7,729
| 1,358
|
MIT
| 2023-09-13T09:36:53
| 2014-02-27T15:16:30
|
C++
|
UTF-8
|
C
| false
| false
| 24
|
QUndoStack
|
#include "qundostack.h"
|
|
5e72e766d18e78927fef687618ce7ef70adc75de
|
485ff07efdbb3e56b9633e3134b1c81271c2d8a3
|
/cpp/SampleRdkContentTask/Resource.h
|
3275407c0c8173894af59afd1d15dc6448375c3a
|
[
"LicenseRef-scancode-warranty-disclaimer"
] |
no_license
|
mcneel/rhino-developer-samples
|
8f8a332d4d6a9a5fa064be6c1532e665d37c8f13
|
4fb376adcf94f9d583878d1c1208038f86bde312
|
refs/heads/7
| 2023-08-18T22:04:34.036498
| 2023-06-08T16:28:43
| 2023-06-08T16:28:43
| 72,225,588
| 526
| 362
|
NOASSERTION
| 2023-09-06T20:29:31
| 2016-10-28T16:52:21
|
C++
|
UTF-8
|
C
| false
| false
| 1,652
|
h
|
Resource.h
|
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by SampleRdkContentTask.rc
//
#define IDI_ICON 100
#define IDM_APP_FILE_SAVE_AS 101
#define IDM_APP_EDIT_COPY 102
#define IDM_APP_FILE_PRINT 103
#define IDM_APP_FILE_EXIT 104
#define IDM_APP_HELP_DISPLAY_HELP 105
#define IDD_MATERIAL_SECTION 1000
#define IDI_RENDER 1001
#define IDR_RENDER 12006
#define ID_APP_VIEW_NORMALVIEW 32777
#define ID_APP_VIEW_IN2X 32779
#define ID_APP_VIEW_IN3X 32780
#define ID_APP_VIEW_IN4X 32781
#define ID_APP_VIEW_IN5X 32782
#define ID_APP_VIEW_OUT2X 32783
#define ID_APP_VIEW_OUT3X 32784
#define ID_APP_VIEW_OUT4X 32785
#define ID_APP_VIEW_OUT5X 32786
#define ID_APP_VIEW_OUT6X 32787
#define ID_APP_VIEW_IN6X 32788
#define ID_APP_VIEW_OUT7X 32789
#define ID_APP_VIEW_OUT8X 32790
#define ID_APP_VIEW_OUT9X 32791
#define ID_APP_VIEW_OUT10X 32792
#define ID_APP_VIEW_IN7X 32793
#define ID_APP_VIEW_IN8X 32794
#define ID_APP_VIEW_IN9X 32795
#define ID_APP_VIEW_IN10X 32796
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 13000
#define _APS_NEXT_CONTROL_VALUE 13000
#define _APS_NEXT_SYMED_VALUE 13000
#define _APS_NEXT_COMMAND_VALUE 32771
#endif
#endif
|
0995f4003273a0552fded75754bdf179c21197d1
|
04cdc91f88a137e2f7d470b0ef713d72f79f9d47
|
/AI_Engine_Development/Design_Tutorials/07-firFilter_AIEvsHLS/HLS/design/host_app_src/input_data.h
|
b8db627ced6877dea17f18a31c8c107a1cd6a4ea
|
[
"MIT"
] |
permissive
|
Xilinx/Vitis-Tutorials
|
80b6945c88406d0669326bb13b222b5a44fcc0c7
|
ab39b8482dcbd2264ccb9462910609e714f1d10d
|
refs/heads/2023.1
| 2023-09-05T11:59:43.272473
| 2023-08-21T16:43:31
| 2023-08-21T16:43:31
| 211,912,254
| 926
| 611
|
MIT
| 2023-08-03T03:20:33
| 2019-09-30T17:08:51
|
C
|
UTF-8
|
C
| false
| false
| 188,726
|
h
|
input_data.h
|
/*
Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: X11
*/
// This data header file automatically generated by FIR_data_gen.m
// r_amplitude: 16383 r_freq: 2
// i_amplitude: 16383 i_freq: 4
#define INPUT_SAMPLES 8192
cint16 input_data[] = {
{ 0, 16383},
{ 101, 0},
{ 201, 0},
{ 302, 0},
{ 402, 0},
{ 503, 0},
{ 603, 0},
{ 703, 0},
{ 804, 0},
{ 904, 0},
{ 1005, 0},
{ 1105, 0},
{ 1205, 0},
{ 1305, 0},
{ 1406, 0},
{ 1506, 0},
{ 1606, 0},
{ 1706, 0},
{ 1806, 0},
{ 1906, 0},
{ 2005, 0},
{ 2105, 0},
{ 2205, 0},
{ 2304, 0},
{ 2404, 0},
{ 2503, 0},
{ 2603, 0},
{ 2702, 0},
{ 2801, 0},
{ 2900, 0},
{ 2999, 0},
{ 3098, 0},
{ 3196, 0},
{ 3295, 0},
{ 3393, 0},
{ 3491, 0},
{ 3590, 0},
{ 3688, 0},
{ 3785, 0},
{ 3883, 0},
{ 3981, 0},
{ 4078, 0},
{ 4175, 0},
{ 4273, 0},
{ 4370, 0},
{ 4466, 0},
{ 4563, 0},
{ 4659, 0},
{ 4756, 0},
{ 4852, 0},
{ 4948, 0},
{ 5044, 0},
{ 5139, 0},
{ 5234, 0},
{ 5330, 0},
{ 5425, 0},
{ 5519, 0},
{ 5614, 0},
{ 5708, 0},
{ 5802, 0},
{ 5896, 0},
{ 5990, 0},
{ 6083, 0},
{ 6177, 0},
{ 6270, 0},
{ 6362, 0},
{ 6455, 0},
{ 6547, 0},
{ 6639, 0},
{ 6731, 0},
{ 6822, 0},
{ 6914, 0},
{ 7005, 0},
{ 7095, 0},
{ 7186, 0},
{ 7276, 0},
{ 7366, 0},
{ 7456, 0},
{ 7545, 0},
{ 7634, 0},
{ 7723, 0},
{ 7811, 0},
{ 7900, 0},
{ 7988, 0},
{ 8075, 0},
{ 8162, 0},
{ 8249, 0},
{ 8336, 0},
{ 8423, 0},
{ 8509, 0},
{ 8594, 0},
{ 8680, 0},
{ 8765, 0},
{ 8850, 0},
{ 8934, 0},
{ 9018, 0},
{ 9102, 0},
{ 9185, 0},
{ 9268, 0},
{ 9351, 0},
{ 9433, 0},
{ 9515, 0},
{ 9597, 0},
{ 9678, 0},
{ 9759, 0},
{ 9840, 0},
{ 9920, 0},
{ 10000, 0},
{ 10079, 0},
{ 10158, 0},
{ 10237, 0},
{ 10315, 0},
{ 10393, 0},
{ 10471, 0},
{ 10548, 0},
{ 10625, 0},
{ 10701, 0},
{ 10777, 0},
{ 10852, 0},
{ 10927, 0},
{ 11002, 0},
{ 11076, 0},
{ 11150, 0},
{ 11224, 0},
{ 11297, 0},
{ 11369, 0},
{ 11441, 0},
{ 11513, 0},
{ 11585, 0},
{ 11655, 0},
{ 11726, 0},
{ 11796, 0},
{ 11865, 0},
{ 11934, 0},
{ 12003, 0},
{ 12071, 0},
{ 12139, 0},
{ 12206, 0},
{ 12273, 0},
{ 12339, 0},
{ 12405, 0},
{ 12471, 0},
{ 12536, 0},
{ 12600, 0},
{ 12664, 0},
{ 12728, 0},
{ 12791, 0},
{ 12853, 0},
{ 12915, 0},
{ 12977, 0},
{ 13038, 0},
{ 13099, 0},
{ 13159, 0},
{ 13219, 0},
{ 13278, 0},
{ 13336, 0},
{ 13394, 0},
{ 13452, 0},
{ 13509, 0},
{ 13566, 0},
{ 13622, 0},
{ 13678, 0},
{ 13733, 0},
{ 13787, 0},
{ 13841, 0},
{ 13895, 0},
{ 13948, 0},
{ 14000, 0},
{ 14052, 0},
{ 14104, 0},
{ 14154, 0},
{ 14205, 0},
{ 14255, 0},
{ 14304, 0},
{ 14353, 0},
{ 14401, 0},
{ 14449, 0},
{ 14496, 0},
{ 14542, 0},
{ 14588, 0},
{ 14634, 0},
{ 14679, 0},
{ 14723, 0},
{ 14767, 0},
{ 14810, 0},
{ 14853, 0},
{ 14895, 0},
{ 14936, 0},
{ 14977, 0},
{ 15018, 0},
{ 15058, 0},
{ 15097, 0},
{ 15136, 0},
{ 15174, 0},
{ 15212, 0},
{ 15249, 0},
{ 15285, 0},
{ 15321, 0},
{ 15356, 0},
{ 15391, 0},
{ 15425, 0},
{ 15459, 0},
{ 15492, 0},
{ 15524, 0},
{ 15556, 0},
{ 15587, 0},
{ 15618, 0},
{ 15648, 0},
{ 15678, 0},
{ 15706, 0},
{ 15735, 0},
{ 15762, 0},
{ 15790, 0},
{ 15816, 0},
{ 15842, 0},
{ 15867, 0},
{ 15892, 0},
{ 15916, 0},
{ 15940, 0},
{ 15963, 0},
{ 15985, 0},
{ 16007, 0},
{ 16028, 0},
{ 16048, 0},
{ 16068, 0},
{ 16088, 0},
{ 16106, 0},
{ 16124, 0},
{ 16142, 0},
{ 16159, 0},
{ 16175, 0},
{ 16191, 0},
{ 16206, 0},
{ 16220, 0},
{ 16234, 0},
{ 16247, 0},
{ 16260, 0},
{ 16272, 0},
{ 16283, 0},
{ 16294, 0},
{ 16304, 0},
{ 16314, 0},
{ 16323, 0},
{ 16331, 0},
{ 16339, 0},
{ 16346, 0},
{ 16352, 0},
{ 16358, 0},
{ 16363, 0},
{ 16368, 0},
{ 16372, 0},
{ 16375, 0},
{ 16378, 0},
{ 16380, 0},
{ 16382, 0},
{ 16383, 0},
{ 16383, 0},
{ 16383, 0},
{ 16382, 0},
{ 16380, 0},
{ 16378, 0},
{ 16375, 0},
{ 16372, 0},
{ 16368, 0},
{ 16363, 0},
{ 16358, 0},
{ 16352, 0},
{ 16346, 0},
{ 16339, 0},
{ 16331, 0},
{ 16323, 0},
{ 16314, 0},
{ 16304, 0},
{ 16294, 0},
{ 16283, 0},
{ 16272, 0},
{ 16260, 0},
{ 16247, 0},
{ 16234, 0},
{ 16220, 0},
{ 16206, 0},
{ 16191, 0},
{ 16175, 0},
{ 16159, 0},
{ 16142, 0},
{ 16124, 0},
{ 16106, 0},
{ 16088, 0},
{ 16068, 0},
{ 16048, 0},
{ 16028, 0},
{ 16007, 0},
{ 15985, 0},
{ 15963, 0},
{ 15940, 0},
{ 15916, 0},
{ 15892, 0},
{ 15867, 0},
{ 15842, 0},
{ 15816, 0},
{ 15790, 0},
{ 15762, 0},
{ 15735, 0},
{ 15706, 0},
{ 15678, 0},
{ 15648, 0},
{ 15618, 0},
{ 15587, 0},
{ 15556, 0},
{ 15524, 0},
{ 15492, 0},
{ 15459, 0},
{ 15425, 0},
{ 15391, 0},
{ 15356, 0},
{ 15321, 0},
{ 15285, 0},
{ 15249, 0},
{ 15212, 0},
{ 15174, 0},
{ 15136, 0},
{ 15097, 0},
{ 15058, 0},
{ 15018, 0},
{ 14977, 0},
{ 14936, 0},
{ 14895, 0},
{ 14853, 0},
{ 14810, 0},
{ 14767, 0},
{ 14723, 0},
{ 14679, 0},
{ 14634, 0},
{ 14588, 0},
{ 14542, 0},
{ 14496, 0},
{ 14449, 0},
{ 14401, 0},
{ 14353, 0},
{ 14304, 0},
{ 14255, 0},
{ 14205, 0},
{ 14154, 0},
{ 14104, 0},
{ 14052, 0},
{ 14000, 0},
{ 13948, 0},
{ 13895, 0},
{ 13841, 0},
{ 13787, 0},
{ 13733, 0},
{ 13678, 0},
{ 13622, 0},
{ 13566, 0},
{ 13509, 0},
{ 13452, 0},
{ 13394, 0},
{ 13336, 0},
{ 13278, 0},
{ 13219, 0},
{ 13159, 0},
{ 13099, 0},
{ 13038, 0},
{ 12977, 0},
{ 12915, 0},
{ 12853, 0},
{ 12791, 0},
{ 12728, 0},
{ 12664, 0},
{ 12600, 0},
{ 12536, 0},
{ 12471, 0},
{ 12405, 0},
{ 12339, 0},
{ 12273, 0},
{ 12206, 0},
{ 12139, 0},
{ 12071, 0},
{ 12003, 0},
{ 11934, 0},
{ 11865, 0},
{ 11796, 0},
{ 11726, 0},
{ 11655, 0},
{ 11585, 0},
{ 11513, 0},
{ 11441, 0},
{ 11369, 0},
{ 11297, 0},
{ 11224, 0},
{ 11150, 0},
{ 11076, 0},
{ 11002, 0},
{ 10927, 0},
{ 10852, 0},
{ 10777, 0},
{ 10701, 0},
{ 10625, 0},
{ 10548, 0},
{ 10471, 0},
{ 10393, 0},
{ 10315, 0},
{ 10237, 0},
{ 10158, 0},
{ 10079, 0},
{ 10000, 0},
{ 9920, 0},
{ 9840, 0},
{ 9759, 0},
{ 9678, 0},
{ 9597, 0},
{ 9515, 0},
{ 9433, 0},
{ 9351, 0},
{ 9268, 0},
{ 9185, 0},
{ 9102, 0},
{ 9018, 0},
{ 8934, 0},
{ 8850, 0},
{ 8765, 0},
{ 8680, 0},
{ 8594, 0},
{ 8509, 0},
{ 8423, 0},
{ 8336, 0},
{ 8249, 0},
{ 8162, 0},
{ 8075, 0},
{ 7988, 0},
{ 7900, 0},
{ 7811, 0},
{ 7723, 0},
{ 7634, 0},
{ 7545, 0},
{ 7456, 0},
{ 7366, 0},
{ 7276, 0},
{ 7186, 0},
{ 7095, 0},
{ 7005, 0},
{ 6914, 0},
{ 6822, 0},
{ 6731, 0},
{ 6639, 0},
{ 6547, 0},
{ 6455, 0},
{ 6362, 0},
{ 6270, 0},
{ 6177, 0},
{ 6083, 0},
{ 5990, 0},
{ 5896, 0},
{ 5802, 0},
{ 5708, 0},
{ 5614, 0},
{ 5519, 0},
{ 5425, 0},
{ 5330, 0},
{ 5234, 0},
{ 5139, 0},
{ 5044, 0},
{ 4948, 0},
{ 4852, 0},
{ 4756, 0},
{ 4659, 0},
{ 4563, 0},
{ 4466, 0},
{ 4370, 0},
{ 4273, 0},
{ 4175, 0},
{ 4078, 0},
{ 3981, 0},
{ 3883, 0},
{ 3785, 0},
{ 3688, 0},
{ 3590, 0},
{ 3491, 0},
{ 3393, 0},
{ 3295, 0},
{ 3196, 0},
{ 3098, 0},
{ 2999, 0},
{ 2900, 0},
{ 2801, 0},
{ 2702, 0},
{ 2603, 0},
{ 2503, 0},
{ 2404, 0},
{ 2304, 0},
{ 2205, 0},
{ 2105, 0},
{ 2005, 0},
{ 1906, 0},
{ 1806, 0},
{ 1706, 0},
{ 1606, 0},
{ 1506, 0},
{ 1406, 0},
{ 1305, 0},
{ 1205, 0},
{ 1105, 0},
{ 1005, 0},
{ 904, 0},
{ 804, 0},
{ 703, 0},
{ 603, 0},
{ 503, 0},
{ 402, 0},
{ 302, 0},
{ 201, 0},
{ 101, 0},
{ 0, 16383},
{ -101, 0},
{ -201, 0},
{ -302, 0},
{ -402, 0},
{ -503, 0},
{ -603, 0},
{ -703, 0},
{ -804, 0},
{ -904, 0},
{ -1005, 0},
{ -1105, 0},
{ -1205, 0},
{ -1305, 0},
{ -1406, 0},
{ -1506, 0},
{ -1606, 0},
{ -1706, 0},
{ -1806, 0},
{ -1906, 0},
{ -2005, 0},
{ -2105, 0},
{ -2205, 0},
{ -2304, 0},
{ -2404, 0},
{ -2503, 0},
{ -2603, 0},
{ -2702, 0},
{ -2801, 0},
{ -2900, 0},
{ -2999, 0},
{ -3098, 0},
{ -3196, 0},
{ -3295, 0},
{ -3393, 0},
{ -3491, 0},
{ -3590, 0},
{ -3688, 0},
{ -3785, 0},
{ -3883, 0},
{ -3981, 0},
{ -4078, 0},
{ -4175, 0},
{ -4273, 0},
{ -4370, 0},
{ -4466, 0},
{ -4563, 0},
{ -4659, 0},
{ -4756, 0},
{ -4852, 0},
{ -4948, 0},
{ -5044, 0},
{ -5139, 0},
{ -5234, 0},
{ -5330, 0},
{ -5425, 0},
{ -5519, 0},
{ -5614, 0},
{ -5708, 0},
{ -5802, 0},
{ -5896, 0},
{ -5990, 0},
{ -6083, 0},
{ -6177, 0},
{ -6270, 0},
{ -6362, 0},
{ -6455, 0},
{ -6547, 0},
{ -6639, 0},
{ -6731, 0},
{ -6822, 0},
{ -6914, 0},
{ -7005, 0},
{ -7095, 0},
{ -7186, 0},
{ -7276, 0},
{ -7366, 0},
{ -7456, 0},
{ -7545, 0},
{ -7634, 0},
{ -7723, 0},
{ -7811, 0},
{ -7900, 0},
{ -7988, 0},
{ -8075, 0},
{ -8162, 0},
{ -8249, 0},
{ -8336, 0},
{ -8423, 0},
{ -8509, 0},
{ -8594, 0},
{ -8680, 0},
{ -8765, 0},
{ -8850, 0},
{ -8934, 0},
{ -9018, 0},
{ -9102, 0},
{ -9185, 0},
{ -9268, 0},
{ -9351, 0},
{ -9433, 0},
{ -9515, 0},
{ -9597, 0},
{ -9678, 0},
{ -9759, 0},
{ -9840, 0},
{ -9920, 0},
{-10000, 0},
{-10079, 0},
{-10158, 0},
{-10237, 0},
{-10315, 0},
{-10393, 0},
{-10471, 0},
{-10548, 0},
{-10625, 0},
{-10701, 0},
{-10777, 0},
{-10852, 0},
{-10927, 0},
{-11002, 0},
{-11076, 0},
{-11150, 0},
{-11224, 0},
{-11297, 0},
{-11369, 0},
{-11441, 0},
{-11513, 0},
{-11585, 0},
{-11655, 0},
{-11726, 0},
{-11796, 0},
{-11865, 0},
{-11934, 0},
{-12003, 0},
{-12071, 0},
{-12139, 0},
{-12206, 0},
{-12273, 0},
{-12339, 0},
{-12405, 0},
{-12471, 0},
{-12536, 0},
{-12600, 0},
{-12664, 0},
{-12728, 0},
{-12791, 0},
{-12853, 0},
{-12915, 0},
{-12977, 0},
{-13038, 0},
{-13099, 0},
{-13159, 0},
{-13219, 0},
{-13278, 0},
{-13336, 0},
{-13394, 0},
{-13452, 0},
{-13509, 0},
{-13566, 0},
{-13622, 0},
{-13678, 0},
{-13733, 0},
{-13787, 0},
{-13841, 0},
{-13895, 0},
{-13948, 0},
{-14000, 0},
{-14052, 0},
{-14104, 0},
{-14154, 0},
{-14205, 0},
{-14255, 0},
{-14304, 0},
{-14353, 0},
{-14401, 0},
{-14449, 0},
{-14496, 0},
{-14542, 0},
{-14588, 0},
{-14634, 0},
{-14679, 0},
{-14723, 0},
{-14767, 0},
{-14810, 0},
{-14853, 0},
{-14895, 0},
{-14936, 0},
{-14977, 0},
{-15018, 0},
{-15058, 0},
{-15097, 0},
{-15136, 0},
{-15174, 0},
{-15212, 0},
{-15249, 0},
{-15285, 0},
{-15321, 0},
{-15356, 0},
{-15391, 0},
{-15425, 0},
{-15459, 0},
{-15492, 0},
{-15524, 0},
{-15556, 0},
{-15587, 0},
{-15618, 0},
{-15648, 0},
{-15678, 0},
{-15706, 0},
{-15735, 0},
{-15762, 0},
{-15790, 0},
{-15816, 0},
{-15842, 0},
{-15867, 0},
{-15892, 0},
{-15916, 0},
{-15940, 0},
{-15963, 0},
{-15985, 0},
{-16007, 0},
{-16028, 0},
{-16048, 0},
{-16068, 0},
{-16088, 0},
{-16106, 0},
{-16124, 0},
{-16142, 0},
{-16159, 0},
{-16175, 0},
{-16191, 0},
{-16206, 0},
{-16220, 0},
{-16234, 0},
{-16247, 0},
{-16260, 0},
{-16272, 0},
{-16283, 0},
{-16294, 0},
{-16304, 0},
{-16314, 0},
{-16323, 0},
{-16331, 0},
{-16339, 0},
{-16346, 0},
{-16352, 0},
{-16358, 0},
{-16363, 0},
{-16368, 0},
{-16372, 0},
{-16375, 0},
{-16378, 0},
{-16380, 0},
{-16382, 0},
{-16383, 0},
{-16383, 0},
{-16383, 0},
{-16382, 0},
{-16380, 0},
{-16378, 0},
{-16375, 0},
{-16372, 0},
{-16368, 0},
{-16363, 0},
{-16358, 0},
{-16352, 0},
{-16346, 0},
{-16339, 0},
{-16331, 0},
{-16323, 0},
{-16314, 0},
{-16304, 0},
{-16294, 0},
{-16283, 0},
{-16272, 0},
{-16260, 0},
{-16247, 0},
{-16234, 0},
{-16220, 0},
{-16206, 0},
{-16191, 0},
{-16175, 0},
{-16159, 0},
{-16142, 0},
{-16124, 0},
{-16106, 0},
{-16088, 0},
{-16068, 0},
{-16048, 0},
{-16028, 0},
{-16007, 0},
{-15985, 0},
{-15963, 0},
{-15940, 0},
{-15916, 0},
{-15892, 0},
{-15867, 0},
{-15842, 0},
{-15816, 0},
{-15790, 0},
{-15762, 0},
{-15735, 0},
{-15706, 0},
{-15678, 0},
{-15648, 0},
{-15618, 0},
{-15587, 0},
{-15556, 0},
{-15524, 0},
{-15492, 0},
{-15459, 0},
{-15425, 0},
{-15391, 0},
{-15356, 0},
{-15321, 0},
{-15285, 0},
{-15249, 0},
{-15212, 0},
{-15174, 0},
{-15136, 0},
{-15097, 0},
{-15058, 0},
{-15018, 0},
{-14977, 0},
{-14936, 0},
{-14895, 0},
{-14853, 0},
{-14810, 0},
{-14767, 0},
{-14723, 0},
{-14679, 0},
{-14634, 0},
{-14588, 0},
{-14542, 0},
{-14496, 0},
{-14449, 0},
{-14401, 0},
{-14353, 0},
{-14304, 0},
{-14255, 0},
{-14205, 0},
{-14154, 0},
{-14104, 0},
{-14052, 0},
{-14000, 0},
{-13948, 0},
{-13895, 0},
{-13841, 0},
{-13787, 0},
{-13733, 0},
{-13678, 0},
{-13622, 0},
{-13566, 0},
{-13509, 0},
{-13452, 0},
{-13394, 0},
{-13336, 0},
{-13278, 0},
{-13219, 0},
{-13159, 0},
{-13099, 0},
{-13038, 0},
{-12977, 0},
{-12915, 0},
{-12853, 0},
{-12791, 0},
{-12728, 0},
{-12664, 0},
{-12600, 0},
{-12536, 0},
{-12471, 0},
{-12405, 0},
{-12339, 0},
{-12273, 0},
{-12206, 0},
{-12139, 0},
{-12071, 0},
{-12003, 0},
{-11934, 0},
{-11865, 0},
{-11796, 0},
{-11726, 0},
{-11655, 0},
{-11585, 0},
{-11513, 0},
{-11441, 0},
{-11369, 0},
{-11297, 0},
{-11224, 0},
{-11150, 0},
{-11076, 0},
{-11002, 0},
{-10927, 0},
{-10852, 0},
{-10777, 0},
{-10701, 0},
{-10625, 0},
{-10548, 0},
{-10471, 0},
{-10393, 0},
{-10315, 0},
{-10237, 0},
{-10158, 0},
{-10079, 0},
{-10000, 0},
{ -9920, 0},
{ -9840, 0},
{ -9759, 0},
{ -9678, 0},
{ -9597, 0},
{ -9515, 0},
{ -9433, 0},
{ -9351, 0},
{ -9268, 0},
{ -9185, 0},
{ -9102, 0},
{ -9018, 0},
{ -8934, 0},
{ -8850, 0},
{ -8765, 0},
{ -8680, 0},
{ -8594, 0},
{ -8509, 0},
{ -8423, 0},
{ -8336, 0},
{ -8249, 0},
{ -8162, 0},
{ -8075, 0},
{ -7988, 0},
{ -7900, 0},
{ -7811, 0},
{ -7723, 0},
{ -7634, 0},
{ -7545, 0},
{ -7456, 0},
{ -7366, 0},
{ -7276, 0},
{ -7186, 0},
{ -7095, 0},
{ -7005, 0},
{ -6914, 0},
{ -6822, 0},
{ -6731, 0},
{ -6639, 0},
{ -6547, 0},
{ -6455, 0},
{ -6362, 0},
{ -6270, 0},
{ -6177, 0},
{ -6083, 0},
{ -5990, 0},
{ -5896, 0},
{ -5802, 0},
{ -5708, 0},
{ -5614, 0},
{ -5519, 0},
{ -5425, 0},
{ -5330, 0},
{ -5234, 0},
{ -5139, 0},
{ -5044, 0},
{ -4948, 0},
{ -4852, 0},
{ -4756, 0},
{ -4659, 0},
{ -4563, 0},
{ -4466, 0},
{ -4370, 0},
{ -4273, 0},
{ -4175, 0},
{ -4078, 0},
{ -3981, 0},
{ -3883, 0},
{ -3785, 0},
{ -3688, 0},
{ -3590, 0},
{ -3491, 0},
{ -3393, 0},
{ -3295, 0},
{ -3196, 0},
{ -3098, 0},
{ -2999, 0},
{ -2900, 0},
{ -2801, 0},
{ -2702, 0},
{ -2603, 0},
{ -2503, 0},
{ -2404, 0},
{ -2304, 0},
{ -2205, 0},
{ -2105, 0},
{ -2005, 0},
{ -1906, 0},
{ -1806, 0},
{ -1706, 0},
{ -1606, 0},
{ -1506, 0},
{ -1406, 0},
{ -1305, 0},
{ -1205, 0},
{ -1105, 0},
{ -1005, 0},
{ -904, 0},
{ -804, 0},
{ -703, 0},
{ -603, 0},
{ -503, 0},
{ -402, 0},
{ -302, 0},
{ -201, 0},
{ -101, 0},
{ 0, 16383},
{ 101, 0},
{ 201, 0},
{ 302, 0},
{ 402, 0},
{ 503, 0},
{ 603, 0},
{ 703, 0},
{ 804, 0},
{ 904, 0},
{ 1005, 0},
{ 1105, 0},
{ 1205, 0},
{ 1305, 0},
{ 1406, 0},
{ 1506, 0},
{ 1606, 0},
{ 1706, 0},
{ 1806, 0},
{ 1906, 0},
{ 2005, 0},
{ 2105, 0},
{ 2205, 0},
{ 2304, 0},
{ 2404, 0},
{ 2503, 0},
{ 2603, 0},
{ 2702, 0},
{ 2801, 0},
{ 2900, 0},
{ 2999, 0},
{ 3098, 0},
{ 3196, 0},
{ 3295, 0},
{ 3393, 0},
{ 3491, 0},
{ 3590, 0},
{ 3688, 0},
{ 3785, 0},
{ 3883, 0},
{ 3981, 0},
{ 4078, 0},
{ 4175, 0},
{ 4273, 0},
{ 4370, 0},
{ 4466, 0},
{ 4563, 0},
{ 4659, 0},
{ 4756, 0},
{ 4852, 0},
{ 4948, 0},
{ 5044, 0},
{ 5139, 0},
{ 5234, 0},
{ 5330, 0},
{ 5425, 0},
{ 5519, 0},
{ 5614, 0},
{ 5708, 0},
{ 5802, 0},
{ 5896, 0},
{ 5990, 0},
{ 6083, 0},
{ 6177, 0},
{ 6270, 0},
{ 6362, 0},
{ 6455, 0},
{ 6547, 0},
{ 6639, 0},
{ 6731, 0},
{ 6822, 0},
{ 6914, 0},
{ 7005, 0},
{ 7095, 0},
{ 7186, 0},
{ 7276, 0},
{ 7366, 0},
{ 7456, 0},
{ 7545, 0},
{ 7634, 0},
{ 7723, 0},
{ 7811, 0},
{ 7900, 0},
{ 7988, 0},
{ 8075, 0},
{ 8162, 0},
{ 8249, 0},
{ 8336, 0},
{ 8423, 0},
{ 8509, 0},
{ 8594, 0},
{ 8680, 0},
{ 8765, 0},
{ 8850, 0},
{ 8934, 0},
{ 9018, 0},
{ 9102, 0},
{ 9185, 0},
{ 9268, 0},
{ 9351, 0},
{ 9433, 0},
{ 9515, 0},
{ 9597, 0},
{ 9678, 0},
{ 9759, 0},
{ 9840, 0},
{ 9920, 0},
{ 10000, 0},
{ 10079, 0},
{ 10158, 0},
{ 10237, 0},
{ 10315, 0},
{ 10393, 0},
{ 10471, 0},
{ 10548, 0},
{ 10625, 0},
{ 10701, 0},
{ 10777, 0},
{ 10852, 0},
{ 10927, 0},
{ 11002, 0},
{ 11076, 0},
{ 11150, 0},
{ 11224, 0},
{ 11297, 0},
{ 11369, 0},
{ 11441, 0},
{ 11513, 0},
{ 11585, 0},
{ 11655, 0},
{ 11726, 0},
{ 11796, 0},
{ 11865, 0},
{ 11934, 0},
{ 12003, 0},
{ 12071, 0},
{ 12139, 0},
{ 12206, 0},
{ 12273, 0},
{ 12339, 0},
{ 12405, 0},
{ 12471, 0},
{ 12536, 0},
{ 12600, 0},
{ 12664, 0},
{ 12728, 0},
{ 12791, 0},
{ 12853, 0},
{ 12915, 0},
{ 12977, 0},
{ 13038, 0},
{ 13099, 0},
{ 13159, 0},
{ 13219, 0},
{ 13278, 0},
{ 13336, 0},
{ 13394, 0},
{ 13452, 0},
{ 13509, 0},
{ 13566, 0},
{ 13622, 0},
{ 13678, 0},
{ 13733, 0},
{ 13787, 0},
{ 13841, 0},
{ 13895, 0},
{ 13948, 0},
{ 14000, 0},
{ 14052, 0},
{ 14104, 0},
{ 14154, 0},
{ 14205, 0},
{ 14255, 0},
{ 14304, 0},
{ 14353, 0},
{ 14401, 0},
{ 14449, 0},
{ 14496, 0},
{ 14542, 0},
{ 14588, 0},
{ 14634, 0},
{ 14679, 0},
{ 14723, 0},
{ 14767, 0},
{ 14810, 0},
{ 14853, 0},
{ 14895, 0},
{ 14936, 0},
{ 14977, 0},
{ 15018, 0},
{ 15058, 0},
{ 15097, 0},
{ 15136, 0},
{ 15174, 0},
{ 15212, 0},
{ 15249, 0},
{ 15285, 0},
{ 15321, 0},
{ 15356, 0},
{ 15391, 0},
{ 15425, 0},
{ 15459, 0},
{ 15492, 0},
{ 15524, 0},
{ 15556, 0},
{ 15587, 0},
{ 15618, 0},
{ 15648, 0},
{ 15678, 0},
{ 15706, 0},
{ 15735, 0},
{ 15762, 0},
{ 15790, 0},
{ 15816, 0},
{ 15842, 0},
{ 15867, 0},
{ 15892, 0},
{ 15916, 0},
{ 15940, 0},
{ 15963, 0},
{ 15985, 0},
{ 16007, 0},
{ 16028, 0},
{ 16048, 0},
{ 16068, 0},
{ 16088, 0},
{ 16106, 0},
{ 16124, 0},
{ 16142, 0},
{ 16159, 0},
{ 16175, 0},
{ 16191, 0},
{ 16206, 0},
{ 16220, 0},
{ 16234, 0},
{ 16247, 0},
{ 16260, 0},
{ 16272, 0},
{ 16283, 0},
{ 16294, 0},
{ 16304, 0},
{ 16314, 0},
{ 16323, 0},
{ 16331, 0},
{ 16339, 0},
{ 16346, 0},
{ 16352, 0},
{ 16358, 0},
{ 16363, 0},
{ 16368, 0},
{ 16372, 0},
{ 16375, 0},
{ 16378, 0},
{ 16380, 0},
{ 16382, 0},
{ 16383, 0},
{ 16383, 0},
{ 16383, 0},
{ 16382, 0},
{ 16380, 0},
{ 16378, 0},
{ 16375, 0},
{ 16372, 0},
{ 16368, 0},
{ 16363, 0},
{ 16358, 0},
{ 16352, 0},
{ 16346, 0},
{ 16339, 0},
{ 16331, 0},
{ 16323, 0},
{ 16314, 0},
{ 16304, 0},
{ 16294, 0},
{ 16283, 0},
{ 16272, 0},
{ 16260, 0},
{ 16247, 0},
{ 16234, 0},
{ 16220, 0},
{ 16206, 0},
{ 16191, 0},
{ 16175, 0},
{ 16159, 0},
{ 16142, 0},
{ 16124, 0},
{ 16106, 0},
{ 16088, 0},
{ 16068, 0},
{ 16048, 0},
{ 16028, 0},
{ 16007, 0},
{ 15985, 0},
{ 15963, 0},
{ 15940, 0},
{ 15916, 0},
{ 15892, 0},
{ 15867, 0},
{ 15842, 0},
{ 15816, 0},
{ 15790, 0},
{ 15762, 0},
{ 15735, 0},
{ 15706, 0},
{ 15678, 0},
{ 15648, 0},
{ 15618, 0},
{ 15587, 0},
{ 15556, 0},
{ 15524, 0},
{ 15492, 0},
{ 15459, 0},
{ 15425, 0},
{ 15391, 0},
{ 15356, 0},
{ 15321, 0},
{ 15285, 0},
{ 15249, 0},
{ 15212, 0},
{ 15174, 0},
{ 15136, 0},
{ 15097, 0},
{ 15058, 0},
{ 15018, 0},
{ 14977, 0},
{ 14936, 0},
{ 14895, 0},
{ 14853, 0},
{ 14810, 0},
{ 14767, 0},
{ 14723, 0},
{ 14679, 0},
{ 14634, 0},
{ 14588, 0},
{ 14542, 0},
{ 14496, 0},
{ 14449, 0},
{ 14401, 0},
{ 14353, 0},
{ 14304, 0},
{ 14255, 0},
{ 14205, 0},
{ 14154, 0},
{ 14104, 0},
{ 14052, 0},
{ 14000, 0},
{ 13948, 0},
{ 13895, 0},
{ 13841, 0},
{ 13787, 0},
{ 13733, 0},
{ 13678, 0},
{ 13622, 0},
{ 13566, 0},
{ 13509, 0},
{ 13452, 0},
{ 13394, 0},
{ 13336, 0},
{ 13278, 0},
{ 13219, 0},
{ 13159, 0},
{ 13099, 0},
{ 13038, 0},
{ 12977, 0},
{ 12915, 0},
{ 12853, 0},
{ 12791, 0},
{ 12728, 0},
{ 12664, 0},
{ 12600, 0},
{ 12536, 0},
{ 12471, 0},
{ 12405, 0},
{ 12339, 0},
{ 12273, 0},
{ 12206, 0},
{ 12139, 0},
{ 12071, 0},
{ 12003, 0},
{ 11934, 0},
{ 11865, 0},
{ 11796, 0},
{ 11726, 0},
{ 11655, 0},
{ 11585, 0},
{ 11513, 0},
{ 11441, 0},
{ 11369, 0},
{ 11297, 0},
{ 11224, 0},
{ 11150, 0},
{ 11076, 0},
{ 11002, 0},
{ 10927, 0},
{ 10852, 0},
{ 10777, 0},
{ 10701, 0},
{ 10625, 0},
{ 10548, 0},
{ 10471, 0},
{ 10393, 0},
{ 10315, 0},
{ 10237, 0},
{ 10158, 0},
{ 10079, 0},
{ 10000, 0},
{ 9920, 0},
{ 9840, 0},
{ 9759, 0},
{ 9678, 0},
{ 9597, 0},
{ 9515, 0},
{ 9433, 0},
{ 9351, 0},
{ 9268, 0},
{ 9185, 0},
{ 9102, 0},
{ 9018, 0},
{ 8934, 0},
{ 8850, 0},
{ 8765, 0},
{ 8680, 0},
{ 8594, 0},
{ 8509, 0},
{ 8423, 0},
{ 8336, 0},
{ 8249, 0},
{ 8162, 0},
{ 8075, 0},
{ 7988, 0},
{ 7900, 0},
{ 7811, 0},
{ 7723, 0},
{ 7634, 0},
{ 7545, 0},
{ 7456, 0},
{ 7366, 0},
{ 7276, 0},
{ 7186, 0},
{ 7095, 0},
{ 7005, 0},
{ 6914, 0},
{ 6822, 0},
{ 6731, 0},
{ 6639, 0},
{ 6547, 0},
{ 6455, 0},
{ 6362, 0},
{ 6270, 0},
{ 6177, 0},
{ 6083, 0},
{ 5990, 0},
{ 5896, 0},
{ 5802, 0},
{ 5708, 0},
{ 5614, 0},
{ 5519, 0},
{ 5425, 0},
{ 5330, 0},
{ 5234, 0},
{ 5139, 0},
{ 5044, 0},
{ 4948, 0},
{ 4852, 0},
{ 4756, 0},
{ 4659, 0},
{ 4563, 0},
{ 4466, 0},
{ 4370, 0},
{ 4273, 0},
{ 4175, 0},
{ 4078, 0},
{ 3981, 0},
{ 3883, 0},
{ 3785, 0},
{ 3688, 0},
{ 3590, 0},
{ 3491, 0},
{ 3393, 0},
{ 3295, 0},
{ 3196, 0},
{ 3098, 0},
{ 2999, 0},
{ 2900, 0},
{ 2801, 0},
{ 2702, 0},
{ 2603, 0},
{ 2503, 0},
{ 2404, 0},
{ 2304, 0},
{ 2205, 0},
{ 2105, 0},
{ 2005, 0},
{ 1906, 0},
{ 1806, 0},
{ 1706, 0},
{ 1606, 0},
{ 1506, 0},
{ 1406, 0},
{ 1305, 0},
{ 1205, 0},
{ 1105, 0},
{ 1005, 0},
{ 904, 0},
{ 804, 0},
{ 703, 0},
{ 603, 0},
{ 503, 0},
{ 402, 0},
{ 302, 0},
{ 201, 0},
{ 101, 0},
{ 0, 16383},
{ -101, 0},
{ -201, 0},
{ -302, 0},
{ -402, 0},
{ -503, 0},
{ -603, 0},
{ -703, 0},
{ -804, 0},
{ -904, 0},
{ -1005, 0},
{ -1105, 0},
{ -1205, 0},
{ -1305, 0},
{ -1406, 0},
{ -1506, 0},
{ -1606, 0},
{ -1706, 0},
{ -1806, 0},
{ -1906, 0},
{ -2005, 0},
{ -2105, 0},
{ -2205, 0},
{ -2304, 0},
{ -2404, 0},
{ -2503, 0},
{ -2603, 0},
{ -2702, 0},
{ -2801, 0},
{ -2900, 0},
{ -2999, 0},
{ -3098, 0},
{ -3196, 0},
{ -3295, 0},
{ -3393, 0},
{ -3491, 0},
{ -3590, 0},
{ -3688, 0},
{ -3785, 0},
{ -3883, 0},
{ -3981, 0},
{ -4078, 0},
{ -4175, 0},
{ -4273, 0},
{ -4370, 0},
{ -4466, 0},
{ -4563, 0},
{ -4659, 0},
{ -4756, 0},
{ -4852, 0},
{ -4948, 0},
{ -5044, 0},
{ -5139, 0},
{ -5234, 0},
{ -5330, 0},
{ -5425, 0},
{ -5519, 0},
{ -5614, 0},
{ -5708, 0},
{ -5802, 0},
{ -5896, 0},
{ -5990, 0},
{ -6083, 0},
{ -6177, 0},
{ -6270, 0},
{ -6362, 0},
{ -6455, 0},
{ -6547, 0},
{ -6639, 0},
{ -6731, 0},
{ -6822, 0},
{ -6914, 0},
{ -7005, 0},
{ -7095, 0},
{ -7186, 0},
{ -7276, 0},
{ -7366, 0},
{ -7456, 0},
{ -7545, 0},
{ -7634, 0},
{ -7723, 0},
{ -7811, 0},
{ -7900, 0},
{ -7988, 0},
{ -8075, 0},
{ -8162, 0},
{ -8249, 0},
{ -8336, 0},
{ -8423, 0},
{ -8509, 0},
{ -8594, 0},
{ -8680, 0},
{ -8765, 0},
{ -8850, 0},
{ -8934, 0},
{ -9018, 0},
{ -9102, 0},
{ -9185, 0},
{ -9268, 0},
{ -9351, 0},
{ -9433, 0},
{ -9515, 0},
{ -9597, 0},
{ -9678, 0},
{ -9759, 0},
{ -9840, 0},
{ -9920, 0},
{-10000, 0},
{-10079, 0},
{-10158, 0},
{-10237, 0},
{-10315, 0},
{-10393, 0},
{-10471, 0},
{-10548, 0},
{-10625, 0},
{-10701, 0},
{-10777, 0},
{-10852, 0},
{-10927, 0},
{-11002, 0},
{-11076, 0},
{-11150, 0},
{-11224, 0},
{-11297, 0},
{-11369, 0},
{-11441, 0},
{-11513, 0},
{-11585, 0},
{-11655, 0},
{-11726, 0},
{-11796, 0},
{-11865, 0},
{-11934, 0},
{-12003, 0},
{-12071, 0},
{-12139, 0},
{-12206, 0},
{-12273, 0},
{-12339, 0},
{-12405, 0},
{-12471, 0},
{-12536, 0},
{-12600, 0},
{-12664, 0},
{-12728, 0},
{-12791, 0},
{-12853, 0},
{-12915, 0},
{-12977, 0},
{-13038, 0},
{-13099, 0},
{-13159, 0},
{-13219, 0},
{-13278, 0},
{-13336, 0},
{-13394, 0},
{-13452, 0},
{-13509, 0},
{-13566, 0},
{-13622, 0},
{-13678, 0},
{-13733, 0},
{-13787, 0},
{-13841, 0},
{-13895, 0},
{-13948, 0},
{-14000, 0},
{-14052, 0},
{-14104, 0},
{-14154, 0},
{-14205, 0},
{-14255, 0},
{-14304, 0},
{-14353, 0},
{-14401, 0},
{-14449, 0},
{-14496, 0},
{-14542, 0},
{-14588, 0},
{-14634, 0},
{-14679, 0},
{-14723, 0},
{-14767, 0},
{-14810, 0},
{-14853, 0},
{-14895, 0},
{-14936, 0},
{-14977, 0},
{-15018, 0},
{-15058, 0},
{-15097, 0},
{-15136, 0},
{-15174, 0},
{-15212, 0},
{-15249, 0},
{-15285, 0},
{-15321, 0},
{-15356, 0},
{-15391, 0},
{-15425, 0},
{-15459, 0},
{-15492, 0},
{-15524, 0},
{-15556, 0},
{-15587, 0},
{-15618, 0},
{-15648, 0},
{-15678, 0},
{-15706, 0},
{-15735, 0},
{-15762, 0},
{-15790, 0},
{-15816, 0},
{-15842, 0},
{-15867, 0},
{-15892, 0},
{-15916, 0},
{-15940, 0},
{-15963, 0},
{-15985, 0},
{-16007, 0},
{-16028, 0},
{-16048, 0},
{-16068, 0},
{-16088, 0},
{-16106, 0},
{-16124, 0},
{-16142, 0},
{-16159, 0},
{-16175, 0},
{-16191, 0},
{-16206, 0},
{-16220, 0},
{-16234, 0},
{-16247, 0},
{-16260, 0},
{-16272, 0},
{-16283, 0},
{-16294, 0},
{-16304, 0},
{-16314, 0},
{-16323, 0},
{-16331, 0},
{-16339, 0},
{-16346, 0},
{-16352, 0},
{-16358, 0},
{-16363, 0},
{-16368, 0},
{-16372, 0},
{-16375, 0},
{-16378, 0},
{-16380, 0},
{-16382, 0},
{-16383, 0},
{-16383, 0},
{-16383, 0},
{-16382, 0},
{-16380, 0},
{-16378, 0},
{-16375, 0},
{-16372, 0},
{-16368, 0},
{-16363, 0},
{-16358, 0},
{-16352, 0},
{-16346, 0},
{-16339, 0},
{-16331, 0},
{-16323, 0},
{-16314, 0},
{-16304, 0},
{-16294, 0},
{-16283, 0},
{-16272, 0},
{-16260, 0},
{-16247, 0},
{-16234, 0},
{-16220, 0},
{-16206, 0},
{-16191, 0},
{-16175, 0},
{-16159, 0},
{-16142, 0},
{-16124, 0},
{-16106, 0},
{-16088, 0},
{-16068, 0},
{-16048, 0},
{-16028, 0},
{-16007, 0},
{-15985, 0},
{-15963, 0},
{-15940, 0},
{-15916, 0},
{-15892, 0},
{-15867, 0},
{-15842, 0},
{-15816, 0},
{-15790, 0},
{-15762, 0},
{-15735, 0},
{-15706, 0},
{-15678, 0},
{-15648, 0},
{-15618, 0},
{-15587, 0},
{-15556, 0},
{-15524, 0},
{-15492, 0},
{-15459, 0},
{-15425, 0},
{-15391, 0},
{-15356, 0},
{-15321, 0},
{-15285, 0},
{-15249, 0},
{-15212, 0},
{-15174, 0},
{-15136, 0},
{-15097, 0},
{-15058, 0},
{-15018, 0},
{-14977, 0},
{-14936, 0},
{-14895, 0},
{-14853, 0},
{-14810, 0},
{-14767, 0},
{-14723, 0},
{-14679, 0},
{-14634, 0},
{-14588, 0},
{-14542, 0},
{-14496, 0},
{-14449, 0},
{-14401, 0},
{-14353, 0},
{-14304, 0},
{-14255, 0},
{-14205, 0},
{-14154, 0},
{-14104, 0},
{-14052, 0},
{-14000, 0},
{-13948, 0},
{-13895, 0},
{-13841, 0},
{-13787, 0},
{-13733, 0},
{-13678, 0},
{-13622, 0},
{-13566, 0},
{-13509, 0},
{-13452, 0},
{-13394, 0},
{-13336, 0},
{-13278, 0},
{-13219, 0},
{-13159, 0},
{-13099, 0},
{-13038, 0},
{-12977, 0},
{-12915, 0},
{-12853, 0},
{-12791, 0},
{-12728, 0},
{-12664, 0},
{-12600, 0},
{-12536, 0},
{-12471, 0},
{-12405, 0},
{-12339, 0},
{-12273, 0},
{-12206, 0},
{-12139, 0},
{-12071, 0},
{-12003, 0},
{-11934, 0},
{-11865, 0},
{-11796, 0},
{-11726, 0},
{-11655, 0},
{-11585, 0},
{-11513, 0},
{-11441, 0},
{-11369, 0},
{-11297, 0},
{-11224, 0},
{-11150, 0},
{-11076, 0},
{-11002, 0},
{-10927, 0},
{-10852, 0},
{-10777, 0},
{-10701, 0},
{-10625, 0},
{-10548, 0},
{-10471, 0},
{-10393, 0},
{-10315, 0},
{-10237, 0},
{-10158, 0},
{-10079, 0},
{-10000, 0},
{ -9920, 0},
{ -9840, 0},
{ -9759, 0},
{ -9678, 0},
{ -9597, 0},
{ -9515, 0},
{ -9433, 0},
{ -9351, 0},
{ -9268, 0},
{ -9185, 0},
{ -9102, 0},
{ -9018, 0},
{ -8934, 0},
{ -8850, 0},
{ -8765, 0},
{ -8680, 0},
{ -8594, 0},
{ -8509, 0},
{ -8423, 0},
{ -8336, 0},
{ -8249, 0},
{ -8162, 0},
{ -8075, 0},
{ -7988, 0},
{ -7900, 0},
{ -7811, 0},
{ -7723, 0},
{ -7634, 0},
{ -7545, 0},
{ -7456, 0},
{ -7366, 0},
{ -7276, 0},
{ -7186, 0},
{ -7095, 0},
{ -7005, 0},
{ -6914, 0},
{ -6822, 0},
{ -6731, 0},
{ -6639, 0},
{ -6547, 0},
{ -6455, 0},
{ -6362, 0},
{ -6270, 0},
{ -6177, 0},
{ -6083, 0},
{ -5990, 0},
{ -5896, 0},
{ -5802, 0},
{ -5708, 0},
{ -5614, 0},
{ -5519, 0},
{ -5425, 0},
{ -5330, 0},
{ -5234, 0},
{ -5139, 0},
{ -5044, 0},
{ -4948, 0},
{ -4852, 0},
{ -4756, 0},
{ -4659, 0},
{ -4563, 0},
{ -4466, 0},
{ -4370, 0},
{ -4273, 0},
{ -4175, 0},
{ -4078, 0},
{ -3981, 0},
{ -3883, 0},
{ -3785, 0},
{ -3688, 0},
{ -3590, 0},
{ -3491, 0},
{ -3393, 0},
{ -3295, 0},
{ -3196, 0},
{ -3098, 0},
{ -2999, 0},
{ -2900, 0},
{ -2801, 0},
{ -2702, 0},
{ -2603, 0},
{ -2503, 0},
{ -2404, 0},
{ -2304, 0},
{ -2205, 0},
{ -2105, 0},
{ -2005, 0},
{ -1906, 0},
{ -1806, 0},
{ -1706, 0},
{ -1606, 0},
{ -1506, 0},
{ -1406, 0},
{ -1305, 0},
{ -1205, 0},
{ -1105, 0},
{ -1005, 0},
{ -904, 0},
{ -804, 0},
{ -703, 0},
{ -603, 0},
{ -503, 0},
{ -402, 0},
{ -302, 0},
{ -201, 0},
{ -101, 0},
{ 0, 16383},
{ 101, 0},
{ 201, 0},
{ 302, 0},
{ 402, 0},
{ 503, 0},
{ 603, 0},
{ 703, 0},
{ 804, 0},
{ 904, 0},
{ 1005, 0},
{ 1105, 0},
{ 1205, 0},
{ 1305, 0},
{ 1406, 0},
{ 1506, 0},
{ 1606, 0},
{ 1706, 0},
{ 1806, 0},
{ 1906, 0},
{ 2005, 0},
{ 2105, 0},
{ 2205, 0},
{ 2304, 0},
{ 2404, 0},
{ 2503, 0},
{ 2603, 0},
{ 2702, 0},
{ 2801, 0},
{ 2900, 0},
{ 2999, 0},
{ 3098, 0},
{ 3196, 0},
{ 3295, 0},
{ 3393, 0},
{ 3491, 0},
{ 3590, 0},
{ 3688, 0},
{ 3785, 0},
{ 3883, 0},
{ 3981, 0},
{ 4078, 0},
{ 4175, 0},
{ 4273, 0},
{ 4370, 0},
{ 4466, 0},
{ 4563, 0},
{ 4659, 0},
{ 4756, 0},
{ 4852, 0},
{ 4948, 0},
{ 5044, 0},
{ 5139, 0},
{ 5234, 0},
{ 5330, 0},
{ 5425, 0},
{ 5519, 0},
{ 5614, 0},
{ 5708, 0},
{ 5802, 0},
{ 5896, 0},
{ 5990, 0},
{ 6083, 0},
{ 6177, 0},
{ 6270, 0},
{ 6362, 0},
{ 6455, 0},
{ 6547, 0},
{ 6639, 0},
{ 6731, 0},
{ 6822, 0},
{ 6914, 0},
{ 7005, 0},
{ 7095, 0},
{ 7186, 0},
{ 7276, 0},
{ 7366, 0},
{ 7456, 0},
{ 7545, 0},
{ 7634, 0},
{ 7723, 0},
{ 7811, 0},
{ 7900, 0},
{ 7988, 0},
{ 8075, 0},
{ 8162, 0},
{ 8249, 0},
{ 8336, 0},
{ 8423, 0},
{ 8509, 0},
{ 8594, 0},
{ 8680, 0},
{ 8765, 0},
{ 8850, 0},
{ 8934, 0},
{ 9018, 0},
{ 9102, 0},
{ 9185, 0},
{ 9268, 0},
{ 9351, 0},
{ 9433, 0},
{ 9515, 0},
{ 9597, 0},
{ 9678, 0},
{ 9759, 0},
{ 9840, 0},
{ 9920, 0},
{ 10000, 0},
{ 10079, 0},
{ 10158, 0},
{ 10237, 0},
{ 10315, 0},
{ 10393, 0},
{ 10471, 0},
{ 10548, 0},
{ 10625, 0},
{ 10701, 0},
{ 10777, 0},
{ 10852, 0},
{ 10927, 0},
{ 11002, 0},
{ 11076, 0},
{ 11150, 0},
{ 11224, 0},
{ 11297, 0},
{ 11369, 0},
{ 11441, 0},
{ 11513, 0},
{ 11585, 0},
{ 11655, 0},
{ 11726, 0},
{ 11796, 0},
{ 11865, 0},
{ 11934, 0},
{ 12003, 0},
{ 12071, 0},
{ 12139, 0},
{ 12206, 0},
{ 12273, 0},
{ 12339, 0},
{ 12405, 0},
{ 12471, 0},
{ 12536, 0},
{ 12600, 0},
{ 12664, 0},
{ 12728, 0},
{ 12791, 0},
{ 12853, 0},
{ 12915, 0},
{ 12977, 0},
{ 13038, 0},
{ 13099, 0},
{ 13159, 0},
{ 13219, 0},
{ 13278, 0},
{ 13336, 0},
{ 13394, 0},
{ 13452, 0},
{ 13509, 0},
{ 13566, 0},
{ 13622, 0},
{ 13678, 0},
{ 13733, 0},
{ 13787, 0},
{ 13841, 0},
{ 13895, 0},
{ 13948, 0},
{ 14000, 0},
{ 14052, 0},
{ 14104, 0},
{ 14154, 0},
{ 14205, 0},
{ 14255, 0},
{ 14304, 0},
{ 14353, 0},
{ 14401, 0},
{ 14449, 0},
{ 14496, 0},
{ 14542, 0},
{ 14588, 0},
{ 14634, 0},
{ 14679, 0},
{ 14723, 0},
{ 14767, 0},
{ 14810, 0},
{ 14853, 0},
{ 14895, 0},
{ 14936, 0},
{ 14977, 0},
{ 15018, 0},
{ 15058, 0},
{ 15097, 0},
{ 15136, 0},
{ 15174, 0},
{ 15212, 0},
{ 15249, 0},
{ 15285, 0},
{ 15321, 0},
{ 15356, 0},
{ 15391, 0},
{ 15425, 0},
{ 15459, 0},
{ 15492, 0},
{ 15524, 0},
{ 15556, 0},
{ 15587, 0},
{ 15618, 0},
{ 15648, 0},
{ 15678, 0},
{ 15706, 0},
{ 15735, 0},
{ 15762, 0},
{ 15790, 0},
{ 15816, 0},
{ 15842, 0},
{ 15867, 0},
{ 15892, 0},
{ 15916, 0},
{ 15940, 0},
{ 15963, 0},
{ 15985, 0},
{ 16007, 0},
{ 16028, 0},
{ 16048, 0},
{ 16068, 0},
{ 16088, 0},
{ 16106, 0},
{ 16124, 0},
{ 16142, 0},
{ 16159, 0},
{ 16175, 0},
{ 16191, 0},
{ 16206, 0},
{ 16220, 0},
{ 16234, 0},
{ 16247, 0},
{ 16260, 0},
{ 16272, 0},
{ 16283, 0},
{ 16294, 0},
{ 16304, 0},
{ 16314, 0},
{ 16323, 0},
{ 16331, 0},
{ 16339, 0},
{ 16346, 0},
{ 16352, 0},
{ 16358, 0},
{ 16363, 0},
{ 16368, 0},
{ 16372, 0},
{ 16375, 0},
{ 16378, 0},
{ 16380, 0},
{ 16382, 0},
{ 16383, 0},
{ 16383, 0},
{ 16383, 0},
{ 16382, 0},
{ 16380, 0},
{ 16378, 0},
{ 16375, 0},
{ 16372, 0},
{ 16368, 0},
{ 16363, 0},
{ 16358, 0},
{ 16352, 0},
{ 16346, 0},
{ 16339, 0},
{ 16331, 0},
{ 16323, 0},
{ 16314, 0},
{ 16304, 0},
{ 16294, 0},
{ 16283, 0},
{ 16272, 0},
{ 16260, 0},
{ 16247, 0},
{ 16234, 0},
{ 16220, 0},
{ 16206, 0},
{ 16191, 0},
{ 16175, 0},
{ 16159, 0},
{ 16142, 0},
{ 16124, 0},
{ 16106, 0},
{ 16088, 0},
{ 16068, 0},
{ 16048, 0},
{ 16028, 0},
{ 16007, 0},
{ 15985, 0},
{ 15963, 0},
{ 15940, 0},
{ 15916, 0},
{ 15892, 0},
{ 15867, 0},
{ 15842, 0},
{ 15816, 0},
{ 15790, 0},
{ 15762, 0},
{ 15735, 0},
{ 15706, 0},
{ 15678, 0},
{ 15648, 0},
{ 15618, 0},
{ 15587, 0},
{ 15556, 0},
{ 15524, 0},
{ 15492, 0},
{ 15459, 0},
{ 15425, 0},
{ 15391, 0},
{ 15356, 0},
{ 15321, 0},
{ 15285, 0},
{ 15249, 0},
{ 15212, 0},
{ 15174, 0},
{ 15136, 0},
{ 15097, 0},
{ 15058, 0},
{ 15018, 0},
{ 14977, 0},
{ 14936, 0},
{ 14895, 0},
{ 14853, 0},
{ 14810, 0},
{ 14767, 0},
{ 14723, 0},
{ 14679, 0},
{ 14634, 0},
{ 14588, 0},
{ 14542, 0},
{ 14496, 0},
{ 14449, 0},
{ 14401, 0},
{ 14353, 0},
{ 14304, 0},
{ 14255, 0},
{ 14205, 0},
{ 14154, 0},
{ 14104, 0},
{ 14052, 0},
{ 14000, 0},
{ 13948, 0},
{ 13895, 0},
{ 13841, 0},
{ 13787, 0},
{ 13733, 0},
{ 13678, 0},
{ 13622, 0},
{ 13566, 0},
{ 13509, 0},
{ 13452, 0},
{ 13394, 0},
{ 13336, 0},
{ 13278, 0},
{ 13219, 0},
{ 13159, 0},
{ 13099, 0},
{ 13038, 0},
{ 12977, 0},
{ 12915, 0},
{ 12853, 0},
{ 12791, 0},
{ 12728, 0},
{ 12664, 0},
{ 12600, 0},
{ 12536, 0},
{ 12471, 0},
{ 12405, 0},
{ 12339, 0},
{ 12273, 0},
{ 12206, 0},
{ 12139, 0},
{ 12071, 0},
{ 12003, 0},
{ 11934, 0},
{ 11865, 0},
{ 11796, 0},
{ 11726, 0},
{ 11655, 0},
{ 11585, 0},
{ 11513, 0},
{ 11441, 0},
{ 11369, 0},
{ 11297, 0},
{ 11224, 0},
{ 11150, 0},
{ 11076, 0},
{ 11002, 0},
{ 10927, 0},
{ 10852, 0},
{ 10777, 0},
{ 10701, 0},
{ 10625, 0},
{ 10548, 0},
{ 10471, 0},
{ 10393, 0},
{ 10315, 0},
{ 10237, 0},
{ 10158, 0},
{ 10079, 0},
{ 10000, 0},
{ 9920, 0},
{ 9840, 0},
{ 9759, 0},
{ 9678, 0},
{ 9597, 0},
{ 9515, 0},
{ 9433, 0},
{ 9351, 0},
{ 9268, 0},
{ 9185, 0},
{ 9102, 0},
{ 9018, 0},
{ 8934, 0},
{ 8850, 0},
{ 8765, 0},
{ 8680, 0},
{ 8594, 0},
{ 8509, 0},
{ 8423, 0},
{ 8336, 0},
{ 8249, 0},
{ 8162, 0},
{ 8075, 0},
{ 7988, 0},
{ 7900, 0},
{ 7811, 0},
{ 7723, 0},
{ 7634, 0},
{ 7545, 0},
{ 7456, 0},
{ 7366, 0},
{ 7276, 0},
{ 7186, 0},
{ 7095, 0},
{ 7005, 0},
{ 6914, 0},
{ 6822, 0},
{ 6731, 0},
{ 6639, 0},
{ 6547, 0},
{ 6455, 0},
{ 6362, 0},
{ 6270, 0},
{ 6177, 0},
{ 6083, 0},
{ 5990, 0},
{ 5896, 0},
{ 5802, 0},
{ 5708, 0},
{ 5614, 0},
{ 5519, 0},
{ 5425, 0},
{ 5330, 0},
{ 5234, 0},
{ 5139, 0},
{ 5044, 0},
{ 4948, 0},
{ 4852, 0},
{ 4756, 0},
{ 4659, 0},
{ 4563, 0},
{ 4466, 0},
{ 4370, 0},
{ 4273, 0},
{ 4175, 0},
{ 4078, 0},
{ 3981, 0},
{ 3883, 0},
{ 3785, 0},
{ 3688, 0},
{ 3590, 0},
{ 3491, 0},
{ 3393, 0},
{ 3295, 0},
{ 3196, 0},
{ 3098, 0},
{ 2999, 0},
{ 2900, 0},
{ 2801, 0},
{ 2702, 0},
{ 2603, 0},
{ 2503, 0},
{ 2404, 0},
{ 2304, 0},
{ 2205, 0},
{ 2105, 0},
{ 2005, 0},
{ 1906, 0},
{ 1806, 0},
{ 1706, 0},
{ 1606, 0},
{ 1506, 0},
{ 1406, 0},
{ 1305, 0},
{ 1205, 0},
{ 1105, 0},
{ 1005, 0},
{ 904, 0},
{ 804, 0},
{ 703, 0},
{ 603, 0},
{ 503, 0},
{ 402, 0},
{ 302, 0},
{ 201, 0},
{ 101, 0},
{ 0, 16383},
{ -101, 0},
{ -201, 0},
{ -302, 0},
{ -402, 0},
{ -503, 0},
{ -603, 0},
{ -703, 0},
{ -804, 0},
{ -904, 0},
{ -1005, 0},
{ -1105, 0},
{ -1205, 0},
{ -1305, 0},
{ -1406, 0},
{ -1506, 0},
{ -1606, 0},
{ -1706, 0},
{ -1806, 0},
{ -1906, 0},
{ -2005, 0},
{ -2105, 0},
{ -2205, 0},
{ -2304, 0},
{ -2404, 0},
{ -2503, 0},
{ -2603, 0},
{ -2702, 0},
{ -2801, 0},
{ -2900, 0},
{ -2999, 0},
{ -3098, 0},
{ -3196, 0},
{ -3295, 0},
{ -3393, 0},
{ -3491, 0},
{ -3590, 0},
{ -3688, 0},
{ -3785, 0},
{ -3883, 0},
{ -3981, 0},
{ -4078, 0},
{ -4175, 0},
{ -4273, 0},
{ -4370, 0},
{ -4466, 0},
{ -4563, 0},
{ -4659, 0},
{ -4756, 0},
{ -4852, 0},
{ -4948, 0},
{ -5044, 0},
{ -5139, 0},
{ -5234, 0},
{ -5330, 0},
{ -5425, 0},
{ -5519, 0},
{ -5614, 0},
{ -5708, 0},
{ -5802, 0},
{ -5896, 0},
{ -5990, 0},
{ -6083, 0},
{ -6177, 0},
{ -6270, 0},
{ -6362, 0},
{ -6455, 0},
{ -6547, 0},
{ -6639, 0},
{ -6731, 0},
{ -6822, 0},
{ -6914, 0},
{ -7005, 0},
{ -7095, 0},
{ -7186, 0},
{ -7276, 0},
{ -7366, 0},
{ -7456, 0},
{ -7545, 0},
{ -7634, 0},
{ -7723, 0},
{ -7811, 0},
{ -7900, 0},
{ -7988, 0},
{ -8075, 0},
{ -8162, 0},
{ -8249, 0},
{ -8336, 0},
{ -8423, 0},
{ -8509, 0},
{ -8594, 0},
{ -8680, 0},
{ -8765, 0},
{ -8850, 0},
{ -8934, 0},
{ -9018, 0},
{ -9102, 0},
{ -9185, 0},
{ -9268, 0},
{ -9351, 0},
{ -9433, 0},
{ -9515, 0},
{ -9597, 0},
{ -9678, 0},
{ -9759, 0},
{ -9840, 0},
{ -9920, 0},
{-10000, 0},
{-10079, 0},
{-10158, 0},
{-10237, 0},
{-10315, 0},
{-10393, 0},
{-10471, 0},
{-10548, 0},
{-10625, 0},
{-10701, 0},
{-10777, 0},
{-10852, 0},
{-10927, 0},
{-11002, 0},
{-11076, 0},
{-11150, 0},
{-11224, 0},
{-11297, 0},
{-11369, 0},
{-11441, 0},
{-11513, 0},
{-11585, 0},
{-11655, 0},
{-11726, 0},
{-11796, 0},
{-11865, 0},
{-11934, 0},
{-12003, 0},
{-12071, 0},
{-12139, 0},
{-12206, 0},
{-12273, 0},
{-12339, 0},
{-12405, 0},
{-12471, 0},
{-12536, 0},
{-12600, 0},
{-12664, 0},
{-12728, 0},
{-12791, 0},
{-12853, 0},
{-12915, 0},
{-12977, 0},
{-13038, 0},
{-13099, 0},
{-13159, 0},
{-13219, 0},
{-13278, 0},
{-13336, 0},
{-13394, 0},
{-13452, 0},
{-13509, 0},
{-13566, 0},
{-13622, 0},
{-13678, 0},
{-13733, 0},
{-13787, 0},
{-13841, 0},
{-13895, 0},
{-13948, 0},
{-14000, 0},
{-14052, 0},
{-14104, 0},
{-14154, 0},
{-14205, 0},
{-14255, 0},
{-14304, 0},
{-14353, 0},
{-14401, 0},
{-14449, 0},
{-14496, 0},
{-14542, 0},
{-14588, 0},
{-14634, 0},
{-14679, 0},
{-14723, 0},
{-14767, 0},
{-14810, 0},
{-14853, 0},
{-14895, 0},
{-14936, 0},
{-14977, 0},
{-15018, 0},
{-15058, 0},
{-15097, 0},
{-15136, 0},
{-15174, 0},
{-15212, 0},
{-15249, 0},
{-15285, 0},
{-15321, 0},
{-15356, 0},
{-15391, 0},
{-15425, 0},
{-15459, 0},
{-15492, 0},
{-15524, 0},
{-15556, 0},
{-15587, 0},
{-15618, 0},
{-15648, 0},
{-15678, 0},
{-15706, 0},
{-15735, 0},
{-15762, 0},
{-15790, 0},
{-15816, 0},
{-15842, 0},
{-15867, 0},
{-15892, 0},
{-15916, 0},
{-15940, 0},
{-15963, 0},
{-15985, 0},
{-16007, 0},
{-16028, 0},
{-16048, 0},
{-16068, 0},
{-16088, 0},
{-16106, 0},
{-16124, 0},
{-16142, 0},
{-16159, 0},
{-16175, 0},
{-16191, 0},
{-16206, 0},
{-16220, 0},
{-16234, 0},
{-16247, 0},
{-16260, 0},
{-16272, 0},
{-16283, 0},
{-16294, 0},
{-16304, 0},
{-16314, 0},
{-16323, 0},
{-16331, 0},
{-16339, 0},
{-16346, 0},
{-16352, 0},
{-16358, 0},
{-16363, 0},
{-16368, 0},
{-16372, 0},
{-16375, 0},
{-16378, 0},
{-16380, 0},
{-16382, 0},
{-16383, 0},
{-16383, 0},
{-16383, 0},
{-16382, 0},
{-16380, 0},
{-16378, 0},
{-16375, 0},
{-16372, 0},
{-16368, 0},
{-16363, 0},
{-16358, 0},
{-16352, 0},
{-16346, 0},
{-16339, 0},
{-16331, 0},
{-16323, 0},
{-16314, 0},
{-16304, 0},
{-16294, 0},
{-16283, 0},
{-16272, 0},
{-16260, 0},
{-16247, 0},
{-16234, 0},
{-16220, 0},
{-16206, 0},
{-16191, 0},
{-16175, 0},
{-16159, 0},
{-16142, 0},
{-16124, 0},
{-16106, 0},
{-16088, 0},
{-16068, 0},
{-16048, 0},
{-16028, 0},
{-16007, 0},
{-15985, 0},
{-15963, 0},
{-15940, 0},
{-15916, 0},
{-15892, 0},
{-15867, 0},
{-15842, 0},
{-15816, 0},
{-15790, 0},
{-15762, 0},
{-15735, 0},
{-15706, 0},
{-15678, 0},
{-15648, 0},
{-15618, 0},
{-15587, 0},
{-15556, 0},
{-15524, 0},
{-15492, 0},
{-15459, 0},
{-15425, 0},
{-15391, 0},
{-15356, 0},
{-15321, 0},
{-15285, 0},
{-15249, 0},
{-15212, 0},
{-15174, 0},
{-15136, 0},
{-15097, 0},
{-15058, 0},
{-15018, 0},
{-14977, 0},
{-14936, 0},
{-14895, 0},
{-14853, 0},
{-14810, 0},
{-14767, 0},
{-14723, 0},
{-14679, 0},
{-14634, 0},
{-14588, 0},
{-14542, 0},
{-14496, 0},
{-14449, 0},
{-14401, 0},
{-14353, 0},
{-14304, 0},
{-14255, 0},
{-14205, 0},
{-14154, 0},
{-14104, 0},
{-14052, 0},
{-14000, 0},
{-13948, 0},
{-13895, 0},
{-13841, 0},
{-13787, 0},
{-13733, 0},
{-13678, 0},
{-13622, 0},
{-13566, 0},
{-13509, 0},
{-13452, 0},
{-13394, 0},
{-13336, 0},
{-13278, 0},
{-13219, 0},
{-13159, 0},
{-13099, 0},
{-13038, 0},
{-12977, 0},
{-12915, 0},
{-12853, 0},
{-12791, 0},
{-12728, 0},
{-12664, 0},
{-12600, 0},
{-12536, 0},
{-12471, 0},
{-12405, 0},
{-12339, 0},
{-12273, 0},
{-12206, 0},
{-12139, 0},
{-12071, 0},
{-12003, 0},
{-11934, 0},
{-11865, 0},
{-11796, 0},
{-11726, 0},
{-11655, 0},
{-11585, 0},
{-11513, 0},
{-11441, 0},
{-11369, 0},
{-11297, 0},
{-11224, 0},
{-11150, 0},
{-11076, 0},
{-11002, 0},
{-10927, 0},
{-10852, 0},
{-10777, 0},
{-10701, 0},
{-10625, 0},
{-10548, 0},
{-10471, 0},
{-10393, 0},
{-10315, 0},
{-10237, 0},
{-10158, 0},
{-10079, 0},
{-10000, 0},
{ -9920, 0},
{ -9840, 0},
{ -9759, 0},
{ -9678, 0},
{ -9597, 0},
{ -9515, 0},
{ -9433, 0},
{ -9351, 0},
{ -9268, 0},
{ -9185, 0},
{ -9102, 0},
{ -9018, 0},
{ -8934, 0},
{ -8850, 0},
{ -8765, 0},
{ -8680, 0},
{ -8594, 0},
{ -8509, 0},
{ -8423, 0},
{ -8336, 0},
{ -8249, 0},
{ -8162, 0},
{ -8075, 0},
{ -7988, 0},
{ -7900, 0},
{ -7811, 0},
{ -7723, 0},
{ -7634, 0},
{ -7545, 0},
{ -7456, 0},
{ -7366, 0},
{ -7276, 0},
{ -7186, 0},
{ -7095, 0},
{ -7005, 0},
{ -6914, 0},
{ -6822, 0},
{ -6731, 0},
{ -6639, 0},
{ -6547, 0},
{ -6455, 0},
{ -6362, 0},
{ -6270, 0},
{ -6177, 0},
{ -6083, 0},
{ -5990, 0},
{ -5896, 0},
{ -5802, 0},
{ -5708, 0},
{ -5614, 0},
{ -5519, 0},
{ -5425, 0},
{ -5330, 0},
{ -5234, 0},
{ -5139, 0},
{ -5044, 0},
{ -4948, 0},
{ -4852, 0},
{ -4756, 0},
{ -4659, 0},
{ -4563, 0},
{ -4466, 0},
{ -4370, 0},
{ -4273, 0},
{ -4175, 0},
{ -4078, 0},
{ -3981, 0},
{ -3883, 0},
{ -3785, 0},
{ -3688, 0},
{ -3590, 0},
{ -3491, 0},
{ -3393, 0},
{ -3295, 0},
{ -3196, 0},
{ -3098, 0},
{ -2999, 0},
{ -2900, 0},
{ -2801, 0},
{ -2702, 0},
{ -2603, 0},
{ -2503, 0},
{ -2404, 0},
{ -2304, 0},
{ -2205, 0},
{ -2105, 0},
{ -2005, 0},
{ -1906, 0},
{ -1806, 0},
{ -1706, 0},
{ -1606, 0},
{ -1506, 0},
{ -1406, 0},
{ -1305, 0},
{ -1205, 0},
{ -1105, 0},
{ -1005, 0},
{ -904, 0},
{ -804, 0},
{ -703, 0},
{ -603, 0},
{ -503, 0},
{ -402, 0},
{ -302, 0},
{ -201, 0},
{ -101, 0},
{ 0, 16383},
{ 101, 0},
{ 201, 0},
{ 302, 0},
{ 402, 0},
{ 503, 0},
{ 603, 0},
{ 703, 0},
{ 804, 0},
{ 904, 0},
{ 1005, 0},
{ 1105, 0},
{ 1205, 0},
{ 1305, 0},
{ 1406, 0},
{ 1506, 0},
{ 1606, 0},
{ 1706, 0},
{ 1806, 0},
{ 1906, 0},
{ 2005, 0},
{ 2105, 0},
{ 2205, 0},
{ 2304, 0},
{ 2404, 0},
{ 2503, 0},
{ 2603, 0},
{ 2702, 0},
{ 2801, 0},
{ 2900, 0},
{ 2999, 0},
{ 3098, 0},
{ 3196, 0},
{ 3295, 0},
{ 3393, 0},
{ 3491, 0},
{ 3590, 0},
{ 3688, 0},
{ 3785, 0},
{ 3883, 0},
{ 3981, 0},
{ 4078, 0},
{ 4175, 0},
{ 4273, 0},
{ 4370, 0},
{ 4466, 0},
{ 4563, 0},
{ 4659, 0},
{ 4756, 0},
{ 4852, 0},
{ 4948, 0},
{ 5044, 0},
{ 5139, 0},
{ 5234, 0},
{ 5330, 0},
{ 5425, 0},
{ 5519, 0},
{ 5614, 0},
{ 5708, 0},
{ 5802, 0},
{ 5896, 0},
{ 5990, 0},
{ 6083, 0},
{ 6177, 0},
{ 6270, 0},
{ 6362, 0},
{ 6455, 0},
{ 6547, 0},
{ 6639, 0},
{ 6731, 0},
{ 6822, 0},
{ 6914, 0},
{ 7005, 0},
{ 7095, 0},
{ 7186, 0},
{ 7276, 0},
{ 7366, 0},
{ 7456, 0},
{ 7545, 0},
{ 7634, 0},
{ 7723, 0},
{ 7811, 0},
{ 7900, 0},
{ 7988, 0},
{ 8075, 0},
{ 8162, 0},
{ 8249, 0},
{ 8336, 0},
{ 8423, 0},
{ 8509, 0},
{ 8594, 0},
{ 8680, 0},
{ 8765, 0},
{ 8850, 0},
{ 8934, 0},
{ 9018, 0},
{ 9102, 0},
{ 9185, 0},
{ 9268, 0},
{ 9351, 0},
{ 9433, 0},
{ 9515, 0},
{ 9597, 0},
{ 9678, 0},
{ 9759, 0},
{ 9840, 0},
{ 9920, 0},
{ 10000, 0},
{ 10079, 0},
{ 10158, 0},
{ 10237, 0},
{ 10315, 0},
{ 10393, 0},
{ 10471, 0},
{ 10548, 0},
{ 10625, 0},
{ 10701, 0},
{ 10777, 0},
{ 10852, 0},
{ 10927, 0},
{ 11002, 0},
{ 11076, 0},
{ 11150, 0},
{ 11224, 0},
{ 11297, 0},
{ 11369, 0},
{ 11441, 0},
{ 11513, 0},
{ 11585, 0},
{ 11655, 0},
{ 11726, 0},
{ 11796, 0},
{ 11865, 0},
{ 11934, 0},
{ 12003, 0},
{ 12071, 0},
{ 12139, 0},
{ 12206, 0},
{ 12273, 0},
{ 12339, 0},
{ 12405, 0},
{ 12471, 0},
{ 12536, 0},
{ 12600, 0},
{ 12664, 0},
{ 12728, 0},
{ 12791, 0},
{ 12853, 0},
{ 12915, 0},
{ 12977, 0},
{ 13038, 0},
{ 13099, 0},
{ 13159, 0},
{ 13219, 0},
{ 13278, 0},
{ 13336, 0},
{ 13394, 0},
{ 13452, 0},
{ 13509, 0},
{ 13566, 0},
{ 13622, 0},
{ 13678, 0},
{ 13733, 0},
{ 13787, 0},
{ 13841, 0},
{ 13895, 0},
{ 13948, 0},
{ 14000, 0},
{ 14052, 0},
{ 14104, 0},
{ 14154, 0},
{ 14205, 0},
{ 14255, 0},
{ 14304, 0},
{ 14353, 0},
{ 14401, 0},
{ 14449, 0},
{ 14496, 0},
{ 14542, 0},
{ 14588, 0},
{ 14634, 0},
{ 14679, 0},
{ 14723, 0},
{ 14767, 0},
{ 14810, 0},
{ 14853, 0},
{ 14895, 0},
{ 14936, 0},
{ 14977, 0},
{ 15018, 0},
{ 15058, 0},
{ 15097, 0},
{ 15136, 0},
{ 15174, 0},
{ 15212, 0},
{ 15249, 0},
{ 15285, 0},
{ 15321, 0},
{ 15356, 0},
{ 15391, 0},
{ 15425, 0},
{ 15459, 0},
{ 15492, 0},
{ 15524, 0},
{ 15556, 0},
{ 15587, 0},
{ 15618, 0},
{ 15648, 0},
{ 15678, 0},
{ 15706, 0},
{ 15735, 0},
{ 15762, 0},
{ 15790, 0},
{ 15816, 0},
{ 15842, 0},
{ 15867, 0},
{ 15892, 0},
{ 15916, 0},
{ 15940, 0},
{ 15963, 0},
{ 15985, 0},
{ 16007, 0},
{ 16028, 0},
{ 16048, 0},
{ 16068, 0},
{ 16088, 0},
{ 16106, 0},
{ 16124, 0},
{ 16142, 0},
{ 16159, 0},
{ 16175, 0},
{ 16191, 0},
{ 16206, 0},
{ 16220, 0},
{ 16234, 0},
{ 16247, 0},
{ 16260, 0},
{ 16272, 0},
{ 16283, 0},
{ 16294, 0},
{ 16304, 0},
{ 16314, 0},
{ 16323, 0},
{ 16331, 0},
{ 16339, 0},
{ 16346, 0},
{ 16352, 0},
{ 16358, 0},
{ 16363, 0},
{ 16368, 0},
{ 16372, 0},
{ 16375, 0},
{ 16378, 0},
{ 16380, 0},
{ 16382, 0},
{ 16383, 0},
{ 16383, 0},
{ 16383, 0},
{ 16382, 0},
{ 16380, 0},
{ 16378, 0},
{ 16375, 0},
{ 16372, 0},
{ 16368, 0},
{ 16363, 0},
{ 16358, 0},
{ 16352, 0},
{ 16346, 0},
{ 16339, 0},
{ 16331, 0},
{ 16323, 0},
{ 16314, 0},
{ 16304, 0},
{ 16294, 0},
{ 16283, 0},
{ 16272, 0},
{ 16260, 0},
{ 16247, 0},
{ 16234, 0},
{ 16220, 0},
{ 16206, 0},
{ 16191, 0},
{ 16175, 0},
{ 16159, 0},
{ 16142, 0},
{ 16124, 0},
{ 16106, 0},
{ 16088, 0},
{ 16068, 0},
{ 16048, 0},
{ 16028, 0},
{ 16007, 0},
{ 15985, 0},
{ 15963, 0},
{ 15940, 0},
{ 15916, 0},
{ 15892, 0},
{ 15867, 0},
{ 15842, 0},
{ 15816, 0},
{ 15790, 0},
{ 15762, 0},
{ 15735, 0},
{ 15706, 0},
{ 15678, 0},
{ 15648, 0},
{ 15618, 0},
{ 15587, 0},
{ 15556, 0},
{ 15524, 0},
{ 15492, 0},
{ 15459, 0},
{ 15425, 0},
{ 15391, 0},
{ 15356, 0},
{ 15321, 0},
{ 15285, 0},
{ 15249, 0},
{ 15212, 0},
{ 15174, 0},
{ 15136, 0},
{ 15097, 0},
{ 15058, 0},
{ 15018, 0},
{ 14977, 0},
{ 14936, 0},
{ 14895, 0},
{ 14853, 0},
{ 14810, 0},
{ 14767, 0},
{ 14723, 0},
{ 14679, 0},
{ 14634, 0},
{ 14588, 0},
{ 14542, 0},
{ 14496, 0},
{ 14449, 0},
{ 14401, 0},
{ 14353, 0},
{ 14304, 0},
{ 14255, 0},
{ 14205, 0},
{ 14154, 0},
{ 14104, 0},
{ 14052, 0},
{ 14000, 0},
{ 13948, 0},
{ 13895, 0},
{ 13841, 0},
{ 13787, 0},
{ 13733, 0},
{ 13678, 0},
{ 13622, 0},
{ 13566, 0},
{ 13509, 0},
{ 13452, 0},
{ 13394, 0},
{ 13336, 0},
{ 13278, 0},
{ 13219, 0},
{ 13159, 0},
{ 13099, 0},
{ 13038, 0},
{ 12977, 0},
{ 12915, 0},
{ 12853, 0},
{ 12791, 0},
{ 12728, 0},
{ 12664, 0},
{ 12600, 0},
{ 12536, 0},
{ 12471, 0},
{ 12405, 0},
{ 12339, 0},
{ 12273, 0},
{ 12206, 0},
{ 12139, 0},
{ 12071, 0},
{ 12003, 0},
{ 11934, 0},
{ 11865, 0},
{ 11796, 0},
{ 11726, 0},
{ 11655, 0},
{ 11585, 0},
{ 11513, 0},
{ 11441, 0},
{ 11369, 0},
{ 11297, 0},
{ 11224, 0},
{ 11150, 0},
{ 11076, 0},
{ 11002, 0},
{ 10927, 0},
{ 10852, 0},
{ 10777, 0},
{ 10701, 0},
{ 10625, 0},
{ 10548, 0},
{ 10471, 0},
{ 10393, 0},
{ 10315, 0},
{ 10237, 0},
{ 10158, 0},
{ 10079, 0},
{ 10000, 0},
{ 9920, 0},
{ 9840, 0},
{ 9759, 0},
{ 9678, 0},
{ 9597, 0},
{ 9515, 0},
{ 9433, 0},
{ 9351, 0},
{ 9268, 0},
{ 9185, 0},
{ 9102, 0},
{ 9018, 0},
{ 8934, 0},
{ 8850, 0},
{ 8765, 0},
{ 8680, 0},
{ 8594, 0},
{ 8509, 0},
{ 8423, 0},
{ 8336, 0},
{ 8249, 0},
{ 8162, 0},
{ 8075, 0},
{ 7988, 0},
{ 7900, 0},
{ 7811, 0},
{ 7723, 0},
{ 7634, 0},
{ 7545, 0},
{ 7456, 0},
{ 7366, 0},
{ 7276, 0},
{ 7186, 0},
{ 7095, 0},
{ 7005, 0},
{ 6914, 0},
{ 6822, 0},
{ 6731, 0},
{ 6639, 0},
{ 6547, 0},
{ 6455, 0},
{ 6362, 0},
{ 6270, 0},
{ 6177, 0},
{ 6083, 0},
{ 5990, 0},
{ 5896, 0},
{ 5802, 0},
{ 5708, 0},
{ 5614, 0},
{ 5519, 0},
{ 5425, 0},
{ 5330, 0},
{ 5234, 0},
{ 5139, 0},
{ 5044, 0},
{ 4948, 0},
{ 4852, 0},
{ 4756, 0},
{ 4659, 0},
{ 4563, 0},
{ 4466, 0},
{ 4370, 0},
{ 4273, 0},
{ 4175, 0},
{ 4078, 0},
{ 3981, 0},
{ 3883, 0},
{ 3785, 0},
{ 3688, 0},
{ 3590, 0},
{ 3491, 0},
{ 3393, 0},
{ 3295, 0},
{ 3196, 0},
{ 3098, 0},
{ 2999, 0},
{ 2900, 0},
{ 2801, 0},
{ 2702, 0},
{ 2603, 0},
{ 2503, 0},
{ 2404, 0},
{ 2304, 0},
{ 2205, 0},
{ 2105, 0},
{ 2005, 0},
{ 1906, 0},
{ 1806, 0},
{ 1706, 0},
{ 1606, 0},
{ 1506, 0},
{ 1406, 0},
{ 1305, 0},
{ 1205, 0},
{ 1105, 0},
{ 1005, 0},
{ 904, 0},
{ 804, 0},
{ 703, 0},
{ 603, 0},
{ 503, 0},
{ 402, 0},
{ 302, 0},
{ 201, 0},
{ 101, 0},
{ 0, 16383},
{ -101, 0},
{ -201, 0},
{ -302, 0},
{ -402, 0},
{ -503, 0},
{ -603, 0},
{ -703, 0},
{ -804, 0},
{ -904, 0},
{ -1005, 0},
{ -1105, 0},
{ -1205, 0},
{ -1305, 0},
{ -1406, 0},
{ -1506, 0},
{ -1606, 0},
{ -1706, 0},
{ -1806, 0},
{ -1906, 0},
{ -2005, 0},
{ -2105, 0},
{ -2205, 0},
{ -2304, 0},
{ -2404, 0},
{ -2503, 0},
{ -2603, 0},
{ -2702, 0},
{ -2801, 0},
{ -2900, 0},
{ -2999, 0},
{ -3098, 0},
{ -3196, 0},
{ -3295, 0},
{ -3393, 0},
{ -3491, 0},
{ -3590, 0},
{ -3688, 0},
{ -3785, 0},
{ -3883, 0},
{ -3981, 0},
{ -4078, 0},
{ -4175, 0},
{ -4273, 0},
{ -4370, 0},
{ -4466, 0},
{ -4563, 0},
{ -4659, 0},
{ -4756, 0},
{ -4852, 0},
{ -4948, 0},
{ -5044, 0},
{ -5139, 0},
{ -5234, 0},
{ -5330, 0},
{ -5425, 0},
{ -5519, 0},
{ -5614, 0},
{ -5708, 0},
{ -5802, 0},
{ -5896, 0},
{ -5990, 0},
{ -6083, 0},
{ -6177, 0},
{ -6270, 0},
{ -6362, 0},
{ -6455, 0},
{ -6547, 0},
{ -6639, 0},
{ -6731, 0},
{ -6822, 0},
{ -6914, 0},
{ -7005, 0},
{ -7095, 0},
{ -7186, 0},
{ -7276, 0},
{ -7366, 0},
{ -7456, 0},
{ -7545, 0},
{ -7634, 0},
{ -7723, 0},
{ -7811, 0},
{ -7900, 0},
{ -7988, 0},
{ -8075, 0},
{ -8162, 0},
{ -8249, 0},
{ -8336, 0},
{ -8423, 0},
{ -8509, 0},
{ -8594, 0},
{ -8680, 0},
{ -8765, 0},
{ -8850, 0},
{ -8934, 0},
{ -9018, 0},
{ -9102, 0},
{ -9185, 0},
{ -9268, 0},
{ -9351, 0},
{ -9433, 0},
{ -9515, 0},
{ -9597, 0},
{ -9678, 0},
{ -9759, 0},
{ -9840, 0},
{ -9920, 0},
{-10000, 0},
{-10079, 0},
{-10158, 0},
{-10237, 0},
{-10315, 0},
{-10393, 0},
{-10471, 0},
{-10548, 0},
{-10625, 0},
{-10701, 0},
{-10777, 0},
{-10852, 0},
{-10927, 0},
{-11002, 0},
{-11076, 0},
{-11150, 0},
{-11224, 0},
{-11297, 0},
{-11369, 0},
{-11441, 0},
{-11513, 0},
{-11585, 0},
{-11655, 0},
{-11726, 0},
{-11796, 0},
{-11865, 0},
{-11934, 0},
{-12003, 0},
{-12071, 0},
{-12139, 0},
{-12206, 0},
{-12273, 0},
{-12339, 0},
{-12405, 0},
{-12471, 0},
{-12536, 0},
{-12600, 0},
{-12664, 0},
{-12728, 0},
{-12791, 0},
{-12853, 0},
{-12915, 0},
{-12977, 0},
{-13038, 0},
{-13099, 0},
{-13159, 0},
{-13219, 0},
{-13278, 0},
{-13336, 0},
{-13394, 0},
{-13452, 0},
{-13509, 0},
{-13566, 0},
{-13622, 0},
{-13678, 0},
{-13733, 0},
{-13787, 0},
{-13841, 0},
{-13895, 0},
{-13948, 0},
{-14000, 0},
{-14052, 0},
{-14104, 0},
{-14154, 0},
{-14205, 0},
{-14255, 0},
{-14304, 0},
{-14353, 0},
{-14401, 0},
{-14449, 0},
{-14496, 0},
{-14542, 0},
{-14588, 0},
{-14634, 0},
{-14679, 0},
{-14723, 0},
{-14767, 0},
{-14810, 0},
{-14853, 0},
{-14895, 0},
{-14936, 0},
{-14977, 0},
{-15018, 0},
{-15058, 0},
{-15097, 0},
{-15136, 0},
{-15174, 0},
{-15212, 0},
{-15249, 0},
{-15285, 0},
{-15321, 0},
{-15356, 0},
{-15391, 0},
{-15425, 0},
{-15459, 0},
{-15492, 0},
{-15524, 0},
{-15556, 0},
{-15587, 0},
{-15618, 0},
{-15648, 0},
{-15678, 0},
{-15706, 0},
{-15735, 0},
{-15762, 0},
{-15790, 0},
{-15816, 0},
{-15842, 0},
{-15867, 0},
{-15892, 0},
{-15916, 0},
{-15940, 0},
{-15963, 0},
{-15985, 0},
{-16007, 0},
{-16028, 0},
{-16048, 0},
{-16068, 0},
{-16088, 0},
{-16106, 0},
{-16124, 0},
{-16142, 0},
{-16159, 0},
{-16175, 0},
{-16191, 0},
{-16206, 0},
{-16220, 0},
{-16234, 0},
{-16247, 0},
{-16260, 0},
{-16272, 0},
{-16283, 0},
{-16294, 0},
{-16304, 0},
{-16314, 0},
{-16323, 0},
{-16331, 0},
{-16339, 0},
{-16346, 0},
{-16352, 0},
{-16358, 0},
{-16363, 0},
{-16368, 0},
{-16372, 0},
{-16375, 0},
{-16378, 0},
{-16380, 0},
{-16382, 0},
{-16383, 0},
{-16383, 0},
{-16383, 0},
{-16382, 0},
{-16380, 0},
{-16378, 0},
{-16375, 0},
{-16372, 0},
{-16368, 0},
{-16363, 0},
{-16358, 0},
{-16352, 0},
{-16346, 0},
{-16339, 0},
{-16331, 0},
{-16323, 0},
{-16314, 0},
{-16304, 0},
{-16294, 0},
{-16283, 0},
{-16272, 0},
{-16260, 0},
{-16247, 0},
{-16234, 0},
{-16220, 0},
{-16206, 0},
{-16191, 0},
{-16175, 0},
{-16159, 0},
{-16142, 0},
{-16124, 0},
{-16106, 0},
{-16088, 0},
{-16068, 0},
{-16048, 0},
{-16028, 0},
{-16007, 0},
{-15985, 0},
{-15963, 0},
{-15940, 0},
{-15916, 0},
{-15892, 0},
{-15867, 0},
{-15842, 0},
{-15816, 0},
{-15790, 0},
{-15762, 0},
{-15735, 0},
{-15706, 0},
{-15678, 0},
{-15648, 0},
{-15618, 0},
{-15587, 0},
{-15556, 0},
{-15524, 0},
{-15492, 0},
{-15459, 0},
{-15425, 0},
{-15391, 0},
{-15356, 0},
{-15321, 0},
{-15285, 0},
{-15249, 0},
{-15212, 0},
{-15174, 0},
{-15136, 0},
{-15097, 0},
{-15058, 0},
{-15018, 0},
{-14977, 0},
{-14936, 0},
{-14895, 0},
{-14853, 0},
{-14810, 0},
{-14767, 0},
{-14723, 0},
{-14679, 0},
{-14634, 0},
{-14588, 0},
{-14542, 0},
{-14496, 0},
{-14449, 0},
{-14401, 0},
{-14353, 0},
{-14304, 0},
{-14255, 0},
{-14205, 0},
{-14154, 0},
{-14104, 0},
{-14052, 0},
{-14000, 0},
{-13948, 0},
{-13895, 0},
{-13841, 0},
{-13787, 0},
{-13733, 0},
{-13678, 0},
{-13622, 0},
{-13566, 0},
{-13509, 0},
{-13452, 0},
{-13394, 0},
{-13336, 0},
{-13278, 0},
{-13219, 0},
{-13159, 0},
{-13099, 0},
{-13038, 0},
{-12977, 0},
{-12915, 0},
{-12853, 0},
{-12791, 0},
{-12728, 0},
{-12664, 0},
{-12600, 0},
{-12536, 0},
{-12471, 0},
{-12405, 0},
{-12339, 0},
{-12273, 0},
{-12206, 0},
{-12139, 0},
{-12071, 0},
{-12003, 0},
{-11934, 0},
{-11865, 0},
{-11796, 0},
{-11726, 0},
{-11655, 0},
{-11585, 0},
{-11513, 0},
{-11441, 0},
{-11369, 0},
{-11297, 0},
{-11224, 0},
{-11150, 0},
{-11076, 0},
{-11002, 0},
{-10927, 0},
{-10852, 0},
{-10777, 0},
{-10701, 0},
{-10625, 0},
{-10548, 0},
{-10471, 0},
{-10393, 0},
{-10315, 0},
{-10237, 0},
{-10158, 0},
{-10079, 0},
{-10000, 0},
{ -9920, 0},
{ -9840, 0},
{ -9759, 0},
{ -9678, 0},
{ -9597, 0},
{ -9515, 0},
{ -9433, 0},
{ -9351, 0},
{ -9268, 0},
{ -9185, 0},
{ -9102, 0},
{ -9018, 0},
{ -8934, 0},
{ -8850, 0},
{ -8765, 0},
{ -8680, 0},
{ -8594, 0},
{ -8509, 0},
{ -8423, 0},
{ -8336, 0},
{ -8249, 0},
{ -8162, 0},
{ -8075, 0},
{ -7988, 0},
{ -7900, 0},
{ -7811, 0},
{ -7723, 0},
{ -7634, 0},
{ -7545, 0},
{ -7456, 0},
{ -7366, 0},
{ -7276, 0},
{ -7186, 0},
{ -7095, 0},
{ -7005, 0},
{ -6914, 0},
{ -6822, 0},
{ -6731, 0},
{ -6639, 0},
{ -6547, 0},
{ -6455, 0},
{ -6362, 0},
{ -6270, 0},
{ -6177, 0},
{ -6083, 0},
{ -5990, 0},
{ -5896, 0},
{ -5802, 0},
{ -5708, 0},
{ -5614, 0},
{ -5519, 0},
{ -5425, 0},
{ -5330, 0},
{ -5234, 0},
{ -5139, 0},
{ -5044, 0},
{ -4948, 0},
{ -4852, 0},
{ -4756, 0},
{ -4659, 0},
{ -4563, 0},
{ -4466, 0},
{ -4370, 0},
{ -4273, 0},
{ -4175, 0},
{ -4078, 0},
{ -3981, 0},
{ -3883, 0},
{ -3785, 0},
{ -3688, 0},
{ -3590, 0},
{ -3491, 0},
{ -3393, 0},
{ -3295, 0},
{ -3196, 0},
{ -3098, 0},
{ -2999, 0},
{ -2900, 0},
{ -2801, 0},
{ -2702, 0},
{ -2603, 0},
{ -2503, 0},
{ -2404, 0},
{ -2304, 0},
{ -2205, 0},
{ -2105, 0},
{ -2005, 0},
{ -1906, 0},
{ -1806, 0},
{ -1706, 0},
{ -1606, 0},
{ -1506, 0},
{ -1406, 0},
{ -1305, 0},
{ -1205, 0},
{ -1105, 0},
{ -1005, 0},
{ -904, 0},
{ -804, 0},
{ -703, 0},
{ -603, 0},
{ -503, 0},
{ -402, 0},
{ -302, 0},
{ -201, 0},
{ -101, 0},
{ 0, 16383},
{ 101, 0},
{ 201, 0},
{ 302, 0},
{ 402, 0},
{ 503, 0},
{ 603, 0},
{ 703, 0},
{ 804, 0},
{ 904, 0},
{ 1005, 0},
{ 1105, 0},
{ 1205, 0},
{ 1305, 0},
{ 1406, 0},
{ 1506, 0},
{ 1606, 0},
{ 1706, 0},
{ 1806, 0},
{ 1906, 0},
{ 2005, 0},
{ 2105, 0},
{ 2205, 0},
{ 2304, 0},
{ 2404, 0},
{ 2503, 0},
{ 2603, 0},
{ 2702, 0},
{ 2801, 0},
{ 2900, 0},
{ 2999, 0},
{ 3098, 0},
{ 3196, 0},
{ 3295, 0},
{ 3393, 0},
{ 3491, 0},
{ 3590, 0},
{ 3688, 0},
{ 3785, 0},
{ 3883, 0},
{ 3981, 0},
{ 4078, 0},
{ 4175, 0},
{ 4273, 0},
{ 4370, 0},
{ 4466, 0},
{ 4563, 0},
{ 4659, 0},
{ 4756, 0},
{ 4852, 0},
{ 4948, 0},
{ 5044, 0},
{ 5139, 0},
{ 5234, 0},
{ 5330, 0},
{ 5425, 0},
{ 5519, 0},
{ 5614, 0},
{ 5708, 0},
{ 5802, 0},
{ 5896, 0},
{ 5990, 0},
{ 6083, 0},
{ 6177, 0},
{ 6270, 0},
{ 6362, 0},
{ 6455, 0},
{ 6547, 0},
{ 6639, 0},
{ 6731, 0},
{ 6822, 0},
{ 6914, 0},
{ 7005, 0},
{ 7095, 0},
{ 7186, 0},
{ 7276, 0},
{ 7366, 0},
{ 7456, 0},
{ 7545, 0},
{ 7634, 0},
{ 7723, 0},
{ 7811, 0},
{ 7900, 0},
{ 7988, 0},
{ 8075, 0},
{ 8162, 0},
{ 8249, 0},
{ 8336, 0},
{ 8423, 0},
{ 8509, 0},
{ 8594, 0},
{ 8680, 0},
{ 8765, 0},
{ 8850, 0},
{ 8934, 0},
{ 9018, 0},
{ 9102, 0},
{ 9185, 0},
{ 9268, 0},
{ 9351, 0},
{ 9433, 0},
{ 9515, 0},
{ 9597, 0},
{ 9678, 0},
{ 9759, 0},
{ 9840, 0},
{ 9920, 0},
{ 10000, 0},
{ 10079, 0},
{ 10158, 0},
{ 10237, 0},
{ 10315, 0},
{ 10393, 0},
{ 10471, 0},
{ 10548, 0},
{ 10625, 0},
{ 10701, 0},
{ 10777, 0},
{ 10852, 0},
{ 10927, 0},
{ 11002, 0},
{ 11076, 0},
{ 11150, 0},
{ 11224, 0},
{ 11297, 0},
{ 11369, 0},
{ 11441, 0},
{ 11513, 0},
{ 11585, 0},
{ 11655, 0},
{ 11726, 0},
{ 11796, 0},
{ 11865, 0},
{ 11934, 0},
{ 12003, 0},
{ 12071, 0},
{ 12139, 0},
{ 12206, 0},
{ 12273, 0},
{ 12339, 0},
{ 12405, 0},
{ 12471, 0},
{ 12536, 0},
{ 12600, 0},
{ 12664, 0},
{ 12728, 0},
{ 12791, 0},
{ 12853, 0},
{ 12915, 0},
{ 12977, 0},
{ 13038, 0},
{ 13099, 0},
{ 13159, 0},
{ 13219, 0},
{ 13278, 0},
{ 13336, 0},
{ 13394, 0},
{ 13452, 0},
{ 13509, 0},
{ 13566, 0},
{ 13622, 0},
{ 13678, 0},
{ 13733, 0},
{ 13787, 0},
{ 13841, 0},
{ 13895, 0},
{ 13948, 0},
{ 14000, 0},
{ 14052, 0},
{ 14104, 0},
{ 14154, 0},
{ 14205, 0},
{ 14255, 0},
{ 14304, 0},
{ 14353, 0},
{ 14401, 0},
{ 14449, 0},
{ 14496, 0},
{ 14542, 0},
{ 14588, 0},
{ 14634, 0},
{ 14679, 0},
{ 14723, 0},
{ 14767, 0},
{ 14810, 0},
{ 14853, 0},
{ 14895, 0},
{ 14936, 0},
{ 14977, 0},
{ 15018, 0},
{ 15058, 0},
{ 15097, 0},
{ 15136, 0},
{ 15174, 0},
{ 15212, 0},
{ 15249, 0},
{ 15285, 0},
{ 15321, 0},
{ 15356, 0},
{ 15391, 0},
{ 15425, 0},
{ 15459, 0},
{ 15492, 0},
{ 15524, 0},
{ 15556, 0},
{ 15587, 0},
{ 15618, 0},
{ 15648, 0},
{ 15678, 0},
{ 15706, 0},
{ 15735, 0},
{ 15762, 0},
{ 15790, 0},
{ 15816, 0},
{ 15842, 0},
{ 15867, 0},
{ 15892, 0},
{ 15916, 0},
{ 15940, 0},
{ 15963, 0},
{ 15985, 0},
{ 16007, 0},
{ 16028, 0},
{ 16048, 0},
{ 16068, 0},
{ 16088, 0},
{ 16106, 0},
{ 16124, 0},
{ 16142, 0},
{ 16159, 0},
{ 16175, 0},
{ 16191, 0},
{ 16206, 0},
{ 16220, 0},
{ 16234, 0},
{ 16247, 0},
{ 16260, 0},
{ 16272, 0},
{ 16283, 0},
{ 16294, 0},
{ 16304, 0},
{ 16314, 0},
{ 16323, 0},
{ 16331, 0},
{ 16339, 0},
{ 16346, 0},
{ 16352, 0},
{ 16358, 0},
{ 16363, 0},
{ 16368, 0},
{ 16372, 0},
{ 16375, 0},
{ 16378, 0},
{ 16380, 0},
{ 16382, 0},
{ 16383, 0},
{ 16383, 0},
{ 16383, 0},
{ 16382, 0},
{ 16380, 0},
{ 16378, 0},
{ 16375, 0},
{ 16372, 0},
{ 16368, 0},
{ 16363, 0},
{ 16358, 0},
{ 16352, 0},
{ 16346, 0},
{ 16339, 0},
{ 16331, 0},
{ 16323, 0},
{ 16314, 0},
{ 16304, 0},
{ 16294, 0},
{ 16283, 0},
{ 16272, 0},
{ 16260, 0},
{ 16247, 0},
{ 16234, 0},
{ 16220, 0},
{ 16206, 0},
{ 16191, 0},
{ 16175, 0},
{ 16159, 0},
{ 16142, 0},
{ 16124, 0},
{ 16106, 0},
{ 16088, 0},
{ 16068, 0},
{ 16048, 0},
{ 16028, 0},
{ 16007, 0},
{ 15985, 0},
{ 15963, 0},
{ 15940, 0},
{ 15916, 0},
{ 15892, 0},
{ 15867, 0},
{ 15842, 0},
{ 15816, 0},
{ 15790, 0},
{ 15762, 0},
{ 15735, 0},
{ 15706, 0},
{ 15678, 0},
{ 15648, 0},
{ 15618, 0},
{ 15587, 0},
{ 15556, 0},
{ 15524, 0},
{ 15492, 0},
{ 15459, 0},
{ 15425, 0},
{ 15391, 0},
{ 15356, 0},
{ 15321, 0},
{ 15285, 0},
{ 15249, 0},
{ 15212, 0},
{ 15174, 0},
{ 15136, 0},
{ 15097, 0},
{ 15058, 0},
{ 15018, 0},
{ 14977, 0},
{ 14936, 0},
{ 14895, 0},
{ 14853, 0},
{ 14810, 0},
{ 14767, 0},
{ 14723, 0},
{ 14679, 0},
{ 14634, 0},
{ 14588, 0},
{ 14542, 0},
{ 14496, 0},
{ 14449, 0},
{ 14401, 0},
{ 14353, 0},
{ 14304, 0},
{ 14255, 0},
{ 14205, 0},
{ 14154, 0},
{ 14104, 0},
{ 14052, 0},
{ 14000, 0},
{ 13948, 0},
{ 13895, 0},
{ 13841, 0},
{ 13787, 0},
{ 13733, 0},
{ 13678, 0},
{ 13622, 0},
{ 13566, 0},
{ 13509, 0},
{ 13452, 0},
{ 13394, 0},
{ 13336, 0},
{ 13278, 0},
{ 13219, 0},
{ 13159, 0},
{ 13099, 0},
{ 13038, 0},
{ 12977, 0},
{ 12915, 0},
{ 12853, 0},
{ 12791, 0},
{ 12728, 0},
{ 12664, 0},
{ 12600, 0},
{ 12536, 0},
{ 12471, 0},
{ 12405, 0},
{ 12339, 0},
{ 12273, 0},
{ 12206, 0},
{ 12139, 0},
{ 12071, 0},
{ 12003, 0},
{ 11934, 0},
{ 11865, 0},
{ 11796, 0},
{ 11726, 0},
{ 11655, 0},
{ 11585, 0},
{ 11513, 0},
{ 11441, 0},
{ 11369, 0},
{ 11297, 0},
{ 11224, 0},
{ 11150, 0},
{ 11076, 0},
{ 11002, 0},
{ 10927, 0},
{ 10852, 0},
{ 10777, 0},
{ 10701, 0},
{ 10625, 0},
{ 10548, 0},
{ 10471, 0},
{ 10393, 0},
{ 10315, 0},
{ 10237, 0},
{ 10158, 0},
{ 10079, 0},
{ 10000, 0},
{ 9920, 0},
{ 9840, 0},
{ 9759, 0},
{ 9678, 0},
{ 9597, 0},
{ 9515, 0},
{ 9433, 0},
{ 9351, 0},
{ 9268, 0},
{ 9185, 0},
{ 9102, 0},
{ 9018, 0},
{ 8934, 0},
{ 8850, 0},
{ 8765, 0},
{ 8680, 0},
{ 8594, 0},
{ 8509, 0},
{ 8423, 0},
{ 8336, 0},
{ 8249, 0},
{ 8162, 0},
{ 8075, 0},
{ 7988, 0},
{ 7900, 0},
{ 7811, 0},
{ 7723, 0},
{ 7634, 0},
{ 7545, 0},
{ 7456, 0},
{ 7366, 0},
{ 7276, 0},
{ 7186, 0},
{ 7095, 0},
{ 7005, 0},
{ 6914, 0},
{ 6822, 0},
{ 6731, 0},
{ 6639, 0},
{ 6547, 0},
{ 6455, 0},
{ 6362, 0},
{ 6270, 0},
{ 6177, 0},
{ 6083, 0},
{ 5990, 0},
{ 5896, 0},
{ 5802, 0},
{ 5708, 0},
{ 5614, 0},
{ 5519, 0},
{ 5425, 0},
{ 5330, 0},
{ 5234, 0},
{ 5139, 0},
{ 5044, 0},
{ 4948, 0},
{ 4852, 0},
{ 4756, 0},
{ 4659, 0},
{ 4563, 0},
{ 4466, 0},
{ 4370, 0},
{ 4273, 0},
{ 4175, 0},
{ 4078, 0},
{ 3981, 0},
{ 3883, 0},
{ 3785, 0},
{ 3688, 0},
{ 3590, 0},
{ 3491, 0},
{ 3393, 0},
{ 3295, 0},
{ 3196, 0},
{ 3098, 0},
{ 2999, 0},
{ 2900, 0},
{ 2801, 0},
{ 2702, 0},
{ 2603, 0},
{ 2503, 0},
{ 2404, 0},
{ 2304, 0},
{ 2205, 0},
{ 2105, 0},
{ 2005, 0},
{ 1906, 0},
{ 1806, 0},
{ 1706, 0},
{ 1606, 0},
{ 1506, 0},
{ 1406, 0},
{ 1305, 0},
{ 1205, 0},
{ 1105, 0},
{ 1005, 0},
{ 904, 0},
{ 804, 0},
{ 703, 0},
{ 603, 0},
{ 503, 0},
{ 402, 0},
{ 302, 0},
{ 201, 0},
{ 101, 0},
{ 0, 16383},
{ -101, 0},
{ -201, 0},
{ -302, 0},
{ -402, 0},
{ -503, 0},
{ -603, 0},
{ -703, 0},
{ -804, 0},
{ -904, 0},
{ -1005, 0},
{ -1105, 0},
{ -1205, 0},
{ -1305, 0},
{ -1406, 0},
{ -1506, 0},
{ -1606, 0},
{ -1706, 0},
{ -1806, 0},
{ -1906, 0},
{ -2005, 0},
{ -2105, 0},
{ -2205, 0},
{ -2304, 0},
{ -2404, 0},
{ -2503, 0},
{ -2603, 0},
{ -2702, 0},
{ -2801, 0},
{ -2900, 0},
{ -2999, 0},
{ -3098, 0},
{ -3196, 0},
{ -3295, 0},
{ -3393, 0},
{ -3491, 0},
{ -3590, 0},
{ -3688, 0},
{ -3785, 0},
{ -3883, 0},
{ -3981, 0},
{ -4078, 0},
{ -4175, 0},
{ -4273, 0},
{ -4370, 0},
{ -4466, 0},
{ -4563, 0},
{ -4659, 0},
{ -4756, 0},
{ -4852, 0},
{ -4948, 0},
{ -5044, 0},
{ -5139, 0},
{ -5234, 0},
{ -5330, 0},
{ -5425, 0},
{ -5519, 0},
{ -5614, 0},
{ -5708, 0},
{ -5802, 0},
{ -5896, 0},
{ -5990, 0},
{ -6083, 0},
{ -6177, 0},
{ -6270, 0},
{ -6362, 0},
{ -6455, 0},
{ -6547, 0},
{ -6639, 0},
{ -6731, 0},
{ -6822, 0},
{ -6914, 0},
{ -7005, 0},
{ -7095, 0},
{ -7186, 0},
{ -7276, 0},
{ -7366, 0},
{ -7456, 0},
{ -7545, 0},
{ -7634, 0},
{ -7723, 0},
{ -7811, 0},
{ -7900, 0},
{ -7988, 0},
{ -8075, 0},
{ -8162, 0},
{ -8249, 0},
{ -8336, 0},
{ -8423, 0},
{ -8509, 0},
{ -8594, 0},
{ -8680, 0},
{ -8765, 0},
{ -8850, 0},
{ -8934, 0},
{ -9018, 0},
{ -9102, 0},
{ -9185, 0},
{ -9268, 0},
{ -9351, 0},
{ -9433, 0},
{ -9515, 0},
{ -9597, 0},
{ -9678, 0},
{ -9759, 0},
{ -9840, 0},
{ -9920, 0},
{-10000, 0},
{-10079, 0},
{-10158, 0},
{-10237, 0},
{-10315, 0},
{-10393, 0},
{-10471, 0},
{-10548, 0},
{-10625, 0},
{-10701, 0},
{-10777, 0},
{-10852, 0},
{-10927, 0},
{-11002, 0},
{-11076, 0},
{-11150, 0},
{-11224, 0},
{-11297, 0},
{-11369, 0},
{-11441, 0},
{-11513, 0},
{-11585, 0},
{-11655, 0},
{-11726, 0},
{-11796, 0},
{-11865, 0},
{-11934, 0},
{-12003, 0},
{-12071, 0},
{-12139, 0},
{-12206, 0},
{-12273, 0},
{-12339, 0},
{-12405, 0},
{-12471, 0},
{-12536, 0},
{-12600, 0},
{-12664, 0},
{-12728, 0},
{-12791, 0},
{-12853, 0},
{-12915, 0},
{-12977, 0},
{-13038, 0},
{-13099, 0},
{-13159, 0},
{-13219, 0},
{-13278, 0},
{-13336, 0},
{-13394, 0},
{-13452, 0},
{-13509, 0},
{-13566, 0},
{-13622, 0},
{-13678, 0},
{-13733, 0},
{-13787, 0},
{-13841, 0},
{-13895, 0},
{-13948, 0},
{-14000, 0},
{-14052, 0},
{-14104, 0},
{-14154, 0},
{-14205, 0},
{-14255, 0},
{-14304, 0},
{-14353, 0},
{-14401, 0},
{-14449, 0},
{-14496, 0},
{-14542, 0},
{-14588, 0},
{-14634, 0},
{-14679, 0},
{-14723, 0},
{-14767, 0},
{-14810, 0},
{-14853, 0},
{-14895, 0},
{-14936, 0},
{-14977, 0},
{-15018, 0},
{-15058, 0},
{-15097, 0},
{-15136, 0},
{-15174, 0},
{-15212, 0},
{-15249, 0},
{-15285, 0},
{-15321, 0},
{-15356, 0},
{-15391, 0},
{-15425, 0},
{-15459, 0},
{-15492, 0},
{-15524, 0},
{-15556, 0},
{-15587, 0},
{-15618, 0},
{-15648, 0},
{-15678, 0},
{-15706, 0},
{-15735, 0},
{-15762, 0},
{-15790, 0},
{-15816, 0},
{-15842, 0},
{-15867, 0},
{-15892, 0},
{-15916, 0},
{-15940, 0},
{-15963, 0},
{-15985, 0},
{-16007, 0},
{-16028, 0},
{-16048, 0},
{-16068, 0},
{-16088, 0},
{-16106, 0},
{-16124, 0},
{-16142, 0},
{-16159, 0},
{-16175, 0},
{-16191, 0},
{-16206, 0},
{-16220, 0},
{-16234, 0},
{-16247, 0},
{-16260, 0},
{-16272, 0},
{-16283, 0},
{-16294, 0},
{-16304, 0},
{-16314, 0},
{-16323, 0},
{-16331, 0},
{-16339, 0},
{-16346, 0},
{-16352, 0},
{-16358, 0},
{-16363, 0},
{-16368, 0},
{-16372, 0},
{-16375, 0},
{-16378, 0},
{-16380, 0},
{-16382, 0},
{-16383, 0},
{-16383, 0},
{-16383, 0},
{-16382, 0},
{-16380, 0},
{-16378, 0},
{-16375, 0},
{-16372, 0},
{-16368, 0},
{-16363, 0},
{-16358, 0},
{-16352, 0},
{-16346, 0},
{-16339, 0},
{-16331, 0},
{-16323, 0},
{-16314, 0},
{-16304, 0},
{-16294, 0},
{-16283, 0},
{-16272, 0},
{-16260, 0},
{-16247, 0},
{-16234, 0},
{-16220, 0},
{-16206, 0},
{-16191, 0},
{-16175, 0},
{-16159, 0},
{-16142, 0},
{-16124, 0},
{-16106, 0},
{-16088, 0},
{-16068, 0},
{-16048, 0},
{-16028, 0},
{-16007, 0},
{-15985, 0},
{-15963, 0},
{-15940, 0},
{-15916, 0},
{-15892, 0},
{-15867, 0},
{-15842, 0},
{-15816, 0},
{-15790, 0},
{-15762, 0},
{-15735, 0},
{-15706, 0},
{-15678, 0},
{-15648, 0},
{-15618, 0},
{-15587, 0},
{-15556, 0},
{-15524, 0},
{-15492, 0},
{-15459, 0},
{-15425, 0},
{-15391, 0},
{-15356, 0},
{-15321, 0},
{-15285, 0},
{-15249, 0},
{-15212, 0},
{-15174, 0},
{-15136, 0},
{-15097, 0},
{-15058, 0},
{-15018, 0},
{-14977, 0},
{-14936, 0},
{-14895, 0},
{-14853, 0},
{-14810, 0},
{-14767, 0},
{-14723, 0},
{-14679, 0},
{-14634, 0},
{-14588, 0},
{-14542, 0},
{-14496, 0},
{-14449, 0},
{-14401, 0},
{-14353, 0},
{-14304, 0},
{-14255, 0},
{-14205, 0},
{-14154, 0},
{-14104, 0},
{-14052, 0},
{-14000, 0},
{-13948, 0},
{-13895, 0},
{-13841, 0},
{-13787, 0},
{-13733, 0},
{-13678, 0},
{-13622, 0},
{-13566, 0},
{-13509, 0},
{-13452, 0},
{-13394, 0},
{-13336, 0},
{-13278, 0},
{-13219, 0},
{-13159, 0},
{-13099, 0},
{-13038, 0},
{-12977, 0},
{-12915, 0},
{-12853, 0},
{-12791, 0},
{-12728, 0},
{-12664, 0},
{-12600, 0},
{-12536, 0},
{-12471, 0},
{-12405, 0},
{-12339, 0},
{-12273, 0},
{-12206, 0},
{-12139, 0},
{-12071, 0},
{-12003, 0},
{-11934, 0},
{-11865, 0},
{-11796, 0},
{-11726, 0},
{-11655, 0},
{-11585, 0},
{-11513, 0},
{-11441, 0},
{-11369, 0},
{-11297, 0},
{-11224, 0},
{-11150, 0},
{-11076, 0},
{-11002, 0},
{-10927, 0},
{-10852, 0},
{-10777, 0},
{-10701, 0},
{-10625, 0},
{-10548, 0},
{-10471, 0},
{-10393, 0},
{-10315, 0},
{-10237, 0},
{-10158, 0},
{-10079, 0},
{-10000, 0},
{ -9920, 0},
{ -9840, 0},
{ -9759, 0},
{ -9678, 0},
{ -9597, 0},
{ -9515, 0},
{ -9433, 0},
{ -9351, 0},
{ -9268, 0},
{ -9185, 0},
{ -9102, 0},
{ -9018, 0},
{ -8934, 0},
{ -8850, 0},
{ -8765, 0},
{ -8680, 0},
{ -8594, 0},
{ -8509, 0},
{ -8423, 0},
{ -8336, 0},
{ -8249, 0},
{ -8162, 0},
{ -8075, 0},
{ -7988, 0},
{ -7900, 0},
{ -7811, 0},
{ -7723, 0},
{ -7634, 0},
{ -7545, 0},
{ -7456, 0},
{ -7366, 0},
{ -7276, 0},
{ -7186, 0},
{ -7095, 0},
{ -7005, 0},
{ -6914, 0},
{ -6822, 0},
{ -6731, 0},
{ -6639, 0},
{ -6547, 0},
{ -6455, 0},
{ -6362, 0},
{ -6270, 0},
{ -6177, 0},
{ -6083, 0},
{ -5990, 0},
{ -5896, 0},
{ -5802, 0},
{ -5708, 0},
{ -5614, 0},
{ -5519, 0},
{ -5425, 0},
{ -5330, 0},
{ -5234, 0},
{ -5139, 0},
{ -5044, 0},
{ -4948, 0},
{ -4852, 0},
{ -4756, 0},
{ -4659, 0},
{ -4563, 0},
{ -4466, 0},
{ -4370, 0},
{ -4273, 0},
{ -4175, 0},
{ -4078, 0},
{ -3981, 0},
{ -3883, 0},
{ -3785, 0},
{ -3688, 0},
{ -3590, 0},
{ -3491, 0},
{ -3393, 0},
{ -3295, 0},
{ -3196, 0},
{ -3098, 0},
{ -2999, 0},
{ -2900, 0},
{ -2801, 0},
{ -2702, 0},
{ -2603, 0},
{ -2503, 0},
{ -2404, 0},
{ -2304, 0},
{ -2205, 0},
{ -2105, 0},
{ -2005, 0},
{ -1906, 0},
{ -1806, 0},
{ -1706, 0},
{ -1606, 0},
{ -1506, 0},
{ -1406, 0},
{ -1305, 0},
{ -1205, 0},
{ -1105, 0},
{ -1005, 0},
{ -904, 0},
{ -804, 0},
{ -703, 0},
{ -603, 0},
{ -503, 0},
{ -402, 0},
{ -302, 0},
{ -201, 0},
{ -101, 0},
{ 0, 16383},
{ 101, 0},
{ 201, 0},
{ 302, 0},
{ 402, 0},
{ 503, 0},
{ 603, 0},
{ 703, 0},
{ 804, 0},
{ 904, 0},
{ 1005, 0},
{ 1105, 0},
{ 1205, 0},
{ 1305, 0},
{ 1406, 0},
{ 1506, 0},
{ 1606, 0},
{ 1706, 0},
{ 1806, 0},
{ 1906, 0},
{ 2005, 0},
{ 2105, 0},
{ 2205, 0},
{ 2304, 0},
{ 2404, 0},
{ 2503, 0},
{ 2603, 0},
{ 2702, 0},
{ 2801, 0},
{ 2900, 0},
{ 2999, 0},
{ 3098, 0},
{ 3196, 0},
{ 3295, 0},
{ 3393, 0},
{ 3491, 0},
{ 3590, 0},
{ 3688, 0},
{ 3785, 0},
{ 3883, 0},
{ 3981, 0},
{ 4078, 0},
{ 4175, 0},
{ 4273, 0},
{ 4370, 0},
{ 4466, 0},
{ 4563, 0},
{ 4659, 0},
{ 4756, 0},
{ 4852, 0},
{ 4948, 0},
{ 5044, 0},
{ 5139, 0},
{ 5234, 0},
{ 5330, 0},
{ 5425, 0},
{ 5519, 0},
{ 5614, 0},
{ 5708, 0},
{ 5802, 0},
{ 5896, 0},
{ 5990, 0},
{ 6083, 0},
{ 6177, 0},
{ 6270, 0},
{ 6362, 0},
{ 6455, 0},
{ 6547, 0},
{ 6639, 0},
{ 6731, 0},
{ 6822, 0},
{ 6914, 0},
{ 7005, 0},
{ 7095, 0},
{ 7186, 0},
{ 7276, 0},
{ 7366, 0},
{ 7456, 0},
{ 7545, 0},
{ 7634, 0},
{ 7723, 0},
{ 7811, 0},
{ 7900, 0},
{ 7988, 0},
{ 8075, 0},
{ 8162, 0},
{ 8249, 0},
{ 8336, 0},
{ 8423, 0},
{ 8509, 0},
{ 8594, 0},
{ 8680, 0},
{ 8765, 0},
{ 8850, 0},
{ 8934, 0},
{ 9018, 0},
{ 9102, 0},
{ 9185, 0},
{ 9268, 0},
{ 9351, 0},
{ 9433, 0},
{ 9515, 0},
{ 9597, 0},
{ 9678, 0},
{ 9759, 0},
{ 9840, 0},
{ 9920, 0},
{ 10000, 0},
{ 10079, 0},
{ 10158, 0},
{ 10237, 0},
{ 10315, 0},
{ 10393, 0},
{ 10471, 0},
{ 10548, 0},
{ 10625, 0},
{ 10701, 0},
{ 10777, 0},
{ 10852, 0},
{ 10927, 0},
{ 11002, 0},
{ 11076, 0},
{ 11150, 0},
{ 11224, 0},
{ 11297, 0},
{ 11369, 0},
{ 11441, 0},
{ 11513, 0},
{ 11585, 0},
{ 11655, 0},
{ 11726, 0},
{ 11796, 0},
{ 11865, 0},
{ 11934, 0},
{ 12003, 0},
{ 12071, 0},
{ 12139, 0},
{ 12206, 0},
{ 12273, 0},
{ 12339, 0},
{ 12405, 0},
{ 12471, 0},
{ 12536, 0},
{ 12600, 0},
{ 12664, 0},
{ 12728, 0},
{ 12791, 0},
{ 12853, 0},
{ 12915, 0},
{ 12977, 0},
{ 13038, 0},
{ 13099, 0},
{ 13159, 0},
{ 13219, 0},
{ 13278, 0},
{ 13336, 0},
{ 13394, 0},
{ 13452, 0},
{ 13509, 0},
{ 13566, 0},
{ 13622, 0},
{ 13678, 0},
{ 13733, 0},
{ 13787, 0},
{ 13841, 0},
{ 13895, 0},
{ 13948, 0},
{ 14000, 0},
{ 14052, 0},
{ 14104, 0},
{ 14154, 0},
{ 14205, 0},
{ 14255, 0},
{ 14304, 0},
{ 14353, 0},
{ 14401, 0},
{ 14449, 0},
{ 14496, 0},
{ 14542, 0},
{ 14588, 0},
{ 14634, 0},
{ 14679, 0},
{ 14723, 0},
{ 14767, 0},
{ 14810, 0},
{ 14853, 0},
{ 14895, 0},
{ 14936, 0},
{ 14977, 0},
{ 15018, 0},
{ 15058, 0},
{ 15097, 0},
{ 15136, 0},
{ 15174, 0},
{ 15212, 0},
{ 15249, 0},
{ 15285, 0},
{ 15321, 0},
{ 15356, 0},
{ 15391, 0},
{ 15425, 0},
{ 15459, 0},
{ 15492, 0},
{ 15524, 0},
{ 15556, 0},
{ 15587, 0},
{ 15618, 0},
{ 15648, 0},
{ 15678, 0},
{ 15706, 0},
{ 15735, 0},
{ 15762, 0},
{ 15790, 0},
{ 15816, 0},
{ 15842, 0},
{ 15867, 0},
{ 15892, 0},
{ 15916, 0},
{ 15940, 0},
{ 15963, 0},
{ 15985, 0},
{ 16007, 0},
{ 16028, 0},
{ 16048, 0},
{ 16068, 0},
{ 16088, 0},
{ 16106, 0},
{ 16124, 0},
{ 16142, 0},
{ 16159, 0},
{ 16175, 0},
{ 16191, 0},
{ 16206, 0},
{ 16220, 0},
{ 16234, 0},
{ 16247, 0},
{ 16260, 0},
{ 16272, 0},
{ 16283, 0},
{ 16294, 0},
{ 16304, 0},
{ 16314, 0},
{ 16323, 0},
{ 16331, 0},
{ 16339, 0},
{ 16346, 0},
{ 16352, 0},
{ 16358, 0},
{ 16363, 0},
{ 16368, 0},
{ 16372, 0},
{ 16375, 0},
{ 16378, 0},
{ 16380, 0},
{ 16382, 0},
{ 16383, 0},
{ 16383, 0},
{ 16383, 0},
{ 16382, 0},
{ 16380, 0},
{ 16378, 0},
{ 16375, 0},
{ 16372, 0},
{ 16368, 0},
{ 16363, 0},
{ 16358, 0},
{ 16352, 0},
{ 16346, 0},
{ 16339, 0},
{ 16331, 0},
{ 16323, 0},
{ 16314, 0},
{ 16304, 0},
{ 16294, 0},
{ 16283, 0},
{ 16272, 0},
{ 16260, 0},
{ 16247, 0},
{ 16234, 0},
{ 16220, 0},
{ 16206, 0},
{ 16191, 0},
{ 16175, 0},
{ 16159, 0},
{ 16142, 0},
{ 16124, 0},
{ 16106, 0},
{ 16088, 0},
{ 16068, 0},
{ 16048, 0},
{ 16028, 0},
{ 16007, 0},
{ 15985, 0},
{ 15963, 0},
{ 15940, 0},
{ 15916, 0},
{ 15892, 0},
{ 15867, 0},
{ 15842, 0},
{ 15816, 0},
{ 15790, 0},
{ 15762, 0},
{ 15735, 0},
{ 15706, 0},
{ 15678, 0},
{ 15648, 0},
{ 15618, 0},
{ 15587, 0},
{ 15556, 0},
{ 15524, 0},
{ 15492, 0},
{ 15459, 0},
{ 15425, 0},
{ 15391, 0},
{ 15356, 0},
{ 15321, 0},
{ 15285, 0},
{ 15249, 0},
{ 15212, 0},
{ 15174, 0},
{ 15136, 0},
{ 15097, 0},
{ 15058, 0},
{ 15018, 0},
{ 14977, 0},
{ 14936, 0},
{ 14895, 0},
{ 14853, 0},
{ 14810, 0},
{ 14767, 0},
{ 14723, 0},
{ 14679, 0},
{ 14634, 0},
{ 14588, 0},
{ 14542, 0},
{ 14496, 0},
{ 14449, 0},
{ 14401, 0},
{ 14353, 0},
{ 14304, 0},
{ 14255, 0},
{ 14205, 0},
{ 14154, 0},
{ 14104, 0},
{ 14052, 0},
{ 14000, 0},
{ 13948, 0},
{ 13895, 0},
{ 13841, 0},
{ 13787, 0},
{ 13733, 0},
{ 13678, 0},
{ 13622, 0},
{ 13566, 0},
{ 13509, 0},
{ 13452, 0},
{ 13394, 0},
{ 13336, 0},
{ 13278, 0},
{ 13219, 0},
{ 13159, 0},
{ 13099, 0},
{ 13038, 0},
{ 12977, 0},
{ 12915, 0},
{ 12853, 0},
{ 12791, 0},
{ 12728, 0},
{ 12664, 0},
{ 12600, 0},
{ 12536, 0},
{ 12471, 0},
{ 12405, 0},
{ 12339, 0},
{ 12273, 0},
{ 12206, 0},
{ 12139, 0},
{ 12071, 0},
{ 12003, 0},
{ 11934, 0},
{ 11865, 0},
{ 11796, 0},
{ 11726, 0},
{ 11655, 0},
{ 11585, 0},
{ 11513, 0},
{ 11441, 0},
{ 11369, 0},
{ 11297, 0},
{ 11224, 0},
{ 11150, 0},
{ 11076, 0},
{ 11002, 0},
{ 10927, 0},
{ 10852, 0},
{ 10777, 0},
{ 10701, 0},
{ 10625, 0},
{ 10548, 0},
{ 10471, 0},
{ 10393, 0},
{ 10315, 0},
{ 10237, 0},
{ 10158, 0},
{ 10079, 0},
{ 10000, 0},
{ 9920, 0},
{ 9840, 0},
{ 9759, 0},
{ 9678, 0},
{ 9597, 0},
{ 9515, 0},
{ 9433, 0},
{ 9351, 0},
{ 9268, 0},
{ 9185, 0},
{ 9102, 0},
{ 9018, 0},
{ 8934, 0},
{ 8850, 0},
{ 8765, 0},
{ 8680, 0},
{ 8594, 0},
{ 8509, 0},
{ 8423, 0},
{ 8336, 0},
{ 8249, 0},
{ 8162, 0},
{ 8075, 0},
{ 7988, 0},
{ 7900, 0},
{ 7811, 0},
{ 7723, 0},
{ 7634, 0},
{ 7545, 0},
{ 7456, 0},
{ 7366, 0},
{ 7276, 0},
{ 7186, 0},
{ 7095, 0},
{ 7005, 0},
{ 6914, 0},
{ 6822, 0},
{ 6731, 0},
{ 6639, 0},
{ 6547, 0},
{ 6455, 0},
{ 6362, 0},
{ 6270, 0},
{ 6177, 0},
{ 6083, 0},
{ 5990, 0},
{ 5896, 0},
{ 5802, 0},
{ 5708, 0},
{ 5614, 0},
{ 5519, 0},
{ 5425, 0},
{ 5330, 0},
{ 5234, 0},
{ 5139, 0},
{ 5044, 0},
{ 4948, 0},
{ 4852, 0},
{ 4756, 0},
{ 4659, 0},
{ 4563, 0},
{ 4466, 0},
{ 4370, 0},
{ 4273, 0},
{ 4175, 0},
{ 4078, 0},
{ 3981, 0},
{ 3883, 0},
{ 3785, 0},
{ 3688, 0},
{ 3590, 0},
{ 3491, 0},
{ 3393, 0},
{ 3295, 0},
{ 3196, 0},
{ 3098, 0},
{ 2999, 0},
{ 2900, 0},
{ 2801, 0},
{ 2702, 0},
{ 2603, 0},
{ 2503, 0},
{ 2404, 0},
{ 2304, 0},
{ 2205, 0},
{ 2105, 0},
{ 2005, 0},
{ 1906, 0},
{ 1806, 0},
{ 1706, 0},
{ 1606, 0},
{ 1506, 0},
{ 1406, 0},
{ 1305, 0},
{ 1205, 0},
{ 1105, 0},
{ 1005, 0},
{ 904, 0},
{ 804, 0},
{ 703, 0},
{ 603, 0},
{ 503, 0},
{ 402, 0},
{ 302, 0},
{ 201, 0},
{ 101, 0},
{ 0, 16383},
{ -101, 0},
{ -201, 0},
{ -302, 0},
{ -402, 0},
{ -503, 0},
{ -603, 0},
{ -703, 0},
{ -804, 0},
{ -904, 0},
{ -1005, 0},
{ -1105, 0},
{ -1205, 0},
{ -1305, 0},
{ -1406, 0},
{ -1506, 0},
{ -1606, 0},
{ -1706, 0},
{ -1806, 0},
{ -1906, 0},
{ -2005, 0},
{ -2105, 0},
{ -2205, 0},
{ -2304, 0},
{ -2404, 0},
{ -2503, 0},
{ -2603, 0},
{ -2702, 0},
{ -2801, 0},
{ -2900, 0},
{ -2999, 0},
{ -3098, 0},
{ -3196, 0},
{ -3295, 0},
{ -3393, 0},
{ -3491, 0},
{ -3590, 0},
{ -3688, 0},
{ -3785, 0},
{ -3883, 0},
{ -3981, 0},
{ -4078, 0},
{ -4175, 0},
{ -4273, 0},
{ -4370, 0},
{ -4466, 0},
{ -4563, 0},
{ -4659, 0},
{ -4756, 0},
{ -4852, 0},
{ -4948, 0},
{ -5044, 0},
{ -5139, 0},
{ -5234, 0},
{ -5330, 0},
{ -5425, 0},
{ -5519, 0},
{ -5614, 0},
{ -5708, 0},
{ -5802, 0},
{ -5896, 0},
{ -5990, 0},
{ -6083, 0},
{ -6177, 0},
{ -6270, 0},
{ -6362, 0},
{ -6455, 0},
{ -6547, 0},
{ -6639, 0},
{ -6731, 0},
{ -6822, 0},
{ -6914, 0},
{ -7005, 0},
{ -7095, 0},
{ -7186, 0},
{ -7276, 0},
{ -7366, 0},
{ -7456, 0},
{ -7545, 0},
{ -7634, 0},
{ -7723, 0},
{ -7811, 0},
{ -7900, 0},
{ -7988, 0},
{ -8075, 0},
{ -8162, 0},
{ -8249, 0},
{ -8336, 0},
{ -8423, 0},
{ -8509, 0},
{ -8594, 0},
{ -8680, 0},
{ -8765, 0},
{ -8850, 0},
{ -8934, 0},
{ -9018, 0},
{ -9102, 0},
{ -9185, 0},
{ -9268, 0},
{ -9351, 0},
{ -9433, 0},
{ -9515, 0},
{ -9597, 0},
{ -9678, 0},
{ -9759, 0},
{ -9840, 0},
{ -9920, 0},
{-10000, 0},
{-10079, 0},
{-10158, 0},
{-10237, 0},
{-10315, 0},
{-10393, 0},
{-10471, 0},
{-10548, 0},
{-10625, 0},
{-10701, 0},
{-10777, 0},
{-10852, 0},
{-10927, 0},
{-11002, 0},
{-11076, 0},
{-11150, 0},
{-11224, 0},
{-11297, 0},
{-11369, 0},
{-11441, 0},
{-11513, 0},
{-11585, 0},
{-11655, 0},
{-11726, 0},
{-11796, 0},
{-11865, 0},
{-11934, 0},
{-12003, 0},
{-12071, 0},
{-12139, 0},
{-12206, 0},
{-12273, 0},
{-12339, 0},
{-12405, 0},
{-12471, 0},
{-12536, 0},
{-12600, 0},
{-12664, 0},
{-12728, 0},
{-12791, 0},
{-12853, 0},
{-12915, 0},
{-12977, 0},
{-13038, 0},
{-13099, 0},
{-13159, 0},
{-13219, 0},
{-13278, 0},
{-13336, 0},
{-13394, 0},
{-13452, 0},
{-13509, 0},
{-13566, 0},
{-13622, 0},
{-13678, 0},
{-13733, 0},
{-13787, 0},
{-13841, 0},
{-13895, 0},
{-13948, 0},
{-14000, 0},
{-14052, 0},
{-14104, 0},
{-14154, 0},
{-14205, 0},
{-14255, 0},
{-14304, 0},
{-14353, 0},
{-14401, 0},
{-14449, 0},
{-14496, 0},
{-14542, 0},
{-14588, 0},
{-14634, 0},
{-14679, 0},
{-14723, 0},
{-14767, 0},
{-14810, 0},
{-14853, 0},
{-14895, 0},
{-14936, 0},
{-14977, 0},
{-15018, 0},
{-15058, 0},
{-15097, 0},
{-15136, 0},
{-15174, 0},
{-15212, 0},
{-15249, 0},
{-15285, 0},
{-15321, 0},
{-15356, 0},
{-15391, 0},
{-15425, 0},
{-15459, 0},
{-15492, 0},
{-15524, 0},
{-15556, 0},
{-15587, 0},
{-15618, 0},
{-15648, 0},
{-15678, 0},
{-15706, 0},
{-15735, 0},
{-15762, 0},
{-15790, 0},
{-15816, 0},
{-15842, 0},
{-15867, 0},
{-15892, 0},
{-15916, 0},
{-15940, 0},
{-15963, 0},
{-15985, 0},
{-16007, 0},
{-16028, 0},
{-16048, 0},
{-16068, 0},
{-16088, 0},
{-16106, 0},
{-16124, 0},
{-16142, 0},
{-16159, 0},
{-16175, 0},
{-16191, 0},
{-16206, 0},
{-16220, 0},
{-16234, 0},
{-16247, 0},
{-16260, 0},
{-16272, 0},
{-16283, 0},
{-16294, 0},
{-16304, 0},
{-16314, 0},
{-16323, 0},
{-16331, 0},
{-16339, 0},
{-16346, 0},
{-16352, 0},
{-16358, 0},
{-16363, 0},
{-16368, 0},
{-16372, 0},
{-16375, 0},
{-16378, 0},
{-16380, 0},
{-16382, 0},
{-16383, 0},
{-16383, 0},
{-16383, 0},
{-16382, 0},
{-16380, 0},
{-16378, 0},
{-16375, 0},
{-16372, 0},
{-16368, 0},
{-16363, 0},
{-16358, 0},
{-16352, 0},
{-16346, 0},
{-16339, 0},
{-16331, 0},
{-16323, 0},
{-16314, 0},
{-16304, 0},
{-16294, 0},
{-16283, 0},
{-16272, 0},
{-16260, 0},
{-16247, 0},
{-16234, 0},
{-16220, 0},
{-16206, 0},
{-16191, 0},
{-16175, 0},
{-16159, 0},
{-16142, 0},
{-16124, 0},
{-16106, 0},
{-16088, 0},
{-16068, 0},
{-16048, 0},
{-16028, 0},
{-16007, 0},
{-15985, 0},
{-15963, 0},
{-15940, 0},
{-15916, 0},
{-15892, 0},
{-15867, 0},
{-15842, 0},
{-15816, 0},
{-15790, 0},
{-15762, 0},
{-15735, 0},
{-15706, 0},
{-15678, 0},
{-15648, 0},
{-15618, 0},
{-15587, 0},
{-15556, 0},
{-15524, 0},
{-15492, 0},
{-15459, 0},
{-15425, 0},
{-15391, 0},
{-15356, 0},
{-15321, 0},
{-15285, 0},
{-15249, 0},
{-15212, 0},
{-15174, 0},
{-15136, 0},
{-15097, 0},
{-15058, 0},
{-15018, 0},
{-14977, 0},
{-14936, 0},
{-14895, 0},
{-14853, 0},
{-14810, 0},
{-14767, 0},
{-14723, 0},
{-14679, 0},
{-14634, 0},
{-14588, 0},
{-14542, 0},
{-14496, 0},
{-14449, 0},
{-14401, 0},
{-14353, 0},
{-14304, 0},
{-14255, 0},
{-14205, 0},
{-14154, 0},
{-14104, 0},
{-14052, 0},
{-14000, 0},
{-13948, 0},
{-13895, 0},
{-13841, 0},
{-13787, 0},
{-13733, 0},
{-13678, 0},
{-13622, 0},
{-13566, 0},
{-13509, 0},
{-13452, 0},
{-13394, 0},
{-13336, 0},
{-13278, 0},
{-13219, 0},
{-13159, 0},
{-13099, 0},
{-13038, 0},
{-12977, 0},
{-12915, 0},
{-12853, 0},
{-12791, 0},
{-12728, 0},
{-12664, 0},
{-12600, 0},
{-12536, 0},
{-12471, 0},
{-12405, 0},
{-12339, 0},
{-12273, 0},
{-12206, 0},
{-12139, 0},
{-12071, 0},
{-12003, 0},
{-11934, 0},
{-11865, 0},
{-11796, 0},
{-11726, 0},
{-11655, 0},
{-11585, 0},
{-11513, 0},
{-11441, 0},
{-11369, 0},
{-11297, 0},
{-11224, 0},
{-11150, 0},
{-11076, 0},
{-11002, 0},
{-10927, 0},
{-10852, 0},
{-10777, 0},
{-10701, 0},
{-10625, 0},
{-10548, 0},
{-10471, 0},
{-10393, 0},
{-10315, 0},
{-10237, 0},
{-10158, 0},
{-10079, 0},
{-10000, 0},
{ -9920, 0},
{ -9840, 0},
{ -9759, 0},
{ -9678, 0},
{ -9597, 0},
{ -9515, 0},
{ -9433, 0},
{ -9351, 0},
{ -9268, 0},
{ -9185, 0},
{ -9102, 0},
{ -9018, 0},
{ -8934, 0},
{ -8850, 0},
{ -8765, 0},
{ -8680, 0},
{ -8594, 0},
{ -8509, 0},
{ -8423, 0},
{ -8336, 0},
{ -8249, 0},
{ -8162, 0},
{ -8075, 0},
{ -7988, 0},
{ -7900, 0},
{ -7811, 0},
{ -7723, 0},
{ -7634, 0},
{ -7545, 0},
{ -7456, 0},
{ -7366, 0},
{ -7276, 0},
{ -7186, 0},
{ -7095, 0},
{ -7005, 0},
{ -6914, 0},
{ -6822, 0},
{ -6731, 0},
{ -6639, 0},
{ -6547, 0},
{ -6455, 0},
{ -6362, 0},
{ -6270, 0},
{ -6177, 0},
{ -6083, 0},
{ -5990, 0},
{ -5896, 0},
{ -5802, 0},
{ -5708, 0},
{ -5614, 0},
{ -5519, 0},
{ -5425, 0},
{ -5330, 0},
{ -5234, 0},
{ -5139, 0},
{ -5044, 0},
{ -4948, 0},
{ -4852, 0},
{ -4756, 0},
{ -4659, 0},
{ -4563, 0},
{ -4466, 0},
{ -4370, 0},
{ -4273, 0},
{ -4175, 0},
{ -4078, 0},
{ -3981, 0},
{ -3883, 0},
{ -3785, 0},
{ -3688, 0},
{ -3590, 0},
{ -3491, 0},
{ -3393, 0},
{ -3295, 0},
{ -3196, 0},
{ -3098, 0},
{ -2999, 0},
{ -2900, 0},
{ -2801, 0},
{ -2702, 0},
{ -2603, 0},
{ -2503, 0},
{ -2404, 0},
{ -2304, 0},
{ -2205, 0},
{ -2105, 0},
{ -2005, 0},
{ -1906, 0},
{ -1806, 0},
{ -1706, 0},
{ -1606, 0},
{ -1506, 0},
{ -1406, 0},
{ -1305, 0},
{ -1205, 0},
{ -1105, 0},
{ -1005, 0},
{ -904, 0},
{ -804, 0},
{ -703, 0},
{ -603, 0},
{ -503, 0},
{ -402, 0},
{ -302, 0},
{ -201, 0},
{ -101, 0},
{ 0, 16383},
{ 101, 0},
{ 201, 0},
{ 302, 0},
{ 402, 0},
{ 503, 0},
{ 603, 0},
{ 703, 0},
{ 804, 0},
{ 904, 0},
{ 1005, 0},
{ 1105, 0},
{ 1205, 0},
{ 1305, 0},
{ 1406, 0},
{ 1506, 0},
{ 1606, 0},
{ 1706, 0},
{ 1806, 0},
{ 1906, 0},
{ 2005, 0},
{ 2105, 0},
{ 2205, 0},
{ 2304, 0},
{ 2404, 0},
{ 2503, 0},
{ 2603, 0},
{ 2702, 0},
{ 2801, 0},
{ 2900, 0},
{ 2999, 0},
{ 3098, 0},
{ 3196, 0},
{ 3295, 0},
{ 3393, 0},
{ 3491, 0},
{ 3590, 0},
{ 3688, 0},
{ 3785, 0},
{ 3883, 0},
{ 3981, 0},
{ 4078, 0},
{ 4175, 0},
{ 4273, 0},
{ 4370, 0},
{ 4466, 0},
{ 4563, 0},
{ 4659, 0},
{ 4756, 0},
{ 4852, 0},
{ 4948, 0},
{ 5044, 0},
{ 5139, 0},
{ 5234, 0},
{ 5330, 0},
{ 5425, 0},
{ 5519, 0},
{ 5614, 0},
{ 5708, 0},
{ 5802, 0},
{ 5896, 0},
{ 5990, 0},
{ 6083, 0},
{ 6177, 0},
{ 6270, 0},
{ 6362, 0},
{ 6455, 0},
{ 6547, 0},
{ 6639, 0},
{ 6731, 0},
{ 6822, 0},
{ 6914, 0},
{ 7005, 0},
{ 7095, 0},
{ 7186, 0},
{ 7276, 0},
{ 7366, 0},
{ 7456, 0},
{ 7545, 0},
{ 7634, 0},
{ 7723, 0},
{ 7811, 0},
{ 7900, 0},
{ 7988, 0},
{ 8075, 0},
{ 8162, 0},
{ 8249, 0},
{ 8336, 0},
{ 8423, 0},
{ 8509, 0},
{ 8594, 0},
{ 8680, 0},
{ 8765, 0},
{ 8850, 0},
{ 8934, 0},
{ 9018, 0},
{ 9102, 0},
{ 9185, 0},
{ 9268, 0},
{ 9351, 0},
{ 9433, 0},
{ 9515, 0},
{ 9597, 0},
{ 9678, 0},
{ 9759, 0},
{ 9840, 0},
{ 9920, 0},
{ 10000, 0},
{ 10079, 0},
{ 10158, 0},
{ 10237, 0},
{ 10315, 0},
{ 10393, 0},
{ 10471, 0},
{ 10548, 0},
{ 10625, 0},
{ 10701, 0},
{ 10777, 0},
{ 10852, 0},
{ 10927, 0},
{ 11002, 0},
{ 11076, 0},
{ 11150, 0},
{ 11224, 0},
{ 11297, 0},
{ 11369, 0},
{ 11441, 0},
{ 11513, 0},
{ 11585, 0},
{ 11655, 0},
{ 11726, 0},
{ 11796, 0},
{ 11865, 0},
{ 11934, 0},
{ 12003, 0},
{ 12071, 0},
{ 12139, 0},
{ 12206, 0},
{ 12273, 0},
{ 12339, 0},
{ 12405, 0},
{ 12471, 0},
{ 12536, 0},
{ 12600, 0},
{ 12664, 0},
{ 12728, 0},
{ 12791, 0},
{ 12853, 0},
{ 12915, 0},
{ 12977, 0},
{ 13038, 0},
{ 13099, 0},
{ 13159, 0},
{ 13219, 0},
{ 13278, 0},
{ 13336, 0},
{ 13394, 0},
{ 13452, 0},
{ 13509, 0},
{ 13566, 0},
{ 13622, 0},
{ 13678, 0},
{ 13733, 0},
{ 13787, 0},
{ 13841, 0},
{ 13895, 0},
{ 13948, 0},
{ 14000, 0},
{ 14052, 0},
{ 14104, 0},
{ 14154, 0},
{ 14205, 0},
{ 14255, 0},
{ 14304, 0},
{ 14353, 0},
{ 14401, 0},
{ 14449, 0},
{ 14496, 0},
{ 14542, 0},
{ 14588, 0},
{ 14634, 0},
{ 14679, 0},
{ 14723, 0},
{ 14767, 0},
{ 14810, 0},
{ 14853, 0},
{ 14895, 0},
{ 14936, 0},
{ 14977, 0},
{ 15018, 0},
{ 15058, 0},
{ 15097, 0},
{ 15136, 0},
{ 15174, 0},
{ 15212, 0},
{ 15249, 0},
{ 15285, 0},
{ 15321, 0},
{ 15356, 0},
{ 15391, 0},
{ 15425, 0},
{ 15459, 0},
{ 15492, 0},
{ 15524, 0},
{ 15556, 0},
{ 15587, 0},
{ 15618, 0},
{ 15648, 0},
{ 15678, 0},
{ 15706, 0},
{ 15735, 0},
{ 15762, 0},
{ 15790, 0},
{ 15816, 0},
{ 15842, 0},
{ 15867, 0},
{ 15892, 0},
{ 15916, 0},
{ 15940, 0},
{ 15963, 0},
{ 15985, 0},
{ 16007, 0},
{ 16028, 0},
{ 16048, 0},
{ 16068, 0},
{ 16088, 0},
{ 16106, 0},
{ 16124, 0},
{ 16142, 0},
{ 16159, 0},
{ 16175, 0},
{ 16191, 0},
{ 16206, 0},
{ 16220, 0},
{ 16234, 0},
{ 16247, 0},
{ 16260, 0},
{ 16272, 0},
{ 16283, 0},
{ 16294, 0},
{ 16304, 0},
{ 16314, 0},
{ 16323, 0},
{ 16331, 0},
{ 16339, 0},
{ 16346, 0},
{ 16352, 0},
{ 16358, 0},
{ 16363, 0},
{ 16368, 0},
{ 16372, 0},
{ 16375, 0},
{ 16378, 0},
{ 16380, 0},
{ 16382, 0},
{ 16383, 0},
{ 16383, 0},
{ 16383, 0},
{ 16382, 0},
{ 16380, 0},
{ 16378, 0},
{ 16375, 0},
{ 16372, 0},
{ 16368, 0},
{ 16363, 0},
{ 16358, 0},
{ 16352, 0},
{ 16346, 0},
{ 16339, 0},
{ 16331, 0},
{ 16323, 0},
{ 16314, 0},
{ 16304, 0},
{ 16294, 0},
{ 16283, 0},
{ 16272, 0},
{ 16260, 0},
{ 16247, 0},
{ 16234, 0},
{ 16220, 0},
{ 16206, 0},
{ 16191, 0},
{ 16175, 0},
{ 16159, 0},
{ 16142, 0},
{ 16124, 0},
{ 16106, 0},
{ 16088, 0},
{ 16068, 0},
{ 16048, 0},
{ 16028, 0},
{ 16007, 0},
{ 15985, 0},
{ 15963, 0},
{ 15940, 0},
{ 15916, 0},
{ 15892, 0},
{ 15867, 0},
{ 15842, 0},
{ 15816, 0},
{ 15790, 0},
{ 15762, 0},
{ 15735, 0},
{ 15706, 0},
{ 15678, 0},
{ 15648, 0},
{ 15618, 0},
{ 15587, 0},
{ 15556, 0},
{ 15524, 0},
{ 15492, 0},
{ 15459, 0},
{ 15425, 0},
{ 15391, 0},
{ 15356, 0},
{ 15321, 0},
{ 15285, 0},
{ 15249, 0},
{ 15212, 0},
{ 15174, 0},
{ 15136, 0},
{ 15097, 0},
{ 15058, 0},
{ 15018, 0},
{ 14977, 0},
{ 14936, 0},
{ 14895, 0},
{ 14853, 0},
{ 14810, 0},
{ 14767, 0},
{ 14723, 0},
{ 14679, 0},
{ 14634, 0},
{ 14588, 0},
{ 14542, 0},
{ 14496, 0},
{ 14449, 0},
{ 14401, 0},
{ 14353, 0},
{ 14304, 0},
{ 14255, 0},
{ 14205, 0},
{ 14154, 0},
{ 14104, 0},
{ 14052, 0},
{ 14000, 0},
{ 13948, 0},
{ 13895, 0},
{ 13841, 0},
{ 13787, 0},
{ 13733, 0},
{ 13678, 0},
{ 13622, 0},
{ 13566, 0},
{ 13509, 0},
{ 13452, 0},
{ 13394, 0},
{ 13336, 0},
{ 13278, 0},
{ 13219, 0},
{ 13159, 0},
{ 13099, 0},
{ 13038, 0},
{ 12977, 0},
{ 12915, 0},
{ 12853, 0},
{ 12791, 0},
{ 12728, 0},
{ 12664, 0},
{ 12600, 0},
{ 12536, 0},
{ 12471, 0},
{ 12405, 0},
{ 12339, 0},
{ 12273, 0},
{ 12206, 0},
{ 12139, 0},
{ 12071, 0},
{ 12003, 0},
{ 11934, 0},
{ 11865, 0},
{ 11796, 0},
{ 11726, 0},
{ 11655, 0},
{ 11585, 0},
{ 11513, 0},
{ 11441, 0},
{ 11369, 0},
{ 11297, 0},
{ 11224, 0},
{ 11150, 0},
{ 11076, 0},
{ 11002, 0},
{ 10927, 0},
{ 10852, 0},
{ 10777, 0},
{ 10701, 0},
{ 10625, 0},
{ 10548, 0},
{ 10471, 0},
{ 10393, 0},
{ 10315, 0},
{ 10237, 0},
{ 10158, 0},
{ 10079, 0},
{ 10000, 0},
{ 9920, 0},
{ 9840, 0},
{ 9759, 0},
{ 9678, 0},
{ 9597, 0},
{ 9515, 0},
{ 9433, 0},
{ 9351, 0},
{ 9268, 0},
{ 9185, 0},
{ 9102, 0},
{ 9018, 0},
{ 8934, 0},
{ 8850, 0},
{ 8765, 0},
{ 8680, 0},
{ 8594, 0},
{ 8509, 0},
{ 8423, 0},
{ 8336, 0},
{ 8249, 0},
{ 8162, 0},
{ 8075, 0},
{ 7988, 0},
{ 7900, 0},
{ 7811, 0},
{ 7723, 0},
{ 7634, 0},
{ 7545, 0},
{ 7456, 0},
{ 7366, 0},
{ 7276, 0},
{ 7186, 0},
{ 7095, 0},
{ 7005, 0},
{ 6914, 0},
{ 6822, 0},
{ 6731, 0},
{ 6639, 0},
{ 6547, 0},
{ 6455, 0},
{ 6362, 0},
{ 6270, 0},
{ 6177, 0},
{ 6083, 0},
{ 5990, 0},
{ 5896, 0},
{ 5802, 0},
{ 5708, 0},
{ 5614, 0},
{ 5519, 0},
{ 5425, 0},
{ 5330, 0},
{ 5234, 0},
{ 5139, 0},
{ 5044, 0},
{ 4948, 0},
{ 4852, 0},
{ 4756, 0},
{ 4659, 0},
{ 4563, 0},
{ 4466, 0},
{ 4370, 0},
{ 4273, 0},
{ 4175, 0},
{ 4078, 0},
{ 3981, 0},
{ 3883, 0},
{ 3785, 0},
{ 3688, 0},
{ 3590, 0},
{ 3491, 0},
{ 3393, 0},
{ 3295, 0},
{ 3196, 0},
{ 3098, 0},
{ 2999, 0},
{ 2900, 0},
{ 2801, 0},
{ 2702, 0},
{ 2603, 0},
{ 2503, 0},
{ 2404, 0},
{ 2304, 0},
{ 2205, 0},
{ 2105, 0},
{ 2005, 0},
{ 1906, 0},
{ 1806, 0},
{ 1706, 0},
{ 1606, 0},
{ 1506, 0},
{ 1406, 0},
{ 1305, 0},
{ 1205, 0},
{ 1105, 0},
{ 1005, 0},
{ 904, 0},
{ 804, 0},
{ 703, 0},
{ 603, 0},
{ 503, 0},
{ 402, 0},
{ 302, 0},
{ 201, 0},
{ 101, 0},
{ 0, 16383},
{ -101, 0},
{ -201, 0},
{ -302, 0},
{ -402, 0},
{ -503, 0},
{ -603, 0},
{ -703, 0},
{ -804, 0},
{ -904, 0},
{ -1005, 0},
{ -1105, 0},
{ -1205, 0},
{ -1305, 0},
{ -1406, 0},
{ -1506, 0},
{ -1606, 0},
{ -1706, 0},
{ -1806, 0},
{ -1906, 0},
{ -2005, 0},
{ -2105, 0},
{ -2205, 0},
{ -2304, 0},
{ -2404, 0},
{ -2503, 0},
{ -2603, 0},
{ -2702, 0},
{ -2801, 0},
{ -2900, 0},
{ -2999, 0},
{ -3098, 0},
{ -3196, 0},
{ -3295, 0},
{ -3393, 0},
{ -3491, 0},
{ -3590, 0},
{ -3688, 0},
{ -3785, 0},
{ -3883, 0},
{ -3981, 0},
{ -4078, 0},
{ -4175, 0},
{ -4273, 0},
{ -4370, 0},
{ -4466, 0},
{ -4563, 0},
{ -4659, 0},
{ -4756, 0},
{ -4852, 0},
{ -4948, 0},
{ -5044, 0},
{ -5139, 0},
{ -5234, 0},
{ -5330, 0},
{ -5425, 0},
{ -5519, 0},
{ -5614, 0},
{ -5708, 0},
{ -5802, 0},
{ -5896, 0},
{ -5990, 0},
{ -6083, 0},
{ -6177, 0},
{ -6270, 0},
{ -6362, 0},
{ -6455, 0},
{ -6547, 0},
{ -6639, 0},
{ -6731, 0},
{ -6822, 0},
{ -6914, 0},
{ -7005, 0},
{ -7095, 0},
{ -7186, 0},
{ -7276, 0},
{ -7366, 0},
{ -7456, 0},
{ -7545, 0},
{ -7634, 0},
{ -7723, 0},
{ -7811, 0},
{ -7900, 0},
{ -7988, 0},
{ -8075, 0},
{ -8162, 0},
{ -8249, 0},
{ -8336, 0},
{ -8423, 0},
{ -8509, 0},
{ -8594, 0},
{ -8680, 0},
{ -8765, 0},
{ -8850, 0},
{ -8934, 0},
{ -9018, 0},
{ -9102, 0},
{ -9185, 0},
{ -9268, 0},
{ -9351, 0},
{ -9433, 0},
{ -9515, 0},
{ -9597, 0},
{ -9678, 0},
{ -9759, 0},
{ -9840, 0},
{ -9920, 0},
{-10000, 0},
{-10079, 0},
{-10158, 0},
{-10237, 0},
{-10315, 0},
{-10393, 0},
{-10471, 0},
{-10548, 0},
{-10625, 0},
{-10701, 0},
{-10777, 0},
{-10852, 0},
{-10927, 0},
{-11002, 0},
{-11076, 0},
{-11150, 0},
{-11224, 0},
{-11297, 0},
{-11369, 0},
{-11441, 0},
{-11513, 0},
{-11585, 0},
{-11655, 0},
{-11726, 0},
{-11796, 0},
{-11865, 0},
{-11934, 0},
{-12003, 0},
{-12071, 0},
{-12139, 0},
{-12206, 0},
{-12273, 0},
{-12339, 0},
{-12405, 0},
{-12471, 0},
{-12536, 0},
{-12600, 0},
{-12664, 0},
{-12728, 0},
{-12791, 0},
{-12853, 0},
{-12915, 0},
{-12977, 0},
{-13038, 0},
{-13099, 0},
{-13159, 0},
{-13219, 0},
{-13278, 0},
{-13336, 0},
{-13394, 0},
{-13452, 0},
{-13509, 0},
{-13566, 0},
{-13622, 0},
{-13678, 0},
{-13733, 0},
{-13787, 0},
{-13841, 0},
{-13895, 0},
{-13948, 0},
{-14000, 0},
{-14052, 0},
{-14104, 0},
{-14154, 0},
{-14205, 0},
{-14255, 0},
{-14304, 0},
{-14353, 0},
{-14401, 0},
{-14449, 0},
{-14496, 0},
{-14542, 0},
{-14588, 0},
{-14634, 0},
{-14679, 0},
{-14723, 0},
{-14767, 0},
{-14810, 0},
{-14853, 0},
{-14895, 0},
{-14936, 0},
{-14977, 0},
{-15018, 0},
{-15058, 0},
{-15097, 0},
{-15136, 0},
{-15174, 0},
{-15212, 0},
{-15249, 0},
{-15285, 0},
{-15321, 0},
{-15356, 0},
{-15391, 0},
{-15425, 0},
{-15459, 0},
{-15492, 0},
{-15524, 0},
{-15556, 0},
{-15587, 0},
{-15618, 0},
{-15648, 0},
{-15678, 0},
{-15706, 0},
{-15735, 0},
{-15762, 0},
{-15790, 0},
{-15816, 0},
{-15842, 0},
{-15867, 0},
{-15892, 0},
{-15916, 0},
{-15940, 0},
{-15963, 0},
{-15985, 0},
{-16007, 0},
{-16028, 0},
{-16048, 0},
{-16068, 0},
{-16088, 0},
{-16106, 0},
{-16124, 0},
{-16142, 0},
{-16159, 0},
{-16175, 0},
{-16191, 0},
{-16206, 0},
{-16220, 0},
{-16234, 0},
{-16247, 0},
{-16260, 0},
{-16272, 0},
{-16283, 0},
{-16294, 0},
{-16304, 0},
{-16314, 0},
{-16323, 0},
{-16331, 0},
{-16339, 0},
{-16346, 0},
{-16352, 0},
{-16358, 0},
{-16363, 0},
{-16368, 0},
{-16372, 0},
{-16375, 0},
{-16378, 0},
{-16380, 0},
{-16382, 0},
{-16383, 0},
{-16383, 0},
{-16383, 0},
{-16382, 0},
{-16380, 0},
{-16378, 0},
{-16375, 0},
{-16372, 0},
{-16368, 0},
{-16363, 0},
{-16358, 0},
{-16352, 0},
{-16346, 0},
{-16339, 0},
{-16331, 0},
{-16323, 0},
{-16314, 0},
{-16304, 0},
{-16294, 0},
{-16283, 0},
{-16272, 0},
{-16260, 0},
{-16247, 0},
{-16234, 0},
{-16220, 0},
{-16206, 0},
{-16191, 0},
{-16175, 0},
{-16159, 0},
{-16142, 0},
{-16124, 0},
{-16106, 0},
{-16088, 0},
{-16068, 0},
{-16048, 0},
{-16028, 0},
{-16007, 0},
{-15985, 0},
{-15963, 0},
{-15940, 0},
{-15916, 0},
{-15892, 0},
{-15867, 0},
{-15842, 0},
{-15816, 0},
{-15790, 0},
{-15762, 0},
{-15735, 0},
{-15706, 0},
{-15678, 0},
{-15648, 0},
{-15618, 0},
{-15587, 0},
{-15556, 0},
{-15524, 0},
{-15492, 0},
{-15459, 0},
{-15425, 0},
{-15391, 0},
{-15356, 0},
{-15321, 0},
{-15285, 0},
{-15249, 0},
{-15212, 0},
{-15174, 0},
{-15136, 0},
{-15097, 0},
{-15058, 0},
{-15018, 0},
{-14977, 0},
{-14936, 0},
{-14895, 0},
{-14853, 0},
{-14810, 0},
{-14767, 0},
{-14723, 0},
{-14679, 0},
{-14634, 0},
{-14588, 0},
{-14542, 0},
{-14496, 0},
{-14449, 0},
{-14401, 0},
{-14353, 0},
{-14304, 0},
{-14255, 0},
{-14205, 0},
{-14154, 0},
{-14104, 0},
{-14052, 0},
{-14000, 0},
{-13948, 0},
{-13895, 0},
{-13841, 0},
{-13787, 0},
{-13733, 0},
{-13678, 0},
{-13622, 0},
{-13566, 0},
{-13509, 0},
{-13452, 0},
{-13394, 0},
{-13336, 0},
{-13278, 0},
{-13219, 0},
{-13159, 0},
{-13099, 0},
{-13038, 0},
{-12977, 0},
{-12915, 0},
{-12853, 0},
{-12791, 0},
{-12728, 0},
{-12664, 0},
{-12600, 0},
{-12536, 0},
{-12471, 0},
{-12405, 0},
{-12339, 0},
{-12273, 0},
{-12206, 0},
{-12139, 0},
{-12071, 0},
{-12003, 0},
{-11934, 0},
{-11865, 0},
{-11796, 0},
{-11726, 0},
{-11655, 0},
{-11585, 0},
{-11513, 0},
{-11441, 0},
{-11369, 0},
{-11297, 0},
{-11224, 0},
{-11150, 0},
{-11076, 0},
{-11002, 0},
{-10927, 0},
{-10852, 0},
{-10777, 0},
{-10701, 0},
{-10625, 0},
{-10548, 0},
{-10471, 0},
{-10393, 0},
{-10315, 0},
{-10237, 0},
{-10158, 0},
{-10079, 0},
{-10000, 0},
{ -9920, 0},
{ -9840, 0},
{ -9759, 0},
{ -9678, 0},
{ -9597, 0},
{ -9515, 0},
{ -9433, 0},
{ -9351, 0},
{ -9268, 0},
{ -9185, 0},
{ -9102, 0},
{ -9018, 0},
{ -8934, 0},
{ -8850, 0},
{ -8765, 0},
{ -8680, 0},
{ -8594, 0},
{ -8509, 0},
{ -8423, 0},
{ -8336, 0},
{ -8249, 0},
{ -8162, 0},
{ -8075, 0},
{ -7988, 0},
{ -7900, 0},
{ -7811, 0},
{ -7723, 0},
{ -7634, 0},
{ -7545, 0},
{ -7456, 0},
{ -7366, 0},
{ -7276, 0},
{ -7186, 0},
{ -7095, 0},
{ -7005, 0},
{ -6914, 0},
{ -6822, 0},
{ -6731, 0},
{ -6639, 0},
{ -6547, 0},
{ -6455, 0},
{ -6362, 0},
{ -6270, 0},
{ -6177, 0},
{ -6083, 0},
{ -5990, 0},
{ -5896, 0},
{ -5802, 0},
{ -5708, 0},
{ -5614, 0},
{ -5519, 0},
{ -5425, 0},
{ -5330, 0},
{ -5234, 0},
{ -5139, 0},
{ -5044, 0},
{ -4948, 0},
{ -4852, 0},
{ -4756, 0},
{ -4659, 0},
{ -4563, 0},
{ -4466, 0},
{ -4370, 0},
{ -4273, 0},
{ -4175, 0},
{ -4078, 0},
{ -3981, 0},
{ -3883, 0},
{ -3785, 0},
{ -3688, 0},
{ -3590, 0},
{ -3491, 0},
{ -3393, 0},
{ -3295, 0},
{ -3196, 0},
{ -3098, 0},
{ -2999, 0},
{ -2900, 0},
{ -2801, 0},
{ -2702, 0},
{ -2603, 0},
{ -2503, 0},
{ -2404, 0},
{ -2304, 0},
{ -2205, 0},
{ -2105, 0},
{ -2005, 0},
{ -1906, 0},
{ -1806, 0},
{ -1706, 0},
{ -1606, 0},
{ -1506, 0},
{ -1406, 0},
{ -1305, 0},
{ -1205, 0},
{ -1105, 0},
{ -1005, 0},
{ -904, 0},
{ -804, 0},
{ -703, 0},
{ -603, 0},
{ -503, 0},
{ -402, 0},
{ -302, 0},
{ -201, 0},
{ -101, 0},
{ 0, 16383},
{ 101, 0},
{ 201, 0},
{ 302, 0},
{ 402, 0},
{ 503, 0},
{ 603, 0},
{ 703, 0},
{ 804, 0},
{ 904, 0},
{ 1005, 0},
{ 1105, 0},
{ 1205, 0},
{ 1305, 0},
{ 1406, 0},
{ 1506, 0},
{ 1606, 0},
{ 1706, 0},
{ 1806, 0},
{ 1906, 0},
{ 2005, 0},
{ 2105, 0},
{ 2205, 0},
{ 2304, 0},
{ 2404, 0},
{ 2503, 0},
{ 2603, 0},
{ 2702, 0},
{ 2801, 0},
{ 2900, 0},
{ 2999, 0},
{ 3098, 0},
{ 3196, 0},
{ 3295, 0},
{ 3393, 0},
{ 3491, 0},
{ 3590, 0},
{ 3688, 0},
{ 3785, 0},
{ 3883, 0},
{ 3981, 0},
{ 4078, 0},
{ 4175, 0},
{ 4273, 0},
{ 4370, 0},
{ 4466, 0},
{ 4563, 0},
{ 4659, 0},
{ 4756, 0},
{ 4852, 0},
{ 4948, 0},
{ 5044, 0},
{ 5139, 0},
{ 5234, 0},
{ 5330, 0},
{ 5425, 0},
{ 5519, 0},
{ 5614, 0},
{ 5708, 0},
{ 5802, 0},
{ 5896, 0},
{ 5990, 0},
{ 6083, 0},
{ 6177, 0},
{ 6270, 0},
{ 6362, 0},
{ 6455, 0},
{ 6547, 0},
{ 6639, 0},
{ 6731, 0},
{ 6822, 0},
{ 6914, 0},
{ 7005, 0},
{ 7095, 0},
{ 7186, 0},
{ 7276, 0},
{ 7366, 0},
{ 7456, 0},
{ 7545, 0},
{ 7634, 0},
{ 7723, 0},
{ 7811, 0},
{ 7900, 0},
{ 7988, 0},
{ 8075, 0},
{ 8162, 0},
{ 8249, 0},
{ 8336, 0},
{ 8423, 0},
{ 8509, 0},
{ 8594, 0},
{ 8680, 0},
{ 8765, 0},
{ 8850, 0},
{ 8934, 0},
{ 9018, 0},
{ 9102, 0},
{ 9185, 0},
{ 9268, 0},
{ 9351, 0},
{ 9433, 0},
{ 9515, 0},
{ 9597, 0},
{ 9678, 0},
{ 9759, 0},
{ 9840, 0},
{ 9920, 0},
{ 10000, 0},
{ 10079, 0},
{ 10158, 0},
{ 10237, 0},
{ 10315, 0},
{ 10393, 0},
{ 10471, 0},
{ 10548, 0},
{ 10625, 0},
{ 10701, 0},
{ 10777, 0},
{ 10852, 0},
{ 10927, 0},
{ 11002, 0},
{ 11076, 0},
{ 11150, 0},
{ 11224, 0},
{ 11297, 0},
{ 11369, 0},
{ 11441, 0},
{ 11513, 0},
{ 11585, 0},
{ 11655, 0},
{ 11726, 0},
{ 11796, 0},
{ 11865, 0},
{ 11934, 0},
{ 12003, 0},
{ 12071, 0},
{ 12139, 0},
{ 12206, 0},
{ 12273, 0},
{ 12339, 0},
{ 12405, 0},
{ 12471, 0},
{ 12536, 0},
{ 12600, 0},
{ 12664, 0},
{ 12728, 0},
{ 12791, 0},
{ 12853, 0},
{ 12915, 0},
{ 12977, 0},
{ 13038, 0},
{ 13099, 0},
{ 13159, 0},
{ 13219, 0},
{ 13278, 0},
{ 13336, 0},
{ 13394, 0},
{ 13452, 0},
{ 13509, 0},
{ 13566, 0},
{ 13622, 0},
{ 13678, 0},
{ 13733, 0},
{ 13787, 0},
{ 13841, 0},
{ 13895, 0},
{ 13948, 0},
{ 14000, 0},
{ 14052, 0},
{ 14104, 0},
{ 14154, 0},
{ 14205, 0},
{ 14255, 0},
{ 14304, 0},
{ 14353, 0},
{ 14401, 0},
{ 14449, 0},
{ 14496, 0},
{ 14542, 0},
{ 14588, 0},
{ 14634, 0},
{ 14679, 0},
{ 14723, 0},
{ 14767, 0},
{ 14810, 0},
{ 14853, 0},
{ 14895, 0},
{ 14936, 0},
{ 14977, 0},
{ 15018, 0},
{ 15058, 0},
{ 15097, 0},
{ 15136, 0},
{ 15174, 0},
{ 15212, 0},
{ 15249, 0},
{ 15285, 0},
{ 15321, 0},
{ 15356, 0},
{ 15391, 0},
{ 15425, 0},
{ 15459, 0},
{ 15492, 0},
{ 15524, 0},
{ 15556, 0},
{ 15587, 0},
{ 15618, 0},
{ 15648, 0},
{ 15678, 0},
{ 15706, 0},
{ 15735, 0},
{ 15762, 0},
{ 15790, 0},
{ 15816, 0},
{ 15842, 0},
{ 15867, 0},
{ 15892, 0},
{ 15916, 0},
{ 15940, 0},
{ 15963, 0},
{ 15985, 0},
{ 16007, 0},
{ 16028, 0},
{ 16048, 0},
{ 16068, 0},
{ 16088, 0},
{ 16106, 0},
{ 16124, 0},
{ 16142, 0},
{ 16159, 0},
{ 16175, 0},
{ 16191, 0},
{ 16206, 0},
{ 16220, 0},
{ 16234, 0},
{ 16247, 0},
{ 16260, 0},
{ 16272, 0},
{ 16283, 0},
{ 16294, 0},
{ 16304, 0},
{ 16314, 0},
{ 16323, 0},
{ 16331, 0},
{ 16339, 0},
{ 16346, 0},
{ 16352, 0},
{ 16358, 0},
{ 16363, 0},
{ 16368, 0},
{ 16372, 0},
{ 16375, 0},
{ 16378, 0},
{ 16380, 0},
{ 16382, 0},
{ 16383, 0},
{ 16383, 0},
{ 16383, 0},
{ 16382, 0},
{ 16380, 0},
{ 16378, 0},
{ 16375, 0},
{ 16372, 0},
{ 16368, 0},
{ 16363, 0},
{ 16358, 0},
{ 16352, 0},
{ 16346, 0},
{ 16339, 0},
{ 16331, 0},
{ 16323, 0},
{ 16314, 0},
{ 16304, 0},
{ 16294, 0},
{ 16283, 0},
{ 16272, 0},
{ 16260, 0},
{ 16247, 0},
{ 16234, 0},
{ 16220, 0},
{ 16206, 0},
{ 16191, 0},
{ 16175, 0},
{ 16159, 0},
{ 16142, 0},
{ 16124, 0},
{ 16106, 0},
{ 16088, 0},
{ 16068, 0},
{ 16048, 0},
{ 16028, 0},
{ 16007, 0},
{ 15985, 0},
{ 15963, 0},
{ 15940, 0},
{ 15916, 0},
{ 15892, 0},
{ 15867, 0},
{ 15842, 0},
{ 15816, 0},
{ 15790, 0},
{ 15762, 0},
{ 15735, 0},
{ 15706, 0},
{ 15678, 0},
{ 15648, 0},
{ 15618, 0},
{ 15587, 0},
{ 15556, 0},
{ 15524, 0},
{ 15492, 0},
{ 15459, 0},
{ 15425, 0},
{ 15391, 0},
{ 15356, 0},
{ 15321, 0},
{ 15285, 0},
{ 15249, 0},
{ 15212, 0},
{ 15174, 0},
{ 15136, 0},
{ 15097, 0},
{ 15058, 0},
{ 15018, 0},
{ 14977, 0},
{ 14936, 0},
{ 14895, 0},
{ 14853, 0},
{ 14810, 0},
{ 14767, 0},
{ 14723, 0},
{ 14679, 0},
{ 14634, 0},
{ 14588, 0},
{ 14542, 0},
{ 14496, 0},
{ 14449, 0},
{ 14401, 0},
{ 14353, 0},
{ 14304, 0},
{ 14255, 0},
{ 14205, 0},
{ 14154, 0},
{ 14104, 0},
{ 14052, 0},
{ 14000, 0},
{ 13948, 0},
{ 13895, 0},
{ 13841, 0},
{ 13787, 0},
{ 13733, 0},
{ 13678, 0},
{ 13622, 0},
{ 13566, 0},
{ 13509, 0},
{ 13452, 0},
{ 13394, 0},
{ 13336, 0},
{ 13278, 0},
{ 13219, 0},
{ 13159, 0},
{ 13099, 0},
{ 13038, 0},
{ 12977, 0},
{ 12915, 0},
{ 12853, 0},
{ 12791, 0},
{ 12728, 0},
{ 12664, 0},
{ 12600, 0},
{ 12536, 0},
{ 12471, 0},
{ 12405, 0},
{ 12339, 0},
{ 12273, 0},
{ 12206, 0},
{ 12139, 0},
{ 12071, 0},
{ 12003, 0},
{ 11934, 0},
{ 11865, 0},
{ 11796, 0},
{ 11726, 0},
{ 11655, 0},
{ 11585, 0},
{ 11513, 0},
{ 11441, 0},
{ 11369, 0},
{ 11297, 0},
{ 11224, 0},
{ 11150, 0},
{ 11076, 0},
{ 11002, 0},
{ 10927, 0},
{ 10852, 0},
{ 10777, 0},
{ 10701, 0},
{ 10625, 0},
{ 10548, 0},
{ 10471, 0},
{ 10393, 0},
{ 10315, 0},
{ 10237, 0},
{ 10158, 0},
{ 10079, 0},
{ 10000, 0},
{ 9920, 0},
{ 9840, 0},
{ 9759, 0},
{ 9678, 0},
{ 9597, 0},
{ 9515, 0},
{ 9433, 0},
{ 9351, 0},
{ 9268, 0},
{ 9185, 0},
{ 9102, 0},
{ 9018, 0},
{ 8934, 0},
{ 8850, 0},
{ 8765, 0},
{ 8680, 0},
{ 8594, 0},
{ 8509, 0},
{ 8423, 0},
{ 8336, 0},
{ 8249, 0},
{ 8162, 0},
{ 8075, 0},
{ 7988, 0},
{ 7900, 0},
{ 7811, 0},
{ 7723, 0},
{ 7634, 0},
{ 7545, 0},
{ 7456, 0},
{ 7366, 0},
{ 7276, 0},
{ 7186, 0},
{ 7095, 0},
{ 7005, 0},
{ 6914, 0},
{ 6822, 0},
{ 6731, 0},
{ 6639, 0},
{ 6547, 0},
{ 6455, 0},
{ 6362, 0},
{ 6270, 0},
{ 6177, 0},
{ 6083, 0},
{ 5990, 0},
{ 5896, 0},
{ 5802, 0},
{ 5708, 0},
{ 5614, 0},
{ 5519, 0},
{ 5425, 0},
{ 5330, 0},
{ 5234, 0},
{ 5139, 0},
{ 5044, 0},
{ 4948, 0},
{ 4852, 0},
{ 4756, 0},
{ 4659, 0},
{ 4563, 0},
{ 4466, 0},
{ 4370, 0},
{ 4273, 0},
{ 4175, 0},
{ 4078, 0},
{ 3981, 0},
{ 3883, 0},
{ 3785, 0},
{ 3688, 0},
{ 3590, 0},
{ 3491, 0},
{ 3393, 0},
{ 3295, 0},
{ 3196, 0},
{ 3098, 0},
{ 2999, 0},
{ 2900, 0},
{ 2801, 0},
{ 2702, 0},
{ 2603, 0},
{ 2503, 0},
{ 2404, 0},
{ 2304, 0},
{ 2205, 0},
{ 2105, 0},
{ 2005, 0},
{ 1906, 0},
{ 1806, 0},
{ 1706, 0},
{ 1606, 0},
{ 1506, 0},
{ 1406, 0},
{ 1305, 0},
{ 1205, 0},
{ 1105, 0},
{ 1005, 0},
{ 904, 0},
{ 804, 0},
{ 703, 0},
{ 603, 0},
{ 503, 0},
{ 402, 0},
{ 302, 0},
{ 201, 0},
{ 101, 0},
{ 0, 16383},
{ -101, 0},
{ -201, 0},
{ -302, 0},
{ -402, 0},
{ -503, 0},
{ -603, 0},
{ -703, 0},
{ -804, 0},
{ -904, 0},
{ -1005, 0},
{ -1105, 0},
{ -1205, 0},
{ -1305, 0},
{ -1406, 0},
{ -1506, 0},
{ -1606, 0},
{ -1706, 0},
{ -1806, 0},
{ -1906, 0},
{ -2005, 0},
{ -2105, 0},
{ -2205, 0},
{ -2304, 0},
{ -2404, 0},
{ -2503, 0},
{ -2603, 0},
{ -2702, 0},
{ -2801, 0},
{ -2900, 0},
{ -2999, 0},
{ -3098, 0},
{ -3196, 0},
{ -3295, 0},
{ -3393, 0},
{ -3491, 0},
{ -3590, 0},
{ -3688, 0},
{ -3785, 0},
{ -3883, 0},
{ -3981, 0},
{ -4078, 0},
{ -4175, 0},
{ -4273, 0},
{ -4370, 0},
{ -4466, 0},
{ -4563, 0},
{ -4659, 0},
{ -4756, 0},
{ -4852, 0},
{ -4948, 0},
{ -5044, 0},
{ -5139, 0},
{ -5234, 0},
{ -5330, 0},
{ -5425, 0},
{ -5519, 0},
{ -5614, 0},
{ -5708, 0},
{ -5802, 0},
{ -5896, 0},
{ -5990, 0},
{ -6083, 0},
{ -6177, 0},
{ -6270, 0},
{ -6362, 0},
{ -6455, 0},
{ -6547, 0},
{ -6639, 0},
{ -6731, 0},
{ -6822, 0},
{ -6914, 0},
{ -7005, 0},
{ -7095, 0},
{ -7186, 0},
{ -7276, 0},
{ -7366, 0},
{ -7456, 0},
{ -7545, 0},
{ -7634, 0},
{ -7723, 0},
{ -7811, 0},
{ -7900, 0},
{ -7988, 0},
{ -8075, 0},
{ -8162, 0},
{ -8249, 0},
{ -8336, 0},
{ -8423, 0},
{ -8509, 0},
{ -8594, 0},
{ -8680, 0},
{ -8765, 0},
{ -8850, 0},
{ -8934, 0},
{ -9018, 0},
{ -9102, 0},
{ -9185, 0},
{ -9268, 0},
{ -9351, 0},
{ -9433, 0},
{ -9515, 0},
{ -9597, 0},
{ -9678, 0},
{ -9759, 0},
{ -9840, 0},
{ -9920, 0},
{-10000, 0},
{-10079, 0},
{-10158, 0},
{-10237, 0},
{-10315, 0},
{-10393, 0},
{-10471, 0},
{-10548, 0},
{-10625, 0},
{-10701, 0},
{-10777, 0},
{-10852, 0},
{-10927, 0},
{-11002, 0},
{-11076, 0},
{-11150, 0},
{-11224, 0},
{-11297, 0},
{-11369, 0},
{-11441, 0},
{-11513, 0},
{-11585, 0},
{-11655, 0},
{-11726, 0},
{-11796, 0},
{-11865, 0},
{-11934, 0},
{-12003, 0},
{-12071, 0},
{-12139, 0},
{-12206, 0},
{-12273, 0},
{-12339, 0},
{-12405, 0},
{-12471, 0},
{-12536, 0},
{-12600, 0},
{-12664, 0},
{-12728, 0},
{-12791, 0},
{-12853, 0},
{-12915, 0},
{-12977, 0},
{-13038, 0},
{-13099, 0},
{-13159, 0},
{-13219, 0},
{-13278, 0},
{-13336, 0},
{-13394, 0},
{-13452, 0},
{-13509, 0},
{-13566, 0},
{-13622, 0},
{-13678, 0},
{-13733, 0},
{-13787, 0},
{-13841, 0},
{-13895, 0},
{-13948, 0},
{-14000, 0},
{-14052, 0},
{-14104, 0},
{-14154, 0},
{-14205, 0},
{-14255, 0},
{-14304, 0},
{-14353, 0},
{-14401, 0},
{-14449, 0},
{-14496, 0},
{-14542, 0},
{-14588, 0},
{-14634, 0},
{-14679, 0},
{-14723, 0},
{-14767, 0},
{-14810, 0},
{-14853, 0},
{-14895, 0},
{-14936, 0},
{-14977, 0},
{-15018, 0},
{-15058, 0},
{-15097, 0},
{-15136, 0},
{-15174, 0},
{-15212, 0},
{-15249, 0},
{-15285, 0},
{-15321, 0},
{-15356, 0},
{-15391, 0},
{-15425, 0},
{-15459, 0},
{-15492, 0},
{-15524, 0},
{-15556, 0},
{-15587, 0},
{-15618, 0},
{-15648, 0},
{-15678, 0},
{-15706, 0},
{-15735, 0},
{-15762, 0},
{-15790, 0},
{-15816, 0},
{-15842, 0},
{-15867, 0},
{-15892, 0},
{-15916, 0},
{-15940, 0},
{-15963, 0},
{-15985, 0},
{-16007, 0},
{-16028, 0},
{-16048, 0},
{-16068, 0},
{-16088, 0},
{-16106, 0},
{-16124, 0},
{-16142, 0},
{-16159, 0},
{-16175, 0},
{-16191, 0},
{-16206, 0},
{-16220, 0},
{-16234, 0},
{-16247, 0},
{-16260, 0},
{-16272, 0},
{-16283, 0},
{-16294, 0},
{-16304, 0},
{-16314, 0},
{-16323, 0},
{-16331, 0},
{-16339, 0},
{-16346, 0},
{-16352, 0},
{-16358, 0},
{-16363, 0},
{-16368, 0},
{-16372, 0},
{-16375, 0},
{-16378, 0},
{-16380, 0},
{-16382, 0},
{-16383, 0},
{-16383, 0},
{-16383, 0},
{-16382, 0},
{-16380, 0},
{-16378, 0},
{-16375, 0},
{-16372, 0},
{-16368, 0},
{-16363, 0},
{-16358, 0},
{-16352, 0},
{-16346, 0},
{-16339, 0},
{-16331, 0},
{-16323, 0},
{-16314, 0},
{-16304, 0},
{-16294, 0},
{-16283, 0},
{-16272, 0},
{-16260, 0},
{-16247, 0},
{-16234, 0},
{-16220, 0},
{-16206, 0},
{-16191, 0},
{-16175, 0},
{-16159, 0},
{-16142, 0},
{-16124, 0},
{-16106, 0},
{-16088, 0},
{-16068, 0},
{-16048, 0},
{-16028, 0},
{-16007, 0},
{-15985, 0},
{-15963, 0},
{-15940, 0},
{-15916, 0},
{-15892, 0},
{-15867, 0},
{-15842, 0},
{-15816, 0},
{-15790, 0},
{-15762, 0},
{-15735, 0},
{-15706, 0},
{-15678, 0},
{-15648, 0},
{-15618, 0},
{-15587, 0},
{-15556, 0},
{-15524, 0},
{-15492, 0},
{-15459, 0},
{-15425, 0},
{-15391, 0},
{-15356, 0},
{-15321, 0},
{-15285, 0},
{-15249, 0},
{-15212, 0},
{-15174, 0},
{-15136, 0},
{-15097, 0},
{-15058, 0},
{-15018, 0},
{-14977, 0},
{-14936, 0},
{-14895, 0},
{-14853, 0},
{-14810, 0},
{-14767, 0},
{-14723, 0},
{-14679, 0},
{-14634, 0},
{-14588, 0},
{-14542, 0},
{-14496, 0},
{-14449, 0},
{-14401, 0},
{-14353, 0},
{-14304, 0},
{-14255, 0},
{-14205, 0},
{-14154, 0},
{-14104, 0},
{-14052, 0},
{-14000, 0},
{-13948, 0},
{-13895, 0},
{-13841, 0},
{-13787, 0},
{-13733, 0},
{-13678, 0},
{-13622, 0},
{-13566, 0},
{-13509, 0},
{-13452, 0},
{-13394, 0},
{-13336, 0},
{-13278, 0},
{-13219, 0},
{-13159, 0},
{-13099, 0},
{-13038, 0},
{-12977, 0},
{-12915, 0},
{-12853, 0},
{-12791, 0},
{-12728, 0},
{-12664, 0},
{-12600, 0},
{-12536, 0},
{-12471, 0},
{-12405, 0},
{-12339, 0},
{-12273, 0},
{-12206, 0},
{-12139, 0},
{-12071, 0},
{-12003, 0},
{-11934, 0},
{-11865, 0},
{-11796, 0},
{-11726, 0},
{-11655, 0},
{-11585, 0},
{-11513, 0},
{-11441, 0},
{-11369, 0},
{-11297, 0},
{-11224, 0},
{-11150, 0},
{-11076, 0},
{-11002, 0},
{-10927, 0},
{-10852, 0},
{-10777, 0},
{-10701, 0},
{-10625, 0},
{-10548, 0},
{-10471, 0},
{-10393, 0},
{-10315, 0},
{-10237, 0},
{-10158, 0},
{-10079, 0},
{-10000, 0},
{ -9920, 0},
{ -9840, 0},
{ -9759, 0},
{ -9678, 0},
{ -9597, 0},
{ -9515, 0},
{ -9433, 0},
{ -9351, 0},
{ -9268, 0},
{ -9185, 0},
{ -9102, 0},
{ -9018, 0},
{ -8934, 0},
{ -8850, 0},
{ -8765, 0},
{ -8680, 0},
{ -8594, 0},
{ -8509, 0},
{ -8423, 0},
{ -8336, 0},
{ -8249, 0},
{ -8162, 0},
{ -8075, 0},
{ -7988, 0},
{ -7900, 0},
{ -7811, 0},
{ -7723, 0},
{ -7634, 0},
{ -7545, 0},
{ -7456, 0},
{ -7366, 0},
{ -7276, 0},
{ -7186, 0},
{ -7095, 0},
{ -7005, 0},
{ -6914, 0},
{ -6822, 0},
{ -6731, 0},
{ -6639, 0},
{ -6547, 0},
{ -6455, 0},
{ -6362, 0},
{ -6270, 0},
{ -6177, 0},
{ -6083, 0},
{ -5990, 0},
{ -5896, 0},
{ -5802, 0},
{ -5708, 0},
{ -5614, 0},
{ -5519, 0},
{ -5425, 0},
{ -5330, 0},
{ -5234, 0},
{ -5139, 0},
{ -5044, 0},
{ -4948, 0},
{ -4852, 0},
{ -4756, 0},
{ -4659, 0},
{ -4563, 0},
{ -4466, 0},
{ -4370, 0},
{ -4273, 0},
{ -4175, 0},
{ -4078, 0},
{ -3981, 0},
{ -3883, 0},
{ -3785, 0},
{ -3688, 0},
{ -3590, 0},
{ -3491, 0},
{ -3393, 0},
{ -3295, 0},
{ -3196, 0},
{ -3098, 0},
{ -2999, 0},
{ -2900, 0},
{ -2801, 0},
{ -2702, 0},
{ -2603, 0},
{ -2503, 0},
{ -2404, 0},
{ -2304, 0},
{ -2205, 0},
{ -2105, 0},
{ -2005, 0},
{ -1906, 0},
{ -1806, 0},
{ -1706, 0},
{ -1606, 0},
{ -1506, 0},
{ -1406, 0},
{ -1305, 0},
{ -1205, 0},
{ -1105, 0},
{ -1005, 0},
{ -904, 0},
{ -804, 0},
{ -703, 0},
{ -603, 0},
{ -503, 0},
{ -402, 0},
{ -302, 0},
{ -201, 0},
{ -101, 0}
};
|
7e39820852951e645b306419fea464101ad79cb9
|
39568e19301a7a112398be542154950af25591de
|
/sw/device/sca/lib/simple_serial.h
|
2951fc9bdf6d13a8bbfe94fd037034f1ae54545f
|
[
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
lowRISC/opentitan
|
493995bc7cf7cb3aee486a5203af3fd62bba3bfc
|
51f6017b8425b14d5a4aa9abace8fe5a25ef08c8
|
refs/heads/master
| 2023-08-31T22:05:09.425796
| 2023-08-14T14:52:15
| 2023-08-31T20:31:13
| 204,516,692
| 2,077
| 634
|
Apache-2.0
| 2023-09-14T21:16:21
| 2019-08-26T16:30:16
|
SystemVerilog
|
UTF-8
|
C
| false
| false
| 4,055
|
h
|
simple_serial.h
|
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
#ifndef OPENTITAN_SW_DEVICE_SCA_LIB_SIMPLE_SERIAL_H_
#define OPENTITAN_SW_DEVICE_SCA_LIB_SIMPLE_SERIAL_H_
#include <stddef.h>
#include <stdint.h>
#include "sw/device/lib/base/status.h"
#include "sw/device/lib/dif/dif_base.h"
#include "sw/device/lib/dif/dif_uart.h"
/**
* @file
* @brief Simple serial protocol for side-channel analysis.
*
* This library implements simple serial protocol version 1.1 and provides
* built-in handlers for 'v' (version) and 's' (seed PRNG) commands. Clients
* can implement additional command by registering their handlers using
* `simple_serial_register_handler()`. See https://wiki.newae.com/SimpleSerial
* for details on the protocol.
*/
/**
* Sends an error message over UART if condition evaluates to false.
*/
#define SS_CHECK(condition) \
do { \
if (!(condition)) { \
simple_serial_send_status(kSimpleSerialError); \
return; \
} \
} while (false)
/**
* Sends an error message over UART if the status represents an error.
*/
#define SS_CHECK_STATUS_OK(expr) \
do { \
status_t status_ = expr; \
if (!(status_ok(status_))) { \
unsigned char *buf = (unsigned char *)&status_.value; \
simple_serial_send_packet('z', buf, sizeof(status_.value)); \
return; \
} \
} while (false)
/**
* Sends an error message over UART if DIF does not return kDifOk.
*/
#define SS_CHECK_DIF_OK(dif_call) \
do { \
if (dif_call != kDifOk) { \
simple_serial_send_status(kSimpleSerialError); \
return; \
} \
} while (false)
/**
* Simple serial status codes.
*/
typedef enum simple_serial_result {
kSimpleSerialOk = 0,
kSimpleSerialError = 1,
} simple_serial_result_t;
/**
* Command handlers must conform to this prototype.
*/
typedef void (*simple_serial_command_handler)(const uint8_t *, size_t);
/**
* Initializes the data structures used by simple serial.
*
* This function also registers handlers for 'v' (version) and 's' (seed PRNG)
* commands.
*
* @param uart Handle to an initialized UART device.
*/
void simple_serial_init(const dif_uart_t *uart);
/**
* Registers a handler for a simple serial command.
*
* Clients cannot register handlers for 'v' (version) and 's' (seed PRNG)
* commands since these are handled by this library.
*
* @param cmd Simple serial command.
* @param handler Command handler.
*/
simple_serial_result_t simple_serial_register_handler(
uint8_t cmd, simple_serial_command_handler handler);
/**
* Waits for a simple serial packet and dispatches it to the appropriate
* handler.
*/
void simple_serial_process_packet(void);
/**
* Sends a simple serial packet over UART.
*
* @param cmd Simple serial command.
* @param data Packet payload.
* @param data_len Payload length.
*/
void simple_serial_send_packet(const uint8_t cmd, const uint8_t *data,
size_t data_len);
/**
* Sends a simple serial status packer over UART.
*
* @param res Status code.
*/
void simple_serial_send_status(uint8_t res);
/**
* Sends a buffer over UART as a hex encoded string.
*
* @param data A buffer
* @param data_len Size of the buffer.
*/
void simple_serial_print_hex(const uint8_t *data, size_t data_len);
#endif // OPENTITAN_SW_DEVICE_SCA_LIB_SIMPLE_SERIAL_H_
|
8c2a38944a832e188906aaea5ecdc61104f22353
|
83b8b30ebb633eecd29ca0a7a20cc43a293c9333
|
/ports/espressif/boards/lilygo_ttgo_t-01c3/pins.c
|
887d85ef2f5445f1d4a244d44c8c855eccd8ff7d
|
[
"MIT",
"GPL-1.0-or-later"
] |
permissive
|
adafruit/circuitpython
|
430ec895149d1eb814b505db39b4977a35ee88a7
|
506dca71b0cbb7af749bb51f86b01021db5483b3
|
refs/heads/main
| 2023-08-21T16:30:46.781068
| 2023-08-20T00:39:44
| 2023-08-20T00:39:44
| 66,166,069
| 3,806
| 1,560
|
MIT
| 2023-09-14T19:23:51
| 2016-08-20T20:10:40
|
C
|
UTF-8
|
C
| false
| false
| 822
|
c
|
pins.c
|
#include "shared-bindings/board/__init__.h"
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
{ MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) },
{ MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) },
{ MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) },
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO20) },
{ MP_ROM_QSTR(MP_QSTR_IO20), MP_ROM_PTR(&pin_GPIO20) },
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO21) },
{ MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) },
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO3) },
{ MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) },
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
};
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
|
6d2c95fdccb64303cea7609a18823ae185b86d62
|
fd016aacb50a65dbda2f0e2b35cec38a63baf68d
|
/src/nanoFramework.Graphics/Graphics/Core/Support/Gif/lzwutil.h
|
80b9baac887f51ce88693dc126e03eafa3be035d
|
[
"MIT"
] |
permissive
|
nanoframework/nf-interpreter
|
4795563afe8b1d8e4819a4b4ebd700c9e36a4d80
|
2ebb0aeef2d9482a6233e4c78f562878ba726cf6
|
refs/heads/main
| 2023-08-29T11:30:31.384324
| 2023-08-29T10:55:46
| 2023-08-29T10:55:46
| 74,834,622
| 283
| 266
|
MIT
| 2023-09-14T00:22:43
| 2016-11-26T15:45:06
|
C
|
UTF-8
|
C
| false
| false
| 1,978
|
h
|
lzwutil.h
|
//
// Copyright (c) .NET Foundation and Contributors
// Portions Copyright (c) Microsoft Corporation. All rights reserved.
// See LICENSE file in the project root for full license information.
//
#ifndef LZWUTIL_H
#define LZWUTIL_H
#include "Graphics.h"
/*****************************************************************************
External APIs. Clients of this library must implement the following
APIs for debug purposes - they are not compiled in in non-debug versions
of the code.
******************************************************************* JohnBo **/
#define LZW_ASSERT(c)
/* Error checking (assert) macros associated with this. */
//#define LZW_B8(i) (LZW_ASSERT((i)<256 && (i)>=0),
// static_cast<unsigned char>(i))
//#define LZW_B16(i) (LZW_ASSERT((i)<65536 && (i)>=0),
// static_cast<unsigned short>(i))
#define LZW_B8(i) (static_cast<unsigned char>(i))
#define LZW_B16(i) (static_cast<unsigned short>(i))
/*****************************************************************************
Utility to set a two byte quantity in the standard GIF little endian
format, likewise for four bytes (GAMMANOW extension.)
******************************************************************* JohnBo **/
inline void GIF16Bit(unsigned char* pb, int i)
{
LZW_ASSERT(i >= 0 && i < 65536);
pb[0] = static_cast<unsigned char>(i);
pb[1] = static_cast<unsigned char>(i >> 8);
}
/* Inverse operation. */
inline unsigned short GIFU16(const unsigned char* pb)
{
return static_cast<unsigned short>(pb[0] + (pb[1] << 8));
}
inline void GIF32Bit(unsigned char* pb, unsigned int i)
{
pb[0] = static_cast<unsigned char>(i);
pb[1] = static_cast<unsigned char>(i >> 8);
pb[2] = static_cast<unsigned char>(i >> 16);
pb[3] = static_cast<unsigned char>(i >> 24);
}
/* Inverse operation. */
inline unsigned int GIFU32(const unsigned char* pb)
{
return pb[0] + (pb[1] << 8) + (pb[2] << 16) + (pb[3] << 24);
}
#endif // LZWUTIL_H
|
a23212195bb375fcc9facfe87f75f358c354184d
|
581bdcc078d282e388f1b655d4cfc4e08152d117
|
/phnt/include/ntgdi.h
|
bf70b71b2904770998b0c7876010330f79b28b01
|
[
"MIT",
"BSD-3-Clause",
"LGPL-2.0-or-later",
"Zlib",
"LGPL-2.1-or-later",
"GPL-2.0-only",
"LicenseRef-scancode-public-domain"
] |
permissive
|
winsiderss/systeminformer
|
774928be871f0055263ac5e62ae0a598b098486b
|
5a6b442acd45d681f699a133d476a3211d072871
|
refs/heads/master
| 2023-08-28T15:43:41.074679
| 2023-08-27T20:59:20
| 2023-08-27T20:59:20
| 50,824,485
| 2,137
| 292
|
MIT
| 2023-09-10T22:35:12
| 2016-02-01T08:10:21
|
C
|
UTF-8
|
C
| false
| false
| 4,134
|
h
|
ntgdi.h
|
/*
* Graphics device interface support
*
* This file is part of System Informer.
*/
#ifndef _NTGDI_H
#define _NTGDI_H
#define GDI_MAX_HANDLE_COUNT 0xFFFF // 0x4000
#define GDI_HANDLE_INDEX_SHIFT 0
#define GDI_HANDLE_INDEX_BITS 16
#define GDI_HANDLE_INDEX_MASK 0xffff
#define GDI_HANDLE_TYPE_SHIFT 16
#define GDI_HANDLE_TYPE_BITS 5
#define GDI_HANDLE_TYPE_MASK 0x1f
#define GDI_HANDLE_ALTTYPE_SHIFT 21
#define GDI_HANDLE_ALTTYPE_BITS 2
#define GDI_HANDLE_ALTTYPE_MASK 0x3
#define GDI_HANDLE_STOCK_SHIFT 23
#define GDI_HANDLE_STOCK_BITS 1
#define GDI_HANDLE_STOCK_MASK 0x1
#define GDI_HANDLE_UNIQUE_SHIFT 24
#define GDI_HANDLE_UNIQUE_BITS 8
#define GDI_HANDLE_UNIQUE_MASK 0xff
#define GDI_HANDLE_INDEX(Handle) ((ULONG)(Handle) & GDI_HANDLE_INDEX_MASK)
#define GDI_HANDLE_TYPE(Handle) (((ULONG)(Handle) >> GDI_HANDLE_TYPE_SHIFT) & GDI_HANDLE_TYPE_MASK)
#define GDI_HANDLE_ALTTYPE(Handle) (((ULONG)(Handle) >> GDI_HANDLE_ALTTYPE_SHIFT) & GDI_HANDLE_ALTTYPE_MASK)
#define GDI_HANDLE_STOCK(Handle) (((ULONG)(Handle) >> GDI_HANDLE_STOCK_SHIFT)) & GDI_HANDLE_STOCK_MASK)
#define GDI_MAKE_HANDLE(Index, Unique) ((ULONG)(((ULONG)(Unique) << GDI_HANDLE_INDEX_BITS) | (ULONG)(Index)))
// GDI server-side types
#define GDI_DEF_TYPE 0 // invalid handle
#define GDI_DC_TYPE 1
#define GDI_DD_DIRECTDRAW_TYPE 2
#define GDI_DD_SURFACE_TYPE 3
#define GDI_RGN_TYPE 4
#define GDI_SURF_TYPE 5
#define GDI_CLIENTOBJ_TYPE 6
#define GDI_PATH_TYPE 7
#define GDI_PAL_TYPE 8
#define GDI_ICMLCS_TYPE 9
#define GDI_LFONT_TYPE 10
#define GDI_RFONT_TYPE 11
#define GDI_PFE_TYPE 12
#define GDI_PFT_TYPE 13
#define GDI_ICMCXF_TYPE 14
#define GDI_ICMDLL_TYPE 15
#define GDI_BRUSH_TYPE 16
#define GDI_PFF_TYPE 17 // unused
#define GDI_CACHE_TYPE 18 // unused
#define GDI_SPACE_TYPE 19
#define GDI_DBRUSH_TYPE 20 // unused
#define GDI_META_TYPE 21
#define GDI_EFSTATE_TYPE 22
#define GDI_BMFD_TYPE 23 // unused
#define GDI_VTFD_TYPE 24 // unused
#define GDI_TTFD_TYPE 25 // unused
#define GDI_RC_TYPE 26 // unused
#define GDI_TEMP_TYPE 27 // unused
#define GDI_DRVOBJ_TYPE 28
#define GDI_DCIOBJ_TYPE 29 // unused
#define GDI_SPOOL_TYPE 30
// GDI client-side types
#define GDI_CLIENT_TYPE_FROM_HANDLE(Handle) ((ULONG)(Handle) & ((GDI_HANDLE_ALTTYPE_MASK << GDI_HANDLE_ALTTYPE_SHIFT) | \
(GDI_HANDLE_TYPE_MASK << GDI_HANDLE_TYPE_SHIFT)))
#define GDI_CLIENT_TYPE_FROM_UNIQUE(Unique) GDI_CLIENT_TYPE_FROM_HANDLE((ULONG)(Unique) << 16)
#define GDI_ALTTYPE_1 (1 << GDI_HANDLE_ALTTYPE_SHIFT)
#define GDI_ALTTYPE_2 (2 << GDI_HANDLE_ALTTYPE_SHIFT)
#define GDI_ALTTYPE_3 (3 << GDI_HANDLE_ALTTYPE_SHIFT)
#define GDI_CLIENT_BITMAP_TYPE (GDI_SURF_TYPE << GDI_HANDLE_TYPE_SHIFT)
#define GDI_CLIENT_BRUSH_TYPE (GDI_BRUSH_TYPE << GDI_HANDLE_TYPE_SHIFT)
#define GDI_CLIENT_CLIENTOBJ_TYPE (GDI_CLIENTOBJ_TYPE << GDI_HANDLE_TYPE_SHIFT)
#define GDI_CLIENT_DC_TYPE (GDI_DC_TYPE << GDI_HANDLE_TYPE_SHIFT)
#define GDI_CLIENT_FONT_TYPE (GDI_LFONT_TYPE << GDI_HANDLE_TYPE_SHIFT)
#define GDI_CLIENT_PALETTE_TYPE (GDI_PAL_TYPE << GDI_HANDLE_TYPE_SHIFT)
#define GDI_CLIENT_REGION_TYPE (GDI_RGN_TYPE << GDI_HANDLE_TYPE_SHIFT)
#define GDI_CLIENT_ALTDC_TYPE (GDI_CLIENT_DC_TYPE | GDI_ALTTYPE_1)
#define GDI_CLIENT_DIBSECTION_TYPE (GDI_CLIENT_BITMAP_TYPE | GDI_ALTTYPE_1)
#define GDI_CLIENT_EXTPEN_TYPE (GDI_CLIENT_BRUSH_TYPE | GDI_ALTTYPE_2)
#define GDI_CLIENT_METADC16_TYPE (GDI_CLIENT_CLIENTOBJ_TYPE | GDI_ALTTYPE_3)
#define GDI_CLIENT_METAFILE_TYPE (GDI_CLIENT_CLIENTOBJ_TYPE | GDI_ALTTYPE_2)
#define GDI_CLIENT_METAFILE16_TYPE (GDI_CLIENT_CLIENTOBJ_TYPE | GDI_ALTTYPE_1)
#define GDI_CLIENT_PEN_TYPE (GDI_CLIENT_BRUSH_TYPE | GDI_ALTTYPE_1)
typedef struct _GDI_HANDLE_ENTRY
{
union
{
PVOID Object;
PVOID NextFree;
};
union
{
struct
{
USHORT ProcessId;
USHORT Lock : 1;
USHORT Count : 15;
};
ULONG Value;
} Owner;
USHORT Unique;
UCHAR Type;
UCHAR Flags;
PVOID UserPointer;
} GDI_HANDLE_ENTRY, *PGDI_HANDLE_ENTRY;
typedef struct _GDI_SHARED_MEMORY
{
GDI_HANDLE_ENTRY Handles[GDI_MAX_HANDLE_COUNT];
} GDI_SHARED_MEMORY, *PGDI_SHARED_MEMORY;
#endif
|
fbe36b77da4358fad08bee07db555c518faed82b
|
ec6a71b57ebe88538269197fd16bede6bc2062ae
|
/lib/crypto/c_src/hmac.c
|
86ffb9a5a301f8a5cf917088a585d6124ac786e5
|
[
"Apache-2.0"
] |
permissive
|
erlang/otp
|
7c6e88ca955bd6a3ede1530154c80e8ce449a370
|
334589af62a8db25a81afba2ecc50f33ff69ddb8
|
refs/heads/master
| 2023-08-30T23:37:28.061328
| 2023-08-30T04:20:48
| 2023-08-30T04:20:48
| 374,927
| 9,920
| 3,018
|
Apache-2.0
| 2023-09-14T10:37:26
| 2009-11-16T17:17:57
|
Erlang
|
UTF-8
|
C
| false
| false
| 6,657
|
c
|
hmac.c
|
/*
* %CopyrightBegin%
*
* Copyright Ericsson AB 2010-2022. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* %CopyrightEnd%
*/
/*****************************************************************
*
* This file has functions for compatibility with cryptolibs
* lacking the EVP_Digest API.
*
* See mac.c for the implementation using the EVP interface.
*
****************************************************************/
#include "hmac.h"
#include "digest.h"
#if !defined(HAS_EVP_PKEY_CTX) || DISABLE_EVP_HMAC
struct hmac_context
{
ErlNifMutex* mtx;
int alive;
HMAC_CTX* ctx;
};
static ErlNifResourceType* hmac_context_rtype;
static void hmac_context_dtor(ErlNifEnv* env, struct hmac_context*);
int init_hmac_ctx(ErlNifEnv *env) {
hmac_context_rtype = enif_open_resource_type(env, NULL, "hmac_context",
(ErlNifResourceDtor*) hmac_context_dtor,
ERL_NIF_RT_CREATE|ERL_NIF_RT_TAKEOVER,
NULL);
if (hmac_context_rtype == NULL)
goto err;
return 1;
err:
PRINTF_ERR0("CRYPTO: Could not open resource type 'hmac_context'");
return 0;
}
static void hmac_context_dtor(ErlNifEnv* env, struct hmac_context *obj)
{
if (obj == NULL)
return;
if (obj->alive) {
if (obj->ctx)
HMAC_CTX_free(obj->ctx);
obj->alive = 0;
}
if (obj->mtx != NULL)
enif_mutex_destroy(obj->mtx);
}
ERL_NIF_TERM hmac_init_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{/* (hmac, Type, Key) */
struct digest_type_t *digp = NULL;
ErlNifBinary key;
ERL_NIF_TERM ret;
struct hmac_context *obj = NULL;
ASSERT(argc == 3);
if ((digp = get_digest_type(argv[1])) == NULL)
goto bad_arg;
if (!enif_inspect_iolist_as_binary(env, argv[2], &key))
goto bad_arg;
if (key.size > INT_MAX)
goto bad_arg;
if (digp->md.p == NULL)
goto err;
if ((obj = enif_alloc_resource(hmac_context_rtype, sizeof(struct hmac_context))) == NULL)
goto err;
obj->ctx = NULL;
obj->mtx = NULL;
obj->alive = 0;
if ((obj->ctx = HMAC_CTX_new()) == NULL)
goto err;
obj->alive = 1;
if ((obj->mtx = enif_mutex_create("crypto.hmac")) == NULL)
goto err;
#if OPENSSL_VERSION_NUMBER >= PACKED_OPENSSL_VERSION_PLAIN(1,0,0)
// Check the return value of HMAC_Init: it may fail in FIPS mode
// for disabled algorithms
if (!HMAC_Init_ex(obj->ctx, key.data, (int)key.size, digp->md.p, NULL))
goto err;
#else
// In ancient versions of OpenSSL, this was a void function.
HMAC_Init_ex(obj->ctx, key.data, (int)key.size, digp->md.p, NULL);
#endif
ret = enif_make_resource(env, obj);
goto done;
bad_arg:
return enif_make_badarg(env);
err:
ret = atom_notsup;
done:
if (obj)
enif_release_resource(obj);
return ret;
}
ERL_NIF_TERM hmac_update_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{/* (Context, Data) */
ERL_NIF_TERM ret;
ErlNifBinary data;
struct hmac_context *obj = NULL;
ASSERT(argc == 2);
if (!enif_get_resource(env, argv[0], (ErlNifResourceType*)hmac_context_rtype, (void**)&obj))
goto bad_arg;
if (!enif_inspect_iolist_as_binary(env, argv[1], &data))
goto bad_arg;
enif_mutex_lock(obj->mtx);
if (!obj->alive)
goto err;
#if OPENSSL_VERSION_NUMBER >= PACKED_OPENSSL_VERSION_PLAIN(1,0,0)
if (!HMAC_Update(obj->ctx, data.data, data.size))
goto err;
#else
// In ancient versions of OpenSSL, this was a void function.
HMAC_Update(obj->ctx, data.data, data.size);
#endif
CONSUME_REDS(env,data);
ret = argv[0];
goto done;
bad_arg:
return enif_make_badarg(env);
err:
ret = enif_make_badarg(env);
done:
enif_mutex_unlock(obj->mtx);
return ret;
}
ERL_NIF_TERM hmac_final_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{/* (Context) or (Context, HashLen) */
ERL_NIF_TERM ret;
struct hmac_context* obj;
unsigned char mac_buf[EVP_MAX_MD_SIZE];
unsigned char * mac_bin;
unsigned int req_len = 0;
unsigned int mac_len;
ASSERT(argc == 1 || argc == 2);
if (!enif_get_resource(env, argv[0], (ErlNifResourceType*)hmac_context_rtype, (void**)&obj))
goto bad_arg;
if (argc == 2) {
if (!enif_get_uint(env, argv[1], &req_len))
goto bad_arg;
}
enif_mutex_lock(obj->mtx);
if (!obj->alive)
goto err;
#if OPENSSL_VERSION_NUMBER >= PACKED_OPENSSL_VERSION_PLAIN(1,0,0)
if (!HMAC_Final(obj->ctx, mac_buf, &mac_len))
goto err;
#else
// In ancient versions of OpenSSL, this was a void function.
HMAC_Final(obj->ctx, mac_buf, &mac_len);
#endif
if (obj->ctx)
HMAC_CTX_free(obj->ctx);
obj->alive = 0;
if (argc == 2 && req_len < mac_len) {
/* Only truncate to req_len bytes if asked. */
mac_len = req_len;
}
if ((mac_bin = enif_make_new_binary(env, mac_len, &ret)) == NULL)
goto err;
memcpy(mac_bin, mac_buf, mac_len);
goto done;
bad_arg:
return enif_make_badarg(env);
err:
ret = enif_make_badarg(env);
done:
enif_mutex_unlock(obj->mtx);
return ret;
}
int hmac_low_level(ErlNifEnv* env, const EVP_MD *md,
ErlNifBinary key_bin, ErlNifBinary text,
ErlNifBinary *ret_bin, int *ret_bin_alloc, ERL_NIF_TERM *return_term)
{
unsigned int size_int;
size_t size;
unsigned char buff[EVP_MAX_MD_SIZE];
if (HMAC(md,
key_bin.data, (int)key_bin.size,
text.data, text.size,
buff, &size_int) == NULL)
{
*return_term = EXCP_ERROR(env, "HMAC sign failed");
return 0;
}
size = (size_t)size_int; /* Otherwise "size" is unused in 0.9.8.... */
ASSERT(0 < size && size <= EVP_MAX_MD_SIZE);
if (!enif_alloc_binary(size, ret_bin))
{
*return_term = EXCP_ERROR(env, "Alloc binary");
return 0;
}
*ret_bin_alloc = 1;
memcpy(ret_bin->data, buff, size);
return 1;
}
#endif
|
a6c0ebfb627400f01fc1224ea8ab9a2cd5aaad67
|
376e1818d427b5e4d32fa6dd6c7b71e9fd88afdb
|
/multimedia/dvb-apps/patches/patch-lib_libucsi_dvb_bat__section.c
|
bec245ba90287a00c15570b4c0be9a30a54d8d71
|
[] |
no_license
|
NetBSD/pkgsrc
|
a0732c023519650ef821ab89c23ab6ab59e25bdb
|
d042034ec4896cc5b47ed6f2e5b8802d9bc5c556
|
refs/heads/trunk
| 2023-09-01T07:40:12.138283
| 2023-09-01T05:25:19
| 2023-09-01T05:25:19
| 88,439,572
| 321
| 138
| null | 2023-07-12T22:34:14
| 2017-04-16T20:04:15
| null |
UTF-8
|
C
| false
| false
| 1,020
|
c
|
patch-lib_libucsi_dvb_bat__section.c
|
$NetBSD: patch-lib_libucsi_dvb_bat__section.c,v 1.1 2011/07/15 22:59:21 jmcneill Exp $
--- lib/libucsi/dvb/bat_section.c.orig 2011-06-28 05:50:24.000000000 +0000
+++ lib/libucsi/dvb/bat_section.c
@@ -31,7 +31,7 @@ struct dvb_bat_section * dvb_bat_section
if (len < sizeof(struct dvb_bat_section))
return NULL;
- bswap16(buf + pos);
+ ubswap16(buf + pos);
pos += 2;
if ((pos + ret->bouquet_descriptors_length) > len)
@@ -44,7 +44,7 @@ struct dvb_bat_section * dvb_bat_section
if ((pos + sizeof(struct dvb_bat_section_part2)) > len)
return NULL;
- bswap16(buf + pos);
+ ubswap16(buf + pos);
pos += sizeof(struct dvb_bat_section_part2);
while (pos < len) {
@@ -54,9 +54,9 @@ struct dvb_bat_section * dvb_bat_section
if ((pos + sizeof(struct dvb_bat_transport)) > len)
return NULL;
- bswap16(buf + pos);
- bswap16(buf + pos + 2);
- bswap16(buf + pos + 4);
+ ubswap16(buf + pos);
+ ubswap16(buf + pos + 2);
+ ubswap16(buf + pos + 4);
pos += sizeof(struct dvb_bat_transport);
|
9f509849e68caeafb23a5d272c22a7cee3173656
|
b23de605446429b92ed1cd1facc402b025a488e8
|
/source/windows/secure_channel_tls_handler.c
|
9ede8ded50737681fddbee390973ededa0a6b583
|
[
"LicenseRef-scancode-proprietary-license",
"Apache-2.0"
] |
permissive
|
awslabs/aws-c-io
|
64e56224e43fce0a7c02e555cfeba39c58b8bb5f
|
b4aa873e16db0824ad381ae78764d445ae62ee32
|
refs/heads/main
| 2023-09-04T05:20:05.302131
| 2023-08-28T17:28:58
| 2023-08-28T17:28:58
| 123,649,788
| 103
| 66
|
Apache-2.0
| 2023-09-06T16:52:56
| 2018-03-03T01:50:50
|
C
|
UTF-8
|
C
| false
| false
| 85,063
|
c
|
secure_channel_tls_handler.c
|
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#define SECURITY_WIN32
#include <aws/io/tls_channel_handler.h>
#include <aws/common/encoding.h>
#include <aws/common/math.h>
#include <aws/common/string.h>
#include <aws/common/task_scheduler.h>
#include <aws/io/channel.h>
#include <aws/io/file_utils.h>
#include <aws/io/logging.h>
#include <aws/io/private/pki_utils.h>
#include <aws/io/private/tls_channel_handler_shared.h>
#include <aws/io/statistics.h>
#include <Windows.h>
#include <schannel.h>
#include <security.h>
#include <errno.h>
#include <inttypes.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef _MSC_VER
# pragma warning(disable : 4221) /* aggregate initializer using local variable addresses */
# pragma warning(disable : 4204) /* non-constant aggregate initializer */
# pragma warning(disable : 4306) /* Identifier is type cast to a larger pointer. */
#endif
#define KB_1 1024
#define READ_OUT_SIZE (16 * KB_1)
#define READ_IN_SIZE READ_OUT_SIZE
#define EST_HANDSHAKE_SIZE (7 * KB_1)
#define EST_TLS_RECORD_OVERHEAD 53 /* 5 byte header + 32 + 16 bytes for padding */
void aws_tls_init_static_state(struct aws_allocator *alloc) {
AWS_LOGF_INFO(AWS_LS_IO_TLS, "static: Initializing TLS using SecureChannel (SSPI).");
(void)alloc;
}
void aws_tls_clean_up_static_state(void) {}
struct secure_channel_ctx {
struct aws_tls_ctx ctx;
struct aws_string *alpn_list;
SCHANNEL_CRED credentials;
PCERT_CONTEXT pcerts;
HCERTSTORE cert_store;
HCERTSTORE custom_trust_store;
HCRYPTPROV crypto_provider;
HCRYPTKEY private_key;
bool verify_peer;
bool should_free_pcerts;
};
struct secure_channel_handler {
struct aws_channel_handler handler;
struct aws_tls_channel_handler_shared shared_state;
CtxtHandle sec_handle;
CredHandle creds;
/*
* The SSPI API expects an array of len 1 of these where it's the leaf certificate associated with its private
* key.
*/
PCCERT_CONTEXT cert_context[1];
HCERTSTORE cert_store;
HCERTSTORE custom_ca_store;
SecPkgContext_StreamSizes stream_sizes;
unsigned long ctx_req;
unsigned long ctx_ret_flags;
struct aws_channel_slot *slot;
struct aws_byte_buf protocol;
struct aws_byte_buf server_name;
TimeStamp sspi_timestamp;
int (*s_connection_state_fn)(struct aws_channel_handler *handler);
/*
* Give a little bit of extra head room, for split records.
*/
uint8_t buffered_read_in_data[READ_IN_SIZE + KB_1];
struct aws_byte_buf buffered_read_in_data_buf;
size_t estimated_incomplete_size;
size_t read_extra;
/* This is to accommodate the extra head room we added above.
because we're allowing for splits, we may have more data decrypted
than we can fit in this buffer if we don't make them match. */
uint8_t buffered_read_out_data[READ_OUT_SIZE + KB_1];
struct aws_byte_buf buffered_read_out_data_buf;
struct aws_channel_task sequential_task_storage;
aws_tls_on_negotiation_result_fn *on_negotiation_result;
aws_tls_on_data_read_fn *on_data_read;
aws_tls_on_error_fn *on_error;
struct aws_string *alpn_list;
void *user_data;
bool advertise_alpn_message;
bool negotiation_finished;
bool verify_peer;
};
static size_t s_message_overhead(struct aws_channel_handler *handler) {
struct secure_channel_handler *sc_handler = handler->impl;
if (AWS_UNLIKELY(!sc_handler->stream_sizes.cbMaximumMessage)) {
SECURITY_STATUS status =
QueryContextAttributes(&sc_handler->sec_handle, SECPKG_ATTR_STREAM_SIZES, &sc_handler->stream_sizes);
if (status != SEC_E_OK) {
return EST_TLS_RECORD_OVERHEAD;
}
}
return sc_handler->stream_sizes.cbTrailer + sc_handler->stream_sizes.cbHeader;
}
bool aws_tls_is_alpn_available(void) {
/* if you built on an old version of windows, still no support, but if you did, we still
want to check the OS version at runtime before agreeing to attempt alpn. */
#ifdef SECBUFFER_APPLICATION_PROTOCOLS
AWS_LOGF_DEBUG(
AWS_LS_IO_TLS,
"static: This library was built with Windows 8.1 or later, "
"probing OS to see what we're actually running on.");
/* make sure we're on windows 8.1 or later. */
OSVERSIONINFOEX os_version;
DWORDLONG condition_mask = 0;
VER_SET_CONDITION(condition_mask, VER_MAJORVERSION, VER_GREATER_EQUAL);
VER_SET_CONDITION(condition_mask, VER_MINORVERSION, VER_GREATER_EQUAL);
VER_SET_CONDITION(condition_mask, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
VER_SET_CONDITION(condition_mask, VER_SERVICEPACKMINOR, VER_GREATER_EQUAL);
AWS_ZERO_STRUCT(os_version);
os_version.dwMajorVersion = HIBYTE(_WIN32_WINNT_WIN8);
os_version.dwMinorVersion = LOBYTE(_WIN32_WINNT_WIN8);
os_version.wServicePackMajor = 0;
os_version.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
if (VerifyVersionInfo(
&os_version,
VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
condition_mask)) {
AWS_LOGF_DEBUG(AWS_LS_IO_TLS, "static: We're running on Windows 8.1 or later. ALPN is available.");
return true;
}
AWS_LOGF_WARN(
AWS_LS_IO_TLS,
"static: Running on older version of windows, ALPN is not supported. "
"Please update your OS to take advantage of modern features.");
#else
AWS_LOGF_WARN(
AWS_LS_IO_TLS,
"static: This library was built using a Windows SDK prior to 8.1. "
"Please build with a version of windows >= 8.1 to take advantage modern features. ALPN is not supported.");
#endif /*SECBUFFER_APPLICATION_PROTOCOLS */
return false;
}
bool aws_tls_is_cipher_pref_supported(enum aws_tls_cipher_pref cipher_pref) {
switch (cipher_pref) {
case AWS_IO_TLS_CIPHER_PREF_SYSTEM_DEFAULT:
return true;
case AWS_IO_TLS_CIPHER_PREF_KMS_PQ_TLSv1_0_2019_06:
default:
return false;
}
}
/* technically we could lower this, but lets be forgiving */
#define MAX_HOST_LENGTH 255
/* this only gets called if the user specified a custom ca. */
static int s_manually_verify_peer_cert(struct aws_channel_handler *handler) {
AWS_LOGF_DEBUG(
AWS_LS_IO_TLS,
"id=%p: manually verifying certifcate chain because a custom CA is configured.",
(void *)handler);
struct secure_channel_handler *sc_handler = handler->impl;
int result = AWS_OP_ERR;
CERT_CONTEXT *peer_certificate = NULL;
HCERTCHAINENGINE engine = NULL;
CERT_CHAIN_CONTEXT *cert_chain_ctx = NULL;
/* get the peer's certificate so we can validate it.*/
SECURITY_STATUS status =
QueryContextAttributes(&sc_handler->sec_handle, SECPKG_ATTR_REMOTE_CERT_CONTEXT, &peer_certificate);
if (status != SEC_E_OK || !peer_certificate) {
AWS_LOGF_ERROR(
AWS_LS_IO_TLS,
"id=%p: failed to load peer's certificate with SECURITY_STATUS %d",
(void *)handler,
(int)status);
return AWS_OP_ERR;
}
/* this next bit scours the custom trust store to try and load a chain to verify
the leaf certificate against. */
CERT_CHAIN_ENGINE_CONFIG engine_config;
AWS_ZERO_STRUCT(engine_config);
engine_config.cbSize = sizeof(engine_config);
engine_config.hExclusiveRoot = sc_handler->custom_ca_store;
if (!CertCreateCertificateChainEngine(&engine_config, &engine)) {
AWS_LOGF_ERROR(
AWS_LS_IO_TLS,
"id=%p: failed to load a certificate chain engine with SECURITY_STATUS %d. "
"Most likely, the configured CA is corrupted.",
(void *)handler,
(int)status);
goto done;
}
/*
* TODO: Investigate CRL options further on a per-platform basis. Add control APIs if appropriate.
*/
DWORD get_chain_flags = 0;
/* mimic chromium here since we intend for this to be used generally */
const LPCSTR usage_identifiers[] = {
szOID_PKIX_KP_SERVER_AUTH,
szOID_SERVER_GATED_CRYPTO,
szOID_SGC_NETSCAPE,
};
CERT_CHAIN_PARA chain_params;
AWS_ZERO_STRUCT(chain_params);
chain_params.cbSize = sizeof(chain_params);
chain_params.RequestedUsage.dwType = USAGE_MATCH_TYPE_OR;
chain_params.RequestedUsage.Usage.cUsageIdentifier = AWS_ARRAY_SIZE(usage_identifiers);
chain_params.RequestedUsage.Usage.rgpszUsageIdentifier = (LPSTR *)usage_identifiers;
if (!CertGetCertificateChain(
engine,
peer_certificate,
NULL,
peer_certificate->hCertStore,
&chain_params,
get_chain_flags,
NULL,
&cert_chain_ctx)) {
AWS_LOGF_ERROR(
AWS_LS_IO_TLS,
"id=%p: unable to find certificate in chain with SECURITY_STATUS %d.",
(void *)handler,
(int)status);
goto done;
}
struct aws_byte_buf host = aws_tls_handler_server_name(handler);
if (host.len > MAX_HOST_LENGTH) {
AWS_LOGF_ERROR(AWS_LS_IO_TLS, "id=%p: host name too long (%d).", (void *)handler, (int)host.len);
goto done;
}
wchar_t whost[MAX_HOST_LENGTH + 1];
AWS_ZERO_ARRAY(whost);
int converted = MultiByteToWideChar(
CP_UTF8, MB_ERR_INVALID_CHARS, (const char *)host.buffer, (int)host.len, whost, AWS_ARRAY_SIZE(whost));
if ((size_t)converted != host.len) {
AWS_LOGF_ERROR(
AWS_LS_IO_TLS,
"id=%p: unable to convert host to wstr, %d -> %d, with last error 0x%x.",
(void *)handler,
(int)host.len,
(int)converted,
(int)GetLastError());
goto done;
}
/* check if the chain was trusted */
LPCSTR policyiod = CERT_CHAIN_POLICY_SSL;
SSL_EXTRA_CERT_CHAIN_POLICY_PARA sslpolicy;
AWS_ZERO_STRUCT(sslpolicy);
sslpolicy.cbSize = sizeof(sslpolicy);
sslpolicy.dwAuthType = AUTHTYPE_SERVER;
sslpolicy.fdwChecks = 0;
sslpolicy.pwszServerName = whost;
CERT_CHAIN_POLICY_PARA policypara;
AWS_ZERO_STRUCT(policypara);
policypara.cbSize = sizeof(policypara);
policypara.dwFlags = 0;
policypara.pvExtraPolicyPara = &sslpolicy;
CERT_CHAIN_POLICY_STATUS policystatus;
AWS_ZERO_STRUCT(policystatus);
policystatus.cbSize = sizeof(policystatus);
if (!CertVerifyCertificateChainPolicy(policyiod, cert_chain_ctx, &policypara, &policystatus)) {
int error = GetLastError();
AWS_LOGF_ERROR(
AWS_LS_IO_TLS, "id=%p: CertVerifyCertificateChainPolicy() failed, error 0x%x", (void *)handler, (int)error);
goto done;
}
if (policystatus.dwError) {
AWS_LOGF_ERROR(
AWS_LS_IO_TLS,
"id=%p: certificate verification failed, error 0x%x",
(void *)handler,
(int)policystatus.dwError);
goto done;
}
/* if the chain was trusted, then we're good to go, if it was not
we bail out. */
CERT_SIMPLE_CHAIN *simple_chain = cert_chain_ctx->rgpChain[0];
DWORD trust_mask = ~(DWORD)CERT_TRUST_IS_NOT_TIME_NESTED;
trust_mask &= simple_chain->TrustStatus.dwErrorStatus;
if (trust_mask != 0) {
AWS_LOGF_ERROR(
AWS_LS_IO_TLS,
"id=%p: peer certificate is un-trusted with SECURITY_STATUS %d.",
(void *)handler,
(int)trust_mask);
goto done;
}
AWS_LOGF_DEBUG(AWS_LS_IO_TLS, "id=%p: peer certificate is trusted.", (void *)handler);
result = AWS_OP_SUCCESS;
done:
if (cert_chain_ctx != NULL) {
CertFreeCertificateChain(cert_chain_ctx);
}
if (engine != NULL) {
CertFreeCertificateChainEngine(engine);
}
if (peer_certificate != NULL) {
CertFreeCertificateContext(peer_certificate);
}
return result;
}
static void s_invoke_negotiation_error(struct aws_channel_handler *handler, int err) {
struct secure_channel_handler *sc_handler = handler->impl;
aws_on_tls_negotiation_completed(&sc_handler->shared_state, err);
if (sc_handler->on_negotiation_result) {
sc_handler->on_negotiation_result(handler, sc_handler->slot, err, sc_handler->user_data);
}
}
static void s_on_negotiation_success(struct aws_channel_handler *handler) {
struct secure_channel_handler *sc_handler = handler->impl;
/* if the user provided an ALPN handler to the channel, we need to let them know what their protocol is. */
if (sc_handler->slot->adj_right && sc_handler->advertise_alpn_message && sc_handler->protocol.len) {
struct aws_io_message *message = aws_channel_acquire_message_from_pool(
sc_handler->slot->channel,
AWS_IO_MESSAGE_APPLICATION_DATA,
sizeof(struct aws_tls_negotiated_protocol_message));
message->message_tag = AWS_TLS_NEGOTIATED_PROTOCOL_MESSAGE;
struct aws_tls_negotiated_protocol_message *protocol_message =
(struct aws_tls_negotiated_protocol_message *)message->message_data.buffer;
protocol_message->protocol = sc_handler->protocol;
message->message_data.len = sizeof(struct aws_tls_negotiated_protocol_message);
if (aws_channel_slot_send_message(sc_handler->slot, message, AWS_CHANNEL_DIR_READ)) {
aws_mem_release(message->allocator, message);
aws_channel_shutdown(sc_handler->slot->channel, aws_last_error());
}
}
aws_on_tls_negotiation_completed(&sc_handler->shared_state, AWS_ERROR_SUCCESS);
if (sc_handler->on_negotiation_result) {
sc_handler->on_negotiation_result(handler, sc_handler->slot, AWS_OP_SUCCESS, sc_handler->user_data);
}
}
static int s_determine_sspi_error(int sspi_status) {
switch (sspi_status) {
case SEC_E_INSUFFICIENT_MEMORY:
return AWS_ERROR_OOM;
case SEC_I_CONTEXT_EXPIRED:
return AWS_IO_TLS_ALERT_NOT_GRACEFUL;
case SEC_E_WRONG_PRINCIPAL:
return AWS_IO_TLS_ERROR_NEGOTIATION_FAILURE;
/*
case SEC_E_INVALID_HANDLE:
case SEC_E_INVALID_TOKEN:
case SEC_E_LOGON_DENIED:
case SEC_E_TARGET_UNKNOWN:
case SEC_E_NO_AUTHENTICATING_AUTHORITY:
case SEC_E_INTERNAL_ERROR:
case SEC_E_NO_CREDENTIALS:
case SEC_E_UNSUPPORTED_FUNCTION:
case SEC_E_APPLICATION_PROTOCOL_MISMATCH:
*/
default:
return AWS_IO_TLS_ERROR_NEGOTIATION_FAILURE;
}
}
#define CHECK_ALPN_BUFFER_SIZE(s, i, b) \
if (s <= i) { \
aws_array_list_clean_up(&b); \
return aws_raise_error(AWS_ERROR_SHORT_BUFFER); \
}
/* construct ALPN extension data... apparently this works on big-endian machines? but I don't believe the docs
if you're running ARM and you find ALPN isn't working, it's probably because I trusted the documentation
and your bug is in here. Note, dotnet's corefx also acts like endianness isn't at play so if this is broken
so is everyone's dotnet code. */
static int s_fillin_alpn_data(
struct aws_channel_handler *handler,
unsigned char *alpn_buffer_data,
size_t buffer_size,
size_t *written) {
*written = 0;
struct secure_channel_handler *sc_handler = handler->impl;
AWS_LOGF_DEBUG(AWS_LS_IO_TLS, "");
struct aws_array_list alpn_buffers;
struct aws_byte_cursor alpn_buffer_array[4];
aws_array_list_init_static(&alpn_buffers, alpn_buffer_array, 4, sizeof(struct aws_byte_cursor));
AWS_LOGF_DEBUG(AWS_LS_IO_TLS, "Setting ALPN extension with string %s.", aws_string_c_str(sc_handler->alpn_list));
struct aws_byte_cursor alpn_str_cur = aws_byte_cursor_from_string(sc_handler->alpn_list);
if (aws_byte_cursor_split_on_char(&alpn_str_cur, ';', &alpn_buffers)) {
return AWS_OP_ERR;
}
size_t protocols_count = aws_array_list_length(&alpn_buffers);
size_t index = 0;
CHECK_ALPN_BUFFER_SIZE(buffer_size, index + sizeof(uint32_t), alpn_buffers)
uint32_t *extension_length = (uint32_t *)&alpn_buffer_data[index];
index += sizeof(uint32_t);
CHECK_ALPN_BUFFER_SIZE(buffer_size, index + sizeof(uint32_t), alpn_buffers)
uint32_t *extension_name = (uint32_t *)&alpn_buffer_data[index];
index += sizeof(uint32_t);
CHECK_ALPN_BUFFER_SIZE(buffer_size, index + sizeof(uint32_t), alpn_buffers)
uint16_t *protocols_byte_length = (uint16_t *)&alpn_buffer_data[index];
index += sizeof(uint16_t);
CHECK_ALPN_BUFFER_SIZE(buffer_size, index + sizeof(uint16_t), alpn_buffers)
*extension_length += sizeof(uint32_t) + sizeof(uint16_t);
*extension_name = SecApplicationProtocolNegotiationExt_ALPN;
/*now add the protocols*/
for (size_t i = 0; i < protocols_count; ++i) {
struct aws_byte_cursor *protocol_ptr = NULL;
aws_array_list_get_at_ptr(&alpn_buffers, (void **)&protocol_ptr, i);
AWS_ASSERT(protocol_ptr);
*extension_length += (uint32_t)protocol_ptr->len + 1;
*protocols_byte_length += (uint16_t)protocol_ptr->len + 1;
CHECK_ALPN_BUFFER_SIZE(buffer_size, index + 1, alpn_buffers)
alpn_buffer_data[index++] = (unsigned char)protocol_ptr->len;
CHECK_ALPN_BUFFER_SIZE(buffer_size, index + protocol_ptr->len, alpn_buffers)
memcpy(alpn_buffer_data + index, protocol_ptr->ptr, protocol_ptr->len);
index += protocol_ptr->len;
}
aws_array_list_clean_up(&alpn_buffers);
*written = *extension_length + sizeof(uint32_t);
return AWS_OP_SUCCESS;
}
static int s_process_connection_state(struct aws_channel_handler *handler) {
struct secure_channel_handler *sc_handler = handler->impl;
return sc_handler->s_connection_state_fn(handler);
}
static int s_do_application_data_decrypt(struct aws_channel_handler *handler);
static int s_do_server_side_negotiation_step_2(struct aws_channel_handler *handler);
/** invoked during the first step of the server's negotiation. It receives the client hello,
adds its alpn data if available, and if everything is good, sends out the server hello. */
static int s_do_server_side_negotiation_step_1(struct aws_channel_handler *handler) {
struct secure_channel_handler *sc_handler = handler->impl;
AWS_LOGF_TRACE(AWS_LS_IO_TLS, "id=%p: server starting negotiation", (void *)handler);
aws_on_drive_tls_negotiation(&sc_handler->shared_state);
unsigned char alpn_buffer_data[128] = {0};
SecBuffer input_bufs[] = {
{
.pvBuffer = sc_handler->buffered_read_in_data_buf.buffer,
.cbBuffer = (unsigned long)sc_handler->buffered_read_in_data_buf.len,
.BufferType = SECBUFFER_TOKEN,
},
{
.pvBuffer = NULL,
.cbBuffer = 0,
.BufferType = SECBUFFER_EMPTY,
},
};
SecBufferDesc input_bufs_desc = {
.ulVersion = SECBUFFER_VERSION,
.cBuffers = 2,
.pBuffers = input_bufs,
};
#ifdef SECBUFFER_APPLICATION_PROTOCOLS
if (sc_handler->alpn_list && aws_tls_is_alpn_available()) {
AWS_LOGF_DEBUG(AWS_LS_IO_TLS, "id=%p: Setting ALPN to %s", handler, aws_string_c_str(sc_handler->alpn_list));
size_t extension_length = 0;
if (s_fillin_alpn_data(handler, alpn_buffer_data, sizeof(alpn_buffer_data), &extension_length)) {
return AWS_OP_ERR;
}
input_bufs[1].pvBuffer = alpn_buffer_data, input_bufs[1].cbBuffer = (unsigned long)extension_length,
input_bufs[1].BufferType = SECBUFFER_APPLICATION_PROTOCOLS;
}
#endif /* SECBUFFER_APPLICATION_PROTOCOLS*/
sc_handler->ctx_req = ASC_REQ_SEQUENCE_DETECT | ASC_REQ_REPLAY_DETECT | ASC_REQ_CONFIDENTIALITY |
ASC_REQ_ALLOCATE_MEMORY | ASC_REQ_STREAM;
if (sc_handler->verify_peer) {
AWS_LOGF_DEBUG(
AWS_LS_IO_TLS,
"id=%p: server configured to use mutual tls, expecting a certficate from client.",
(void *)handler);
sc_handler->ctx_req |= ASC_REQ_MUTUAL_AUTH;
}
SecBuffer output_buffer = {
.pvBuffer = NULL,
.cbBuffer = 0,
.BufferType = SECBUFFER_TOKEN,
};
SecBufferDesc output_buffer_desc = {
.ulVersion = SECBUFFER_VERSION,
.cBuffers = 1,
.pBuffers = &output_buffer,
};
/* process the client hello. */
SECURITY_STATUS status = AcceptSecurityContext(
&sc_handler->creds,
NULL,
&input_bufs_desc,
sc_handler->ctx_req,
0,
&sc_handler->sec_handle,
&output_buffer_desc,
&sc_handler->ctx_ret_flags,
NULL);
if (!(status == SEC_I_CONTINUE_NEEDED || status == SEC_E_OK)) {
AWS_LOGF_ERROR(
AWS_LS_IO_TLS,
"id=%p: error during processing of the ClientHello. SECURITY_STATUS is %d",
(void *)handler,
(int)status);
int error = s_determine_sspi_error(status);
aws_raise_error(error);
s_invoke_negotiation_error(handler, error);
return AWS_OP_ERR;
}
size_t data_to_write_len = output_buffer.cbBuffer;
AWS_LOGF_TRACE(AWS_LS_IO_TLS, "id=%p: Sending ServerHello. Data size %zu", (void *)handler, data_to_write_len);
/* send the server hello. */
struct aws_io_message *outgoing_message = aws_channel_acquire_message_from_pool(
sc_handler->slot->channel, AWS_IO_MESSAGE_APPLICATION_DATA, data_to_write_len);
if (!outgoing_message) {
FreeContextBuffer(output_buffer.pvBuffer);
s_invoke_negotiation_error(handler, aws_last_error());
return AWS_OP_ERR;
}
AWS_ASSERT(outgoing_message->message_data.capacity >= data_to_write_len);
memcpy(outgoing_message->message_data.buffer, output_buffer.pvBuffer, output_buffer.cbBuffer);
outgoing_message->message_data.len = output_buffer.cbBuffer;
FreeContextBuffer(output_buffer.pvBuffer);
if (aws_channel_slot_send_message(sc_handler->slot, outgoing_message, AWS_CHANNEL_DIR_WRITE)) {
aws_mem_release(outgoing_message->allocator, outgoing_message);
s_invoke_negotiation_error(handler, aws_last_error());
return AWS_OP_ERR;
}
sc_handler->s_connection_state_fn = s_do_server_side_negotiation_step_2;
return AWS_OP_SUCCESS;
}
/* cipher change, key exchange, mutual TLS stuff. */
static int s_do_server_side_negotiation_step_2(struct aws_channel_handler *handler) {
struct secure_channel_handler *sc_handler = handler->impl;
AWS_LOGF_TRACE(
AWS_LS_IO_TLS, "id=%p: running step 2 of negotiation (cipher change, key exchange etc...)", (void *)handler);
SecBuffer input_buffers[] = {
[0] =
{
.pvBuffer = sc_handler->buffered_read_in_data_buf.buffer,
.cbBuffer = (unsigned long)sc_handler->buffered_read_in_data_buf.len,
.BufferType = SECBUFFER_TOKEN,
},
[1] =
{
.pvBuffer = NULL,
.cbBuffer = 0,
.BufferType = SECBUFFER_EMPTY,
},
};
SecBufferDesc input_buffers_desc = {
.ulVersion = SECBUFFER_VERSION,
.cBuffers = 2,
.pBuffers = input_buffers,
};
SecBuffer output_buffers[3];
AWS_ZERO_ARRAY(output_buffers);
output_buffers[0].BufferType = SECBUFFER_TOKEN;
output_buffers[1].BufferType = SECBUFFER_ALERT;
SecBufferDesc output_buffers_desc = {
.ulVersion = SECBUFFER_VERSION,
.cBuffers = 3,
.pBuffers = output_buffers,
};
sc_handler->read_extra = 0;
sc_handler->estimated_incomplete_size = 0;
SECURITY_STATUS status = AcceptSecurityContext(
&sc_handler->creds,
&sc_handler->sec_handle,
&input_buffers_desc,
sc_handler->ctx_req,
0,
NULL,
&output_buffers_desc,
&sc_handler->ctx_ret_flags,
&sc_handler->sspi_timestamp);
if (status != SEC_E_INCOMPLETE_MESSAGE && status != SEC_I_CONTINUE_NEEDED && status != SEC_E_OK) {
AWS_LOGF_ERROR(
AWS_LS_IO_TLS, "id=%p: Error during negotiation. SECURITY_STATUS is %d", (void *)handler, (int)status);
int aws_error = s_determine_sspi_error(status);
aws_raise_error(aws_error);
s_invoke_negotiation_error(handler, aws_error);
return AWS_OP_ERR;
}
if (status == SEC_E_INCOMPLETE_MESSAGE) {
AWS_LOGF_TRACE(
AWS_LS_IO_TLS, "id=%p: Last processed buffer was incomplete, waiting on more data.", (void *)handler);
sc_handler->estimated_incomplete_size = input_buffers[1].cbBuffer;
return aws_raise_error(AWS_IO_READ_WOULD_BLOCK);
};
/* any output buffers that were filled in with SECBUFFER_TOKEN need to be sent,
SECBUFFER_EXTRA means we need to account for extra data and shift everything for the next run. */
if (status == SEC_I_CONTINUE_NEEDED || status == SEC_E_OK) {
for (size_t i = 0; i < output_buffers_desc.cBuffers; ++i) {
SecBuffer *buf_ptr = &output_buffers[i];
if (buf_ptr->BufferType == SECBUFFER_TOKEN && buf_ptr->cbBuffer) {
struct aws_io_message *outgoing_message = aws_channel_acquire_message_from_pool(
sc_handler->slot->channel, AWS_IO_MESSAGE_APPLICATION_DATA, buf_ptr->cbBuffer);
if (!outgoing_message) {
FreeContextBuffer(buf_ptr->pvBuffer);
s_invoke_negotiation_error(handler, aws_last_error());
return AWS_OP_ERR;
}
memcpy(outgoing_message->message_data.buffer, buf_ptr->pvBuffer, buf_ptr->cbBuffer);
outgoing_message->message_data.len = buf_ptr->cbBuffer;
FreeContextBuffer(buf_ptr->pvBuffer);
if (aws_channel_slot_send_message(sc_handler->slot, outgoing_message, AWS_CHANNEL_DIR_WRITE)) {
aws_mem_release(outgoing_message->allocator, outgoing_message);
s_invoke_negotiation_error(handler, aws_last_error());
return AWS_OP_ERR;
}
}
}
if (input_buffers[1].BufferType == SECBUFFER_EXTRA && input_buffers[1].cbBuffer > 0) {
AWS_LOGF_TRACE(
AWS_LS_IO_TLS,
"id=%p: Extra data recieved. Extra size is %lu",
(void *)handler,
input_buffers[1].cbBuffer);
sc_handler->read_extra = input_buffers[1].cbBuffer;
}
}
if (status == SEC_E_OK) {
AWS_LOGF_TRACE(AWS_LS_IO_TLS, "id=%p: handshake completed", (void *)handler);
/* if a custom CA store was configured, we have to do the verification ourselves. */
if (sc_handler->custom_ca_store) {
AWS_LOGF_TRACE(
AWS_LS_IO_TLS,
"id=%p: Custom CA was configured, evaluating trust before completing connection",
(void *)handler);
if (s_manually_verify_peer_cert(handler)) {
aws_raise_error(AWS_IO_TLS_ERROR_NEGOTIATION_FAILURE);
s_invoke_negotiation_error(handler, AWS_IO_TLS_ERROR_NEGOTIATION_FAILURE);
return AWS_OP_ERR;
}
}
sc_handler->negotiation_finished = true;
/* force query of the sizes so future calls to encrypt will be loaded. */
s_message_overhead(handler);
/*
grab the negotiated protocol out of the session.
*/
#ifdef SECBUFFER_APPLICATION_PROTOCOLS
if (sc_handler->alpn_list && aws_tls_is_alpn_available()) {
SecPkgContext_ApplicationProtocol alpn_result;
status = QueryContextAttributes(&sc_handler->sec_handle, SECPKG_ATTR_APPLICATION_PROTOCOL, &alpn_result);
AWS_LOGF_TRACE(AWS_LS_IO_TLS, "id=%p: ALPN is configured. Checking for negotiated protocol", handler);
if (status == SEC_E_OK && alpn_result.ProtoNegoStatus == SecApplicationProtocolNegotiationStatus_Success) {
aws_byte_buf_init(&sc_handler->protocol, handler->alloc, alpn_result.ProtocolIdSize + 1);
memset(sc_handler->protocol.buffer, 0, alpn_result.ProtocolIdSize + 1);
memcpy(sc_handler->protocol.buffer, alpn_result.ProtocolId, alpn_result.ProtocolIdSize);
sc_handler->protocol.len = alpn_result.ProtocolIdSize;
AWS_LOGF_DEBUG(
AWS_LS_IO_TLS, "id=%p: negotiated protocol %s", handler, (char *)sc_handler->protocol.buffer);
} else {
AWS_LOGF_WARN(
AWS_LS_IO_TLS,
"id=%p: Error retrieving negotiated protocol. SECURITY_STATUS is %d",
handler,
(int)status);
int aws_error = s_determine_sspi_error(status);
aws_raise_error(aws_error);
}
}
#endif
sc_handler->s_connection_state_fn = s_do_application_data_decrypt;
AWS_LOGF_DEBUG(AWS_LS_IO_TLS, "id=%p: TLS handshake completed successfully.", (void *)handler);
s_on_negotiation_success(handler);
}
return AWS_OP_SUCCESS;
}
static int s_do_client_side_negotiation_step_2(struct aws_channel_handler *handler);
/* send the client hello */
static int s_do_client_side_negotiation_step_1(struct aws_channel_handler *handler) {
struct secure_channel_handler *sc_handler = handler->impl;
AWS_LOGF_TRACE(AWS_LS_IO_TLS, "id=%p: client starting negotiation", (void *)handler);
aws_on_drive_tls_negotiation(&sc_handler->shared_state);
unsigned char alpn_buffer_data[128] = {0};
SecBuffer input_buf = {
.pvBuffer = NULL,
.cbBuffer = 0,
.BufferType = SECBUFFER_EMPTY,
};
SecBufferDesc input_buf_desc = {
.ulVersion = SECBUFFER_VERSION,
.cBuffers = 1,
.pBuffers = &input_buf,
};
SecBufferDesc *alpn_sspi_data = NULL;
/* add alpn data to the client hello if it's supported. */
#ifdef SECBUFFER_APPLICATION_PROTOCOLS
if (sc_handler->alpn_list && aws_tls_is_alpn_available()) {
AWS_LOGF_DEBUG(
AWS_LS_IO_TLS, "id=%p: Setting ALPN data as %s", handler, aws_string_c_str(sc_handler->alpn_list));
size_t extension_length = 0;
if (s_fillin_alpn_data(handler, alpn_buffer_data, sizeof(alpn_buffer_data), &extension_length)) {
s_invoke_negotiation_error(handler, aws_last_error());
return AWS_OP_ERR;
}
input_buf.pvBuffer = alpn_buffer_data, input_buf.cbBuffer = (unsigned long)extension_length,
input_buf.BufferType = SECBUFFER_APPLICATION_PROTOCOLS;
alpn_sspi_data = &input_buf_desc;
}
#endif /* SECBUFFER_APPLICATION_PROTOCOLS*/
sc_handler->ctx_req = ISC_REQ_SEQUENCE_DETECT | ISC_REQ_REPLAY_DETECT | ISC_REQ_CONFIDENTIALITY |
ISC_REQ_ALLOCATE_MEMORY | ISC_REQ_STREAM;
SecBuffer output_buffer = {
.pvBuffer = NULL,
.cbBuffer = 0,
.BufferType = SECBUFFER_EMPTY,
};
SecBufferDesc output_buffer_desc = {
.ulVersion = SECBUFFER_VERSION,
.cBuffers = 1,
.pBuffers = &output_buffer,
};
char server_name_cstr[256];
AWS_ZERO_ARRAY(server_name_cstr);
AWS_ASSERT(sc_handler->server_name.len < 256);
memcpy(server_name_cstr, sc_handler->server_name.buffer, sc_handler->server_name.len);
SECURITY_STATUS status = InitializeSecurityContextA(
&sc_handler->creds,
NULL,
(SEC_CHAR *)server_name_cstr,
sc_handler->ctx_req,
0,
0,
alpn_sspi_data,
0,
&sc_handler->sec_handle,
&output_buffer_desc,
&sc_handler->ctx_ret_flags,
&sc_handler->sspi_timestamp);
if (status != SEC_I_CONTINUE_NEEDED) {
AWS_LOGF_ERROR(
AWS_LS_IO_TLS,
"id=%p: Error sending client/receiving server handshake data. SECURITY_STATUS is %d",
(void *)handler,
(int)status);
int aws_error = s_determine_sspi_error(status);
aws_raise_error(aws_error);
s_invoke_negotiation_error(handler, aws_error);
return AWS_OP_ERR;
}
size_t data_to_write_len = output_buffer.cbBuffer;
AWS_LOGF_TRACE(
AWS_LS_IO_TLS, "id=%p: Sending client handshake data of size %zu", (void *)handler, data_to_write_len);
struct aws_io_message *outgoing_message = aws_channel_acquire_message_from_pool(
sc_handler->slot->channel, AWS_IO_MESSAGE_APPLICATION_DATA, data_to_write_len);
if (!outgoing_message) {
FreeContextBuffer(output_buffer.pvBuffer);
s_invoke_negotiation_error(handler, aws_last_error());
return AWS_OP_ERR;
}
AWS_ASSERT(outgoing_message->message_data.capacity >= data_to_write_len);
memcpy(outgoing_message->message_data.buffer, output_buffer.pvBuffer, output_buffer.cbBuffer);
outgoing_message->message_data.len = output_buffer.cbBuffer;
FreeContextBuffer(output_buffer.pvBuffer);
if (aws_channel_slot_send_message(sc_handler->slot, outgoing_message, AWS_CHANNEL_DIR_WRITE)) {
aws_mem_release(outgoing_message->allocator, outgoing_message);
s_invoke_negotiation_error(handler, aws_last_error());
return AWS_OP_ERR;
}
sc_handler->s_connection_state_fn = s_do_client_side_negotiation_step_2;
return AWS_OP_SUCCESS;
}
/* cipher exchange, key exchange etc.... */
static int s_do_client_side_negotiation_step_2(struct aws_channel_handler *handler) {
struct secure_channel_handler *sc_handler = handler->impl;
AWS_LOGF_TRACE(
AWS_LS_IO_TLS,
"id=%p: running step 2 of client-side negotiation (cipher change, key exchange etc...)",
(void *)handler);
SecBuffer input_buffers[] = {
[0] =
{
.pvBuffer = sc_handler->buffered_read_in_data_buf.buffer,
.cbBuffer = (unsigned long)sc_handler->buffered_read_in_data_buf.len,
.BufferType = SECBUFFER_TOKEN,
},
[1] =
{
.pvBuffer = NULL,
.cbBuffer = 0,
.BufferType = SECBUFFER_EMPTY,
},
};
SecBufferDesc input_buffers_desc = {
.ulVersion = SECBUFFER_VERSION,
.cBuffers = 2,
.pBuffers = input_buffers,
};
SecBuffer output_buffers[3];
AWS_ZERO_ARRAY(output_buffers);
output_buffers[0].BufferType = SECBUFFER_TOKEN;
output_buffers[1].BufferType = SECBUFFER_ALERT;
SecBufferDesc output_buffers_desc = {
.ulVersion = SECBUFFER_VERSION,
.cBuffers = 3,
.pBuffers = output_buffers,
};
SECURITY_STATUS status = SEC_E_OK;
sc_handler->read_extra = 0;
sc_handler->estimated_incomplete_size = 0;
char server_name_cstr[256];
AWS_ZERO_ARRAY(server_name_cstr);
AWS_FATAL_ASSERT(sc_handler->server_name.len < sizeof(server_name_cstr));
memcpy(server_name_cstr, sc_handler->server_name.buffer, sc_handler->server_name.len);
status = InitializeSecurityContextA(
&sc_handler->creds,
&sc_handler->sec_handle,
(SEC_CHAR *)server_name_cstr,
sc_handler->ctx_req,
0,
0,
&input_buffers_desc,
0,
NULL,
&output_buffers_desc,
&sc_handler->ctx_ret_flags,
&sc_handler->sspi_timestamp);
if (status != SEC_E_INCOMPLETE_MESSAGE && status != SEC_I_CONTINUE_NEEDED && status != SEC_E_OK) {
AWS_LOGF_ERROR(
AWS_LS_IO_TLS, "id=%p: Error during negotiation. SECURITY_STATUS is %d", (void *)handler, (int)status);
int aws_error = s_determine_sspi_error(status);
aws_raise_error(aws_error);
s_invoke_negotiation_error(handler, aws_error);
return AWS_OP_ERR;
}
if (status == SEC_E_INCOMPLETE_MESSAGE) {
sc_handler->estimated_incomplete_size = input_buffers[1].cbBuffer;
AWS_LOGF_TRACE(
AWS_LS_IO_TLS,
"id=%p: Incomplete buffer recieved. Incomplete size is %zu. Waiting for more data.",
(void *)handler,
sc_handler->estimated_incomplete_size);
return aws_raise_error(AWS_IO_READ_WOULD_BLOCK);
}
if (status == SEC_I_CONTINUE_NEEDED || status == SEC_E_OK) {
for (size_t i = 0; i < output_buffers_desc.cBuffers; ++i) {
SecBuffer *buf_ptr = &output_buffers[i];
if (buf_ptr->BufferType == SECBUFFER_TOKEN && buf_ptr->cbBuffer) {
struct aws_io_message *outgoing_message = aws_channel_acquire_message_from_pool(
sc_handler->slot->channel, AWS_IO_MESSAGE_APPLICATION_DATA, buf_ptr->cbBuffer);
if (!outgoing_message) {
FreeContextBuffer(buf_ptr->pvBuffer);
s_invoke_negotiation_error(handler, aws_last_error());
return AWS_OP_ERR;
}
memcpy(outgoing_message->message_data.buffer, buf_ptr->pvBuffer, buf_ptr->cbBuffer);
outgoing_message->message_data.len = buf_ptr->cbBuffer;
FreeContextBuffer(buf_ptr->pvBuffer);
if (aws_channel_slot_send_message(sc_handler->slot, outgoing_message, AWS_CHANNEL_DIR_WRITE)) {
aws_mem_release(outgoing_message->allocator, outgoing_message);
s_invoke_negotiation_error(handler, aws_last_error());
return AWS_OP_ERR;
}
}
}
if (input_buffers[1].BufferType == SECBUFFER_EXTRA && input_buffers[1].cbBuffer > 0) {
AWS_LOGF_TRACE(
AWS_LS_IO_TLS,
"id=%p: Extra data recieved. Extra data size is %lu.",
(void *)handler,
input_buffers[1].cbBuffer);
sc_handler->read_extra = input_buffers[1].cbBuffer;
}
}
if (status == SEC_E_OK) {
AWS_LOGF_TRACE(AWS_LS_IO_TLS, "id=%p: handshake completed", handler);
/* if a custom CA store was configured, we have to do the verification ourselves. */
if (sc_handler->custom_ca_store) {
AWS_LOGF_TRACE(
AWS_LS_IO_TLS,
"id=%p: Custom CA was configured, evaluating trust before completing connection",
(void *)handler);
if (s_manually_verify_peer_cert(handler)) {
aws_raise_error(AWS_IO_TLS_ERROR_NEGOTIATION_FAILURE);
s_invoke_negotiation_error(handler, AWS_IO_TLS_ERROR_NEGOTIATION_FAILURE);
return AWS_OP_ERR;
}
}
sc_handler->negotiation_finished = true;
/* force the sizes query, so future Encrypt message calls work.*/
s_message_overhead(handler);
#ifdef SECBUFFER_APPLICATION_PROTOCOLS
if (sc_handler->alpn_list && aws_tls_is_alpn_available()) {
AWS_LOGF_TRACE(AWS_LS_IO_TLS, "id=%p: Retrieving negotiated protocol.", handler);
SecPkgContext_ApplicationProtocol alpn_result;
status = QueryContextAttributes(&sc_handler->sec_handle, SECPKG_ATTR_APPLICATION_PROTOCOL, &alpn_result);
if (status == SEC_E_OK && alpn_result.ProtoNegoStatus == SecApplicationProtocolNegotiationStatus_Success) {
aws_byte_buf_init(&sc_handler->protocol, handler->alloc, alpn_result.ProtocolIdSize + 1);
memset(sc_handler->protocol.buffer, 0, alpn_result.ProtocolIdSize + 1);
memcpy(sc_handler->protocol.buffer, alpn_result.ProtocolId, alpn_result.ProtocolIdSize);
sc_handler->protocol.len = alpn_result.ProtocolIdSize;
AWS_LOGF_DEBUG(
AWS_LS_IO_TLS, "id=%p: Negotiated protocol %s", handler, (char *)sc_handler->protocol.buffer);
} else {
AWS_LOGF_WARN(
AWS_LS_IO_TLS,
"id=%p: Error retrieving negotiated protocol. SECURITY_STATUS is %d",
handler,
(int)status);
int aws_error = s_determine_sspi_error(status);
aws_raise_error(aws_error);
}
}
#endif
AWS_LOGF_DEBUG(AWS_LS_IO_TLS, "id=%p: TLS handshake completed successfully.", (void *)handler);
sc_handler->s_connection_state_fn = s_do_application_data_decrypt;
s_on_negotiation_success(handler);
}
return AWS_OP_SUCCESS;
}
static int s_do_application_data_decrypt(struct aws_channel_handler *handler) {
struct secure_channel_handler *sc_handler = handler->impl;
/* I know this is an unncessary initialization, it's initialized here to make linters happy.*/
int error = AWS_OP_ERR;
/* when we get an Extra buffer we have to move the pointer and replay the buffer, so we loop until we don't have
any extra buffers left over, in the last phase, we then go ahead and send the output. This state function will
always say BLOCKED_ON_READ, AWS_IO_TLS_ERROR_READ_FAILURE or SUCCESS. There will never be left over reads.*/
do {
error = AWS_OP_ERR;
/* 4 buffers are needed, only one is input, the others get zeroed out for the output operation. */
SecBuffer input_buffers[4];
AWS_ZERO_ARRAY(input_buffers);
size_t read_len = sc_handler->read_extra ? sc_handler->read_extra : sc_handler->buffered_read_in_data_buf.len;
size_t offset = sc_handler->read_extra ? sc_handler->buffered_read_in_data_buf.len - sc_handler->read_extra : 0;
sc_handler->read_extra = 0;
input_buffers[0] = (SecBuffer){
.cbBuffer = (unsigned long)(read_len),
.pvBuffer = sc_handler->buffered_read_in_data_buf.buffer + offset,
.BufferType = SECBUFFER_DATA,
};
SecBufferDesc buffer_desc = {
.ulVersion = SECBUFFER_VERSION,
.cBuffers = 4,
.pBuffers = input_buffers,
};
SECURITY_STATUS status = DecryptMessage(&sc_handler->sec_handle, &buffer_desc, 0, NULL);
if (status == SEC_E_OK) {
error = AWS_OP_SUCCESS;
/* if SECBUFFER_DATA is the buffer type of the second buffer, we have decrypted data to process.
If SECBUFFER_DATA is the type for the fourth buffer we need to keep track of it so we can shift
everything before doing another decrypt operation.
We don't care what's in the third buffer for TLS usage.*/
if (input_buffers[1].BufferType == SECBUFFER_DATA) {
size_t decrypted_length = input_buffers[1].cbBuffer;
AWS_LOGF_TRACE(
AWS_LS_IO_TLS, "id=%p: Decrypted message with length %zu.", (void *)handler, decrypted_length);
struct aws_byte_cursor to_append =
aws_byte_cursor_from_array(input_buffers[1].pvBuffer, decrypted_length);
int append_failed = aws_byte_buf_append(&sc_handler->buffered_read_out_data_buf, &to_append);
AWS_ASSERT(!append_failed);
(void)append_failed;
/* if we have extra we have to move the pointer and do another Decrypt operation. */
if (input_buffers[3].BufferType == SECBUFFER_EXTRA) {
sc_handler->read_extra = input_buffers[3].cbBuffer;
AWS_LOGF_TRACE(
AWS_LS_IO_TLS,
"id=%p: Extra (incomplete) message received with length %zu.",
(void *)handler,
sc_handler->read_extra);
} else {
error = AWS_OP_SUCCESS;
/* this means we processed everything in the buffer. */
sc_handler->buffered_read_in_data_buf.len = 0;
AWS_LOGF_TRACE(
AWS_LS_IO_TLS,
"id=%p: Decrypt ended exactly on the end of the record, resetting buffer.",
(void *)handler);
}
}
}
/* SEC_E_INCOMPLETE_MESSAGE means the message we tried to decrypt isn't a full record and we need to
append our next read to it and try again. */
else if (status == SEC_E_INCOMPLETE_MESSAGE) {
sc_handler->estimated_incomplete_size = input_buffers[1].cbBuffer;
AWS_LOGF_TRACE(
AWS_LS_IO_TLS,
"id=%p: (incomplete) message received. Expecting remaining portion of size %zu.",
(void *)handler,
sc_handler->estimated_incomplete_size);
memmove(
sc_handler->buffered_read_in_data_buf.buffer,
sc_handler->buffered_read_in_data_buf.buffer + offset,
read_len);
sc_handler->buffered_read_in_data_buf.len = read_len;
aws_raise_error(AWS_IO_READ_WOULD_BLOCK);
}
/* SEC_I_CONTEXT_EXPIRED means that the message sender has shut down the connection. One such case
where this can happen is an unaccepted certificate. */
else if (status == SEC_I_CONTEXT_EXPIRED) {
AWS_LOGF_TRACE(
AWS_LS_IO_TLS,
"id=%p: Alert received. Message sender has shut down the connection. SECURITY_STATUS is %d.",
(void *)handler,
(int)status);
struct aws_channel_slot *slot = handler->slot;
aws_channel_shutdown(slot->channel, AWS_OP_SUCCESS);
error = AWS_OP_SUCCESS;
} else {
AWS_LOGF_ERROR(
AWS_LS_IO_TLS, "id=%p: Error decrypting message. SECURITY_STATUS is %d.", (void *)handler, (int)status);
aws_raise_error(AWS_IO_TLS_ERROR_READ_FAILURE);
}
} while (sc_handler->read_extra);
return error;
}
static int s_process_pending_output_messages(struct aws_channel_handler *handler) {
struct secure_channel_handler *sc_handler = handler->impl;
size_t downstream_window = SIZE_MAX;
if (sc_handler->slot->adj_right) {
downstream_window = aws_channel_slot_downstream_read_window(sc_handler->slot);
}
AWS_LOGF_TRACE(
AWS_LS_IO_TLS,
"id=%p: Processing incomming messages. Downstream window is %zu",
(void *)handler,
downstream_window);
while (sc_handler->buffered_read_out_data_buf.len && downstream_window) {
size_t requested_message_size = sc_handler->buffered_read_out_data_buf.len > downstream_window
? downstream_window
: sc_handler->buffered_read_out_data_buf.len;
AWS_LOGF_TRACE(AWS_LS_IO_TLS, "id=%p: Requested message size is %zu", (void *)handler, requested_message_size);
if (sc_handler->slot->adj_right) {
struct aws_io_message *read_out_msg = aws_channel_acquire_message_from_pool(
sc_handler->slot->channel, AWS_IO_MESSAGE_APPLICATION_DATA, requested_message_size);
if (!read_out_msg) {
return AWS_OP_ERR;
}
size_t copy_size = read_out_msg->message_data.capacity < requested_message_size
? read_out_msg->message_data.capacity
: requested_message_size;
memcpy(read_out_msg->message_data.buffer, sc_handler->buffered_read_out_data_buf.buffer, copy_size);
read_out_msg->message_data.len = copy_size;
memmove(
sc_handler->buffered_read_out_data_buf.buffer,
sc_handler->buffered_read_out_data_buf.buffer + copy_size,
sc_handler->buffered_read_out_data_buf.len - copy_size);
sc_handler->buffered_read_out_data_buf.len -= copy_size;
if (sc_handler->on_data_read) {
sc_handler->on_data_read(handler, sc_handler->slot, &read_out_msg->message_data, sc_handler->user_data);
}
if (aws_channel_slot_send_message(sc_handler->slot, read_out_msg, AWS_CHANNEL_DIR_READ)) {
aws_mem_release(read_out_msg->allocator, read_out_msg);
return AWS_OP_ERR;
}
if (sc_handler->slot->adj_right) {
downstream_window = aws_channel_slot_downstream_read_window(sc_handler->slot);
}
AWS_LOGF_TRACE(AWS_LS_IO_TLS, "id=%p: Downstream window is %zu", (void *)handler, downstream_window);
} else {
if (sc_handler->on_data_read) {
sc_handler->on_data_read(
handler, sc_handler->slot, &sc_handler->buffered_read_out_data_buf, sc_handler->user_data);
}
sc_handler->buffered_read_out_data_buf.len = 0;
}
}
return AWS_OP_SUCCESS;
}
static void s_process_pending_output_task(struct aws_channel_task *task, void *arg, enum aws_task_status status) {
(void)task;
struct aws_channel_handler *handler = arg;
aws_channel_task_init(task, NULL, NULL, "secure_channel_handler_process_pending_output");
if (status == AWS_TASK_STATUS_RUN_READY) {
if (s_process_pending_output_messages(handler)) {
struct secure_channel_handler *sc_handler = arg;
aws_channel_shutdown(sc_handler->slot->channel, aws_last_error());
}
}
}
static int s_process_read_message(
struct aws_channel_handler *handler,
struct aws_channel_slot *slot,
struct aws_io_message *message) {
struct secure_channel_handler *sc_handler = handler->impl;
if (message) {
/* note, most of these functions log internally, so the log messages in this function are sparse. */
AWS_LOGF_TRACE(
AWS_LS_IO_TLS,
"id=%p: processing incoming message of size %zu",
(void *)handler,
message->message_data.len);
struct aws_byte_cursor message_cursor = aws_byte_cursor_from_buf(&message->message_data);
/* The SSPI interface forces us to manage incomplete records manually. So when we had extra after
the previous read, it needs to be shifted to the beginning of the current read, then the current
read data is appended to it. If we had an incomplete record, we don't need to shift anything but
we do need to append the current read data to the end of the incomplete record from the previous read.
Keep going until we've processed everything in the message we were just passed.
*/
int err = AWS_OP_SUCCESS;
while (!err && message_cursor.len) {
size_t available_buffer_space =
sc_handler->buffered_read_in_data_buf.capacity - sc_handler->buffered_read_in_data_buf.len;
size_t available_message_len = message_cursor.len;
size_t amount_to_move_to_buffer =
available_buffer_space > available_message_len ? available_message_len : available_buffer_space;
memcpy(
sc_handler->buffered_read_in_data_buf.buffer + sc_handler->buffered_read_in_data_buf.len,
message_cursor.ptr,
amount_to_move_to_buffer);
sc_handler->buffered_read_in_data_buf.len += amount_to_move_to_buffer;
err = sc_handler->s_connection_state_fn(handler);
if (err && aws_last_error() == AWS_IO_READ_WOULD_BLOCK) {
if (sc_handler->buffered_read_in_data_buf.len == sc_handler->buffered_read_in_data_buf.capacity) {
/* throw this one as a protocol error. */
aws_raise_error(AWS_IO_TLS_ERROR_WRITE_FAILURE);
} else {
if (sc_handler->buffered_read_out_data_buf.len) {
err = s_process_pending_output_messages(handler);
if (err) {
break;
}
}
/* prevent a deadlock due to downstream handlers wanting more data, but we have an incomplete
record, and the amount they're requesting is less than the size of a tls record. */
size_t window_size = slot->window_size;
if (!window_size &&
aws_channel_slot_increment_read_window(slot, sc_handler->estimated_incomplete_size)) {
err = AWS_OP_ERR;
} else {
sc_handler->estimated_incomplete_size = 0;
err = AWS_OP_SUCCESS;
}
}
aws_byte_cursor_advance(&message_cursor, amount_to_move_to_buffer);
continue;
} else if (err) {
break;
}
/* handle any left over extra data from the decrypt operation here. */
if (sc_handler->read_extra) {
size_t move_pos = sc_handler->buffered_read_in_data_buf.len - sc_handler->read_extra;
memmove(
sc_handler->buffered_read_in_data_buf.buffer,
sc_handler->buffered_read_in_data_buf.buffer + move_pos,
sc_handler->read_extra);
sc_handler->buffered_read_in_data_buf.len = sc_handler->read_extra;
sc_handler->read_extra = 0;
} else {
sc_handler->buffered_read_in_data_buf.len = 0;
}
if (sc_handler->buffered_read_out_data_buf.len) {
err = s_process_pending_output_messages(handler);
if (err) {
break;
}
}
aws_byte_cursor_advance(&message_cursor, amount_to_move_to_buffer);
}
if (!err) {
aws_mem_release(message->allocator, message);
return AWS_OP_SUCCESS;
}
aws_channel_shutdown(slot->channel, aws_last_error());
return AWS_OP_ERR;
}
if (sc_handler->buffered_read_out_data_buf.len) {
if (s_process_pending_output_messages(handler)) {
return AWS_OP_ERR;
}
aws_mem_release(message->allocator, message);
}
return AWS_OP_SUCCESS;
}
static int s_process_write_message(
struct aws_channel_handler *handler,
struct aws_channel_slot *slot,
struct aws_io_message *message) {
struct secure_channel_handler *sc_handler = (struct secure_channel_handler *)handler->impl;
AWS_ASSERT(sc_handler->negotiation_finished);
SECURITY_STATUS status = SEC_E_OK;
if (message) {
AWS_LOGF_TRACE(
AWS_LS_IO_TLS, "id=%p: processing ougoing message of size %zu", (void *)handler, message->message_data.len);
struct aws_byte_cursor message_cursor = aws_byte_cursor_from_buf(&message->message_data);
while (message_cursor.len) {
AWS_LOGF_TRACE(
AWS_LS_IO_TLS, "id=%p: processing message fragment of size %zu", (void *)handler, message_cursor.len);
/* message size will be the lesser of either payload + record overhead or the max TLS record size.*/
size_t upstream_overhead = aws_channel_slot_upstream_message_overhead(sc_handler->slot);
upstream_overhead += sc_handler->stream_sizes.cbHeader + sc_handler->stream_sizes.cbTrailer;
size_t requested_length = message_cursor.len + upstream_overhead;
size_t to_write = sc_handler->stream_sizes.cbMaximumMessage < requested_length
? sc_handler->stream_sizes.cbMaximumMessage
: requested_length;
struct aws_io_message *outgoing_message =
aws_channel_acquire_message_from_pool(slot->channel, AWS_IO_MESSAGE_APPLICATION_DATA, to_write);
if (!outgoing_message || outgoing_message->message_data.capacity <= upstream_overhead) {
return AWS_OP_ERR;
}
/* what if message is larger than one record? */
size_t original_message_fragment_to_process = outgoing_message->message_data.capacity - upstream_overhead;
memcpy(
outgoing_message->message_data.buffer + sc_handler->stream_sizes.cbHeader,
message_cursor.ptr,
original_message_fragment_to_process);
if (original_message_fragment_to_process == message_cursor.len) {
outgoing_message->on_completion = message->on_completion;
outgoing_message->user_data = message->user_data;
}
SecBuffer buffers[4] = {
[0] =
{
.BufferType = SECBUFFER_STREAM_HEADER,
.pvBuffer = outgoing_message->message_data.buffer,
.cbBuffer = sc_handler->stream_sizes.cbHeader,
},
[1] =
{
.BufferType = SECBUFFER_DATA,
.pvBuffer = outgoing_message->message_data.buffer + sc_handler->stream_sizes.cbHeader,
.cbBuffer = (unsigned long)original_message_fragment_to_process,
},
[2] =
{
.BufferType = SECBUFFER_STREAM_TRAILER,
.pvBuffer = outgoing_message->message_data.buffer + sc_handler->stream_sizes.cbHeader +
original_message_fragment_to_process,
.cbBuffer = sc_handler->stream_sizes.cbTrailer,
},
[3] =
{
.BufferType = SECBUFFER_EMPTY,
.pvBuffer = NULL,
.cbBuffer = 0,
},
};
SecBufferDesc buffer_desc = {
.ulVersion = SECBUFFER_VERSION,
.cBuffers = 4,
.pBuffers = buffers,
};
status = EncryptMessage(&sc_handler->sec_handle, 0, &buffer_desc, 0);
if (status == SEC_E_OK) {
outgoing_message->message_data.len = buffers[0].cbBuffer + buffers[1].cbBuffer + buffers[2].cbBuffer;
AWS_LOGF_TRACE(
AWS_LS_IO_TLS,
"id=%p:message fragment encrypted successfully: size is %zu",
(void *)handler,
outgoing_message->message_data.len);
if (aws_channel_slot_send_message(slot, outgoing_message, AWS_CHANNEL_DIR_WRITE)) {
aws_mem_release(outgoing_message->allocator, outgoing_message);
return AWS_OP_ERR;
}
aws_byte_cursor_advance(&message_cursor, original_message_fragment_to_process);
} else {
AWS_LOGF_TRACE(
AWS_LS_IO_TLS,
"id=%p: Error encrypting message. SECURITY_STATUS is %d",
(void *)handler,
(int)status);
return aws_raise_error(AWS_IO_TLS_ERROR_WRITE_FAILURE);
}
}
aws_mem_release(message->allocator, message);
}
return AWS_OP_SUCCESS;
}
static int s_increment_read_window(struct aws_channel_handler *handler, struct aws_channel_slot *slot, size_t size) {
(void)size;
struct secure_channel_handler *sc_handler = handler->impl;
AWS_LOGF_TRACE(AWS_LS_IO_TLS, "id=%p: Increment read window message received %zu", (void *)handler, size);
/* You can't query a context if negotiation isn't completed, since ciphers haven't been negotiated
* and it couldn't possibly know the overhead size yet. */
if (sc_handler->negotiation_finished && !sc_handler->stream_sizes.cbMaximumMessage) {
SECURITY_STATUS status =
QueryContextAttributes(&sc_handler->sec_handle, SECPKG_ATTR_STREAM_SIZES, &sc_handler->stream_sizes);
if (status != SEC_E_OK) {
AWS_LOGF_ERROR(
AWS_LS_IO_TLS, "id=%p: QueryContextAttributes failed with error %d", (void *)handler, (int)status);
aws_raise_error(AWS_ERROR_SYS_CALL_FAILURE);
aws_channel_shutdown(slot->channel, AWS_ERROR_SYS_CALL_FAILURE);
return AWS_OP_ERR;
}
}
size_t total_desired_size = size;
size_t downstream_size = aws_channel_slot_downstream_read_window(slot);
size_t current_window_size = slot->window_size;
/* the only time this branch isn't taken is when a window update is propagated during tls negotiation.
* in that case just pass it through. */
if (sc_handler->stream_sizes.cbMaximumMessage) {
size_t likely_records_count = (size_t)ceil((double)(downstream_size) / (double)(READ_IN_SIZE));
size_t offset_size = aws_mul_size_saturating(
likely_records_count, sc_handler->stream_sizes.cbTrailer + sc_handler->stream_sizes.cbHeader);
total_desired_size = aws_add_size_saturating(offset_size, downstream_size);
}
if (total_desired_size > current_window_size) {
size_t window_update_size = total_desired_size - current_window_size;
AWS_LOGF_TRACE(
AWS_LS_IO_TLS, "id=%p: Propagating read window increment of size %zu", (void *)handler, window_update_size);
aws_channel_slot_increment_read_window(slot, window_update_size);
}
if (sc_handler->negotiation_finished && !sc_handler->sequential_task_storage.task_fn) {
aws_channel_task_init(
&sc_handler->sequential_task_storage,
s_process_pending_output_task,
handler,
"secure_channel_handler_process_pending_output_on_window_increment");
aws_channel_schedule_task_now(slot->channel, &sc_handler->sequential_task_storage);
}
return AWS_OP_SUCCESS;
}
static size_t s_initial_window_size(struct aws_channel_handler *handler) {
(void)handler;
/* set this to just enough for the handshake, once the handshake completes, the downstream
handler will tell us the new window size. */
return EST_HANDSHAKE_SIZE;
}
static int s_handler_shutdown(
struct aws_channel_handler *handler,
struct aws_channel_slot *slot,
enum aws_channel_direction dir,
int error_code,
bool abort_immediately) {
struct secure_channel_handler *sc_handler = handler->impl;
if (dir == AWS_CHANNEL_DIR_WRITE) {
if (!abort_immediately && error_code != AWS_IO_SOCKET_CLOSED) {
AWS_LOGF_DEBUG(AWS_LS_IO_TLS, "id=%p: Shutting down the write direction", (void *)handler);
/* send a TLS alert. */
SECURITY_STATUS status;
DWORD shutdown_code = SCHANNEL_SHUTDOWN;
SecBuffer shutdown_buffer = {
.pvBuffer = &shutdown_code,
.cbBuffer = sizeof(shutdown_code),
.BufferType = SECBUFFER_TOKEN,
};
SecBufferDesc shutdown_buffer_desc = {
.ulVersion = SECBUFFER_VERSION,
.cBuffers = 1,
.pBuffers = &shutdown_buffer,
};
/* this updates the SSPI internal state machine. */
status = ApplyControlToken(&sc_handler->sec_handle, &shutdown_buffer_desc);
if (status != SEC_E_OK) {
aws_raise_error(AWS_ERROR_SYS_CALL_FAILURE);
return aws_channel_slot_on_handler_shutdown_complete(
slot, dir, AWS_ERROR_SYS_CALL_FAILURE, abort_immediately);
}
SecBuffer output_buffer = {
.pvBuffer = NULL,
.cbBuffer = 0,
.BufferType = SECBUFFER_EMPTY,
};
SecBufferDesc output_buffer_desc = {
.ulVersion = SECBUFFER_VERSION,
.cBuffers = 1,
.pBuffers = &output_buffer,
};
struct aws_byte_buf server_name = aws_tls_handler_server_name(handler);
char server_name_cstr[256];
AWS_ZERO_ARRAY(server_name_cstr);
AWS_FATAL_ASSERT(server_name.len < sizeof(server_name_cstr));
memcpy(server_name_cstr, server_name.buffer, server_name.len);
/* this acutally gives us an Alert record to send. */
status = InitializeSecurityContextA(
&sc_handler->creds,
&sc_handler->sec_handle,
(SEC_CHAR *)server_name_cstr,
sc_handler->ctx_req,
0,
0,
NULL,
0,
NULL,
&output_buffer_desc,
&sc_handler->ctx_ret_flags,
NULL);
if (status == SEC_E_OK || status == SEC_I_CONTEXT_EXPIRED) {
struct aws_io_message *outgoing_message = aws_channel_acquire_message_from_pool(
slot->channel, AWS_IO_MESSAGE_APPLICATION_DATA, output_buffer.cbBuffer);
if (!outgoing_message || outgoing_message->message_data.capacity < output_buffer.cbBuffer) {
return aws_channel_slot_on_handler_shutdown_complete(slot, dir, aws_last_error(), true);
}
memcpy(outgoing_message->message_data.buffer, output_buffer.pvBuffer, output_buffer.cbBuffer);
outgoing_message->message_data.len = output_buffer.cbBuffer;
/* we don't really care if this succeeds or not, it's just sending the TLS alert. */
if (aws_channel_slot_send_message(slot, outgoing_message, AWS_CHANNEL_DIR_WRITE)) {
aws_mem_release(outgoing_message->allocator, outgoing_message);
}
}
}
}
return aws_channel_slot_on_handler_shutdown_complete(slot, dir, error_code, abort_immediately);
}
static void s_do_negotiation_task(struct aws_channel_task *task, void *arg, enum aws_task_status status) {
(void)task;
struct aws_channel_handler *handler = arg;
struct secure_channel_handler *sc_handler = handler->impl;
if (status == AWS_TASK_STATUS_RUN_READY) {
int err = sc_handler->s_connection_state_fn(handler);
if (err) {
aws_channel_shutdown(sc_handler->slot->channel, aws_last_error());
}
}
}
static void s_secure_channel_handler_destroy(
struct aws_allocator *allocator,
struct secure_channel_handler *sc_handler) {
if (sc_handler == NULL) {
return;
}
if (sc_handler->protocol.buffer) {
aws_byte_buf_clean_up(&sc_handler->protocol);
}
if (sc_handler->alpn_list) {
aws_string_destroy(sc_handler->alpn_list);
}
if (sc_handler->server_name.buffer) {
aws_byte_buf_clean_up(&sc_handler->server_name);
}
if (sc_handler->sec_handle.dwLower || sc_handler->sec_handle.dwUpper) {
DeleteSecurityContext(&sc_handler->sec_handle);
}
if (sc_handler->creds.dwLower || sc_handler->creds.dwUpper) {
DeleteSecurityContext(&sc_handler->creds);
}
aws_tls_channel_handler_shared_clean_up(&sc_handler->shared_state);
aws_mem_release(allocator, sc_handler);
}
static void s_handler_destroy(struct aws_channel_handler *handler) {
AWS_LOGF_DEBUG(AWS_LS_IO_TLS, "id=%p: destroying handler", (void *)handler);
struct secure_channel_handler *sc_handler = handler->impl;
s_secure_channel_handler_destroy(handler->alloc, sc_handler);
}
static void s_reset_statistics(struct aws_channel_handler *handler) {
struct secure_channel_handler *sc_handler = handler->impl;
aws_crt_statistics_tls_reset(&sc_handler->shared_state.stats);
}
static void s_gather_statistics(struct aws_channel_handler *handler, struct aws_array_list *stats) {
struct secure_channel_handler *sc_handler = handler->impl;
void *stats_base = &sc_handler->shared_state.stats;
aws_array_list_push_back(stats, &stats_base);
}
int aws_tls_client_handler_start_negotiation(struct aws_channel_handler *handler) {
AWS_LOGF_DEBUG(AWS_LS_IO_TLS, "id=%p: Kicking off TLS negotiation", (void *)handler);
struct secure_channel_handler *sc_handler = handler->impl;
if (aws_channel_thread_is_callers_thread(sc_handler->slot->channel)) {
int err = sc_handler->s_connection_state_fn(handler);
if (err) {
aws_channel_shutdown(sc_handler->slot->channel, aws_last_error());
}
return err;
}
aws_channel_task_init(
&sc_handler->sequential_task_storage,
s_do_negotiation_task,
handler,
"secure_channel_handler_start_negotation");
aws_channel_schedule_task_now(sc_handler->slot->channel, &sc_handler->sequential_task_storage);
return AWS_OP_SUCCESS;
}
struct aws_byte_buf aws_tls_handler_protocol(struct aws_channel_handler *handler) {
struct secure_channel_handler *sc_handler = handler->impl;
return sc_handler->protocol;
}
struct aws_byte_buf aws_tls_handler_server_name(struct aws_channel_handler *handler) {
struct secure_channel_handler *sc_handler = handler->impl;
return sc_handler->server_name;
}
static struct aws_channel_handler_vtable s_handler_vtable = {
.destroy = s_handler_destroy,
.process_read_message = s_process_read_message,
.process_write_message = s_process_write_message,
.shutdown = s_handler_shutdown,
.increment_read_window = s_increment_read_window,
.initial_window_size = s_initial_window_size,
.message_overhead = s_message_overhead,
.reset_statistics = s_reset_statistics,
.gather_statistics = s_gather_statistics,
};
static struct aws_channel_handler *s_tls_handler_new(
struct aws_allocator *alloc,
struct aws_tls_connection_options *options,
struct aws_channel_slot *slot,
bool is_client_mode) {
AWS_ASSERT(options->ctx);
struct secure_channel_handler *sc_handler = aws_mem_calloc(alloc, 1, sizeof(struct secure_channel_handler));
if (!sc_handler) {
return NULL;
}
sc_handler->handler.alloc = alloc;
sc_handler->handler.impl = sc_handler;
sc_handler->handler.vtable = &s_handler_vtable;
sc_handler->handler.slot = slot;
aws_tls_channel_handler_shared_init(&sc_handler->shared_state, &sc_handler->handler, options);
struct secure_channel_ctx *sc_ctx = options->ctx->impl;
unsigned long credential_use = SECPKG_CRED_INBOUND;
if (is_client_mode) {
credential_use = SECPKG_CRED_OUTBOUND;
}
SECURITY_STATUS status = AcquireCredentialsHandleA(
NULL,
UNISP_NAME,
credential_use,
NULL,
&sc_ctx->credentials,
NULL,
NULL,
&sc_handler->creds,
&sc_handler->sspi_timestamp);
if (status != SEC_E_OK) {
AWS_LOGF_ERROR(AWS_LS_IO_TLS, "Error on AcquireCredentialsHandle. SECURITY_STATUS is %d", (int)status);
int aws_error = s_determine_sspi_error(status);
aws_raise_error(aws_error);
goto on_error;
}
sc_handler->advertise_alpn_message = options->advertise_alpn_message;
sc_handler->on_data_read = options->on_data_read;
sc_handler->on_error = options->on_error;
sc_handler->on_negotiation_result = options->on_negotiation_result;
sc_handler->user_data = options->user_data;
if (!options->alpn_list && sc_ctx->alpn_list) {
sc_handler->alpn_list = aws_string_new_from_string(alloc, sc_ctx->alpn_list);
if (!sc_handler->alpn_list) {
goto on_error;
}
} else if (options->alpn_list) {
sc_handler->alpn_list = aws_string_new_from_string(alloc, options->alpn_list);
if (!sc_handler->alpn_list) {
goto on_error;
}
}
if (options->server_name) {
AWS_LOGF_DEBUG(
AWS_LS_IO_TLS,
"id=%p: Setting SNI to %s",
(void *)&sc_handler->handler,
aws_string_c_str(options->server_name));
struct aws_byte_cursor server_name_crsr = aws_byte_cursor_from_string(options->server_name);
if (aws_byte_buf_init_copy_from_cursor(&sc_handler->server_name, alloc, server_name_crsr)) {
goto on_error;
}
}
sc_handler->slot = slot;
if (is_client_mode) {
sc_handler->s_connection_state_fn = s_do_client_side_negotiation_step_1;
} else {
sc_handler->s_connection_state_fn = s_do_server_side_negotiation_step_1;
}
sc_handler->custom_ca_store = sc_ctx->custom_trust_store;
sc_handler->buffered_read_in_data_buf =
aws_byte_buf_from_array(sc_handler->buffered_read_in_data, sizeof(sc_handler->buffered_read_in_data));
sc_handler->buffered_read_in_data_buf.len = 0;
sc_handler->buffered_read_out_data_buf =
aws_byte_buf_from_array(sc_handler->buffered_read_out_data, sizeof(sc_handler->buffered_read_out_data));
sc_handler->buffered_read_out_data_buf.len = 0;
sc_handler->verify_peer = sc_ctx->verify_peer;
return &sc_handler->handler;
on_error:
s_secure_channel_handler_destroy(alloc, sc_handler);
return NULL;
}
struct aws_channel_handler *aws_tls_client_handler_new(
struct aws_allocator *allocator,
struct aws_tls_connection_options *options,
struct aws_channel_slot *slot) {
return s_tls_handler_new(allocator, options, slot, true);
}
struct aws_channel_handler *aws_tls_server_handler_new(
struct aws_allocator *allocator,
struct aws_tls_connection_options *options,
struct aws_channel_slot *slot) {
return s_tls_handler_new(allocator, options, slot, false);
}
static void s_secure_channel_ctx_destroy(struct secure_channel_ctx *secure_channel_ctx) {
if (secure_channel_ctx == NULL) {
return;
}
if (secure_channel_ctx->private_key) {
CryptDestroyKey(secure_channel_ctx->private_key);
}
if (secure_channel_ctx->crypto_provider) {
CryptReleaseContext(secure_channel_ctx->crypto_provider, 0);
}
if (secure_channel_ctx->custom_trust_store) {
aws_close_cert_store(secure_channel_ctx->custom_trust_store);
}
if (secure_channel_ctx->pcerts) {
/**
* Only free the private certificate context if the private key is NOT
* from the certificate context because freeing the private key
* using CryptDestroyKey frees the certificate context and then
* trying to access it leads to a access violation.
*/
if (secure_channel_ctx->should_free_pcerts == true) {
CertFreeCertificateContext(secure_channel_ctx->pcerts);
}
}
if (secure_channel_ctx->cert_store) {
aws_close_cert_store(secure_channel_ctx->cert_store);
}
if (secure_channel_ctx->alpn_list) {
aws_string_destroy(secure_channel_ctx->alpn_list);
}
aws_mem_release(secure_channel_ctx->ctx.alloc, secure_channel_ctx);
}
struct aws_tls_ctx *s_ctx_new(
struct aws_allocator *alloc,
const struct aws_tls_ctx_options *options,
bool is_client_mode) {
if (!aws_tls_is_cipher_pref_supported(options->cipher_pref)) {
aws_raise_error(AWS_IO_TLS_CIPHER_PREF_UNSUPPORTED);
AWS_LOGF_ERROR(AWS_LS_IO_TLS, "static: TLS Cipher Preference is not supported: %d.", options->cipher_pref);
return NULL;
}
struct secure_channel_ctx *secure_channel_ctx = aws_mem_calloc(alloc, 1, sizeof(struct secure_channel_ctx));
if (!secure_channel_ctx) {
return NULL;
}
secure_channel_ctx->ctx.alloc = alloc;
secure_channel_ctx->ctx.impl = secure_channel_ctx;
aws_ref_count_init(
&secure_channel_ctx->ctx.ref_count,
secure_channel_ctx,
(aws_simple_completion_callback *)s_secure_channel_ctx_destroy);
if (options->alpn_list) {
secure_channel_ctx->alpn_list = aws_string_new_from_string(alloc, options->alpn_list);
if (!secure_channel_ctx->alpn_list) {
goto clean_up;
}
}
secure_channel_ctx->verify_peer = options->verify_peer;
secure_channel_ctx->credentials.dwVersion = SCHANNEL_CRED_VERSION;
secure_channel_ctx->should_free_pcerts = true;
secure_channel_ctx->credentials.grbitEnabledProtocols = 0;
if (is_client_mode) {
switch (options->minimum_tls_version) {
case AWS_IO_SSLv3:
secure_channel_ctx->credentials.grbitEnabledProtocols |= SP_PROT_SSL3_CLIENT;
case AWS_IO_TLSv1:
secure_channel_ctx->credentials.grbitEnabledProtocols |= SP_PROT_TLS1_0_CLIENT;
case AWS_IO_TLSv1_1:
secure_channel_ctx->credentials.grbitEnabledProtocols |= SP_PROT_TLS1_1_CLIENT;
case AWS_IO_TLSv1_2:
#if defined(SP_PROT_TLS1_2_CLIENT)
secure_channel_ctx->credentials.grbitEnabledProtocols |= SP_PROT_TLS1_2_CLIENT;
#endif
case AWS_IO_TLSv1_3:
#if defined(SP_PROT_TLS1_3_CLIENT)
secure_channel_ctx->credentials.grbitEnabledProtocols |= SP_PROT_TLS1_3_CLIENT;
#endif
break;
case AWS_IO_TLS_VER_SYS_DEFAULTS:
secure_channel_ctx->credentials.grbitEnabledProtocols = 0;
break;
}
} else {
switch (options->minimum_tls_version) {
case AWS_IO_SSLv3:
secure_channel_ctx->credentials.grbitEnabledProtocols |= SP_PROT_SSL3_SERVER;
case AWS_IO_TLSv1:
secure_channel_ctx->credentials.grbitEnabledProtocols |= SP_PROT_TLS1_0_SERVER;
case AWS_IO_TLSv1_1:
secure_channel_ctx->credentials.grbitEnabledProtocols |= SP_PROT_TLS1_1_SERVER;
case AWS_IO_TLSv1_2:
#if defined(SP_PROT_TLS1_2_SERVER)
secure_channel_ctx->credentials.grbitEnabledProtocols |= SP_PROT_TLS1_2_SERVER;
#endif
case AWS_IO_TLSv1_3:
#if defined(SP_PROT_TLS1_3_SERVER)
secure_channel_ctx->credentials.grbitEnabledProtocols |= SP_PROT_TLS1_3_SERVER;
#endif
break;
case AWS_IO_TLS_VER_SYS_DEFAULTS:
secure_channel_ctx->credentials.grbitEnabledProtocols = 0;
break;
}
}
if (options->verify_peer && aws_tls_options_buf_is_set(&options->ca_file)) {
AWS_LOGF_DEBUG(AWS_LS_IO_TLS, "static: loading custom CA file.");
secure_channel_ctx->credentials.dwFlags = SCH_CRED_MANUAL_CRED_VALIDATION;
struct aws_byte_cursor ca_blob_cur = aws_byte_cursor_from_buf(&options->ca_file);
int error = aws_import_trusted_certificates(alloc, &ca_blob_cur, &secure_channel_ctx->custom_trust_store);
if (error) {
AWS_LOGF_ERROR(AWS_LS_IO_TLS, "static: failed to import custom CA with error %d", aws_last_error());
goto clean_up;
}
} else if (is_client_mode) {
secure_channel_ctx->credentials.dwFlags = SCH_CRED_AUTO_CRED_VALIDATION;
}
if (is_client_mode && !options->verify_peer) {
AWS_LOGF_WARN(
AWS_LS_IO_TLS,
"static: x.509 validation has been disabled. "
"If this is not running in a test environment, this is likely a security vulnerability.");
secure_channel_ctx->credentials.dwFlags &= ~(SCH_CRED_AUTO_CRED_VALIDATION);
secure_channel_ctx->credentials.dwFlags |= SCH_CRED_IGNORE_NO_REVOCATION_CHECK |
SCH_CRED_IGNORE_REVOCATION_OFFLINE | SCH_CRED_NO_SERVERNAME_CHECK |
SCH_CRED_MANUAL_CRED_VALIDATION;
} else if (is_client_mode) {
secure_channel_ctx->credentials.dwFlags |= SCH_CRED_REVOCATION_CHECK_CHAIN | SCH_CRED_IGNORE_REVOCATION_OFFLINE;
}
/* if someone wants to use broken algorithms like rc4/md5/des they'll need to ask for a special control */
secure_channel_ctx->credentials.dwFlags |= SCH_USE_STRONG_CRYPTO;
/* if using a system store. */
if (options->system_certificate_path) {
AWS_LOGF_DEBUG(AWS_LS_IO_TLS, "static: assuming certificate is in a system store, loading now.");
if (aws_load_cert_from_system_cert_store(
options->system_certificate_path, &secure_channel_ctx->cert_store, &secure_channel_ctx->pcerts)) {
AWS_LOGF_ERROR(AWS_LS_IO_TLS, "static: failed to load %s", options->system_certificate_path);
goto clean_up;
}
secure_channel_ctx->credentials.paCred = &secure_channel_ctx->pcerts;
secure_channel_ctx->credentials.cCreds = 1;
/* if using traditional PEM armored PKCS#7 and ASN Encoding public/private key pairs */
} else if (aws_tls_options_buf_is_set(&options->certificate) && aws_tls_options_buf_is_set(&options->private_key)) {
AWS_LOGF_DEBUG(AWS_LS_IO_TLS, "static: certificate and key have been set, setting them up now.");
if (!aws_text_is_utf8(options->certificate.buffer, options->certificate.len)) {
AWS_LOGF_ERROR(AWS_LS_IO_TLS, "static: failed to import certificate, must be ASCII/UTF-8 encoded");
aws_raise_error(AWS_IO_FILE_VALIDATION_FAILURE);
goto clean_up;
}
if (!aws_text_is_utf8(options->private_key.buffer, options->private_key.len)) {
AWS_LOGF_ERROR(AWS_LS_IO_TLS, "static: failed to import private key, must be ASCII/UTF-8 encoded");
aws_raise_error(AWS_IO_FILE_VALIDATION_FAILURE);
goto clean_up;
}
struct aws_byte_cursor cert_chain_cur = aws_byte_cursor_from_buf(&options->certificate);
struct aws_byte_cursor pk_cur = aws_byte_cursor_from_buf(&options->private_key);
int err = aws_import_key_pair_to_cert_context(
alloc,
&cert_chain_cur,
&pk_cur,
is_client_mode,
&secure_channel_ctx->cert_store,
&secure_channel_ctx->pcerts,
&secure_channel_ctx->crypto_provider,
&secure_channel_ctx->private_key);
if (err) {
AWS_LOGF_ERROR(
AWS_LS_IO_TLS, "static: failed to import certificate and private key with error %d.", aws_last_error());
goto clean_up;
}
secure_channel_ctx->credentials.paCred = &secure_channel_ctx->pcerts;
secure_channel_ctx->credentials.cCreds = 1;
secure_channel_ctx->should_free_pcerts = false;
}
return &secure_channel_ctx->ctx;
clean_up:
s_secure_channel_ctx_destroy(secure_channel_ctx);
return NULL;
}
struct aws_tls_ctx *aws_tls_server_ctx_new(struct aws_allocator *alloc, const struct aws_tls_ctx_options *options) {
return s_ctx_new(alloc, options, false);
}
struct aws_tls_ctx *aws_tls_client_ctx_new(struct aws_allocator *alloc, const struct aws_tls_ctx_options *options) {
return s_ctx_new(alloc, options, true);
}
|
0fa9a63326e362b89497216025b8eeb0868a8d96
|
1efb2283837c9b70bc6449cec877799e4efa3268
|
/src/mpi/datatype/typerep/src/typerep_yaksa_pack.c
|
9a15bb915348f63d2ab8aa4b3308390dc38c0869
|
[
"mpich2"
] |
permissive
|
pmodels/mpich
|
d2392e8e30536cad3e500c16aa1e71211101d83f
|
2d265f9f5f93ebdd07ad547423bc6212868262a4
|
refs/heads/main
| 2023-09-04T05:50:15.041823
| 2023-09-01T23:07:33
| 2023-09-01T23:07:33
| 70,918,679
| 506
| 313
|
NOASSERTION
| 2023-09-14T14:38:36
| 2016-10-14T14:39:42
|
C
|
UTF-8
|
C
| false
| false
| 22,429
|
c
|
typerep_yaksa_pack.c
|
/*
* Copyright (C) by Argonne National Laboratory
* See COPYRIGHT in top-level directory
*/
#include "mpiimpl.h"
#include "yaksa.h"
#include "typerep_internal.h"
/*
=== BEGIN_MPI_T_CVAR_INFO_BLOCK ===
cvars:
- name : MPIR_CVAR_YAKSA_COMPLEX_SUPPORT
category : COLLECTIVE
type : int
default : 0
class : none
verbosity : MPI_T_VERBOSITY_USER_BASIC
scope : MPI_T_SCOPE_ALL_EQ
description : >-
This CVAR indicates that complex type reduction is not supported in yaksa.
- name : MPIR_CVAR_GPU_DOUBLE_SUPPORT
category : COLLECTIVE
type : int
default : 0
class : none
verbosity : MPI_T_VERBOSITY_USER_BASIC
scope : MPI_T_SCOPE_ALL_EQ
description : >-
This CVAR indicates that double type is not supported on the GPU.
- name : MPIR_CVAR_GPU_LONG_DOUBLE_SUPPORT
category : COLLECTIVE
type : int
default : 0
class : none
verbosity : MPI_T_VERBOSITY_USER_BASIC
scope : MPI_T_SCOPE_ALL_EQ
description : >-
This CVAR indicates that double type is not supported on the GPU.
- name : MPIR_CVAR_ENABLE_YAKSA_REDUCTION
category : COLLECTIVE
type : int
default : 1
class : none
verbosity : MPI_T_VERBOSITY_USER_BASIC
scope : MPI_T_SCOPE_ALL_EQ
description : >-
This cvar enables yaksa based reduction for local reduce.
=== END_MPI_T_CVAR_INFO_BLOCK ===
*/
#define IS_HOST(attr) \
((attr).type == MPL_GPU_POINTER_UNREGISTERED_HOST || \
(attr).type == MPL_GPU_POINTER_REGISTERED_HOST)
/* When a returned typerep_req is expected, using the nonblocking yaksa routine and
* return the request; otherwise use the blocking yaksa routine. */
static int typerep_do_copy(void *outbuf, const void *inbuf, MPI_Aint num_bytes,
MPIR_Typerep_req * typerep_req, uint32_t flags)
{
MPIR_FUNC_ENTER;
int mpi_errno = MPI_SUCCESS;
int rc;
if (typerep_req) {
*typerep_req = MPIR_TYPEREP_REQ_NULL;
}
if (num_bytes == 0) {
goto fn_exit;
}
MPL_pointer_attr_t inattr, outattr;
MPIR_GPU_query_pointer_attr(inbuf, &inattr);
MPIR_GPU_query_pointer_attr(outbuf, &outattr);
if (IS_HOST(inattr) && IS_HOST(outattr)) {
MPIR_Memcpy(outbuf, inbuf, num_bytes);
} else {
uintptr_t actual_pack_bytes;
yaksa_info_t info = MPII_yaksa_get_info(&inattr, &outattr);
if (typerep_req) {
rc = yaksa_ipack(inbuf, num_bytes, YAKSA_TYPE__BYTE, 0, outbuf, num_bytes,
&actual_pack_bytes, info, YAKSA_OP__REPLACE,
(yaksa_request_t *) typerep_req);
} else {
rc = yaksa_pack(inbuf, num_bytes, YAKSA_TYPE__BYTE, 0, outbuf, num_bytes,
&actual_pack_bytes, info, YAKSA_OP__REPLACE);
}
MPIR_ERR_CHKANDJUMP(rc, mpi_errno, MPI_ERR_INTERN, "**yaksa");
MPIR_Assert(actual_pack_bytes == num_bytes);
rc = MPII_yaksa_free_info(info);
MPIR_ERR_CHKANDJUMP(rc, mpi_errno, MPI_ERR_INTERN, "**yaksa");
}
fn_exit:
MPIR_FUNC_EXIT;
return mpi_errno;
fn_fail:
goto fn_exit;
}
/* When a returned typerep_req is expected, using the nonblocking yaksa routine and
* return the request; otherwise use the blocking yaksa routine. */
static int typerep_do_pack(const void *inbuf, MPI_Aint incount, MPI_Datatype datatype,
MPI_Aint inoffset, void *outbuf, MPI_Aint max_pack_bytes,
MPI_Aint * actual_pack_bytes, MPIR_Typerep_req * typerep_req,
uint32_t flags)
{
MPIR_FUNC_ENTER;
int mpi_errno = MPI_SUCCESS;
int rc;
if (typerep_req) {
*typerep_req = MPIR_TYPEREP_REQ_NULL;
}
if (incount == 0) {
*actual_pack_bytes = 0;
goto fn_exit;
}
MPIR_Assert(datatype != MPI_DATATYPE_NULL);
int is_contig = 0;
int element_size = -1;
const void *inbuf_ptr; /* adjusted by true_lb */
MPI_Aint total_size = 0;
if (HANDLE_IS_BUILTIN(datatype)) {
is_contig = 1;
element_size = MPIR_Datatype_get_basic_size(datatype);
inbuf_ptr = inbuf;
total_size = incount * element_size;
} else {
MPIR_Datatype *dtp;
MPIR_Datatype_get_ptr(datatype, dtp);
is_contig = dtp->is_contig;
element_size = dtp->builtin_element_size;
inbuf_ptr = MPIR_get_contig_ptr(inbuf, dtp->true_lb);
total_size = incount * dtp->size;
}
MPL_pointer_attr_t inattr, outattr;
/* only query the pointer attributes in case of relative addressing */
bool rel_addressing = (inbuf != MPI_BOTTOM);
if (rel_addressing) {
MPIR_GPU_query_pointer_attr(inbuf_ptr, &inattr);
MPIR_GPU_query_pointer_attr(outbuf, &outattr);
}
if (rel_addressing && is_contig && element_size > 0 && IS_HOST(inattr) && IS_HOST(outattr)) {
MPI_Aint real_bytes = MPL_MIN(total_size - inoffset, max_pack_bytes);
/* Make sure we never pack partial element */
real_bytes -= real_bytes % element_size;
if (flags & MPIR_TYPEREP_FLAG_STREAM) {
MPIR_Memcpy_stream(outbuf, MPIR_get_contig_ptr(inbuf_ptr, inoffset), real_bytes);
} else {
MPIR_Memcpy(outbuf, MPIR_get_contig_ptr(inbuf_ptr, inoffset), real_bytes);
}
*actual_pack_bytes = real_bytes;
goto fn_exit;
}
yaksa_type_t type = MPII_Typerep_get_yaksa_type(datatype);
yaksa_info_t info = (rel_addressing) ? MPII_yaksa_get_info(&inattr, &outattr) : NULL;
uintptr_t real_pack_bytes;
if (typerep_req) {
rc = yaksa_ipack(inbuf, incount, type, inoffset, outbuf, max_pack_bytes,
&real_pack_bytes, info, YAKSA_OP__REPLACE,
(yaksa_request_t *) typerep_req);
} else {
rc = yaksa_pack(inbuf, incount, type, inoffset, outbuf, max_pack_bytes,
&real_pack_bytes, info, YAKSA_OP__REPLACE);
}
MPIR_ERR_CHKANDJUMP(rc, mpi_errno, MPI_ERR_INTERN, "**yaksa");
if (info) {
rc = MPII_yaksa_free_info(info);
MPIR_ERR_CHKANDJUMP(rc, mpi_errno, MPI_ERR_INTERN, "**yaksa");
}
*actual_pack_bytes = (MPI_Aint) real_pack_bytes;
fn_exit:
MPIR_FUNC_EXIT;
return mpi_errno;
fn_fail:
goto fn_exit;
}
/* This function checks whether the operation is supported in yaksa for the
* provided datatype */
int MPIR_Typerep_reduce_is_supported(MPI_Op op, MPI_Datatype datatype)
{
yaksa_op_t yaksa_op;
if (!MPIR_CVAR_ENABLE_YAKSA_REDUCTION)
return 0;
/* yaksa pup code currently treat unsigned integer type the same as
* the corresponding signed integer type, which will not work with
* most op other than REPLACE.
*/
if (datatype == MPI_UNSIGNED_CHAR ||
datatype == MPI_UNSIGNED_SHORT ||
datatype == MPI_UNSIGNED ||
datatype == MPI_UNSIGNED_LONG ||
datatype == MPI_UNSIGNED_LONG_LONG ||
datatype == MPI_UINT8_T ||
datatype == MPI_UINT16_T || datatype == MPI_UINT32_T || datatype == MPI_UINT64_T) {
return 0;
}
if ((datatype == MPI_DOUBLE || datatype == MPI_C_DOUBLE_COMPLEX) &&
(!MPIR_CVAR_GPU_DOUBLE_SUPPORT))
return 0;
if ((datatype == MPI_LONG_DOUBLE || datatype == MPI_C_LONG_DOUBLE_COMPLEX) &&
(!MPIR_CVAR_GPU_LONG_DOUBLE_SUPPORT))
return 0;
if ((datatype == MPI_C_COMPLEX || datatype == MPI_C_DOUBLE_COMPLEX ||
datatype == MPI_C_LONG_DOUBLE_COMPLEX) && (!MPIR_CVAR_YAKSA_COMPLEX_SUPPORT))
return 0;
#ifdef HAVE_FORTRAN_BINDING
if ((datatype == MPI_COMPLEX || datatype == MPI_DOUBLE_COMPLEX || datatype == MPI_COMPLEX8 ||
datatype == MPI_COMPLEX16) && (!MPIR_CVAR_YAKSA_COMPLEX_SUPPORT))
return 0;
if (datatype == MPI_DOUBLE_COMPLEX && (!MPIR_CVAR_GPU_DOUBLE_SUPPORT))
return 0;
#endif
#ifdef HAVE_CXX_BINDING
if ((datatype == MPI_CXX_FLOAT_COMPLEX || datatype == MPI_CXX_DOUBLE_COMPLEX ||
datatype == MPI_CXX_LONG_DOUBLE_COMPLEX) && (!MPIR_CVAR_YAKSA_COMPLEX_SUPPORT))
return 0;
if (datatype == MPI_CXX_DOUBLE_COMPLEX && (!MPIR_CVAR_GPU_DOUBLE_SUPPORT))
return 0;
if (datatype == MPI_CXX_LONG_DOUBLE_COMPLEX && (!MPIR_CVAR_GPU_LONG_DOUBLE_SUPPORT))
return 0;
#endif
if ((datatype == MPI_FLOAT || datatype == MPI_DOUBLE || datatype == MPI_LONG_DOUBLE) &&
(op == MPI_LXOR || op == MPI_LAND || op == MPI_LOR))
return 0;
yaksa_op = MPII_Typerep_get_yaksa_op(op);
if (yaksa_op == YAKSA_OP__LAST)
return 0;
return 1;
}
/* When a returned typerep_req is expected, using the nonblocking yaksa routine and
* return the request; otherwise use the blocking yaksa routine. */
static int typerep_do_unpack(const void *inbuf, MPI_Aint insize, void *outbuf, MPI_Aint outcount,
MPI_Datatype datatype, MPI_Aint outoffset,
MPI_Aint * actual_unpack_bytes, MPIR_Typerep_req * typerep_req,
uint32_t flags)
{
MPIR_FUNC_ENTER;
int mpi_errno = MPI_SUCCESS;
int rc;
if (typerep_req) {
*typerep_req = MPIR_TYPEREP_REQ_NULL;
}
if (insize == 0) {
*actual_unpack_bytes = 0;
goto fn_exit;
}
MPIR_Assert(datatype != MPI_DATATYPE_NULL);
int is_contig = 0;
int element_size = -1;
const void *outbuf_ptr; /* adjusted by true_lb */
MPI_Aint total_size = 0;
if (HANDLE_IS_BUILTIN(datatype)) {
is_contig = 1;
element_size = MPIR_Datatype_get_basic_size(datatype);
outbuf_ptr = outbuf;
total_size = outcount * element_size;
} else {
MPIR_Datatype *dtp;
MPIR_Datatype_get_ptr(datatype, dtp);
is_contig = dtp->is_contig;
element_size = dtp->builtin_element_size;
outbuf_ptr = MPIR_get_contig_ptr(outbuf, dtp->true_lb);
total_size = outcount * dtp->size;
}
MPL_pointer_attr_t inattr, outattr;
/* only query the pointer attributes in case of relative addressing */
bool rel_addressing = (outbuf != MPI_BOTTOM);
if (rel_addressing) {
MPIR_GPU_query_pointer_attr(inbuf, &inattr);
MPIR_GPU_query_pointer_attr(outbuf_ptr, &outattr);
}
if (rel_addressing && is_contig && IS_HOST(inattr) && IS_HOST(outattr)) {
*actual_unpack_bytes = MPL_MIN(total_size - outoffset, insize);
/* We assume the amount we unpack is multiple of element_size */
MPIR_Assert(element_size < 0 || *actual_unpack_bytes % element_size == 0);
MPIR_Memcpy(MPIR_get_contig_ptr(outbuf_ptr, outoffset), inbuf, *actual_unpack_bytes);
goto fn_exit;
}
yaksa_type_t type = MPII_Typerep_get_yaksa_type(datatype);
yaksa_info_t info = (rel_addressing) ? MPII_yaksa_get_info(&inattr, &outattr) : NULL;
uintptr_t real_insize = MPL_MIN(total_size - outoffset, insize);
uintptr_t real_unpack_bytes;
if (typerep_req) {
rc = yaksa_iunpack(inbuf, real_insize, outbuf, outcount, type, outoffset,
&real_unpack_bytes, info, YAKSA_OP__REPLACE,
(yaksa_request_t *) typerep_req);
} else {
rc = yaksa_unpack(inbuf, real_insize, outbuf, outcount, type, outoffset, &real_unpack_bytes,
info, YAKSA_OP__REPLACE);
}
MPIR_ERR_CHKANDJUMP(rc, mpi_errno, MPI_ERR_INTERN, "**yaksa");
if (info) {
rc = MPII_yaksa_free_info(info);
MPIR_ERR_CHKANDJUMP(rc, mpi_errno, MPI_ERR_INTERN, "**yaksa");
}
*actual_unpack_bytes = (MPI_Aint) real_unpack_bytes;
fn_exit:
MPIR_FUNC_EXIT;
return mpi_errno;
fn_fail:
goto fn_exit;
}
int MPIR_Typerep_icopy(void *outbuf, const void *inbuf, MPI_Aint num_bytes,
MPIR_Typerep_req * typerep_req, uint32_t flags)
{
MPIR_FUNC_ENTER;
int mpi_errno = MPI_SUCCESS;
mpi_errno = typerep_do_copy(outbuf, inbuf, num_bytes, typerep_req, flags);
MPIR_FUNC_EXIT;
return mpi_errno;
}
int MPIR_Typerep_copy(void *outbuf, const void *inbuf, MPI_Aint num_bytes, uint32_t flags)
{
MPIR_FUNC_ENTER;
int mpi_errno = MPI_SUCCESS;
mpi_errno = typerep_do_copy(outbuf, inbuf, num_bytes, NULL, flags);
MPIR_FUNC_EXIT;
return mpi_errno;
}
int MPIR_Typerep_ipack(const void *inbuf, MPI_Aint incount, MPI_Datatype datatype,
MPI_Aint inoffset, void *outbuf, MPI_Aint max_pack_bytes,
MPI_Aint * actual_pack_bytes, MPIR_Typerep_req * typerep_req, uint32_t flags)
{
MPIR_FUNC_ENTER;
int mpi_errno = MPI_SUCCESS;
mpi_errno = typerep_do_pack(inbuf, incount, datatype, inoffset, outbuf, max_pack_bytes,
actual_pack_bytes, typerep_req, flags);
MPIR_FUNC_EXIT;
return mpi_errno;
}
int MPIR_Typerep_pack(const void *inbuf, MPI_Aint incount, MPI_Datatype datatype,
MPI_Aint inoffset, void *outbuf, MPI_Aint max_pack_bytes,
MPI_Aint * actual_pack_bytes, uint32_t flags)
{
MPIR_FUNC_ENTER;
int mpi_errno = MPI_SUCCESS;
mpi_errno = typerep_do_pack(inbuf, incount, datatype, inoffset, outbuf, max_pack_bytes,
actual_pack_bytes, NULL, flags);
MPIR_FUNC_EXIT;
return mpi_errno;
}
int MPIR_Typerep_iunpack(const void *inbuf, MPI_Aint insize, void *outbuf, MPI_Aint outcount,
MPI_Datatype datatype, MPI_Aint outoffset, MPI_Aint * actual_unpack_bytes,
MPIR_Typerep_req * typerep_req, uint32_t flags)
{
MPIR_FUNC_ENTER;
int mpi_errno = MPI_SUCCESS;
mpi_errno = typerep_do_unpack(inbuf, insize, outbuf, outcount, datatype, outoffset,
actual_unpack_bytes, typerep_req, flags);
MPIR_FUNC_EXIT;
return mpi_errno;
}
int MPIR_Typerep_unpack(const void *inbuf, MPI_Aint insize, void *outbuf, MPI_Aint outcount,
MPI_Datatype datatype, MPI_Aint outoffset, MPI_Aint * actual_unpack_bytes,
uint32_t flags)
{
MPIR_FUNC_ENTER;
int mpi_errno = MPI_SUCCESS;
mpi_errno = typerep_do_unpack(inbuf, insize, outbuf, outcount, datatype, outoffset,
actual_unpack_bytes, NULL, flags);
MPIR_FUNC_EXIT;
return mpi_errno;
}
int MPIR_Typerep_wait(MPIR_Typerep_req typerep_req)
{
MPIR_FUNC_ENTER;
int mpi_errno = MPI_SUCCESS;
int rc;
if (typerep_req == MPIR_TYPEREP_REQ_NULL)
goto fn_exit;
rc = yaksa_request_wait((yaksa_request_t) typerep_req);
MPIR_ERR_CHKANDJUMP(rc, mpi_errno, MPI_ERR_INTERN, "**yaksa");
fn_exit:
MPIR_FUNC_EXIT;
return mpi_errno;
fn_fail:
goto fn_exit;
}
/* MPIR_Typerep_op - accumulate source_buf onto target_buf with op.
* Assume (we may relax and extend in the future)
* - source datatype is predefined (basic or pairtype)
* - target datatype may be derived with the same basic type as source
* - op is builtin op
*/
static int typerep_op_unpack(void *source_buf, void *target_buf, MPI_Aint count,
MPI_Datatype datatype, MPI_Op op, int mapped_device);
static int typerep_op_pack(void *source_buf, void *target_buf, MPI_Aint count,
MPI_Datatype datatype, MPI_Op op, int mapped_device);
int MPIR_Typerep_reduce(const void *in_buf, void *out_buf, MPI_Aint count, MPI_Datatype datatype,
MPI_Op op)
{
int mpi_errno = MPI_SUCCESS;
MPIR_FUNC_ENTER;
mpi_errno = typerep_op_pack((void *) in_buf, out_buf, count, datatype, op, -1);
MPIR_ERR_CHECK(mpi_errno);
fn_exit:
MPIR_FUNC_EXIT;
return mpi_errno;
fn_fail:
goto fn_exit;
}
int MPIR_Typerep_op(void *source_buf, MPI_Aint source_count, MPI_Datatype source_dtp,
void *target_buf, MPI_Aint target_count, MPI_Datatype target_dtp, MPI_Op op,
bool source_is_packed, int mapped_device)
{
int mpi_errno = MPI_SUCCESS;
MPIR_FUNC_ENTER;
/* trivial cases */
if (op == MPI_NO_OP) {
goto fn_exit;
}
/* error checking */
MPIR_Assert(HANDLE_IS_BUILTIN(op));
MPIR_Assert(MPIR_DATATYPE_IS_PREDEFINED(source_dtp));
bool use_yaksa = MPIR_Typerep_reduce_is_supported(op, source_dtp);
if (use_yaksa) {
int source_is_contig, target_is_contig;
MPIR_Datatype_is_contig(source_dtp, &source_is_contig);
MPIR_Datatype_is_contig(target_dtp, &target_is_contig);
MPI_Aint true_extent, true_lb;
if (source_is_packed) {
mpi_errno = typerep_op_unpack(source_buf, target_buf, target_count, target_dtp,
op, mapped_device);
} else if (source_is_contig) {
MPIR_Type_get_true_extent_impl(source_dtp, &true_lb, &true_extent);
void *addr = MPIR_get_contig_ptr(source_buf, true_lb);
mpi_errno = typerep_op_unpack(addr, target_buf, target_count, target_dtp,
op, mapped_device);
} else if (target_is_contig) {
MPIR_Type_get_true_extent_impl(target_dtp, &true_lb, &true_extent);
void *addr = MPIR_get_contig_ptr(target_buf, true_lb);
mpi_errno = typerep_op_pack(source_buf, addr, source_count, source_dtp,
op, mapped_device);
} else {
MPI_Aint data_sz;
MPIR_Pack_size(source_count, source_dtp, &data_sz);
void *src_ptr = MPL_malloc(data_sz, MPL_MEM_OTHER);
MPI_Aint pack_size;
MPIR_Typerep_pack(source_buf, source_count, source_dtp, 0, src_ptr, data_sz,
&pack_size, MPIR_TYPEREP_REQ_NULL);
MPIR_Assert(pack_size == data_sz);
mpi_errno = typerep_op_unpack(src_ptr, target_buf, target_count, target_dtp,
op, mapped_device);
MPL_free(src_ptr);
}
} else {
mpi_errno = MPII_Typerep_op_fallback(source_buf, source_count, source_dtp,
target_buf, target_count, target_dtp,
op, source_is_packed);
}
MPIR_ERR_CHECK(mpi_errno);
fn_exit:
MPIR_FUNC_EXIT;
return mpi_errno;
fn_fail:
goto fn_exit;
}
static int typerep_op_unpack(void *source_buf, void *target_buf, MPI_Aint count,
MPI_Datatype datatype, MPI_Op op, int mapped_device)
{
int mpi_errno = MPI_SUCCESS;
int rc;
yaksa_type_t yaksa_type = MPII_Typerep_get_yaksa_type(datatype);
yaksa_op_t yaksa_op = MPII_Typerep_get_yaksa_op(op);
MPI_Aint data_sz;
MPIR_Pack_size(count, datatype, &data_sz);
yaksa_info_t info = NULL;
if (mapped_device >= 0) {
yaksa_info_create(&info);
rc = yaksa_info_keyval_append(info, "yaksa_mapped_device", &mapped_device, sizeof(int));
MPIR_Assert(rc == 0);
}
uintptr_t actual_bytes;
yaksa_request_t request;
rc = yaksa_iunpack(source_buf, data_sz, target_buf, count, yaksa_type, 0, &actual_bytes,
info, yaksa_op, &request);
MPIR_ERR_CHKANDJUMP(rc, mpi_errno, MPI_ERR_INTERN, "**yaksa");
rc = yaksa_request_wait(request);
MPIR_ERR_CHKANDJUMP(rc, mpi_errno, MPI_ERR_INTERN, "**yaksa");
MPIR_Assert(actual_bytes == data_sz);
fn_exit:
return mpi_errno;
fn_fail:
goto fn_exit;
}
static int typerep_op_pack(void *source_buf, void *target_buf, MPI_Aint count,
MPI_Datatype datatype, MPI_Op op, int mapped_device)
{
int mpi_errno = MPI_SUCCESS;
int rc;
yaksa_type_t yaksa_type = MPII_Typerep_get_yaksa_type(datatype);
yaksa_op_t yaksa_op = MPII_Typerep_get_yaksa_op(op);
MPI_Aint data_sz;
MPIR_Pack_size(count, datatype, &data_sz);
yaksa_info_t info = NULL;
if (mapped_device >= 0) {
yaksa_info_create(&info);
rc = yaksa_info_keyval_append(info, "yaksa_mapped_device", &mapped_device, sizeof(int));
MPIR_Assert(rc == 0);
}
uintptr_t actual_pack_bytes;
yaksa_request_t request;
rc = yaksa_ipack(source_buf, count, yaksa_type, 0, target_buf, data_sz, &actual_pack_bytes,
info, yaksa_op, &request);
MPIR_ERR_CHKANDJUMP(rc, mpi_errno, MPI_ERR_INTERN, "**yaksa");
rc = yaksa_request_wait(request);
MPIR_ERR_CHKANDJUMP(rc, mpi_errno, MPI_ERR_INTERN, "**yaksa");
MPIR_Assert(actual_pack_bytes == data_sz);
fn_exit:
return mpi_errno;
fn_fail:
goto fn_exit;
}
int MPIR_Typerep_pack_stream(const void *inbuf, MPI_Aint incount, MPI_Datatype datatype,
MPI_Aint inoffset, void *outbuf, MPI_Aint max_pack_bytes,
MPI_Aint * actual_pack_bytes, void *stream)
{
MPIR_FUNC_ENTER;
int mpi_errno = MPI_SUCCESS;
int rc;
yaksa_type_t type = MPII_Typerep_get_yaksa_type(datatype);
uintptr_t packed_bytes;;
rc = yaksa_pack_stream(inbuf, incount, type, inoffset, outbuf, max_pack_bytes,
&packed_bytes, NULL, YAKSA_OP__REPLACE, stream);
MPIR_ERR_CHKANDJUMP(rc, mpi_errno, MPI_ERR_INTERN, "**yaksa");
*actual_pack_bytes = packed_bytes;
fn_exit:
MPIR_FUNC_EXIT;
return mpi_errno;
fn_fail:
goto fn_exit;
}
int MPIR_Typerep_unpack_stream(const void *inbuf, MPI_Aint insize, void *outbuf,
MPI_Aint outcount, MPI_Datatype datatype, MPI_Aint outoffset,
MPI_Aint * actual_unpack_bytes, void *stream)
{
MPIR_FUNC_ENTER;
int mpi_errno = MPI_SUCCESS;
int rc;
yaksa_type_t type = MPII_Typerep_get_yaksa_type(datatype);
uintptr_t unpacked_bytes;;
rc = yaksa_unpack_stream(inbuf, insize, outbuf, outcount, type, outoffset,
&unpacked_bytes, NULL, YAKSA_OP__REPLACE, stream);
MPIR_ERR_CHKANDJUMP(rc, mpi_errno, MPI_ERR_INTERN, "**yaksa");
*actual_unpack_bytes = unpacked_bytes;
fn_exit:
MPIR_FUNC_EXIT;
return mpi_errno;
fn_fail:
goto fn_exit;
}
|
31ec1f2e988950e210d3782be089370e21eec52c
|
d169de4c5c6b281984df35536430dcc931a957a9
|
/source/component/3rd-party/btstack/extension/btstack_oo/host/btstack_host.h
|
c5c0c10d4ace4947576d14ad2d6a912363c5ce87
|
[
"LGPL-2.1-only",
"Apache-2.0"
] |
permissive
|
vsfteam/vsf
|
2ba968ba2ef53b036668019c6c6746149a63c38a
|
522a52ff2ee4ed149b52789a5bd366f80c08c458
|
refs/heads/master
| 2023-08-27T07:32:08.339123
| 2023-08-26T17:46:07
| 2023-08-26T17:46:07
| 181,911,464
| 273
| 83
|
Apache-2.0
| 2023-08-29T03:08:36
| 2019-04-17T14:43:42
|
C
|
UTF-8
|
C
| false
| false
| 2,276
|
h
|
btstack_host.h
|
#ifndef __BTSTACK_HOST_H__
#define __BTSTACK_HOST_H__
#include "./btstack_host_cfg.h"
#if BTSTACK_OO_USE_HOST == ENABLED
#include "../btstack_oo.h"
#include "btstack.h"
#if defined(__BTSTACK_HOST_CLASS_IMPLEMENT)
# define __VSF_CLASS_IMPLEMENT
#elif defined(__BTSTACK_HOST_CLASS_INHERIT__)
# define __VSF_CLASS_INHERIT
#endif
#include "utilities/ooc_class.h"
#define BTSTACK_HOST_TRACE(...) BTSTACK_TRACE("host: " __VA_ARGS__)
#if BTSTACK_HOST_CFG_DEV_INHERIT != ENABLED
# error not supported currently!
# define btstack_host_get_priv_dev(__dev) (__dev->priv_dev)
#else
# define btstack_host_get_priv_dev(__dev) (__dev)
#endif
struct btstack_host_drv_op_t {
implement(btstack_drv_op_t)
};
typedef struct btstack_host_drv_op_t btstack_host_drv_op_t;
struct btstack_host_drv_t {
btstack_linked_item_t drv_node;
const btstack_host_drv_op_t *op;
};
typedef struct btstack_host_drv_t btstack_host_drv_t;
#undef PUBLIC_CONST
#if defined(__BTSTACK_HOST_CLASS_INHERIT__) || defined(__BTSTACK_HOST_CLASS_IMPLEMENT)
# define PUBLIC_CONST
#else
# define PUBLIC_CONST const
#endif
vsf_class(btstack_host_dev_t) {
public_member(
implement(btstack_dev_t)
// info from inquiry
PUBLIC_CONST uint32_t cod;
PUBLIC_CONST char name[32];
PUBLIC_CONST uint16_t clock_offset;
PUBLIC_CONST uint8_t page_scan_repetition_mode;
)
protected_member(
#if BTSTACK_HOST_CFG_DEV_INHERIT != ENABLED
void *priv_dev;
#endif
// remote name request state
uint8_t request_name : 1;
)
};
extern void btstack_host_init(void);
extern void btstack_host_register_drv(btstack_host_drv_t *drv);
extern bool btstack_host_is_dev_supported(btstack_host_dev_t *dev);
extern int btstack_host_connect_dev(btstack_host_dev_t *dev);
extern int btstack_host_remove_dev(btstack_host_dev_t *dev, btstack_linked_list_iterator_t *it);
extern int btstack_host_scan(uint_fast8_t duration_in_1280ms_units);
#undef __BTSTACK_HOST_CLASS_IMPLEMENT
#undef __BTSTACK_HOST_CLASS_INHERIT__
#if BTSTACK_OO_USE_HOST_HID == ENABLED
# include "./driver/hid/btstack_host_hid_base.h"
#endif
#endif // BTSTACK_OO_USE_HOST
#endif // __BTSTACK_HOST_H__
|
07e5b1948ec1a6f0fc38e778ce5e82ca3bd9314f
|
d2d15560a3ca4f8146d9baec60d1ce6743b13633
|
/ext/qml/engine.h
|
092aabc30a010e8e1dd53aea8e93d60425bf5da9
|
[
"MIT"
] |
permissive
|
seanchas116/ruby-qml
|
4ecd3728962cb4f4ea8791bd91e9666825ce289f
|
569af4c31460d2946c18346dc94751c77b1d4dfc
|
refs/heads/master
| 2021-01-21T12:31:27.975059
| 2019-11-17T08:13:34
| 2019-11-17T08:13:34
| 21,888,221
| 141
| 20
|
MIT
| 2019-11-17T08:13:35
| 2014-07-16T05:35:33
|
Ruby
|
UTF-8
|
C
| false
| false
| 166
|
h
|
engine.h
|
#pragma once
#include <ruby/ruby.h>
#include <qmlbind.h>
extern VALUE rbqml_cEngine;
qmlbind_engine *rbqml_get_engine(VALUE value);
void rbqml_init_engine(void);
|
7fbf89e4a82737d7e65a44930c38c1e5d6b56207
|
e5f4f37d941ceb8145d65f92028cc54658b1ac01
|
/Code/ThirdParty/Recast/RecastDll.h
|
1f896f9d53ce7cd17fc45c8f0054db92b953b94a
|
[
"MIT",
"Zlib",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
ezEngine/ezEngine
|
19983d2733a5409fb2665c6c3a0a575dadcefb50
|
c46e3b4b2cd46798e4abb4938fbca281c054b039
|
refs/heads/dev
| 2023-09-06T02:17:28.152665
| 2023-09-05T18:25:43
| 2023-09-05T18:25:43
| 18,179,848
| 1,050
| 165
|
MIT
| 2023-09-14T21:44:39
| 2014-03-27T15:02:16
|
C++
|
UTF-8
|
C
| false
| false
| 342
|
h
|
RecastDll.h
|
#pragma once
#ifdef BUILDSYSTEM_COMPILE_ENGINE_AS_DLL
#ifdef _WIN32
#if BUILDSYSTEM_BUILDING_RECAST_LIB
#define RECAST_API __declspec(dllexport)
#else
#define RECAST_API __declspec(dllimport)
#endif
#else
#define RECAST_API __attribute__ ((visibility ("default")))
#endif
#else
#define RECAST_API
#endif
|
de3c43bc408467c80b8c36c7b8210e9431909344
|
88ae8695987ada722184307301e221e1ba3cc2fa
|
/third_party/ffmpeg/libavcodec/exif.h
|
f70d21391af9516afb0482ae52099aa236f29a0f
|
[
"BSD-3-Clause",
"LGPL-2.1-only",
"LGPL-3.0-only",
"LGPL-2.0-or-later",
"GPL-1.0-or-later",
"GPL-2.0-only",
"LGPL-2.1-or-later",
"GPL-3.0-or-later",
"LGPL-3.0-or-later",
"IJG",
"LicenseRef-scancode-other-permissive",
"MIT",
"GPL-2.0-or-later",
"Apache-2.0",
"GPL-3.0-only"
] |
permissive
|
iridium-browser/iridium-browser
|
71d9c5ff76e014e6900b825f67389ab0ccd01329
|
5ee297f53dc7f8e70183031cff62f37b0f19d25f
|
refs/heads/master
| 2023-08-03T16:44:16.844552
| 2023-07-20T15:17:00
| 2023-07-23T16:09:30
| 220,016,632
| 341
| 40
|
BSD-3-Clause
| 2021-08-13T13:54:45
| 2019-11-06T14:32:31
| null |
UTF-8
|
C
| false
| false
| 1,472
|
h
|
exif.h
|
/*
* EXIF metadata parser
* Copyright (c) 2013 Thilo Borgmann <thilo.borgmann _at_ mail.de>
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file
* EXIF metadata parser
* @author Thilo Borgmann <thilo.borgmann _at_ mail.de>
*/
#ifndef AVCODEC_EXIF_H
#define AVCODEC_EXIF_H
#include <stdint.h>
#include "libavutil/dict.h"
#include "bytestream.h"
/** Recursively decodes all IFD's and
* adds included TAGS into the metadata dictionary. */
int avpriv_exif_decode_ifd(void *logctx, const uint8_t *buf, int size,
int le, int depth, AVDictionary **metadata);
int ff_exif_decode_ifd(void *logctx, GetByteContext *gbytes, int le,
int depth, AVDictionary **metadata);
#endif /* AVCODEC_EXIF_H */
|
1e04e15c801d66ffae311588367052a3627819a5
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/include/linux/ipv6_route.h
|
25b5f1f5e7802a6d53f41783d9c0b5bad256a173
|
[
"Linux-syscall-note",
"GPL-2.0-only",
"GPL-1.0-or-later",
"LicenseRef-scancode-free-unknown",
"Apache-2.0"
] |
permissive
|
OLIMEX/DIY-LAPTOP
|
ae82f4ee79c641d9aee444db9a75f3f6709afa92
|
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
|
refs/heads/rel3
| 2023-08-04T01:54:19.483792
| 2023-04-03T07:18:12
| 2023-04-03T07:18:12
| 80,094,055
| 507
| 92
|
Apache-2.0
| 2023-04-03T07:05:59
| 2017-01-26T07:25:50
|
C
|
UTF-8
|
C
| false
| false
| 594
|
h
|
ipv6_route.h
|
/*
* Linux INET6 implementation
*
* Authors:
* Pedro Roque <roque@di.fc.ul.pt>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
#ifndef _LINUX_IPV6_ROUTE_H
#define _LINUX_IPV6_ROUTE_H
#include <uapi/linux/ipv6_route.h>
#define IPV6_EXTRACT_PREF(flag) (((flag) & RTF_PREF_MASK) >> 27)
#define IPV6_DECODE_PREF(pref) ((pref) ^ 2) /* 1:low,2:med,3:high */
#endif
|
1f8235ae81b759f835adfc4038511bc60b8c7059
|
2c2390232d175cecbcafeedae39bc2943ddf8452
|
/UIShop/Template/IM_Resource.h
|
7547ffc11ff32a82cb5b68590f3d682a43591e2a
|
[] |
permissive
|
iUIShop/LibUIDK
|
d36621fbf3551b1c8ac5b6a44a2df1769a73a4f6
|
ea7b0ca3ba1e58867bb35fdaa32b8685a3f83409
|
refs/heads/master
| 2023-04-13T04:37:35.618021
| 2023-03-30T09:53:55
| 2023-03-30T09:53:55
| 207,088,755
| 418
| 204
|
MIT
| 2019-09-09T13:52:26
| 2019-09-08T09:19:02
|
C++
|
UTF-8
|
C
| false
| false
| 2,500
|
h
|
IM_Resource.h
|
//WARNING: DO NOT EDIT OR DELETE THIS HEADER FILE!
#pragma once
#define IDW_LOGIN 1000
#define IDC_BTN_MIN 1001
#define IDC_BTN_CLOSE 1002
#define IDC_EDT_NAME 1003
#define IDC_EDT_PASSWORD 1004
#define IDC_CHK_REMEMBER_PASSWORD 1005
#define IDC_CHK_AUTO_LOGIN 1006
#define IDC_BTN_LOGIN 1007
#define IDC_BTN_FORGET_PASSWORD 1008
#define IDC_BTN_REGISTER 1009
#define IDW_MAIN 1010
#define IDC_BTN_SKIN 1011
#define IDC_CHK_MAX 1012
#define IDC_BTN_HEADER 1013
#define IDC_CHK_STATUS 1014
#define IDC_BTN_MAIL 1015
#define IDC_BTN_ZONE 1016
#define IDC_BTN_MESSAGE 1017
#define IDC_EDT_SEARCH 1018
#define IDC_BTN_SEARCH_WEB 1019
#define IDC_RAD_FRIEND 1020
#define IDC_RAD_GROUP 1021
#define IDC_RAD_RECENT 1022
#define IDC_CHK_START 1023
#define IDC_BTN_GAME 1024
#define IDC_BTN_SETTING 1025
#define IDC_BTN_MSG 1026
#define IDC_BTN_SECURE 1027
#define IDC_BTN_SEARCH 1028
#define IDC_BTN_APP_MGR 1029
#define IDC_BTN_WEATHER 1030
#define IDC_STA_NAME 1031
#define IDC_BTN_SIGN 1032
#define IDC_STA_TITLE 1033
#define IDC_TWMGR_MAIN 1034
#define IDC_PNL_UGRID_TAB 1035
#define IDW_FRIEND_PAGE 1036
#define IDW_GROUP_PAGE 1037
#define IDC_STA_GROUP 1038
#define IDW_RECENT_PAGE 1039
#define IDC_STA_RECENT 1040
#define IDW_START_MENU 1041
#define IDW_CHAT_FRAME 1042
#define IDC_BTN_EXIT 1043
#define IDC_BTN_VIDEO 1044
#define IDC_BTN_AUDIO 1045
#define IDC_BTN_TRANS_FILE 1046
#define IDC_BTN_CREATE_GROUP 1047
#define IDC_BTN_REMOTE 1048
#define IDC_BTN_MORE 1049
#define IDC_CHK_FONT 1050
#define IDC_CHK_FACE 1051
#define IDC_BTN_SEND 1052
#define IDC_BTN_SEND2 1053
|
6f273fbf4b10ee6ec52d09e8da24e264a2d0db73
|
653ab4373a629a3695872d805a62f6b7ba937eed
|
/SDWebImage/include/SDWebImage/SDDiskCache.h
|
ba20df74abe78377068f015973f503898a78bd80
|
[
"MIT",
"Apache-2.0"
] |
permissive
|
SDWebImage/SDWebImage
|
b3fbbe42cacc834726af77571d675ab1a7aee2f8
|
507225ea04876894856186af6d3c30a9e8c1200a
|
refs/heads/master
| 2023-08-31T09:49:02.624904
| 2023-08-23T10:26:29
| 2023-08-23T10:26:29
| 313,419
| 5,435
| 1,427
|
MIT
| 2023-09-12T08:03:38
| 2009-09-21T17:39:19
|
Objective-C
|
UTF-8
|
C
| false
| false
| 24
|
h
|
SDDiskCache.h
|
../../Core/SDDiskCache.h
|
1157aadeb3384395365e1e229b59051c884c759a
|
e73547787354afd9b717ea57fe8dd0695d161821
|
/include/mapfs/jan_04_shape.h
|
d9c8e3e8375a23979223de046910395032855dd0
|
[] |
no_license
|
pmret/papermario
|
8b514b19653cef8d6145e47499b3636b8c474a37
|
9774b26d93f1045dd2a67e502b6efc9599fb6c31
|
refs/heads/main
| 2023-08-31T07:09:48.951514
| 2023-08-21T18:07:08
| 2023-08-21T18:07:08
| 287,151,133
| 904
| 139
| null | 2023-09-14T02:44:23
| 2020-08-13T01:22:57
|
C
|
UTF-8
|
C
| false
| false
| 3,482
|
h
|
jan_04_shape.h
|
#define MODEL_Root 0x5B
#define MODEL_g1 0x5A
#define MODEL_g12 0x59
#define MODEL_o61 0x58
#define MODEL_o60 0x57
#define MODEL_g20 0x56
#define MODEL_g32 0x55
#define MODEL_o87 0x54
#define MODEL_g31 0x53
#define MODEL_o88 0x52
#define MODEL_g30 0x51
#define MODEL_o86 0x50
#define MODEL_g29 0x4F
#define MODEL_o92 0x4E
#define MODEL_g28 0x4D
#define MODEL_o91 0x4C
#define MODEL_g27 0x4B
#define MODEL_o89 0x4A
#define MODEL_g26 0x49
#define MODEL_o85 0x48
#define MODEL_g25 0x47
#define MODEL_o83 0x46
#define MODEL_g24 0x45
#define MODEL_o81 0x44
#define MODEL_g23 0x43
#define MODEL_o82 0x42
#define MODEL_g15 0x41
#define MODEL_o69 0x40
#define MODEL_o68 0x3F
#define MODEL_g19 0x3E
#define MODEL_o79 0x3D
#define MODEL_o78 0x3C
#define MODEL_o77 0x3B
#define MODEL_o76 0x3A
#define MODEL_o75 0x39
#define MODEL_o74 0x38
#define MODEL_g13 0x37
#define MODEL_g22 0x36
#define MODEL_o105 0x35
#define MODEL_o104 0x34
#define MODEL_o103 0x33
#define MODEL_o102 0x32
#define MODEL_o101 0x31
#define MODEL_o100 0x30
#define MODEL_g21 0x2F
#define MODEL_o98 0x2E
#define MODEL_o97 0x2D
#define MODEL_o96 0x2C
#define MODEL_o95 0x2B
#define MODEL_o94 0x2A
#define MODEL_o99 0x29
#define MODEL_g14 0x28
#define MODEL_o67 0x27
#define MODEL_o66 0x26
#define MODEL_o65 0x25
#define MODEL_o64 0x24
#define MODEL_o63 0x23
#define MODEL_o34 0x22
#define MODEL_g5 0x21
#define MODEL_o19 0x20
#define MODEL_o18 0x1F
#define MODEL_o17 0x1E
#define MODEL_o16 0x1D
#define MODEL_o10 0x1C
#define MODEL_o9 0x1B
#define MODEL_g16 0x1A
#define MODEL_g18 0x19
#define MODEL_o73 0x18
#define MODEL_o72 0x17
#define MODEL_g17 0x16
#define MODEL_o108 0x15
#define MODEL_o106 0x14
#define MODEL_g6 0x13
#define MODEL_g11 0x12
#define MODEL_o59 0x11
#define MODEL_o55 0x10
#define MODEL_o45 0xF
#define MODEL_o44 0xE
#define MODEL_o43 0xD
#define MODEL_g10 0xC
#define MODEL_o58 0xB
#define MODEL_o53 0xA
#define MODEL_o30 0x9
#define MODEL_o27 0x8
#define MODEL_o32 0x7
#define MODEL_o23 0x6
#define MODEL_o57 0x5
#define MODEL_o35 0x4
#define MODEL_g2 0x3
#define MODEL_o3 0x2
#define MODEL_o2 0x1
#define MODEL_o6 0x0
|
22115aa68a1c2597d6c43841a1563f9c21353f72
|
eac80658fb291b4d449c37aa0767b1390be9ef53
|
/src/factory/include/agz/factory/creator/geometry_creators.h
|
a25affc2984bd71db1e87d98c7f4be401a4b1888
|
[
"MIT"
] |
permissive
|
AirGuanZ/Atrc
|
92e357a0b18bb8b9b2bbc1eb234f549aba6589ad
|
9bf8fdbb74affaa047bc40bb452c0d2c9bf0d121
|
refs/heads/master
| 2023-07-11T06:31:09.259287
| 2023-06-25T08:00:10
| 2023-06-25T08:00:10
| 147,777,386
| 484
| 30
|
MIT
| 2023-03-07T13:25:58
| 2018-09-07T05:56:14
|
C++
|
UTF-8
|
C
| false
| false
| 160
|
h
|
geometry_creators.h
|
#pragma once
#include <agz/factory/factory.h>
AGZ_TRACER_FACTORY_BEGIN
void initialize_geometry_factory(Factory<Geometry> &factory);
AGZ_TRACER_FACTORY_END
|
f3bda6aeebb590db2501b1176d81bcfea26c1ab4
|
5eff7a36d9a9917dce9111f0c3074375fe6f7656
|
/lib/mesa/src/amd/llvm/ac_llvm_build.h
|
823005ebb37087d7bd69ba6bcd70fc3ee08bb756
|
[] |
no_license
|
openbsd/xenocara
|
cb392d02ebba06f6ff7d826fd8a89aa3b8401779
|
a012b5de33ea0b977095d77316a521195b26cc6b
|
refs/heads/master
| 2023-08-25T12:16:58.862008
| 2023-08-12T16:16:25
| 2023-08-12T16:16:25
| 66,967,384
| 177
| 66
| null | 2023-07-22T18:12:37
| 2016-08-30T18:36:01
|
C
|
UTF-8
|
C
| false
| false
| 27,792
|
h
|
ac_llvm_build.h
|
/*
* Copyright 2016 Bas Nieuwenhuizen
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
*/
#ifndef AC_LLVM_BUILD_H
#define AC_LLVM_BUILD_H
#include "ac_llvm_util.h"
#include "ac_shader_abi.h"
#include "ac_shader_args.h"
#include "ac_shader_util.h"
#include "amd_family.h"
#include "compiler/nir/nir.h"
#include <llvm-c/Core.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
enum
{
AC_ADDR_SPACE_FLAT = 0, /* Slower than global. */
AC_ADDR_SPACE_GLOBAL = 1,
AC_ADDR_SPACE_GDS = 2,
AC_ADDR_SPACE_LDS = 3,
AC_ADDR_SPACE_CONST = 4, /* Global allowing SMEM. */
AC_ADDR_SPACE_CONST_32BIT = 6, /* same as CONST, but the pointer type has 32 bits */
};
#define AC_WAIT_LGKM (1 << 0) /* LDS, GDS, constant, message */
#define AC_WAIT_VLOAD (1 << 1) /* VMEM load/sample instructions */
#define AC_WAIT_VSTORE (1 << 2) /* VMEM store instructions */
#define AC_WAIT_EXP (1 << 3) /* EXP instructions */
struct ac_llvm_flow;
struct ac_llvm_compiler;
struct ac_llvm_flow_state {
struct ac_llvm_flow *stack;
unsigned depth_max;
unsigned depth;
};
struct ac_llvm_pointer {
union {
LLVMValueRef value;
LLVMValueRef v;
};
/* Doesn't support complex types (pointer to pointer to etc...),
* but this isn't a problem since there's no place where this
* would be required.
*/
union {
LLVMTypeRef pointee_type;
LLVMTypeRef t;
};
};
struct ac_llvm_context {
LLVMContextRef context;
LLVMModuleRef module;
LLVMBuilderRef builder;
struct ac_llvm_pointer main_function;
LLVMTypeRef voidt;
LLVMTypeRef i1;
LLVMTypeRef i8;
LLVMTypeRef i16;
LLVMTypeRef i32;
LLVMTypeRef i64;
LLVMTypeRef i128;
LLVMTypeRef intptr;
LLVMTypeRef f16;
LLVMTypeRef f32;
LLVMTypeRef f64;
LLVMTypeRef v2i16;
LLVMTypeRef v4i16;
LLVMTypeRef v2f16;
LLVMTypeRef v4f16;
LLVMTypeRef v2i32;
LLVMTypeRef v3i32;
LLVMTypeRef v4i32;
LLVMTypeRef v2f32;
LLVMTypeRef v3f32;
LLVMTypeRef v4f32;
LLVMTypeRef v8i32;
LLVMTypeRef iN_wavemask;
LLVMTypeRef iN_ballotmask;
LLVMValueRef i8_0;
LLVMValueRef i8_1;
LLVMValueRef i16_0;
LLVMValueRef i16_1;
LLVMValueRef i32_0;
LLVMValueRef i32_1;
LLVMValueRef i64_0;
LLVMValueRef i64_1;
LLVMValueRef i128_0;
LLVMValueRef i128_1;
LLVMValueRef f16_0;
LLVMValueRef f16_1;
LLVMValueRef f32_0;
LLVMValueRef f32_1;
LLVMValueRef f64_0;
LLVMValueRef f64_1;
LLVMValueRef i1true;
LLVMValueRef i1false;
/* Temporary helper to implement demote_to_helper:
* True = live lanes
* False = demoted lanes
*/
LLVMValueRef postponed_kill;
bool conditional_demote_seen;
/* Since ac_nir_translate makes a local copy of ac_llvm_context, there
* are two ac_llvm_contexts. Declare a pointer here, so that the control
* flow stack is shared by both ac_llvm_contexts.
*/
struct ac_llvm_flow_state *flow;
unsigned range_md_kind;
unsigned invariant_load_md_kind;
unsigned uniform_md_kind;
LLVMValueRef empty_md;
enum amd_gfx_level gfx_level;
enum radeon_family family;
bool has_3d_cube_border_color_mipmap;
unsigned wave_size;
unsigned ballot_mask_bits;
unsigned float_mode;
struct ac_llvm_pointer lds;
};
void ac_llvm_context_init(struct ac_llvm_context *ctx, struct ac_llvm_compiler *compiler,
enum amd_gfx_level gfx_level, enum radeon_family family,
bool has_3d_cube_border_color_mipmap,
enum ac_float_mode float_mode, unsigned wave_size,
unsigned ballot_mask_bits);
void ac_llvm_context_dispose(struct ac_llvm_context *ctx);
int ac_get_llvm_num_components(LLVMValueRef value);
int ac_get_elem_bits(struct ac_llvm_context *ctx, LLVMTypeRef type);
LLVMValueRef ac_llvm_extract_elem(struct ac_llvm_context *ac, LLVMValueRef value, int index);
unsigned ac_get_type_size(LLVMTypeRef type);
LLVMTypeRef ac_to_integer_type(struct ac_llvm_context *ctx, LLVMTypeRef t);
LLVMValueRef ac_to_integer(struct ac_llvm_context *ctx, LLVMValueRef v);
LLVMValueRef ac_to_integer_or_pointer(struct ac_llvm_context *ctx, LLVMValueRef v);
LLVMTypeRef ac_to_float_type(struct ac_llvm_context *ctx, LLVMTypeRef t);
LLVMValueRef ac_to_float(struct ac_llvm_context *ctx, LLVMValueRef v);
LLVMValueRef ac_build_intrinsic(struct ac_llvm_context *ctx, const char *name,
LLVMTypeRef return_type, LLVMValueRef *params, unsigned param_count,
unsigned attrib_mask);
void ac_build_type_name_for_intr(LLVMTypeRef type, char *buf, unsigned bufsize);
LLVMValueRef ac_build_phi(struct ac_llvm_context *ctx, LLVMTypeRef type, unsigned count_incoming,
LLVMValueRef *values, LLVMBasicBlockRef *blocks);
void ac_build_s_barrier(struct ac_llvm_context *ctx, gl_shader_stage stage);
void ac_build_optimization_barrier(struct ac_llvm_context *ctx, LLVMValueRef *pgpr, bool sgpr);
LLVMValueRef ac_build_shader_clock(struct ac_llvm_context *ctx, nir_scope scope);
LLVMValueRef ac_build_ballot(struct ac_llvm_context *ctx, LLVMValueRef value);
LLVMValueRef ac_get_i1_sgpr_mask(struct ac_llvm_context *ctx, LLVMValueRef value);
LLVMValueRef ac_build_vote_all(struct ac_llvm_context *ctx, LLVMValueRef value);
LLVMValueRef ac_build_vote_any(struct ac_llvm_context *ctx, LLVMValueRef value);
LLVMValueRef ac_build_vote_eq(struct ac_llvm_context *ctx, LLVMValueRef value);
LLVMValueRef ac_build_varying_gather_values(struct ac_llvm_context *ctx, LLVMValueRef *values,
unsigned value_count, unsigned component);
LLVMValueRef ac_build_gather_values_extended(struct ac_llvm_context *ctx, LLVMValueRef *values,
unsigned value_count, unsigned value_stride,
bool always_vector);
LLVMValueRef ac_build_gather_values(struct ac_llvm_context *ctx, LLVMValueRef *values,
unsigned value_count);
LLVMValueRef ac_build_concat(struct ac_llvm_context *ctx, LLVMValueRef a, LLVMValueRef b);
LLVMValueRef ac_extract_components(struct ac_llvm_context *ctx, LLVMValueRef value, unsigned start,
unsigned channels);
LLVMValueRef ac_build_expand(struct ac_llvm_context *ctx, LLVMValueRef value,
unsigned src_channels, unsigned dst_channels);
LLVMValueRef ac_build_expand_to_vec4(struct ac_llvm_context *ctx, LLVMValueRef value,
unsigned num_channels);
LLVMValueRef ac_build_round(struct ac_llvm_context *ctx, LLVMValueRef value);
LLVMValueRef ac_build_fdiv(struct ac_llvm_context *ctx, LLVMValueRef num, LLVMValueRef den);
LLVMValueRef ac_build_fast_udiv(struct ac_llvm_context *ctx, LLVMValueRef num,
LLVMValueRef multiplier, LLVMValueRef pre_shift,
LLVMValueRef post_shift, LLVMValueRef increment);
LLVMValueRef ac_build_fast_udiv_nuw(struct ac_llvm_context *ctx, LLVMValueRef num,
LLVMValueRef multiplier, LLVMValueRef pre_shift,
LLVMValueRef post_shift, LLVMValueRef increment);
LLVMValueRef ac_build_fast_udiv_u31_d_not_one(struct ac_llvm_context *ctx, LLVMValueRef num,
LLVMValueRef multiplier, LLVMValueRef post_shift);
void ac_prepare_cube_coords(struct ac_llvm_context *ctx, bool is_deriv, bool is_array, bool is_lod,
LLVMValueRef *coords_arg, LLVMValueRef *derivs_arg);
LLVMValueRef ac_build_fs_interp(struct ac_llvm_context *ctx, LLVMValueRef llvm_chan,
LLVMValueRef attr_number, LLVMValueRef params, LLVMValueRef i,
LLVMValueRef j);
LLVMValueRef ac_build_fs_interp_f16(struct ac_llvm_context *ctx, LLVMValueRef llvm_chan,
LLVMValueRef attr_number, LLVMValueRef params, LLVMValueRef i,
LLVMValueRef j, bool high_16bits);
LLVMValueRef ac_build_fs_interp_mov(struct ac_llvm_context *ctx, LLVMValueRef parameter,
LLVMValueRef llvm_chan, LLVMValueRef attr_number,
LLVMValueRef params);
LLVMValueRef ac_build_gep_ptr(struct ac_llvm_context *ctx, LLVMTypeRef type, LLVMValueRef base_ptr,
LLVMValueRef index);
LLVMValueRef ac_build_pointer_add(struct ac_llvm_context *ctx, LLVMTypeRef type, LLVMValueRef ptr,
LLVMValueRef index);
LLVMTypeRef ac_build_gep0_type(LLVMTypeRef pointee_type, LLVMValueRef index);
LLVMValueRef ac_build_gep0(struct ac_llvm_context *ctx, struct ac_llvm_pointer ptr, LLVMValueRef index);
void ac_build_indexed_store(struct ac_llvm_context *ctx, struct ac_llvm_pointer ptr, LLVMValueRef index,
LLVMValueRef value);
LLVMValueRef ac_build_load(struct ac_llvm_context *ctx, struct ac_llvm_pointer ptr, LLVMValueRef index);
LLVMValueRef ac_build_load_invariant(struct ac_llvm_context *ctx, struct ac_llvm_pointer ptr,
LLVMValueRef index);
LLVMValueRef ac_build_load_to_sgpr(struct ac_llvm_context *ctx, struct ac_llvm_pointer ptr,
LLVMValueRef index);
LLVMValueRef ac_build_load_to_sgpr_uint_wraparound(struct ac_llvm_context *ctx, struct ac_llvm_pointer ptr,
LLVMValueRef index);
void ac_build_buffer_store_dword(struct ac_llvm_context *ctx, LLVMValueRef rsrc, LLVMValueRef vdata,
LLVMValueRef vindex, LLVMValueRef voffset, LLVMValueRef soffset,
unsigned cache_policy);
void ac_build_buffer_store_format(struct ac_llvm_context *ctx, LLVMValueRef rsrc, LLVMValueRef data,
LLVMValueRef vindex, LLVMValueRef voffset, unsigned cache_policy);
LLVMValueRef ac_build_buffer_load(struct ac_llvm_context *ctx, LLVMValueRef rsrc, int num_channels,
LLVMValueRef vindex, LLVMValueRef voffset, LLVMValueRef soffset,
LLVMTypeRef channel_type, unsigned cache_policy,
bool can_speculate, bool allow_smem);
LLVMValueRef ac_build_buffer_load_format(struct ac_llvm_context *ctx, LLVMValueRef rsrc,
LLVMValueRef vindex, LLVMValueRef voffset,
unsigned num_channels, unsigned cache_policy,
bool can_speculate, bool d16, bool tfe);
LLVMValueRef ac_build_buffer_load_short(struct ac_llvm_context *ctx, LLVMValueRef rsrc,
LLVMValueRef voffset, LLVMValueRef soffset,
unsigned cache_policy);
LLVMValueRef ac_build_buffer_load_byte(struct ac_llvm_context *ctx, LLVMValueRef rsrc,
LLVMValueRef voffset, LLVMValueRef soffset,
unsigned cache_policy);
LLVMValueRef ac_build_struct_tbuffer_load(struct ac_llvm_context *ctx, LLVMValueRef rsrc,
LLVMValueRef vindex, LLVMValueRef voffset,
LLVMValueRef soffset, unsigned num_channels,
unsigned dfmt, unsigned nfmt, unsigned cache_policy,
bool can_speculate);
LLVMValueRef ac_build_opencoded_load_format(struct ac_llvm_context *ctx, unsigned log_size,
unsigned num_channels, unsigned format, bool reverse,
bool known_aligned, LLVMValueRef rsrc,
LLVMValueRef vindex, LLVMValueRef voffset,
LLVMValueRef soffset, unsigned cache_policy,
bool can_speculate);
void ac_build_buffer_store_short(struct ac_llvm_context *ctx, LLVMValueRef rsrc,
LLVMValueRef vdata, LLVMValueRef voffset, LLVMValueRef soffset,
unsigned cache_policy);
void ac_build_buffer_store_byte(struct ac_llvm_context *ctx, LLVMValueRef rsrc, LLVMValueRef vdata,
LLVMValueRef voffset, LLVMValueRef soffset, unsigned cache_policy);
void ac_set_range_metadata(struct ac_llvm_context *ctx, LLVMValueRef value, unsigned lo,
unsigned hi);
LLVMValueRef ac_get_thread_id(struct ac_llvm_context *ctx);
#define AC_TID_MASK_TOP_LEFT 0xfffffffc
#define AC_TID_MASK_TOP 0xfffffffd
#define AC_TID_MASK_LEFT 0xfffffffe
LLVMValueRef ac_build_ddxy(struct ac_llvm_context *ctx, uint32_t mask, int idx, LLVMValueRef val);
#define AC_SENDMSG_GS 2
#define AC_SENDMSG_GS_DONE 3
#define AC_SENDMSG_GS_ALLOC_REQ 9
#define AC_SENDMSG_GS_OP_NOP (0 << 4)
#define AC_SENDMSG_GS_OP_CUT (1 << 4)
#define AC_SENDMSG_GS_OP_EMIT (2 << 4)
#define AC_SENDMSG_GS_OP_EMIT_CUT (3 << 4)
void ac_build_sendmsg(struct ac_llvm_context *ctx, uint32_t msg, LLVMValueRef wave_id);
LLVMValueRef ac_build_imsb(struct ac_llvm_context *ctx, LLVMValueRef arg, LLVMTypeRef dst_type);
LLVMValueRef ac_build_umsb(struct ac_llvm_context *ctx, LLVMValueRef arg, LLVMTypeRef dst_type,
bool rev);
LLVMValueRef ac_build_fmin(struct ac_llvm_context *ctx, LLVMValueRef a, LLVMValueRef b);
LLVMValueRef ac_build_fmax(struct ac_llvm_context *ctx, LLVMValueRef a, LLVMValueRef b);
LLVMValueRef ac_build_imin(struct ac_llvm_context *ctx, LLVMValueRef a, LLVMValueRef b);
LLVMValueRef ac_build_imax(struct ac_llvm_context *ctx, LLVMValueRef a, LLVMValueRef b);
LLVMValueRef ac_build_umin(struct ac_llvm_context *ctx, LLVMValueRef a, LLVMValueRef b);
LLVMValueRef ac_build_umax(struct ac_llvm_context *ctx, LLVMValueRef a, LLVMValueRef b);
LLVMValueRef ac_build_clamp(struct ac_llvm_context *ctx, LLVMValueRef value);
struct ac_export_args {
LLVMValueRef out[4];
unsigned target;
unsigned enabled_channels;
bool compr;
bool done;
bool valid_mask;
};
void ac_build_export(struct ac_llvm_context *ctx, struct ac_export_args *a);
void ac_build_export_null(struct ac_llvm_context *ctx, bool uses_discard);
enum ac_image_opcode
{
ac_image_sample,
ac_image_gather4,
ac_image_load,
ac_image_load_mip,
ac_image_store,
ac_image_store_mip,
ac_image_get_lod,
ac_image_get_resinfo,
ac_image_atomic,
ac_image_atomic_cmpswap,
};
enum ac_atomic_op
{
ac_atomic_swap,
ac_atomic_add,
ac_atomic_sub,
ac_atomic_smin,
ac_atomic_umin,
ac_atomic_smax,
ac_atomic_umax,
ac_atomic_and,
ac_atomic_or,
ac_atomic_xor,
ac_atomic_inc_wrap,
ac_atomic_dec_wrap,
ac_atomic_fmin,
ac_atomic_fmax,
};
/* These cache policy bits match the definitions used by the LLVM intrinsics. */
enum ac_image_cache_policy
{
ac_glc = 1 << 0, /* per-CU cache control */
ac_slc = 1 << 1, /* global L2 cache control */
ac_dlc = 1 << 2, /* per-shader-array cache control */
ac_swizzled = 1 << 3, /* the access is swizzled, disabling load/store merging */
};
struct ac_image_args {
enum ac_image_opcode opcode;
enum ac_atomic_op atomic; /* for the ac_image_atomic opcode */
enum ac_image_dim dim;
unsigned dmask : 4;
unsigned cache_policy : 3;
bool unorm : 1;
bool level_zero : 1;
bool d16 : 1; /* GFX8+: data and return values are 16-bit */
bool a16 : 1; /* GFX9+: address components except compare, offset and bias are 16-bit */
bool g16 : 1; /* GFX10+: derivatives are 16-bit; GFX<=9: must be equal to a16 */
bool tfe : 1;
unsigned attributes; /* additional call-site specific AC_FUNC_ATTRs */
LLVMValueRef resource;
LLVMValueRef sampler;
LLVMValueRef data[2]; /* data[0] is source data (vector); data[1] is cmp for cmpswap */
LLVMValueRef offset;
LLVMValueRef bias;
LLVMValueRef compare;
LLVMValueRef derivs[6];
LLVMValueRef coords[4];
LLVMValueRef lod; // also used by ac_image_get_resinfo
LLVMValueRef min_lod;
};
LLVMValueRef ac_build_image_opcode(struct ac_llvm_context *ctx, struct ac_image_args *a);
LLVMValueRef ac_build_image_get_sample_count(struct ac_llvm_context *ctx, LLVMValueRef rsrc);
LLVMValueRef ac_build_cvt_pkrtz_f16(struct ac_llvm_context *ctx, LLVMValueRef args[2]);
LLVMValueRef ac_build_cvt_pknorm_i16(struct ac_llvm_context *ctx, LLVMValueRef args[2]);
LLVMValueRef ac_build_cvt_pknorm_u16(struct ac_llvm_context *ctx, LLVMValueRef args[2]);
LLVMValueRef ac_build_cvt_pknorm_i16_f16(struct ac_llvm_context *ctx, LLVMValueRef args[2]);
LLVMValueRef ac_build_cvt_pknorm_u16_f16(struct ac_llvm_context *ctx, LLVMValueRef args[2]);
LLVMValueRef ac_build_cvt_pk_i16(struct ac_llvm_context *ctx, LLVMValueRef args[2], unsigned bits,
bool hi);
LLVMValueRef ac_build_cvt_pk_u16(struct ac_llvm_context *ctx, LLVMValueRef args[2], unsigned bits,
bool hi);
LLVMValueRef ac_build_wqm_vote(struct ac_llvm_context *ctx, LLVMValueRef i1);
void ac_build_kill_if_false(struct ac_llvm_context *ctx, LLVMValueRef i1);
LLVMValueRef ac_build_bfe(struct ac_llvm_context *ctx, LLVMValueRef input, LLVMValueRef offset,
LLVMValueRef width, bool is_signed);
LLVMValueRef ac_build_imad(struct ac_llvm_context *ctx, LLVMValueRef s0, LLVMValueRef s1,
LLVMValueRef s2);
LLVMValueRef ac_build_fmad(struct ac_llvm_context *ctx, LLVMValueRef s0, LLVMValueRef s1,
LLVMValueRef s2);
void ac_build_waitcnt(struct ac_llvm_context *ctx, unsigned wait_flags);
LLVMValueRef ac_build_fract(struct ac_llvm_context *ctx, LLVMValueRef src0, unsigned bitsize);
LLVMValueRef ac_const_uint_vec(struct ac_llvm_context *ctx, LLVMTypeRef type, uint64_t value);
LLVMValueRef ac_build_isign(struct ac_llvm_context *ctx, LLVMValueRef src0);
LLVMValueRef ac_build_fsign(struct ac_llvm_context *ctx, LLVMValueRef src);
LLVMValueRef ac_build_bit_count(struct ac_llvm_context *ctx, LLVMValueRef src0);
LLVMValueRef ac_build_fsat(struct ac_llvm_context *ctx, LLVMValueRef src,
LLVMTypeRef type);
LLVMValueRef ac_build_bitfield_reverse(struct ac_llvm_context *ctx, LLVMValueRef src0);
LLVMValueRef ac_build_sudot_4x8(struct ac_llvm_context *ctx, LLVMValueRef s0, LLVMValueRef s1,
LLVMValueRef s2, bool clamp, unsigned neg_lo);
void ac_init_exec_full_mask(struct ac_llvm_context *ctx);
void ac_declare_lds_as_pointer(struct ac_llvm_context *ac);
LLVMValueRef ac_lds_load(struct ac_llvm_context *ctx, LLVMValueRef dw_addr);
void ac_lds_store(struct ac_llvm_context *ctx, LLVMValueRef dw_addr, LLVMValueRef value);
LLVMValueRef ac_find_lsb(struct ac_llvm_context *ctx, LLVMTypeRef dst_type, LLVMValueRef src0);
LLVMTypeRef ac_array_in_const_addr_space(LLVMTypeRef elem_type);
LLVMTypeRef ac_array_in_const32_addr_space(LLVMTypeRef elem_type);
void ac_build_bgnloop(struct ac_llvm_context *ctx, int lable_id);
void ac_build_break(struct ac_llvm_context *ctx);
void ac_build_continue(struct ac_llvm_context *ctx);
void ac_build_else(struct ac_llvm_context *ctx, int lable_id);
void ac_build_endif(struct ac_llvm_context *ctx, int lable_id);
void ac_build_endloop(struct ac_llvm_context *ctx, int lable_id);
void ac_build_ifcc(struct ac_llvm_context *ctx, LLVMValueRef cond, int label_id);
LLVMValueRef ac_build_alloca(struct ac_llvm_context *ac, LLVMTypeRef type, const char *name);
LLVMValueRef ac_build_alloca_undef(struct ac_llvm_context *ac, LLVMTypeRef type, const char *name);
LLVMValueRef ac_build_alloca_init(struct ac_llvm_context *ac, LLVMValueRef val, const char *name);
LLVMValueRef ac_cast_ptr(struct ac_llvm_context *ctx, LLVMValueRef ptr, LLVMTypeRef type);
LLVMValueRef ac_trim_vector(struct ac_llvm_context *ctx, LLVMValueRef value, unsigned count);
LLVMValueRef ac_unpack_param(struct ac_llvm_context *ctx, LLVMValueRef param, unsigned rshift,
unsigned bitwidth);
void ac_apply_fmask_to_sample(struct ac_llvm_context *ac, LLVMValueRef fmask, LLVMValueRef *addr,
bool is_array_tex);
LLVMValueRef ac_build_ds_swizzle(struct ac_llvm_context *ctx, LLVMValueRef src, unsigned mask);
LLVMValueRef ac_build_readlane_no_opt_barrier(struct ac_llvm_context *ctx, LLVMValueRef src,
LLVMValueRef lane);
LLVMValueRef ac_build_readlane(struct ac_llvm_context *ctx, LLVMValueRef src, LLVMValueRef lane);
LLVMValueRef ac_build_writelane(struct ac_llvm_context *ctx, LLVMValueRef src, LLVMValueRef value,
LLVMValueRef lane);
LLVMValueRef ac_build_mbcnt_add(struct ac_llvm_context *ctx, LLVMValueRef mask, LLVMValueRef add_src);
LLVMValueRef ac_build_mbcnt(struct ac_llvm_context *ctx, LLVMValueRef mask);
LLVMValueRef ac_build_inclusive_scan(struct ac_llvm_context *ctx, LLVMValueRef src, nir_op op);
LLVMValueRef ac_build_exclusive_scan(struct ac_llvm_context *ctx, LLVMValueRef src, nir_op op);
LLVMValueRef ac_build_reduce(struct ac_llvm_context *ctx, LLVMValueRef src, nir_op op,
unsigned cluster_size);
/**
* Common arguments for a scan/reduce operation that accumulates per-wave
* values across an entire workgroup, while respecting the order of waves.
*/
struct ac_wg_scan {
gl_shader_stage stage;
bool enable_reduce;
bool enable_exclusive;
bool enable_inclusive;
nir_op op;
LLVMValueRef src; /* clobbered! */
LLVMValueRef result_reduce;
LLVMValueRef result_exclusive;
LLVMValueRef result_inclusive;
LLVMValueRef extra;
LLVMValueRef waveidx;
LLVMValueRef numwaves; /* only needed for "reduce" operations */
/* T addrspace(LDS) pointer to the same type as value, at least maxwaves entries */
LLVMValueRef scratch;
unsigned maxwaves;
};
void ac_build_wg_wavescan_top(struct ac_llvm_context *ctx, struct ac_wg_scan *ws);
void ac_build_wg_wavescan_bottom(struct ac_llvm_context *ctx, struct ac_wg_scan *ws);
void ac_build_wg_wavescan(struct ac_llvm_context *ctx, struct ac_wg_scan *ws);
void ac_build_wg_scan_top(struct ac_llvm_context *ctx, struct ac_wg_scan *ws);
void ac_build_wg_scan_bottom(struct ac_llvm_context *ctx, struct ac_wg_scan *ws);
void ac_build_wg_scan(struct ac_llvm_context *ctx, struct ac_wg_scan *ws);
LLVMValueRef ac_build_quad_swizzle(struct ac_llvm_context *ctx, LLVMValueRef src, unsigned lane0,
unsigned lane1, unsigned lane2, unsigned lane3);
LLVMValueRef ac_build_shuffle(struct ac_llvm_context *ctx, LLVMValueRef src, LLVMValueRef index);
LLVMValueRef ac_build_frexp_exp(struct ac_llvm_context *ctx, LLVMValueRef src0, unsigned bitsize);
LLVMValueRef ac_build_frexp_mant(struct ac_llvm_context *ctx, LLVMValueRef src0, unsigned bitsize);
LLVMValueRef ac_build_canonicalize(struct ac_llvm_context *ctx, LLVMValueRef src0,
unsigned bitsize);
LLVMValueRef ac_build_ddxy_interp(struct ac_llvm_context *ctx, LLVMValueRef interp_ij);
LLVMValueRef ac_build_load_helper_invocation(struct ac_llvm_context *ctx);
LLVMValueRef ac_build_is_helper_invocation(struct ac_llvm_context *ctx);
LLVMValueRef ac_build_call(struct ac_llvm_context *ctx, LLVMTypeRef fn_type, LLVMValueRef func,
LLVMValueRef *args, unsigned num_args);
LLVMValueRef ac_build_atomic_rmw(struct ac_llvm_context *ctx, LLVMAtomicRMWBinOp op,
LLVMValueRef ptr, LLVMValueRef val, const char *sync_scope);
LLVMValueRef ac_build_atomic_cmp_xchg(struct ac_llvm_context *ctx, LLVMValueRef ptr,
LLVMValueRef cmp, LLVMValueRef val, const char *sync_scope);
void ac_export_mrt_z(struct ac_llvm_context *ctx, LLVMValueRef depth, LLVMValueRef stencil,
LLVMValueRef samplemask, LLVMValueRef mrt0_alpha, bool is_last,
struct ac_export_args *args);
void ac_build_sendmsg_gs_alloc_req(struct ac_llvm_context *ctx, LLVMValueRef wave_id,
LLVMValueRef vtx_cnt, LLVMValueRef prim_cnt);
struct ac_ngg_prim {
unsigned num_vertices;
LLVMValueRef isnull;
LLVMValueRef index[3];
LLVMValueRef edgeflags;
LLVMValueRef passthrough;
};
LLVMValueRef ac_pack_edgeflags_for_export(struct ac_llvm_context *ctx,
const struct ac_shader_args *args);
LLVMValueRef ac_pack_prim_export(struct ac_llvm_context *ctx, const struct ac_ngg_prim *prim);
void ac_build_export_prim(struct ac_llvm_context *ctx, const struct ac_ngg_prim *prim);
LLVMTypeRef ac_arg_type_to_pointee_type(struct ac_llvm_context *ctx, enum ac_arg_type type);
static inline LLVMValueRef ac_get_arg(struct ac_llvm_context *ctx, struct ac_arg arg)
{
assert(arg.used);
return LLVMGetParam(ctx->main_function.value, arg.arg_index);
}
static inline struct ac_llvm_pointer
ac_get_ptr_arg(struct ac_llvm_context *ctx, const struct ac_shader_args *args, struct ac_arg arg)
{
struct ac_llvm_pointer ptr;
ptr.pointee_type = ac_arg_type_to_pointee_type(ctx, args->args[arg.arg_index].type);
ptr.value = LLVMGetParam(ctx->main_function.value, arg.arg_index);
return ptr;
}
enum ac_llvm_calling_convention
{
AC_LLVM_AMDGPU_VS = 87,
AC_LLVM_AMDGPU_GS = 88,
AC_LLVM_AMDGPU_PS = 89,
AC_LLVM_AMDGPU_CS = 90,
AC_LLVM_AMDGPU_HS = 93,
};
struct ac_llvm_pointer ac_build_main(const struct ac_shader_args *args, struct ac_llvm_context *ctx,
enum ac_llvm_calling_convention convention, const char *name,
LLVMTypeRef ret_type, LLVMModuleRef module);
void ac_build_s_endpgm(struct ac_llvm_context *ctx);
void ac_build_triangle_strip_indices_to_triangle(struct ac_llvm_context *ctx, LLVMValueRef is_odd,
LLVMValueRef flatshade_first,
LLVMValueRef index[3]);
LLVMValueRef ac_build_is_inf_or_nan(struct ac_llvm_context *ctx, LLVMValueRef a);
void ac_build_dual_src_blend_swizzle(struct ac_llvm_context *ctx,
struct ac_export_args *mrt0,
struct ac_export_args *mrt1);
#ifdef __cplusplus
}
#endif
#endif
|
afeb412df9db469a21dc41814068a34f2e79fa29
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/drivers/net/wireless/ath/ath5k/initvals.c
|
ee1c2fa8b59190e6739f1eb3774be53f04d1273a
|
[
"Linux-syscall-note",
"GPL-2.0-only",
"GPL-1.0-or-later",
"LicenseRef-scancode-free-unknown",
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] |
permissive
|
OLIMEX/DIY-LAPTOP
|
ae82f4ee79c641d9aee444db9a75f3f6709afa92
|
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
|
refs/heads/rel3
| 2023-08-04T01:54:19.483792
| 2023-04-03T07:18:12
| 2023-04-03T07:18:12
| 80,094,055
| 507
| 92
|
Apache-2.0
| 2023-04-03T07:05:59
| 2017-01-26T07:25:50
|
C
|
UTF-8
|
C
| false
| false
| 51,578
|
c
|
initvals.c
|
/*
* Initial register settings functions
*
* Copyright (c) 2004-2007 Reyk Floeter <reyk@openbsd.org>
* Copyright (c) 2006-2009 Nick Kossifidis <mickflemm@gmail.com>
* Copyright (c) 2007-2008 Jiri Slaby <jirislaby@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include "ath5k.h"
#include "reg.h"
#include "debug.h"
/**
* struct ath5k_ini - Mode-independent initial register writes
* @ini_register: Register address
* @ini_value: Default value
* @ini_mode: 0 to write 1 to read (and clear)
*/
struct ath5k_ini {
u16 ini_register;
u32 ini_value;
enum {
AR5K_INI_WRITE = 0, /* Default */
AR5K_INI_READ = 1,
} ini_mode;
};
/**
* struct ath5k_ini_mode - Mode specific initial register values
* @mode_register: Register address
* @mode_value: Set of values for each enum ath5k_driver_mode
*/
struct ath5k_ini_mode {
u16 mode_register;
u32 mode_value[3];
};
/* Initial register settings for AR5210 */
static const struct ath5k_ini ar5210_ini[] = {
/* PCU and MAC registers */
{ AR5K_NOQCU_TXDP0, 0 },
{ AR5K_NOQCU_TXDP1, 0 },
{ AR5K_RXDP, 0 },
{ AR5K_CR, 0 },
{ AR5K_ISR, 0, AR5K_INI_READ },
{ AR5K_IMR, 0 },
{ AR5K_IER, AR5K_IER_DISABLE },
{ AR5K_BSR, 0, AR5K_INI_READ },
{ AR5K_TXCFG, AR5K_DMASIZE_128B },
{ AR5K_RXCFG, AR5K_DMASIZE_128B },
{ AR5K_CFG, AR5K_INIT_CFG },
{ AR5K_TOPS, 8 },
{ AR5K_RXNOFRM, 8 },
{ AR5K_RPGTO, 0 },
{ AR5K_TXNOFRM, 0 },
{ AR5K_SFR, 0 },
{ AR5K_MIBC, 0 },
{ AR5K_MISC, 0 },
{ AR5K_RX_FILTER_5210, 0 },
{ AR5K_MCAST_FILTER0_5210, 0 },
{ AR5K_MCAST_FILTER1_5210, 0 },
{ AR5K_TX_MASK0, 0 },
{ AR5K_TX_MASK1, 0 },
{ AR5K_CLR_TMASK, 0 },
{ AR5K_TRIG_LVL, AR5K_TUNE_MIN_TX_FIFO_THRES },
{ AR5K_DIAG_SW_5210, 0 },
{ AR5K_RSSI_THR, AR5K_TUNE_RSSI_THRES },
{ AR5K_TSF_L32_5210, 0 },
{ AR5K_TIMER0_5210, 0 },
{ AR5K_TIMER1_5210, 0xffffffff },
{ AR5K_TIMER2_5210, 0xffffffff },
{ AR5K_TIMER3_5210, 1 },
{ AR5K_CFP_DUR_5210, 0 },
{ AR5K_CFP_PERIOD_5210, 0 },
/* PHY registers */
{ AR5K_PHY(0), 0x00000047 },
{ AR5K_PHY_AGC, 0x00000000 },
{ AR5K_PHY(3), 0x09848ea6 },
{ AR5K_PHY(4), 0x3d32e000 },
{ AR5K_PHY(5), 0x0000076b },
{ AR5K_PHY_ACT, AR5K_PHY_ACT_DISABLE },
{ AR5K_PHY(8), 0x02020200 },
{ AR5K_PHY(9), 0x00000e0e },
{ AR5K_PHY(10), 0x0a020201 },
{ AR5K_PHY(11), 0x00036ffc },
{ AR5K_PHY(12), 0x00000000 },
{ AR5K_PHY(13), 0x00000e0e },
{ AR5K_PHY(14), 0x00000007 },
{ AR5K_PHY(15), 0x00020100 },
{ AR5K_PHY(16), 0x89630000 },
{ AR5K_PHY(17), 0x1372169c },
{ AR5K_PHY(18), 0x0018b633 },
{ AR5K_PHY(19), 0x1284613c },
{ AR5K_PHY(20), 0x0de8b8e0 },
{ AR5K_PHY(21), 0x00074859 },
{ AR5K_PHY(22), 0x7e80beba },
{ AR5K_PHY(23), 0x313a665e },
{ AR5K_PHY_AGCCTL, 0x00001d08 },
{ AR5K_PHY(25), 0x0001ce00 },
{ AR5K_PHY(26), 0x409a4190 },
{ AR5K_PHY(28), 0x0000000f },
{ AR5K_PHY(29), 0x00000080 },
{ AR5K_PHY(30), 0x00000004 },
{ AR5K_PHY(31), 0x00000018 }, /* 0x987c */
{ AR5K_PHY(64), 0x00000000 }, /* 0x9900 */
{ AR5K_PHY(65), 0x00000000 },
{ AR5K_PHY(66), 0x00000000 },
{ AR5K_PHY(67), 0x00800000 },
{ AR5K_PHY(68), 0x00000003 },
/* BB gain table (64bytes) */
{ AR5K_BB_GAIN(0), 0x00000000 },
{ AR5K_BB_GAIN(1), 0x00000020 },
{ AR5K_BB_GAIN(2), 0x00000010 },
{ AR5K_BB_GAIN(3), 0x00000030 },
{ AR5K_BB_GAIN(4), 0x00000008 },
{ AR5K_BB_GAIN(5), 0x00000028 },
{ AR5K_BB_GAIN(6), 0x00000028 },
{ AR5K_BB_GAIN(7), 0x00000004 },
{ AR5K_BB_GAIN(8), 0x00000024 },
{ AR5K_BB_GAIN(9), 0x00000014 },
{ AR5K_BB_GAIN(10), 0x00000034 },
{ AR5K_BB_GAIN(11), 0x0000000c },
{ AR5K_BB_GAIN(12), 0x0000002c },
{ AR5K_BB_GAIN(13), 0x00000002 },
{ AR5K_BB_GAIN(14), 0x00000022 },
{ AR5K_BB_GAIN(15), 0x00000012 },
{ AR5K_BB_GAIN(16), 0x00000032 },
{ AR5K_BB_GAIN(17), 0x0000000a },
{ AR5K_BB_GAIN(18), 0x0000002a },
{ AR5K_BB_GAIN(19), 0x00000001 },
{ AR5K_BB_GAIN(20), 0x00000021 },
{ AR5K_BB_GAIN(21), 0x00000011 },
{ AR5K_BB_GAIN(22), 0x00000031 },
{ AR5K_BB_GAIN(23), 0x00000009 },
{ AR5K_BB_GAIN(24), 0x00000029 },
{ AR5K_BB_GAIN(25), 0x00000005 },
{ AR5K_BB_GAIN(26), 0x00000025 },
{ AR5K_BB_GAIN(27), 0x00000015 },
{ AR5K_BB_GAIN(28), 0x00000035 },
{ AR5K_BB_GAIN(29), 0x0000000d },
{ AR5K_BB_GAIN(30), 0x0000002d },
{ AR5K_BB_GAIN(31), 0x00000003 },
{ AR5K_BB_GAIN(32), 0x00000023 },
{ AR5K_BB_GAIN(33), 0x00000013 },
{ AR5K_BB_GAIN(34), 0x00000033 },
{ AR5K_BB_GAIN(35), 0x0000000b },
{ AR5K_BB_GAIN(36), 0x0000002b },
{ AR5K_BB_GAIN(37), 0x00000007 },
{ AR5K_BB_GAIN(38), 0x00000027 },
{ AR5K_BB_GAIN(39), 0x00000017 },
{ AR5K_BB_GAIN(40), 0x00000037 },
{ AR5K_BB_GAIN(41), 0x0000000f },
{ AR5K_BB_GAIN(42), 0x0000002f },
{ AR5K_BB_GAIN(43), 0x0000002f },
{ AR5K_BB_GAIN(44), 0x0000002f },
{ AR5K_BB_GAIN(45), 0x0000002f },
{ AR5K_BB_GAIN(46), 0x0000002f },
{ AR5K_BB_GAIN(47), 0x0000002f },
{ AR5K_BB_GAIN(48), 0x0000002f },
{ AR5K_BB_GAIN(49), 0x0000002f },
{ AR5K_BB_GAIN(50), 0x0000002f },
{ AR5K_BB_GAIN(51), 0x0000002f },
{ AR5K_BB_GAIN(52), 0x0000002f },
{ AR5K_BB_GAIN(53), 0x0000002f },
{ AR5K_BB_GAIN(54), 0x0000002f },
{ AR5K_BB_GAIN(55), 0x0000002f },
{ AR5K_BB_GAIN(56), 0x0000002f },
{ AR5K_BB_GAIN(57), 0x0000002f },
{ AR5K_BB_GAIN(58), 0x0000002f },
{ AR5K_BB_GAIN(59), 0x0000002f },
{ AR5K_BB_GAIN(60), 0x0000002f },
{ AR5K_BB_GAIN(61), 0x0000002f },
{ AR5K_BB_GAIN(62), 0x0000002f },
{ AR5K_BB_GAIN(63), 0x0000002f },
/* 5110 RF gain table (64btes) */
{ AR5K_RF_GAIN(0), 0x0000001d },
{ AR5K_RF_GAIN(1), 0x0000005d },
{ AR5K_RF_GAIN(2), 0x0000009d },
{ AR5K_RF_GAIN(3), 0x000000dd },
{ AR5K_RF_GAIN(4), 0x0000011d },
{ AR5K_RF_GAIN(5), 0x00000021 },
{ AR5K_RF_GAIN(6), 0x00000061 },
{ AR5K_RF_GAIN(7), 0x000000a1 },
{ AR5K_RF_GAIN(8), 0x000000e1 },
{ AR5K_RF_GAIN(9), 0x00000031 },
{ AR5K_RF_GAIN(10), 0x00000071 },
{ AR5K_RF_GAIN(11), 0x000000b1 },
{ AR5K_RF_GAIN(12), 0x0000001c },
{ AR5K_RF_GAIN(13), 0x0000005c },
{ AR5K_RF_GAIN(14), 0x00000029 },
{ AR5K_RF_GAIN(15), 0x00000069 },
{ AR5K_RF_GAIN(16), 0x000000a9 },
{ AR5K_RF_GAIN(17), 0x00000020 },
{ AR5K_RF_GAIN(18), 0x00000019 },
{ AR5K_RF_GAIN(19), 0x00000059 },
{ AR5K_RF_GAIN(20), 0x00000099 },
{ AR5K_RF_GAIN(21), 0x00000030 },
{ AR5K_RF_GAIN(22), 0x00000005 },
{ AR5K_RF_GAIN(23), 0x00000025 },
{ AR5K_RF_GAIN(24), 0x00000065 },
{ AR5K_RF_GAIN(25), 0x000000a5 },
{ AR5K_RF_GAIN(26), 0x00000028 },
{ AR5K_RF_GAIN(27), 0x00000068 },
{ AR5K_RF_GAIN(28), 0x0000001f },
{ AR5K_RF_GAIN(29), 0x0000001e },
{ AR5K_RF_GAIN(30), 0x00000018 },
{ AR5K_RF_GAIN(31), 0x00000058 },
{ AR5K_RF_GAIN(32), 0x00000098 },
{ AR5K_RF_GAIN(33), 0x00000003 },
{ AR5K_RF_GAIN(34), 0x00000004 },
{ AR5K_RF_GAIN(35), 0x00000044 },
{ AR5K_RF_GAIN(36), 0x00000084 },
{ AR5K_RF_GAIN(37), 0x00000013 },
{ AR5K_RF_GAIN(38), 0x00000012 },
{ AR5K_RF_GAIN(39), 0x00000052 },
{ AR5K_RF_GAIN(40), 0x00000092 },
{ AR5K_RF_GAIN(41), 0x000000d2 },
{ AR5K_RF_GAIN(42), 0x0000002b },
{ AR5K_RF_GAIN(43), 0x0000002a },
{ AR5K_RF_GAIN(44), 0x0000006a },
{ AR5K_RF_GAIN(45), 0x000000aa },
{ AR5K_RF_GAIN(46), 0x0000001b },
{ AR5K_RF_GAIN(47), 0x0000001a },
{ AR5K_RF_GAIN(48), 0x0000005a },
{ AR5K_RF_GAIN(49), 0x0000009a },
{ AR5K_RF_GAIN(50), 0x000000da },
{ AR5K_RF_GAIN(51), 0x00000006 },
{ AR5K_RF_GAIN(52), 0x00000006 },
{ AR5K_RF_GAIN(53), 0x00000006 },
{ AR5K_RF_GAIN(54), 0x00000006 },
{ AR5K_RF_GAIN(55), 0x00000006 },
{ AR5K_RF_GAIN(56), 0x00000006 },
{ AR5K_RF_GAIN(57), 0x00000006 },
{ AR5K_RF_GAIN(58), 0x00000006 },
{ AR5K_RF_GAIN(59), 0x00000006 },
{ AR5K_RF_GAIN(60), 0x00000006 },
{ AR5K_RF_GAIN(61), 0x00000006 },
{ AR5K_RF_GAIN(62), 0x00000006 },
{ AR5K_RF_GAIN(63), 0x00000006 },
/* PHY activation */
{ AR5K_PHY(53), 0x00000020 },
{ AR5K_PHY(51), 0x00000004 },
{ AR5K_PHY(50), 0x00060106 },
{ AR5K_PHY(39), 0x0000006d },
{ AR5K_PHY(48), 0x00000000 },
{ AR5K_PHY(52), 0x00000014 },
{ AR5K_PHY_ACT, AR5K_PHY_ACT_ENABLE },
};
/* Initial register settings for AR5211 */
static const struct ath5k_ini ar5211_ini[] = {
{ AR5K_RXDP, 0x00000000 },
{ AR5K_RTSD0, 0x84849c9c },
{ AR5K_RTSD1, 0x7c7c7c7c },
{ AR5K_RXCFG, 0x00000005 },
{ AR5K_MIBC, 0x00000000 },
{ AR5K_TOPS, 0x00000008 },
{ AR5K_RXNOFRM, 0x00000008 },
{ AR5K_TXNOFRM, 0x00000010 },
{ AR5K_RPGTO, 0x00000000 },
{ AR5K_RFCNT, 0x0000001f },
{ AR5K_QUEUE_TXDP(0), 0x00000000 },
{ AR5K_QUEUE_TXDP(1), 0x00000000 },
{ AR5K_QUEUE_TXDP(2), 0x00000000 },
{ AR5K_QUEUE_TXDP(3), 0x00000000 },
{ AR5K_QUEUE_TXDP(4), 0x00000000 },
{ AR5K_QUEUE_TXDP(5), 0x00000000 },
{ AR5K_QUEUE_TXDP(6), 0x00000000 },
{ AR5K_QUEUE_TXDP(7), 0x00000000 },
{ AR5K_QUEUE_TXDP(8), 0x00000000 },
{ AR5K_QUEUE_TXDP(9), 0x00000000 },
{ AR5K_DCU_FP, 0x00000000 },
{ AR5K_STA_ID1, 0x00000000 },
{ AR5K_BSS_ID0, 0x00000000 },
{ AR5K_BSS_ID1, 0x00000000 },
{ AR5K_RSSI_THR, 0x00000000 },
{ AR5K_CFP_PERIOD_5211, 0x00000000 },
{ AR5K_TIMER0_5211, 0x00000030 },
{ AR5K_TIMER1_5211, 0x0007ffff },
{ AR5K_TIMER2_5211, 0x01ffffff },
{ AR5K_TIMER3_5211, 0x00000031 },
{ AR5K_CFP_DUR_5211, 0x00000000 },
{ AR5K_RX_FILTER_5211, 0x00000000 },
{ AR5K_MCAST_FILTER0_5211, 0x00000000 },
{ AR5K_MCAST_FILTER1_5211, 0x00000002 },
{ AR5K_DIAG_SW_5211, 0x00000000 },
{ AR5K_ADDAC_TEST, 0x00000000 },
{ AR5K_DEFAULT_ANTENNA, 0x00000000 },
/* PHY registers */
{ AR5K_PHY_AGC, 0x00000000 },
{ AR5K_PHY(3), 0x2d849093 },
{ AR5K_PHY(4), 0x7d32e000 },
{ AR5K_PHY(5), 0x00000f6b },
{ AR5K_PHY_ACT, 0x00000000 },
{ AR5K_PHY(11), 0x00026ffe },
{ AR5K_PHY(12), 0x00000000 },
{ AR5K_PHY(15), 0x00020100 },
{ AR5K_PHY(16), 0x206a017a },
{ AR5K_PHY(19), 0x1284613c },
{ AR5K_PHY(21), 0x00000859 },
{ AR5K_PHY(26), 0x409a4190 }, /* 0x9868 */
{ AR5K_PHY(27), 0x050cb081 },
{ AR5K_PHY(28), 0x0000000f },
{ AR5K_PHY(29), 0x00000080 },
{ AR5K_PHY(30), 0x0000000c },
{ AR5K_PHY(64), 0x00000000 },
{ AR5K_PHY(65), 0x00000000 },
{ AR5K_PHY(66), 0x00000000 },
{ AR5K_PHY(67), 0x00800000 },
{ AR5K_PHY(68), 0x00000001 },
{ AR5K_PHY(71), 0x0000092a },
{ AR5K_PHY_IQ, 0x00000000 },
{ AR5K_PHY(73), 0x00058a05 },
{ AR5K_PHY(74), 0x00000001 },
{ AR5K_PHY(75), 0x00000000 },
{ AR5K_PHY_PAPD_PROBE, 0x00000000 },
{ AR5K_PHY(77), 0x00000000 }, /* 0x9934 */
{ AR5K_PHY(78), 0x00000000 }, /* 0x9938 */
{ AR5K_PHY(79), 0x0000003f }, /* 0x993c */
{ AR5K_PHY(80), 0x00000004 },
{ AR5K_PHY(82), 0x00000000 },
{ AR5K_PHY(83), 0x00000000 },
{ AR5K_PHY(84), 0x00000000 },
{ AR5K_PHY_RADAR, 0x5d50f14c },
{ AR5K_PHY(86), 0x00000018 },
{ AR5K_PHY(87), 0x004b6a8e },
/* Initial Power table (32bytes)
* common on all cards/modes.
* Note: Table is rewritten during
* txpower setup later using calibration
* data etc. so next write is non-common */
{ AR5K_PHY_PCDAC_TXPOWER(1), 0x06ff05ff },
{ AR5K_PHY_PCDAC_TXPOWER(2), 0x07ff07ff },
{ AR5K_PHY_PCDAC_TXPOWER(3), 0x08ff08ff },
{ AR5K_PHY_PCDAC_TXPOWER(4), 0x09ff09ff },
{ AR5K_PHY_PCDAC_TXPOWER(5), 0x0aff0aff },
{ AR5K_PHY_PCDAC_TXPOWER(6), 0x0bff0bff },
{ AR5K_PHY_PCDAC_TXPOWER(7), 0x0cff0cff },
{ AR5K_PHY_PCDAC_TXPOWER(8), 0x0dff0dff },
{ AR5K_PHY_PCDAC_TXPOWER(9), 0x0fff0eff },
{ AR5K_PHY_PCDAC_TXPOWER(10), 0x12ff12ff },
{ AR5K_PHY_PCDAC_TXPOWER(11), 0x14ff13ff },
{ AR5K_PHY_PCDAC_TXPOWER(12), 0x16ff15ff },
{ AR5K_PHY_PCDAC_TXPOWER(13), 0x19ff17ff },
{ AR5K_PHY_PCDAC_TXPOWER(14), 0x1bff1aff },
{ AR5K_PHY_PCDAC_TXPOWER(15), 0x1eff1dff },
{ AR5K_PHY_PCDAC_TXPOWER(16), 0x23ff20ff },
{ AR5K_PHY_PCDAC_TXPOWER(17), 0x27ff25ff },
{ AR5K_PHY_PCDAC_TXPOWER(18), 0x2cff29ff },
{ AR5K_PHY_PCDAC_TXPOWER(19), 0x31ff2fff },
{ AR5K_PHY_PCDAC_TXPOWER(20), 0x37ff34ff },
{ AR5K_PHY_PCDAC_TXPOWER(21), 0x3aff3aff },
{ AR5K_PHY_PCDAC_TXPOWER(22), 0x3aff3aff },
{ AR5K_PHY_PCDAC_TXPOWER(23), 0x3aff3aff },
{ AR5K_PHY_PCDAC_TXPOWER(24), 0x3aff3aff },
{ AR5K_PHY_PCDAC_TXPOWER(25), 0x3aff3aff },
{ AR5K_PHY_PCDAC_TXPOWER(26), 0x3aff3aff },
{ AR5K_PHY_PCDAC_TXPOWER(27), 0x3aff3aff },
{ AR5K_PHY_PCDAC_TXPOWER(28), 0x3aff3aff },
{ AR5K_PHY_PCDAC_TXPOWER(29), 0x3aff3aff },
{ AR5K_PHY_PCDAC_TXPOWER(30), 0x3aff3aff },
{ AR5K_PHY_PCDAC_TXPOWER(31), 0x3aff3aff },
{ AR5K_PHY_CCKTXCTL, 0x00000000 },
{ AR5K_PHY(642), 0x503e4646 },
{ AR5K_PHY_GAIN_2GHZ, 0x6480416c },
{ AR5K_PHY(644), 0x0199a003 },
{ AR5K_PHY(645), 0x044cd610 },
{ AR5K_PHY(646), 0x13800040 },
{ AR5K_PHY(647), 0x1be00060 },
{ AR5K_PHY(648), 0x0c53800a },
{ AR5K_PHY(649), 0x0014df3b },
{ AR5K_PHY(650), 0x000001b5 },
{ AR5K_PHY(651), 0x00000020 },
};
/* Initial mode-specific settings for AR5211
* 5211 supports OFDM-only g (draft g) but we
* need to test it ! */
static const struct ath5k_ini_mode ar5211_ini_mode[] = {
{ AR5K_TXCFG,
/* A B G */
{ 0x00000015, 0x0000001d, 0x00000015 } },
{ AR5K_QUEUE_DFS_LOCAL_IFS(0),
{ 0x002ffc0f, 0x002ffc1f, 0x002ffc0f } },
{ AR5K_QUEUE_DFS_LOCAL_IFS(1),
{ 0x002ffc0f, 0x002ffc1f, 0x002ffc0f } },
{ AR5K_QUEUE_DFS_LOCAL_IFS(2),
{ 0x002ffc0f, 0x002ffc1f, 0x002ffc0f } },
{ AR5K_QUEUE_DFS_LOCAL_IFS(3),
{ 0x002ffc0f, 0x002ffc1f, 0x002ffc0f } },
{ AR5K_QUEUE_DFS_LOCAL_IFS(4),
{ 0x002ffc0f, 0x002ffc1f, 0x002ffc0f } },
{ AR5K_QUEUE_DFS_LOCAL_IFS(5),
{ 0x002ffc0f, 0x002ffc1f, 0x002ffc0f } },
{ AR5K_QUEUE_DFS_LOCAL_IFS(6),
{ 0x002ffc0f, 0x002ffc1f, 0x002ffc0f } },
{ AR5K_QUEUE_DFS_LOCAL_IFS(7),
{ 0x002ffc0f, 0x002ffc1f, 0x002ffc0f } },
{ AR5K_QUEUE_DFS_LOCAL_IFS(8),
{ 0x002ffc0f, 0x002ffc1f, 0x002ffc0f } },
{ AR5K_QUEUE_DFS_LOCAL_IFS(9),
{ 0x002ffc0f, 0x002ffc1f, 0x002ffc0f } },
{ AR5K_DCU_GBL_IFS_SLOT,
{ 0x00000168, 0x000001b8, 0x00000168 } },
{ AR5K_DCU_GBL_IFS_SIFS,
{ 0x00000230, 0x000000b0, 0x00000230 } },
{ AR5K_DCU_GBL_IFS_EIFS,
{ 0x00000d98, 0x00001f48, 0x00000d98 } },
{ AR5K_DCU_GBL_IFS_MISC,
{ 0x0000a0e0, 0x00005880, 0x0000a0e0 } },
{ AR5K_TIME_OUT,
{ 0x04000400, 0x20003000, 0x04000400 } },
{ AR5K_USEC_5211,
{ 0x0e8d8fa7, 0x01608f95, 0x0e8d8fa7 } },
{ AR5K_PHY(8),
{ 0x02020200, 0x02010200, 0x02020200 } },
{ AR5K_PHY_RF_CTL2,
{ 0x00000e0e, 0x00000707, 0x00000e0e } },
{ AR5K_PHY_RF_CTL3,
{ 0x0a020001, 0x05010000, 0x0a020001 } },
{ AR5K_PHY_RF_CTL4,
{ 0x00000e0e, 0x00000e0e, 0x00000e0e } },
{ AR5K_PHY_PA_CTL,
{ 0x00000007, 0x0000000b, 0x0000000b } },
{ AR5K_PHY_SETTLING,
{ 0x1372169c, 0x137216a8, 0x1372169c } },
{ AR5K_PHY_GAIN,
{ 0x0018ba67, 0x0018ba69, 0x0018ba69 } },
{ AR5K_PHY_DESIRED_SIZE,
{ 0x0c28b4e0, 0x0c28b4e0, 0x0c28b4e0 } },
{ AR5K_PHY_SIG,
{ 0x7e800d2e, 0x7ec00d2e, 0x7e800d2e } },
{ AR5K_PHY_AGCCOARSE,
{ 0x31375d5e, 0x313a5d5e, 0x31375d5e } },
{ AR5K_PHY_AGCCTL,
{ 0x0000bd10, 0x0000bd38, 0x0000bd10 } },
{ AR5K_PHY_NF,
{ 0x0001ce00, 0x0001ce00, 0x0001ce00 } },
{ AR5K_PHY_RX_DELAY,
{ 0x00002710, 0x0000157c, 0x00002710 } },
{ AR5K_PHY(70),
{ 0x00000190, 0x00000084, 0x00000190 } },
{ AR5K_PHY_FRAME_CTL_5211,
{ 0x6fe01020, 0x6fe00920, 0x6fe01020 } },
{ AR5K_PHY_PCDAC_TXPOWER_BASE,
{ 0x05ff14ff, 0x05ff14ff, 0x05ff19ff } },
{ AR5K_RF_BUFFER_CONTROL_4,
{ 0x00000010, 0x00000010, 0x00000010 } },
};
/* Initial register settings for AR5212 and newer chips */
static const struct ath5k_ini ar5212_ini_common_start[] = {
{ AR5K_RXDP, 0x00000000 },
{ AR5K_RXCFG, 0x00000005 },
{ AR5K_MIBC, 0x00000000 },
{ AR5K_TOPS, 0x00000008 },
{ AR5K_RXNOFRM, 0x00000008 },
{ AR5K_TXNOFRM, 0x00000010 },
{ AR5K_RPGTO, 0x00000000 },
{ AR5K_RFCNT, 0x0000001f },
{ AR5K_QUEUE_TXDP(0), 0x00000000 },
{ AR5K_QUEUE_TXDP(1), 0x00000000 },
{ AR5K_QUEUE_TXDP(2), 0x00000000 },
{ AR5K_QUEUE_TXDP(3), 0x00000000 },
{ AR5K_QUEUE_TXDP(4), 0x00000000 },
{ AR5K_QUEUE_TXDP(5), 0x00000000 },
{ AR5K_QUEUE_TXDP(6), 0x00000000 },
{ AR5K_QUEUE_TXDP(7), 0x00000000 },
{ AR5K_QUEUE_TXDP(8), 0x00000000 },
{ AR5K_QUEUE_TXDP(9), 0x00000000 },
{ AR5K_DCU_FP, 0x00000000 },
{ AR5K_DCU_TXP, 0x00000000 },
/* Tx filter table 0 (32 entries) */
{ AR5K_DCU_TX_FILTER_0(0), 0x00000000 }, /* DCU 0 */
{ AR5K_DCU_TX_FILTER_0(1), 0x00000000 },
{ AR5K_DCU_TX_FILTER_0(2), 0x00000000 },
{ AR5K_DCU_TX_FILTER_0(3), 0x00000000 },
{ AR5K_DCU_TX_FILTER_0(4), 0x00000000 }, /* DCU 1 */
{ AR5K_DCU_TX_FILTER_0(5), 0x00000000 },
{ AR5K_DCU_TX_FILTER_0(6), 0x00000000 },
{ AR5K_DCU_TX_FILTER_0(7), 0x00000000 },
{ AR5K_DCU_TX_FILTER_0(8), 0x00000000 }, /* DCU 2 */
{ AR5K_DCU_TX_FILTER_0(9), 0x00000000 },
{ AR5K_DCU_TX_FILTER_0(10), 0x00000000 },
{ AR5K_DCU_TX_FILTER_0(11), 0x00000000 },
{ AR5K_DCU_TX_FILTER_0(12), 0x00000000 }, /* DCU 3 */
{ AR5K_DCU_TX_FILTER_0(13), 0x00000000 },
{ AR5K_DCU_TX_FILTER_0(14), 0x00000000 },
{ AR5K_DCU_TX_FILTER_0(15), 0x00000000 },
{ AR5K_DCU_TX_FILTER_0(16), 0x00000000 }, /* DCU 4 */
{ AR5K_DCU_TX_FILTER_0(17), 0x00000000 },
{ AR5K_DCU_TX_FILTER_0(18), 0x00000000 },
{ AR5K_DCU_TX_FILTER_0(19), 0x00000000 },
{ AR5K_DCU_TX_FILTER_0(20), 0x00000000 }, /* DCU 5 */
{ AR5K_DCU_TX_FILTER_0(21), 0x00000000 },
{ AR5K_DCU_TX_FILTER_0(22), 0x00000000 },
{ AR5K_DCU_TX_FILTER_0(23), 0x00000000 },
{ AR5K_DCU_TX_FILTER_0(24), 0x00000000 }, /* DCU 6 */
{ AR5K_DCU_TX_FILTER_0(25), 0x00000000 },
{ AR5K_DCU_TX_FILTER_0(26), 0x00000000 },
{ AR5K_DCU_TX_FILTER_0(27), 0x00000000 },
{ AR5K_DCU_TX_FILTER_0(28), 0x00000000 }, /* DCU 7 */
{ AR5K_DCU_TX_FILTER_0(29), 0x00000000 },
{ AR5K_DCU_TX_FILTER_0(30), 0x00000000 },
{ AR5K_DCU_TX_FILTER_0(31), 0x00000000 },
/* Tx filter table 1 (16 entries) */
{ AR5K_DCU_TX_FILTER_1(0), 0x00000000 },
{ AR5K_DCU_TX_FILTER_1(1), 0x00000000 },
{ AR5K_DCU_TX_FILTER_1(2), 0x00000000 },
{ AR5K_DCU_TX_FILTER_1(3), 0x00000000 },
{ AR5K_DCU_TX_FILTER_1(4), 0x00000000 },
{ AR5K_DCU_TX_FILTER_1(5), 0x00000000 },
{ AR5K_DCU_TX_FILTER_1(6), 0x00000000 },
{ AR5K_DCU_TX_FILTER_1(7), 0x00000000 },
{ AR5K_DCU_TX_FILTER_1(8), 0x00000000 },
{ AR5K_DCU_TX_FILTER_1(9), 0x00000000 },
{ AR5K_DCU_TX_FILTER_1(10), 0x00000000 },
{ AR5K_DCU_TX_FILTER_1(11), 0x00000000 },
{ AR5K_DCU_TX_FILTER_1(12), 0x00000000 },
{ AR5K_DCU_TX_FILTER_1(13), 0x00000000 },
{ AR5K_DCU_TX_FILTER_1(14), 0x00000000 },
{ AR5K_DCU_TX_FILTER_1(15), 0x00000000 },
{ AR5K_DCU_TX_FILTER_CLR, 0x00000000 },
{ AR5K_DCU_TX_FILTER_SET, 0x00000000 },
{ AR5K_STA_ID1, 0x00000000 },
{ AR5K_BSS_ID0, 0x00000000 },
{ AR5K_BSS_ID1, 0x00000000 },
{ AR5K_BEACON_5211, 0x00000000 },
{ AR5K_CFP_PERIOD_5211, 0x00000000 },
{ AR5K_TIMER0_5211, 0x00000030 },
{ AR5K_TIMER1_5211, 0x0007ffff },
{ AR5K_TIMER2_5211, 0x01ffffff },
{ AR5K_TIMER3_5211, 0x00000031 },
{ AR5K_CFP_DUR_5211, 0x00000000 },
{ AR5K_RX_FILTER_5211, 0x00000000 },
{ AR5K_DIAG_SW_5211, 0x00000000 },
{ AR5K_ADDAC_TEST, 0x00000000 },
{ AR5K_DEFAULT_ANTENNA, 0x00000000 },
{ AR5K_FRAME_CTL_QOSM, 0x000fc78f },
{ AR5K_XRMODE, 0x2a82301a },
{ AR5K_XRDELAY, 0x05dc01e0 },
{ AR5K_XRTIMEOUT, 0x1f402710 },
{ AR5K_XRCHIRP, 0x01f40000 },
{ AR5K_XRSTOMP, 0x00001e1c },
{ AR5K_SLEEP0, 0x0002aaaa },
{ AR5K_SLEEP1, 0x02005555 },
{ AR5K_SLEEP2, 0x00000000 },
{ AR_BSSMSKL, 0xffffffff },
{ AR_BSSMSKU, 0x0000ffff },
{ AR5K_TXPC, 0x00000000 },
{ AR5K_PROFCNT_TX, 0x00000000 },
{ AR5K_PROFCNT_RX, 0x00000000 },
{ AR5K_PROFCNT_RXCLR, 0x00000000 },
{ AR5K_PROFCNT_CYCLE, 0x00000000 },
{ AR5K_QUIET_CTL1, 0x00000088 },
/* Initial rate duration table (32 entries )*/
{ AR5K_RATE_DUR(0), 0x00000000 },
{ AR5K_RATE_DUR(1), 0x0000008c },
{ AR5K_RATE_DUR(2), 0x000000e4 },
{ AR5K_RATE_DUR(3), 0x000002d5 },
{ AR5K_RATE_DUR(4), 0x00000000 },
{ AR5K_RATE_DUR(5), 0x00000000 },
{ AR5K_RATE_DUR(6), 0x000000a0 },
{ AR5K_RATE_DUR(7), 0x000001c9 },
{ AR5K_RATE_DUR(8), 0x0000002c },
{ AR5K_RATE_DUR(9), 0x0000002c },
{ AR5K_RATE_DUR(10), 0x00000030 },
{ AR5K_RATE_DUR(11), 0x0000003c },
{ AR5K_RATE_DUR(12), 0x0000002c },
{ AR5K_RATE_DUR(13), 0x0000002c },
{ AR5K_RATE_DUR(14), 0x00000030 },
{ AR5K_RATE_DUR(15), 0x0000003c },
{ AR5K_RATE_DUR(16), 0x00000000 },
{ AR5K_RATE_DUR(17), 0x00000000 },
{ AR5K_RATE_DUR(18), 0x00000000 },
{ AR5K_RATE_DUR(19), 0x00000000 },
{ AR5K_RATE_DUR(20), 0x00000000 },
{ AR5K_RATE_DUR(21), 0x00000000 },
{ AR5K_RATE_DUR(22), 0x00000000 },
{ AR5K_RATE_DUR(23), 0x00000000 },
{ AR5K_RATE_DUR(24), 0x000000d5 },
{ AR5K_RATE_DUR(25), 0x000000df },
{ AR5K_RATE_DUR(26), 0x00000102 },
{ AR5K_RATE_DUR(27), 0x0000013a },
{ AR5K_RATE_DUR(28), 0x00000075 },
{ AR5K_RATE_DUR(29), 0x0000007f },
{ AR5K_RATE_DUR(30), 0x000000a2 },
{ AR5K_RATE_DUR(31), 0x00000000 },
{ AR5K_QUIET_CTL2, 0x00010002 },
{ AR5K_TSF_PARM, 0x00000001 },
{ AR5K_QOS_NOACK, 0x000000c0 },
{ AR5K_PHY_ERR_FIL, 0x00000000 },
{ AR5K_XRLAT_TX, 0x00000168 },
{ AR5K_ACKSIFS, 0x00000000 },
/* Rate -> db table
* notice ...03<-02<-01<-00 ! */
{ AR5K_RATE2DB(0), 0x03020100 },
{ AR5K_RATE2DB(1), 0x07060504 },
{ AR5K_RATE2DB(2), 0x0b0a0908 },
{ AR5K_RATE2DB(3), 0x0f0e0d0c },
{ AR5K_RATE2DB(4), 0x13121110 },
{ AR5K_RATE2DB(5), 0x17161514 },
{ AR5K_RATE2DB(6), 0x1b1a1918 },
{ AR5K_RATE2DB(7), 0x1f1e1d1c },
/* Db -> Rate table */
{ AR5K_DB2RATE(0), 0x03020100 },
{ AR5K_DB2RATE(1), 0x07060504 },
{ AR5K_DB2RATE(2), 0x0b0a0908 },
{ AR5K_DB2RATE(3), 0x0f0e0d0c },
{ AR5K_DB2RATE(4), 0x13121110 },
{ AR5K_DB2RATE(5), 0x17161514 },
{ AR5K_DB2RATE(6), 0x1b1a1918 },
{ AR5K_DB2RATE(7), 0x1f1e1d1c },
/* PHY registers (Common settings
* for all chips/modes) */
{ AR5K_PHY(3), 0xad848e19 },
{ AR5K_PHY(4), 0x7d28e000 },
{ AR5K_PHY_TIMING_3, 0x9c0a9f6b },
{ AR5K_PHY_ACT, 0x00000000 },
{ AR5K_PHY(16), 0x206a017a },
{ AR5K_PHY(21), 0x00000859 },
{ AR5K_PHY_BIN_MASK_1, 0x00000000 },
{ AR5K_PHY_BIN_MASK_2, 0x00000000 },
{ AR5K_PHY_BIN_MASK_3, 0x00000000 },
{ AR5K_PHY_BIN_MASK_CTL, 0x00800000 },
{ AR5K_PHY_ANT_CTL, 0x00000001 },
/*{ AR5K_PHY(71), 0x0000092a },*/ /* Old value */
{ AR5K_PHY_MAX_RX_LEN, 0x00000c80 },
{ AR5K_PHY_IQ, 0x05100000 },
{ AR5K_PHY_WARM_RESET, 0x00000001 },
{ AR5K_PHY_CTL, 0x00000004 },
{ AR5K_PHY_TXPOWER_RATE1, 0x1e1f2022 },
{ AR5K_PHY_TXPOWER_RATE2, 0x0a0b0c0d },
{ AR5K_PHY_TXPOWER_RATE_MAX, 0x0000003f },
{ AR5K_PHY(82), 0x9280b212 },
{ AR5K_PHY_RADAR, 0x5d50e188 },
/*{ AR5K_PHY(86), 0x000000ff },*/
{ AR5K_PHY(87), 0x004b6a8e },
{ AR5K_PHY_NFTHRES, 0x000003ce },
{ AR5K_PHY_RESTART, 0x192fb515 },
{ AR5K_PHY(94), 0x00000001 },
{ AR5K_PHY_RFBUS_REQ, 0x00000000 },
/*{ AR5K_PHY(644), 0x0080a333 },*/ /* Old value */
/*{ AR5K_PHY(645), 0x00206c10 },*/ /* Old value */
{ AR5K_PHY(644), 0x00806333 },
{ AR5K_PHY(645), 0x00106c10 },
{ AR5K_PHY(646), 0x009c4060 },
/* { AR5K_PHY(647), 0x1483800a }, */
/* { AR5K_PHY(648), 0x01831061 }, */ /* Old value */
{ AR5K_PHY(648), 0x018830c6 },
{ AR5K_PHY(649), 0x00000400 },
/*{ AR5K_PHY(650), 0x000001b5 },*/
{ AR5K_PHY(651), 0x00000000 },
{ AR5K_PHY_TXPOWER_RATE3, 0x20202020 },
{ AR5K_PHY_TXPOWER_RATE4, 0x20202020 },
/*{ AR5K_PHY(655), 0x13c889af },*/
{ AR5K_PHY(656), 0x38490a20 },
{ AR5K_PHY(657), 0x00007bb6 },
{ AR5K_PHY(658), 0x0fff3ffc },
};
/* Initial mode-specific settings for AR5212 (Written before ar5212_ini) */
static const struct ath5k_ini_mode ar5212_ini_mode_start[] = {
{ AR5K_QUEUE_DFS_LOCAL_IFS(0),
/* A/XR B G */
{ 0x002ffc0f, 0x002ffc1f, 0x002ffc0f } },
{ AR5K_QUEUE_DFS_LOCAL_IFS(1),
{ 0x002ffc0f, 0x002ffc1f, 0x002ffc0f } },
{ AR5K_QUEUE_DFS_LOCAL_IFS(2),
{ 0x002ffc0f, 0x002ffc1f, 0x002ffc0f } },
{ AR5K_QUEUE_DFS_LOCAL_IFS(3),
{ 0x002ffc0f, 0x002ffc1f, 0x002ffc0f } },
{ AR5K_QUEUE_DFS_LOCAL_IFS(4),
{ 0x002ffc0f, 0x002ffc1f, 0x002ffc0f } },
{ AR5K_QUEUE_DFS_LOCAL_IFS(5),
{ 0x002ffc0f, 0x002ffc1f, 0x002ffc0f } },
{ AR5K_QUEUE_DFS_LOCAL_IFS(6),
{ 0x002ffc0f, 0x002ffc1f, 0x002ffc0f } },
{ AR5K_QUEUE_DFS_LOCAL_IFS(7),
{ 0x002ffc0f, 0x002ffc1f, 0x002ffc0f } },
{ AR5K_QUEUE_DFS_LOCAL_IFS(8),
{ 0x002ffc0f, 0x002ffc1f, 0x002ffc0f } },
{ AR5K_QUEUE_DFS_LOCAL_IFS(9),
{ 0x002ffc0f, 0x002ffc1f, 0x002ffc0f } },
{ AR5K_DCU_GBL_IFS_SIFS,
{ 0x00000230, 0x000000b0, 0x00000160 } },
{ AR5K_DCU_GBL_IFS_SLOT,
{ 0x00000168, 0x000001b8, 0x0000018c } },
{ AR5K_DCU_GBL_IFS_EIFS,
{ 0x00000e60, 0x00001f1c, 0x00003e38 } },
{ AR5K_DCU_GBL_IFS_MISC,
{ 0x0000a0e0, 0x00005880, 0x0000b0e0 } },
{ AR5K_TIME_OUT,
{ 0x03e803e8, 0x04200420, 0x08400840 } },
{ AR5K_PHY(8),
{ 0x02020200, 0x02010200, 0x02020200 } },
{ AR5K_PHY_RF_CTL2,
{ 0x00000e0e, 0x00000707, 0x00000e0e } },
{ AR5K_PHY_SETTLING,
{ 0x1372161c, 0x13721722, 0x137216a2 } },
{ AR5K_PHY_AGCCTL,
{ 0x00009d10, 0x00009d18, 0x00009d18 } },
{ AR5K_PHY_NF,
{ 0x0001ce00, 0x0001ce00, 0x0001ce00 } },
{ AR5K_PHY_WEAK_OFDM_HIGH_THR,
{ 0x409a4190, 0x409a4190, 0x409a4190 } },
{ AR5K_PHY(70),
{ 0x000001b8, 0x00000084, 0x00000108 } },
{ AR5K_PHY_OFDM_SELFCORR,
{ 0x10058a05, 0x10058a05, 0x10058a05 } },
{ 0xa230,
{ 0x00000000, 0x00000000, 0x00000108 } },
};
/* Initial mode-specific settings for AR5212 + RF5111
* (Written after ar5212_ini) */
static const struct ath5k_ini_mode rf5111_ini_mode_end[] = {
{ AR5K_TXCFG,
/* A/XR B G */
{ 0x00008015, 0x00008015, 0x00008015 } },
{ AR5K_USEC_5211,
{ 0x128d8fa7, 0x04e00f95, 0x12e00fab } },
{ AR5K_PHY_RF_CTL3,
{ 0x0a020001, 0x05010100, 0x0a020001 } },
{ AR5K_PHY_RF_CTL4,
{ 0x00000e0e, 0x00000e0e, 0x00000e0e } },
{ AR5K_PHY_PA_CTL,
{ 0x00000007, 0x0000000b, 0x0000000b } },
{ AR5K_PHY_GAIN,
{ 0x0018da5a, 0x0018ca69, 0x0018ca69 } },
{ AR5K_PHY_DESIRED_SIZE,
{ 0x0de8b4e0, 0x0de8b4e0, 0x0de8b4e0 } },
{ AR5K_PHY_SIG,
{ 0x7e800d2e, 0x7ee84d2e, 0x7ee84d2e } },
{ AR5K_PHY_AGCCOARSE,
{ 0x3137665e, 0x3137665e, 0x3137665e } },
{ AR5K_PHY_WEAK_OFDM_LOW_THR,
{ 0x050cb081, 0x050cb081, 0x050cb080 } },
{ AR5K_PHY_RX_DELAY,
{ 0x00002710, 0x0000157c, 0x00002af8 } },
{ AR5K_PHY_FRAME_CTL_5211,
{ 0xf7b81020, 0xf7b80d20, 0xf7b81020 } },
{ AR5K_PHY_GAIN_2GHZ,
{ 0x642c416a, 0x6440416a, 0x6440416a } },
{ AR5K_PHY_CCK_RX_CTL_4,
{ 0x1883800a, 0x1873800a, 0x1883800a } },
};
/* Common for all modes */
static const struct ath5k_ini rf5111_ini_common_end[] = {
{ AR5K_DCU_FP, 0x00000000 },
{ AR5K_PHY_AGC, 0x00000000 },
{ AR5K_PHY_ADC_CTL, 0x00022ffe },
{ 0x983c, 0x00020100 },
{ AR5K_PHY_GAIN_OFFSET, 0x1284613c },
{ AR5K_PHY_PAPD_PROBE, 0x00004883 },
{ 0x9940, 0x00000004 },
{ 0x9958, 0x000000ff },
{ 0x9974, 0x00000000 },
{ AR5K_PHY_SPENDING, 0x00000018 },
{ AR5K_PHY_CCKTXCTL, 0x00000000 },
{ AR5K_PHY_CCK_CROSSCORR, 0xd03e6788 },
{ AR5K_PHY_DAG_CCK_CTL, 0x000001b5 },
{ 0xa23c, 0x13c889af },
};
/* Initial mode-specific settings for AR5212 + RF5112
* (Written after ar5212_ini) */
static const struct ath5k_ini_mode rf5112_ini_mode_end[] = {
{ AR5K_TXCFG,
/* A/XR B G */
{ 0x00008015, 0x00008015, 0x00008015 } },
{ AR5K_USEC_5211,
{ 0x128d93a7, 0x04e01395, 0x12e013ab } },
{ AR5K_PHY_RF_CTL3,
{ 0x0a020001, 0x05020100, 0x0a020001 } },
{ AR5K_PHY_RF_CTL4,
{ 0x00000e0e, 0x00000e0e, 0x00000e0e } },
{ AR5K_PHY_PA_CTL,
{ 0x00000007, 0x0000000b, 0x0000000b } },
{ AR5K_PHY_GAIN,
{ 0x0018da6d, 0x0018ca75, 0x0018ca75 } },
{ AR5K_PHY_DESIRED_SIZE,
{ 0x0de8b4e0, 0x0de8b4e0, 0x0de8b4e0 } },
{ AR5K_PHY_SIG,
{ 0x7e800d2e, 0x7ee80d2e, 0x7ee80d2e } },
{ AR5K_PHY_AGCCOARSE,
{ 0x3137665e, 0x3137665e, 0x3137665e } },
{ AR5K_PHY_WEAK_OFDM_LOW_THR,
{ 0x050cb081, 0x050cb081, 0x050cb081 } },
{ AR5K_PHY_RX_DELAY,
{ 0x000007d0, 0x0000044c, 0x00000898 } },
{ AR5K_PHY_FRAME_CTL_5211,
{ 0xf7b81020, 0xf7b80d10, 0xf7b81010 } },
{ AR5K_PHY_CCKTXCTL,
{ 0x00000000, 0x00000008, 0x00000008 } },
{ AR5K_PHY_CCK_CROSSCORR,
{ 0xd6be6788, 0xd03e6788, 0xd03e6788 } },
{ AR5K_PHY_GAIN_2GHZ,
{ 0x642c0140, 0x6442c160, 0x6442c160 } },
{ AR5K_PHY_CCK_RX_CTL_4,
{ 0x1883800a, 0x1873800a, 0x1883800a } },
};
static const struct ath5k_ini rf5112_ini_common_end[] = {
{ AR5K_DCU_FP, 0x00000000 },
{ AR5K_PHY_AGC, 0x00000000 },
{ AR5K_PHY_ADC_CTL, 0x00022ffe },
{ 0x983c, 0x00020100 },
{ AR5K_PHY_GAIN_OFFSET, 0x1284613c },
{ AR5K_PHY_PAPD_PROBE, 0x00004882 },
{ 0x9940, 0x00000004 },
{ 0x9958, 0x000000ff },
{ 0x9974, 0x00000000 },
{ AR5K_PHY_DAG_CCK_CTL, 0x000001b5 },
{ 0xa23c, 0x13c889af },
};
/* Initial mode-specific settings for RF5413/5414
* (Written after ar5212_ini) */
static const struct ath5k_ini_mode rf5413_ini_mode_end[] = {
{ AR5K_TXCFG,
/* A/XR B G */
{ 0x00000015, 0x00000015, 0x00000015 } },
{ AR5K_USEC_5211,
{ 0x128d93a7, 0x04e01395, 0x12e013ab } },
{ AR5K_PHY_RF_CTL3,
{ 0x0a020001, 0x05020100, 0x0a020001 } },
{ AR5K_PHY_RF_CTL4,
{ 0x00000e0e, 0x00000e0e, 0x00000e0e } },
{ AR5K_PHY_PA_CTL,
{ 0x00000007, 0x0000000b, 0x0000000b } },
{ AR5K_PHY_GAIN,
{ 0x0018fa61, 0x001a1a63, 0x001a1a63 } },
{ AR5K_PHY_DESIRED_SIZE,
{ 0x0c98b4e0, 0x0c98b0da, 0x0c98b0da } },
{ AR5K_PHY_SIG,
{ 0x7ec80d2e, 0x7ec80d2e, 0x7ec80d2e } },
{ AR5K_PHY_AGCCOARSE,
{ 0x3139605e, 0x3139605e, 0x3139605e } },
{ AR5K_PHY_WEAK_OFDM_LOW_THR,
{ 0x050cb081, 0x050cb081, 0x050cb081 } },
{ AR5K_PHY_RX_DELAY,
{ 0x000007d0, 0x0000044c, 0x00000898 } },
{ AR5K_PHY_FRAME_CTL_5211,
{ 0xf7b81000, 0xf7b80d00, 0xf7b81000 } },
{ AR5K_PHY_CCKTXCTL,
{ 0x00000000, 0x00000000, 0x00000000 } },
{ AR5K_PHY_CCK_CROSSCORR,
{ 0xd6be6788, 0xd03e6788, 0xd03e6788 } },
{ AR5K_PHY_GAIN_2GHZ,
{ 0x002ec1e0, 0x002ac120, 0x002ac120 } },
{ AR5K_PHY_CCK_RX_CTL_4,
{ 0x1883800a, 0x1863800a, 0x1883800a } },
{ 0xa300,
{ 0x18010000, 0x18010000, 0x18010000 } },
{ 0xa304,
{ 0x30032602, 0x30032602, 0x30032602 } },
{ 0xa308,
{ 0x48073e06, 0x48073e06, 0x48073e06 } },
{ 0xa30c,
{ 0x560b4c0a, 0x560b4c0a, 0x560b4c0a } },
{ 0xa310,
{ 0x641a600f, 0x641a600f, 0x641a600f } },
{ 0xa314,
{ 0x784f6e1b, 0x784f6e1b, 0x784f6e1b } },
{ 0xa318,
{ 0x868f7c5a, 0x868f7c5a, 0x868f7c5a } },
{ 0xa31c,
{ 0x90cf865b, 0x8ecf865b, 0x8ecf865b } },
{ 0xa320,
{ 0x9d4f970f, 0x9b4f970f, 0x9b4f970f } },
{ 0xa324,
{ 0xa7cfa38f, 0xa3cf9f8f, 0xa3cf9f8f } },
{ 0xa328,
{ 0xb55faf1f, 0xb35faf1f, 0xb35faf1f } },
{ 0xa32c,
{ 0xbddfb99f, 0xbbdfb99f, 0xbbdfb99f } },
{ 0xa330,
{ 0xcb7fc53f, 0xcb7fc73f, 0xcb7fc73f } },
{ 0xa334,
{ 0xd5ffd1bf, 0xd3ffd1bf, 0xd3ffd1bf } },
};
static const struct ath5k_ini rf5413_ini_common_end[] = {
{ AR5K_DCU_FP, 0x000003e0 },
{ AR5K_5414_CBCFG, 0x00000010 },
{ AR5K_SEQ_MASK, 0x0000000f },
{ 0x809c, 0x00000000 },
{ 0x80a0, 0x00000000 },
{ AR5K_MIC_QOS_CTL, 0x00000000 },
{ AR5K_MIC_QOS_SEL, 0x00000000 },
{ AR5K_MISC_MODE, 0x00000000 },
{ AR5K_OFDM_FIL_CNT, 0x00000000 },
{ AR5K_CCK_FIL_CNT, 0x00000000 },
{ AR5K_PHYERR_CNT1, 0x00000000 },
{ AR5K_PHYERR_CNT1_MASK, 0x00000000 },
{ AR5K_PHYERR_CNT2, 0x00000000 },
{ AR5K_PHYERR_CNT2_MASK, 0x00000000 },
{ AR5K_TSF_THRES, 0x00000000 },
{ 0x8140, 0x800003f9 },
{ 0x8144, 0x00000000 },
{ AR5K_PHY_AGC, 0x00000000 },
{ AR5K_PHY_ADC_CTL, 0x0000a000 },
{ 0x983c, 0x00200400 },
{ AR5K_PHY_GAIN_OFFSET, 0x1284233c },
{ AR5K_PHY_SCR, 0x0000001f },
{ AR5K_PHY_SLMT, 0x00000080 },
{ AR5K_PHY_SCAL, 0x0000000e },
{ 0x9958, 0x00081fff },
{ AR5K_PHY_TIMING_7, 0x00000000 },
{ AR5K_PHY_TIMING_8, 0x02800000 },
{ AR5K_PHY_TIMING_11, 0x00000000 },
{ AR5K_PHY_HEAVY_CLIP_ENABLE, 0x00000000 },
{ 0x99e4, 0xaaaaaaaa },
{ 0x99e8, 0x3c466478 },
{ 0x99ec, 0x000000aa },
{ AR5K_PHY_SCLOCK, 0x0000000c },
{ AR5K_PHY_SDELAY, 0x000000ff },
{ AR5K_PHY_SPENDING, 0x00000014 },
{ AR5K_PHY_DAG_CCK_CTL, 0x000009b5 },
{ 0xa23c, 0x93c889af },
{ AR5K_PHY_FAST_ADC, 0x00000001 },
{ 0xa250, 0x0000a000 },
{ AR5K_PHY_BLUETOOTH, 0x00000000 },
{ AR5K_PHY_TPC_RG1, 0x0cc75380 },
{ 0xa25c, 0x0f0f0f01 },
{ 0xa260, 0x5f690f01 },
{ 0xa264, 0x00418a11 },
{ 0xa268, 0x00000000 },
{ AR5K_PHY_TPC_RG5, 0x0c30c16a },
{ 0xa270, 0x00820820 },
{ 0xa274, 0x081b7caa },
{ 0xa278, 0x1ce739ce },
{ 0xa27c, 0x051701ce },
{ 0xa338, 0x00000000 },
{ 0xa33c, 0x00000000 },
{ 0xa340, 0x00000000 },
{ 0xa344, 0x00000000 },
{ 0xa348, 0x3fffffff },
{ 0xa34c, 0x3fffffff },
{ 0xa350, 0x3fffffff },
{ 0xa354, 0x0003ffff },
{ 0xa358, 0x79a8aa1f },
{ 0xa35c, 0x066c420f },
{ 0xa360, 0x0f282207 },
{ 0xa364, 0x17601685 },
{ 0xa368, 0x1f801104 },
{ 0xa36c, 0x37a00c03 },
{ 0xa370, 0x3fc40883 },
{ 0xa374, 0x57c00803 },
{ 0xa378, 0x5fd80682 },
{ 0xa37c, 0x7fe00482 },
{ 0xa380, 0x7f3c7bba },
{ 0xa384, 0xf3307ff0 },
};
/* Initial mode-specific settings for RF2413/2414
* (Written after ar5212_ini) */
/* XXX: a mode ? */
static const struct ath5k_ini_mode rf2413_ini_mode_end[] = {
{ AR5K_TXCFG,
/* A/XR B G */
{ 0x00000015, 0x00000015, 0x00000015 } },
{ AR5K_USEC_5211,
{ 0x128d93a7, 0x04e01395, 0x12e013ab } },
{ AR5K_PHY_RF_CTL3,
{ 0x0a020001, 0x05020000, 0x0a020001 } },
{ AR5K_PHY_RF_CTL4,
{ 0x00000e00, 0x00000e00, 0x00000e00 } },
{ AR5K_PHY_PA_CTL,
{ 0x00000002, 0x0000000a, 0x0000000a } },
{ AR5K_PHY_GAIN,
{ 0x0018da6d, 0x001a6a64, 0x001a6a64 } },
{ AR5K_PHY_DESIRED_SIZE,
{ 0x0de8b4e0, 0x0de8b0da, 0x0c98b0da } },
{ AR5K_PHY_SIG,
{ 0x7e800d2e, 0x7ee80d2e, 0x7ec80d2e } },
{ AR5K_PHY_AGCCOARSE,
{ 0x3137665e, 0x3137665e, 0x3139605e } },
{ AR5K_PHY_WEAK_OFDM_LOW_THR,
{ 0x050cb081, 0x050cb081, 0x050cb081 } },
{ AR5K_PHY_RX_DELAY,
{ 0x000007d0, 0x0000044c, 0x00000898 } },
{ AR5K_PHY_FRAME_CTL_5211,
{ 0xf7b81000, 0xf7b80d00, 0xf7b81000 } },
{ AR5K_PHY_CCKTXCTL,
{ 0x00000000, 0x00000000, 0x00000000 } },
{ AR5K_PHY_CCK_CROSSCORR,
{ 0xd6be6788, 0xd03e6788, 0xd03e6788 } },
{ AR5K_PHY_GAIN_2GHZ,
{ 0x002c0140, 0x0042c140, 0x0042c140 } },
{ AR5K_PHY_CCK_RX_CTL_4,
{ 0x1883800a, 0x1863800a, 0x1883800a } },
};
static const struct ath5k_ini rf2413_ini_common_end[] = {
{ AR5K_DCU_FP, 0x000003e0 },
{ AR5K_SEQ_MASK, 0x0000000f },
{ AR5K_MIC_QOS_CTL, 0x00000000 },
{ AR5K_MIC_QOS_SEL, 0x00000000 },
{ AR5K_MISC_MODE, 0x00000000 },
{ AR5K_OFDM_FIL_CNT, 0x00000000 },
{ AR5K_CCK_FIL_CNT, 0x00000000 },
{ AR5K_PHYERR_CNT1, 0x00000000 },
{ AR5K_PHYERR_CNT1_MASK, 0x00000000 },
{ AR5K_PHYERR_CNT2, 0x00000000 },
{ AR5K_PHYERR_CNT2_MASK, 0x00000000 },
{ AR5K_TSF_THRES, 0x00000000 },
{ 0x8140, 0x800000a8 },
{ 0x8144, 0x00000000 },
{ AR5K_PHY_AGC, 0x00000000 },
{ AR5K_PHY_ADC_CTL, 0x0000a000 },
{ 0x983c, 0x00200400 },
{ AR5K_PHY_GAIN_OFFSET, 0x1284233c },
{ AR5K_PHY_SCR, 0x0000001f },
{ AR5K_PHY_SLMT, 0x00000080 },
{ AR5K_PHY_SCAL, 0x0000000e },
{ 0x9958, 0x000000ff },
{ AR5K_PHY_TIMING_7, 0x00000000 },
{ AR5K_PHY_TIMING_8, 0x02800000 },
{ AR5K_PHY_TIMING_11, 0x00000000 },
{ AR5K_PHY_HEAVY_CLIP_ENABLE, 0x00000000 },
{ 0x99e4, 0xaaaaaaaa },
{ 0x99e8, 0x3c466478 },
{ 0x99ec, 0x000000aa },
{ AR5K_PHY_SCLOCK, 0x0000000c },
{ AR5K_PHY_SDELAY, 0x000000ff },
{ AR5K_PHY_SPENDING, 0x00000014 },
{ AR5K_PHY_DAG_CCK_CTL, 0x000009b5 },
{ 0xa23c, 0x93c889af },
{ AR5K_PHY_FAST_ADC, 0x00000001 },
{ 0xa250, 0x0000a000 },
{ AR5K_PHY_BLUETOOTH, 0x00000000 },
{ AR5K_PHY_TPC_RG1, 0x0cc75380 },
{ 0xa25c, 0x0f0f0f01 },
{ 0xa260, 0x5f690f01 },
{ 0xa264, 0x00418a11 },
{ 0xa268, 0x00000000 },
{ AR5K_PHY_TPC_RG5, 0x0c30c16a },
{ 0xa270, 0x00820820 },
{ 0xa274, 0x001b7caa },
{ 0xa278, 0x1ce739ce },
{ 0xa27c, 0x051701ce },
{ 0xa300, 0x18010000 },
{ 0xa304, 0x30032602 },
{ 0xa308, 0x48073e06 },
{ 0xa30c, 0x560b4c0a },
{ 0xa310, 0x641a600f },
{ 0xa314, 0x784f6e1b },
{ 0xa318, 0x868f7c5a },
{ 0xa31c, 0x8ecf865b },
{ 0xa320, 0x9d4f970f },
{ 0xa324, 0xa5cfa18f },
{ 0xa328, 0xb55faf1f },
{ 0xa32c, 0xbddfb99f },
{ 0xa330, 0xcd7fc73f },
{ 0xa334, 0xd5ffd1bf },
{ 0xa338, 0x00000000 },
{ 0xa33c, 0x00000000 },
{ 0xa340, 0x00000000 },
{ 0xa344, 0x00000000 },
{ 0xa348, 0x3fffffff },
{ 0xa34c, 0x3fffffff },
{ 0xa350, 0x3fffffff },
{ 0xa354, 0x0003ffff },
{ 0xa358, 0x79a8aa1f },
{ 0xa35c, 0x066c420f },
{ 0xa360, 0x0f282207 },
{ 0xa364, 0x17601685 },
{ 0xa368, 0x1f801104 },
{ 0xa36c, 0x37a00c03 },
{ 0xa370, 0x3fc40883 },
{ 0xa374, 0x57c00803 },
{ 0xa378, 0x5fd80682 },
{ 0xa37c, 0x7fe00482 },
{ 0xa380, 0x7f3c7bba },
{ 0xa384, 0xf3307ff0 },
};
/* Initial mode-specific settings for RF2425
* (Written after ar5212_ini) */
/* XXX: a mode ? */
static const struct ath5k_ini_mode rf2425_ini_mode_end[] = {
{ AR5K_TXCFG,
/* A/XR B G */
{ 0x00000015, 0x00000015, 0x00000015 } },
{ AR5K_USEC_5211,
{ 0x128d93a7, 0x04e01395, 0x12e013ab } },
{ AR5K_PHY_RF_CTL3,
{ 0x0a020001, 0x05020100, 0x0a020001 } },
{ AR5K_PHY_RF_CTL4,
{ 0x00000e0e, 0x00000e0e, 0x00000e0e } },
{ AR5K_PHY_PA_CTL,
{ 0x00000003, 0x0000000b, 0x0000000b } },
{ AR5K_PHY_SETTLING,
{ 0x1372161c, 0x13721722, 0x13721422 } },
{ AR5K_PHY_GAIN,
{ 0x0018fa61, 0x00199a65, 0x00199a65 } },
{ AR5K_PHY_DESIRED_SIZE,
{ 0x0c98b4e0, 0x0c98b0da, 0x0c98b0da } },
{ AR5K_PHY_SIG,
{ 0x7ec80d2e, 0x7ec80d2e, 0x7ec80d2e } },
{ AR5K_PHY_AGCCOARSE,
{ 0x3139605e, 0x3139605e, 0x3139605e } },
{ AR5K_PHY_WEAK_OFDM_LOW_THR,
{ 0x050cb081, 0x050cb081, 0x050cb081 } },
{ AR5K_PHY_RX_DELAY,
{ 0x000007d0, 0x0000044c, 0x00000898 } },
{ AR5K_PHY_FRAME_CTL_5211,
{ 0xf7b81000, 0xf7b80d00, 0xf7b81000 } },
{ AR5K_PHY_CCKTXCTL,
{ 0x00000000, 0x00000000, 0x00000000 } },
{ AR5K_PHY_CCK_CROSSCORR,
{ 0xd6be6788, 0xd03e6788, 0xd03e6788 } },
{ AR5K_PHY_GAIN_2GHZ,
{ 0x00000140, 0x0052c140, 0x0052c140 } },
{ AR5K_PHY_CCK_RX_CTL_4,
{ 0x1883800a, 0x1863800a, 0x1883800a } },
{ 0xa324,
{ 0xa7cfa7cf, 0xa7cfa7cf, 0xa7cfa7cf } },
{ 0xa328,
{ 0xa7cfa7cf, 0xa7cfa7cf, 0xa7cfa7cf } },
{ 0xa32c,
{ 0xa7cfa7cf, 0xa7cfa7cf, 0xa7cfa7cf } },
{ 0xa330,
{ 0xa7cfa7cf, 0xa7cfa7cf, 0xa7cfa7cf } },
{ 0xa334,
{ 0xa7cfa7cf, 0xa7cfa7cf, 0xa7cfa7cf } },
};
static const struct ath5k_ini rf2425_ini_common_end[] = {
{ AR5K_DCU_FP, 0x000003e0 },
{ AR5K_SEQ_MASK, 0x0000000f },
{ 0x809c, 0x00000000 },
{ 0x80a0, 0x00000000 },
{ AR5K_MIC_QOS_CTL, 0x00000000 },
{ AR5K_MIC_QOS_SEL, 0x00000000 },
{ AR5K_MISC_MODE, 0x00000000 },
{ AR5K_OFDM_FIL_CNT, 0x00000000 },
{ AR5K_CCK_FIL_CNT, 0x00000000 },
{ AR5K_PHYERR_CNT1, 0x00000000 },
{ AR5K_PHYERR_CNT1_MASK, 0x00000000 },
{ AR5K_PHYERR_CNT2, 0x00000000 },
{ AR5K_PHYERR_CNT2_MASK, 0x00000000 },
{ AR5K_TSF_THRES, 0x00000000 },
{ 0x8140, 0x800003f9 },
{ 0x8144, 0x00000000 },
{ AR5K_PHY_AGC, 0x00000000 },
{ AR5K_PHY_ADC_CTL, 0x0000a000 },
{ 0x983c, 0x00200400 },
{ AR5K_PHY_GAIN_OFFSET, 0x1284233c },
{ AR5K_PHY_SCR, 0x0000001f },
{ AR5K_PHY_SLMT, 0x00000080 },
{ AR5K_PHY_SCAL, 0x0000000e },
{ 0x9958, 0x00081fff },
{ AR5K_PHY_TIMING_7, 0x00000000 },
{ AR5K_PHY_TIMING_8, 0x02800000 },
{ AR5K_PHY_TIMING_11, 0x00000000 },
{ 0x99dc, 0xfebadbe8 },
{ AR5K_PHY_HEAVY_CLIP_ENABLE, 0x00000000 },
{ 0x99e4, 0xaaaaaaaa },
{ 0x99e8, 0x3c466478 },
{ 0x99ec, 0x000000aa },
{ AR5K_PHY_SCLOCK, 0x0000000c },
{ AR5K_PHY_SDELAY, 0x000000ff },
{ AR5K_PHY_SPENDING, 0x00000014 },
{ AR5K_PHY_DAG_CCK_CTL, 0x000009b5 },
{ AR5K_PHY_TXPOWER_RATE3, 0x20202020 },
{ AR5K_PHY_TXPOWER_RATE4, 0x20202020 },
{ 0xa23c, 0x93c889af },
{ AR5K_PHY_FAST_ADC, 0x00000001 },
{ 0xa250, 0x0000a000 },
{ AR5K_PHY_BLUETOOTH, 0x00000000 },
{ AR5K_PHY_TPC_RG1, 0x0cc75380 },
{ 0xa25c, 0x0f0f0f01 },
{ 0xa260, 0x5f690f01 },
{ 0xa264, 0x00418a11 },
{ 0xa268, 0x00000000 },
{ AR5K_PHY_TPC_RG5, 0x0c30c166 },
{ 0xa270, 0x00820820 },
{ 0xa274, 0x081a3caa },
{ 0xa278, 0x1ce739ce },
{ 0xa27c, 0x051701ce },
{ 0xa300, 0x16010000 },
{ 0xa304, 0x2c032402 },
{ 0xa308, 0x48433e42 },
{ 0xa30c, 0x5a0f500b },
{ 0xa310, 0x6c4b624a },
{ 0xa314, 0x7e8b748a },
{ 0xa318, 0x96cf8ccb },
{ 0xa31c, 0xa34f9d0f },
{ 0xa320, 0xa7cfa58f },
{ 0xa348, 0x3fffffff },
{ 0xa34c, 0x3fffffff },
{ 0xa350, 0x3fffffff },
{ 0xa354, 0x0003ffff },
{ 0xa358, 0x79a8aa1f },
{ 0xa35c, 0x066c420f },
{ 0xa360, 0x0f282207 },
{ 0xa364, 0x17601685 },
{ 0xa368, 0x1f801104 },
{ 0xa36c, 0x37a00c03 },
{ 0xa370, 0x3fc40883 },
{ 0xa374, 0x57c00803 },
{ 0xa378, 0x5fd80682 },
{ 0xa37c, 0x7fe00482 },
{ 0xa380, 0x7f3c7bba },
{ 0xa384, 0xf3307ff0 },
};
/*
* Initial BaseBand Gain settings for RF5111/5112 (AR5210 comes with
* RF5110 only so initial BB Gain settings are included in AR5K_AR5210_INI)
*/
/* RF5111 Initial BaseBand Gain settings */
static const struct ath5k_ini rf5111_ini_bbgain[] = {
{ AR5K_BB_GAIN(0), 0x00000000 },
{ AR5K_BB_GAIN(1), 0x00000020 },
{ AR5K_BB_GAIN(2), 0x00000010 },
{ AR5K_BB_GAIN(3), 0x00000030 },
{ AR5K_BB_GAIN(4), 0x00000008 },
{ AR5K_BB_GAIN(5), 0x00000028 },
{ AR5K_BB_GAIN(6), 0x00000004 },
{ AR5K_BB_GAIN(7), 0x00000024 },
{ AR5K_BB_GAIN(8), 0x00000014 },
{ AR5K_BB_GAIN(9), 0x00000034 },
{ AR5K_BB_GAIN(10), 0x0000000c },
{ AR5K_BB_GAIN(11), 0x0000002c },
{ AR5K_BB_GAIN(12), 0x00000002 },
{ AR5K_BB_GAIN(13), 0x00000022 },
{ AR5K_BB_GAIN(14), 0x00000012 },
{ AR5K_BB_GAIN(15), 0x00000032 },
{ AR5K_BB_GAIN(16), 0x0000000a },
{ AR5K_BB_GAIN(17), 0x0000002a },
{ AR5K_BB_GAIN(18), 0x00000006 },
{ AR5K_BB_GAIN(19), 0x00000026 },
{ AR5K_BB_GAIN(20), 0x00000016 },
{ AR5K_BB_GAIN(21), 0x00000036 },
{ AR5K_BB_GAIN(22), 0x0000000e },
{ AR5K_BB_GAIN(23), 0x0000002e },
{ AR5K_BB_GAIN(24), 0x00000001 },
{ AR5K_BB_GAIN(25), 0x00000021 },
{ AR5K_BB_GAIN(26), 0x00000011 },
{ AR5K_BB_GAIN(27), 0x00000031 },
{ AR5K_BB_GAIN(28), 0x00000009 },
{ AR5K_BB_GAIN(29), 0x00000029 },
{ AR5K_BB_GAIN(30), 0x00000005 },
{ AR5K_BB_GAIN(31), 0x00000025 },
{ AR5K_BB_GAIN(32), 0x00000015 },
{ AR5K_BB_GAIN(33), 0x00000035 },
{ AR5K_BB_GAIN(34), 0x0000000d },
{ AR5K_BB_GAIN(35), 0x0000002d },
{ AR5K_BB_GAIN(36), 0x00000003 },
{ AR5K_BB_GAIN(37), 0x00000023 },
{ AR5K_BB_GAIN(38), 0x00000013 },
{ AR5K_BB_GAIN(39), 0x00000033 },
{ AR5K_BB_GAIN(40), 0x0000000b },
{ AR5K_BB_GAIN(41), 0x0000002b },
{ AR5K_BB_GAIN(42), 0x0000002b },
{ AR5K_BB_GAIN(43), 0x0000002b },
{ AR5K_BB_GAIN(44), 0x0000002b },
{ AR5K_BB_GAIN(45), 0x0000002b },
{ AR5K_BB_GAIN(46), 0x0000002b },
{ AR5K_BB_GAIN(47), 0x0000002b },
{ AR5K_BB_GAIN(48), 0x0000002b },
{ AR5K_BB_GAIN(49), 0x0000002b },
{ AR5K_BB_GAIN(50), 0x0000002b },
{ AR5K_BB_GAIN(51), 0x0000002b },
{ AR5K_BB_GAIN(52), 0x0000002b },
{ AR5K_BB_GAIN(53), 0x0000002b },
{ AR5K_BB_GAIN(54), 0x0000002b },
{ AR5K_BB_GAIN(55), 0x0000002b },
{ AR5K_BB_GAIN(56), 0x0000002b },
{ AR5K_BB_GAIN(57), 0x0000002b },
{ AR5K_BB_GAIN(58), 0x0000002b },
{ AR5K_BB_GAIN(59), 0x0000002b },
{ AR5K_BB_GAIN(60), 0x0000002b },
{ AR5K_BB_GAIN(61), 0x0000002b },
{ AR5K_BB_GAIN(62), 0x00000002 },
{ AR5K_BB_GAIN(63), 0x00000016 },
};
/* RF5112 Initial BaseBand Gain settings (Same for RF5413/5414+) */
static const struct ath5k_ini rf5112_ini_bbgain[] = {
{ AR5K_BB_GAIN(0), 0x00000000 },
{ AR5K_BB_GAIN(1), 0x00000001 },
{ AR5K_BB_GAIN(2), 0x00000002 },
{ AR5K_BB_GAIN(3), 0x00000003 },
{ AR5K_BB_GAIN(4), 0x00000004 },
{ AR5K_BB_GAIN(5), 0x00000005 },
{ AR5K_BB_GAIN(6), 0x00000008 },
{ AR5K_BB_GAIN(7), 0x00000009 },
{ AR5K_BB_GAIN(8), 0x0000000a },
{ AR5K_BB_GAIN(9), 0x0000000b },
{ AR5K_BB_GAIN(10), 0x0000000c },
{ AR5K_BB_GAIN(11), 0x0000000d },
{ AR5K_BB_GAIN(12), 0x00000010 },
{ AR5K_BB_GAIN(13), 0x00000011 },
{ AR5K_BB_GAIN(14), 0x00000012 },
{ AR5K_BB_GAIN(15), 0x00000013 },
{ AR5K_BB_GAIN(16), 0x00000014 },
{ AR5K_BB_GAIN(17), 0x00000015 },
{ AR5K_BB_GAIN(18), 0x00000018 },
{ AR5K_BB_GAIN(19), 0x00000019 },
{ AR5K_BB_GAIN(20), 0x0000001a },
{ AR5K_BB_GAIN(21), 0x0000001b },
{ AR5K_BB_GAIN(22), 0x0000001c },
{ AR5K_BB_GAIN(23), 0x0000001d },
{ AR5K_BB_GAIN(24), 0x00000020 },
{ AR5K_BB_GAIN(25), 0x00000021 },
{ AR5K_BB_GAIN(26), 0x00000022 },
{ AR5K_BB_GAIN(27), 0x00000023 },
{ AR5K_BB_GAIN(28), 0x00000024 },
{ AR5K_BB_GAIN(29), 0x00000025 },
{ AR5K_BB_GAIN(30), 0x00000028 },
{ AR5K_BB_GAIN(31), 0x00000029 },
{ AR5K_BB_GAIN(32), 0x0000002a },
{ AR5K_BB_GAIN(33), 0x0000002b },
{ AR5K_BB_GAIN(34), 0x0000002c },
{ AR5K_BB_GAIN(35), 0x0000002d },
{ AR5K_BB_GAIN(36), 0x00000030 },
{ AR5K_BB_GAIN(37), 0x00000031 },
{ AR5K_BB_GAIN(38), 0x00000032 },
{ AR5K_BB_GAIN(39), 0x00000033 },
{ AR5K_BB_GAIN(40), 0x00000034 },
{ AR5K_BB_GAIN(41), 0x00000035 },
{ AR5K_BB_GAIN(42), 0x00000035 },
{ AR5K_BB_GAIN(43), 0x00000035 },
{ AR5K_BB_GAIN(44), 0x00000035 },
{ AR5K_BB_GAIN(45), 0x00000035 },
{ AR5K_BB_GAIN(46), 0x00000035 },
{ AR5K_BB_GAIN(47), 0x00000035 },
{ AR5K_BB_GAIN(48), 0x00000035 },
{ AR5K_BB_GAIN(49), 0x00000035 },
{ AR5K_BB_GAIN(50), 0x00000035 },
{ AR5K_BB_GAIN(51), 0x00000035 },
{ AR5K_BB_GAIN(52), 0x00000035 },
{ AR5K_BB_GAIN(53), 0x00000035 },
{ AR5K_BB_GAIN(54), 0x00000035 },
{ AR5K_BB_GAIN(55), 0x00000035 },
{ AR5K_BB_GAIN(56), 0x00000035 },
{ AR5K_BB_GAIN(57), 0x00000035 },
{ AR5K_BB_GAIN(58), 0x00000035 },
{ AR5K_BB_GAIN(59), 0x00000035 },
{ AR5K_BB_GAIN(60), 0x00000035 },
{ AR5K_BB_GAIN(61), 0x00000035 },
{ AR5K_BB_GAIN(62), 0x00000010 },
{ AR5K_BB_GAIN(63), 0x0000001a },
};
/**
* ath5k_hw_ini_registers() - Write initial register dump common for all modes
* @ah: The &struct ath5k_hw
* @size: Dump size
* @ini_regs: The array of &struct ath5k_ini
* @skip_pcu: Skip PCU registers
*/
static void
ath5k_hw_ini_registers(struct ath5k_hw *ah, unsigned int size,
const struct ath5k_ini *ini_regs, bool skip_pcu)
{
unsigned int i;
/* Write initial registers */
for (i = 0; i < size; i++) {
/* Skip PCU registers if
* requested */
if (skip_pcu &&
ini_regs[i].ini_register >= AR5K_PCU_MIN &&
ini_regs[i].ini_register <= AR5K_PCU_MAX)
continue;
switch (ini_regs[i].ini_mode) {
case AR5K_INI_READ:
/* Cleared on read */
ath5k_hw_reg_read(ah, ini_regs[i].ini_register);
break;
case AR5K_INI_WRITE:
default:
AR5K_REG_WAIT(i);
ath5k_hw_reg_write(ah, ini_regs[i].ini_value,
ini_regs[i].ini_register);
}
}
}
/**
* ath5k_hw_ini_mode_registers() - Write initial mode-specific register dump
* @ah: The &struct ath5k_hw
* @size: Dump size
* @ini_mode: The array of &struct ath5k_ini_mode
* @mode: One of enum ath5k_driver_mode
*/
static void
ath5k_hw_ini_mode_registers(struct ath5k_hw *ah,
unsigned int size, const struct ath5k_ini_mode *ini_mode,
u8 mode)
{
unsigned int i;
for (i = 0; i < size; i++) {
AR5K_REG_WAIT(i);
ath5k_hw_reg_write(ah, ini_mode[i].mode_value[mode],
(u32)ini_mode[i].mode_register);
}
}
/**
* ath5k_hw_write_initvals() - Write initial chip-specific register dump
* @ah: The &struct ath5k_hw
* @mode: One of enum ath5k_driver_mode
* @skip_pcu: Skip PCU registers
*
* Write initial chip-specific register dump, to get the chipset on a
* clean and ready-to-work state after warm reset.
*/
int
ath5k_hw_write_initvals(struct ath5k_hw *ah, u8 mode, bool skip_pcu)
{
/*
* Write initial register settings
*/
/* For AR5212 and compatible */
if (ah->ah_version == AR5K_AR5212) {
/* First set of mode-specific settings */
ath5k_hw_ini_mode_registers(ah,
ARRAY_SIZE(ar5212_ini_mode_start),
ar5212_ini_mode_start, mode);
/*
* Write initial settings common for all modes
*/
ath5k_hw_ini_registers(ah, ARRAY_SIZE(ar5212_ini_common_start),
ar5212_ini_common_start, skip_pcu);
/* Second set of mode-specific settings */
switch (ah->ah_radio) {
case AR5K_RF5111:
ath5k_hw_ini_mode_registers(ah,
ARRAY_SIZE(rf5111_ini_mode_end),
rf5111_ini_mode_end, mode);
ath5k_hw_ini_registers(ah,
ARRAY_SIZE(rf5111_ini_common_end),
rf5111_ini_common_end, skip_pcu);
/* Baseband gain table */
ath5k_hw_ini_registers(ah,
ARRAY_SIZE(rf5111_ini_bbgain),
rf5111_ini_bbgain, skip_pcu);
break;
case AR5K_RF5112:
ath5k_hw_ini_mode_registers(ah,
ARRAY_SIZE(rf5112_ini_mode_end),
rf5112_ini_mode_end, mode);
ath5k_hw_ini_registers(ah,
ARRAY_SIZE(rf5112_ini_common_end),
rf5112_ini_common_end, skip_pcu);
ath5k_hw_ini_registers(ah,
ARRAY_SIZE(rf5112_ini_bbgain),
rf5112_ini_bbgain, skip_pcu);
break;
case AR5K_RF5413:
ath5k_hw_ini_mode_registers(ah,
ARRAY_SIZE(rf5413_ini_mode_end),
rf5413_ini_mode_end, mode);
ath5k_hw_ini_registers(ah,
ARRAY_SIZE(rf5413_ini_common_end),
rf5413_ini_common_end, skip_pcu);
ath5k_hw_ini_registers(ah,
ARRAY_SIZE(rf5112_ini_bbgain),
rf5112_ini_bbgain, skip_pcu);
break;
case AR5K_RF2316:
case AR5K_RF2413:
ath5k_hw_ini_mode_registers(ah,
ARRAY_SIZE(rf2413_ini_mode_end),
rf2413_ini_mode_end, mode);
ath5k_hw_ini_registers(ah,
ARRAY_SIZE(rf2413_ini_common_end),
rf2413_ini_common_end, skip_pcu);
/* Override settings from rf2413_ini_common_end */
if (ah->ah_radio == AR5K_RF2316) {
ath5k_hw_reg_write(ah, 0x00004000,
AR5K_PHY_AGC);
ath5k_hw_reg_write(ah, 0x081b7caa,
0xa274);
}
ath5k_hw_ini_registers(ah,
ARRAY_SIZE(rf5112_ini_bbgain),
rf5112_ini_bbgain, skip_pcu);
break;
case AR5K_RF2317:
ath5k_hw_ini_mode_registers(ah,
ARRAY_SIZE(rf2413_ini_mode_end),
rf2413_ini_mode_end, mode);
ath5k_hw_ini_registers(ah,
ARRAY_SIZE(rf2425_ini_common_end),
rf2425_ini_common_end, skip_pcu);
/* Override settings from rf2413_ini_mode_end */
ath5k_hw_reg_write(ah, 0x00180a65, AR5K_PHY_GAIN);
/* Override settings from rf2413_ini_common_end */
ath5k_hw_reg_write(ah, 0x00004000, AR5K_PHY_AGC);
AR5K_REG_WRITE_BITS(ah, AR5K_PHY_TPC_RG5,
AR5K_PHY_TPC_RG5_PD_GAIN_OVERLAP, 0xa);
ath5k_hw_reg_write(ah, 0x800000a8, 0x8140);
ath5k_hw_reg_write(ah, 0x000000ff, 0x9958);
ath5k_hw_ini_registers(ah,
ARRAY_SIZE(rf5112_ini_bbgain),
rf5112_ini_bbgain, skip_pcu);
break;
case AR5K_RF2425:
ath5k_hw_ini_mode_registers(ah,
ARRAY_SIZE(rf2425_ini_mode_end),
rf2425_ini_mode_end, mode);
ath5k_hw_ini_registers(ah,
ARRAY_SIZE(rf2425_ini_common_end),
rf2425_ini_common_end, skip_pcu);
ath5k_hw_ini_registers(ah,
ARRAY_SIZE(rf5112_ini_bbgain),
rf5112_ini_bbgain, skip_pcu);
break;
default:
return -EINVAL;
}
/* For AR5211 */
} else if (ah->ah_version == AR5K_AR5211) {
/* AR5K_MODE_11B */
if (mode > 2) {
ATH5K_ERR(ah, "unsupported channel mode: %d\n", mode);
return -EINVAL;
}
/* Mode-specific settings */
ath5k_hw_ini_mode_registers(ah, ARRAY_SIZE(ar5211_ini_mode),
ar5211_ini_mode, mode);
/*
* Write initial settings common for all modes
*/
ath5k_hw_ini_registers(ah, ARRAY_SIZE(ar5211_ini),
ar5211_ini, skip_pcu);
/* AR5211 only comes with 5111 */
/* Baseband gain table */
ath5k_hw_ini_registers(ah, ARRAY_SIZE(rf5111_ini_bbgain),
rf5111_ini_bbgain, skip_pcu);
/* For AR5210 (for mode settings check out ath5k_hw_reset_tx_queue) */
} else if (ah->ah_version == AR5K_AR5210) {
ath5k_hw_ini_registers(ah, ARRAY_SIZE(ar5210_ini),
ar5210_ini, skip_pcu);
}
return 0;
}
|
86cf5eaad43a3f87c0607d14725257f303331f87
|
eb9f655206c43c12b497c667ba56a0d358b6bc3a
|
/native/WinFsNotifier/fileWatcher3.c
|
3c75741d4cc9cadbf9038a5c610241a8214571ea
|
[
"Apache-2.0"
] |
permissive
|
JetBrains/intellij-community
|
2ed226e200ecc17c037dcddd4a006de56cd43941
|
05dbd4575d01a213f3f4d69aa4968473f2536142
|
refs/heads/master
| 2023-09-03T17:06:37.560889
| 2023-09-03T11:51:00
| 2023-09-03T12:12:27
| 2,489,216
| 16,288
| 6,635
|
Apache-2.0
| 2023-09-12T07:41:58
| 2011-09-30T13:33:05
| null |
UTF-8
|
C
| false
| false
| 14,193
|
c
|
fileWatcher3.c
|
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
#include <ctype.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include <Windows.h>
typedef struct {
char rootPath[4];
HANDLE hThread;
HANDLE hStopEvent;
bool bInitialized;
bool bUsed;
bool bFailed;
} WatchDrive;
#define ROOT_COUNT ('Z'-'A'+1)
static WatchDrive watchDrive[ROOT_COUNT];
typedef struct WatchRoot {
char *path;
struct WatchRoot *next;
} WatchRoot;
static WatchRoot *firstWatchRoot = NULL;
static CRITICAL_SECTION csOutput;
#define EVENT_BUFFER_SIZE (16*1024)
#ifdef __PRINT_STATS
static UINT64 _total_ = 0, _post_ = 0;
static UINT32 _calls_ = 0, _max_events_ = 0;
#endif
// -- Utilities ---------------------------------------------------
#define IS_SET(flags, flag) (((flags) & (flag)) == (flag))
#define FILE_SHARE_ALL (FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE)
typedef DWORD (WINAPI *GetFinalPathNameByHandlePtr)(HANDLE, LPCWSTR, DWORD, DWORD);
static GetFinalPathNameByHandlePtr pGetFinalPathNameByHandle = NULL;
typedef struct {
char *text;
size_t size;
} PrintBuffer;
static void AppendString(PrintBuffer *buffer, const char *str) {
if (buffer->text == NULL || strlen(buffer->text) + strlen(str) + 1 > buffer->size) {
size_t newSize = buffer->size + max(4096, strlen(str));
char *newData = (char *)malloc(newSize);
if (buffer->text != NULL) {
strcpy_s(newData, newSize, buffer->text);
free(buffer->text);
} else {
newData[0] = '\0';
}
buffer->text = newData;
buffer->size = newSize;
}
strcat_s(buffer->text, buffer->size, str);
}
// -- Volume operations ---------------------------------------------------
static bool IsDriveWatchable(const char *rootPath) {
UINT type = GetDriveTypeA(rootPath);
if (type == DRIVE_REMOVABLE || type == DRIVE_FIXED || type == DRIVE_RAMDISK) {
char fsName[MAX_PATH + 1];
if (GetVolumeInformationA(rootPath, NULL, 0, NULL, NULL, NULL, fsName, sizeof(fsName))) {
return strcmp(fsName, "NTFS") == 0 ||
strcmp(fsName, "FAT") == 0 ||
strcmp(fsName, "FAT32") == 0 ||
_stricmp(fsName, "exFAT") == 0 ||
_stricmp(fsName, "reFS") == 0;
}
}
return false;
}
static bool IsPathWatchable(const char *pathToWatch) {
bool watchable = true;
int pathLen = MultiByteToWideChar(CP_UTF8, 0, pathToWatch, -1, NULL, 0);
wchar_t *path = (wchar_t *)calloc((size_t)pathLen + 1, sizeof(wchar_t));
MultiByteToWideChar(CP_UTF8, 0, pathToWatch, -1, path, pathLen);
wchar_t buffer[1024];
const unsigned int bufferSize = 1024;
wchar_t *pSlash;
while ((pSlash = wcsrchr(path, L'\\')) != NULL) {
DWORD attributes = GetFileAttributesW(path);
if (attributes != INVALID_FILE_ATTRIBUTES && IS_SET(attributes, FILE_ATTRIBUTE_REPARSE_POINT)) {
if (pGetFinalPathNameByHandle != NULL) {
HANDLE h = CreateFileW(path, 0, FILE_SHARE_ALL, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
if (h != INVALID_HANDLE_VALUE) {
DWORD result = pGetFinalPathNameByHandle(h, buffer, bufferSize, 0);
CloseHandle(h);
if (result > 0 && result < bufferSize && wcsncmp(buffer, L"\\\\?\\UNC\\", 8) == 0) {
watchable = false;
break;
}
}
}
path[pathLen - 1] = L'\\';
path[pathLen] = L'\0';
if (GetVolumeNameForVolumeMountPointW(path, buffer, bufferSize) != 0) {
watchable = false;
break;
}
}
*pSlash = L'\0';
pathLen = (int)(pSlash - path);
}
free(path);
return watchable;
}
static void PrintUnwatchableDrives(PrintBuffer *buffer, UINT32 unwatchable) {
for (int i = 0; i < ROOT_COUNT; i++) {
if (IS_SET(unwatchable, 1 << i)) {
AppendString(buffer, watchDrive[i].rootPath);
AppendString(buffer, "\n");
}
}
}
static void PrintUnwatchablePaths(PrintBuffer *buffer, UINT32 unwatchable) {
for (WatchRoot *root = firstWatchRoot; root; root = root->next) {
const char *path = root->path;
int drive = toupper(*path);
if (drive < 'A' || drive > 'Z' ||
(!IS_SET(unwatchable, 1 << (drive - 'A')) && !IsPathWatchable(path))) {
AppendString(buffer, path);
AppendString(buffer, "\n");
}
}
}
static void PrintRemapForSubstDrives(PrintBuffer *buffer) {
wchar_t targetPath[MAX_PATH];
char targetPathUtf[4 * MAX_PATH];
for (int i = 0; i < ROOT_COUNT; i++) {
if (watchDrive[i].bUsed) {
wchar_t device[3] = {btowc(watchDrive[i].rootPath[0]), L':', L'\0'};
DWORD res = QueryDosDeviceW(device, targetPath, sizeof(targetPath) / sizeof(wchar_t));
if (res > 4 && targetPath[0] == L'\\' && targetPath[1] == L'?' && targetPath[2] == L'?' && targetPath[3] == L'\\') {
WideCharToMultiByte(CP_UTF8, 0, targetPath + 4, -1, targetPathUtf, sizeof(targetPathUtf), NULL, NULL);
AppendString(buffer, watchDrive[i].rootPath);
AppendString(buffer, "\n");
AppendString(buffer, targetPathUtf);
AppendString(buffer, "\n");
}
}
}
}
// -- Watcher thread ----------------------------------------------------------
static void PrintChangeInfo(const char *rootPath, FILE_NOTIFY_INFORMATION *info) {
const char *event;
if (info->Action == FILE_ACTION_ADDED || info->Action == FILE_ACTION_RENAMED_NEW_NAME) {
event = "CREATE";
} else if (info->Action == FILE_ACTION_REMOVED || info->Action == FILE_ACTION_RENAMED_OLD_NAME) {
event = "DELETE";
} else if (info->Action == FILE_ACTION_MODIFIED) {
event = "CHANGE";
} else {
return; // unknown event
}
char utfBuffer[4 * MAX_PATH + 1];
int wcsLen = (int)(info->FileNameLength / sizeof(wchar_t));
int converted = WideCharToMultiByte(CP_UTF8, 0, info->FileName, wcsLen, utfBuffer, sizeof(utfBuffer), NULL, NULL);
utfBuffer[converted] = '\0';
EnterCriticalSection(&csOutput);
puts(event);
printf(rootPath);
puts(utfBuffer);
fflush(stdout);
LeaveCriticalSection(&csOutput);
}
static void PrintEverythingChangedUnderRoot(const char *rootPath) {
EnterCriticalSection(&csOutput);
puts("RECDIRTY");
puts(rootPath);
fflush(stdout);
LeaveCriticalSection(&csOutput);
}
#define CREATE_SHARE (FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE)
#define CREATE_FLAGS (FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED)
#define EVENT_MASK (FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME | \
FILE_NOTIFY_CHANGE_ATTRIBUTES | FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_LAST_WRITE)
static DWORD WINAPI WatcherThread(void *param) {
#ifdef __PRINT_STATS
LARGE_INTEGER t1, t2, t3;
UINT32 nEvents = 0;
#endif
WatchDrive *drive = (WatchDrive *)param;
OVERLAPPED overlapped;
memset(&overlapped, 0, sizeof(overlapped));
overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
const char *rootPath = drive->rootPath;
HANDLE hRootDir = CreateFileA(rootPath, GENERIC_READ, CREATE_SHARE, NULL, OPEN_EXISTING, CREATE_FLAGS, NULL);
char buffer[EVENT_BUFFER_SIZE];
HANDLE handles[2] = {drive->hStopEvent, overlapped.hEvent};
while (true) {
int rcDir = ReadDirectoryChangesW(hRootDir, buffer, sizeof(buffer), TRUE, EVENT_MASK, NULL, &overlapped, NULL);
if (rcDir == 0) {
drive->bFailed = true;
break;
}
DWORD rc = WaitForMultipleObjects(2, handles, FALSE, INFINITE);
if (rc == WAIT_OBJECT_0) {
break;
}
if (rc == WAIT_OBJECT_0 + 1) {
#ifdef __PRINT_STATS
QueryPerformanceCounter(&t1);
#endif
DWORD dwBytesReturned;
if (!GetOverlappedResult(hRootDir, &overlapped, &dwBytesReturned, FALSE)) {
drive->bFailed = true;
break;
}
#ifdef __PRINT_STATS
QueryPerformanceCounter(&t2);
#endif
if (dwBytesReturned == 0) {
// don't send dirty too much, everything is changed anyway
if (WaitForSingleObject(drive->hStopEvent, 500) == WAIT_OBJECT_0)
break;
// Got a buffer overflow => current changes lost => send RECDIRTY on root
PrintEverythingChangedUnderRoot(rootPath);
} else {
FILE_NOTIFY_INFORMATION *info = (FILE_NOTIFY_INFORMATION *)buffer;
bool hasNext = false;
do {
PrintChangeInfo(rootPath, info);
hasNext = (info->NextEntryOffset != 0);
info = (FILE_NOTIFY_INFORMATION *)((char *)info + info->NextEntryOffset);
#ifdef __PRINT_STATS
nEvents++;
#endif
} while (hasNext);
}
#ifdef __PRINT_STATS
QueryPerformanceCounter(&t3);
_post_ += t2.QuadPart - t1.QuadPart;
_total_ += t3.QuadPart - t1.QuadPart;
_calls_++;
_max_events_ = max(_max_events_, nEvents);
#endif
}
}
CloseHandle(overlapped.hEvent);
CloseHandle(hRootDir);
return 0;
}
// -- Roots update ------------------------------------------------------------
static void MarkAllRootsUnused() {
for (int i = 0; i < ROOT_COUNT; i++) {
watchDrive[i].bUsed = false;
}
}
static void StartRoot(WatchDrive *drive) {
drive->hStopEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
drive->hThread = CreateThread(NULL, 0, &WatcherThread, drive, 0, NULL);
SetThreadPriority(drive->hThread, THREAD_PRIORITY_ABOVE_NORMAL);
drive->bInitialized = true;
}
static void StopRoot(WatchDrive *drive) {
SetEvent(drive->hStopEvent);
WaitForSingleObject(drive->hThread, INFINITE);
CloseHandle(drive->hThread);
CloseHandle(drive->hStopEvent);
drive->bInitialized = false;
}
static void UpdateRoots(bool report) {
UINT32 unwatchable = 0;
for (int i = 0; i < ROOT_COUNT; i++) {
if (watchDrive[i].bInitialized && (!watchDrive[i].bUsed || watchDrive[i].bFailed)) {
StopRoot(&watchDrive[i]);
watchDrive[i].bFailed = false;
}
if (watchDrive[i].bUsed) {
if (!IsDriveWatchable(watchDrive[i].rootPath)) {
unwatchable |= (1 << i);
watchDrive[i].bUsed = false;
continue;
}
if (!watchDrive[i].bInitialized) {
StartRoot(&watchDrive[i]);
}
}
}
if (!report) {
return;
}
PrintBuffer buffer = {NULL, 0};
AppendString(&buffer, "UNWATCHEABLE\n");
PrintUnwatchableDrives(&buffer, unwatchable);
PrintUnwatchablePaths(&buffer, unwatchable);
AppendString(&buffer, "#\nREMAP\n");
PrintRemapForSubstDrives(&buffer);
AppendString(&buffer, "#");
EnterCriticalSection(&csOutput);
puts(buffer.text);
fflush(stdout);
LeaveCriticalSection(&csOutput);
free(buffer.text);
}
static void AddWatchRoot(const char *path) {
WatchRoot *root = (WatchRoot *)malloc(sizeof(WatchRoot));
root->next = NULL;
root->path = _strdup(path);
root->next = firstWatchRoot;
firstWatchRoot = root;
}
static void FreeWatchRootsList() {
WatchRoot *root = firstWatchRoot, *next;
while (root) {
next = root->next;
free(root->path);
free(root);
root = next;
}
firstWatchRoot = NULL;
}
// -- Main - file watcher protocol ---------------------------------------------
int main(int argc, char *argv[]) {
SetErrorMode(SEM_FAILCRITICALERRORS);
pGetFinalPathNameByHandle = (GetFinalPathNameByHandlePtr)GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "GetFinalPathNameByHandleW");
InitializeCriticalSection(&csOutput);
for (int i = 0; i < ROOT_COUNT; i++) {
char rootPath[4] = {(char)('A' + i), ':', '\\', '\0'};
strcpy_s(watchDrive[i].rootPath, 4, rootPath);
watchDrive[i].bInitialized = false;
watchDrive[i].bUsed = false;
}
char buffer[8192];
while (true) {
if (!gets_s(buffer, sizeof(buffer) - 1) || strcmp(buffer, "EXIT") == 0) {
break;
}
if (strcmp(buffer, "ROOTS") == 0) {
MarkAllRootsUnused();
FreeWatchRootsList();
bool failed = false;
while (true) {
if (!gets_s(buffer, sizeof(buffer) - 1)) {
failed = true;
break;
}
if (strlen(buffer) == 0) {
continue;
}
if (buffer[0] == '#') {
break;
}
char *root = buffer;
if (*root == '|') root++;
AddWatchRoot(root);
int driveLetter = toupper(*root);
if (driveLetter >= 'A' && driveLetter <= 'Z') {
watchDrive[driveLetter - 'A'].bUsed = true;
}
}
if (failed) {
break;
}
UpdateRoots(true);
}
}
MarkAllRootsUnused();
UpdateRoots(false);
DeleteCriticalSection(&csOutput);
#ifdef __PRINT_STATS
if (_calls_ > 0) {
LARGE_INTEGER fcy;
QueryPerformanceFrequency(&fcy);
_total_ = _total_ * 1000000 / fcy.QuadPart;
_post_ = _post_ * 1000000 / fcy.QuadPart;
fprintf(stderr, "!! TOTAL=%llu(%d) POST=%llu(%d) MAX.EVENTS=%u\n",
_total_, (int) (_total_ / _calls_),
_post_, (int) (_post_ / _calls_),
_max_events_);
}
#endif
return 0;
}
|
7c8b90ee8e7f05e2a6f9245fd90cefa8a5ce5e7d
|
5ff4b6986e6799bc0e143e060bafc14369030d8b
|
/toolchain/riscv-isa-sim/riscv/insns/p_extbs.h
|
de3e100e89988fbb7268d1b48872f407bdde08bb
|
[
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"GPL-1.0-or-later",
"LLVM-exception",
"Apache-2.0",
"BSD-3-Clause",
"LicenseRef-scancode-bsd-3-clause-jtag",
"GPL-3.0-or-later"
] |
permissive
|
pulp-platform/mempool
|
7583204b2436cfc12ed95599463e51ad4df51557
|
c98fb3ada4f255623eaf9b09861f397a60c3d96b
|
refs/heads/main
| 2023-08-08T09:07:56.696580
| 2023-07-27T17:24:38
| 2023-07-27T17:24:38
| 223,218,149
| 178
| 28
|
Apache-2.0
| 2023-07-27T17:24:39
| 2019-11-21T16:34:37
|
C
|
UTF-8
|
C
| false
| false
| 22
|
h
|
p_extbs.h
|
WRITE_RD(sext8(RS1));
|
52ac0a70e1d04a303168a3352d0c2c5d4d7daea3
|
67305fcba68fdf469862aed2959ad1dd5b22a536
|
/rt-thread/components/libc/compilers/common/gmtime_r.c
|
dff251ab6cafe9939c3098dd5de84370d6f1a65e
|
[
"Apache-2.0",
"LicenseRef-scancode-generic-cla"
] |
permissive
|
RT-Thread/IoT_Board
|
cdabf100a8d515fbcaa65ab0b72ec67acb0d2c9a
|
2d218a4e06f06dbb356ec00767904f91d00db7cc
|
refs/heads/master
| 2023-09-04T16:51:34.485240
| 2022-01-19T01:26:16
| 2022-01-19T01:26:16
| 161,133,933
| 344
| 238
|
Apache-2.0
| 2023-06-06T04:10:57
| 2018-12-10T07:21:46
|
C
|
UTF-8
|
C
| false
| false
| 2,170
|
c
|
gmtime_r.c
|
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-10-26 zylx first version
*/
#if defined(__CC_ARM) || defined(__CLANG_ARM) || defined (__IAR_SYSTEMS_ICC__)
#include <sys/time.h>
/* seconds per day */
#define SPD 24*60*60
/* days per month -- nonleap! */
const short __spm[13] =
{
0,
(31),
(31 + 28),
(31 + 28 + 31),
(31 + 28 + 31 + 30),
(31 + 28 + 31 + 30 + 31),
(31 + 28 + 31 + 30 + 31 + 30),
(31 + 28 + 31 + 30 + 31 + 30 + 31),
(31 + 28 + 31 + 30 + 31 + 30 + 31 + 31),
(31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30),
(31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31),
(31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30),
(31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31),
};
int __isleap(int year)
{
/* every fourth year is a leap year except for century years that are
* not divisible by 400. */
/* return (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); */
return (!(year % 4) && ((year % 100) || !(year % 400)));
}
/**
* This function will convert Time (Restartable)
*
* @param timep the timestamp
* @param the structure to stores information
*
* @return the structure to stores information
*
*/
struct tm *gmtime_r(const time_t *timep, struct tm *r)
{
time_t i;
register time_t work = *timep % (SPD);
r->tm_sec = work % 60;
work /= 60;
r->tm_min = work % 60;
r->tm_hour = work / 60;
work = *timep / (SPD);
r->tm_wday = (4 + work) % 7;
for (i = 1970;; ++i)
{
register time_t k = __isleap(i) ? 366 : 365;
if (work >= k)
work -= k;
else
break;
}
r->tm_year = i - 1900;
r->tm_yday = work;
r->tm_mday = 1;
if (__isleap(i) && (work > 58))
{
if (work == 59)
r->tm_mday = 2; /* 29.2. */
work -= 1;
}
for (i = 11; i && (__spm[i] > work); --i)
;
r->tm_mon = i;
r->tm_mday += work - __spm[i];
return r;
}
#endif /* end of __CC_ARM or __CLANG_ARM or __IAR_SYSTEMS_ICC__ */
|
86505c3d9fec01a59fb4377d7b3f53832871985d
|
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
|
/sys/arch/alpha/alpha/disksubr.c
|
0250821962e5214866884fb421e48ce4ea2ca33e
|
[] |
no_license
|
NetBSD/src
|
1a9cbc22ed778be638b37869ed4fb5c8dd616166
|
23ee83f7c0aea0777bd89d8ebd7f0cde9880d13c
|
refs/heads/trunk
| 2023-08-31T13:24:58.105962
| 2023-08-27T15:50:47
| 2023-08-27T15:50:47
| 88,439,547
| 656
| 348
| null | 2023-07-20T20:07:24
| 2017-04-16T20:03:43
| null |
UTF-8
|
C
| false
| false
| 5,132
|
c
|
disksubr.c
|
/* $NetBSD: disksubr.c,v 1.42 2019/04/03 22:10:49 christos Exp $ */
/*
* Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
* All rights reserved.
*
* Authors: Keith Bostic, Chris G. Demetriou
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.42 2019/04/03 22:10:49 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/buf.h>
#include <sys/ioccom.h>
#include <sys/device.h>
#include <sys/disklabel.h>
#include <sys/disk.h>
#include <machine/cpu.h>
#include <machine/autoconf.h>
extern device_t bootdv;
/*
* Attempt to read a disk label from a device
* using the indicated strategy routine.
* The label must be partly set up before this:
* secpercyl and anything required in the strategy routine
* (e.g., sector size) must be filled in before calling us.
* Returns null on success and an error string on failure.
*/
const char *
readdisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, struct cpu_disklabel *clp)
{
struct buf *bp;
struct disklabel *dlp;
struct dkbad *bdp;
const char *msg = NULL;
int i;
/* minimal requirements for archtypal disk label */
if (lp->d_secsize == 0)
lp->d_secsize = DEV_BSIZE;
if (lp->d_secperunit == 0)
lp->d_secperunit = 0x1fffffff;
lp->d_npartitions = RAW_PART + 1;
if (lp->d_partitions[RAW_PART].p_size == 0)
lp->d_partitions[RAW_PART].p_size = lp->d_secperunit;
lp->d_partitions[RAW_PART].p_offset = 0;
/* obtain buffer to probe drive with */
bp = geteblk((int)lp->d_secsize);
/* next, dig out disk label */
bp->b_dev = dev;
bp->b_blkno = LABELSECTOR;
bp->b_cylinder = 0;
bp->b_bcount = lp->d_secsize;
bp->b_flags |= B_READ;
(*strat)(bp);
/* if successful, locate disk label within block and validate */
if (biowait(bp)) {
msg = "disk label read error";
goto done;
}
dlp = (struct disklabel *)((char *)bp->b_data + LABELOFFSET);
if (dlp->d_magic == DISKMAGIC) {
if (dkcksum(dlp))
msg = "NetBSD disk label corrupted";
else
*lp = *dlp;
} else
msg = "no disk label";
if (msg)
goto done;
/* obtain bad sector table if requested and present */
if (clp && (bdp = &clp->bad) != NULL && (lp->d_flags & D_BADSECT)) {
struct dkbad *db;
i = 0;
do {
/* read a bad sector table */
bp->b_oflags &= ~BO_DONE;
bp->b_flags |= B_READ;
bp->b_blkno = lp->d_secperunit - lp->d_nsectors + i;
if (lp->d_secsize > DEV_BSIZE)
bp->b_blkno *= lp->d_secsize / DEV_BSIZE;
else
bp->b_blkno /= DEV_BSIZE / lp->d_secsize;
bp->b_bcount = lp->d_secsize;
bp->b_cylinder = lp->d_ncylinders - 1;
(*strat)(bp);
/* if successful, validate, otherwise try another */
if (biowait(bp)) {
msg = "bad sector table I/O error";
} else {
db = (struct dkbad *)(bp->b_data);
#define DKBAD_MAGIC 0x4321
if (db->bt_mbz == 0
&& db->bt_flag == DKBAD_MAGIC) {
msg = NULL;
*bdp = *db;
break;
} else
msg = "bad sector table corrupted";
}
} while (bp->b_error != 0 && (i += 2) < 10 &&
i < lp->d_nsectors);
}
done:
brelse(bp, 0);
return (msg);
}
/*
* Write disk label back to device after modification.
* This means write out the rigid disk blocks to represent the
* label. Hope the user was careful.
*/
int
writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, struct cpu_disklabel *clp)
{
struct buf *bp;
struct disklabel *dlp;
int error = 0;
bp = geteblk((int)lp->d_secsize);
bp->b_dev = dev;
bp->b_blkno = LABELSECTOR;
bp->b_cylinder = 0;
bp->b_bcount = lp->d_secsize;
bp->b_flags |= B_READ; /* get current label */
(*strat)(bp);
if ((error = biowait(bp)) != 0)
goto done;
dlp = (struct disklabel *)((char *)bp->b_data + LABELOFFSET);
*dlp = *lp; /* struct assignment */
/*
* The Alpha requires that the boot block be checksummed.
* The first 63 8-bit quantites are summed into the 64th.
*/
{
int i;
u_long *dp, sum;
dp = (u_long *)bp->b_data;
sum = 0;
for (i = 0; i < 63; i++)
sum += dp[i];
dp[63] = sum;
}
bp->b_flags &= ~B_READ;
bp->b_flags |= B_WRITE;
bp->b_oflags &= ~BO_DONE;
(*strat)(bp);
error = biowait(bp);
done:
brelse(bp, 0);
return (error);
}
|
8cfe20850c5ceca7ad8c5d2353a99738187d7aa0
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/u-boot_new/board/atmel/sama5d3xek/sama5d3xek.c
|
c835c12d02d623777ab756c384bf8b948f6a7711
|
[
"GPL-2.0-or-later",
"LicenseRef-scancode-free-unknown",
"Apache-2.0"
] |
permissive
|
OLIMEX/DIY-LAPTOP
|
ae82f4ee79c641d9aee444db9a75f3f6709afa92
|
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
|
refs/heads/rel3
| 2023-08-04T01:54:19.483792
| 2023-04-03T07:18:12
| 2023-04-03T07:18:12
| 80,094,055
| 507
| 92
|
Apache-2.0
| 2023-04-03T07:05:59
| 2017-01-26T07:25:50
|
C
|
UTF-8
|
C
| false
| false
| 9,186
|
c
|
sama5d3xek.c
|
/*
* Copyright (C) 2012 - 2013 Atmel Corporation
* Bo Shen <voice.shen@atmel.com>
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
#include <mmc.h>
#include <asm/io.h>
#include <asm/arch/sama5d3_smc.h>
#include <asm/arch/at91_common.h>
#include <asm/arch/at91_pmc.h>
#include <asm/arch/at91_rstc.h>
#include <asm/arch/gpio.h>
#include <asm/arch/clk.h>
#include <lcd.h>
#include <atmel_lcdc.h>
#include <atmel_mci.h>
#include <micrel.h>
#include <net.h>
#include <netdev.h>
#include <spl.h>
#include <asm/arch/atmel_mpddrc.h>
#include <asm/arch/at91_wdt.h>
#ifdef CONFIG_USB_GADGET_ATMEL_USBA
#include <asm/arch/atmel_usba_udc.h>
#endif
DECLARE_GLOBAL_DATA_PTR;
/* ------------------------------------------------------------------------- */
/*
* Miscelaneous platform dependent initialisations
*/
#ifdef CONFIG_NAND_ATMEL
void sama5d3xek_nand_hw_init(void)
{
struct at91_smc *smc = (struct at91_smc *)ATMEL_BASE_SMC;
at91_periph_clk_enable(ATMEL_ID_SMC);
/* Configure SMC CS3 for NAND/SmartMedia */
writel(AT91_SMC_SETUP_NWE(2) | AT91_SMC_SETUP_NCS_WR(1) |
AT91_SMC_SETUP_NRD(2) | AT91_SMC_SETUP_NCS_RD(1),
&smc->cs[3].setup);
writel(AT91_SMC_PULSE_NWE(3) | AT91_SMC_PULSE_NCS_WR(5) |
AT91_SMC_PULSE_NRD(3) | AT91_SMC_PULSE_NCS_RD(5),
&smc->cs[3].pulse);
writel(AT91_SMC_CYCLE_NWE(8) | AT91_SMC_CYCLE_NRD(8),
&smc->cs[3].cycle);
writel(AT91_SMC_TIMINGS_TCLR(3) | AT91_SMC_TIMINGS_TADL(10) |
AT91_SMC_TIMINGS_TAR(3) | AT91_SMC_TIMINGS_TRR(4) |
AT91_SMC_TIMINGS_TWB(5) | AT91_SMC_TIMINGS_RBNSEL(3)|
AT91_SMC_TIMINGS_NFSEL(1), &smc->cs[3].timings);
writel(AT91_SMC_MODE_RM_NRD | AT91_SMC_MODE_WM_NWE |
AT91_SMC_MODE_EXNW_DISABLE |
#ifdef CONFIG_SYS_NAND_DBW_16
AT91_SMC_MODE_DBW_16 |
#else /* CONFIG_SYS_NAND_DBW_8 */
AT91_SMC_MODE_DBW_8 |
#endif
AT91_SMC_MODE_TDF_CYCLE(3),
&smc->cs[3].mode);
}
#endif
#ifdef CONFIG_CMD_USB
static void sama5d3xek_usb_hw_init(void)
{
at91_set_pio_output(AT91_PIO_PORTD, 25, 0);
at91_set_pio_output(AT91_PIO_PORTD, 26, 0);
at91_set_pio_output(AT91_PIO_PORTD, 27, 0);
}
#endif
#ifdef CONFIG_GENERIC_ATMEL_MCI
static void sama5d3xek_mci_hw_init(void)
{
at91_mci_hw_init();
at91_set_pio_output(AT91_PIO_PORTB, 10, 0); /* MCI0 Power */
}
#endif
#ifdef CONFIG_LCD
vidinfo_t panel_info = {
.vl_col = 800,
.vl_row = 480,
.vl_clk = 24000000,
.vl_sync = ATMEL_LCDC_INVLINE_NORMAL | ATMEL_LCDC_INVFRAME_NORMAL,
.vl_bpix = LCD_BPP,
.vl_tft = 1,
.vl_hsync_len = 128,
.vl_left_margin = 64,
.vl_right_margin = 64,
.vl_vsync_len = 2,
.vl_upper_margin = 22,
.vl_lower_margin = 21,
.mmio = ATMEL_BASE_LCDC,
};
void lcd_enable(void)
{
}
void lcd_disable(void)
{
}
static void sama5d3xek_lcd_hw_init(void)
{
gd->fb_base = CONFIG_SAMA5D3_LCD_BASE;
/* The higher 8 bit of LCD is board related */
at91_set_c_periph(AT91_PIO_PORTC, 14, 0); /* LCDD16 */
at91_set_c_periph(AT91_PIO_PORTC, 13, 0); /* LCDD17 */
at91_set_c_periph(AT91_PIO_PORTC, 12, 0); /* LCDD18 */
at91_set_c_periph(AT91_PIO_PORTC, 11, 0); /* LCDD19 */
at91_set_c_periph(AT91_PIO_PORTC, 10, 0); /* LCDD20 */
at91_set_c_periph(AT91_PIO_PORTC, 15, 0); /* LCDD21 */
at91_set_c_periph(AT91_PIO_PORTE, 27, 0); /* LCDD22 */
at91_set_c_periph(AT91_PIO_PORTE, 28, 0); /* LCDD23 */
/* Configure lower 16 bit of LCD and enable clock */
at91_lcd_hw_init();
}
#ifdef CONFIG_LCD_INFO
#include <nand.h>
#include <version.h>
void lcd_show_board_info(void)
{
ulong dram_size;
uint64_t nand_size;
int i;
char temp[32];
lcd_printf("%s\n", U_BOOT_VERSION);
lcd_printf("(C) 2013 ATMEL Corp\n");
lcd_printf("at91@atmel.com\n");
lcd_printf("%s CPU at %s MHz\n", get_cpu_name(),
strmhz(temp, get_cpu_clk_rate()));
dram_size = 0;
for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++)
dram_size += gd->bd->bi_dram[i].size;
nand_size = 0;
#ifdef CONFIG_NAND_ATMEL
for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++)
nand_size += nand_info[i].size;
#endif
lcd_printf("%ld MB SDRAM, %lld MB NAND\n",
dram_size >> 20, nand_size >> 20);
}
#endif /* CONFIG_LCD_INFO */
#endif /* CONFIG_LCD */
int board_early_init_f(void)
{
at91_periph_clk_enable(ATMEL_ID_PIOA);
at91_periph_clk_enable(ATMEL_ID_PIOB);
at91_periph_clk_enable(ATMEL_ID_PIOC);
at91_periph_clk_enable(ATMEL_ID_PIOD);
at91_periph_clk_enable(ATMEL_ID_PIOE);
at91_seriald_hw_init();
return 0;
}
int board_init(void)
{
/* adress of boot parameters */
gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
#ifdef CONFIG_NAND_ATMEL
sama5d3xek_nand_hw_init();
#endif
#ifdef CONFIG_CMD_USB
sama5d3xek_usb_hw_init();
#endif
#ifdef CONFIG_USB_GADGET_ATMEL_USBA
at91_udp_hw_init();
#endif
#ifdef CONFIG_GENERIC_ATMEL_MCI
sama5d3xek_mci_hw_init();
#endif
#ifdef CONFIG_ATMEL_SPI
at91_spi0_hw_init(1 << 0);
#endif
#ifdef CONFIG_MACB
if (has_emac())
at91_macb_hw_init();
if (has_gmac())
at91_gmac_hw_init();
#endif
#ifdef CONFIG_LCD
if (has_lcdc())
sama5d3xek_lcd_hw_init();
#endif
return 0;
}
int dram_init(void)
{
gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
CONFIG_SYS_SDRAM_SIZE);
return 0;
}
int board_phy_config(struct phy_device *phydev)
{
/* rx data delay */
ksz9021_phy_extended_write(phydev,
MII_KSZ9021_EXT_RGMII_RX_DATA_SKEW, 0x2222);
/* tx data delay */
ksz9021_phy_extended_write(phydev,
MII_KSZ9021_EXT_RGMII_TX_DATA_SKEW, 0x2222);
/* rx/tx clock delay */
ksz9021_phy_extended_write(phydev,
MII_KSZ9021_EXT_RGMII_CLOCK_SKEW, 0xf2f4);
return 0;
}
int board_eth_init(bd_t *bis)
{
int rc = 0;
#ifdef CONFIG_MACB
if (has_emac())
rc = macb_eth_initialize(0, (void *)ATMEL_BASE_EMAC, 0x00);
if (has_gmac())
rc = macb_eth_initialize(0, (void *)ATMEL_BASE_GMAC, 0x00);
#endif
#ifdef CONFIG_USB_GADGET_ATMEL_USBA
usba_udc_probe(&pdata);
#ifdef CONFIG_USB_ETH_RNDIS
usb_eth_initialize(bis);
#endif
#endif
return rc;
}
#ifdef CONFIG_GENERIC_ATMEL_MCI
int board_mmc_init(bd_t *bis)
{
int rc = 0;
rc = atmel_mci_init((void *)ATMEL_BASE_MCI0);
return rc;
}
#endif
/* SPI chip select control */
#ifdef CONFIG_ATMEL_SPI
#include <spi.h>
int spi_cs_is_valid(unsigned int bus, unsigned int cs)
{
return bus == 0 && cs < 4;
}
void spi_cs_activate(struct spi_slave *slave)
{
switch (slave->cs) {
case 0:
at91_set_pio_output(AT91_PIO_PORTD, 13, 0);
case 1:
at91_set_pio_output(AT91_PIO_PORTD, 14, 0);
case 2:
at91_set_pio_output(AT91_PIO_PORTD, 15, 0);
case 3:
at91_set_pio_output(AT91_PIO_PORTD, 16, 0);
default:
break;
}
}
void spi_cs_deactivate(struct spi_slave *slave)
{
switch (slave->cs) {
case 0:
at91_set_pio_output(AT91_PIO_PORTD, 13, 1);
case 1:
at91_set_pio_output(AT91_PIO_PORTD, 14, 1);
case 2:
at91_set_pio_output(AT91_PIO_PORTD, 15, 1);
case 3:
at91_set_pio_output(AT91_PIO_PORTD, 16, 1);
default:
break;
}
}
#endif /* CONFIG_ATMEL_SPI */
/* SPL */
#ifdef CONFIG_SPL_BUILD
void spl_board_init(void)
{
#ifdef CONFIG_SYS_USE_MMC
sama5d3xek_mci_hw_init();
#elif CONFIG_SYS_USE_NANDFLASH
sama5d3xek_nand_hw_init();
#elif CONFIG_SYS_USE_SERIALFLASH
at91_spi0_hw_init(1 << 0);
#endif
}
static void ddr2_conf(struct atmel_mpddr *ddr2)
{
ddr2->md = (ATMEL_MPDDRC_MD_DBW_32_BITS | ATMEL_MPDDRC_MD_DDR2_SDRAM);
ddr2->cr = (ATMEL_MPDDRC_CR_NC_COL_10 |
ATMEL_MPDDRC_CR_NR_ROW_14 |
ATMEL_MPDDRC_CR_CAS_DDR_CAS3 |
ATMEL_MPDDRC_CR_ENRDM_ON |
ATMEL_MPDDRC_CR_NB_8BANKS |
ATMEL_MPDDRC_CR_NDQS_DISABLED |
ATMEL_MPDDRC_CR_DECOD_INTERLEAVED |
ATMEL_MPDDRC_CR_UNAL_SUPPORTED);
/*
* As the DDR2-SDRAm device requires a refresh time is 7.8125us
* when DDR run at 133MHz, so it needs (7.8125us * 133MHz / 10^9) clocks
*/
ddr2->rtr = 0x411;
ddr2->tpr0 = (6 << ATMEL_MPDDRC_TPR0_TRAS_OFFSET |
2 << ATMEL_MPDDRC_TPR0_TRCD_OFFSET |
2 << ATMEL_MPDDRC_TPR0_TWR_OFFSET |
8 << ATMEL_MPDDRC_TPR0_TRC_OFFSET |
2 << ATMEL_MPDDRC_TPR0_TRP_OFFSET |
2 << ATMEL_MPDDRC_TPR0_TRRD_OFFSET |
2 << ATMEL_MPDDRC_TPR0_TWTR_OFFSET |
2 << ATMEL_MPDDRC_TPR0_TMRD_OFFSET);
ddr2->tpr1 = (2 << ATMEL_MPDDRC_TPR1_TXP_OFFSET |
200 << ATMEL_MPDDRC_TPR1_TXSRD_OFFSET |
28 << ATMEL_MPDDRC_TPR1_TXSNR_OFFSET |
26 << ATMEL_MPDDRC_TPR1_TRFC_OFFSET);
ddr2->tpr2 = (7 << ATMEL_MPDDRC_TPR2_TFAW_OFFSET |
2 << ATMEL_MPDDRC_TPR2_TRTP_OFFSET |
2 << ATMEL_MPDDRC_TPR2_TRPA_OFFSET |
7 << ATMEL_MPDDRC_TPR2_TXARDS_OFFSET |
8 << ATMEL_MPDDRC_TPR2_TXARD_OFFSET);
}
void mem_init(void)
{
struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
struct atmel_mpddr ddr2;
ddr2_conf(&ddr2);
/* enable MPDDR clock */
at91_periph_clk_enable(ATMEL_ID_MPDDRC);
writel(0x4, &pmc->scer);
/* DDRAM2 Controller initialize */
ddr2_init(ATMEL_BASE_DDRCS, &ddr2);
}
void at91_pmc_init(void)
{
struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
u32 tmp;
tmp = AT91_PMC_PLLAR_29 |
AT91_PMC_PLLXR_PLLCOUNT(0x3f) |
AT91_PMC_PLLXR_MUL(43) |
AT91_PMC_PLLXR_DIV(1);
at91_plla_init(tmp);
writel(0x3 << 8, &pmc->pllicpr);
tmp = AT91_PMC_MCKR_MDIV_4 |
AT91_PMC_MCKR_CSS_PLLA;
at91_mck_init(tmp);
}
#endif
|
de2671ce4f232023588bc370c4d1e12c8b6ef250
|
7df190df28da7e4ff166e55dc8ce780f11236a9f
|
/src/router/open-plc-utils/plc/int6ktest.c
|
bf9c018738061f7dfacceee36f7377cb442b3dd4
|
[
"BSD-3-Clause-Clear"
] |
permissive
|
mirror/dd-wrt
|
25416946e6132aa54b35809de61834a1825a9a36
|
8f2934a5a2adfbb59b471375aa3a38de5d036531
|
refs/heads/master
| 2023-08-31T14:54:47.496685
| 2023-08-30T17:40:54
| 2023-08-30T17:40:54
| 7,470,282
| 520
| 281
| null | 2023-05-29T20:56:24
| 2013-01-06T17:21:29
| null |
UTF-8
|
C
| false
| false
| 11,885
|
c
|
int6ktest.c
|
/*====================================================================*
*
* Copyright (c) 2013 Qualcomm Atheros, Inc.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted (subject to the limitations
* in the disclaimer below) provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of Qualcomm Atheros nor the names of
* its contributors may be used to endorse or promote products
* derived from this software without specific prior written
* permission.
*
* NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
* GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE
* COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*--------------------------------------------------------------------*/
/*====================================================================*
*
* int6ktest.c - Atheros Test Applet Loader;
*
*
* Contributor(s):
* Charles Maier <cmaier@qca.qualcomm.com>
* Matthieu Poullet <m.poullet@avm.de>
*
*--------------------------------------------------------------------*/
/*====================================================================*"
* system header files;
*--------------------------------------------------------------------*/
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
#include <limits.h>
#include <errno.h>
/*====================================================================*
* custom header files;
*--------------------------------------------------------------------*/
#include "../tools/getoptv.h"
#include "../tools/putoptv.h"
#include "../tools/memory.h"
#include "../tools/number.h"
#include "../tools/types.h"
#include "../tools/flags.h"
#include "../tools/files.h"
#include "../tools/error.h"
#include "../ether/channel.h"
#include "../ram/nvram.h"
#include "../ram/sdram.h"
#include "../nvm/nvm.h"
#include "../pib/pib.h"
#include "../plc/plc.h"
/*====================================================================*
* custom source files;
*--------------------------------------------------------------------*/
#ifndef MAKEFILE
#include "../plc/chipset.c"
#include "../plc/Confirm.c"
#include "../plc/Devices.c"
#include "../plc/Display.c"
#include "../plc/Failure.c"
#include "../plc/Request.c"
#include "../plc/SendMME.c"
#include "../plc/WriteFirmware1.c"
#include "../plc/StartFirmware1.c"
#include "../plc/WaitForStart.c"
#endif
#ifndef MAKEFILE
#include "../tools/getoptv.c"
#include "../tools/putoptv.c"
#include "../tools/version.c"
#include "../tools/uintspec.c"
#include "../tools/checkfilename.c"
#include "../tools/hexdecode.c"
#include "../tools/todigit.c"
#include "../tools/hexdump.c"
#include "../tools/checksum32.c"
#include "../tools/fdchecksum32.c"
#include "../tools/error.c"
#include "../tools/strfbits.c"
#include "../tools/typename.c"
#endif
#ifndef MAKEFILE
#include "../ether/openchannel.c"
#include "../ether/closechannel.c"
#include "../ether/readpacket.c"
#include "../ether/sendpacket.c"
#include "../ether/channel.c"
#endif
#ifndef MAKEFILE
#include "../nvm/nvmfile1.c"
#endif
#ifndef MAKEFILE
#include "../mme/MMECode.c"
#include "../mme/EthernetHeader.c"
#include "../mme/QualcommHeader.c"
#include "../mme/UnwantedMessage.c"
#endif
/*====================================================================*
*
* signed ReadMME (struct plc * plc, uint8_t MMV, uint16_t MMTYPE);
*
* plc.h
*
* this is a custom version of ReadMME that intercepts VS_ARPC
* messages and print them on the console in human readable format;
*
* this implementation was an early attempt the does not take full
* advantage of the VS_ARPC structure and so messages are printed
* in a format that is incompatible with the Windows Device Manager;
* program amptest corrects this problem by calling ARPCPrint;
*
* this function is maintained for legacy purposes only and will be
* deleted at some point in the future;
*
*
* Contributor(s):
* Charles Maier <cmaier@qca.qualcomm.com>
*
*--------------------------------------------------------------------*/
signed ReadMME (struct plc * plc, uint8_t MMV, uint16_t MMTYPE)
{
struct channel * channel = (struct channel *)(plc->channel);
struct message * message = (struct message *)(plc->message);
#ifndef __GNUC__
#pragma pack (push,1)
#endif
static qualcomm_hdr header_arpc =
{
0,
VS_ARPC | MMTYPE_IND,
{
0x00,
0xB0,
0x52
}
};
struct __packed vs_arpc_ind
{
struct ethernet_hdr ethernet;
struct qualcomm_hdr qualcomm;
uint16_t RDATALENGTH;
uint8_t RDATAOFFSET;
uint8_t RDATA [1];
}
* indicate = (struct vs_arpc_ind *)(plc->message);
#ifndef __GNUC__
#pragma pack (pop)
#endif
while ((plc->packetsize = readpacket (channel, message, sizeof (* message))) > 0)
{
#if 1
/*
* Normally this block of code would be replaced by function FirmwareMessage () but due to an
* ARPC implmenetation error on early diagnostic applets we need to use this code instead;
*/
header_arpc.MMTYPE = HTOLE16 (header_arpc.MMTYPE);
if (!memcmp (&indicate->qualcomm, &header_arpc, sizeof (header_arpc)))
{
indicate->RDATA [indicate->RDATALENGTH - indicate->RDATAOFFSET] = (char)(0);
Display (plc, "0x%02X %s", indicate->RDATA [0], &indicate->RDATA [5]);
continue;
}
#endif
if (UnwantedMessage (message, plc->packetsize, 0, MMTYPE))
{
continue;
}
break;
}
return (plc->packetsize);
}
/*====================================================================*
*
* signed sequence (struct plc * plc);
*
* plc.h
*
* sequentially download and execute all modules found in a .nvm
* file regardless of module type; users must ensure that modules
* are executable or results may be unpredictable;
*
* DO NOT USE THIS FUNCTION TO DOWNBOOT AND EXECUTE RUNTIME FIRMWARE;
*
*
* Contributor(s):
* Charles Maier <cmaier@qca.qualcomm.com>
*
*--------------------------------------------------------------------*/
static signed sequence (struct plc * plc)
{
struct nvm_header1 nvm_header;
unsigned module = 0;
do
{
if (read (plc->NVM.file, &nvm_header, sizeof (nvm_header)) != sizeof (nvm_header))
{
if (_allclr (plc->flags, PLC_SILENCE))
{
error (0, errno, NVM_HDR_CANTREAD, plc->NVM.name, module);
}
return (-1);
}
if (LE32TOH (nvm_header.HEADERVERSION) != 0x60000000)
{
if (_allclr (plc->flags, PLC_SILENCE))
{
error (0, 0, NVM_HDR_VERSION, plc->NVM.name, module);
}
return (-1);
}
if (checksum32 (&nvm_header, sizeof (nvm_header), 0))
{
if (_allclr (plc->flags, PLC_SILENCE))
{
error (0, 0, NVM_HDR_CHECKSUM, plc->NVM.name, module);
}
return (-1);
}
if (WriteFirmware1 (plc, module, &nvm_header))
{
return (-1);
}
if (StartFirmware1 (plc, module, &nvm_header))
{
return (-1);
}
if (_anyset (plc->flags, PLC_QUICK_FLASH))
{
break;
}
while (!ReadMME (plc, 0, (VS_HOST_ACTION | MMTYPE_IND)));
module++;
}
while (nvm_header.NEXTHEADER);
return (0);
}
/*====================================================================*
*
* void function (struct plc * plc, int argc, char const * argv);
*
* execute all applets in each file on the command line; return no
* value; this function may be called repeatedly;
*
*
*--------------------------------------------------------------------*/
static void function (struct plc * plc, int argc, char const * argv [])
{
while ((argc) && (* argv))
{
if ((plc->NVM.file = open (plc->NVM.name = * argv, O_BINARY|O_RDONLY)) == -1)
{
error (0, errno, "%s", plc->NVM.name);
}
else if (nvmfile1 (&plc->NVM))
{
error (0, errno, "Won't load %s", plc->NVM.name);
}
else if (sequence (plc))
{
error (0, errno, "Abandoning %s", plc->NVM.name);
}
close (plc->NVM.file);
argc--;
argv++;
}
return;
}
/*====================================================================*
*
* int main (int argc, char const * argv[]);
*
* parse command line, populate plc structure and perform selected
* operations; show help summary when asked; see getoptv and putoptv
* to understand command line parsing and help summary display; see
* plc.h for the definition of struct plc;
*
* the default interface is eth1 because most people use eth0 as
* their principle network connection; you can specify another
* interface with -i or define environment string PLC to make
* that the default interface and save typing;
*
*
*--------------------------------------------------------------------*/
int main (int argc, char const * argv [])
{
extern struct channel channel;
char firmware [PLC_VERSION_STRING];
static char const * optv [] =
{
"c:ei:lp:qt:vx",
"file [file] [...]",
"Qualcomm Atheros Test Applet Loader",
"e\tredirect stderr to stdout",
#if defined (WINPCAP) || defined (LIBPCAP)
"i n\thost interface is (n) [" LITERAL (CHANNEL_ETHNUMBER) "]",
#else
"i s\thost interface is (s) [" LITERAL (CHANNEL_ETHDEVICE) "]",
#endif
"l\tloop until program is terminated",
"q\tquiet mode",
"t n\tread timeout is (n) milliseconds [" LITERAL (CHANNEL_TIMEOUT) "]",
"v\tverbose mode",
"x\texit on error",
(char const *) (0)
};
#include "../plc/plc.c"
signed c;
if (getenv (PLCDEVICE))
{
#if defined (WINPCAP) || defined (LIBPCAP)
channel.ifindex = atoi (getenv (PLCDEVICE));
#else
channel.ifname = strdup (getenv (PLCDEVICE));
#endif
}
optind = 1;
while ((c = getoptv (argc, argv, optv)) != -1)
{
switch (c)
{
case 'e':
dup2 (STDOUT_FILENO, STDERR_FILENO);
break;
case 'i':
#if defined (WINPCAP) || defined (LIBPCAP)
channel.ifindex = atoi (optarg);
#else
channel.ifname = optarg;
#endif
break;
case 'l':
_setbits (plc.flags, PLC_FOREVER);
break;
case 'q':
_setbits (channel.flags, CHANNEL_SILENCE);
_setbits (plc.flags, PLC_SILENCE);
break;
case 't':
channel.timeout = (signed)(uintspec (optarg, 0, UINT_MAX));
break;
case 'v':
_setbits (channel.flags, CHANNEL_VERBOSE);
_setbits (plc.flags, PLC_VERBOSE);
break;
case 'x':
_setbits (plc.flags, PLC_BAILOUT);
break;
default:
break;
}
}
argc -= optind;
argv += optind;
openchannel (&channel);
if (!(plc.message = malloc (sizeof (* plc.message))))
{
error (1, errno, PLC_NOMEMORY);
}
if (WaitForStart (&plc, firmware, sizeof (firmware)))
{
error (1, ECANCELED, PLC_NODETECT);
}
if (strcmp (firmware, "BootLoader"))
{
error (1, ECANCELED, "BootLoader must be running");
}
do
{
function (&plc, argc, argv);
}
while (_anyset (plc.flags, PLC_FOREVER));
free (plc.message);
closechannel (&channel);
return (plc.state);
}
|
8c2e61773cd694270bc84ec7b1127de19d030fa1
|
ae31542273a142210a1ff30fb76ed9d45d38eba9
|
/src/backend/nodes/params.c
|
f5d56138ee53db6601b1be669378343a1f639ce7
|
[
"Apache-2.0",
"LicenseRef-scancode-generic-cla",
"PostgreSQL",
"OpenSSL",
"LicenseRef-scancode-stream-benchmark",
"ISC",
"LicenseRef-scancode-openssl",
"LicenseRef-scancode-other-copyleft",
"LicenseRef-scancode-ssleay-windows",
"BSD-2-Clause",
"Python-2.0"
] |
permissive
|
greenplum-db/gpdb
|
8334837bceb2d5d51a684500793d11b190117c6a
|
2c0f8f0fb24a2d7a7da114dc80f5f5a2712fca50
|
refs/heads/main
| 2023-08-22T02:03:03.806269
| 2023-08-21T22:59:53
| 2023-08-22T01:17:10
| 44,781,140
| 6,417
| 2,082
|
Apache-2.0
| 2023-09-14T20:33:42
| 2015-10-23T00:25:17
|
C
|
UTF-8
|
C
| false
| false
| 6,611
|
c
|
params.c
|
/*-------------------------------------------------------------------------
*
* params.c
* Support for finding the values associated with Param nodes.
*
*
* Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* src/backend/nodes/params.c
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "nodes/bitmapset.h"
#include "nodes/params.h"
#include "storage/shmem.h"
#include "utils/datum.h"
#include "utils/lsyscache.h"
/*
* Allocate and initialize a new ParamListInfo structure.
*
* To make a new structure for the "dynamic" way (with hooks), pass 0 for
* numParams and set numParams manually.
*/
ParamListInfo
makeParamList(int numParams)
{
ParamListInfo retval;
Size size;
size = offsetof(ParamListInfoData, params) +
numParams * sizeof(ParamExternData);
retval = (ParamListInfo) palloc(size);
retval->paramFetch = NULL;
retval->paramFetchArg = NULL;
retval->paramCompile = NULL;
retval->paramCompileArg = NULL;
retval->parserSetup = NULL;
retval->parserSetupArg = NULL;
retval->numParams = numParams;
return retval;
}
/*
* Copy a ParamListInfo structure.
*
* The result is allocated in CurrentMemoryContext.
*
* Note: the intent of this function is to make a static, self-contained
* set of parameter values. If dynamic parameter hooks are present, we
* intentionally do not copy them into the result. Rather, we forcibly
* instantiate all available parameter values and copy the datum values.
*/
ParamListInfo
copyParamList(ParamListInfo from)
{
ParamListInfo retval;
if (from == NULL || from->numParams <= 0)
return NULL;
retval = makeParamList(from->numParams);
for (int i = 0; i < from->numParams; i++)
{
ParamExternData *oprm;
ParamExternData *nprm = &retval->params[i];
ParamExternData prmdata;
int16 typLen;
bool typByVal;
/* give hook a chance in case parameter is dynamic */
if (from->paramFetch != NULL)
oprm = from->paramFetch(from, i + 1, false, &prmdata);
else
oprm = &from->params[i];
/* flat-copy the parameter info */
*nprm = *oprm;
/* need datumCopy in case it's a pass-by-reference datatype */
if (nprm->isnull || !OidIsValid(nprm->ptype))
continue;
get_typlenbyval(nprm->ptype, &typLen, &typByVal);
nprm->value = datumCopy(nprm->value, typByVal, typLen);
}
return retval;
}
/*
* Estimate the amount of space required to serialize a ParamListInfo.
*/
Size
EstimateParamListSpace(ParamListInfo paramLI)
{
int i;
Size sz = sizeof(int);
if (paramLI == NULL || paramLI->numParams <= 0)
return sz;
for (i = 0; i < paramLI->numParams; i++)
{
ParamExternData *prm;
ParamExternData prmdata;
Oid typeOid;
int16 typLen;
bool typByVal;
/* give hook a chance in case parameter is dynamic */
if (paramLI->paramFetch != NULL)
prm = paramLI->paramFetch(paramLI, i + 1, false, &prmdata);
else
prm = ¶mLI->params[i];
typeOid = prm->ptype;
sz = add_size(sz, sizeof(Oid)); /* space for type OID */
sz = add_size(sz, sizeof(uint16)); /* space for pflags */
/* space for datum/isnull */
if (OidIsValid(typeOid))
get_typlenbyval(typeOid, &typLen, &typByVal);
else
{
/* If no type OID, assume by-value, like copyParamList does. */
typLen = sizeof(Datum);
typByVal = true;
}
sz = add_size(sz,
datumEstimateSpace(prm->value, prm->isnull, typByVal, typLen));
}
return sz;
}
/*
* Serialize a paramListInfo structure into caller-provided storage.
*
* We write the number of parameters first, as a 4-byte integer, and then
* write details for each parameter in turn. The details for each parameter
* consist of a 4-byte type OID, 2 bytes of flags, and then the datum as
* serialized by datumSerialize(). The caller is responsible for ensuring
* that there is enough storage to store the number of bytes that will be
* written; use EstimateParamListSpace to find out how many will be needed.
* *start_address is updated to point to the byte immediately following those
* written.
*
* RestoreParamList can be used to recreate a ParamListInfo based on the
* serialized representation; this will be a static, self-contained copy
* just as copyParamList would create.
*/
void
SerializeParamList(ParamListInfo paramLI, char **start_address)
{
int nparams;
int i;
/* Write number of parameters. */
if (paramLI == NULL || paramLI->numParams <= 0)
nparams = 0;
else
nparams = paramLI->numParams;
memcpy(*start_address, &nparams, sizeof(int));
*start_address += sizeof(int);
/* Write each parameter in turn. */
for (i = 0; i < nparams; i++)
{
ParamExternData *prm;
ParamExternData prmdata;
Oid typeOid;
int16 typLen;
bool typByVal;
/* give hook a chance in case parameter is dynamic */
if (paramLI->paramFetch != NULL)
prm = paramLI->paramFetch(paramLI, i + 1, false, &prmdata);
else
prm = ¶mLI->params[i];
typeOid = prm->ptype;
/* Write type OID. */
memcpy(*start_address, &typeOid, sizeof(Oid));
*start_address += sizeof(Oid);
/* Write flags. */
memcpy(*start_address, &prm->pflags, sizeof(uint16));
*start_address += sizeof(uint16);
/* Write datum/isnull. */
if (OidIsValid(typeOid))
get_typlenbyval(typeOid, &typLen, &typByVal);
else
{
/* If no type OID, assume by-value, like copyParamList does. */
typLen = sizeof(Datum);
typByVal = true;
}
datumSerialize(prm->value, prm->isnull, typByVal, typLen,
start_address);
}
}
/*
* Copy a ParamListInfo structure.
*
* The result is allocated in CurrentMemoryContext.
*
* Note: the intent of this function is to make a static, self-contained
* set of parameter values. If dynamic parameter hooks are present, we
* intentionally do not copy them into the result. Rather, we forcibly
* instantiate all available parameter values and copy the datum values.
*/
ParamListInfo
RestoreParamList(char **start_address)
{
ParamListInfo paramLI;
int nparams;
memcpy(&nparams, *start_address, sizeof(int));
*start_address += sizeof(int);
paramLI = makeParamList(nparams);
for (int i = 0; i < nparams; i++)
{
ParamExternData *prm = ¶mLI->params[i];
/* Read type OID. */
memcpy(&prm->ptype, *start_address, sizeof(Oid));
*start_address += sizeof(Oid);
/* Read flags. */
memcpy(&prm->pflags, *start_address, sizeof(uint16));
*start_address += sizeof(uint16);
/* Read datum/isnull. */
prm->value = datumRestore(start_address, &prm->isnull);
}
return paramLI;
}
|
c99e593b24cfdd0289390931dce989ad66e00f65
|
e814383d36a10839104efaa4df277996ab220fa3
|
/ompi/mca/io/romio341/src/io_romio341_file_write.c
|
a60c6d18be54fa351a051755779716cd5f46aec3
|
[
"mpich2",
"BSD-3-Clause-Open-MPI"
] |
permissive
|
open-mpi/ompi
|
a1d7483ae1d83dd8fd8ae3ee95e832e0a0ee04e3
|
1edfdb025c4450f694600083ad871cf06c8d45cd
|
refs/heads/main
| 2023-09-01T01:30:02.040705
| 2023-08-29T17:32:18
| 2023-08-29T17:32:18
| 24,107,001
| 2,008
| 973
|
NOASSERTION
| 2023-09-14T20:59:26
| 2014-09-16T16:08:30
|
C
|
UTF-8
|
C
| false
| false
| 12,530
|
c
|
io_romio341_file_write.c
|
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2015-2021 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2017 IBM Corporation. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "ompi_config.h"
#include "mpi.h"
#include "ompi/file/file.h"
#include "io_romio341.h"
int
mca_io_romio341_file_write_at (ompi_file_t *fh,
MPI_Offset offset,
const void *buf,
int count,
struct ompi_datatype_t *datatype,
ompi_status_public_t * status)
{
int ret;
mca_io_romio341_data_t *data;
data = (mca_io_romio341_data_t *) fh->f_io_selected_data;
OPAL_THREAD_LOCK (&mca_io_romio341_mutex);
ret =
ROMIO_PREFIX(MPI_File_write_at) (data->romio_fh, offset, buf, count,
datatype, status);
OPAL_THREAD_UNLOCK (&mca_io_romio341_mutex);
return ret;
}
int
mca_io_romio341_file_write_at_all (ompi_file_t *fh,
MPI_Offset offset,
const void *buf,
int count,
struct ompi_datatype_t *datatype,
ompi_status_public_t * status)
{
int ret;
mca_io_romio341_data_t *data;
data = (mca_io_romio341_data_t *) fh->f_io_selected_data;
OPAL_THREAD_LOCK (&mca_io_romio341_mutex);
ret =
ROMIO_PREFIX(MPI_File_write_at_all) (data->romio_fh, offset, buf,
count, datatype, status);
OPAL_THREAD_UNLOCK (&mca_io_romio341_mutex);
return ret;
}
int
mca_io_romio341_file_iwrite_at (ompi_file_t *fh,
MPI_Offset offset,
const void *buf,
int count,
struct ompi_datatype_t *datatype,
ompi_request_t **request)
{
int ret;
mca_io_romio341_data_t *data;
data = (mca_io_romio341_data_t *) fh->f_io_selected_data;
OPAL_THREAD_LOCK (&mca_io_romio341_mutex);
ret =
ROMIO_PREFIX(MPI_File_iwrite_at) (data->romio_fh, offset, buf, count,
datatype, request);
OPAL_THREAD_UNLOCK (&mca_io_romio341_mutex);
return ret;
}
int
mca_io_romio341_file_iwrite_at_all (ompi_file_t *fh,
MPI_Offset offset,
const void *buf,
int count,
struct ompi_datatype_t *datatype,
ompi_request_t **request)
{
int ret;
mca_io_romio341_data_t *data;
data = (mca_io_romio341_data_t *) fh->f_io_selected_data;
OPAL_THREAD_LOCK (&mca_io_romio341_mutex);
// ----------------------------------------------------
// NOTE: If you upgrade ROMIO, replace this with the actual ROMIO call.
// ----------------------------------------------------
// No support for non-blocking collective I/O operations.
// Fake it with individual non-blocking I/O operations.
// Similar to OMPIO
ret =
ROMIO_PREFIX(MPI_File_iwrite_at_all) (data->romio_fh, offset, buf, count,
datatype, request);
OPAL_THREAD_UNLOCK (&mca_io_romio341_mutex);
return ret;
}
int
mca_io_romio341_file_write (ompi_file_t *fh,
const void *buf,
int count,
struct ompi_datatype_t *datatype,
ompi_status_public_t * status)
{
int ret;
mca_io_romio341_data_t *data;
data = (mca_io_romio341_data_t *) fh->f_io_selected_data;
OPAL_THREAD_LOCK (&mca_io_romio341_mutex);
ret =
ROMIO_PREFIX(MPI_File_write) (data->romio_fh, buf, count, datatype,
status);
OPAL_THREAD_UNLOCK (&mca_io_romio341_mutex);
return ret;
}
int
mca_io_romio341_file_write_all (ompi_file_t *fh,
const void *buf,
int count,
struct ompi_datatype_t *datatype,
ompi_status_public_t * status)
{
int ret;
mca_io_romio341_data_t *data;
data = (mca_io_romio341_data_t *) fh->f_io_selected_data;
OPAL_THREAD_LOCK (&mca_io_romio341_mutex);
ret =
ROMIO_PREFIX(MPI_File_write_all) (data->romio_fh, buf, count, datatype,
status);
OPAL_THREAD_UNLOCK (&mca_io_romio341_mutex);
return ret;
}
int
mca_io_romio341_file_iwrite (ompi_file_t *fh,
const void *buf,
int count,
struct ompi_datatype_t *datatype,
ompi_request_t **request)
{
int ret;
mca_io_romio341_data_t *data;
data = (mca_io_romio341_data_t *) fh->f_io_selected_data;
OPAL_THREAD_LOCK (&mca_io_romio341_mutex);
ret =
ROMIO_PREFIX(MPI_File_iwrite) (data->romio_fh, buf, count, datatype,
request);
OPAL_THREAD_UNLOCK (&mca_io_romio341_mutex);
return ret;
}
int
mca_io_romio341_file_iwrite_all (ompi_file_t *fh,
const void *buf,
int count,
struct ompi_datatype_t *datatype,
ompi_request_t **request)
{
int ret;
mca_io_romio341_data_t *data;
data = (mca_io_romio341_data_t *) fh->f_io_selected_data;
OPAL_THREAD_LOCK (&mca_io_romio341_mutex);
// ----------------------------------------------------
// NOTE: If you upgrade ROMIO, replace this with the actual ROMIO call.
// ----------------------------------------------------
// No support for non-blocking collective I/O operations.
// Fake it with individual non-blocking I/O operations.
// Similar to OMPIO
ret =
ROMIO_PREFIX(MPI_File_iwrite_all) (data->romio_fh, buf, count, datatype,
request);
OPAL_THREAD_UNLOCK (&mca_io_romio341_mutex);
return ret;
}
int
mca_io_romio341_file_write_shared (ompi_file_t *fh,
const void *buf,
int count,
struct ompi_datatype_t *datatype,
ompi_status_public_t * status)
{
int ret;
mca_io_romio341_data_t *data;
data = (mca_io_romio341_data_t *) fh->f_io_selected_data;
OPAL_THREAD_LOCK (&mca_io_romio341_mutex);
ret =
ROMIO_PREFIX(MPI_File_write_shared) (data->romio_fh, buf, count,
datatype, status);
OPAL_THREAD_UNLOCK (&mca_io_romio341_mutex);
return ret;
}
int
mca_io_romio341_file_iwrite_shared (ompi_file_t *fh,
const void *buf,
int count,
struct ompi_datatype_t *datatype,
ompi_request_t **request)
{
int ret;
mca_io_romio341_data_t *data;
data = (mca_io_romio341_data_t *) fh->f_io_selected_data;
OPAL_THREAD_LOCK (&mca_io_romio341_mutex);
ret =
ROMIO_PREFIX(MPI_File_iwrite_shared) (data->romio_fh, buf, count,
datatype, request);
OPAL_THREAD_UNLOCK (&mca_io_romio341_mutex);
return ret;
}
int
mca_io_romio341_file_write_ordered (ompi_file_t *fh,
const void *buf,
int count,
struct ompi_datatype_t *datatype,
ompi_status_public_t * status)
{
int ret;
mca_io_romio341_data_t *data;
data = (mca_io_romio341_data_t *) fh->f_io_selected_data;
OPAL_THREAD_LOCK (&mca_io_romio341_mutex);
ret =
ROMIO_PREFIX(MPI_File_write_ordered) (data->romio_fh, buf, count,
datatype, status);
OPAL_THREAD_UNLOCK (&mca_io_romio341_mutex);
return ret;
}
int
mca_io_romio341_file_write_at_all_begin (ompi_file_t *fh,
MPI_Offset offset,
const void *buf,
int count,
struct ompi_datatype_t *datatype)
{
int ret;
mca_io_romio341_data_t *data;
data = (mca_io_romio341_data_t *) fh->f_io_selected_data;
OPAL_THREAD_LOCK (&mca_io_romio341_mutex);
ret = ROMIO_PREFIX(MPI_File_write_at_all_begin) (data->romio_fh, offset,
buf, count, datatype);
OPAL_THREAD_UNLOCK (&mca_io_romio341_mutex);
return ret;
}
int
mca_io_romio341_file_write_at_all_end (ompi_file_t *fh,
const void *buf,
ompi_status_public_t * status)
{
int ret;
mca_io_romio341_data_t *data;
data = (mca_io_romio341_data_t *) fh->f_io_selected_data;
OPAL_THREAD_LOCK (&mca_io_romio341_mutex);
ret = ROMIO_PREFIX(MPI_File_write_at_all_end) (data->romio_fh, buf,
status);
OPAL_THREAD_UNLOCK (&mca_io_romio341_mutex);
return ret;
}
int
mca_io_romio341_file_write_all_begin (ompi_file_t *fh,
const void *buf,
int count,
struct ompi_datatype_t *datatype)
{
int ret;
mca_io_romio341_data_t *data;
data = (mca_io_romio341_data_t *) fh->f_io_selected_data;
OPAL_THREAD_LOCK (&mca_io_romio341_mutex);
ret = ROMIO_PREFIX(MPI_File_write_all_begin) (data->romio_fh, buf, count,
datatype);
OPAL_THREAD_UNLOCK (&mca_io_romio341_mutex);
return ret;
}
int
mca_io_romio341_file_write_all_end (ompi_file_t *fh,
const void *buf,
ompi_status_public_t * status)
{
int ret;
mca_io_romio341_data_t *data;
data = (mca_io_romio341_data_t *) fh->f_io_selected_data;
OPAL_THREAD_LOCK (&mca_io_romio341_mutex);
ret = ROMIO_PREFIX(MPI_File_write_all_end) (data->romio_fh, buf, status);
OPAL_THREAD_UNLOCK (&mca_io_romio341_mutex);
return ret;
}
int
mca_io_romio341_file_write_ordered_begin (ompi_file_t *fh,
const void *buf,
int count,
struct ompi_datatype_t *datatype)
{
int ret;
mca_io_romio341_data_t *data;
data = (mca_io_romio341_data_t *) fh->f_io_selected_data;
OPAL_THREAD_LOCK (&mca_io_romio341_mutex);
ret = ROMIO_PREFIX(MPI_File_write_ordered_begin) (data->romio_fh, buf,
count, datatype);
OPAL_THREAD_UNLOCK (&mca_io_romio341_mutex);
return ret;
}
int
mca_io_romio341_file_write_ordered_end (ompi_file_t *fh,
const void *buf,
ompi_status_public_t * status)
{
int ret;
mca_io_romio341_data_t *data;
data = (mca_io_romio341_data_t *) fh->f_io_selected_data;
OPAL_THREAD_LOCK (&mca_io_romio341_mutex);
ret = ROMIO_PREFIX(MPI_File_write_ordered_end) (data->romio_fh, buf,
status);
OPAL_THREAD_UNLOCK (&mca_io_romio341_mutex);
return ret;
}
|
cf14ea1013b126dd0c64b102aa61c3462348b36d
|
35c04ea32351dc95bc18d46e5c70dda9c1e08668
|
/Examples/Eclipse/FRDM-KL25Z/FRDM-KL25Z_Printf/Sources/Application.h
|
af72cb5859dc5dbeb44947c5a5604a50e1624b05
|
[
"LicenseRef-scancode-warranty-disclaimer"
] |
no_license
|
ErichStyger/mcuoneclipse
|
0f8e7a2056a26ed79d9d4a0afd64777ff0b2b2fe
|
04ad311b11860ae5f8285316010961a87fa06d0c
|
refs/heads/master
| 2023-08-28T22:54:08.501719
| 2023-08-25T15:11:44
| 2023-08-25T15:11:44
| 7,446,094
| 620
| 1,191
|
NOASSERTION
| 2020-10-16T03:13:28
| 2013-01-04T19:38:12
|
Batchfile
|
UTF-8
|
C
| false
| false
| 402
|
h
|
Application.h
|
/**
* \file
* \brief GPS Data Logger Application Interface
* \author (c) 2014 Erich Styger, http://mcuoneclipse.com/
* \note MIT License (http://opensource.org/licenses/mit-license.html)
*
* This module implements the main module for the GPS data logger.
*/
#ifndef APPLICATION_H_
#define APPLICATION_H_
/*!
* \brief Runs the application.
*/
void APP_Run(void);
#endif /* APPLICATION_H_ */
|
5c560077e694b1a671889f724a382a913b990517
|
79d343002bb63a44f8ab0dbac0c9f4ec54078c3a
|
/lib/libc/wasi/libc-top-half/musl/src/math/ilogbl.c
|
7b1a9cf8d007ff16c1d6fe072916a5a8a226e3e3
|
[
"BSD-3-Clause",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-musl-exception",
"MIT",
"LLVM-exception",
"Apache-2.0",
"NCSA"
] |
permissive
|
ziglang/zig
|
4aa75d8d3bcc9e39bf61d265fd84b7f005623fc5
|
f4c9e19bc3213c2bc7e03d7b06d7129882f39f6c
|
refs/heads/master
| 2023-08-31T13:16:45.980913
| 2023-08-31T05:50:29
| 2023-08-31T05:50:29
| 40,276,274
| 25,560
| 2,399
|
MIT
| 2023-09-14T21:09:50
| 2015-08-06T00:51:28
|
Zig
|
UTF-8
|
C
| false
| false
| 1,004
|
c
|
ilogbl.c
|
#include <limits.h>
#include "libm.h"
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
int ilogbl(long double x)
{
return ilogb(x);
}
#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
int ilogbl(long double x)
{
#pragma STDC FENV_ACCESS ON
union ldshape u = {x};
uint64_t m = u.i.m;
int e = u.i.se & 0x7fff;
if (!e) {
if (m == 0) {
FORCE_EVAL(0/0.0f);
return FP_ILOGB0;
}
/* subnormal x */
for (e = -0x3fff+1; m>>63 == 0; e--, m<<=1);
return e;
}
if (e == 0x7fff) {
FORCE_EVAL(0/0.0f);
return m<<1 ? FP_ILOGBNAN : INT_MAX;
}
return e - 0x3fff;
}
#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
int ilogbl(long double x)
{
#pragma STDC FENV_ACCESS ON
union ldshape u = {x};
int e = u.i.se & 0x7fff;
if (!e) {
if (x == 0) {
FORCE_EVAL(0/0.0f);
return FP_ILOGB0;
}
/* subnormal x */
x *= 0x1p120;
return ilogbl(x) - 120;
}
if (e == 0x7fff) {
FORCE_EVAL(0/0.0f);
u.i.se = 0;
return u.f ? FP_ILOGBNAN : INT_MAX;
}
return e - 0x3fff;
}
#endif
|
92e37971df814dc44223c310ebd5460676f967a0
|
bed3ac926beac0f4e0293303d7b2a6031ee476c9
|
/Modules/ThirdParty/HDF5/src/itkhdf5/src/H5make_libsettings.c
|
bd2b9199aa75ac28b183ea003a3a765edc572267
|
[
"IJG",
"Zlib",
"LicenseRef-scancode-proprietary-license",
"SMLNJ",
"BSD-3-Clause",
"BSD-4.3TAHOE",
"LicenseRef-scancode-free-unknown",
"Spencer-86",
"LicenseRef-scancode-llnl",
"FSFUL",
"Libpng",
"libtiff",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-hdf5",
"MIT",
"NTP",
"LicenseRef-scancode-mit-old-style",
"GPL-1.0-or-later",
"LicenseRef-scancode-unknown-license-reference",
"MPL-2.0",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause"
] |
permissive
|
InsightSoftwareConsortium/ITK
|
ed9dbbc5b8b3f7511f007c0fc0eebb3ad37b88eb
|
3eb8fd7cdfbc5ac2d0c2e5e776848a4cbab3d7e1
|
refs/heads/master
| 2023-08-31T17:21:47.754304
| 2023-08-31T00:58:51
| 2023-08-31T14:12:21
| 800,928
| 1,229
| 656
|
Apache-2.0
| 2023-09-14T17:54:00
| 2010-07-27T15:48:04
|
C++
|
UTF-8
|
C
| false
| false
| 9,844
|
c
|
H5make_libsettings.c
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*keep this declaration near the top of this file -RPM*/
static const char *FileHeader = "\n\
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n\
* Copyright by The HDF Group. *\n\
* Copyright by the Board of Trustees of the University of Illinois. *\n\
* All rights reserved. *\n\
* *\n\
* This file is part of HDF5. The full HDF5 copyright notice, including *\n\
* terms governing use, modification, and redistribution, is contained in *\n\
* the COPYING file, which can be found at the root of the source code *\n\
* distribution tree, or in https://www.hdfgroup.org/licenses. *\n\
* If you do not have access to either file, you may request a copy from *\n\
* help@hdfgroup.org. *\n\
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *";
/*
* Purpose: Generate the H5libsettings.c file from the
* libhdf5.settings file.
*
*-------------------------------------------------------------------------
*/
#include "H5private.h"
/* Do NOT use HDfprintf in this file as it is not linked with the library,
* which contains the H5system.c file in which the function is defined.
*/
#define LIBSETTINGSFNAME "libhdf5.settings"
FILE *rawoutstream = NULL;
/*-------------------------------------------------------------------------
* Function: insert_libhdf5_settings
*
* Purpose: insert the contents of libhdf5.settings into a file
* represented by flibinfo.
* Make it an empty string if H5_HAVE_EMBEDDED_LIBINFO is not
* defined, i.e., not enabled.
*
* Return: void
*-------------------------------------------------------------------------
*/
static void
insert_libhdf5_settings(FILE *flibinfo)
{
/* ITK --start */
#if defined(H5_HAVE_EMBEDDED_LIBINFO) && !defined(__EMSCRIPTEN__)
/* ITK --stop */
FILE *fsettings; /* for files libhdf5.settings */
int inchar;
int bol = 0; /* indicates the beginning of a new line */
if (NULL == (fsettings = HDfopen(LIBSETTINGSFNAME, "r"))) {
HDperror(LIBSETTINGSFNAME);
HDexit(EXIT_FAILURE);
}
/* print variable definition and the string */
/* Do not use const else AIX strings does not show it. */
/* ITK --start */
fprintf(flibinfo, "char " H5_TOSTRING(H5libhdf5_settings) "[]=\n");
/* ITK --stop */
bol++;
while (EOF != (inchar = HDgetc(fsettings))) {
if (bol) {
/* Start a new line */
fprintf(flibinfo, "\t\"");
bol = 0;
}
if (inchar == '\n') {
/* end of a line */
fprintf(flibinfo, "\\n\"\n");
bol++;
}
else
HDputc(inchar, flibinfo);
}
if (HDfeof(fsettings)) {
/* wrap up */
if (!bol)
/* EOF found without a new line */
fprintf(flibinfo, "\\n\"\n");
fprintf(flibinfo, ";\n\n");
}
else {
fprintf(stderr, "Read errors encountered with %s\n", LIBSETTINGSFNAME);
HDexit(EXIT_FAILURE);
}
if (0 != HDfclose(fsettings)) {
HDperror(LIBSETTINGSFNAME);
HDexit(EXIT_FAILURE);
}
#else
/* print variable definition and an empty string */
/* Do not use const else AIX strings does not show it. */
/* ITK --start */
fprintf(flibinfo, "char " H5_TOSTRING(H5libhdf5_settings) "[]=\"\";\n");
/* ITK --stop */
#endif
} /* insert_libhdf5_settings() */
/*-------------------------------------------------------------------------
* Function: make_libinfo
*
* Purpose: Create the embedded library information definition.
* This sets up for a potential extension that the declaration
* is printed to a file different from stdout.
*
* Return: void
*-------------------------------------------------------------------------
*/
static void
make_libinfo(void)
{
/* print variable definition and then the string as a macro. */
insert_libhdf5_settings(rawoutstream);
}
/*-------------------------------------------------------------------------
* Function: print_header
*
* Purpose: Prints the header for the generated file.
*
* Return: void
*-------------------------------------------------------------------------
*/
static void
print_header(void)
{
time_t now = HDtime(NULL);
struct tm * tm = HDlocaltime(&now);
char real_name[30];
char host_name[256];
int i;
const char *s;
#ifdef H5_HAVE_GETPWUID
struct passwd *pwd = NULL;
#else
int pwd = 1;
#endif
static const char *month_name[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
static const char *purpose = "\
This machine-generated source code contains\n\
information about the library build configuration\n";
/*
* The real name is the first item from the passwd gecos field.
*/
#ifdef H5_HAVE_GETPWUID
{
size_t n;
char * comma;
if ((pwd = HDgetpwuid(HDgetuid()))) {
if ((comma = HDstrchr(pwd->pw_gecos, ','))) {
n = MIN(sizeof(real_name) - 1, (unsigned)(comma - pwd->pw_gecos));
HDstrncpy(real_name, pwd->pw_gecos, n);
real_name[n] = '\0';
}
else {
HDstrncpy(real_name, pwd->pw_gecos, sizeof(real_name));
real_name[sizeof(real_name) - 1] = '\0';
}
}
else
real_name[0] = '\0';
}
#else
real_name[0] = '\0';
#endif
/*
* The FQDM of this host or the empty string.
*/
#ifdef H5_HAVE_GETHOSTNAME
if (HDgethostname(host_name, sizeof(host_name)) < 0)
host_name[0] = '\0';
#else
host_name[0] = '\0';
#endif
/*
* The file header: warning, copyright notice, build information.
*/
fprintf(rawoutstream, "/* Generated automatically by H5make_libsettings -- do not edit */\n\n\n");
HDfputs(FileHeader, rawoutstream); /*the copyright notice--see top of this file */
fprintf(rawoutstream, " *\n * Created:\t\t%s %2d, %4d\n", month_name[tm->tm_mon], tm->tm_mday,
1900 + tm->tm_year);
if (pwd || real_name[0] || host_name[0]) {
fprintf(rawoutstream, " *\t\t\t");
if (real_name[0])
fprintf(rawoutstream, "%s <", real_name);
#ifdef H5_HAVE_GETPWUID
if (pwd)
HDfputs(pwd->pw_name, rawoutstream);
#endif
if (host_name[0])
fprintf(rawoutstream, "@%s", host_name);
if (real_name[0])
fprintf(rawoutstream, ">");
HDfputc('\n', rawoutstream);
}
fprintf(rawoutstream, " *\n * Purpose:\t\t");
for (s = purpose; *s; s++) {
HDfputc(*s, rawoutstream);
if ('\n' == *s && s[1])
fprintf(rawoutstream, " *\t\t\t");
}
fprintf(rawoutstream, " *\n * Modifications:\n *\n");
fprintf(rawoutstream, " *\tDO NOT MAKE MODIFICATIONS TO THIS FILE!\n");
fprintf(rawoutstream, " *\tIt was generated by code in `H5make_libsettings.c'.\n");
fprintf(rawoutstream, " *\n *");
for (i = 0; i < 73; i++)
HDfputc('-', rawoutstream);
fprintf(rawoutstream, "\n */\n\n");
}
/*-------------------------------------------------------------------------
* Function: print_footer
*
* Purpose: Prints the file footer for the generated file.
*
* Return: void
*-------------------------------------------------------------------------
*/
static void
print_footer(void)
{
/* nothing */
}
/*-------------------------------------------------------------------------
* Function: main
*
* Purpose: Main entry point.
*
* Return: Success: EXIT_SUCCESS
*-------------------------------------------------------------------------
*/
int
main(int argc, char *argv[])
{
char *fname = NULL;
FILE *f; /* temporary holding place for the stream pointer
* so that rawoutstream is changed only when succeeded
*/
if (argc > 1)
fname = argv[1];
/* First check if filename is string "NULL" */
if (fname != NULL) {
/* binary output */
if ((f = HDfopen(fname, "w")) != NULL)
rawoutstream = f;
}
if (!rawoutstream)
rawoutstream = stdout;
print_header();
/* Generate embedded library information variable definition */
make_libinfo();
print_footer();
if (rawoutstream && rawoutstream != stdout) {
if (HDfclose(rawoutstream))
fprintf(stderr, "closing rawoutstream");
else
rawoutstream = NULL;
}
HDexit(EXIT_SUCCESS);
}
|
c663ca9d34996f08ff856acd24c568ca439669d7
|
eb266f888155c0fa59c923d7496e875c7259f1de
|
/src/lib/lib_bitset.c
|
6d8eb7880d9a7d2b87503be6983fba79543bc557
|
[
"BSD-2-Clause"
] |
permissive
|
werererer/japokwm
|
e7f46b210e7daf6a7d3a6bb8c61d912c40a2cb58
|
9cdc208ed70d4b58a805431992e4078171403edd
|
refs/heads/master
| 2023-05-25T18:46:40.826666
| 2023-01-15T22:26:59
| 2023-01-15T22:26:59
| 297,172,042
| 121
| 4
|
BSD-2-Clause
| 2023-01-15T22:27:00
| 2020-09-20T22:06:29
|
C
|
UTF-8
|
C
| false
| false
| 7,681
|
c
|
lib_bitset.c
|
#include "lib/lib_bitset.h"
#include "bitset/bitset.h"
#include "client.h"
#include "container.h"
#include "lib/lib_list.h"
#include "server.h"
#include "tag.h"
#include "tagset.h"
#include "translationLayer.h"
static const struct luaL_Reg bitset_gc_meta[] =
{
{"__gc", lib_bitset_gc},
{"__tostring", lib_bitset_tostring},
{NULL, NULL},
};
static const struct luaL_Reg bitset_meta[] =
{
{"__index", lib_bitset_get},
{"__newindex", lib_bitset_set},
{"__bxor", lib_bitset_meta_bxor},
{"__band", lib_bitset_meta_band},
{"__bor", lib_bitset_meta_bor},
{"__bnot", lib_bitset_meta_bnot},
{NULL, NULL},
};
static const struct luaL_Reg bitset_static_methods[] =
{
{"new", lib_bitset_new},
{NULL, NULL},
};
static const struct luaL_Reg bitset_methods[] =
{
{"_xor", lib_bitset_xor},
{"_and", lib_bitset_and},
{"_or", lib_bitset_or},
{"_not", lib_bitset_not},
{NULL, NULL},
};
static const struct luaL_Reg bitset_setter[] =
{
{NULL, NULL},
};
static const struct luaL_Reg bitset_getter[] =
{
{NULL, NULL},
};
void lua_load_bitset(lua_State *L)
{
create_class(L,
bitset_meta,
bitset_static_methods,
bitset_methods,
bitset_setter,
bitset_getter,
CONFIG_BITSET);
create_class(L,
bitset_meta,
bitset_static_methods,
bitset_methods,
bitset_setter,
bitset_getter,
CONFIG_BITSET_WITH_TAG);
create_class(L,
bitset_meta,
bitset_static_methods,
bitset_methods,
bitset_setter,
bitset_getter,
CONFIG_BITSET_WITH_CONTAINER);
create_class(L,
bitset_meta,
bitset_static_methods,
bitset_methods,
bitset_setter,
bitset_getter,
CONFIG_BITSET_GC);
luaL_getmetatable(L, CONFIG_BITSET_GC);
luaL_setfuncs(L, bitset_gc_meta, 0);
lua_pop(L, 1);
luaL_newlib(L, bitset_static_methods);
lua_setglobal(L, "Bitset");
}
static void create_lua_bitset_gc(lua_State *L, BitSet *bitset)
{
BitSet **user_bitset = lua_newuserdata(L, sizeof(BitSet *));
*user_bitset = bitset;
luaL_setmetatable(L, CONFIG_BITSET_GC);
}
BitSet *check_bitset(lua_State *L, int narg)
{
void **ud = NULL;
if (luaL_testudata(L, narg, CONFIG_BITSET)) {
ud = luaL_checkudata(L, narg, CONFIG_BITSET);
} else if (luaL_testudata(L, narg, CONFIG_BITSET_GC)) {
ud = luaL_checkudata(L, narg, CONFIG_BITSET_GC);
} else if (luaL_testudata(L, narg, CONFIG_BITSET_WITH_CONTAINER)) {
ud = luaL_checkudata(L, narg, CONFIG_BITSET_WITH_CONTAINER);
} else if (luaL_testudata(L, narg, CONFIG_BITSET_WITH_TAG)) {
ud = luaL_checkudata(L, narg, CONFIG_BITSET_WITH_TAG);
} else if (lua_isinteger(L, narg)) {
int tags_dec = luaL_checkinteger(L, -1);
lua_pop(L, 1);
BitSet *bitset = bitset_from_value(tags_dec);
bitset_reverse(bitset, 0, 64);
// hand over garbage collection to lua
create_lua_bitset_gc(L, bitset);
ud = luaL_checkudata(L, narg, CONFIG_BITSET_GC);
} else {
lua_pushstring(L, "`bitset' expected");
lua_error(L);
}
luaL_argcheck(L, ud != NULL, 1, "`bitset' expected");
return *(BitSet **)ud;
}
void create_lua_bitset_with_tag(lua_State *L, BitSet *bitset)
{
BitSet **user_bitset = lua_newuserdata(L, sizeof(BitSet *));
*user_bitset = bitset;
luaL_setmetatable(L, CONFIG_BITSET_WITH_TAG);
}
void create_lua_bitset_with_container(lua_State *L, BitSet *bitset)
{
BitSet **user_bitset = lua_newuserdata(L, sizeof(BitSet *));
*user_bitset = bitset;
luaL_setmetatable(L, CONFIG_BITSET_WITH_CONTAINER);
}
void create_lua_bitset(lua_State *L, struct BitSet *bitset)
{
struct BitSet **user_tags = lua_newuserdata(L, sizeof(BitSet *));
*user_tags = bitset;
luaL_setmetatable(L, CONFIG_BITSET);
}
// meta
int lib_bitset_get(lua_State *L)
{
// [table, key]
BitSet *bitset = check_bitset(L, 1);
bool is_number = lua_isnumber(L, -1);
if (!is_number) {
get_lua_value(L);
return 1;
}
int i = lua_idx_to_c_idx(lua_tonumber(L, -1));
if (i < 0) {
lua_pushnil(L);
return 1;
}
bool b = bitset_test(bitset, i);
lua_pushboolean(L, b);
return 1;
}
int lib_bitset_set(lua_State *L)
{
// [table, key, value]
bool value = lua_toboolean(L, 3);
BitSet *bitset = check_bitset(L, 1);
bool is_number = lua_isnumber(L, 2);
if (!is_number) {
set_lua_value(L);
return 0;
}
int i = lua_idx_to_c_idx(lua_tonumber(L, 2));
if (i < 0) {
lua_pushnil(L);
return 1;
}
call_bitset_func(L, bitset_assign, bitset, i, value);
return 0;
}
int lib_bitset_meta_bxor(lua_State *L)
{
BitSet *bitset = check_bitset(L, 2);
lua_pop(L, 1);
BitSet *self = check_bitset(L, 1);
lua_pop(L, 1);
BitSet *target_bitset = bitset_create();
bitset_assign_bitset(&target_bitset, self);
bitset_xor(target_bitset, bitset);
create_lua_bitset_gc(L, target_bitset);
return 1;
}
int lib_bitset_meta_band(lua_State *L)
{
BitSet *bitset = check_bitset(L, 2);
lua_pop(L, 1);
BitSet *oth_bitset = check_bitset(L, 1);
lua_pop(L, 1);
BitSet *target_bitset = bitset_create();
bitset_assign_bitset(&target_bitset, oth_bitset);
bitset_and(target_bitset, bitset);
create_lua_bitset_gc(L, target_bitset);
return 1;
}
int lib_bitset_meta_bor(lua_State *L)
{
BitSet *bitset = check_bitset(L, 2);
lua_pop(L, 1);
BitSet *oth_bitset = check_bitset(L, 1);
lua_pop(L, 1);
BitSet *target_bitset = bitset_create();
bitset_assign_bitset(&target_bitset, oth_bitset);
bitset_or(target_bitset, bitset);
create_lua_bitset_gc(L, target_bitset);
return 1;
}
int lib_bitset_meta_bnot(lua_State *L)
{
BitSet *bitset = check_bitset(L, 1);
lua_pop(L, 1);
BitSet *target_bitset = bitset_create();
bitset_assign_bitset(&target_bitset, bitset);
bitset_flip(target_bitset, 0, 8);
create_lua_bitset_gc(L, target_bitset);
return 1;
}
int lib_bitset_gc(lua_State *L)
{
BitSet *bitset = check_bitset(L, 1);
lua_pop(L, 1);
bitset_destroy(bitset);
return 0;
}
int lib_bitset_tostring(lua_State *L)
{
BitSet *bitset = check_bitset(L, 1);
lua_pop(L, 1);
char *str = bitset_to_string(bitset);
lua_pushstring(L, str);
free(str);
return 1;
}
// static methods
int lib_bitset_new(lua_State *L)
{
BitSet *bitset = bitset_create();
// hand over rights for this pointer (deletion etc.) to lua
create_lua_bitset_gc(L, bitset);
return 1;
}
// methods
int lib_bitset_xor(lua_State *L)
{
BitSet *bitset = check_bitset(L, 2);
lua_pop(L, 1);
BitSet *self = check_bitset(L, 1);
call_bitset_func(L, bitset_xor, self, bitset);
lua_pop(L, 1);
return 0;
}
int lib_bitset_and(lua_State *L)
{
BitSet *bitset = check_bitset(L, 2);
lua_pop(L, 1);
BitSet *self = check_bitset(L, 1);
call_bitset_func(L, bitset_and, self, bitset);
lua_pop(L, 1);
return 0;
}
int lib_bitset_or(lua_State *L)
{
BitSet *bitset = check_bitset(L, 2);
lua_pop(L, 1);
BitSet *self = check_bitset(L, 1);
call_bitset_func(L, bitset_or, self, bitset);
lua_pop(L, 1);
return 0;
}
int lib_bitset_not(lua_State *L)
{
BitSet *self = check_bitset(L, 1);
call_bitset_func(L, bitset_flip, self, 0, 8);
lua_pop(L, 1);
return 0;
}
// getters
// setters
|
bd30107dcf7b673cfae0fd7fe49dcc72d7d7e9d2
|
eb907ede8881df72394637539b204a36089afe45
|
/deps/check-0.9.8/lib/sleep.c
|
a70ffbdb28eef3258ab3684da824b8883e6d2d02
|
[
"LGPL-2.1-only"
] |
permissive
|
armon/hlld
|
735ce9d1b179d0da8e6efb9e60a77ab94fe2c8b2
|
a7b035ff305a48335c8a3c39d6617ce5ffc1f980
|
refs/heads/master
| 2023-07-08T20:50:32.609950
| 2021-02-11T17:57:24
| 2021-02-11T17:57:24
| 9,990,694
| 205
| 28
|
BSD-3-Clause
| 2021-02-11T17:57:25
| 2013-05-10T21:25:27
|
C
|
UTF-8
|
C
| false
| false
| 116
|
c
|
sleep.c
|
#include "libcompat.h"
unsigned int
sleep (unsigned int seconds CK_ATTRIBUTE_UNUSED)
{
assert (0);
return 0;
}
|
95a092b00b81820c49f2dc2186c36d25ba261ce2
|
03666e5f961946fc1a0ac67781ac1425562ef0d7
|
/src/databases/SPCTH/SPCTHCommonPluginInfo.C
|
3e7b9cae96497394f7999429f0e1a281b99ba262
|
[
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
visit-dav/visit
|
e9f81b4d4b9b9930a0db9d5282cd1bcabf465e2e
|
601ae46e0bef2e18425b482a755d03490ade0493
|
refs/heads/develop
| 2023-09-06T08:19:38.397058
| 2023-09-05T21:29:32
| 2023-09-05T21:29:32
| 165,565,988
| 335
| 120
|
BSD-3-Clause
| 2023-09-14T00:53:37
| 2019-01-13T23:27:26
|
C
|
UTF-8
|
C
| false
| false
| 1,874
|
c
|
SPCTHCommonPluginInfo.C
|
// Copyright (c) Lawrence Livermore National Security, LLC and other VisIt
// Project developers. See the top-level LICENSE file for dates and other
// details. No copyright assignment is required to contribute to VisIt.
#include <SPCTHPluginInfo.h>
#include <avtSPCTHFileFormat.h>
#include <avtMTMDFileFormatInterface.h>
#include <avtGenericDatabase.h>
// ****************************************************************************
// Method: SPCTHCommonPluginInfo::GetDatabaseType
//
// Purpose:
// Returns the type of a SPCTH database.
//
// Programmer: generated by xml2info
// Creation: omitted
//
// ****************************************************************************
DatabaseType
SPCTHCommonPluginInfo::GetDatabaseType()
{
return DB_TYPE_MTMD;
}
// ****************************************************************************
// Method: SPCTHCommonPluginInfo::SetupDatabase
//
// Purpose:
// Sets up a SPCTH database.
//
// Arguments:
// list A list of file names.
// nList The number of timesteps in list.
// nBlocks The number of blocks in the list.
//
// Returns: A SPCTH database from list.
//
// Programmer: generated by xml2info
// Creation: omitted
//
// ****************************************************************************
avtDatabase *
SPCTHCommonPluginInfo::SetupDatabase(const char *const *list,
int nList,
int nBlock)
{
avtMTMDFileFormat **ffl = new avtMTMDFileFormat*[1];
ffl[0] = new avtSPCTHFileFormat(list[0]);
if(nList > 1)
{
avtSPCTHFileFormat *ff = dynamic_cast<avtSPCTHFileFormat *>(ffl[0]);
ff->SetFileList(list, nList);
}
avtMTMDFileFormatInterface *inter
= new avtMTMDFileFormatInterface(ffl, 1);
return new avtGenericDatabase(inter);
}
|
304b9554439cb38027bea8a0849ef4a7971b4c11
|
4d78977ee7a816f97134d92b5826e929fb56c571
|
/include/cpm/threadlocal.h
|
4e37193f1b5d280e5e3456c133d6eb09ceee4715
|
[
"MIT"
] |
permissive
|
ireader/sdk
|
312e3ebdd4b0f694977236efab012d75cbd4bdd1
|
9fb240206c4d925d12be5b29aeb94c7884ea8262
|
refs/heads/master
| 2023-09-01T17:49:04.171634
| 2023-07-22T01:56:22
| 2023-07-22T01:56:22
| 11,940,320
| 394
| 250
|
MIT
| 2022-05-01T08:18:58
| 2013-08-07T03:16:47
|
C
|
UTF-8
|
C
| false
| false
| 272
|
h
|
threadlocal.h
|
#ifndef _threadlocal_h_
#define _threadlocal_h_
#if defined(OS_WINDOWS)
#define THREAD_LOCAL static __declspec(thread)
#elif defined(__GNUC__) || defined(__clang__)
#define THREAD_LOCAL static __thread
#else
#define THREAD_LOCAL
#endif
#endif /* !_threadlocal_h_ */
|
6905bb5c60b0a4b41762a50ea190ce969bb40fab
|
e1cddfd754d952134e72dfd03522c5ea4fb6008e
|
/src/plugins/perfmon/arm/bundle/mem_access.c
|
cfe8f4dc42576d7d3c29c501e3015dd2459cdfb8
|
[
"Apache-2.0"
] |
permissive
|
FDio/vpp
|
0ad30fa1bec2975ffa6b66b45c9f4f32163123b6
|
f234b0d4626d7e686422cc9dfd25958584f4931e
|
refs/heads/master
| 2023-08-31T16:09:04.068646
| 2022-03-14T09:49:15
| 2023-08-31T09:50:00
| 96,556,718
| 1,048
| 630
|
Apache-2.0
| 2023-06-21T05:39:17
| 2017-07-07T16:29:40
|
C
|
UTF-8
|
C
| false
| false
| 2,787
|
c
|
mem_access.c
|
/*
* Copyright (c) 2022 Arm and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <vnet/vnet.h>
#include <vppinfra/linux/sysfs.h>
#include <perfmon/perfmon.h>
#include <perfmon/arm/events.h>
/* as per .events[n] in PERFMON_REGISTER_BUNDLE */
enum
{
MEM_ACCESS,
BUS_ACCESS,
MEMORY_ERROR
};
static u8 *
format_arm_memory_access (u8 *s, va_list *args)
{
perfmon_node_stats_t *ns = va_arg (*args, perfmon_node_stats_t *);
int row = va_arg (*args, int);
switch (row)
{
case 0:
s = format (s, "%.2f", (f64) ns->value[MEM_ACCESS] / ns->n_packets);
break;
case 1:
s = format (s, "%.3f", (f64) ns->value[BUS_ACCESS] / ns->n_packets);
break;
case 2:
s = format (s, "%llu", ns->value[MEMORY_ERROR]);
break;
case 3:
s = format (s, "%llu", ns->n_packets);
break;
}
return s;
}
PERFMON_REGISTER_BUNDLE (arm_memory_access) = {
.name = "memory-access",
.description = "Memory/bus accesses per pkt + total memory errors",
.source = "arm",
.type = PERFMON_BUNDLE_TYPE_NODE,
.events[0] = ARMV8_PMUV3_MEM_ACCESS,
.events[1] = ARMV8_PMUV3_BUS_ACCESS,
.events[2] = ARMV8_PMUV3_MEMORY_ERROR,
.n_events = 3,
.n_columns = 4,
.format_fn = format_arm_memory_access,
.column_headers = PERFMON_STRINGS ("Mem-access/pkt", "Bus-access/pkt",
"Total-mem-errors", "pkts"),
/*
* set a bit for every event used in each column
* this allows us to disable columns at bundle registration if an
* event is not supported
*/
.column_events = PERFMON_COLUMN_EVENTS (SET_BIT (MEM_ACCESS),
SET_BIT (BUS_ACCESS),
SET_BIT (MEMORY_ERROR), 0),
.footer =
"Mem-access: The counter counts Memory-read operations and Memory-write"
" operations that the PE made\n"
"Bus-access: The counter counts Memory-read operations and Memory-write"
" operations that access outside of the boundary of the PE and its "
"closely-coupled caches\n"
"Mem-error: Memory error refers to a physical error in memory closely "
"coupled to this PE, and detected by the hardware, such as a parity or"
" ECC error\n"
"- See Armv8-A Architecture Reference Manual, D7.10 PMU events and"
" event numbers for full description.\n"
};
|
9cf57d35c0f082827d0ecba3d81d74db404de441
|
72f2515c4cef9e02c27452b32269ca403f76c69a
|
/src/modules/videoconference/VideoConferenceShared/MediaFoundationAPIProvider.h
|
470f8b1f0f60962f3487e38d235487e71560ebce
|
[
"LicenseRef-scancode-generic-cla",
"MIT",
"BSL-1.0",
"Unlicense"
] |
permissive
|
microsoft/PowerToys
|
4625ffc4c513265094bf9e0f490753a54aabeaa0
|
3244ba989921dd26dd32be75021ed68c9cfcdda9
|
refs/heads/main
| 2023-08-17T00:10:06.645243
| 2023-08-16T16:31:10
| 2023-08-16T16:31:10
| 184,456,251
| 103,306
| 7,187
|
MIT
| 2023-09-14T16:52:26
| 2019-05-01T17:44:02
|
C#
|
UTF-8
|
C
| false
| false
| 284
|
h
|
MediaFoundationAPIProvider.h
|
#pragma once
#include <mfapi.h>
#include <mfidl.h>
#include "DLLProviderHelpers.h"
DECLARE_DLL_PROVIDER_BEGIN(mfplat)
DECLARE_DLL_FUNCTION(MFCreateAttributes)
DECLAR_DLL_PROVIDER_END
DECLARE_DLL_PROVIDER_BEGIN(mf)
DECLARE_DLL_FUNCTION(MFEnumDeviceSources)
DECLAR_DLL_PROVIDER_END
|
047bd31497dc743f508e7e26ba087c12054d4b03
|
8a51a96f61699f0318315ccc89cef39f6866f2b5
|
/src/backend/access/tablesample/system.c
|
076842aa6bb7a4536b105eb9958423ffdfd87f4d
|
[
"PostgreSQL"
] |
permissive
|
postgres/postgres
|
979febf2b41c00090d1256228f768f33e7ef3b6f
|
b5934bfd6071fed3a38cea0cfaa93afda63d9c0c
|
refs/heads/master
| 2023-08-31T00:10:01.373472
| 2023-08-30T23:07:48
| 2023-08-30T23:07:48
| 927,442
| 13,691
| 4,807
|
NOASSERTION
| 2023-09-09T13:59:15
| 2010-09-21T11:35:45
|
C
|
UTF-8
|
C
| false
| false
| 7,343
|
c
|
system.c
|
/*-------------------------------------------------------------------------
*
* system.c
* support routines for SYSTEM tablesample method
*
* To ensure repeatability of samples, it is necessary that selection of a
* given tuple be history-independent; otherwise syncscanning would break
* repeatability, to say nothing of logically-irrelevant maintenance such
* as physical extension or shortening of the relation.
*
* To achieve that, we proceed by hashing each candidate block number together
* with the active seed, and then selecting it if the hash is less than the
* cutoff value computed from the selection probability by BeginSampleScan.
*
*
* Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* src/backend/access/tablesample/system.c
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include <math.h>
#include "access/relscan.h"
#include "access/tsmapi.h"
#include "catalog/pg_type.h"
#include "common/hashfn.h"
#include "optimizer/optimizer.h"
#include "utils/builtins.h"
/* Private state */
typedef struct
{
uint64 cutoff; /* select blocks with hash less than this */
uint32 seed; /* random seed */
BlockNumber nextblock; /* next block to consider sampling */
OffsetNumber lt; /* last tuple returned from current block */
} SystemSamplerData;
static void system_samplescangetsamplesize(PlannerInfo *root,
RelOptInfo *baserel,
List *paramexprs,
BlockNumber *pages,
double *tuples);
static void system_initsamplescan(SampleScanState *node,
int eflags);
static void system_beginsamplescan(SampleScanState *node,
Datum *params,
int nparams,
uint32 seed);
static BlockNumber system_nextsampleblock(SampleScanState *node, BlockNumber nblocks);
static OffsetNumber system_nextsampletuple(SampleScanState *node,
BlockNumber blockno,
OffsetNumber maxoffset);
/*
* Create a TsmRoutine descriptor for the SYSTEM method.
*/
Datum
tsm_system_handler(PG_FUNCTION_ARGS)
{
TsmRoutine *tsm = makeNode(TsmRoutine);
tsm->parameterTypes = list_make1_oid(FLOAT4OID);
tsm->repeatable_across_queries = true;
tsm->repeatable_across_scans = true;
tsm->SampleScanGetSampleSize = system_samplescangetsamplesize;
tsm->InitSampleScan = system_initsamplescan;
tsm->BeginSampleScan = system_beginsamplescan;
tsm->NextSampleBlock = system_nextsampleblock;
tsm->NextSampleTuple = system_nextsampletuple;
tsm->EndSampleScan = NULL;
PG_RETURN_POINTER(tsm);
}
/*
* Sample size estimation.
*/
static void
system_samplescangetsamplesize(PlannerInfo *root,
RelOptInfo *baserel,
List *paramexprs,
BlockNumber *pages,
double *tuples)
{
Node *pctnode;
float4 samplefract;
/* Try to extract an estimate for the sample percentage */
pctnode = (Node *) linitial(paramexprs);
pctnode = estimate_expression_value(root, pctnode);
if (IsA(pctnode, Const) &&
!((Const *) pctnode)->constisnull)
{
samplefract = DatumGetFloat4(((Const *) pctnode)->constvalue);
if (samplefract >= 0 && samplefract <= 100 && !isnan(samplefract))
samplefract /= 100.0f;
else
{
/* Default samplefract if the value is bogus */
samplefract = 0.1f;
}
}
else
{
/* Default samplefract if we didn't obtain a non-null Const */
samplefract = 0.1f;
}
/* We'll visit a sample of the pages ... */
*pages = clamp_row_est(baserel->pages * samplefract);
/* ... and hopefully get a representative number of tuples from them */
*tuples = clamp_row_est(baserel->tuples * samplefract);
}
/*
* Initialize during executor setup.
*/
static void
system_initsamplescan(SampleScanState *node, int eflags)
{
node->tsm_state = palloc0(sizeof(SystemSamplerData));
}
/*
* Examine parameters and prepare for a sample scan.
*/
static void
system_beginsamplescan(SampleScanState *node,
Datum *params,
int nparams,
uint32 seed)
{
SystemSamplerData *sampler = (SystemSamplerData *) node->tsm_state;
double percent = DatumGetFloat4(params[0]);
double dcutoff;
if (percent < 0 || percent > 100 || isnan(percent))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLESAMPLE_ARGUMENT),
errmsg("sample percentage must be between 0 and 100")));
/*
* The cutoff is sample probability times (PG_UINT32_MAX + 1); we have to
* store that as a uint64, of course. Note that this gives strictly
* correct behavior at the limits of zero or one probability.
*/
dcutoff = rint(((double) PG_UINT32_MAX + 1) * percent / 100);
sampler->cutoff = (uint64) dcutoff;
sampler->seed = seed;
sampler->nextblock = 0;
sampler->lt = InvalidOffsetNumber;
/*
* Bulkread buffer access strategy probably makes sense unless we're
* scanning a very small fraction of the table. The 1% cutoff here is a
* guess. We should use pagemode visibility checking, since we scan all
* tuples on each selected page.
*/
node->use_bulkread = (percent >= 1);
node->use_pagemode = true;
}
/*
* Select next block to sample.
*/
static BlockNumber
system_nextsampleblock(SampleScanState *node, BlockNumber nblocks)
{
SystemSamplerData *sampler = (SystemSamplerData *) node->tsm_state;
BlockNumber nextblock = sampler->nextblock;
uint32 hashinput[2];
/*
* We compute the hash by applying hash_any to an array of 2 uint32's
* containing the block number and seed. This is efficient to set up, and
* with the current implementation of hash_any, it gives
* machine-independent results, which is a nice property for regression
* testing.
*
* These words in the hash input are the same throughout the block:
*/
hashinput[1] = sampler->seed;
/*
* Loop over block numbers until finding suitable block or reaching end of
* relation.
*/
for (; nextblock < nblocks; nextblock++)
{
uint32 hash;
hashinput[0] = nextblock;
hash = DatumGetUInt32(hash_any((const unsigned char *) hashinput,
(int) sizeof(hashinput)));
if (hash < sampler->cutoff)
break;
}
if (nextblock < nblocks)
{
/* Found a suitable block; remember where we should start next time */
sampler->nextblock = nextblock + 1;
return nextblock;
}
/* Done, but let's reset nextblock to 0 for safety. */
sampler->nextblock = 0;
return InvalidBlockNumber;
}
/*
* Select next sampled tuple in current block.
*
* In block sampling, we just want to sample all the tuples in each selected
* block.
*
* It is OK here to return an offset without knowing if the tuple is visible
* (or even exists); nodeSamplescan.c will deal with that.
*
* When we reach end of the block, return InvalidOffsetNumber which tells
* SampleScan to go to next block.
*/
static OffsetNumber
system_nextsampletuple(SampleScanState *node,
BlockNumber blockno,
OffsetNumber maxoffset)
{
SystemSamplerData *sampler = (SystemSamplerData *) node->tsm_state;
OffsetNumber tupoffset = sampler->lt;
/* Advance to next possible offset on page */
if (tupoffset == InvalidOffsetNumber)
tupoffset = FirstOffsetNumber;
else
tupoffset++;
/* Done? */
if (tupoffset > maxoffset)
tupoffset = InvalidOffsetNumber;
sampler->lt = tupoffset;
return tupoffset;
}
|
66a117c016f5fcff9fbf5f08efe83decbebbc2e8
|
a3d6556180e74af7b555f8d47d3fea55b94bcbda
|
/third_party/protobuf/php/ext/google/protobuf/convert.h
|
5f3cc077034faa9803cfaa05074b9950627640ff
|
[
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-protobuf",
"GPL-1.0-or-later",
"MIT",
"LGPL-2.0-or-later",
"Apache-2.0"
] |
permissive
|
chromium/chromium
|
aaa9eda10115b50b0616d2f1aed5ef35d1d779d6
|
a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c
|
refs/heads/main
| 2023-08-24T00:35:12.585945
| 2023-08-23T22:01:11
| 2023-08-23T22:01:11
| 120,360,765
| 17,408
| 7,102
|
BSD-3-Clause
| 2023-09-10T23:44:27
| 2018-02-05T20:55:32
| null |
UTF-8
|
C
| false
| false
| 3,219
|
h
|
convert.h
|
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef PHP_PROTOBUF_CONVERT_H_
#define PHP_PROTOBUF_CONVERT_H_
#include <php.h>
#include "php-upb.h"
#include "def.h"
upb_CType pbphp_dtype_to_type(upb_FieldType type);
// Converts |php_val| to an int64_t. Returns false if the value cannot be
// converted.
bool Convert_PhpToInt64(const zval *php_val, int64_t *i64);
// Converts |php_val| to a upb_MessageValue according to |type|. If type is
// kUpb_CType_Message, then |desc| must be the Descriptor for this message type.
// If type is string, message, or bytes, then |arena| will be used to copy
// string data or fuse this arena to the given message's arena.
bool Convert_PhpToUpb(zval *php_val, upb_MessageValue *upb_val, TypeInfo type,
upb_Arena *arena);
// Similar to Convert_PhpToUpb, but supports automatically wrapping the wrapper
// types if a primitive is specified:
//
// 5 -> Int64Wrapper(value=5)
//
// We currently allow this implicit conversion in initializers, but not for
// assignment.
bool Convert_PhpToUpbAutoWrap(zval *val, upb_MessageValue *upb_val, TypeInfo type,
upb_Arena *arena);
// Converts |upb_val| to a PHP zval according to |type|. This may involve
// creating a PHP wrapper object. Any newly created wrapper object
// will reference |arena|.
//
// The caller owns a reference to the returned value.
void Convert_UpbToPhp(upb_MessageValue upb_val, zval *php_val, TypeInfo type,
zval *arena);
// Registers the GPBUtil class.
void Convert_ModuleInit(void);
#endif // PHP_PROTOBUF_CONVERT_H_
|
98a2a2b27c20be19ee3802c3a96bd77b64bc1d4f
|
79d343002bb63a44f8ab0dbac0c9f4ec54078c3a
|
/lib/libc/include/any-linux-any/linux/fiemap.h
|
fe6ff7559612b4adafe15ff38f1beeaedd3828ca
|
[
"MIT"
] |
permissive
|
ziglang/zig
|
4aa75d8d3bcc9e39bf61d265fd84b7f005623fc5
|
f4c9e19bc3213c2bc7e03d7b06d7129882f39f6c
|
refs/heads/master
| 2023-08-31T13:16:45.980913
| 2023-08-31T05:50:29
| 2023-08-31T05:50:29
| 40,276,274
| 25,560
| 2,399
|
MIT
| 2023-09-14T21:09:50
| 2015-08-06T00:51:28
|
Zig
|
UTF-8
|
C
| false
| false
| 2,773
|
h
|
fiemap.h
|
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
/*
* FS_IOC_FIEMAP ioctl infrastructure.
*
* Some portions copyright (C) 2007 Cluster File Systems, Inc
*
* Authors: Mark Fasheh <mfasheh@suse.com>
* Kalpak Shah <kalpak.shah@sun.com>
* Andreas Dilger <adilger@sun.com>
*/
#ifndef _LINUX_FIEMAP_H
#define _LINUX_FIEMAP_H
#include <linux/types.h>
struct fiemap_extent {
__u64 fe_logical; /* logical offset in bytes for the start of
* the extent from the beginning of the file */
__u64 fe_physical; /* physical offset in bytes for the start
* of the extent from the beginning of the disk */
__u64 fe_length; /* length in bytes for this extent */
__u64 fe_reserved64[2];
__u32 fe_flags; /* FIEMAP_EXTENT_* flags for this extent */
__u32 fe_reserved[3];
};
struct fiemap {
__u64 fm_start; /* logical offset (inclusive) at
* which to start mapping (in) */
__u64 fm_length; /* logical length of mapping which
* userspace wants (in) */
__u32 fm_flags; /* FIEMAP_FLAG_* flags for request (in/out) */
__u32 fm_mapped_extents;/* number of extents that were mapped (out) */
__u32 fm_extent_count; /* size of fm_extents array (in) */
__u32 fm_reserved;
struct fiemap_extent fm_extents[]; /* array of mapped extents (out) */
};
#define FIEMAP_MAX_OFFSET (~0ULL)
#define FIEMAP_FLAG_SYNC 0x00000001 /* sync file data before map */
#define FIEMAP_FLAG_XATTR 0x00000002 /* map extended attribute tree */
#define FIEMAP_FLAG_CACHE 0x00000004 /* request caching of the extents */
#define FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR)
#define FIEMAP_EXTENT_LAST 0x00000001 /* Last extent in file. */
#define FIEMAP_EXTENT_UNKNOWN 0x00000002 /* Data location unknown. */
#define FIEMAP_EXTENT_DELALLOC 0x00000004 /* Location still pending.
* Sets EXTENT_UNKNOWN. */
#define FIEMAP_EXTENT_ENCODED 0x00000008 /* Data can not be read
* while fs is unmounted */
#define FIEMAP_EXTENT_DATA_ENCRYPTED 0x00000080 /* Data is encrypted by fs.
* Sets EXTENT_NO_BYPASS. */
#define FIEMAP_EXTENT_NOT_ALIGNED 0x00000100 /* Extent offsets may not be
* block aligned. */
#define FIEMAP_EXTENT_DATA_INLINE 0x00000200 /* Data mixed with metadata.
* Sets EXTENT_NOT_ALIGNED.*/
#define FIEMAP_EXTENT_DATA_TAIL 0x00000400 /* Multiple files in block.
* Sets EXTENT_NOT_ALIGNED.*/
#define FIEMAP_EXTENT_UNWRITTEN 0x00000800 /* Space allocated, but
* no data (i.e. zero). */
#define FIEMAP_EXTENT_MERGED 0x00001000 /* File does not natively
* support extents. Result
* merged for efficiency. */
#define FIEMAP_EXTENT_SHARED 0x00002000 /* Space shared with other
* files. */
#endif /* _LINUX_FIEMAP_H */
|
6f442b399aa45548ecfda986ab5e90a66bf45305
|
9467e2502183e843a67736800199e31674b1d8f6
|
/HybridCLRData/LocalIl2CppData-OSXEditor/il2cpp/libil2cpp/os/Unity/ExtendedAtomicOps.h
|
90af7158a14982d4f3091430ccadd301c32c04a5
|
[
"Apache-2.0"
] |
permissive
|
yimengfan/BDFramework.Core
|
3a046fcd755a84ba55d648dd3ad52c37a1cc1a04
|
81380fce8e84367f912777717665b53f074ab617
|
refs/heads/master
| 2023-09-04T10:08:47.644992
| 2023-07-05T16:22:11
| 2023-07-05T16:22:11
| 85,928,537
| 2,421
| 497
|
Apache-2.0
| 2023-03-21T06:56:21
| 2017-03-23T09:03:48
|
C#
|
UTF-8
|
C
| false
| false
| 7,700
|
h
|
ExtendedAtomicOps.h
|
#pragma once
#include "ExtendedAtomicTypes.h"
UNITY_PLATFORM_BEGIN_NAMESPACE;
enum memory_order_relaxed_t { memory_order_relaxed = 0 };
enum memory_order_acquire_t { memory_order_acquire = 2, memory_order_consume = memory_order_acquire };
enum memory_order_release_t { memory_order_release = 3 };
enum memory_order_acq_rel_t { memory_order_acq_rel = 4 };
enum memory_order_seq_cst_t { memory_order_seq_cst = 5 };
/*
Available atomic functions:
// non-explicit versions, use sequential consistency semantic by default
// atomic load
atomic_word atomic_load (const volatile atomic_word* p);
// atomic store
void atomic_store (volatile atomic_word* p, atomic_word val);
// atomic exchange, returns previous value
atomic_word atomic_exchange (volatile atomic_word* p, atomic_word val);
// atomic compare exchange (strong), returns if the operation succeeded
// and update *oldval with the previous value
// http://en.cppreference.com/w/c/atomic/atomic_compare_exchange
bool atomic_compare_exchange (volatile atomic_word* p, atomic_word* oldval, atomic_word newval);
// atomic fetch then add, returns previous value
atomic_word atomic_fetch_add (volatile atomic_word *p, atomic_word val);
// atomic fetch then sub, returns previous value
atomic_word atomic_fetch_sub (volatile atomic_word *p, atomic_word val);
// explicit versions
// memory fence with <mo> semantic
void atomic_thread_fence (memory_order_t mo);
// atomic load with <mo> semantic
atomic_word atomic_load_explicit (const volatile atomic_word* p, memory_order_t mo);
// atomic store with <mo> semantic
void atomic_store_explicit (volatile atomic_word* p, atomic_word v, memory_order_t mo);
// atomic exchange with <mo> semantic, returns previous value
atomic_word atomic_exchange_explicit (volatile atomic_word* p, atomic_word v, memory_order_t mo);
// on RISC platforms with LoadLinked-StoreConditional available:
// atomic_compare_exchange_weak_explicit: can fail spuriously even if *p == *oldval
// uses <success> memory barrier when it succeeds, <failure> otherwize
// returns the state of the operation and updates *oldval with the previous value
// http://en.cppreference.com/w/c/atomic/atomic_compare_exchange
bool atomic_compare_exchange_weak_explicit (volatile atomic_word* p, atomic_word *oldval, atomic_word newval, memory_order_t success, memory_order_t failure);
// atomic_compare_exchange_strong_explicit: can loop and only returns false if *p != *oldval
// uses <success> memory barrier when it succeeds, <failure> otherwise
// returns the state of the operation and updates *oldval with the previous value
// http://en.cppreference.com/w/c/atomic/atomic_compare_exchange
bool atomic_compare_exchange_strong_explicit (volatile atomic_word* p, atomic_word *oldval, atomic_word newval, memory_order_t success, memory_order_t failure);
// atomic fetch then add with <mo> semantic, returns previous value
int atomic_fetch_add_explicit (volatile int* p, int val, memory_order_t mo);
atomic_word atomic_fetch_add_explicit (volatile atomic_word* p, atomic_word val, memory_order_t mo);
// atomic fetch then sub with <mo> semantic, returns previous value
int atomic_fetch_sub_explicit (volatile int* p, int val, memory_order_t mo);
atomic_word atomic_fetch_sub_explicit (volatile atomic_word* p, atomic_word val, memory_order_t mo);
// extensions to the C++0x11 standard:
// atomic increment with relaxed semantic
void atomic_retain (volatile int *p);
// atomic decrement with acquire/release semantic, returns true if resulting value is zero, false otherwize
bool atomic_release (volatile int *p);
// on platforms with double word compare exchange (ABA safe atomic pointers):
// atomic load
atomic_word2 atomic_load_explicit (const volatile atomic_word2* p, memory_order_t mo);
// atomic store
void atomic_store_explicit (volatile atomic_word2* p, atomic_word2 v, memory_order_t mo);
// atomic exchange
atomic_word2 atomic_exchange_explicit (volatile atomic_word2* p, atomic_word2 newval, memory_order_t mo);
// atomic compare exchange
bool atomic_compare_exchange_strong_explicit (volatile atomic_word2* p, atomic_word2* oldval, atomic_word2 newval, memory_order_t success, memory_order_t failure);
*/
#if IL2CPP_TARGET_HAS_EXTENDED_ATOMICS
# include "os/ExtendedAtomicOps.h"
#elif UNITY_ATOMIC_USE_GCC_ATOMICS || UNITY_ATOMIC_USE_CLANG_ATOMICS
# include "ExtendedAtomicOps-clang-gcc.h"
#elif defined(__x86_64__) || defined(_M_X64)
# include "ExtendedAtomicOps-x86-64.h"
#elif defined(__x86__) || defined(__i386__) || defined(_M_IX86)
# include "ExtendedAtomicOps-x86.h"
#elif (defined(__arm64__) || defined(__aarch64__)) && (defined(__clang__) || defined(__GNUC__))
# include "ExtendedAtomicOps-arm64.h"
#elif defined(_M_ARM64)
# include "ExtendedAtomicOps-arm64-windows.h"
#elif defined(_M_ARM) || (defined(__arm__) && (defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__)) && (defined(__clang__) || defined(__GNUC__)))
# include "ExtendedAtomicOps-arm.h"
#else
#define UNITY_NO_ATOMIC_OPS
static inline atomic_word atomic_load_explicit(const volatile atomic_word* p, memory_order_relaxed_t)
{
return *p;
}
static inline void atomic_store_explicit(volatile atomic_word* p, atomic_word v, memory_order_relaxed_t)
{
*p = v;
}
#endif
#ifndef UNITY_NO_ATOMIC_OPS
// non-explicit versions, use sequential consistency semantic
static inline void atomic_thread_fence()
{
atomic_thread_fence(memory_order_seq_cst);
}
static inline atomic_word atomic_load(const volatile atomic_word* p)
{
return atomic_load_explicit(p, memory_order_seq_cst);
}
static inline void atomic_store(volatile atomic_word* p, atomic_word val)
{
atomic_store_explicit(p, val, memory_order_seq_cst);
}
static inline atomic_word atomic_exchange(volatile atomic_word* p, atomic_word val)
{
return atomic_exchange_explicit(p, val, memory_order_seq_cst);
}
static inline bool atomic_compare_exchange(volatile atomic_word* p, atomic_word* oldval, atomic_word newval)
{
return atomic_compare_exchange_strong_explicit(p, oldval, newval, memory_order_seq_cst, memory_order_seq_cst);
}
static inline atomic_word atomic_fetch_add(volatile atomic_word *p, atomic_word val)
{
return atomic_fetch_add_explicit(p, val, memory_order_seq_cst);
}
static inline atomic_word atomic_fetch_sub(volatile atomic_word *p, atomic_word val)
{
return atomic_fetch_sub_explicit(p, val, memory_order_seq_cst);
}
#if defined(UNITY_ATOMIC_INT_OVERLOAD)
static inline int atomic_load(const volatile int* p)
{
return atomic_load_explicit(p, memory_order_seq_cst);
}
static inline void atomic_store(volatile int* p, int val)
{
atomic_store_explicit(p, val, memory_order_seq_cst);
}
static inline int atomic_exchange(volatile int* p, int val)
{
return atomic_exchange_explicit(p, val, memory_order_seq_cst);
}
static inline bool atomic_compare_exchange(volatile int* p, int* oldval, int newval)
{
return atomic_compare_exchange_strong_explicit(p, oldval, newval, memory_order_seq_cst, memory_order_seq_cst);
}
static inline int atomic_fetch_add(volatile int *p, int val)
{
return static_cast<int>(atomic_fetch_add_explicit(p, val, memory_order_seq_cst));
}
static inline int atomic_fetch_sub(volatile int *p, int val)
{
return static_cast<int>(atomic_fetch_sub_explicit(p, val, memory_order_seq_cst));
}
#endif
#endif
UNITY_PLATFORM_END_NAMESPACE;
|
d73025903c9b33c7a5b301fa527bd4e3af9ee8ae
|
85af3e305e5bcd7e42ea9c269afbeb8d8049e8fe
|
/N64SoundListToolUpdated/N64SoundLibrary/SoundToolExports.h
|
fff74f155cf89b341b3c93ad2f7a993a07340959
|
[
"Unlicense"
] |
permissive
|
jombo23/N64-Tools
|
d5729bf7c2c0b898b0ee66d610bfd34fdd83d9fb
|
4d935fdd48230ddd0cb5bd3739106e6765cac01e
|
refs/heads/master
| 2023-05-11T20:31:30.723225
| 2023-05-09T01:23:39
| 2023-05-09T01:23:39
| 148,819,274
| 229
| 150
|
Unlicense
| 2022-11-26T17:00:56
| 2018-09-14T17:11:31
|
C++
|
UTF-8
|
C
| false
| false
| 186
|
h
|
SoundToolExports.h
|
#ifdef DLL_CONFIG
#ifdef SOUNDTOOL_EXPORTS
#define SOUNDTOOL_API __declspec(dllexport)
#else
#define SOUNDTOOL_API __declspec(dllimport)
#endif
#else
#define SOUNDTOOL_API
#endif
|
795eac188580e9e7817f754bfa94fe3a3ca9d512
|
f085956afa0ff005e887a079eab410242865d831
|
/thirdparty/mbedtls/include/mbedtls/config_psa.h
|
2a6672e17a2a5e7a884184ed92c9ca3677c6cf0b
|
[
"MIT",
"Apache-2.0",
"GPL-2.0-or-later"
] |
permissive
|
vlang/v
|
844f108863477626a61bd7580a7fb8f3365ec3e5
|
93d54651b5aae1299239d30b1276439d8c142d88
|
refs/heads/master
| 2023-09-01T05:13:11.841452
| 2023-08-31T23:04:58
| 2023-08-31T23:04:58
| 169,677,297
| 38,639
| 3,871
|
MIT
| 2023-09-14T21:45:03
| 2019-02-08T02:57:06
|
V
|
UTF-8
|
C
| false
| false
| 27,140
|
h
|
config_psa.h
|
/**
* \file mbedtls/config_psa.h
* \brief PSA crypto configuration options (set of defines)
*
* This set of compile-time options takes settings defined in
* include/mbedtls/mbedtls_config.h and include/psa/crypto_config.h and uses
* those definitions to define symbols used in the library code.
*
* Users and integrators should not edit this file, please edit
* include/mbedtls/mbedtls_config.h for MBETLS_XXX settings or
* include/psa/crypto_config.h for PSA_WANT_XXX settings.
*/
/*
* Copyright The Mbed TLS Contributors
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MBEDTLS_CONFIG_PSA_H
#define MBEDTLS_CONFIG_PSA_H
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG_FILE)
#include MBEDTLS_PSA_CRYPTO_CONFIG_FILE
#else
#include "psa/crypto_config.h"
#endif
#endif /* defined(MBEDTLS_PSA_CRYPTO_CONFIG) */
#if defined(MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE)
#include MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE
#endif
#ifdef __cplusplus
extern "C" {
#endif
/****************************************************************/
/* De facto synonyms */
/****************************************************************/
#if defined(PSA_WANT_ALG_ECDSA_ANY) && !defined(PSA_WANT_ALG_ECDSA)
#define PSA_WANT_ALG_ECDSA PSA_WANT_ALG_ECDSA_ANY
#elif !defined(PSA_WANT_ALG_ECDSA_ANY) && defined(PSA_WANT_ALG_ECDSA)
#define PSA_WANT_ALG_ECDSA_ANY PSA_WANT_ALG_ECDSA
#endif
#if defined(PSA_WANT_ALG_CCM_STAR_NO_TAG) && !defined(PSA_WANT_ALG_CCM)
#define PSA_WANT_ALG_CCM PSA_WANT_ALG_CCM_STAR_NO_TAG
#elif !defined(PSA_WANT_ALG_CCM_STAR_NO_TAG) && defined(PSA_WANT_ALG_CCM)
#define PSA_WANT_ALG_CCM_STAR_NO_TAG PSA_WANT_ALG_CCM
#endif
#if defined(PSA_WANT_ALG_RSA_PKCS1V15_SIGN_RAW) && !defined(PSA_WANT_ALG_RSA_PKCS1V15_SIGN)
#define PSA_WANT_ALG_RSA_PKCS1V15_SIGN PSA_WANT_ALG_RSA_PKCS1V15_SIGN_RAW
#elif !defined(PSA_WANT_ALG_RSA_PKCS1V15_SIGN_RAW) && defined(PSA_WANT_ALG_RSA_PKCS1V15_SIGN)
#define PSA_WANT_ALG_RSA_PKCS1V15_SIGN_RAW PSA_WANT_ALG_RSA_PKCS1V15_SIGN
#endif
#if defined(PSA_WANT_ALG_RSA_PSS_ANY_SALT) && !defined(PSA_WANT_ALG_RSA_PSS)
#define PSA_WANT_ALG_RSA_PSS PSA_WANT_ALG_RSA_PSS_ANY_SALT
#elif !defined(PSA_WANT_ALG_RSA_PSS_ANY_SALT) && defined(PSA_WANT_ALG_RSA_PSS)
#define PSA_WANT_ALG_RSA_PSS_ANY_SALT PSA_WANT_ALG_RSA_PSS
#endif
/****************************************************************/
/* Require built-in implementations based on PSA requirements */
/****************************************************************/
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
#if defined(PSA_WANT_ALG_DETERMINISTIC_ECDSA)
#if !defined(MBEDTLS_PSA_ACCEL_ALG_DETERMINISTIC_ECDSA)
#define MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA 1
#define MBEDTLS_ECDSA_DETERMINISTIC
#define MBEDTLS_ECDSA_C
#define MBEDTLS_HMAC_DRBG_C
#define MBEDTLS_MD_C
#endif /* !MBEDTLS_PSA_ACCEL_ALG_DETERMINISTIC_ECDSA */
#endif /* PSA_WANT_ALG_DETERMINISTIC_ECDSA */
#if defined(PSA_WANT_ALG_ECDH)
#if !defined(MBEDTLS_PSA_ACCEL_ALG_ECDH)
#define MBEDTLS_PSA_BUILTIN_ALG_ECDH 1
#define MBEDTLS_ECDH_C
#define MBEDTLS_ECP_C
#define MBEDTLS_BIGNUM_C
#endif /* !MBEDTLS_PSA_ACCEL_ALG_ECDH */
#endif /* PSA_WANT_ALG_ECDH */
#if defined(PSA_WANT_ALG_ECDSA)
#if !defined(MBEDTLS_PSA_ACCEL_ALG_ECDSA)
#define MBEDTLS_PSA_BUILTIN_ALG_ECDSA 1
#define MBEDTLS_ECDSA_C
#define MBEDTLS_ECP_C
#define MBEDTLS_BIGNUM_C
#define MBEDTLS_ASN1_PARSE_C
#define MBEDTLS_ASN1_WRITE_C
#endif /* !MBEDTLS_PSA_ACCEL_ALG_ECDSA */
#endif /* PSA_WANT_ALG_ECDSA */
#if defined(PSA_WANT_ALG_HKDF)
#if !defined(MBEDTLS_PSA_ACCEL_ALG_HKDF)
#define MBEDTLS_PSA_BUILTIN_ALG_HMAC 1
#define MBEDTLS_PSA_BUILTIN_ALG_HKDF 1
#endif /* !MBEDTLS_PSA_ACCEL_ALG_HKDF */
#endif /* PSA_WANT_ALG_HKDF */
#if defined(PSA_WANT_ALG_HKDF_EXTRACT)
#if !defined(MBEDTLS_PSA_ACCEL_ALG_HKDF_EXTRACT)
#define MBEDTLS_PSA_BUILTIN_ALG_HMAC 1
#define MBEDTLS_PSA_BUILTIN_ALG_HKDF_EXTRACT 1
#endif /* !MBEDTLS_PSA_ACCEL_ALG_HKDF_EXTRACT */
#endif /* PSA_WANT_ALG_HKDF_EXTRACT */
#if defined(PSA_WANT_ALG_HKDF_EXPAND)
#if !defined(MBEDTLS_PSA_ACCEL_ALG_HKDF_EXPAND)
#define MBEDTLS_PSA_BUILTIN_ALG_HMAC 1
#define MBEDTLS_PSA_BUILTIN_ALG_HKDF_EXPAND 1
#endif /* !MBEDTLS_PSA_ACCEL_ALG_HKDF_EXPAND */
#endif /* PSA_WANT_ALG_HKDF_EXPAND */
#if defined(PSA_WANT_ALG_HMAC)
#if !defined(MBEDTLS_PSA_ACCEL_ALG_HMAC)
#define MBEDTLS_PSA_BUILTIN_ALG_HMAC 1
#endif /* !MBEDTLS_PSA_ACCEL_ALG_HMAC */
#endif /* PSA_WANT_ALG_HMAC */
#if defined(PSA_WANT_ALG_MD5) && !defined(MBEDTLS_PSA_ACCEL_ALG_MD5)
#define MBEDTLS_PSA_BUILTIN_ALG_MD5 1
#define MBEDTLS_MD5_C
#endif
#if defined(PSA_WANT_ALG_RIPEMD160) && !defined(MBEDTLS_PSA_ACCEL_ALG_RIPEMD160)
#define MBEDTLS_PSA_BUILTIN_ALG_RIPEMD160 1
#define MBEDTLS_RIPEMD160_C
#endif
#if defined(PSA_WANT_ALG_RSA_OAEP)
#if !defined(MBEDTLS_PSA_ACCEL_ALG_RSA_OAEP)
#define MBEDTLS_PSA_BUILTIN_ALG_RSA_OAEP 1
#define MBEDTLS_RSA_C
#define MBEDTLS_BIGNUM_C
#define MBEDTLS_OID_C
#define MBEDTLS_PKCS1_V21
#define MBEDTLS_MD_C
#endif /* !MBEDTLS_PSA_ACCEL_ALG_RSA_OAEP */
#endif /* PSA_WANT_ALG_RSA_OAEP */
#if defined(PSA_WANT_ALG_RSA_PKCS1V15_CRYPT)
#if !defined(MBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_CRYPT)
#define MBEDTLS_PSA_BUILTIN_ALG_RSA_PKCS1V15_CRYPT 1
#define MBEDTLS_RSA_C
#define MBEDTLS_BIGNUM_C
#define MBEDTLS_OID_C
#define MBEDTLS_PKCS1_V15
#endif /* !MBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_CRYPT */
#endif /* PSA_WANT_ALG_RSA_PKCS1V15_CRYPT */
#if defined(PSA_WANT_ALG_RSA_PKCS1V15_SIGN)
#if !defined(MBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_SIGN)
#define MBEDTLS_PSA_BUILTIN_ALG_RSA_PKCS1V15_SIGN 1
#define MBEDTLS_RSA_C
#define MBEDTLS_BIGNUM_C
#define MBEDTLS_OID_C
#define MBEDTLS_PKCS1_V15
#define MBEDTLS_MD_C
#endif /* !MBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_SIGN */
#endif /* PSA_WANT_ALG_RSA_PKCS1V15_SIGN */
#if defined(PSA_WANT_ALG_RSA_PSS)
#if !defined(MBEDTLS_PSA_ACCEL_ALG_RSA_PSS)
#define MBEDTLS_PSA_BUILTIN_ALG_RSA_PSS 1
#define MBEDTLS_RSA_C
#define MBEDTLS_BIGNUM_C
#define MBEDTLS_OID_C
#define MBEDTLS_PKCS1_V21
#define MBEDTLS_MD_C
#endif /* !MBEDTLS_PSA_ACCEL_ALG_RSA_PSS */
#endif /* PSA_WANT_ALG_RSA_PSS */
#if defined(PSA_WANT_ALG_SHA_1) && !defined(MBEDTLS_PSA_ACCEL_ALG_SHA_1)
#define MBEDTLS_PSA_BUILTIN_ALG_SHA_1 1
#define MBEDTLS_SHA1_C
#endif
#if defined(PSA_WANT_ALG_SHA_224) && !defined(MBEDTLS_PSA_ACCEL_ALG_SHA_224)
#define MBEDTLS_PSA_BUILTIN_ALG_SHA_224 1
#define MBEDTLS_SHA224_C
#endif
#if defined(PSA_WANT_ALG_SHA_256) && !defined(MBEDTLS_PSA_ACCEL_ALG_SHA_256)
#define MBEDTLS_PSA_BUILTIN_ALG_SHA_256 1
#define MBEDTLS_SHA256_C
#endif
#if defined(PSA_WANT_ALG_SHA_384) && !defined(MBEDTLS_PSA_ACCEL_ALG_SHA_384)
#define MBEDTLS_PSA_BUILTIN_ALG_SHA_384 1
#define MBEDTLS_SHA384_C
#endif
#if defined(PSA_WANT_ALG_SHA_512) && !defined(MBEDTLS_PSA_ACCEL_ALG_SHA_512)
#define MBEDTLS_PSA_BUILTIN_ALG_SHA_512 1
#define MBEDTLS_SHA512_C
#endif
#if defined(PSA_WANT_ALG_TLS12_PRF)
#if !defined(MBEDTLS_PSA_ACCEL_ALG_TLS12_PRF)
#define MBEDTLS_PSA_BUILTIN_ALG_TLS12_PRF 1
#endif /* !MBEDTLS_PSA_ACCEL_ALG_TLS12_PRF */
#endif /* PSA_WANT_ALG_TLS12_PRF */
#if defined(PSA_WANT_ALG_TLS12_PSK_TO_MS)
#if !defined(MBEDTLS_PSA_ACCEL_ALG_TLS12_PSK_TO_MS)
#define MBEDTLS_PSA_BUILTIN_ALG_TLS12_PSK_TO_MS 1
#endif /* !MBEDTLS_PSA_ACCEL_ALG_TLS12_PSK_TO_MS */
#endif /* PSA_WANT_ALG_TLS12_PSK_TO_MS */
#if defined(PSA_WANT_KEY_TYPE_ECC_KEY_PAIR)
#if !defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR)
#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_KEY_PAIR 1
#define MBEDTLS_ECP_C
#define MBEDTLS_BIGNUM_C
#endif /* !MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR */
#endif /* PSA_WANT_KEY_TYPE_ECC_KEY_PAIR */
#if defined(PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY)
#if !defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_PUBLIC_KEY)
#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_PUBLIC_KEY 1
#define MBEDTLS_ECP_C
#define MBEDTLS_BIGNUM_C
#endif /* !MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_PUBLIC_KEY */
#endif /* PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY */
#if defined(PSA_WANT_KEY_TYPE_RSA_KEY_PAIR)
#if !defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_KEY_PAIR)
#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_KEY_PAIR 1
#define MBEDTLS_RSA_C
#define MBEDTLS_BIGNUM_C
#define MBEDTLS_OID_C
#define MBEDTLS_GENPRIME
#define MBEDTLS_PK_PARSE_C
#define MBEDTLS_PK_WRITE_C
#define MBEDTLS_PK_C
#define MBEDTLS_ASN1_PARSE_C
#define MBEDTLS_ASN1_WRITE_C
#endif /* !MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_KEY_PAIR */
#endif /* PSA_WANT_KEY_TYPE_RSA_KEY_PAIR */
#if defined(PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY)
#if !defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_PUBLIC_KEY)
#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_PUBLIC_KEY 1
#define MBEDTLS_RSA_C
#define MBEDTLS_BIGNUM_C
#define MBEDTLS_OID_C
#define MBEDTLS_PK_PARSE_C
#define MBEDTLS_PK_WRITE_C
#define MBEDTLS_PK_C
#define MBEDTLS_ASN1_PARSE_C
#define MBEDTLS_ASN1_WRITE_C
#endif /* !MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_PUBLIC_KEY */
#endif /* PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY */
/* If any of the block modes are requested that don't have an
* associated HW assist, define PSA_HAVE_SOFT_BLOCK_MODE for checking
* in the block cipher key types. */
#if (defined(PSA_WANT_ALG_CTR) && !defined(MBEDTLS_PSA_ACCEL_ALG_CTR)) || \
(defined(PSA_WANT_ALG_CFB) && !defined(MBEDTLS_PSA_ACCEL_ALG_CFB)) || \
(defined(PSA_WANT_ALG_OFB) && !defined(MBEDTLS_PSA_ACCEL_ALG_OFB)) || \
defined(PSA_WANT_ALG_ECB_NO_PADDING) || \
(defined(PSA_WANT_ALG_CBC_NO_PADDING) && \
!defined(MBEDTLS_PSA_ACCEL_ALG_CBC_NO_PADDING)) || \
(defined(PSA_WANT_ALG_CBC_PKCS7) && \
!defined(MBEDTLS_PSA_ACCEL_ALG_CBC_PKCS7)) || \
(defined(PSA_WANT_ALG_CMAC) && !defined(MBEDTLS_PSA_ACCEL_ALG_CMAC))
#define PSA_HAVE_SOFT_BLOCK_MODE 1
#endif
#if (defined(PSA_WANT_ALG_GCM) && !defined(MBEDTLS_PSA_ACCEL_ALG_GCM)) || \
(defined(PSA_WANT_ALG_CCM) && !defined(MBEDTLS_PSA_ACCEL_ALG_CCM))
#define PSA_HAVE_SOFT_BLOCK_AEAD 1
#endif
#if defined(PSA_WANT_KEY_TYPE_AES)
#if !defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_AES)
#define PSA_HAVE_SOFT_KEY_TYPE_AES 1
#endif /* !MBEDTLS_PSA_ACCEL_KEY_TYPE_AES */
#if defined(PSA_HAVE_SOFT_KEY_TYPE_AES) || \
defined(PSA_HAVE_SOFT_BLOCK_MODE) || \
defined(PSA_HAVE_SOFT_BLOCK_AEAD)
#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_AES 1
#define MBEDTLS_AES_C
#endif /* PSA_HAVE_SOFT_KEY_TYPE_AES || PSA_HAVE_SOFT_BLOCK_MODE */
#endif /* PSA_WANT_KEY_TYPE_AES */
#if defined(PSA_WANT_KEY_TYPE_ARIA)
#if !defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ARIA)
#define PSA_HAVE_SOFT_KEY_TYPE_ARIA 1
#endif /* !MBEDTLS_PSA_ACCEL_KEY_TYPE_ARIA */
#if defined(PSA_HAVE_SOFT_KEY_TYPE_ARIA) || \
defined(PSA_HAVE_SOFT_BLOCK_MODE) || \
defined(PSA_HAVE_SOFT_BLOCK_AEAD)
#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_ARIA 1
#define MBEDTLS_ARIA_C
#endif /* PSA_HAVE_SOFT_KEY_TYPE_ARIA || PSA_HAVE_SOFT_BLOCK_MODE */
#endif /* PSA_WANT_KEY_TYPE_ARIA */
#if defined(PSA_WANT_KEY_TYPE_CAMELLIA)
#if !defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_CAMELLIA)
#define PSA_HAVE_SOFT_KEY_TYPE_CAMELLIA 1
#endif /* !MBEDTLS_PSA_ACCEL_KEY_TYPE_CAMELLIA */
#if defined(PSA_HAVE_SOFT_KEY_TYPE_CAMELLIA) || \
defined(PSA_HAVE_SOFT_BLOCK_MODE) || \
defined(PSA_HAVE_SOFT_BLOCK_AEAD)
#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_CAMELLIA 1
#define MBEDTLS_CAMELLIA_C
#endif /* PSA_HAVE_SOFT_KEY_TYPE_CAMELLIA || PSA_HAVE_SOFT_BLOCK_MODE */
#endif /* PSA_WANT_KEY_TYPE_CAMELLIA */
#if defined(PSA_WANT_KEY_TYPE_DES)
#if !defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_DES)
#define PSA_HAVE_SOFT_KEY_TYPE_DES 1
#endif /* !MBEDTLS_PSA_ACCEL_KEY_TYPE_DES */
#if defined(PSA_HAVE_SOFT_KEY_TYPE_DES) || \
defined(PSA_HAVE_SOFT_BLOCK_MODE)
#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_DES 1
#define MBEDTLS_DES_C
#endif /*PSA_HAVE_SOFT_KEY_TYPE_DES || PSA_HAVE_SOFT_BLOCK_MODE */
#endif /* PSA_WANT_KEY_TYPE_DES */
#if defined(PSA_WANT_KEY_TYPE_CHACHA20)
#if !defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_CHACHA20)
#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_CHACHA20 1
#define MBEDTLS_CHACHA20_C
#endif /*!MBEDTLS_PSA_ACCEL_KEY_TYPE_CHACHA20 */
#endif /* PSA_WANT_KEY_TYPE_CHACHA20 */
/* If any of the software block ciphers are selected, define
* PSA_HAVE_SOFT_BLOCK_CIPHER, which can be used in any of these
* situations. */
#if defined(PSA_HAVE_SOFT_KEY_TYPE_AES) || \
defined(PSA_HAVE_SOFT_KEY_TYPE_ARIA) || \
defined(PSA_HAVE_SOFT_KEY_TYPE_DES) || \
defined(PSA_HAVE_SOFT_KEY_TYPE_CAMELLIA)
#define PSA_HAVE_SOFT_BLOCK_CIPHER 1
#endif
#if defined(PSA_WANT_ALG_STREAM_CIPHER)
#define MBEDTLS_PSA_BUILTIN_ALG_STREAM_CIPHER 1
#endif /* PSA_WANT_ALG_STREAM_CIPHER */
#if defined(PSA_WANT_ALG_CBC_MAC)
#if !defined(MBEDTLS_PSA_ACCEL_ALG_CBC_MAC)
#error "CBC-MAC is not yet supported via the PSA API in Mbed TLS."
#define MBEDTLS_PSA_BUILTIN_ALG_CBC_MAC 1
#endif /* !MBEDTLS_PSA_ACCEL_ALG_CBC_MAC */
#endif /* PSA_WANT_ALG_CBC_MAC */
#if defined(PSA_WANT_ALG_CMAC)
#if !defined(MBEDTLS_PSA_ACCEL_ALG_CMAC) || \
defined(PSA_HAVE_SOFT_BLOCK_CIPHER)
#define MBEDTLS_PSA_BUILTIN_ALG_CMAC 1
#define MBEDTLS_CMAC_C
#endif /* !MBEDTLS_PSA_ACCEL_ALG_CMAC */
#endif /* PSA_WANT_ALG_CMAC */
#if defined(PSA_WANT_ALG_CTR)
#if !defined(MBEDTLS_PSA_ACCEL_ALG_CTR) || \
defined(PSA_HAVE_SOFT_BLOCK_CIPHER)
#define MBEDTLS_PSA_BUILTIN_ALG_CTR 1
#define MBEDTLS_CIPHER_MODE_CTR
#endif
#endif /* PSA_WANT_ALG_CTR */
#if defined(PSA_WANT_ALG_CFB)
#if !defined(MBEDTLS_PSA_ACCEL_ALG_CFB) || \
defined(PSA_HAVE_SOFT_BLOCK_CIPHER)
#define MBEDTLS_PSA_BUILTIN_ALG_CFB 1
#define MBEDTLS_CIPHER_MODE_CFB
#endif
#endif /* PSA_WANT_ALG_CFB */
#if defined(PSA_WANT_ALG_OFB)
#if !defined(MBEDTLS_PSA_ACCEL_ALG_OFB) || \
defined(PSA_HAVE_SOFT_BLOCK_CIPHER)
#define MBEDTLS_PSA_BUILTIN_ALG_OFB 1
#define MBEDTLS_CIPHER_MODE_OFB
#endif
#endif /* PSA_WANT_ALG_OFB */
#if defined(PSA_WANT_ALG_ECB_NO_PADDING) && \
!defined(MBEDTLS_PSA_ACCEL_ALG_ECB_NO_PADDING)
#define MBEDTLS_PSA_BUILTIN_ALG_ECB_NO_PADDING 1
#endif
#if defined(PSA_WANT_ALG_CBC_NO_PADDING)
#if !defined(MBEDTLS_PSA_ACCEL_ALG_CBC_NO_PADDING) || \
defined(PSA_HAVE_SOFT_BLOCK_CIPHER)
#define MBEDTLS_CIPHER_MODE_CBC
#define MBEDTLS_PSA_BUILTIN_ALG_CBC_NO_PADDING 1
#endif
#endif /* PSA_WANT_ALG_CBC_NO_PADDING */
#if defined(PSA_WANT_ALG_CBC_PKCS7)
#if !defined(MBEDTLS_PSA_ACCEL_ALG_CBC_PKCS7) || \
defined(PSA_HAVE_SOFT_BLOCK_CIPHER)
#define MBEDTLS_CIPHER_MODE_CBC
#define MBEDTLS_PSA_BUILTIN_ALG_CBC_PKCS7 1
#define MBEDTLS_CIPHER_PADDING_PKCS7
#endif
#endif /* PSA_WANT_ALG_CBC_PKCS7 */
#if defined(PSA_WANT_ALG_CCM)
#if !defined(MBEDTLS_PSA_ACCEL_ALG_CCM) || \
defined(PSA_HAVE_SOFT_KEY_TYPE_AES) || \
defined(PSA_HAVE_SOFT_KEY_TYPE_ARIA) || \
defined(PSA_HAVE_SOFT_KEY_TYPE_CAMELLIA)
#define MBEDTLS_PSA_BUILTIN_ALG_CCM 1
#define MBEDTLS_PSA_BUILTIN_ALG_CCM_STAR_NO_TAG 1
#define MBEDTLS_CCM_C
#endif
#endif /* PSA_WANT_ALG_CCM */
#if defined(PSA_WANT_ALG_GCM)
#if !defined(MBEDTLS_PSA_ACCEL_ALG_GCM) || \
defined(PSA_HAVE_SOFT_KEY_TYPE_AES) || \
defined(PSA_HAVE_SOFT_KEY_TYPE_ARIA) || \
defined(PSA_HAVE_SOFT_KEY_TYPE_CAMELLIA)
#define MBEDTLS_PSA_BUILTIN_ALG_GCM 1
#define MBEDTLS_GCM_C
#endif
#endif /* PSA_WANT_ALG_GCM */
#if defined(PSA_WANT_ALG_CHACHA20_POLY1305)
#if !defined(MBEDTLS_PSA_ACCEL_ALG_CHACHA20_POLY1305)
#if defined(PSA_WANT_KEY_TYPE_CHACHA20)
#define MBEDTLS_CHACHAPOLY_C
#define MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 1
#endif /* PSA_WANT_KEY_TYPE_CHACHA20 */
#endif /* !MBEDTLS_PSA_ACCEL_ALG_CHACHA20_POLY1305 */
#endif /* PSA_WANT_ALG_CHACHA20_POLY1305 */
#if defined(PSA_WANT_ECC_BRAINPOOL_P_R1_256)
#if !defined(MBEDTLS_PSA_ACCEL_ECC_BRAINPOOL_P_R1_256)
#define MBEDTLS_ECP_DP_BP256R1_ENABLED
#define MBEDTLS_PSA_BUILTIN_ECC_BRAINPOOL_P_R1_256 1
#endif /* !MBEDTLS_PSA_ACCEL_ECC_BRAINPOOL_P_R1_256 */
#endif /* PSA_WANT_ECC_BRAINPOOL_P_R1_256 */
#if defined(PSA_WANT_ECC_BRAINPOOL_P_R1_384)
#if !defined(MBEDTLS_PSA_ACCEL_ECC_BRAINPOOL_P_R1_384)
#define MBEDTLS_ECP_DP_BP384R1_ENABLED
#define MBEDTLS_PSA_BUILTIN_ECC_BRAINPOOL_P_R1_384 1
#endif /* !MBEDTLS_PSA_ACCEL_ECC_BRAINPOOL_P_R1_384 */
#endif /* PSA_WANT_ECC_BRAINPOOL_P_R1_384 */
#if defined(PSA_WANT_ECC_BRAINPOOL_P_R1_512)
#if !defined(MBEDTLS_PSA_ACCEL_ECC_BRAINPOOL_P_R1_512)
#define MBEDTLS_ECP_DP_BP512R1_ENABLED
#define MBEDTLS_PSA_BUILTIN_ECC_BRAINPOOL_P_R1_512 1
#endif /* !MBEDTLS_PSA_ACCEL_ECC_BRAINPOOL_P_R1_512 */
#endif /* PSA_WANT_ECC_BRAINPOOL_P_R1_512 */
#if defined(PSA_WANT_ECC_MONTGOMERY_255)
#if !defined(MBEDTLS_PSA_ACCEL_ECC_MONTGOMERY_255)
#define MBEDTLS_ECP_DP_CURVE25519_ENABLED
#define MBEDTLS_PSA_BUILTIN_ECC_MONTGOMERY_255 1
#endif /* !MBEDTLS_PSA_ACCEL_ECC_MONTGOMERY_255 */
#endif /* PSA_WANT_ECC_MONTGOMERY_255 */
#if defined(PSA_WANT_ECC_MONTGOMERY_448)
#if !defined(MBEDTLS_PSA_ACCEL_ECC_MONTGOMERY_448)
#define MBEDTLS_ECP_DP_CURVE448_ENABLED
#define MBEDTLS_PSA_BUILTIN_ECC_MONTGOMERY_448 1
#endif /* !MBEDTLS_PSA_ACCEL_ECC_MONTGOMERY_448 */
#endif /* PSA_WANT_ECC_MONTGOMERY_448 */
#if defined(PSA_WANT_ECC_SECP_R1_192)
#if !defined(MBEDTLS_PSA_ACCEL_ECC_SECP_R1_192)
#define MBEDTLS_ECP_DP_SECP192R1_ENABLED
#define MBEDTLS_PSA_BUILTIN_ECC_SECP_R1_192 1
#endif /* !MBEDTLS_PSA_ACCEL_ECC_SECP_R1_192 */
#endif /* PSA_WANT_ECC_SECP_R1_192 */
#if defined(PSA_WANT_ECC_SECP_R1_224)
#if !defined(MBEDTLS_PSA_ACCEL_ECC_SECP_R1_224)
#define MBEDTLS_ECP_DP_SECP224R1_ENABLED
#define MBEDTLS_PSA_BUILTIN_ECC_SECP_R1_224 1
#endif /* !MBEDTLS_PSA_ACCEL_ECC_SECP_R1_224 */
#endif /* PSA_WANT_ECC_SECP_R1_224 */
#if defined(PSA_WANT_ECC_SECP_R1_256)
#if !defined(MBEDTLS_PSA_ACCEL_ECC_SECP_R1_256)
#define MBEDTLS_ECP_DP_SECP256R1_ENABLED
#define MBEDTLS_PSA_BUILTIN_ECC_SECP_R1_256 1
#endif /* !MBEDTLS_PSA_ACCEL_ECC_SECP_R1_256 */
#endif /* PSA_WANT_ECC_SECP_R1_256 */
#if defined(PSA_WANT_ECC_SECP_R1_384)
#if !defined(MBEDTLS_PSA_ACCEL_ECC_SECP_R1_384)
#define MBEDTLS_ECP_DP_SECP384R1_ENABLED
#define MBEDTLS_PSA_BUILTIN_ECC_SECP_R1_384 1
#endif /* !MBEDTLS_PSA_ACCEL_ECC_SECP_R1_384 */
#endif /* PSA_WANT_ECC_SECP_R1_384 */
#if defined(PSA_WANT_ECC_SECP_R1_521)
#if !defined(MBEDTLS_PSA_ACCEL_ECC_SECP_R1_521)
#define MBEDTLS_ECP_DP_SECP521R1_ENABLED
#define MBEDTLS_PSA_BUILTIN_ECC_SECP_R1_521 1
#endif /* !MBEDTLS_PSA_ACCEL_ECC_SECP_R1_521 */
#endif /* PSA_WANT_ECC_SECP_R1_521 */
#if defined(PSA_WANT_ECC_SECP_K1_192)
#if !defined(MBEDTLS_PSA_ACCEL_ECC_SECP_K1_192)
#define MBEDTLS_ECP_DP_SECP192K1_ENABLED
#define MBEDTLS_PSA_BUILTIN_ECC_SECP_K1_192 1
#endif /* !MBEDTLS_PSA_ACCEL_ECC_SECP_K1_192 */
#endif /* PSA_WANT_ECC_SECP_K1_192 */
#if defined(PSA_WANT_ECC_SECP_K1_224)
#if !defined(MBEDTLS_PSA_ACCEL_ECC_SECP_K1_224)
/*
* SECP224K1 is buggy via the PSA API in Mbed TLS
* (https://github.com/Mbed-TLS/mbedtls/issues/3541).
*/
#error "SECP224K1 is buggy via the PSA API in Mbed TLS."
#define MBEDTLS_ECP_DP_SECP224K1_ENABLED
#define MBEDTLS_PSA_BUILTIN_ECC_SECP_K1_224 1
#endif /* !MBEDTLS_PSA_ACCEL_ECC_SECP_K1_224 */
#endif /* PSA_WANT_ECC_SECP_K1_224 */
#if defined(PSA_WANT_ECC_SECP_K1_256)
#if !defined(MBEDTLS_PSA_ACCEL_ECC_SECP_K1_256)
#define MBEDTLS_ECP_DP_SECP256K1_ENABLED
#define MBEDTLS_PSA_BUILTIN_ECC_SECP_K1_256 1
#endif /* !MBEDTLS_PSA_ACCEL_ECC_SECP_K1_256 */
#endif /* PSA_WANT_ECC_SECP_K1_256 */
/****************************************************************/
/* Infer PSA requirements from Mbed TLS capabilities */
/****************************************************************/
#else /* MBEDTLS_PSA_CRYPTO_CONFIG */
/*
* Ensure PSA_WANT_* defines are setup properly if MBEDTLS_PSA_CRYPTO_CONFIG
* is not defined
*/
#if defined(MBEDTLS_CCM_C)
#define MBEDTLS_PSA_BUILTIN_ALG_CCM 1
#define MBEDTLS_PSA_BUILTIN_ALG_CCM_STAR_NO_TAG 1
#define PSA_WANT_ALG_CCM 1
#define PSA_WANT_ALG_CCM_STAR_NO_TAG 1
#endif /* MBEDTLS_CCM_C */
#if defined(MBEDTLS_CMAC_C)
#define MBEDTLS_PSA_BUILTIN_ALG_CMAC 1
#define PSA_WANT_ALG_CMAC 1
#endif /* MBEDTLS_CMAC_C */
#if defined(MBEDTLS_ECDH_C)
#define MBEDTLS_PSA_BUILTIN_ALG_ECDH 1
#define PSA_WANT_ALG_ECDH 1
#endif /* MBEDTLS_ECDH_C */
#if defined(MBEDTLS_ECDSA_C)
#define MBEDTLS_PSA_BUILTIN_ALG_ECDSA 1
#define PSA_WANT_ALG_ECDSA 1
#define PSA_WANT_ALG_ECDSA_ANY 1
// Only add in DETERMINISTIC support if ECDSA is also enabled
#if defined(MBEDTLS_ECDSA_DETERMINISTIC)
#define MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA 1
#define PSA_WANT_ALG_DETERMINISTIC_ECDSA 1
#endif /* MBEDTLS_ECDSA_DETERMINISTIC */
#endif /* MBEDTLS_ECDSA_C */
#if defined(MBEDTLS_ECP_C)
#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_KEY_PAIR 1
#define PSA_WANT_KEY_TYPE_ECC_KEY_PAIR 1
#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_PUBLIC_KEY 1
#define PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY 1
#endif /* MBEDTLS_ECP_C */
#if defined(MBEDTLS_GCM_C)
#define MBEDTLS_PSA_BUILTIN_ALG_GCM 1
#define PSA_WANT_ALG_GCM 1
#endif /* MBEDTLS_GCM_C */
/* Enable PSA HKDF algorithm if mbedtls HKDF is supported.
* PSA HKDF EXTRACT and PSA HKDF EXPAND have minimal cost when
* PSA HKDF is enabled, so enable both algorithms together
* with PSA HKDF. */
#if defined(MBEDTLS_HKDF_C)
#define MBEDTLS_PSA_BUILTIN_ALG_HMAC 1
#define PSA_WANT_ALG_HMAC 1
#define MBEDTLS_PSA_BUILTIN_ALG_HKDF 1
#define PSA_WANT_ALG_HKDF 1
#define MBEDTLS_PSA_BUILTIN_ALG_HKDF_EXTRACT 1
#define PSA_WANT_ALG_HKDF_EXTRACT 1
#define MBEDTLS_PSA_BUILTIN_ALG_HKDF_EXPAND 1
#define PSA_WANT_ALG_HKDF_EXPAND 1
#endif /* MBEDTLS_HKDF_C */
#if defined(MBEDTLS_MD_C)
#define MBEDTLS_PSA_BUILTIN_ALG_HMAC 1
#define PSA_WANT_ALG_HMAC 1
#define PSA_WANT_KEY_TYPE_HMAC
#define MBEDTLS_PSA_BUILTIN_ALG_TLS12_PRF 1
#define PSA_WANT_ALG_TLS12_PRF 1
#define MBEDTLS_PSA_BUILTIN_ALG_TLS12_PSK_TO_MS 1
#define PSA_WANT_ALG_TLS12_PSK_TO_MS 1
#endif /* MBEDTLS_MD_C */
#if defined(MBEDTLS_MD5_C)
#define MBEDTLS_PSA_BUILTIN_ALG_MD5 1
#define PSA_WANT_ALG_MD5 1
#endif
#if defined(MBEDTLS_RIPEMD160_C)
#define MBEDTLS_PSA_BUILTIN_ALG_RIPEMD160 1
#define PSA_WANT_ALG_RIPEMD160 1
#endif
#if defined(MBEDTLS_RSA_C)
#if defined(MBEDTLS_PKCS1_V15)
#define MBEDTLS_PSA_BUILTIN_ALG_RSA_PKCS1V15_CRYPT 1
#define PSA_WANT_ALG_RSA_PKCS1V15_CRYPT 1
#define MBEDTLS_PSA_BUILTIN_ALG_RSA_PKCS1V15_SIGN 1
#define PSA_WANT_ALG_RSA_PKCS1V15_SIGN 1
#define PSA_WANT_ALG_RSA_PKCS1V15_SIGN_RAW 1
#endif /* MBEDTLS_PKCS1_V15 */
#if defined(MBEDTLS_PKCS1_V21)
#define MBEDTLS_PSA_BUILTIN_ALG_RSA_OAEP 1
#define PSA_WANT_ALG_RSA_OAEP 1
#define MBEDTLS_PSA_BUILTIN_ALG_RSA_PSS 1
#define PSA_WANT_ALG_RSA_PSS 1
#endif /* MBEDTLS_PKCS1_V21 */
#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_KEY_PAIR 1
#define PSA_WANT_KEY_TYPE_RSA_KEY_PAIR 1
#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_PUBLIC_KEY 1
#define PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY 1
#endif /* MBEDTLS_RSA_C */
#if defined(MBEDTLS_SHA1_C)
#define MBEDTLS_PSA_BUILTIN_ALG_SHA_1 1
#define PSA_WANT_ALG_SHA_1 1
#endif
#if defined(MBEDTLS_SHA224_C)
#define MBEDTLS_PSA_BUILTIN_ALG_SHA_224 1
#define PSA_WANT_ALG_SHA_224 1
#endif
#if defined(MBEDTLS_SHA256_C)
#define MBEDTLS_PSA_BUILTIN_ALG_SHA_256 1
#define PSA_WANT_ALG_SHA_256 1
#endif
#if defined(MBEDTLS_SHA384_C)
#define MBEDTLS_PSA_BUILTIN_ALG_SHA_384 1
#define PSA_WANT_ALG_SHA_384 1
#endif
#if defined(MBEDTLS_SHA512_C)
#define MBEDTLS_PSA_BUILTIN_ALG_SHA_512 1
#define PSA_WANT_ALG_SHA_512 1
#endif
#if defined(MBEDTLS_AES_C)
#define PSA_WANT_KEY_TYPE_AES 1
#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_AES 1
#endif
#if defined(MBEDTLS_ARIA_C)
#define PSA_WANT_KEY_TYPE_ARIA 1
#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_ARIA 1
#endif
#if defined(MBEDTLS_CAMELLIA_C)
#define PSA_WANT_KEY_TYPE_CAMELLIA 1
#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_CAMELLIA 1
#endif
#if defined(MBEDTLS_DES_C)
#define PSA_WANT_KEY_TYPE_DES 1
#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_DES 1
#endif
#if defined(MBEDTLS_CHACHA20_C)
#define PSA_WANT_KEY_TYPE_CHACHA20 1
#define PSA_WANT_ALG_STREAM_CIPHER 1
#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_CHACHA20 1
#define MBEDTLS_PSA_BUILTIN_ALG_STREAM_CIPHER 1
#if defined(MBEDTLS_CHACHAPOLY_C)
#define PSA_WANT_ALG_CHACHA20_POLY1305 1
#define MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 1
#endif
#endif
#if defined(MBEDTLS_CIPHER_MODE_CBC)
#define MBEDTLS_PSA_BUILTIN_ALG_CBC_NO_PADDING 1
#define PSA_WANT_ALG_CBC_NO_PADDING 1
#if defined(MBEDTLS_CIPHER_PADDING_PKCS7)
#define MBEDTLS_PSA_BUILTIN_ALG_CBC_PKCS7 1
#define PSA_WANT_ALG_CBC_PKCS7 1
#endif
#endif
#if defined(MBEDTLS_AES_C) || defined(MBEDTLS_DES_C) || \
defined(MBEDTLS_ARIA_C) || defined(MBEDTLS_CAMELLIA_C)
#define MBEDTLS_PSA_BUILTIN_ALG_ECB_NO_PADDING 1
#define PSA_WANT_ALG_ECB_NO_PADDING 1
#endif
#if defined(MBEDTLS_CIPHER_MODE_CFB)
#define MBEDTLS_PSA_BUILTIN_ALG_CFB 1
#define PSA_WANT_ALG_CFB 1
#endif
#if defined(MBEDTLS_CIPHER_MODE_CTR)
#define MBEDTLS_PSA_BUILTIN_ALG_CTR 1
#define PSA_WANT_ALG_CTR 1
#endif
#if defined(MBEDTLS_CIPHER_MODE_OFB)
#define MBEDTLS_PSA_BUILTIN_ALG_OFB 1
#define PSA_WANT_ALG_OFB 1
#endif
#if defined(MBEDTLS_ECP_DP_BP256R1_ENABLED)
#define MBEDTLS_PSA_BUILTIN_ECC_BRAINPOOL_P_R1_256 1
#define PSA_WANT_ECC_BRAINPOOL_P_R1_256
#endif
#if defined(MBEDTLS_ECP_DP_BP384R1_ENABLED)
#define MBEDTLS_PSA_BUILTIN_ECC_BRAINPOOL_P_R1_384 1
#define PSA_WANT_ECC_BRAINPOOL_P_R1_384
#endif
#if defined(MBEDTLS_ECP_DP_BP512R1_ENABLED)
#define MBEDTLS_PSA_BUILTIN_ECC_BRAINPOOL_P_R1_512 1
#define PSA_WANT_ECC_BRAINPOOL_P_R1_512
#endif
#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED)
#define MBEDTLS_PSA_BUILTIN_ECC_MONTGOMERY_255 1
#define PSA_WANT_ECC_MONTGOMERY_255
#endif
#if defined(MBEDTLS_ECP_DP_CURVE448_ENABLED)
#define MBEDTLS_PSA_BUILTIN_ECC_MONTGOMERY_448 1
#define PSA_WANT_ECC_MONTGOMERY_448
#endif
#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED)
#define MBEDTLS_PSA_BUILTIN_ECC_SECP_R1_192 1
#define PSA_WANT_ECC_SECP_R1_192
#endif
#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED)
#define MBEDTLS_PSA_BUILTIN_ECC_SECP_R1_224 1
#define PSA_WANT_ECC_SECP_R1_224
#endif
#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED)
#define MBEDTLS_PSA_BUILTIN_ECC_SECP_R1_256 1
#define PSA_WANT_ECC_SECP_R1_256
#endif
#if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED)
#define MBEDTLS_PSA_BUILTIN_ECC_SECP_R1_384 1
#define PSA_WANT_ECC_SECP_R1_384
#endif
#if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED)
#define MBEDTLS_PSA_BUILTIN_ECC_SECP_R1_521 1
#define PSA_WANT_ECC_SECP_R1_521
#endif
#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED)
#define MBEDTLS_PSA_BUILTIN_ECC_SECP_K1_192 1
#define PSA_WANT_ECC_SECP_K1_192
#endif
/* SECP224K1 is buggy via the PSA API (https://github.com/Mbed-TLS/mbedtls/issues/3541) */
#if 0 && defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED)
#define MBEDTLS_PSA_BUILTIN_ECC_SECP_K1_224 1
#define PSA_WANT_ECC_SECP_K1_224
#endif
#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)
#define MBEDTLS_PSA_BUILTIN_ECC_SECP_K1_256 1
#define PSA_WANT_ECC_SECP_K1_256
#endif
#endif /* MBEDTLS_PSA_CRYPTO_CONFIG */
/* These features are always enabled. */
#define PSA_WANT_KEY_TYPE_DERIVE 1
#define PSA_WANT_KEY_TYPE_RAW_DATA 1
#ifdef __cplusplus
}
#endif
#endif /* MBEDTLS_CONFIG_PSA_H */
|
d2de6ed539440e3390ab1e15e00e9c28abb8ccac
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/include/linux/netfilter/nf_conntrack_sane.h
|
4767d6e23e977197ebc930600bb859db2ca96245
|
[
"Linux-syscall-note",
"GPL-2.0-only",
"GPL-1.0-or-later",
"LicenseRef-scancode-free-unknown",
"Apache-2.0"
] |
permissive
|
OLIMEX/DIY-LAPTOP
|
ae82f4ee79c641d9aee444db9a75f3f6709afa92
|
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
|
refs/heads/rel3
| 2023-08-04T01:54:19.483792
| 2023-04-03T07:18:12
| 2023-04-03T07:18:12
| 80,094,055
| 507
| 92
|
Apache-2.0
| 2023-04-03T07:05:59
| 2017-01-26T07:25:50
|
C
|
UTF-8
|
C
| false
| false
| 357
|
h
|
nf_conntrack_sane.h
|
#ifndef _NF_CONNTRACK_SANE_H
#define _NF_CONNTRACK_SANE_H
/* SANE tracking. */
#ifdef __KERNEL__
#define SANE_PORT 6566
enum sane_state {
SANE_STATE_NORMAL,
SANE_STATE_START_REQUESTED,
};
/* This structure exists only once per master */
struct nf_ct_sane_master {
enum sane_state state;
};
#endif /* __KERNEL__ */
#endif /* _NF_CONNTRACK_SANE_H */
|
bab99c33633330245dade0b271fd3803073ee78a
|
14ed2724b7c610543959f23d401e7b90283e63c4
|
/Source/ldbmp.h
|
116fa6b3fd0c258e6bb7ccdc722ec4fa566db65f
|
[
"MIT"
] |
permissive
|
powervr-graphics/PowerVR-Series1
|
d0ec36623d257e05c078e5d3f4bdfcd786ba46a4
|
c8c11cbe29c5b758ed1ef9600fc8614fc8da618e
|
refs/heads/main
| 2023-08-14T18:42:40.609670
| 2022-03-23T10:29:37
| 2022-03-23T10:29:37
| 467,444,934
| 260
| 17
| null | null | null | null |
UTF-8
|
C
| false
| false
| 766
|
h
|
ldbmp.h
|
/******************************************************************************
* Name : ldbmp.h
* Title : BMP manipulation routines.
* Author : Peter Leaback
* Created : 03/08/1995
*
* Copyright : 1995-2022 Imagination Technologies (c)
* License : MIT
*
* Description : sgl.h defines the bmp loaded. The functions below are used
* by the simulator to write out the bmp.
*
* Platform : ANSI
*
* Modifications:
* $Log: ldbmp.h,v $
* Revision 1.1 1995/08/03 12:52:34 pdl
* Initial revision
*
*
*****************************************************************************/
unsigned int GetShort(FILE *fp);
unsigned long GetLong(FILE *fp);
void PutShort(FILE *fp,int i);
void PutLong(FILE *fp,long i);
|
12fcae95a062b8ded16cfcc70c58f41fb98d6128
|
f019a06a4aa9f88a1a091eb09861999a0d6389e4
|
/tcp_crr.c
|
0fe8bd1a227bb0122e863ef6c1f3f5f930e482be
|
[
"Apache-2.0"
] |
permissive
|
google/neper
|
17faefa6d171638ae6ab3b587cdda36e7b412588
|
8509d279655eb8770a234672ee1f064411d511e2
|
refs/heads/master
| 2023-09-05T16:28:45.786657
| 2023-05-18T01:42:53
| 2023-05-18T01:42:53
| 55,101,823
| 253
| 66
|
Apache-2.0
| 2023-05-18T01:42:54
| 2016-03-30T22:21:18
|
C
|
UTF-8
|
C
| false
| false
| 1,410
|
c
|
tcp_crr.c
|
/*
* Copyright 2016 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "common.h"
#include "rr.h"
#include "socket.h"
#include "thread.h"
static const struct neper_fn client_fn = {
.fn_loop_init = socket_connect_all,
.fn_flow_init = crr_flow_init,
.fn_report = rr_report_stats,
.fn_type = SOCK_STREAM
};
static const struct neper_fn server_fn = {
.fn_loop_init = socket_listen,
.fn_flow_init = crr_flow_init,
.fn_report = rr_report_stats,
.fn_type = SOCK_STREAM
};
int tcp_crr(struct options *opts, struct callbacks *cb)
{
const struct neper_fn *fn = opts->client ? &client_fn : &server_fn;
/* tcp_crr server doesn't collect stats, as it uses too much memory. */
if (!opts->client)
opts->nostats = true;
return run_main_thread(opts, cb, fn);
}
|
2957e50bc29a298668284bce8fc187e31859a434
|
ecce427678ecff2a93a47f3b1b664202c7d27617
|
/levels/castle_courtyard/areas/1/3/model.inc.c
|
d4ef531991b0b05f1d543620921713f56cd26000
|
[] |
no_license
|
sm64pc/sm64ex
|
ecf37f31b3f7426c4874254660d856030d789714
|
54cd27ccee45a2403b45f07a00d6043c51149969
|
refs/heads/nightly
| 2023-08-11T12:14:34.424168
| 2023-07-01T11:45:50
| 2023-07-01T11:45:50
| 262,091,731
| 795
| 238
| null | 2023-07-01T11:45:51
| 2020-05-07T15:43:27
|
C
|
UTF-8
|
C
| false
| false
| 3,977
|
c
|
model.inc.c
|
// 0x07005708 - 0x070057F8
static const Vtx castle_courtyard_seg7_vertex_07005708[] = {
{{{ 205, 1741, 502}, 0, { 990, 0}, {0xa2, 0xa2, 0xc1, 0xff}}},
{{{ 614, 1741, 502}, 0, { 0, 0}, {0xa2, 0xa2, 0xc1, 0xff}}},
{{{ 614, 1331, 502}, 0, { 0, 990}, {0xa2, 0xa2, 0xc1, 0xff}}},
{{{ -2047, 1126, 195}, 0, { 990, 0}, {0xa2, 0xa2, 0xc1, 0xff}}},
{{{ -1637, 717, 195}, 0, { 0, 990}, {0xa2, 0xa2, 0xc1, 0xff}}},
{{{ -2047, 717, 195}, 0, { 990, 990}, {0xa2, 0xa2, 0xc1, 0xff}}},
{{{ -1637, 1126, 195}, 0, { 0, 0}, {0xa2, 0xa2, 0xc1, 0xff}}},
{{{ -2047, 1741, 195}, 0, { 990, 0}, {0xa2, 0xa2, 0xc1, 0xff}}},
{{{ -1637, 1331, 195}, 0, { 0, 990}, {0xa2, 0xa2, 0xc1, 0xff}}},
{{{ -2047, 1331, 195}, 0, { 990, 990}, {0xa2, 0xa2, 0xc1, 0xff}}},
{{{ -1637, 1741, 195}, 0, { 0, 0}, {0xa2, 0xa2, 0xc1, 0xff}}},
{{{ -613, 1741, 502}, 0, { 990, 0}, {0xa2, 0xa2, 0xc1, 0xff}}},
{{{ -204, 1331, 502}, 0, { 0, 990}, {0xa2, 0xa2, 0xc1, 0xff}}},
{{{ -613, 1331, 502}, 0, { 990, 990}, {0xa2, 0xa2, 0xc1, 0xff}}},
{{{ -204, 1741, 502}, 0, { 0, 0}, {0xa2, 0xa2, 0xc1, 0xff}}},
};
// 0x070057F8 - 0x070058A8
static const Vtx castle_courtyard_seg7_vertex_070057F8[] = {
{{{ 1638, 1741, 195}, 0, { 990, 0}, {0xa2, 0xa2, 0xc1, 0xff}}},
{{{ 2048, 1741, 195}, 0, { 0, 0}, {0xa2, 0xa2, 0xc1, 0xff}}},
{{{ 2048, 1331, 195}, 0, { 0, 990}, {0xa2, 0xa2, 0xc1, 0xff}}},
{{{ 205, 1741, 502}, 0, { 990, 0}, {0xa2, 0xa2, 0xc1, 0xff}}},
{{{ 614, 1331, 502}, 0, { 0, 990}, {0xa2, 0xa2, 0xc1, 0xff}}},
{{{ 205, 1331, 502}, 0, { 990, 990}, {0xa2, 0xa2, 0xc1, 0xff}}},
{{{ 1638, 1126, 195}, 0, { 990, 0}, {0xa2, 0xa2, 0xc1, 0xff}}},
{{{ 2048, 1126, 195}, 0, { 0, 0}, {0xa2, 0xa2, 0xc1, 0xff}}},
{{{ 2048, 717, 195}, 0, { 0, 990}, {0xa2, 0xa2, 0xc1, 0xff}}},
{{{ 1638, 717, 195}, 0, { 990, 990}, {0xa2, 0xa2, 0xc1, 0xff}}},
{{{ 1638, 1331, 195}, 0, { 990, 990}, {0xa2, 0xa2, 0xc1, 0xff}}},
};
// 0x070058A8 - 0x07005938
static const Gfx castle_courtyard_seg7_dl_070058A8[] = {
gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, outside_0900A800),
gsDPLoadSync(),
gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 32 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)),
gsSPVertex(castle_courtyard_seg7_vertex_07005708, 15, 0),
gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0),
gsSP2Triangles( 3, 6, 4, 0x0, 7, 8, 9, 0x0),
gsSP2Triangles( 7, 10, 8, 0x0, 11, 12, 13, 0x0),
gsSP1Triangle(11, 14, 12, 0x0),
gsSPVertex(castle_courtyard_seg7_vertex_070057F8, 11, 0),
gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0),
gsSP2Triangles( 6, 7, 8, 0x0, 6, 8, 9, 0x0),
gsSP1Triangle( 0, 2, 10, 0x0),
gsSPEndDisplayList(),
};
// 0x07005938 - 0x070059A8
const Gfx castle_courtyard_seg7_dl_07005938[] = {
gsDPPipeSync(),
gsDPSetCombineMode(G_CC_MODULATERGBA, G_CC_MODULATERGBA),
gsSPClearGeometryMode(G_LIGHTING),
gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD),
gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON),
gsDPTileSync(),
gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 0, G_TX_RENDERTILE, 0, G_TX_CLAMP, 5, G_TX_NOLOD, G_TX_CLAMP, 5, G_TX_NOLOD),
gsDPSetTileSize(0, 0, 0, (32 - 1) << G_TEXTURE_IMAGE_FRAC, (32 - 1) << G_TEXTURE_IMAGE_FRAC),
gsSPDisplayList(castle_courtyard_seg7_dl_070058A8),
gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF),
gsDPPipeSync(),
gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE),
gsSPSetGeometryMode(G_LIGHTING),
gsSPEndDisplayList(),
};
|
cc4dc08619c7b799899b4c1febf31f9ffd29a3f1
|
a3d6556180e74af7b555f8d47d3fea55b94bcbda
|
/tools/clang/scripts/sanitizers/sanitizer_intercept_overriders.h
|
bfd0f6b5b98e5c6af0c55b777beadaee01374ed8
|
[
"BSD-3-Clause"
] |
permissive
|
chromium/chromium
|
aaa9eda10115b50b0616d2f1aed5ef35d1d779d6
|
a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c
|
refs/heads/main
| 2023-08-24T00:35:12.585945
| 2023-08-23T22:01:11
| 2023-08-23T22:01:11
| 120,360,765
| 17,408
| 7,102
|
BSD-3-Clause
| 2023-09-10T23:44:27
| 2018-02-05T20:55:32
| null |
UTF-8
|
C
| false
| false
| 168
|
h
|
sanitizer_intercept_overriders.h
|
// Workaround for https://crbug.com/1302636#c49, #c55
#ifdef SANITIZER_INTERCEPT_CRYPT_R
#undef SANITIZER_INTERCEPT_CRYPT_R
#define SANITIZER_INTERCEPT_CRYPT_R 0
#endif
|
b78d91db7f2bcee3d5df03caff0801d6ba2ce6a7
|
50dd46b8ece33f3cdd174284b15d1d51f89669d4
|
/third_party/edk2/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOnboardDeviceFunction.c
|
ecf6e6e2bcce2b7ed9e9ecec527953f51f6b47a1
|
[
"LicenseRef-scancode-generic-cla",
"Apache-2.0",
"BSD-2-Clause",
"OpenSSL"
] |
permissive
|
google/google-ctf
|
f99da1ee07729bbccb869fff1cbaed6a80e43bcc
|
df02323eaf945d15e124801c74abaadca2749dc7
|
refs/heads/master
| 2023-08-31T14:30:27.548081
| 2023-08-29T13:04:20
| 2023-08-29T13:04:20
| 131,317,137
| 4,136
| 607
|
Apache-2.0
| 2023-08-30T22:17:02
| 2018-04-27T15:56:03
|
Go
|
UTF-8
|
C
| false
| false
| 5,078
|
c
|
MiscOnboardDeviceFunction.c
|
/** @file
Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
MiscOnboardDeviceFunction.c
Abstract:
Create the device path for the Onboard device.
The Onboard device information is Misc. subclass type 8 and SMBIOS type 10.
**/
#include "CommonHeader.h"
#include "MiscSubclassDriver.h"
/**
This is a macro defined function, in fact, the function is
MiscOnboardDeviceFunction (RecordType, RecordLen, RecordData, LogRecordData)
This function makes boot time changes to the contents of the
MiscOnboardDevice structure.
@param MiscOnboardDevice The string which is used to create the function
The Arguments in fact:
@param RecordType Type of record to be processed from the Data
Table. mMiscSubclassDataTable[].RecordType
@param RecordLen Size of static RecordData from the Data Table.
mMiscSubclassDataTable[].RecordLen
@param RecordData Pointer to RecordData, which will be written to
the Data Hub
@param LogRecordData TRUE to log RecordData to Data Hub. FALSE when
there is no more data to log.
@retval EFI_SUCCESS *RecordData and *LogRecordData have been set.
@retval EFI_UNSUPPORTED Unexpected RecordType value.
@retval EFI_INVALID_PARAMETER One of the following parameter conditions was
true: RecordLen was zero. RecordData was NULL.
LogRecordData was NULL.
**/
MISC_SMBIOS_TABLE_FUNCTION (
MiscOnboardDevice
)
{
CHAR8 *OptionalStrStart;
UINT8 StatusAndType;
UINTN DescriptionStrLen;
EFI_STRING DeviceDescription;
STRING_REF TokenToGet;
EFI_STATUS Status;
EFI_SMBIOS_HANDLE SmbiosHandle;
SMBIOS_TABLE_TYPE10 *SmbiosRecord;
EFI_MISC_ONBOARD_DEVICE *ForType10InputData;
ForType10InputData = (EFI_MISC_ONBOARD_DEVICE *)RecordData;
//
// First check for invalid parameters.
//
if (RecordData == NULL) {
return EFI_INVALID_PARAMETER;
}
TokenToGet = 0;
switch (ForType10InputData->OnBoardDeviceDescription) {
case STR_MISC_ONBOARD_DEVICE_VIDEO:
TokenToGet = STRING_TOKEN (STR_MISC_ONBOARD_DEVICE_VIDEO);
break;
case STR_MISC_ONBOARD_DEVICE_AUDIO:
TokenToGet = STRING_TOKEN (STR_MISC_ONBOARD_DEVICE_AUDIO);
break;
default:
break;
}
DeviceDescription = SmbiosMiscGetString (TokenToGet);
DescriptionStrLen = StrLen(DeviceDescription);
if (DescriptionStrLen > SMBIOS_STRING_MAX_LENGTH) {
return EFI_UNSUPPORTED;
}
//
// Two zeros following the last string.
//
SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE10) + DescriptionStrLen + 1 + 1);
ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE10) + DescriptionStrLen + 1 + 1);
SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_ONBOARD_DEVICE_INFORMATION;
SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE10);
//
// Make handle chosen by smbios protocol.add automatically.
//
SmbiosRecord->Hdr.Handle = 0;
//
// Status & Type: Bit 7 Devicen Status, Bits 6:0 Type of Device
//
StatusAndType = (UINT8) ForType10InputData->OnBoardDeviceStatus.DeviceType;
if (ForType10InputData->OnBoardDeviceStatus.DeviceEnabled != 0) {
StatusAndType |= 0x80;
} else {
StatusAndType &= 0x7F;
}
SmbiosRecord->Device[0].DeviceType = StatusAndType;
SmbiosRecord->Device[0].DescriptionString = 1;
OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
UnicodeStrToAsciiStr(DeviceDescription, OptionalStrStart);
//
// Now we have got the full smbios record, call smbios protocol to add this record.
//
SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
Status = Smbios-> Add(
Smbios,
NULL,
&SmbiosHandle,
(EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord
);
FreePool(SmbiosRecord);
return Status;
}
|
bc6dca83effecbdf905375e82b2039746f41084c
|
79d343002bb63a44f8ab0dbac0c9f4ec54078c3a
|
/lib/libc/glibc/sysdeps/unix/sysv/linux/arm/sysdep.h
|
c1722557bd16526427ef99c64a819c7b5a871ca6
|
[
"MIT",
"LicenseRef-scancode-inner-net-2.0",
"LGPL-2.1-or-later",
"BSD-3-Clause",
"HPND",
"LicenseRef-scancode-pcre",
"LicenseRef-scancode-other-copyleft",
"ISC",
"LicenseRef-scancode-other-permissive",
"Spencer-94",
"SunPro",
"CMU-Mach"
] |
permissive
|
ziglang/zig
|
4aa75d8d3bcc9e39bf61d265fd84b7f005623fc5
|
f4c9e19bc3213c2bc7e03d7b06d7129882f39f6c
|
refs/heads/master
| 2023-08-31T13:16:45.980913
| 2023-08-31T05:50:29
| 2023-08-31T05:50:29
| 40,276,274
| 25,560
| 2,399
|
MIT
| 2023-09-14T21:09:50
| 2015-08-06T00:51:28
|
Zig
|
UTF-8
|
C
| false
| false
| 12,410
|
h
|
sysdep.h
|
/* Copyright (C) 1992-2021 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>, August 1995.
ARM changes by Philip Blundell, <pjb27@cam.ac.uk>, May 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */
#ifndef _LINUX_ARM_SYSDEP_H
#define _LINUX_ARM_SYSDEP_H 1
/* There is some commonality. */
#include <sysdeps/unix/sysv/linux/sysdep.h>
#include <sysdeps/unix/arm/sysdep.h>
/* Defines RTLD_PRIVATE_ERRNO and USE_DL_SYSINFO. */
#include <dl-sysdep.h>
#include <tls.h>
/* For Linux we can use the system call table in the header file
/usr/include/asm/unistd.h
of the kernel. But these symbols do not follow the SYS_* syntax
so we have to redefine the `SYS_ify' macro here. */
#undef SYS_ify
#define SYS_ify(syscall_name) (__NR_##syscall_name)
#include <bits/hwcap.h>
#ifdef __ASSEMBLER__
#ifndef ARCH_HAS_HARD_TP
/* Internal macro calling the linux kernel kuser_get_tls helper.
Note that in thumb mode, a constant pool break is often out of range, so
we always expand the constant inline. */
# ifdef __thumb2__
# define GET_TLS_BODY \
movw r0, #0x0fe0; \
movt r0, #0xffff; \
blx r0
# else
# define GET_TLS_BODY \
mov r0, #0xffff0fff; /* Point to the high page. */ \
mov lr, pc; /* Save our return address. */ \
sub pc, r0, #31 /* Jump to the TLS entry. */
# endif
/* Helper to get the TLS base pointer. Save LR in TMP, return in R0,
and no other registers clobbered. TMP may be LR itself to indicate
that no save is necessary. */
# undef GET_TLS
# define GET_TLS(TMP) \
.ifnc TMP, lr; \
mov TMP, lr; \
cfi_register (lr, TMP); \
GET_TLS_BODY; \
mov lr, TMP; \
cfi_restore (lr); \
.else; \
GET_TLS_BODY; \
.endif
#endif /* ARCH_HAS_HARD_TP */
/* Linux uses a negative return value to indicate syscall errors,
unlike most Unices, which use the condition codes' carry flag.
Since version 2.1 the return value of a system call might be
negative even if the call succeeded. E.g., the `lseek' system call
might return a large offset. Therefore we must not anymore test
for < 0, but test for a real error by making sure the value in R0
is a real error number. Linus said he will make sure the no syscall
returns a value in -1 .. -4095 as a valid result so we can safely
test with -4095. */
#undef PSEUDO
#define PSEUDO(name, syscall_name, args) \
.text; \
ENTRY (name); \
DO_CALL (syscall_name, args); \
cmn r0, $4096;
#define PSEUDO_RET \
it cc; \
RETINSTR(cc, lr); \
b PLTJMP(SYSCALL_ERROR)
#undef ret
#define ret PSEUDO_RET
#undef PSEUDO_END
#define PSEUDO_END(name) \
SYSCALL_ERROR_HANDLER; \
END (name)
#undef PSEUDO_NOERRNO
#define PSEUDO_NOERRNO(name, syscall_name, args) \
.text; \
ENTRY (name); \
DO_CALL (syscall_name, args);
#define PSEUDO_RET_NOERRNO \
DO_RET (lr);
#undef ret_NOERRNO
#define ret_NOERRNO PSEUDO_RET_NOERRNO
#undef PSEUDO_END_NOERRNO
#define PSEUDO_END_NOERRNO(name) \
END (name)
/* The function has to return the error code. */
#undef PSEUDO_ERRVAL
#define PSEUDO_ERRVAL(name, syscall_name, args) \
.text; \
ENTRY (name) \
DO_CALL (syscall_name, args); \
rsb r0, r0, #0
#undef PSEUDO_END_ERRVAL
#define PSEUDO_END_ERRVAL(name) \
END (name)
#define ret_ERRVAL PSEUDO_RET_NOERRNO
#if !IS_IN (libc)
# define SYSCALL_ERROR __local_syscall_error
# if RTLD_PRIVATE_ERRNO
# define SYSCALL_ERROR_HANDLER \
__local_syscall_error: \
rsb r0, r0, #0; \
LDST_PCREL(str, r0, r1, C_SYMBOL_NAME(rtld_errno)); \
mvn r0, #0; \
DO_RET(lr)
# else
# if defined(__ARM_ARCH_4T__) && defined(__THUMB_INTERWORK__)
# define POP_PC \
pop { lr }; \
cfi_adjust_cfa_offset (-4); \
cfi_restore (lr); \
bx lr
# else
# define POP_PC pop { pc }
# endif
# define SYSCALL_ERROR_HANDLER \
__local_syscall_error: \
push { lr }; \
cfi_adjust_cfa_offset (4); \
cfi_rel_offset (lr, 0); \
push { r0 }; \
cfi_adjust_cfa_offset (4); \
bl PLTJMP(C_SYMBOL_NAME(__errno_location)); \
pop { r1 }; \
cfi_adjust_cfa_offset (-4); \
rsb r1, r1, #0; \
str r1, [r0]; \
mvn r0, #0; \
POP_PC;
# endif
#else
# define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */
# define SYSCALL_ERROR __syscall_error
#endif
/* The ARM EABI user interface passes the syscall number in r7, instead
of in the swi. This is more efficient, because the kernel does not need
to fetch the swi from memory to find out the number; which can be painful
with separate I-cache and D-cache. Make sure to use 0 for the SWI
argument; otherwise the (optional) compatibility code for APCS binaries
may be invoked. */
/* Linux takes system call args in registers:
arg 1 r0
arg 2 r1
arg 3 r2
arg 4 r3
arg 5 r4 (this is different from the APCS convention)
arg 6 r5
arg 7 r6
The compiler is going to form a call by coming here, through PSEUDO, with
arguments
syscall number in the DO_CALL macro
arg 1 r0
arg 2 r1
arg 3 r2
arg 4 r3
arg 5 [sp]
arg 6 [sp+4]
arg 7 [sp+8]
We need to shuffle values between R4..R6 and the stack so that the
caller's v1..v3 and stack frame are not corrupted, and the kernel
sees the right arguments.
*/
/* We must save and restore r7 (call-saved) for the syscall number.
We never make function calls from inside here (only potentially
signal handlers), so we do not bother with doubleword alignment.
Just like the APCS syscall convention, the EABI syscall convention uses
r0 through r6 for up to seven syscall arguments. None are ever passed to
the kernel on the stack, although incoming arguments are on the stack for
syscalls with five or more arguments.
The assembler will convert the literal pool load to a move for most
syscalls. */
#undef DO_CALL
#define DO_CALL(syscall_name, args) \
DOARGS_##args; \
ldr r7, =SYS_ify (syscall_name); \
swi 0x0; \
UNDOARGS_##args
#undef DOARGS_0
#define DOARGS_0 \
.fnstart; \
push { r7 }; \
cfi_adjust_cfa_offset (4); \
cfi_rel_offset (r7, 0); \
.save { r7 }
#undef DOARGS_1
#define DOARGS_1 DOARGS_0
#undef DOARGS_2
#define DOARGS_2 DOARGS_0
#undef DOARGS_3
#define DOARGS_3 DOARGS_0
#undef DOARGS_4
#define DOARGS_4 DOARGS_0
#undef DOARGS_5
#define DOARGS_5 \
.fnstart; \
push {r4, r7}; \
cfi_adjust_cfa_offset (8); \
cfi_rel_offset (r4, 0); \
cfi_rel_offset (r7, 4); \
.save { r4, r7 }; \
ldr r4, [sp, #8]
#undef DOARGS_6
#define DOARGS_6 \
.fnstart; \
mov ip, sp; \
push {r4, r5, r7}; \
cfi_adjust_cfa_offset (12); \
cfi_rel_offset (r4, 0); \
cfi_rel_offset (r5, 4); \
cfi_rel_offset (r7, 8); \
.save { r4, r5, r7 }; \
ldmia ip, {r4, r5}
#undef DOARGS_7
#define DOARGS_7 \
.fnstart; \
mov ip, sp; \
push {r4, r5, r6, r7}; \
cfi_adjust_cfa_offset (16); \
cfi_rel_offset (r4, 0); \
cfi_rel_offset (r5, 4); \
cfi_rel_offset (r6, 8); \
cfi_rel_offset (r7, 12); \
.save { r4, r5, r6, r7 }; \
ldmia ip, {r4, r5, r6}
#undef UNDOARGS_0
#define UNDOARGS_0 \
pop {r7}; \
cfi_adjust_cfa_offset (-4); \
cfi_restore (r7); \
.fnend
#undef UNDOARGS_1
#define UNDOARGS_1 UNDOARGS_0
#undef UNDOARGS_2
#define UNDOARGS_2 UNDOARGS_0
#undef UNDOARGS_3
#define UNDOARGS_3 UNDOARGS_0
#undef UNDOARGS_4
#define UNDOARGS_4 UNDOARGS_0
#undef UNDOARGS_5
#define UNDOARGS_5 \
pop {r4, r7}; \
cfi_adjust_cfa_offset (-8); \
cfi_restore (r4); \
cfi_restore (r7); \
.fnend
#undef UNDOARGS_6
#define UNDOARGS_6 \
pop {r4, r5, r7}; \
cfi_adjust_cfa_offset (-12); \
cfi_restore (r4); \
cfi_restore (r5); \
cfi_restore (r7); \
.fnend
#undef UNDOARGS_7
#define UNDOARGS_7 \
pop {r4, r5, r6, r7}; \
cfi_adjust_cfa_offset (-16); \
cfi_restore (r4); \
cfi_restore (r5); \
cfi_restore (r6); \
cfi_restore (r7); \
.fnend
#else /* not __ASSEMBLER__ */
#if defined(__thumb__)
/* We can not expose the use of r7 to the compiler. GCC (as
of 4.5) uses r7 as the hard frame pointer for Thumb - although
for Thumb-2 it isn't obviously a better choice than r11.
And GCC does not support asms that conflict with the frame
pointer.
This would be easier if syscall numbers never exceeded 255,
but they do. For the moment the LOAD_ARGS_7 is sacrificed.
We can't use push/pop inside the asm because that breaks
unwinding (i.e. thread cancellation) for this frame. We can't
locally save and restore r7, because we do not know if this
function uses r7 or if it is our caller's r7; if it is our caller's,
then unwinding will fail higher up the stack. So we move the
syscall out of line and provide its own unwind information. */
# undef INTERNAL_SYSCALL_RAW
# define INTERNAL_SYSCALL_RAW(name, nr, args...) \
({ \
register int _a1 asm ("a1"); \
int _nametmp = name; \
LOAD_ARGS_##nr (args) \
register int _name asm ("ip") = _nametmp; \
asm volatile ("bl __libc_do_syscall" \
: "=r" (_a1) \
: "r" (_name) ASM_ARGS_##nr \
: "memory", "lr"); \
_a1; })
#else /* ARM */
# undef INTERNAL_SYSCALL_RAW
# define INTERNAL_SYSCALL_RAW(name, nr, args...) \
({ \
register int _a1 asm ("r0"), _nr asm ("r7"); \
LOAD_ARGS_##nr (args) \
_nr = name; \
asm volatile ("swi 0x0 @ syscall " #name \
: "=r" (_a1) \
: "r" (_nr) ASM_ARGS_##nr \
: "memory"); \
_a1; })
#endif
#undef INTERNAL_SYSCALL
#define INTERNAL_SYSCALL(name, nr, args...) \
INTERNAL_SYSCALL_RAW(SYS_ify(name), nr, args)
#define VDSO_NAME "LINUX_2.6"
#define VDSO_HASH 61765110
/* List of system calls which are supported as vsyscalls. */
#define HAVE_CLOCK_GETTIME_VSYSCALL "__vdso_clock_gettime"
#define HAVE_CLOCK_GETTIME64_VSYSCALL "__vdso_clock_gettime64"
#define HAVE_GETTIMEOFDAY_VSYSCALL "__vdso_gettimeofday"
#define LOAD_ARGS_0()
#define ASM_ARGS_0
#define LOAD_ARGS_1(a1) \
int _a1tmp = (int) (a1); \
LOAD_ARGS_0 () \
_a1 = _a1tmp;
#define ASM_ARGS_1 ASM_ARGS_0, "r" (_a1)
#define LOAD_ARGS_2(a1, a2) \
int _a2tmp = (int) (a2); \
LOAD_ARGS_1 (a1) \
register int _a2 asm ("a2") = _a2tmp;
#define ASM_ARGS_2 ASM_ARGS_1, "r" (_a2)
#define LOAD_ARGS_3(a1, a2, a3) \
int _a3tmp = (int) (a3); \
LOAD_ARGS_2 (a1, a2) \
register int _a3 asm ("a3") = _a3tmp;
#define ASM_ARGS_3 ASM_ARGS_2, "r" (_a3)
#define LOAD_ARGS_4(a1, a2, a3, a4) \
int _a4tmp = (int) (a4); \
LOAD_ARGS_3 (a1, a2, a3) \
register int _a4 asm ("a4") = _a4tmp;
#define ASM_ARGS_4 ASM_ARGS_3, "r" (_a4)
#define LOAD_ARGS_5(a1, a2, a3, a4, a5) \
int _v1tmp = (int) (a5); \
LOAD_ARGS_4 (a1, a2, a3, a4) \
register int _v1 asm ("v1") = _v1tmp;
#define ASM_ARGS_5 ASM_ARGS_4, "r" (_v1)
#define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \
int _v2tmp = (int) (a6); \
LOAD_ARGS_5 (a1, a2, a3, a4, a5) \
register int _v2 asm ("v2") = _v2tmp;
#define ASM_ARGS_6 ASM_ARGS_5, "r" (_v2)
#ifndef __thumb__
# define LOAD_ARGS_7(a1, a2, a3, a4, a5, a6, a7) \
int _v3tmp = (int) (a7); \
LOAD_ARGS_6 (a1, a2, a3, a4, a5, a6) \
register int _v3 asm ("v3") = _v3tmp;
# define ASM_ARGS_7 ASM_ARGS_6, "r" (_v3)
#endif
/* For EABI, non-constant syscalls are actually pretty easy... */
#undef INTERNAL_SYSCALL_NCS
#define INTERNAL_SYSCALL_NCS(number, nr, args...) \
INTERNAL_SYSCALL_RAW (number, nr, args)
#define SINGLE_THREAD_BY_GLOBAL 1
#endif /* __ASSEMBLER__ */
#endif /* linux/arm/sysdep.h */
|
1413084140ce440351ad45a95cc44eed1bb55bfe
|
e881a80473c7798ff8e2722da7f173ae332c9e3a
|
/7zip/CPP/7zip/UI/FileManager/PropertyName.h
|
4f0d6dc11d9e1c1a33b8bde54ae57f81bd1ee636
|
[
"ISC",
"Apache-2.0",
"LGPL-2.0-or-later",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
unknownbrackets/maxcso
|
4a69151a7b9325b3f24033862113275e2e3c3fc2
|
e4bdee13ffa8959a2ba052bf5b2f53e0455f8994
|
refs/heads/master
| 2023-06-14T07:44:37.357559
| 2023-06-04T05:26:06
| 2023-06-04T05:26:06
| 25,741,910
| 333
| 35
|
ISC
| 2023-06-04T05:26:07
| 2014-10-25T18:33:44
|
C
|
UTF-8
|
C
| false
| false
| 182
|
h
|
PropertyName.h
|
// PropertyName.h
#ifndef __PROPERTY_NAME_H
#define __PROPERTY_NAME_H
#include "../../../Common/MyString.h"
UString GetNameOfProperty(PROPID propID, const wchar_t *name);
#endif
|
61b2f11cf5459b6c619bfff9072f4132e2c42859
|
a3d6556180e74af7b555f8d47d3fea55b94bcbda
|
/chrome/browser/ui/views/chrome_typography.h
|
842ca932d45db50fa5346d0709a59b2aebd29601
|
[
"BSD-3-Clause"
] |
permissive
|
chromium/chromium
|
aaa9eda10115b50b0616d2f1aed5ef35d1d779d6
|
a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c
|
refs/heads/main
| 2023-08-24T00:35:12.585945
| 2023-08-23T22:01:11
| 2023-08-23T22:01:11
| 120,360,765
| 17,408
| 7,102
|
BSD-3-Clause
| 2023-09-10T23:44:27
| 2018-02-05T20:55:32
| null |
UTF-8
|
C
| false
| false
| 4,127
|
h
|
chrome_typography.h
|
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_CHROME_TYPOGRAPHY_H_
#define CHROME_BROWSER_UI_VIEWS_CHROME_TYPOGRAPHY_H_
#include "build/chromeos_buildflags.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/font.h"
#include "ui/views/style/typography.h"
#include "ui/views/style/typography_provider.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
// gn check complains on Linux Ozone.
#include "ash/public/cpp/ash_typography.h" // nogncheck
#endif
enum ChromeTextContext {
#if BUILDFLAG(IS_CHROMEOS_ASH)
CHROME_TEXT_CONTEXT_START = ash::ASH_TEXT_CONTEXT_END,
#else
CHROME_TEXT_CONTEXT_START = views::style::VIEWS_TEXT_CONTEXT_END,
#endif
// Headline text. Usually 20pt. Never multi-line.
CONTEXT_HEADLINE = CHROME_TEXT_CONTEXT_START,
// Smaller version of CONTEXT_DIALOG_BODY_TEXT. Usually 12pt.
CONTEXT_DIALOG_BODY_TEXT_SMALL,
// Text of the page title in the tab hover card.
CONTEXT_TAB_HOVER_CARD_TITLE,
// Text of the number of tabs in the tab counter used in tablet mode.
CONTEXT_TAB_COUNTER,
// Text used in the following UI contexts:
// - Omnibox query row text entry
// - Location icon view in the Omnibox
// - Omnibox pedals / action chips (omnibox_suggestion_button_row_view.cc)
//
// This context is also used in the following UI components, but likely has
// little to no effect in terms of typography (font size, weight, etc.):
// - Custom tab bar used by PWAs (custom_tab_bar_view.cc)
// - Picture-in-Picture view (picture_in_picture_browser_frame_view.cc)
CONTEXT_OMNIBOX_PRIMARY,
// Primary text in the omnibox dropdown.
CONTEXT_OMNIBOX_POPUP,
// Text in the suggestions section header in the omnibox dropdown.
CONTEXT_OMNIBOX_SECTION_HEADER,
// Text used in the following UI contexts:
// - Omnibox answer results
// - Two-line entity suggestions (description)
//
// This context is also used in the following UI components, but likely has
// little to no effect in terms of typography (font size, font weight, etc.):
// - Additional text view in the Omnibox
// - Error messages in password manager (manage_passwords_details_view.cc)
CONTEXT_OMNIBOX_DEEMPHASIZED,
// Text for titles, body text and buttons that appear in dialogs attempting to
// mimic the native Windows 10 look and feel.
CONTEXT_WINDOWS10_NATIVE,
// ToolbarButton label
CONTEXT_TOOLBAR_BUTTON,
// Most text in the download shelf. Usually 13pt.
CONTEXT_DOWNLOAD_SHELF,
// Status labels in the download shelf. Usually 10pt.
CONTEXT_DOWNLOAD_SHELF_STATUS,
// Title label in the IPH bubble. Usually 18pt.
CONTEXT_IPH_BUBBLE_TITLE,
// Body text label in the IPH bubble. Usually 14pt.
CONTEXT_IPH_BUBBLE_BODY,
// Title label in the browser side panel. Usually 13pt.
CONTEXT_SIDE_PANEL_TITLE,
};
enum ChromeTextStyle {
#if BUILDFLAG(IS_CHROMEOS_ASH)
CHROME_TEXT_STYLE_START = ash::ASH_TEXT_STYLE_END,
#else
CHROME_TEXT_STYLE_START = views::style::VIEWS_TEXT_STYLE_END,
#endif
// Similar to views::style::STYLE_PRIMARY but with a monospaced typeface.
STYLE_PRIMARY_MONOSPACED = CHROME_TEXT_STYLE_START,
// Similar to views::style::STYLE_SECONDARY but with a monospaced typeface.
STYLE_SECONDARY_MONOSPACED,
// A solid shade of red.
STYLE_RED,
// A solid shade of green.
STYLE_GREEN,
};
// Takes a desired font size and returns the size delta to request from
// ui::ResourceBundle that will result either in that font size, or the biggest
// font size that is smaller than the desired font size but will fit inside
// |available_height|.
int GetFontSizeDeltaBoundedByAvailableHeight(int available_height,
int desired_font_size);
// Sets the |details| for text that should not be affected by the Harmony spec.
void ApplyCommonFontStyles(int context,
int style,
ui::ResourceBundle::FontDetails& details);
#endif // CHROME_BROWSER_UI_VIEWS_CHROME_TYPOGRAPHY_H_
|
47c38a0bf60ddf4049262c8dda43099760c813d8
|
6e1cde66aa5a649138babe297293962cdf97743e
|
/src/pl-mutex.h
|
0894aea235645826e42002bf66ca2f56a8c854ee
|
[
"BSD-2-Clause"
] |
permissive
|
SWI-Prolog/swipl-devel
|
db56676481984addc09f4f228bc1c41f7f53759f
|
41ac4a569c8e6c3d3b93a21449403962e3de1ece
|
refs/heads/master
| 2023-09-01T03:49:40.696481
| 2023-08-30T18:12:56
| 2023-08-30T18:12:56
| 17,516,793
| 935
| 328
|
NOASSERTION
| 2023-08-26T14:32:33
| 2014-03-07T14:43:14
|
C
|
UTF-8
|
C
| false
| false
| 5,991
|
h
|
pl-mutex.h
|
/* Part of SWI-Prolog
Author: Jan Wielemaker
E-mail: J.Wielemaker@vu.nl
WWW: http://www.swi-prolog.org
Copyright (c) 2000-2020, University of Amsterdam
CWI, Amsterdam
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This file defines just the mutexes needed by the SWI-Prolog
multi-threading support. It is in a separate file because it needs to be
included before SWI-Stream.h, which in turn needs to be included early.
The remainder of the thread support must be at the end to exploit access
to the other Prolog data-types.
To allow for multiple thread-implementations, we do not use plain POSIX
mutex-primitives in the remainder of the code. Instead, mutexes are
controlled using the following macros:
type simpleMutex Non-recursive mutex
type recursiveMutex Recursive mutex
simpleMutexInit(p) Initialise a simple mutex
simpleMutexDelete(p) Delete a simple mutex
simpleMutexLock(p) Lock a simple mutex
simpleMutexTryLock(p) Try Lock a simple mutex
simpleMutexUnlock(p) unlock a simple mutex
recursiveMutexInit(p) Initialise a recursive mutex
recursiveMutexDelete(p) Delete a recursive mutex
recursiveMutexLock(p) Lock a recursive mutex
recursiveMutexTryLock(p) Try Lock a recursive mutex
recursiveMutexUnlock(p) unlock a recursive mutex
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "pl-incl.h"
#ifndef PL_MUTEX_H_DEFINED
#define PL_MUTEX_H_DEFINED
void initMutexes(void);
foreign_t pl_with_mutex(term_t mutex, term_t goal);
#ifdef O_PLMT
int get_mutex(term_t t, pl_mutex **mutex, int create);
#if defined(__WINDOWS__)
#define USE_CRITICAL_SECTIONS 1
#endif
#include <pthread.h>
#ifdef USE_CRITICAL_SECTIONS
#ifndef WINDOWS_LEAN_AND_MEAN
#define WINDOWS_LEAN_AND_MEAN
#endif
#include <winsock2.h>
#include <windows.h>
#define RECURSIVE_MUTEXES 1
#define simpleMutex CRITICAL_SECTION
#define simpleMutexInit(p) InitializeCriticalSection(p)
#define simpleMutexDelete(p) DeleteCriticalSection(p)
#define simpleMutexLock(p) EnterCriticalSection(p)
#if _WIN32_WINNT >= 0x0400
#define simpleMutexTryLock(p) TryEnterCriticalSection(p)
#endif
#define simpleMutexUnlock(p) LeaveCriticalSection(p)
#else /* USE_CRITICAL_SECTIONS */
typedef pthread_mutex_t simpleMutex;
#define simpleMutexInit(p) pthread_mutex_init(p, NULL)
#define simpleMutexDelete(p) pthread_mutex_destroy(p)
#define simpleMutexLock(p) pthread_mutex_lock(p)
#define simpleMutexTryLock(p) (pthread_mutex_trylock(p) == 0)
#define simpleMutexUnlock(p) pthread_mutex_unlock(p)
#endif /*USE_CRITICAL_SECTIONS*/
/* This struct name also appears in SWI-Stream.h */
typedef struct recursiveMutex {
pthread_mutex_t lock;
#ifndef RECURSIVE_MUTEXES
pthread_t owner;
unsigned int count;
#endif
} recursiveMutex;
#ifdef RECURSIVE_MUTEXES
#define NEED_RECURSIVE_MUTEX_INIT 1
extern int recursiveMutexInit(recursiveMutex *m);
#define recursiveMutexDelete(p) pthread_mutex_destroy(&((p)->lock))
#define recursiveMutexLock(p) pthread_mutex_lock(&((p)->lock))
#define recursiveMutexTryLock(p) pthread_mutex_trylock(&((p)->lock))
#define recursiveMutexUnlock(p) pthread_mutex_unlock(&((p)->lock))
#else /*RECURSIVE_MUTEXES*/
#define NEED_RECURSIVE_MUTEX_INIT 1
#define NEED_RECURSIVE_MUTEX_DELETE 1
extern int recursiveMutexInit(recursiveMutex *m);
extern int recursiveMutexDelete(recursiveMutex *m);
extern int recursiveMutexLock(recursiveMutex *m);
extern int recursiveMutexTryLock(recursiveMutex *m);
extern int recursiveMutexUnlock(recursiveMutex *m);
#endif /*RECURSIVE_MUTEXES*/
#ifdef simpleMutexTryLock
#define O_CONTENTION_STATISTICS 1
#ifndef USE_CRITICAL_SECTIONS
#include <errno.h>
#endif
#endif
typedef struct counting_mutex
{ simpleMutex mutex; /* mutex itself */
const char *name; /* name of the mutex */
uint64_t count; /* # times locked */
unsigned int lock_count; /* # times unlocked */
#ifdef O_CONTENTION_STATISTICS
unsigned int collisions; /* # contentions */
#endif
struct counting_mutex *next; /* next of allocated chain */
struct counting_mutex *prev; /* prvious in allocated chain */
} counting_mutex;
extern counting_mutex *allocSimpleMutex(const char *name);
extern void initSimpleMutex(counting_mutex *m, const char *name);
extern void deleteSimpleMutex(counting_mutex *m);
extern void freeSimpleMutex(counting_mutex *m);
#else /*O_PLMT*/
#define simpleMutexInit(p) (void)0
#define simpleMutexDelete(p) (void)0
#define simpleMutexLock(p) (void)0
#define simpleMutexUnlock(p) (void)0
#endif /*O_PLMT*/
#endif /*PL_MUTEX_H_DEFINED*/
|
e02fe3b58d89187f051ecfa3067f8ebfe862c435
|
1885ce333f6980ab6aad764b3f8caf42094d9f7d
|
/test/e2e/test_master/wxWidgets/include/wx/help.h
|
d1ae7a906f4ded4296bf5520ea3f7ea421930758
|
[
"MIT"
] |
permissive
|
satya-das/cppparser
|
1dbccdeed4287c36c61edc30190c82de447e415b
|
f9a4cfac1a3af7286332056d7c661d86b6c35eb3
|
refs/heads/master
| 2023-07-06T00:55:23.382303
| 2022-10-03T19:40:05
| 2022-10-03T19:40:05
| 16,642,636
| 194
| 26
|
MIT
| 2023-06-26T13:44:32
| 2014-02-08T12:20:01
|
C++
|
UTF-8
|
C
| false
| false
| 890
|
h
|
help.h
|
/////////////////////////////////////////////////////////////////////////////
// Name: wx/help.h
// Purpose: wxHelpController base header
// Author: wxWidgets Team
// Modified by:
// Created:
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_HELP_H_BASE_
# define _WX_HELP_H_BASE_
# include "wx/defs.h"
# if wxUSE_HELP
# include "wx/helpbase.h"
# if defined(__WXMSW__)
# include "wx/msw/helpchm.h"
# define wxHelpController wxCHMHelpController
# else
# if wxUSE_WXHTML_HELP
# include "wx/html/helpctrl.h"
# define wxHelpController wxHtmlHelpController
# else
# include "wx/generic/helpext.h"
# define wxHelpController wxExtHelpController
# endif
# endif
# endif
#endif
// _WX_HELP_H_BASE_
|
fcab4d9cad0cf65e03a12d4c874eaa92aa0e7e3f
|
488e6c9b8555a253df765edc2232e8750e8b3a1b
|
/firmware-src/sources/devices/bmp280.h
|
2bf732f68bf912b0e62c41628dfb71c0bb896358
|
[
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-proprietary-license"
] |
permissive
|
devicehive/esp8266-firmware
|
32edadae1d919438fd13388b562979030cc4472a
|
eb8a61482035bfc93a343db386d4470d17fa13d6
|
refs/heads/develop
| 2021-01-01T16:44:57.970370
| 2019-03-28T12:48:43
| 2019-03-28T12:48:43
| 39,383,605
| 182
| 61
|
MIT
| 2018-05-07T20:43:14
| 2015-07-20T12:53:51
|
C
|
UTF-8
|
C
| false
| false
| 998
|
h
|
bmp280.h
|
/**
* @file
* @brief Simple communication with BMP280 pressure sensor.
* @copyright 2016 [DeviceHive](http://devicehive.com)
* @author Nikolay Khabarov
*/
#ifndef _DEVICES_BMP280_H_
#define _DEVICES_BMP280_H_
#include "user_config.h"
#if defined(DH_DEVICE_BMP280)
/**
* @brief Measure pressure one time.
* @param[in] sda Pin for I2C's SDA. Can be DH_I2C_NO_PIN.
* @param[in] scl Pin for I2C's SCL. Can be DH_I2C_NO_PIN.
* @param[out] pressure Pointer for storing pressure result measure in Pascals.
* @param[out] temperature Pointer for storing temperature result measure in degree Celsius. Can be NULL.
* @return Status value, one of DH_I2C_Status enum.
*/
int bmp280_read(int sda, int scl,
float *pressure,
float *temperature);
/**
* @brief Set sensor address which should be used while reading.
* @param[in] address I2C end device address.
*/
void bmp280_set_address(int address);
#endif /* DH_DEVICE_BMP280 */
#endif /* _DEVICES_BMP280_H_ */
|
a1691a04fa5c9dede9f3cd92946773881cf793aa
|
90f4fefd00d7baf1fb0137c66f22222f3a0b1d4d
|
/Blinker/BlinkerBLE.c
|
77dcd7e2440728a31e74e543214cb53029759c85
|
[] |
no_license
|
blinker-iot/blinker-nRF52
|
969e9f49e7c80d661215007a330232b2168a80c4
|
501322572e0ce4f633ef402419f879c2ab84d24c
|
refs/heads/dev_1.0
| 2023-04-03T11:46:04.909891
| 2021-04-15T14:33:14
| 2021-04-15T14:33:14
| 241,844,430
| 1,739
| 3
| null | 2021-04-15T09:33:19
| 2020-02-20T09:33:02
|
C
|
UTF-8
|
C
| false
| false
| 35,842
|
c
|
BlinkerBLE.c
|
/**
* Copyright (c) 2017 - 2019, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/** @brief GATT Service client example application main file.
@details This file contains the main source code for a sample client application that uses the
GATT Service. This client can be used to receive Service Changed indications. This is
needed if your application interacts with GATT servers that modify, remove or add
services. A typical course of action if a Service Changed indication is received is to
rediscover the database on the peer device.
For more information about the GATT Service, see "Defined Generic Attribute Profile Service"
in Bluetooth Specification Version 5.0 Vol 3, Part G Section 7.
*/
#include "BlinkerBle.h"
#if NRF_MODULE_ENABLED(BLINKER_BLE)
// #include "app_adv.h"
#include "nordic_common.h"
#include "nrf.h"
#include "app_error.h"
#include "ble.h"
#include "ble_srv_common.h"
#include "ble_advdata.h"
#include "ble_advertising.h"
#include "nrf_sdh.h"
#include "nrf_sdh_soc.h"
#include "nrf_sdh_ble.h"
#include "app_timer.h"
#include "bsp.h"
#include "bsp_btn_ble.h"
#include "nrf_ble_gatts_c.h"
#include "boards.h"
#include "ble_gap.h"
#include "nrf_ble_gatt.h"
#include "nrf_ble_qwr.h"
#include "peer_manager.h"
#include "peer_manager_handler.h"
#include "fds.h"
#include "ble_conn_state.h"
#include "nrf_pwr_mgmt.h"
#include "app_adv.h"
#include "ble_advdata.h"
#include "ble_advertising.h"
#include "bsp.h"
#include "peer_manager.h"
#include "nrf_sdh.h"
#include "nrf_sdh_soc.h"
#include "nrf_sdh_ble.h"
#include "nrf_log.h"
#include "nrf_log_ctrl.h"
#include "nrf_log_default_backends.h"
#define APP_BLE_OBSERVER_PRIO 3 /**< Application's BLE observer priority. You shouldn't need to modify this value. */
#define APP_BLE_CONN_CFG_TAG 1 /**< A tag identifying the SoftDevice BLE configuration. */
#define DEAD_BEEF 0xDEADBEEF /**< Value used as error code on stack dump, can be used to identify stack location on stack unwind. */
#define APP_ADV_FAST_INTERVAL 0x0028 /**< Fast advertising interval (in units of 0.625 ms. This value corresponds to 25 ms.). */
#define APP_ADV_SLOW_INTERVAL 0x0C80 /**< Slow advertising interval (in units of 0.625 ms. This value corrsponds to 2 seconds). */
#define APP_ADV_FAST_DURATION 0 /**< The advertising duration (180 seconds) in units of 10 milliseconds. */
// #define APP_ADV_SLOW_DURATION 18000 /**< The advertising duration of slow advertising in units of 10 milliseconds. */
#define MIN_CONN_INTERVAL MSEC_TO_UNITS(50, UNIT_1_25_MS) /**< Minimum acceptable connection interval (20 ms), Connection interval uses 1.25 ms units. */
#define MAX_CONN_INTERVAL MSEC_TO_UNITS(100, UNIT_1_25_MS) /**< Maximum acceptable connection interval (75 ms), Connection interval uses 1.25 ms units. */
#define SLAVE_LATENCY 0 /**< Slave latency. */
#define CONN_SUP_TIMEOUT MSEC_TO_UNITS(4000, UNIT_10_MS) /**< Connection supervisory timeout (4 seconds), Supervision Timeout uses 10 ms units. */
#define FIRST_CONN_PARAMS_UPDATE_DELAY APP_TIMER_TICKS(5000) /**< Time from initiating event (connect or start of notification) to first time sd_ble_gap_conn_param_update is called (5 seconds). */
#define NEXT_CONN_PARAMS_UPDATE_DELAY APP_TIMER_TICKS(30000) /**< Time between each call to sd_ble_gap_conn_param_update after the first call (30 seconds). */
#define MAX_CONN_PARAMS_UPDATE_COUNT 3 /**< Number of attempts before giving up the connection parameter negotiation. */
#define BTS_SERVICE_UUID_TYPE BLE_UUID_TYPE_VENDOR_BEGIN /**< UUID type for the Nordic UART Service (vendor specific). */
#define APP_BLE_CONN_CFG_TAG 1 /**< A tag for a BLE stack configuration .*/
#define APP_ADV_DURATION BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED /**< The advertising duration in units of 10 milliseconds. */
BLE_BTS_DEF(m_bts, NRF_SDH_BLE_TOTAL_LINK_COUNT); /**< Link Loss service instance. */
NRF_BLE_GATT_DEF(m_gatt); /**< GATT module instance. */
NRF_BLE_GATTS_C_DEF(m_gatts_c); /**< GATT Service client instance. Handles Service Changed indications from the peer. */
NRF_BLE_QWR_DEF(m_qwr); /**< Context for the Queued Write module.*/
BLE_DB_DISCOVERY_DEF(m_ble_db_discovery); /**< DB discovery module instance. */
NRF_BLE_GQ_DEF(m_ble_gatt_queue, /**< BLE GATT Queue instance. */
NRF_SDH_BLE_PERIPHERAL_LINK_COUNT,
NRF_BLE_GQ_QUEUE_SIZE);
BLE_ADVERTISING_DEF(m_advertising); /**< Advertising module instance. */
static uint16_t m_conn_handle = BLE_CONN_HANDLE_INVALID; /**< Handle of the current connection. */
static uint16_t m_ble_bts_max_data_len = BLE_GATT_ATT_MTU_DEFAULT - 3; /**< Maximum length of data (in bytes) that can be transmitted to the peer by the Nordic UART service module. */
static bool m_erase_bonds; /**< Bool to determine if bonds should be erased before advertising starts. Based on button push upon startup. */
static ble_uuid_t m_adv_uuids[] = /**< Universally unique service identifiers. */
{
{0xFFE0, BLE_UUID_TYPE_BLE},
// {BLE_UUID_IMMEDIATE_ALERT_SERVICE, BLE_UUID_TYPE_BLE},
// {BLE_UUID_BATTERY_SERVICE, BLE_UUID_TYPE_BLE},
// // {BLE_UUID_TX_POWER_SERVICE, BLE_UUID_TYPE_BLE},
// {BLE_UUID_LINK_LOSS_SERVICE, BLE_UUID_TYPE_BLE}
};
static uint8_t m_pm_peer_srv_buffer[ALIGN_NUM(4, sizeof(ble_gatt_db_srv_t))] = {0}; /**< Data written to flash by peer manager must be aligned on 4 bytes.
When loading and storing we will treat this byte array as a ble_gatt_db_srv_t.
We use a static variable because it is written asynchronously. */
blinker_callback_with_string_arg_t blinker_parse_func = NULL;
static bool ble_connect_state = false;
static char ble_buf[BLINKER_MAX_READ_SIZE];
static bool ble_fresh = false;
static bool ble_avail = false;
static uint32_t ble_buf_len;
bool blinker_ble_connect(void) { return ble_connect_state; }
bool blinker_ble_connected(void) { return ble_connect_state; }
void blinker_ble_disconnect(void) { advertising_start(&m_erase_bonds); }
bool blinker_ble_avaliable(void)
{
if (ble_avail)
{
ble_avail = false;
return true;
}
else
{
return false;
}
}
char * blinker_ble_lastread(void) { return ble_buf;}
void blinker_ble_flush(void)
{
if (ble_fresh)
{
NRF_LOG_INFO("blinker ble flush");
// free(ble_buf);
ble_fresh = false;
ble_avail = false;
}
}
/**@brief Function for handling the data from the Nordic UART Service.
*
* @details This function will process the data received from the Nordic UART BLE Service and send
* it to the UART module.
*
* @param[in] p_evt Nordic UART Service event.
*/
/**@snippet [Handling the data received over BLE] */
static void bts_data_handler(ble_bts_evt_t * p_evt)
{
if (p_evt->evt_type == BLE_BTS_EVT_RX_DATA)
{
// uint32_t err_code;
if (p_evt->params.rx_data.length > 0)
{
// if (!ble_buf_len)
// {
// ble_buf = (char*)malloc((p_evt->params.rx_data.length + 1)*sizeof(char));
// }
// else
// {
// free(ble_buf);
// ble_buf = (char*)malloc((p_evt->params.rx_data.length + 1)*sizeof(char));
// }
strcpy(ble_buf, p_evt->params.rx_data.p_data);
ble_buf_len = p_evt->params.rx_data.length;
ble_buf[ble_buf_len] = '\0';
}
ble_fresh = true;
ble_avail = true;
if (ble_buf[ble_buf_len - 1] == '\n') ble_buf[ble_buf_len - 1] = '\0';
if (ble_buf[ble_buf_len - 2] == '\r') ble_buf[ble_buf_len - 2] = '\0';
NRF_LOG_INFO("get data: %s, len: %d", ble_buf, ble_buf_len);
// NRF_LOG_INFO("get data: %s, len: %d", p_evt->params.rx_data.p_data, p_evt->params.rx_data.length);
// NRF_LOG_INFO("heap: %d", xPortGetFreeHeapSize());
if (blinker_parse_func) blinker_parse_func(ble_buf);
// NRF_LOG_DEBUG("Received data from BLE BTS. Writing data on UART.");
// NRF_LOG_HEXDUMP_DEBUG(p_evt->params.rx_data.p_data, p_evt->params.rx_data.length);
// for (uint32_t i = 0; i < p_evt->params.rx_data.length; i++)
// {
// do
// {
// err_code = app_uart_put(p_evt->params.rx_data.p_data[i]);
// if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_BUSY))
// {
// NRF_LOG_ERROR("Failed receiving BTS message. Error 0x%x. ", err_code);
// APP_ERROR_CHECK(err_code);
// }
// } while (err_code == NRF_ERROR_BUSY);
// }
// if (p_evt->params.rx_data.p_data[p_evt->params.rx_data.length - 1] == '\r')
// {
// while (app_uart_put('\n') == NRF_ERROR_BUSY);
// }
}
// static uint8_t data_array[BLE_BTS_MAX_DATA_LEN];
// static uint8_t index;
// uint32_t err_code;
// static char data_buf[BLE_BTS_MAX_DATA_LEN] = { 0 };
// memcpy(data_buf, p_evt->params.rx_data.p_data, p_evt->params.rx_data.length);
// strcpy(data_array, data_buf);
// strcat(data_array, "\r\n");
// NRF_LOG_INFO("bts_data_handler: %s, %d", data_buf, p_evt->params.rx_data.length);
// index = p_evt->params.rx_data.length + 2;
// NRF_LOG_INFO("bts_data_handler end");
// if (index > 0)
// {
// if ((data_array[index - 1] == '\n') ||
// (data_array[index - 1] == '\r') ||
// (index >= m_ble_bts_max_data_len))
// {
// if (index > 1)
// {
// NRF_LOG_DEBUG("Ready to send data over BLE BTS");
// NRF_LOG_HEXDUMP_DEBUG(data_array, index);
// NRF_LOG_INFO("send data over BLE BTS: len: %d, %s", index, data_array);
// do
// {
// NRF_LOG_INFO("m_conn_handle %d.", m_conn_handle);
// uint16_t length = (uint16_t)index;
// err_code = ble_bts_data_send(&m_bts, data_array, &length, m_conn_handle);
// if ((err_code != NRF_ERROR_INVALID_STATE) &&
// (err_code != NRF_ERROR_RESOURCES) &&
// (err_code != NRF_ERROR_NOT_FOUND))
// {
// APP_ERROR_CHECK(err_code);
// NRF_LOG_INFO("Failed...err_code: %d", err_code);
// }
// // blinker_ble_print(data_array, false);
// } while (err_code == NRF_ERROR_RESOURCES);
// // blinker_ble_print(data_array, false);
// }
// index = 0;
// }
// }
}
void blinker_ble_print(char * data, bool need_check)
{
NRF_LOG_INFO("response: %s, len: %d", data, strlen(data));
if (ble_connect_state && strlen(data))
{
uint32_t err_code;
uint16_t length = (uint16_t)strlen(data);
uint16_t send_len = 0;
uint8_t parts = length / 20 + 1;
char s_send[23] = {0};
for (uint8_t num = 0; num < parts; num++)
{
if ((num + 1) == parts)
{
blinker_substring(s_send, data, num*(20), length);
send_len = length - num*(20);
}
else
{
blinker_substring(s_send, data, num*(20), (num+1)*20);
send_len = 20;
}
do
{
err_code = ble_bts_data_send(&m_bts, s_send, &send_len, m_conn_handle);
if ((err_code != NRF_ERROR_INVALID_STATE) &&
(err_code != NRF_ERROR_RESOURCES) &&
(err_code != NRF_ERROR_NOT_FOUND))
{
APP_ERROR_CHECK(err_code);
}
} while (err_code == NRF_ERROR_RESOURCES);
}
NRF_LOG_INFO("Success...");
}
else
{
NRF_LOG_INFO("Failed... Disconnected");
}
}
/**@brief Function for handling advertising events.
@details This function will be called for advertising events which are passed to the application.
@param[in] ble_adv_evt Advertising event.
*/
void on_adv_evt(ble_adv_evt_t ble_adv_evt)
{
ret_code_t err_code;
switch (ble_adv_evt)
{
case BLE_ADV_EVT_FAST:
NRF_LOG_INFO("Fast advertising.");
err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING);
APP_ERROR_CHECK(err_code);
break;
case BLE_ADV_EVT_IDLE:
NRF_LOG_INFO("Advertising stopped.");
break;
default:
break;
}
}
/**@brief Function for initializing the Advertising functionality.
@details Encodes the required advertising data and passes it to the stack.
Also builds a structure to be passed to the stack when starting advertising.
*/
void advertising_init(void)
{
ret_code_t err_code;
ble_advertising_init_t init;
memset(&init, 0, sizeof(init));
ble_gap_addr_t ble_addr;
sd_ble_gap_addr_get(&ble_addr);
// FICR->DEVICEADDR[x]
ble_advdata_manuf_data_t manuf_data; //Variable to hold manufacturer specific data
// uint8_t data[] = "blinker test!"; //Our data to advertise
manuf_data.company_identifier = 0x4444; //Nordics company ID
manuf_data.data.p_data = ble_addr.addr;//data;
manuf_data.data.size = sizeof(ble_addr.addr);//sizeof(data);
init.advdata.p_manuf_specific_data = &manuf_data;
init.advdata.name_type = BLE_ADVDATA_FULL_NAME;
init.advdata.include_appearance = true;
init.advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
init.advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
init.advdata.uuids_complete.p_uuids = m_adv_uuids;
init.config.ble_adv_fast_enabled = true;
init.config.ble_adv_fast_interval = ADV_INTERVAL;
init.config.ble_adv_fast_timeout = APP_ADV_DURATION;
init.evt_handler = on_adv_evt;
err_code = ble_advertising_init(&m_advertising, &init);
APP_ERROR_CHECK(err_code);
ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
}
/**@brief Function for starting advertising, or instead trigger it from peer manager (after
deleting bonds).
@param[in] erase_bonds Bool to determine if bonds will be deleted before advertising.
*/
void advertising_start(bool erase_bonds)
{
ret_code_t err_code;
if (erase_bonds == true)
{
// Advertising is started by the PM_EVT_PEERS_DELETE_SUCCEEDED event.
NRF_LOG_INFO("Erase bonds.");
err_code = pm_peers_delete();
APP_ERROR_CHECK(err_code);
}
else
{
err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST);
APP_ERROR_CHECK(err_code);
}
}
/**@brief Function for assert macro callback.
@details This function will be called in case of an assert in the SoftDevice.
@warning This handler is an example only and does not fit a final product. You need to analyze
how your product is supposed to react in case of Assert.
@warning On assert from the SoftDevice, the system can only recover on reset.
@param[in] line_num Line number of the failing ASSERT call.
@param[in] p_file_name File name of the failing ASSERT call.
*/
void assert_nrf_callback(uint16_t line_num, const uint8_t * p_file_name)
{
app_error_handler(DEAD_BEEF, line_num, p_file_name);
}
/**@brief Function for handling the GATT Service Client errors.
*
* @param[in] nrf_error Error code containing information about what went wrong.
*/
static void gatt_c_error_handler(uint32_t nrf_error)
{
APP_ERROR_HANDLER(nrf_error);
}
/**@brief Function for the LEDs initialization.
@details Initializes all LEDs used by the application.
*/
static void leds_init(void)
{
bsp_board_init(BSP_INIT_LEDS);
}
/**@brief Function for the Timer initialization.
@details Initializes the timer module.
*/
static void timers_init(void)
{
ret_code_t err_code;
err_code = app_timer_init();
APP_ERROR_CHECK(err_code);
}
/**@brief Function for the GAP initialization.
@details This function sets up all the necessary GAP (Generic Access Profile) parameters of the
device including the device name, appearance, and the preferred connection parameters.
*/
static void gap_params_init(void)
{
ret_code_t err_code;
ble_gap_conn_params_t gap_conn_params;
ble_gap_conn_sec_mode_t sec_mode;
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
err_code = sd_ble_gap_device_name_set(&sec_mode,
(const uint8_t *)DEVICE_NAME,
strlen(DEVICE_NAME));
APP_ERROR_CHECK(err_code);
memset(&gap_conn_params, 0, sizeof(gap_conn_params));
gap_conn_params.min_conn_interval = MSEC_TO_UNITS(MIN_CONN_INTERVAL_MSEC, UNIT_1_25_MS);
gap_conn_params.max_conn_interval = MSEC_TO_UNITS(MAX_CONN_INTERVAL_MSEC, UNIT_1_25_MS);
gap_conn_params.slave_latency = SLAVE_LATENCY;
gap_conn_params.conn_sup_timeout = MSEC_TO_UNITS(CONN_SUP_TIMEOUT_MSEC, UNIT_10_MS);
err_code = sd_ble_gap_ppcp_set(&gap_conn_params);
APP_ERROR_CHECK(err_code);
}
/**@brief Function for initializing buttons and leds.
@param[out] p_erase_bonds Boolean that will be set to true if the device is
woken up by the BSP_EVENT_CLEAR_BONDING_DATA event.
*/
static void buttons_leds_init(bool * p_erase_bonds)
{
ret_code_t err_code;
bsp_event_t startup_event;
err_code = bsp_init(BSP_INIT_LEDS | BSP_INIT_BUTTONS, NULL);
APP_ERROR_CHECK(err_code);
err_code = bsp_btn_ble_init(NULL, &startup_event);
APP_ERROR_CHECK(err_code);
*p_erase_bonds = (startup_event == BSP_EVENT_CLEAR_BONDING_DATA);
}
/**@brief Function for handling events from the GATT Servive client module.
@param[in] p_evt GATT Service event.
*/
static void gatts_evt_handler(nrf_ble_gatts_c_evt_t * p_evt)
{
ret_code_t err_code;
switch (p_evt->evt_type)
{
case NRF_BLE_GATTS_C_EVT_DISCOVERY_COMPLETE:
{
NRF_LOG_INFO("GATT Service and Service Changed characteristic found on server.");
err_code = nrf_ble_gatts_c_handles_assign(&m_gatts_c,
p_evt->conn_handle,
&p_evt->params.srv_changed_char);
APP_ERROR_CHECK(err_code);
pm_peer_id_t peer_id;
err_code = pm_peer_id_get(p_evt->conn_handle, &peer_id);
APP_ERROR_CHECK(err_code);
ble_gatt_db_srv_t srv_db_to_store;
srv_db_to_store.charateristics[0] = p_evt->params.srv_changed_char;
memcpy(m_pm_peer_srv_buffer, &srv_db_to_store, sizeof(ble_gatt_db_srv_t));
err_code = pm_peer_data_remote_db_store(peer_id,
(ble_gatt_db_srv_t *)m_pm_peer_srv_buffer,
sizeof(m_pm_peer_srv_buffer),
NULL);
if (err_code == NRF_ERROR_STORAGE_FULL)
{
err_code = fds_gc();
}
APP_ERROR_CHECK(err_code);
err_code = nrf_ble_gatts_c_enable_indication(&m_gatts_c, true);
APP_ERROR_CHECK(err_code);
} break;
case NRF_BLE_GATTS_C_EVT_DISCOVERY_FAILED:
NRF_LOG_INFO("GATT Service or Service Changed characteristic not found on server.");
break;
case NRF_BLE_GATTS_C_EVT_DISCONN_COMPLETE:
NRF_LOG_INFO("GATTS Service client disconnected connection handle %i.", p_evt->conn_handle);
break;
case NRF_BLE_GATTS_C_EVT_SRV_CHANGED:
NRF_LOG_INFO("Service Changed indication received.");
NRF_LOG_INFO("Handle range start: %04x", p_evt->params.handle_range.start_handle);
NRF_LOG_INFO("Handle range end: %04x", p_evt->params.handle_range.end_handle);
break;
default:
break;
}
}
/**@brief Function for handling Peer Manager events.
*
* @param[in] p_evt Peer Manager event.
*/
static void pm_evt_handler(pm_evt_t const * p_evt)
{
ret_code_t err_code;
pm_handler_on_pm_evt(p_evt);
pm_handler_flash_clean(p_evt);
switch (p_evt->evt_id)
{
case PM_EVT_BONDED_PEER_CONNECTED:
{
pm_peer_id_t peer_id;
err_code = pm_peer_id_get(p_evt->conn_handle, &peer_id);
APP_ERROR_CHECK(err_code);
if (peer_id != PM_PEER_ID_INVALID)
{
ble_gatt_db_srv_t * remote_db;
remote_db = (ble_gatt_db_srv_t *)m_pm_peer_srv_buffer;
uint32_t data_len = sizeof(m_pm_peer_srv_buffer);
err_code = pm_peer_data_remote_db_load(peer_id, remote_db, &data_len);
if (err_code == NRF_ERROR_NOT_FOUND)
{
NRF_LOG_DEBUG("Could not find the remote database in flash.");
err_code = nrf_ble_gatts_c_handles_assign(&m_gatts_c, p_evt->conn_handle, NULL);
APP_ERROR_CHECK(err_code);
// Discover peer's services.
memset(&m_ble_db_discovery, 0x00, sizeof(m_ble_db_discovery));
err_code = ble_db_discovery_start(&m_ble_db_discovery, p_evt->conn_handle);
APP_ERROR_CHECK(err_code);
}
else
{
// Check if the load was successful.
NRF_LOG_INFO("Remote Database loaded from flash.");
APP_ERROR_CHECK(err_code);
// Assign the loaded handles to the GATT Service client module.
ble_gatt_db_char_t service_changed_handles = remote_db->charateristics[0];
err_code = nrf_ble_gatts_c_handles_assign(&m_gatts_c,
p_evt->conn_handle,
&service_changed_handles);
APP_ERROR_CHECK(err_code);
// Enable indications.
err_code = nrf_ble_gatts_c_enable_indication(&m_gatts_c, true);
APP_ERROR_CHECK(err_code);
}
}
} break;
case PM_EVT_CONN_SEC_SUCCEEDED:
// Check it the Service Changed characteristic handle exists in our client instance.
// If it is invalid, we know service discovery is needed.
// (No database was loaded during @ref PM_EVT_BONDED_PEER_CONNECTED)
if (m_gatts_c.srv_changed_char.characteristic.handle_value == BLE_GATT_HANDLE_INVALID)
{
err_code = nrf_ble_gatts_c_handles_assign(&m_gatts_c, p_evt->conn_handle, NULL);
APP_ERROR_CHECK(err_code);
// Discover peer's services.
memset(&m_ble_db_discovery, 0x00, sizeof(m_ble_db_discovery));
err_code = ble_db_discovery_start(&m_ble_db_discovery, p_evt->conn_handle);
APP_ERROR_CHECK(err_code);
}
break;
case PM_EVT_PEERS_DELETE_SUCCEEDED:
// Peer data was cleared from the flash. Start advertising with an empty list of peers.
advertising_start(false);
break;
default:
// No implementation needed.
break;
}
}
/**@brief Function for initializing the Peer Manager.
*/
void peer_manager_init(void)
{
ret_code_t err_code;
ble_gap_sec_params_t sec_param;
err_code = pm_init();
APP_ERROR_CHECK(err_code);
memset(&sec_param, 0, sizeof(ble_gap_sec_params_t));
// Security parameters to be used for all security procedures.
sec_param.bond = SEC_PARAM_BOND;
sec_param.mitm = SEC_PARAM_MITM;
sec_param.io_caps = SEC_PARAM_IO_CAPABILITIES;
sec_param.oob = SEC_PARAM_OOB;
sec_param.min_key_size = SEC_PARAM_MIN_KEY_SIZE;
sec_param.max_key_size = SEC_PARAM_MAX_KEY_SIZE;
sec_param.kdist_own.enc = 1;
sec_param.kdist_own.id = 1;
sec_param.kdist_peer.enc = 1;
sec_param.kdist_peer.id = 1;
err_code = pm_sec_params_set(&sec_param);
APP_ERROR_CHECK(err_code);
err_code = pm_register(pm_evt_handler);
APP_ERROR_CHECK(err_code);
}
/**@brief Function for handling database discovery events.
@details This function is callback function to handle events from the database discovery module.
Depending on the UUIDs that are discovered, this function should forward the events
to their respective services.
@param[in] p_event Pointer to the database discovery event.
*/
static void db_disc_handler(ble_db_discovery_evt_t * p_evt)
{
nrf_ble_gatts_c_on_db_disc_evt(&m_gatts_c, p_evt);
}
/**@brief Function for handling connection events.
@param[in] p_ble_evt Bluetooth stack event.
*/
static void on_connect(ble_evt_t const * p_ble_evt)
{
ret_code_t err_code;
NRF_LOG_INFO("Connected.");
err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
APP_ERROR_CHECK(err_code);
m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
err_code = nrf_ble_qwr_conn_handle_assign(&m_qwr, m_conn_handle);
APP_ERROR_CHECK(err_code);
ble_connect_state = true;
}
/**@brief Function for handling timeout BLE stack events.
@param[in] p_ble_evt Bluetooth stack event.
*/
static void on_timeout(ble_evt_t const * p_ble_evt)
{
ret_code_t err_code;
switch (p_ble_evt->header.evt_id)
{
case BLE_GATTC_EVT_TIMEOUT:
NRF_LOG_DEBUG("GATT Client Timeout.");
err_code = sd_ble_gap_disconnect(p_ble_evt->evt.gattc_evt.conn_handle,
BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
APP_ERROR_CHECK(err_code);
break;
case BLE_GATTS_EVT_TIMEOUT:
NRF_LOG_DEBUG("GATT Server Timeout.");
err_code = sd_ble_gap_disconnect(p_ble_evt->evt.gatts_evt.conn_handle,
BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
APP_ERROR_CHECK(err_code);
break;
default:
// No implementation needed.
break;
}
}
/**@brief Function for handling BLE events.
*
* @param[in] p_ble_evt Bluetooth stack event.
* @param[in] p_context Unused.
*/
static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
{
ret_code_t err_code;
pm_handler_secure_on_connection(p_ble_evt);
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_CONNECTED:
{
on_connect(p_ble_evt);
} break;
case BLE_GAP_EVT_DISCONNECTED:
NRF_LOG_INFO("Disconnected.");
m_conn_handle = BLE_CONN_HANDLE_INVALID;
ble_connect_state = false;
break;
case BLE_GAP_EVT_PHY_UPDATE_REQUEST:
{
NRF_LOG_DEBUG("PHY update request.");
ble_gap_phys_t const phys =
{
.rx_phys = BLE_GAP_PHY_AUTO,
.tx_phys = BLE_GAP_PHY_AUTO,
};
err_code = sd_ble_gap_phy_update(p_ble_evt->evt.gap_evt.conn_handle, &phys);
APP_ERROR_CHECK(err_code);
} break;
case BLE_GATTS_EVT_SYS_ATTR_MISSING:
// No system attributes have been stored.
err_code = sd_ble_gatts_sys_attr_set(p_ble_evt->evt.gatts_evt.conn_handle, NULL, 0, 0);
APP_ERROR_CHECK(err_code);
break;
case BLE_GATTC_EVT_TIMEOUT:
// fall-through.
case BLE_GATTS_EVT_TIMEOUT:
on_timeout(p_ble_evt);
break;
default:
// No implementation needed.
break;
}
}
/**@brief Function for initializing the BLE stack.
@details Initializes the SoftDevice and the BLE event interrupt.
*/
static void ble_stack_init(void)
{
ret_code_t err_code;
err_code = nrf_sdh_enable_request();
APP_ERROR_CHECK(err_code);
// Configure the BLE stack using the default settings.
// Fetch the start address of the application RAM.
uint32_t ram_start = 0;
err_code = nrf_sdh_ble_default_cfg_set(APP_BLE_CONN_CFG_TAG, &ram_start);
APP_ERROR_CHECK(err_code);
// Enable BLE stack.
err_code = nrf_sdh_ble_enable(&ram_start);
APP_ERROR_CHECK(err_code);
// Register handler for BLE events.
NRF_SDH_BLE_OBSERVER(m_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_handler, NULL);
}
/** @brief Database discovery initialization.
*/
static void db_discovery_init(void)
{
ble_db_discovery_init_t db_init;
memset(&db_init, 0, sizeof(db_init));
db_init.evt_handler = db_disc_handler;
db_init.p_gatt_queue = &m_ble_gatt_queue;
ret_code_t err_code = ble_db_discovery_init(&db_init);
APP_ERROR_CHECK(err_code);
}
/**@brief Function for initializing the nrf log module.
*/
static void log_init(void)
{
ret_code_t err_code = NRF_LOG_INIT(NULL);
APP_ERROR_CHECK(err_code);
NRF_LOG_DEFAULT_BACKENDS_INIT();
}
/**@brief Function for initializing power management.
*/
static void power_management_init(void)
{
ret_code_t err_code;
err_code = nrf_pwr_mgmt_init();
APP_ERROR_CHECK(err_code);
}
/**@brief Function for handling the idle state (main loop). If there is no pending log operation,
then sleep until next the next event occurs.
*/
static void idle_state_handle(void)
{
if (NRF_LOG_PROCESS() == false)
{
nrf_pwr_mgmt_run();
}
}
/**@brief Function for initializing the GATT module.
*/
static void gatt_init(void)
{
ret_code_t err_code = nrf_ble_gatt_init(&m_gatt, NULL);
APP_ERROR_CHECK(err_code);
}
/**@brief Function for handling Queued Write Module errors.
*
* @details A pointer to this function will be passed to each service which may need to inform the
* application about an error.
*
* @param[in] nrf_error Error code containing information about what went wrong.
*/
static void nrf_qwr_error_handler(uint32_t nrf_error)
{
APP_ERROR_HANDLER(nrf_error);
}
/**@brief Function for initializing services that will be used by the application.
*/
static void services_init(void)
{
ret_code_t err_code;
nrf_ble_gatts_c_init_t gatts_c_init = {0};
nrf_ble_qwr_init_t qwr_init = {0};
ble_bts_init_t bts_init_obj;
// Initialize Link Loss Service
memset(&bts_init_obj, 0, sizeof(bts_init_obj));
// bts_init_obj.evt_handler = on_bts_evt;
// bts_init_obj.error_handler = service_error_handler;
// bts_init_obj.initial_alert_level = INITIAL_BTS_ALERT_LEVEL;
bts_init_obj.data_handler = bts_data_handler;
// bts_init_obj.alert_level_rd_sec = SEC_JUST_WORKS;
// bts_init_obj.alert_level_wr_sec = SEC_JUST_WORKS;
err_code = ble_bts_init(&m_bts, &bts_init_obj);
APP_ERROR_CHECK(err_code);
// Initialize Queued Write Module.
qwr_init.error_handler = nrf_qwr_error_handler;
err_code = nrf_ble_qwr_init(&m_qwr, &qwr_init);
APP_ERROR_CHECK(err_code);
// Initialize GATTS Client Module.
gatts_c_init.evt_handler = gatts_evt_handler;
gatts_c_init.err_handler = gatt_c_error_handler;
gatts_c_init.p_gatt_queue = &m_ble_gatt_queue;
err_code = nrf_ble_gatts_c_init(&m_gatts_c, &gatts_c_init);
APP_ERROR_CHECK(err_code);
}
/**@brief Function for initializing all the modules used in this example application.
*/
static void modules_init(void)
{
log_init();
leds_init();
timers_init();
buttons_leds_init(&m_erase_bonds);
power_management_init();
ble_stack_init();
gap_params_init();
gatt_init();
db_discovery_init();
services_init();
advertising_init();
peer_manager_init();
}
/**@brief Function for application main entry.
*/
void blinker_ble_init(blinker_callback_with_string_arg_t func)
// int blinker_ble_init(void)
{
blinker_parse_func = func;
// Initialize.
modules_init();
// Start execution.
NRF_LOG_INFO("GATT Service client started.");
advertising_start(m_erase_bonds);
// Enter main loop.
for (;;)
{
idle_state_handle();
}
}
/**
* @}
*/
#endif
|
33a497305bbc4556d8bea3608bbaf115b14088fa
|
98fb215e1111bc72ad69b5c4634adcf73ca2f8ec
|
/GRRLIB/GRRLIB/grrlib/GRRLIB__lib.h
|
f02a996ef8602870892b96f2f8ecb15e76f9974d
|
[
"GPL-1.0-or-later",
"MIT"
] |
permissive
|
GRRLIB/GRRLIB
|
aa3915bc232cadd17b74ce7e666706529d0b87b0
|
f2235220d5b1e10fd52e534bdd4da26284b7e737
|
refs/heads/master
| 2023-02-24T23:59:18.082858
| 2023-02-05T19:22:25
| 2023-02-05T19:37:15
| 32,872,649
| 115
| 29
|
MIT
| 2023-08-24T14:23:21
| 2015-03-25T15:17:19
|
C
|
UTF-8
|
C
| false
| false
| 9,389
|
h
|
GRRLIB__lib.h
|
/*------------------------------------------------------------------------------
Copyright (c) 2009-2022 The GRRLIB Team
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
------------------------------------------------------------------------------*/
/**
* @file GRRLIB__lib.h
* GRRLIB library function prototypes.
* Do not include GRRLIB__lib.h directly, include only GRRLIB.h.
*/
/**
* @addtogroup AllFunc
* @{
*/
#ifndef __GRRLIB_H__
# error Do not include GRRLIB__lib.h directly, include only GRRLIB.h
#endif
#ifndef __GRRLIB_FNLIB_H__
#define __GRRLIB_FNLIB_H__
//==============================================================================
// Prototypes for library contained functions
//==============================================================================
//------------------------------------------------------------------------------
// GRRLIB_bmf.c - BitMapFont functions
GRRLIB_bytemapFont* GRRLIB_LoadBMF (const u8 my_bmf[] );
void GRRLIB_FreeBMF (GRRLIB_bytemapFont *bmf);
void GRRLIB_InitTileSet (GRRLIB_texImg *tex,
const u32 tilew, const u32 tileh,
const u32 tilestart);
//------------------------------------------------------------------------------
// GRRLIB_bmfx.c - Bitmap f/x
void GRRLIB_BMFX_FlipH (const GRRLIB_texImg *texsrc,
GRRLIB_texImg *texdest);
void GRRLIB_BMFX_FlipV (const GRRLIB_texImg *texsrc,
GRRLIB_texImg *texdest);
void GRRLIB_BMFX_Grayscale (const GRRLIB_texImg *texsrc,
GRRLIB_texImg *texdest);
void GRRLIB_BMFX_Sepia (const GRRLIB_texImg *texsrc,
GRRLIB_texImg *texdest);
void GRRLIB_BMFX_Invert (const GRRLIB_texImg *texsrc,
GRRLIB_texImg *texdest);
void GRRLIB_BMFX_Blur (const GRRLIB_texImg *texsrc,
GRRLIB_texImg *texdest, const u32 factor);
void GRRLIB_BMFX_Scatter (const GRRLIB_texImg *texsrc,
GRRLIB_texImg *texdest, const u32 factor);
void GRRLIB_BMFX_Pixelate (const GRRLIB_texImg *texsrc,
GRRLIB_texImg *texdest, const u32 factor);
//------------------------------------------------------------------------------
// GRRLIB_core.c - GRRLIB core functions
int GRRLIB_Init (void);
void GRRLIB_Exit (void);
//------------------------------------------------------------------------------
// GRRLIB_fbAdvanced.c - Render to framebuffer: Advanced primitives
void GRRLIB_Ellipse (const f32 x, const f32 y, const f32 radiusX,
const f32 radiusY, const u32 color, const u8 filled);
void GRRLIB_Circle (const f32 x, const f32 y, const f32 radius,
const u32 color, const u8 filled);
//------------------------------------------------------------------------------
// GRRLIB_fileIO - File I/O (SD Card)
int GRRLIB_LoadFile (const char* filename, u8* *data);
GRRLIB_texImg* GRRLIB_LoadTextureFromFile (const char* filename);
GRRLIB_ttfFont* GRRLIB_LoadTTFFromFile (const char* filename);
bool GRRLIB_ScrShot (const char* filename);
//------------------------------------------------------------------------------
// GRRLIB_print.c - Will someone please tell me what these are :)
void GRRLIB_Printf (const f32 xpos, const f32 ypos,
const GRRLIB_texImg *tex, const u32 color,
const f32 zoom, const char *text, ...);
void GRRLIB_PrintBMF (const f32 xpos, const f32 ypos,
const GRRLIB_bytemapFont *bmf,
const char *text, ...);
//------------------------------------------------------------------------------
// GRRLIB_render.c - Rendering functions
void GRRLIB_DrawImg (const f32 xpos, const f32 ypos, const GRRLIB_texImg *tex,
const f32 degrees, const f32 scaleX, const f32 scaleY,
const u32 color);
void GRRLIB_DrawImgQuad (const guVector pos[4], GRRLIB_texImg *tex,
const u32 color);
void GRRLIB_DrawTile (const f32 xpos, const f32 ypos, const GRRLIB_texImg *tex,
const f32 degrees, const f32 scaleX, const f32 scaleY,
const u32 color, const int frame);
void GRRLIB_DrawPart (const f32 xpos, const f32 ypos, const f32 partx, const f32 party,
const f32 partw, const f32 parth, const GRRLIB_texImg *tex,
const f32 degrees, const f32 scaleX, const f32 scaleY,
const u32 color);
void GRRLIB_DrawTileQuad (const guVector pos[4], GRRLIB_texImg *tex, const u32 color, const int frame);
void GRRLIB_Render (void);
//------------------------------------------------------------------------------
// GRRLIB_snapshot.c - Create a texture containing a snapshot of a part of the framebuffer
void GRRLIB_Screen2Texture (u16 posx, u16 posy, GRRLIB_texImg *tex, bool clear);
void GRRLIB_CompoStart (void);
void GRRLIB_CompoEnd(u16 posx, u16 posy, GRRLIB_texImg *tex);
//------------------------------------------------------------------------------
// GRRLIB_texEdit.c - Modifying the content of a texture
GRRLIB_texImg* GRRLIB_CreateEmptyTexture (const u32 width, const u32 height);
GRRLIB_texImg* GRRLIB_LoadTexture (const u8 *my_img);
GRRLIB_texImg* GRRLIB_LoadTexturePNG (const u8 *my_png);
GRRLIB_texImg* GRRLIB_LoadTextureJPG (const u8 *my_jpg);
GRRLIB_texImg* GRRLIB_LoadTextureJPGEx (const u8 *my_jpg, const u32 my_size);
GRRLIB_texImg* GRRLIB_LoadTextureBMP (const u8 *my_bmp);
//------------------------------------------------------------------------------
// GRRLIB_gecko.c - USB_Gecko output facilities
bool GRRLIB_GeckoInit();
void GRRLIB_GeckoPrintf (const char *text, ...);
//------------------------------------------------------------------------------
// GRRLIB_3D.c - 3D functions for GRRLIB
void GRRLIB_SetBackgroundColour(u8 r, u8 g, u8 b, u8 a);
void GRRLIB_Camera3dSettings(f32 posx, f32 posy, f32 posz, f32 upx, f32 upy, f32 upz, f32 lookx, f32 looky, f32 lookz);
void GRRLIB_3dMode(f32 minDist, f32 maxDist, f32 fov, bool texturemode, bool normalmode);
void GRRLIB_2dMode();
void GRRLIB_ObjectViewBegin(void);
void GRRLIB_ObjectViewScale(f32 scalx, f32 scaly, f32 scalz);
void GRRLIB_ObjectViewRotate(f32 angx, f32 angy, f32 angz);
void GRRLIB_ObjectViewTrans(f32 posx, f32 posy, f32 posz);
void GRRLIB_ObjectViewEnd(void);
void GRRLIB_ObjectView(f32 posx, f32 posy, f32 posz, f32 angx, f32 angy, f32 angz, f32 scalx, f32 scaly, f32 scalz);
void GRRLIB_ObjectViewInv(f32 posx, f32 posy, f32 posz, f32 angx, f32 angy, f32 angz, f32 scalx, f32 scaly, f32 scalz);
void GRRLIB_SetTexture(GRRLIB_texImg *tex, bool rep);
void GRRLIB_DrawTorus(f32 r, f32 R, int nsides, int rings, bool filled, u32 col);
void GRRLIB_DrawSphere(f32 r, int lats, int longs, bool filled, u32 col);
void GRRLIB_DrawCube(f32 size, bool filled, u32 col);
void GRRLIB_DrawCylinder(f32 r, f32 h, u16 d, bool filled, u32 col);
void GRRLIB_DrawCone(f32 r, f32 h, u16 d, bool filled, u32 col);
void GRRLIB_DrawTessPanel(f32 w, f32 wstep, f32 h, f32 hstep, bool filled, u32 col);
void GRRLIB_SetLightAmbient(u32 ambientcolor);
void GRRLIB_SetLightDiff(u8 num, guVector pos, f32 distattn, f32 brightness, u32 lightcolor);
void GRRLIB_SetLightSpec(u8 num, guVector dir, f32 shininess, u32 lightcolor, u32 speccolor);
void GRRLIB_SetLightSpot(u8 num, guVector pos, guVector lookat, f32 angAttn0, f32 angAttn1, f32 angAttn2, f32 distAttn0, f32 distAttn1, f32 distAttn2, u32 lightcolor);
void GRRLIB_SetLightOff(void);
//------------------------------------------------------------------------------
// GRRLIB_ttf.c - FreeType function for GRRLIB
GRRLIB_ttfFont* GRRLIB_LoadTTF(const u8* file_base, s32 file_size);
void GRRLIB_FreeTTF(GRRLIB_ttfFont *myFont);
void GRRLIB_PrintfTTF(int x, int y, GRRLIB_ttfFont *myFont, const char *string, unsigned int fontSize, const u32 color);
void GRRLIB_PrintfTTFW(int x, int y, GRRLIB_ttfFont *myFont, const wchar_t *string, unsigned int fontSize, const u32 color);
u32 GRRLIB_WidthTTF(GRRLIB_ttfFont *myFont, const char *, unsigned int);
u32 GRRLIB_WidthTTFW(GRRLIB_ttfFont *myFont, const wchar_t *, unsigned int);
#endif // __GRRLIB_FNLIB_H__
/** @} */ // end of group
|
ee48d95b73d4ca793a0422e1b6f0b5225bb58f9c
|
2b3bbfc742ad6a2529f2906193c3c5263ebd5fac
|
/tests/unit/app/driver/afe/maxim/common/test_mxm_17841b.c
|
ef7248cd29abbccad14c8aa46bee9b763b99cb15
|
[
"CC-BY-4.0",
"BSD-3-Clause"
] |
permissive
|
foxBMS/foxbms-2
|
35502ef8441dfc7374fd6c0839e7f5328a5bda8f
|
9eb6d1c44e63e43e62bbf6983b2e618fb6ad02cc
|
refs/heads/master
| 2023-05-22T05:30:25.862475
| 2023-02-23T15:03:35
| 2023-02-24T15:04:15
| 353,751,476
| 151
| 80
|
NOASSERTION
| 2023-09-01T09:59:30
| 2021-04-01T15:52:24
|
C
|
UTF-8
|
C
| false
| false
| 23,899
|
c
|
test_mxm_17841b.c
|
/**
*
* @copyright © 2010 - 2023, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V.
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* We kindly request you to use one or more of the following phrases to refer to
* foxBMS in your hardware, software, documentation or advertising materials:
*
* - ″This product uses parts of foxBMS®″
* - ″This product includes parts of foxBMS®″
* - ″This product is derived from foxBMS®″
*
*/
/**
* @file test_mxm_17841b.c
* @author foxBMS Team
* @date 2020-06-22 (date of creation)
* @updated 2023-02-23 (date of last update)
* @version v1.5.1
* @ingroup UNIT_TEST_IMPLEMENTATION
* @prefix MXM
*
* @brief Test for the Maxim MAX17841B driver.
*
* @details def
*
*/
/*========== Includes =======================================================*/
#include "unity.h"
#include "Mockfassert.h"
#include "Mockmxm_cfg.h"
#include "Mockos.h"
#include "mxm_17841b.h"
#include "mxm_bitextract.h"
#include "test_assert_helper.h"
#include <stdbool.h>
#include <stdint.h>
TEST_FILE("mxm_17841b.c")
/*========== Definitions and Implementations for Unit Test ==================*/
/** replicating the config register length in the driver */
#define MXM_41B_CONFIG_REGISTER_LENGTH (7u)
static MXM_41B_INSTANCE_s mxm_41bState = {
.state = MXM_STATEMACH_41B_UNINITIALIZED,
.substate = MXM_41B_ENTRY_SUBSTATE,
.extendMessageBytes = 0,
.waitCounter = 0,
.regRXIntEnable = 0x00u,
.regTXIntEnable = 0x00u,
.regRXStatus = 0x00u,
.regTXStatus = 0x00u,
.regConfig1 = MXM_41B_CONFIG_1_DEFAULT_VALUE,
.regConfig2 = MXM_41B_CONFIG_2_DEFAULT_VALUE,
.regConfig3 = MXM_41B_CONFIG_3_DEFAULT_VALUE,
.hwModel = 0,
.hwMaskRevision = 0,
.spiRXBuffer = {0},
.spiTXBuffer = {0},
};
uint16_t commandBuffer[10] = {0};
uint16_t rxBuffer[100] = {0};
MXM_41B_STATE_REQUEST_STATUS_e status41b = MXM_41B_STATE_UNPROCESSED;
/*========== Setup and Teardown =============================================*/
void setUp(void) {
MXM_41BInitializeStateStruct(&mxm_41bState);
mxm_41bState.processed = &status41b;
commandBuffer[0] = 0;
commandBuffer[1] = 0;
commandBuffer[2] = 0;
commandBuffer[3] = 0;
commandBuffer[4] = 0;
commandBuffer[5] = 0;
commandBuffer[6] = 0;
commandBuffer[7] = 0;
commandBuffer[8] = 0;
commandBuffer[9] = 0;
status41b = MXM_41B_STATE_UNPROCESSED;
}
void tearDown(void) {
}
/*========== Test Cases =====================================================*/
/**
* \defgroup mxm41b-set-state-request tests for function MXM_41BSetStateRequest
* @{
*/
/**
* @brief Test with an invalid pointer
* @details This test calls #MXM_41BSetStateRequest() with an invalid pointer
* value and expects an assertion to be triggered.
*/
void testSetStateRequestInvalidInstancePointer(void) {
TEST_ASSERT_FAIL_ASSERT(MXM_41BSetStateRequest(
NULL_PTR, MXM_STATEMACH_41B_UNINITIALIZED, commandBuffer, 6, 0, rxBuffer, 100, &status41b));
}
/**
* @brief Test that the only transition from uninitialized is initialization
* @details This test expects the state machine to be in state
* #MXM_STATEMACH_41B_UNINITIALIZED and various transitions to other
* states. The only valid transition has to be to
* #MXM_STATEMACH_41B_INIT. This is check by evaluating the return
* value of #MXM_41BSetStateRequest().
*/
void testOnlyAllowedTransitionFromUnitializedIsInit(void) {
TEST_ASSERT_EQUAL(
STD_NOT_OK,
MXM_41BSetStateRequest(
&mxm_41bState, MXM_STATEMACH_41B_UNINITIALIZED, commandBuffer, 6, 0, rxBuffer, 100, &status41b));
TEST_ASSERT_EQUAL(
STD_NOT_OK,
MXM_41BSetStateRequest(
&mxm_41bState, MXM_STATEMACH_41B_MAXSTATE, commandBuffer, 6, 0, rxBuffer, 100, &status41b));
TEST_ASSERT_EQUAL(
STD_NOT_OK,
MXM_41BSetStateRequest(
&mxm_41bState, MXM_STATEMACH_41B_CHECK_FMEA, commandBuffer, 6, 0, rxBuffer, 100, &status41b));
TEST_ASSERT_EQUAL(
STD_OK,
MXM_41BSetStateRequest(&mxm_41bState, MXM_STATEMACH_41B_INIT, commandBuffer, 6, 0, rxBuffer, 100, &status41b));
}
void testTransitionsOnlyAllowedInIdleAfterInit(void) {
/* start in Idle state */
mxm_41bState.state = MXM_STATEMACH_41B_IDLE;
TEST_ASSERT_EQUAL(
STD_OK,
MXM_41BSetStateRequest(
&mxm_41bState, MXM_STATEMACH_41B_CHECK_FMEA, commandBuffer, 6, 0, rxBuffer, 100, &status41b));
/* try additional transition (even though not in idle state anymore) */
TEST_ASSERT_EQUAL(
STD_NOT_OK,
MXM_41BSetStateRequest(
&mxm_41bState, MXM_STATEMACH_41B_CHECK_FMEA, commandBuffer, 6, 0, rxBuffer, 100, &status41b));
}
void testStateRequestConsistentInput(void) {
TEST_ASSERT_EQUAL(
STD_OK,
MXM_41BSetStateRequest(&mxm_41bState, MXM_STATEMACH_41B_INIT, commandBuffer, 6, 0, rxBuffer, 100, &status41b));
}
void testStateRequestInconsistentInputPayload(void) {
TEST_ASSERT_EQUAL(
STD_NOT_OK,
MXM_41BSetStateRequest(&mxm_41bState, MXM_STATEMACH_41B_INIT, commandBuffer, 0, 0, rxBuffer, 100, &status41b));
TEST_ASSERT_EQUAL(
STD_NOT_OK,
MXM_41BSetStateRequest(&mxm_41bState, MXM_STATEMACH_41B_INIT, NULL_PTR, 6, 0, rxBuffer, 100, &status41b));
TEST_ASSERT_EQUAL(
STD_OK,
MXM_41BSetStateRequest(&mxm_41bState, MXM_STATEMACH_41B_INIT, NULL_PTR, 0, 0, rxBuffer, 100, &status41b));
}
void testStateRequestInconsistentInputRXBuffer(void) {
TEST_ASSERT_EQUAL(
STD_NOT_OK,
MXM_41BSetStateRequest(&mxm_41bState, MXM_STATEMACH_41B_INIT, commandBuffer, 6, 0, rxBuffer, 0, &status41b));
TEST_ASSERT_EQUAL(
STD_NOT_OK,
MXM_41BSetStateRequest(&mxm_41bState, MXM_STATEMACH_41B_INIT, commandBuffer, 6, 0, NULL_PTR, 100, &status41b));
TEST_ASSERT_EQUAL(
STD_OK,
MXM_41BSetStateRequest(&mxm_41bState, MXM_STATEMACH_41B_INIT, commandBuffer, 6, 0, NULL_PTR, 0, &status41b));
}
void testStateRequestInconsistentInputProcessed(void) {
TEST_ASSERT_EQUAL(
STD_NOT_OK,
MXM_41BSetStateRequest(&mxm_41bState, MXM_STATEMACH_41B_INIT, commandBuffer, 6, 0, rxBuffer, 100, NULL_PTR));
}
/** @}
* end of tests for function MXM_41BSetStateRequest */
/**
* \defgroup mxm41b-write-register-function tests for function MXM_41BWriteRegisterFunction
* @{
*/
void testWriteRegisterFunctionWithIllegalValues(void) {
TEST_ASSERT_EQUAL(STD_NOT_OK, MXM_41BWriteRegisterFunction(&mxm_41bState, 0xFF, 0));
TEST_ASSERT_FAIL_ASSERT(MXM_41BWriteRegisterFunction(NULL_PTR, 0xFF, 0));
}
void testWriteRegisterFunctionWithLegalValues(void) {
/* standard state should be only fourth bit set */
TEST_ASSERT_EQUAL(0x10u, mxm_41bState.regConfig2);
TEST_ASSERT_EQUAL(
STD_OK, MXM_41BWriteRegisterFunction(&mxm_41bState, MXM_41B_REG_FUNCTION_TX_PREAMBLES, MXM_41B_REG_FALSE));
TEST_ASSERT_EQUAL(0x10u, mxm_41bState.regConfig2);
/* after writing register, fifth bit should be set in addition */
TEST_ASSERT_EQUAL(
STD_OK, MXM_41BWriteRegisterFunction(&mxm_41bState, MXM_41B_REG_FUNCTION_TX_PREAMBLES, MXM_41B_REG_TRUE));
TEST_ASSERT_EQUAL((0x10u | (1u << 5u)), mxm_41bState.regConfig2);
/* standard state should be third, second, first and zero bit set */
TEST_ASSERT_EQUAL(0xFu, mxm_41bState.regConfig3);
/* 0us --> 0 */
TEST_ASSERT_EQUAL(
STD_OK,
MXM_41BWriteRegisterFunction(&mxm_41bState, MXM_41B_REG_FUNCTION_KEEP_ALIVE, MXM_41B_REG_KEEP_ALIVE_0US));
TEST_ASSERT_EQUAL(0x0u, mxm_41bState.regConfig3);
/* 10us --> 1 */
TEST_ASSERT_EQUAL(
STD_OK,
MXM_41BWriteRegisterFunction(&mxm_41bState, MXM_41B_REG_FUNCTION_KEEP_ALIVE, MXM_41B_REG_KEEP_ALIVE_10US));
TEST_ASSERT_EQUAL(0x1u, mxm_41bState.regConfig3);
/* 640us --> 0x7 */
TEST_ASSERT_EQUAL(
STD_OK,
MXM_41BWriteRegisterFunction(&mxm_41bState, MXM_41B_REG_FUNCTION_KEEP_ALIVE, MXM_41B_REG_KEEP_ALIVE_640US));
TEST_ASSERT_EQUAL(0x7u, mxm_41bState.regConfig3);
/* INF DLY --> 0xF */
TEST_ASSERT_EQUAL(
STD_OK,
MXM_41BWriteRegisterFunction(&mxm_41bState, MXM_41B_REG_FUNCTION_KEEP_ALIVE, MXM_41B_REG_KEEP_ALIVE_INF_DLY));
TEST_ASSERT_EQUAL(0xFu, mxm_41bState.regConfig3);
/* standard state should be zero */
TEST_ASSERT_EQUAL(0x0u, mxm_41bState.regRXIntEnable);
/* rx error int on --> 0x80 */
TEST_ASSERT_EQUAL(
STD_OK, MXM_41BWriteRegisterFunction(&mxm_41bState, MXM_41B_REG_FUNCTION_RX_ERROR_INT, MXM_41B_REG_TRUE));
TEST_ASSERT_EQUAL(0x80u, mxm_41bState.regRXIntEnable);
/* rx error int off --> 0 */
TEST_ASSERT_EQUAL(
STD_OK, MXM_41BWriteRegisterFunction(&mxm_41bState, MXM_41B_REG_FUNCTION_RX_ERROR_INT, MXM_41B_REG_FALSE));
TEST_ASSERT_EQUAL(0x0u, mxm_41bState.regRXIntEnable);
/* standard state should be zero */
TEST_ASSERT_EQUAL(0x0u, mxm_41bState.regRXIntEnable);
/* rx overflow int on --> 0x8 */
TEST_ASSERT_EQUAL(
STD_OK, MXM_41BWriteRegisterFunction(&mxm_41bState, MXM_41B_REG_FUNCTION_RX_OVERFLOW_INT, MXM_41B_REG_TRUE));
TEST_ASSERT_EQUAL(0x8u, mxm_41bState.regRXIntEnable);
/* rx overflow int off --> 0 */
TEST_ASSERT_EQUAL(
STD_OK, MXM_41BWriteRegisterFunction(&mxm_41bState, MXM_41B_REG_FUNCTION_RX_OVERFLOW_INT, MXM_41B_REG_FALSE));
TEST_ASSERT_EQUAL(0x0u, mxm_41bState.regRXIntEnable);
}
/** @}
* end of tests for function MXM_41BWriteRegisterFunction */
/**
* \defgroup mxm41b-read-register-function tests for function MXM_41BReadRegisterFunction
* @{
*/
void testReadRegisterFunctionWithIllegalValues(void) {
MXM_41B_REG_BIT_VALUE result = {0};
TEST_ASSERT_EQUAL(STD_NOT_OK, MXM_41BReadRegisterFunction(&mxm_41bState, 0xFF, &result));
TEST_ASSERT_FAIL_ASSERT(MXM_41BReadRegisterFunction(NULL_PTR, 0xFF, &result));
TEST_ASSERT_FAIL_ASSERT(MXM_41BReadRegisterFunction(&mxm_41bState, 0xFF, NULL_PTR));
}
void testReadRegisterFunctionWithLegalValues(void) {
MXM_41B_REG_BIT_VALUE result = 42;
/* set register */
mxm_41bState.regRXStatus = 0u;
/* read all functions in this register */
TEST_ASSERT_EQUAL(STD_OK, MXM_41BReadRegisterFunction(&mxm_41bState, MXM_41B_REG_FUNCTION_RX_BUSY_STATUS, &result));
TEST_ASSERT_EQUAL(MXM_41B_REG_FALSE, result);
TEST_ASSERT_EQUAL(
STD_OK, MXM_41BReadRegisterFunction(&mxm_41bState, MXM_41B_REG_FUNCTION_RX_EMPTY_STATUS, &result));
TEST_ASSERT_EQUAL(MXM_41B_REG_FALSE, result);
/* set register with bit RX_EMPTY */
mxm_41bState.regRXStatus = 1u;
/* read all functions in this register */
TEST_ASSERT_EQUAL(STD_OK, MXM_41BReadRegisterFunction(&mxm_41bState, MXM_41B_REG_FUNCTION_RX_BUSY_STATUS, &result));
TEST_ASSERT_EQUAL(MXM_41B_REG_FALSE, result);
TEST_ASSERT_EQUAL(
STD_OK, MXM_41BReadRegisterFunction(&mxm_41bState, MXM_41B_REG_FUNCTION_RX_EMPTY_STATUS, &result));
TEST_ASSERT_EQUAL(MXM_41B_REG_TRUE, result);
/* set register with bit RX_BUSY */
mxm_41bState.regRXStatus = 0x20u;
/* read all functions in this register */
TEST_ASSERT_EQUAL(STD_OK, MXM_41BReadRegisterFunction(&mxm_41bState, MXM_41B_REG_FUNCTION_RX_BUSY_STATUS, &result));
TEST_ASSERT_EQUAL(MXM_41B_REG_TRUE, result);
TEST_ASSERT_EQUAL(
STD_OK, MXM_41BReadRegisterFunction(&mxm_41bState, MXM_41B_REG_FUNCTION_RX_EMPTY_STATUS, &result));
TEST_ASSERT_EQUAL(MXM_41B_REG_FALSE, result);
/* set register to zero */
mxm_41bState.regConfig2 = 0u;
/* read all functions in this register */
TEST_ASSERT_EQUAL(STD_OK, MXM_41BReadRegisterFunction(&mxm_41bState, MXM_41B_REG_FUNCTION_TX_PREAMBLES, &result));
TEST_ASSERT_EQUAL(MXM_41B_REG_FALSE, result);
/* set register with TX_PREAMBLES */
mxm_41bState.regConfig2 = 0x20u;
/* read all functions in this register */
TEST_ASSERT_EQUAL(STD_OK, MXM_41BReadRegisterFunction(&mxm_41bState, MXM_41B_REG_FUNCTION_TX_PREAMBLES, &result));
TEST_ASSERT_EQUAL(MXM_41B_REG_TRUE, result);
}
/** @}
* end of tests for function MXM_41BReadRegisterFunction */
/**
* \defgroup mxm41b-state-machine tests for the MXM_41b-state-machine
* @{
*/
void testStateStayInUninitialized(void) {
TEST_ASSERT_EQUAL(MXM_STATEMACH_41B_UNINITIALIZED, mxm_41bState.state);
MXM_41BStateMachine(&mxm_41bState);
TEST_ASSERT_EQUAL(MXM_STATEMACH_41B_UNINITIALIZED, mxm_41bState.state);
}
void testStateStayInIdle(void) {
/* force state-machine in idle state */
mxm_41bState.state = MXM_STATEMACH_41B_IDLE;
TEST_ASSERT_EQUAL(MXM_STATEMACH_41B_IDLE, mxm_41bState.state);
MXM_41BStateMachine(&mxm_41bState);
TEST_ASSERT_EQUAL(MXM_STATEMACH_41B_IDLE, mxm_41bState.state);
}
void testStateCheckFMEA(void) {
/* force state-machine in check_fmea state */
mxm_41bState.state = MXM_STATEMACH_41B_CHECK_FMEA;
TEST_ASSERT_EQUAL(MXM_STATEMACH_41B_CHECK_FMEA, mxm_41bState.state);
/* create a buffer with the assumed output of the ASCI and inject into SPI read */
uint16_t rxBuffer[10] = {0x13u, 0x00u};
MXM_ReceiveData_ExpectAndReturn(mxm_41bState.spiTXBuffer, mxm_41bState.spiRXBuffer, 2, STD_OK);
MXM_ReceiveData_ReturnArrayThruPtr_rxBuffer(rxBuffer, 2);
MXM_41BStateMachine(&mxm_41bState);
TEST_ASSERT_EQUAL(MXM_STATEMACH_41B_CHECK_FMEA, mxm_41bState.state);
/* check if the values are parsed correctly */
MXM_GetSPIStateReady_ExpectAndReturn(STD_OK);
MXM_41BStateMachine(&mxm_41bState);
TEST_ASSERT_EQUAL(MXM_STATEMACH_41B_IDLE, mxm_41bState.state);
TEST_ASSERT_EQUAL(MXM_41B_STATE_PROCESSED, status41b);
}
void testStateCheckFmeaGNDLAlert(void) {
/* force state-machine in check_fmea state */
mxm_41bState.state = MXM_STATEMACH_41B_CHECK_FMEA;
TEST_ASSERT_EQUAL(MXM_STATEMACH_41B_CHECK_FMEA, mxm_41bState.state);
/* create a buffer with the assumed output of the ASCI and inject into SPI read */
/* simulate an GNDL Alert in FMEA register */
uint16_t rxBuffer[10] = {0x13u, 0x01u};
MXM_ReceiveData_ExpectAndReturn(mxm_41bState.spiTXBuffer, mxm_41bState.spiRXBuffer, 2, STD_OK);
MXM_ReceiveData_ReturnArrayThruPtr_rxBuffer(rxBuffer, 2);
MXM_41BStateMachine(&mxm_41bState);
TEST_ASSERT_EQUAL(MXM_STATEMACH_41B_CHECK_FMEA, mxm_41bState.state);
/* check if the values are parsed correctly */
MXM_GetSPIStateReady_ExpectAndReturn(STD_OK);
MXM_41BStateMachine(&mxm_41bState);
TEST_ASSERT_EQUAL(MXM_STATEMACH_41B_IDLE, mxm_41bState.state);
TEST_ASSERT_EQUAL(MXM_41B_STATE_ERROR, status41b);
}
void testStateGetVersion(void) {
/* force state-machine in get_version state */
mxm_41bState.state = MXM_STATEMACH_41B_GET_VERSION;
TEST_ASSERT_EQUAL(MXM_STATEMACH_41B_GET_VERSION, mxm_41bState.state);
/* create a buffer with the assumed output of the ASCI and inject into SPI read */
uint16_t rxBuffer[10] = {0x15u, 0x84u, 0x12u};
MXM_ReceiveData_ExpectAndReturn(mxm_41bState.spiTXBuffer, mxm_41bState.spiRXBuffer, 3, STD_OK);
MXM_ReceiveData_ReturnArrayThruPtr_rxBuffer(rxBuffer, 3);
MXM_41BStateMachine(&mxm_41bState);
TEST_ASSERT_EQUAL(MXM_STATEMACH_41B_GET_VERSION, mxm_41bState.state);
/* check if the values are parsed correctly */
MXM_GetSPIStateReady_ExpectAndReturn(STD_OK);
MXM_41BStateMachine(&mxm_41bState);
TEST_ASSERT_EQUAL(0x841u, mxm_41bState.hwModel);
TEST_ASSERT_EQUAL(0x2u, mxm_41bState.hwMaskRevision);
}
void testStateClearReceiveBuffer(void) {
/* force state-machine in clear_receive_buffer state */
mxm_41bState.state = MXM_STATEMACH_41B_CLEAR_RECEIVE_BUFFER;
TEST_ASSERT_EQUAL(MXM_STATEMACH_41B_CLEAR_RECEIVE_BUFFER, mxm_41bState.state);
/* create a buffer with the assumed input to the ASCI */
uint16_t tx_buffer[10] = {0xE0u};
MXM_SendData_ExpectAndReturn(tx_buffer, 1, STD_OK);
MXM_41BStateMachine(&mxm_41bState);
/* check if the write was successful */
TEST_ASSERT_EQUAL(MXM_STATEMACH_41B_IDLE, mxm_41bState.state);
TEST_ASSERT_EQUAL(MXM_41B_STATE_PROCESSED, status41b);
}
void testStateClearReceiveBufferFailedSPIWrite(void) {
/* force state-machine in clear_receive_buffer state */
mxm_41bState.state = MXM_STATEMACH_41B_CLEAR_RECEIVE_BUFFER;
TEST_ASSERT_EQUAL(MXM_STATEMACH_41B_CLEAR_RECEIVE_BUFFER, mxm_41bState.state);
/* create a buffer with the assumed input to the ASCI */
uint16_t tx_buffer[10] = {0xE0u};
/* simulate a failure of writing */
MXM_SendData_ExpectAndReturn(tx_buffer, 1, STD_NOT_OK);
MXM_41BStateMachine(&mxm_41bState);
/* check if the write was successful */
TEST_ASSERT_EQUAL(MXM_STATEMACH_41B_IDLE, mxm_41bState.state);
TEST_ASSERT_EQUAL(MXM_41B_STATE_ERROR, status41b);
}
void testStateClearTransmitBuffer(void) {
/* force state-machine in clear_transmit_buffer state */
mxm_41bState.state = MXM_STATEMACH_41B_CLEAR_TRANSMIT_BUFFER;
TEST_ASSERT_EQUAL(MXM_STATEMACH_41B_CLEAR_TRANSMIT_BUFFER, mxm_41bState.state);
/* create a buffer with the assumed input to the ASCI */
uint16_t tx_buffer[10] = {0x20u};
MXM_SendData_ExpectAndReturn(tx_buffer, 1, STD_OK);
MXM_41BStateMachine(&mxm_41bState);
/* check if the write was successful */
TEST_ASSERT_EQUAL(MXM_STATEMACH_41B_IDLE, mxm_41bState.state);
TEST_ASSERT_EQUAL(MXM_41B_STATE_PROCESSED, status41b);
}
void testStateClearTransmitBufferFailedSPIWrite(void) {
/* force state-machine in clear_transmit_buffer state */
mxm_41bState.state = MXM_STATEMACH_41B_CLEAR_TRANSMIT_BUFFER;
TEST_ASSERT_EQUAL(MXM_STATEMACH_41B_CLEAR_TRANSMIT_BUFFER, mxm_41bState.state);
/* create a buffer with the assumed input to the ASCI */
uint16_t tx_buffer[10] = {0x20u};
/* simulate a failure of writing */
MXM_SendData_ExpectAndReturn(tx_buffer, 1, STD_NOT_OK);
MXM_41BStateMachine(&mxm_41bState);
/* check if the write was successful */
TEST_ASSERT_EQUAL(MXM_STATEMACH_41B_IDLE, mxm_41bState.state);
TEST_ASSERT_EQUAL(MXM_41B_STATE_ERROR, status41b);
}
void testStateUARTWaitForRXStatusChangeFail(void) {
/* force state-machine in MXM_41B_UART_WAIT_FOR_RX_STATUS_CHANGE_READ_AND_READ_BACK_RCV_BUF */
mxm_41bState.state = MXM_STATEMACH_41B_UART_TRANSACTION;
mxm_41bState.substate = MXM_41B_UART_WAIT_FOR_RX_STATUS_CHANGE_READ_AND_READ_BACK_RCV_BUF;
/* prepare RX buffer with not received RX_Stop_Status bit */
mxm_41bState.spiRXBuffer[1] = 0;
/* transition */
MXM_41BStateMachine(&mxm_41bState);
TEST_ASSERT_EQUAL(MXM_41B_UART_WAIT_FOR_RX_STATUS_CHANGE_WRITE, mxm_41bState.substate);
}
void testStateUARTWaitForRXStatusChangeSuccess(void) {
/* force state-machine in MXM_41B_UART_WAIT_FOR_RX_STATUS_CHANGE_READ_AND_READ_BACK_RCV_BUF */
mxm_41bState.state = MXM_STATEMACH_41B_UART_TRANSACTION;
mxm_41bState.substate = MXM_41B_UART_WAIT_FOR_RX_STATUS_CHANGE_READ_AND_READ_BACK_RCV_BUF;
/* prepare RX buffer with received RX_Stop_Status bit */
mxm_41bState.spiRXBuffer[1] |= (0x01u << 1u);
/* transition */
MXM_ReceiveData_IgnoreAndReturn(STD_OK);
MXM_41BStateMachine(&mxm_41bState);
TEST_ASSERT_EQUAL(MXM_41B_UART_READ_BACK_RECEIVE_BUFFER_SAVE, mxm_41bState.substate);
}
void testStateDefault(void) {
/* force state-machine in invalid state */
mxm_41bState.state = MXM_STATEMACH_41B_MAXSTATE;
mxm_41bState.substate = MXM_41B_ENTRY_SUBSTATE;
/* transition */
MXM_ReceiveData_IgnoreAndReturn(STD_OK);
TEST_ASSERT_FAIL_ASSERT(MXM_41BStateMachine(&mxm_41bState));
}
/** tests the normally to be expected flow through the initialization state */
void testStateInitNormalFlow(void) {
/* force state-machine in init state */
mxm_41bState.state = MXM_STATEMACH_41B_INIT;
TEST_ASSERT_EQUAL(MXM_STATEMACH_41B_INIT, mxm_41bState.state);
TEST_ASSERT_EQUAL(MXM_41B_ENTRY_SUBSTATE, mxm_41bState.substate);
/* first the bridge IC should be shut down */
MXM_ShutDownBridgeIc_Expect();
/* timestamp for the shutdown */
const uint32_t shutdownTimestamp = 42u;
OS_GetTickCount_ExpectAndReturn(shutdownTimestamp);
MXM_41BStateMachine(&mxm_41bState);
/* next call the timestamp will be checked, simulate time is not up yet */
OS_CheckTimeHasPassed_ExpectAndReturn(shutdownTimestamp, 0u, false);
OS_CheckTimeHasPassed_IgnoreArg_timeToPass_ms();
MXM_41BStateMachine(&mxm_41bState);
/* next call the timestamp will be checked again, simulate time is up */
OS_CheckTimeHasPassed_ExpectAndReturn(shutdownTimestamp, 0u, true);
OS_CheckTimeHasPassed_IgnoreArg_timeToPass_ms();
/* now the bridge IC should be reenabled */
MXM_EnableBridgeIc_Expect();
MXM_41BStateMachine(&mxm_41bState);
/* now the default configuration should be sent to the bridge IC */
MXM_SendData_ExpectAndReturn(mxm_41bState.spiTXBuffer, 8, STD_OK);
MXM_41BStateMachine(&mxm_41bState);
/* default values to check against */
const uint8_t mxm_41B_reg_default_values[MXM_41B_CONFIG_REGISTER_LENGTH] = {
MXM_41B_RX_INT_ENABLE_DEFAULT_VALUE,
MXM_41B_TX_INT_ENABLE_DEFAULT_VALUE,
MXM_41B_RX_INT_FLAG_DEFAULT_VALUE,
MXM_41B_TX_INT_FLAG_DEFAULT_VALUE,
MXM_41B_CONFIG_1_DEFAULT_VALUE,
MXM_41B_CONFIG_2_DEFAULT_VALUE,
MXM_41B_CONFIG_3_DEFAULT_VALUE};
MXM_ReceiveData_ExpectAndReturn(
mxm_41bState.spiTXBuffer, mxm_41bState.spiRXBuffer, MXM_41B_CONFIG_REGISTER_LENGTH + 1, STD_OK);
MXM_41BStateMachine(&mxm_41bState);
/* inject the values by copying into the pointer (can be done since we know the address) */
for (uint8_t i = 0u; i < MXM_41B_CONFIG_REGISTER_LENGTH; i++) {
mxm_41bState.spiRXBuffer[i + 1u] = mxm_41B_reg_default_values[i];
}
MXM_GetSPIStateReady_ExpectAndReturn(STD_OK);
MXM_41BStateMachine(&mxm_41bState);
/* and now we should be done and back in idle */
TEST_ASSERT_EQUAL(MXM_STATEMACH_41B_IDLE, mxm_41bState.state);
TEST_ASSERT_EQUAL(MXM_41B_ENTRY_SUBSTATE, mxm_41bState.substate);
}
/** @}
* end tests for the state-machine */
|
ebd898ed3404652ffdda59cb96eeaf4583f71934
|
7664f318ed04bd0680f3d82321c18896e3ef6ad5
|
/include/z64map_mark.h
|
d862197840ffe53d5295ca5d3260aeeed8466252
|
[] |
no_license
|
zeldaret/oot
|
9c80ce17f2d8fd61514b375f92ee4739b5ce9d4e
|
2875ab4fcf5c5f81d76353d1ee0024c9ea8d0b23
|
refs/heads/master
| 2023-08-29T05:29:31.356427
| 2023-08-28T22:48:52
| 2023-08-28T22:48:52
| 247,875,738
| 4,401
| 802
| null | 2023-09-14T13:34:38
| 2020-03-17T04:02:19
|
C
|
UTF-8
|
C
| false
| false
| 748
|
h
|
z64map_mark.h
|
#ifndef Z64MAP_MARK_H
#define Z64MAP_MARK_H
#include "ultra64.h"
#define MAP_MARK_NONE -1
#define MAP_MARK_CHEST 0
#define MAP_MARK_BOSS 1
typedef struct {
/* 0x00 */ s8 chestFlag; // chest icon is only displayed if this flag is not set for the current room
/* 0x01 */ u8 x, y; // coordinates to place the icon (top-left corner), relative to the minimap texture
} MapMarkPoint; // size = 0x3
typedef struct {
/* 0x00 */ s8 markType; // 0 for the chest icon, 1 for the boss skull icon, -1 for none
/* 0x01 */ u8 count; // number of icons to display
/* 0x02 */ MapMarkPoint points[12];
} MapMarkIconData; // size = 0x26
typedef MapMarkIconData MapMarkData[3]; // size = 0x72
extern MapMarkData* gMapMarkDataTable[];
#endif
|
2bf1eec4f3facdf99d8c5d3cd76f70540c30fd1c
|
ec6a71b57ebe88538269197fd16bede6bc2062ae
|
/erts/include/internal/tile/atomic.h
|
7f5f83bcc733475afce9bb06ac02044414889160
|
[
"Apache-2.0"
] |
permissive
|
erlang/otp
|
7c6e88ca955bd6a3ede1530154c80e8ce449a370
|
334589af62a8db25a81afba2ecc50f33ff69ddb8
|
refs/heads/master
| 2023-08-30T23:37:28.061328
| 2023-08-30T04:20:48
| 2023-08-30T04:20:48
| 374,927
| 9,920
| 3,018
|
Apache-2.0
| 2023-09-14T10:37:26
| 2009-11-16T17:17:57
|
Erlang
|
UTF-8
|
C
| false
| false
| 3,656
|
h
|
atomic.h
|
/*
* %CopyrightBegin%
*
* Copyright Ericsson AB 2008-2016. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* %CopyrightEnd%
*/
/*
* Native ethread atomics on TILE64/TILEPro.
*
*/
#ifndef ETHREAD_TILE_ATOMIC_H
#define ETHREAD_TILE_ATOMIC_H
#define ETHR_HAVE_NATIVE_ATOMIC32 1
#define ETHR_NATIVE_ATOMIC32_IMPL "tilera"
#include <atomic.h>
/* An atomic is an aligned int accessed via locked operations.
*/
typedef struct {
volatile ethr_sint32_t counter;
} ethr_native_atomic32_t;
#if defined(ETHR_TRY_INLINE_FUNCS) || defined(ETHR_ATOMIC_IMPL__)
#define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADDR 1
static ETHR_INLINE ethr_sint32_t *
ethr_native_atomic32_addr(ethr_native_atomic32_t *var)
{
return (ethr_sint32_t *) &var->counter;
}
#define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INIT 1
static ETHR_INLINE void
ethr_native_atomic32_init(ethr_native_atomic32_t *var, ethr_sint32_t i)
{
var->counter = i;
}
#define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_READ 1
static ETHR_INLINE ethr_sint32_t
ethr_native_atomic32_read(ethr_native_atomic32_t *var)
{
return var->counter;
}
#define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_READ_ACQB 1
static ETHR_INLINE ethr_sint32_t
ethr_native_atomic32_read_acqb(ethr_native_atomic32_t *var)
{
return atomic_compare_and_exchange_val_acq(&var->counter,
0x81818181,
0x81818181);
}
#define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADD 1
static ETHR_INLINE void
ethr_native_atomic32_add(ethr_native_atomic32_t *var, ethr_sint32_t incr)
{
atomic_add(&var->counter, incr);
}
#define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INC 1
static ETHR_INLINE void
ethr_native_atomic32_inc(ethr_native_atomic32_t *var)
{
atomic_increment(&var->counter);
}
#define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_DEC 1
static ETHR_INLINE void
ethr_native_atomic32_dec(ethr_native_atomic32_t *var)
{
atomic_decrement(&var->counter);
}
#define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADD_RETURN 1
static ETHR_INLINE ethr_sint32_t
ethr_native_atomic32_add_return(ethr_native_atomic32_t *var, ethr_sint32_t incr)
{
return atomic_exchange_and_add(&var->counter, incr) + incr;
}
#define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_AND_RETOLD 1
static ETHR_INLINE ethr_sint32_t
ethr_native_atomic32_and_retold(ethr_native_atomic32_t *var, ethr_sint32_t mask)
{
return atomic_and_val(&var->counter, mask);
}
#define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_OR_RETOLD 1
static ETHR_INLINE ethr_sint32_t
ethr_native_atomic32_or_retold(ethr_native_atomic32_t *var, ethr_sint32_t mask)
{
return atomic_or_val(&var->counter, mask);
}
#define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_XCHG_ACQB 1
static ETHR_INLINE ethr_sint32_t
ethr_native_atomic32_xchg_acqb(ethr_native_atomic32_t *var, ethr_sint32_t val)
{
return atomic_exchange_acq(&var->counter, val);
}
#define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_CMPXCHG_ACQB 1
static ETHR_INLINE ethr_sint32_t
ethr_native_atomic32_cmpxchg_acqb(ethr_native_atomic32_t *var,
ethr_sint32_t new,
ethr_sint32_t expected)
{
return atomic_compare_and_exchange_val_acq(&var->counter, new, expected);
}
#endif /* ETHR_TRY_INLINE_FUNCS */
#endif /* ETHREAD_TILE_ATOMIC_H */
|
93f86cced58e6f889167209fa26373a2298f06cf
|
581bdcc078d282e388f1b655d4cfc4e08152d117
|
/phnt/include/ntmmapi.h
|
057f712723d1f4c1ad38d61d4039ffdbc4bfb85e
|
[
"MIT",
"BSD-3-Clause",
"LGPL-2.0-or-later",
"Zlib",
"LGPL-2.1-or-later",
"GPL-2.0-only",
"LicenseRef-scancode-public-domain"
] |
permissive
|
winsiderss/systeminformer
|
774928be871f0055263ac5e62ae0a598b098486b
|
5a6b442acd45d681f699a133d476a3211d072871
|
refs/heads/master
| 2023-08-28T15:43:41.074679
| 2023-08-27T20:59:20
| 2023-08-27T20:59:20
| 50,824,485
| 2,137
| 292
|
MIT
| 2023-09-10T22:35:12
| 2016-02-01T08:10:21
|
C
|
UTF-8
|
C
| false
| false
| 31,777
|
h
|
ntmmapi.h
|
/*
* Memory Manager Support functions
*
* This file is part of System Informer.
*/
#ifndef _NTMMAPI_H
#define _NTMMAPI_H
// Protection constants
#define PAGE_NOACCESS 0x01
#define PAGE_READONLY 0x02
#define PAGE_READWRITE 0x04
#define PAGE_WRITECOPY 0x08
#define PAGE_EXECUTE 0x10
#define PAGE_EXECUTE_READ 0x20
#define PAGE_EXECUTE_READWRITE 0x40
#define PAGE_EXECUTE_WRITECOPY 0x80
#define PAGE_GUARD 0x100
#define PAGE_NOCACHE 0x200
#define PAGE_WRITECOMBINE 0x400
#define PAGE_REVERT_TO_FILE_MAP 0x80000000
#define PAGE_ENCLAVE_THREAD_CONTROL 0x80000000
#define PAGE_TARGETS_NO_UPDATE 0x40000000
#define PAGE_TARGETS_INVALID 0x40000000
#define PAGE_ENCLAVE_UNVALIDATED 0x20000000
#define PAGE_ENCLAVE_NO_CHANGE 0x20000000
#define PAGE_ENCLAVE_MASK 0x10000000
#define PAGE_ENCLAVE_DECOMMIT (PAGE_ENCLAVE_MASK | 0)
#define PAGE_ENCLAVE_SS_FIRST (PAGE_ENCLAVE_MASK | 1)
#define PAGE_ENCLAVE_SS_REST (PAGE_ENCLAVE_MASK | 2)
// Region and section constants
#define MEM_COMMIT 0x00001000
#define MEM_RESERVE 0x00002000
#define MEM_DECOMMIT 0x00004000
#define MEM_RELEASE 0x00008000
#define MEM_FREE 0x00010000
#define MEM_PRIVATE 0x00020000
#define MEM_MAPPED 0x00040000
#define MEM_RESET 0x00080000
#define MEM_TOP_DOWN 0x00100000
#define MEM_WRITE_WATCH 0x00200000
#define MEM_PHYSICAL 0x00400000
#define MEM_ROTATE 0x00800000
#define MEM_DIFFERENT_IMAGE_BASE_OK 0x00800000
#define MEM_RESET_UNDO 0x01000000
#define MEM_LARGE_PAGES 0x20000000
#define MEM_DOS_LIM 0x40000000
#define MEM_4MB_PAGES 0x80000000
#define MEM_64K_PAGES (MEM_LARGE_PAGES | MEM_PHYSICAL)
#define MEM_UNMAP_WITH_TRANSIENT_BOOST 0x00000001
#define MEM_COALESCE_PLACEHOLDERS 0x00000001
#define MEM_PRESERVE_PLACEHOLDER 0x00000002
#define MEM_REPLACE_PLACEHOLDER 0x00004000
#define MEM_RESERVE_PLACEHOLDER 0x00040000
#define SEC_HUGE_PAGES 0x00020000
#define SEC_PARTITION_OWNER_HANDLE 0x00040000
#define SEC_64K_PAGES 0x00080000
#define SEC_BASED 0x00200000
#define SEC_NO_CHANGE 0x00400000
#define SEC_FILE 0x00800000
#define SEC_IMAGE 0x01000000
#define SEC_PROTECTED_IMAGE 0x02000000
#define SEC_RESERVE 0x04000000
#define SEC_COMMIT 0x08000000
#define SEC_NOCACHE 0x10000000
#define SEC_GLOBAL 0x20000000
#define SEC_WRITECOMBINE 0x40000000
#define SEC_LARGE_PAGES 0x80000000
#define SEC_IMAGE_NO_EXECUTE (SEC_IMAGE | SEC_NOCACHE)
#if (PHNT_MODE == PHNT_MODE_KERNEL)
#define MEM_IMAGE SEC_IMAGE
#endif
#if (PHNT_MODE != PHNT_MODE_KERNEL)
// private
typedef enum _MEMORY_INFORMATION_CLASS
{
MemoryBasicInformation, // q: MEMORY_BASIC_INFORMATION
MemoryWorkingSetInformation, // q: MEMORY_WORKING_SET_INFORMATION
MemoryMappedFilenameInformation, // q: UNICODE_STRING
MemoryRegionInformation, // q: MEMORY_REGION_INFORMATION
MemoryWorkingSetExInformation, // q: MEMORY_WORKING_SET_EX_INFORMATION // since VISTA
MemorySharedCommitInformation, // q: MEMORY_SHARED_COMMIT_INFORMATION // since WIN8
MemoryImageInformation, // q: MEMORY_IMAGE_INFORMATION
MemoryRegionInformationEx, // MEMORY_REGION_INFORMATION
MemoryPrivilegedBasicInformation, // MEMORY_BASIC_INFORMATION
MemoryEnclaveImageInformation, // MEMORY_ENCLAVE_IMAGE_INFORMATION // since REDSTONE3
MemoryBasicInformationCapped, // 10
MemoryPhysicalContiguityInformation, // MEMORY_PHYSICAL_CONTIGUITY_INFORMATION // since 20H1
MemoryBadInformation, // since WIN11
MemoryBadInformationAllProcesses, // since 22H1
MaxMemoryInfoClass
} MEMORY_INFORMATION_CLASS;
#else
#define MemoryBasicInformation 0x0
#define MemoryWorkingSetInformation 0x1
#define MemoryMappedFilenameInformation 0x2
#define MemoryRegionInformation 0x3
#define MemoryWorkingSetExInformation 0x4
#define MemorySharedCommitInformation 0x5
#define MemoryImageInformation 0x6
#define MemoryRegionInformationEx 0x7
#define MemoryPrivilegedBasicInformation 0x8
#define MemoryEnclaveImageInformation 0x9
#define MemoryBasicInformationCapped 0xA
#define MemoryPhysicalContiguityInformation 0xB
#define MemoryBadInformation 0xC
#define MemoryBadInformationAllProcesses 0xD
#endif
typedef struct _MEMORY_WORKING_SET_BLOCK
{
ULONG_PTR Protection : 5;
ULONG_PTR ShareCount : 3;
ULONG_PTR Shared : 1;
ULONG_PTR Node : 3;
#ifdef _WIN64
ULONG_PTR VirtualPage : 52;
#else
ULONG VirtualPage : 20;
#endif
} MEMORY_WORKING_SET_BLOCK, *PMEMORY_WORKING_SET_BLOCK;
typedef struct _MEMORY_WORKING_SET_INFORMATION
{
ULONG_PTR NumberOfEntries;
_Field_size_(NumberOfEntries) MEMORY_WORKING_SET_BLOCK WorkingSetInfo[1];
} MEMORY_WORKING_SET_INFORMATION, *PMEMORY_WORKING_SET_INFORMATION;
// private
typedef struct _MEMORY_REGION_INFORMATION
{
PVOID AllocationBase;
ULONG AllocationProtect;
union
{
ULONG RegionType;
struct
{
ULONG Private : 1;
ULONG MappedDataFile : 1;
ULONG MappedImage : 1;
ULONG MappedPageFile : 1;
ULONG MappedPhysical : 1;
ULONG DirectMapped : 1;
ULONG SoftwareEnclave : 1; // REDSTONE3
ULONG PageSize64K : 1;
ULONG PlaceholderReservation : 1; // REDSTONE4
ULONG MappedAwe : 1; // 21H1
ULONG MappedWriteWatch : 1;
ULONG PageSizeLarge : 1;
ULONG PageSizeHuge : 1;
ULONG Reserved : 19;
};
};
SIZE_T RegionSize;
SIZE_T CommitSize;
ULONG_PTR PartitionId; // 19H1
ULONG_PTR NodePreference; // 20H1
} MEMORY_REGION_INFORMATION, *PMEMORY_REGION_INFORMATION;
// private
typedef enum _MEMORY_WORKING_SET_EX_LOCATION
{
MemoryLocationInvalid,
MemoryLocationResident,
MemoryLocationPagefile,
MemoryLocationReserved
} MEMORY_WORKING_SET_EX_LOCATION;
// private
typedef struct _MEMORY_WORKING_SET_EX_BLOCK
{
union
{
struct
{
ULONG_PTR Valid : 1;
ULONG_PTR ShareCount : 3;
ULONG_PTR Win32Protection : 11;
ULONG_PTR Shared : 1;
ULONG_PTR Node : 6;
ULONG_PTR Locked : 1;
ULONG_PTR LargePage : 1;
ULONG_PTR Priority : 3;
ULONG_PTR Reserved : 3;
ULONG_PTR SharedOriginal : 1;
ULONG_PTR Bad : 1;
ULONG_PTR Win32GraphicsProtection : 4; // 19H1
#ifdef _WIN64
ULONG_PTR ReservedUlong : 28;
#endif
};
struct
{
ULONG_PTR Valid : 1;
ULONG_PTR Reserved0 : 14;
ULONG_PTR Shared : 1;
ULONG_PTR Reserved1 : 5;
ULONG_PTR PageTable : 1;
ULONG_PTR Location : 2;
ULONG_PTR Priority : 3;
ULONG_PTR ModifiedList : 1;
ULONG_PTR Reserved2 : 2;
ULONG_PTR SharedOriginal : 1;
ULONG_PTR Bad : 1;
#ifdef _WIN64
ULONG_PTR ReservedUlong : 32;
#endif
} Invalid;
};
} MEMORY_WORKING_SET_EX_BLOCK, *PMEMORY_WORKING_SET_EX_BLOCK;
// private
typedef struct _MEMORY_WORKING_SET_EX_INFORMATION
{
PVOID VirtualAddress;
union
{
MEMORY_WORKING_SET_EX_BLOCK VirtualAttributes;
ULONG_PTR Long;
} u1;
} MEMORY_WORKING_SET_EX_INFORMATION, *PMEMORY_WORKING_SET_EX_INFORMATION;
// private
typedef struct _MEMORY_SHARED_COMMIT_INFORMATION
{
SIZE_T CommitSize;
} MEMORY_SHARED_COMMIT_INFORMATION, *PMEMORY_SHARED_COMMIT_INFORMATION;
// private
typedef struct _MEMORY_IMAGE_INFORMATION
{
PVOID ImageBase;
SIZE_T SizeOfImage;
union
{
ULONG ImageFlags;
struct
{
ULONG ImagePartialMap : 1;
ULONG ImageNotExecutable : 1;
ULONG ImageSigningLevel : 4; // REDSTONE3
ULONG Reserved : 26;
};
};
} MEMORY_IMAGE_INFORMATION, *PMEMORY_IMAGE_INFORMATION;
// private
typedef struct _MEMORY_ENCLAVE_IMAGE_INFORMATION
{
MEMORY_IMAGE_INFORMATION ImageInfo;
UCHAR UniqueID[32];
UCHAR AuthorID[32];
} MEMORY_ENCLAVE_IMAGE_INFORMATION, *PMEMORY_ENCLAVE_IMAGE_INFORMATION;
// private
typedef enum _MEMORY_PHYSICAL_CONTIGUITY_UNIT_STATE
{
MemoryNotContiguous,
MemoryAlignedAndContiguous,
MemoryNotResident,
MemoryNotEligibleToMakeContiguous,
MemoryContiguityStateMax,
} MEMORY_PHYSICAL_CONTIGUITY_UNIT_STATE;
// private
typedef struct _MEMORY_PHYSICAL_CONTIGUITY_UNIT_INFORMATION
{
union
{
struct
{
ULONG State : 2;
ULONG Reserved : 30;
};
ULONG AllInformation;
};
} MEMORY_PHYSICAL_CONTIGUITY_UNIT_INFORMATION, *PMEMORY_PHYSICAL_CONTIGUITY_UNIT_INFORMATION;
// private
typedef struct _MEMORY_PHYSICAL_CONTIGUITY_INFORMATION
{
PVOID VirtualAddress;
ULONG_PTR Size;
ULONG_PTR ContiguityUnitSize;
ULONG Flags;
PMEMORY_PHYSICAL_CONTIGUITY_UNIT_INFORMATION ContiguityUnitInformation;
} MEMORY_PHYSICAL_CONTIGUITY_INFORMATION, *PMEMORY_PHYSICAL_CONTIGUITY_INFORMATION;
#define MMPFNLIST_ZERO 0
#define MMPFNLIST_FREE 1
#define MMPFNLIST_STANDBY 2
#define MMPFNLIST_MODIFIED 3
#define MMPFNLIST_MODIFIEDNOWRITE 4
#define MMPFNLIST_BAD 5
#define MMPFNLIST_ACTIVE 6
#define MMPFNLIST_TRANSITION 7
//typedef enum _MMLISTS
//{
// ZeroedPageList = 0,
// FreePageList = 1,
// StandbyPageList = 2,
// ModifiedPageList = 3,
// ModifiedNoWritePageList = 4,
// BadPageList = 5,
// ActiveAndValid = 6,
// TransitionPage = 7
//} MMLISTS;
#define MMPFNUSE_PROCESSPRIVATE 0
#define MMPFNUSE_FILE 1
#define MMPFNUSE_PAGEFILEMAPPED 2
#define MMPFNUSE_PAGETABLE 3
#define MMPFNUSE_PAGEDPOOL 4
#define MMPFNUSE_NONPAGEDPOOL 5
#define MMPFNUSE_SYSTEMPTE 6
#define MMPFNUSE_SESSIONPRIVATE 7
#define MMPFNUSE_METAFILE 8
#define MMPFNUSE_AWEPAGE 9
#define MMPFNUSE_DRIVERLOCKPAGE 10
#define MMPFNUSE_KERNELSTACK 11
//typedef enum _MMPFNUSE
//{
// ProcessPrivatePage,
// MemoryMappedFilePage,
// PageFileMappedPage,
// PageTablePage,
// PagedPoolPage,
// NonPagedPoolPage,
// SystemPTEPage,
// SessionPrivatePage,
// MetafilePage,
// AWEPage,
// DriverLockedPage,
// KernelStackPage
//} MMPFNUSE;
// private
typedef struct _MEMORY_FRAME_INFORMATION
{
ULONGLONG UseDescription : 4; // MMPFNUSE_*
ULONGLONG ListDescription : 3; // MMPFNLIST_*
ULONGLONG Cold : 1; // 19H1
ULONGLONG Pinned : 1; // 1 - pinned, 0 - not pinned
ULONGLONG DontUse : 48; // *_INFORMATION overlay
ULONGLONG Priority : 3;
ULONGLONG NonTradeable : 1;
ULONGLONG Reserved : 3;
} MEMORY_FRAME_INFORMATION;
// private
typedef struct _FILEOFFSET_INFORMATION
{
ULONGLONG DontUse : 9; // MEMORY_FRAME_INFORMATION overlay
ULONGLONG Offset : 48; // mapped files
ULONGLONG Reserved : 7;
} FILEOFFSET_INFORMATION;
// private
typedef struct _PAGEDIR_INFORMATION
{
ULONGLONG DontUse : 9; // MEMORY_FRAME_INFORMATION overlay
ULONGLONG PageDirectoryBase : 48; // private pages
ULONGLONG Reserved : 7;
} PAGEDIR_INFORMATION;
// private
typedef struct _UNIQUE_PROCESS_INFORMATION
{
ULONGLONG DontUse : 9; // MEMORY_FRAME_INFORMATION overlay
ULONGLONG UniqueProcessKey : 48; // ProcessId
ULONGLONG Reserved : 7;
} UNIQUE_PROCESS_INFORMATION, *PUNIQUE_PROCESS_INFORMATION;
// private
typedef struct _MMPFN_IDENTITY
{
union
{
MEMORY_FRAME_INFORMATION e1; // all
FILEOFFSET_INFORMATION e2; // mapped files
PAGEDIR_INFORMATION e3; // private pages
UNIQUE_PROCESS_INFORMATION e4; // owning process
} u1;
ULONG_PTR PageFrameIndex; // all
union
{
struct
{
ULONG_PTR Image : 1;
ULONG_PTR Mismatch : 1;
} e1;
struct
{
ULONG_PTR CombinedPage;
} e2;
ULONG_PTR FileObject; // mapped files
ULONG_PTR UniqueFileObjectKey;
ULONG_PTR ProtoPteAddress;
ULONG_PTR VirtualAddress; // everything else
} u2;
} MMPFN_IDENTITY, *PMMPFN_IDENTITY;
typedef struct _MMPFN_MEMSNAP_INFORMATION
{
ULONG_PTR InitialPageFrameIndex;
ULONG_PTR Count;
} MMPFN_MEMSNAP_INFORMATION, *PMMPFN_MEMSNAP_INFORMATION;
typedef enum _SECTION_INFORMATION_CLASS
{
SectionBasicInformation, // q; SECTION_BASIC_INFORMATION
SectionImageInformation, // q; SECTION_IMAGE_INFORMATION
SectionRelocationInformation, // q; PVOID RelocationAddress // name:wow64:whNtQuerySection_SectionRelocationInformation // since WIN7
SectionOriginalBaseInformation, // PVOID BaseAddress
SectionInternalImageInformation, // SECTION_INTERNAL_IMAGE_INFORMATION // since REDSTONE2
MaxSectionInfoClass
} SECTION_INFORMATION_CLASS;
typedef struct _SECTION_BASIC_INFORMATION
{
PVOID BaseAddress;
ULONG AllocationAttributes;
LARGE_INTEGER MaximumSize;
} SECTION_BASIC_INFORMATION, *PSECTION_BASIC_INFORMATION;
// symbols
typedef struct _SECTION_IMAGE_INFORMATION
{
PVOID TransferAddress;
ULONG ZeroBits;
SIZE_T MaximumStackSize;
SIZE_T CommittedStackSize;
ULONG SubSystemType;
union
{
struct
{
USHORT SubSystemMinorVersion;
USHORT SubSystemMajorVersion;
};
ULONG SubSystemVersion;
};
union
{
struct
{
USHORT MajorOperatingSystemVersion;
USHORT MinorOperatingSystemVersion;
};
ULONG OperatingSystemVersion;
};
USHORT ImageCharacteristics;
USHORT DllCharacteristics;
USHORT Machine;
BOOLEAN ImageContainsCode;
union
{
UCHAR ImageFlags;
struct
{
UCHAR ComPlusNativeReady : 1;
UCHAR ComPlusILOnly : 1;
UCHAR ImageDynamicallyRelocated : 1;
UCHAR ImageMappedFlat : 1;
UCHAR BaseBelow4gb : 1;
UCHAR ComPlusPrefer32bit : 1;
UCHAR Reserved : 2;
};
};
ULONG LoaderFlags;
ULONG ImageFileSize;
ULONG CheckSum;
} SECTION_IMAGE_INFORMATION, *PSECTION_IMAGE_INFORMATION;
// symbols
typedef struct _SECTION_INTERNAL_IMAGE_INFORMATION
{
SECTION_IMAGE_INFORMATION SectionInformation;
union
{
ULONG ExtendedFlags;
struct
{
ULONG ImageExportSuppressionEnabled : 1;
ULONG ImageCetShadowStacksReady : 1; // 20H1
ULONG ImageXfgEnabled : 1; // 20H2
ULONG ImageCetShadowStacksStrictMode : 1;
ULONG ImageCetSetContextIpValidationRelaxedMode : 1;
ULONG ImageCetDynamicApisAllowInProc : 1;
ULONG ImageCetDowngradeReserved1 : 1;
ULONG ImageCetDowngradeReserved2 : 1;
ULONG Reserved : 24;
};
};
} SECTION_INTERNAL_IMAGE_INFORMATION, *PSECTION_INTERNAL_IMAGE_INFORMATION;
#if (PHNT_MODE != PHNT_MODE_KERNEL)
typedef enum _SECTION_INHERIT
{
ViewShare = 1,
ViewUnmap = 2
} SECTION_INHERIT;
#endif
#define MEM_EXECUTE_OPTION_ENABLE 0x1
#define MEM_EXECUTE_OPTION_DISABLE 0x2
#define MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION 0x4
#define MEM_EXECUTE_OPTION_PERMANENT 0x8
#define MEM_EXECUTE_OPTION_EXECUTE_DISPATCH_ENABLE 0x10
#define MEM_EXECUTE_OPTION_IMAGE_DISPATCH_ENABLE 0x20
#define MEM_EXECUTE_OPTION_VALID_FLAGS 0x3f
// Virtual memory
#if (PHNT_MODE != PHNT_MODE_KERNEL)
_Must_inspect_result_
_When_(return == 0, __drv_allocatesMem(mem))
NTSYSCALLAPI
NTSTATUS
NTAPI
NtAllocateVirtualMemory(
_In_ HANDLE ProcessHandle,
_Inout_ _At_(*BaseAddress, _Readable_bytes_(*RegionSize) _Writable_bytes_(*RegionSize) _Post_readable_byte_size_(*RegionSize)) PVOID *BaseAddress,
_In_ ULONG_PTR ZeroBits,
_Inout_ PSIZE_T RegionSize,
_In_ ULONG AllocationType,
_In_ ULONG Protect
);
#if (PHNT_VERSION >= PHNT_REDSTONE5)
_Must_inspect_result_
_When_(return == 0, __drv_allocatesMem(mem))
NTSYSCALLAPI
NTSTATUS
NTAPI
NtAllocateVirtualMemoryEx(
_In_ HANDLE ProcessHandle,
_Inout_ _At_(*BaseAddress, _Readable_bytes_(*RegionSize) _Writable_bytes_(*RegionSize) _Post_readable_byte_size_(*RegionSize)) PVOID *BaseAddress,
_Inout_ PSIZE_T RegionSize,
_In_ ULONG AllocationType,
_In_ ULONG PageProtection,
_Inout_updates_opt_(ExtendedParameterCount) PMEM_EXTENDED_PARAMETER ExtendedParameters,
_In_ ULONG ExtendedParameterCount
);
#endif
NTSYSCALLAPI
NTSTATUS
NTAPI
NtFreeVirtualMemory(
_In_ HANDLE ProcessHandle,
_Inout_ PVOID *BaseAddress,
_Inout_ PSIZE_T RegionSize,
_In_ ULONG FreeType
);
NTSYSCALLAPI
NTSTATUS
NTAPI
NtReadVirtualMemory(
_In_ HANDLE ProcessHandle,
_In_opt_ PVOID BaseAddress,
_Out_writes_bytes_(BufferSize) PVOID Buffer,
_In_ SIZE_T BufferSize,
_Out_opt_ PSIZE_T NumberOfBytesRead
);
#if (PHNT_VERSION >= PHNT_WIN11)
// rev
NTSYSCALLAPI
NTSTATUS
NTAPI
NtReadVirtualMemoryEx(
_In_ HANDLE ProcessHandle,
_In_opt_ PVOID BaseAddress,
_Out_writes_bytes_(BufferSize) PVOID Buffer,
_In_ SIZE_T BufferSize,
_Out_opt_ PSIZE_T NumberOfBytesRead,
_In_ ULONG Flags
);
#endif
NTSYSCALLAPI
NTSTATUS
NTAPI
NtWriteVirtualMemory(
_In_ HANDLE ProcessHandle,
_In_opt_ PVOID BaseAddress,
_In_reads_bytes_(BufferSize) PVOID Buffer,
_In_ SIZE_T BufferSize,
_Out_opt_ PSIZE_T NumberOfBytesWritten
);
NTSYSCALLAPI
NTSTATUS
NTAPI
NtProtectVirtualMemory(
_In_ HANDLE ProcessHandle,
_Inout_ PVOID *BaseAddress,
_Inout_ PSIZE_T RegionSize,
_In_ ULONG NewProtect,
_Out_ PULONG OldProtect
);
NTSYSCALLAPI
NTSTATUS
NTAPI
NtQueryVirtualMemory(
_In_ HANDLE ProcessHandle,
_In_opt_ PVOID BaseAddress,
_In_ MEMORY_INFORMATION_CLASS MemoryInformationClass,
_Out_writes_bytes_(MemoryInformationLength) PVOID MemoryInformation,
_In_ SIZE_T MemoryInformationLength,
_Out_opt_ PSIZE_T ReturnLength
);
typedef struct _IO_STATUS_BLOCK* PIO_STATUS_BLOCK;
NTSYSCALLAPI
NTSTATUS
NTAPI
NtFlushVirtualMemory(
_In_ HANDLE ProcessHandle,
_Inout_ PVOID *BaseAddress,
_Inout_ PSIZE_T RegionSize,
_Out_ PIO_STATUS_BLOCK IoStatus
);
#endif
// begin_private
#if (PHNT_MODE != PHNT_MODE_KERNEL)
typedef enum _VIRTUAL_MEMORY_INFORMATION_CLASS
{
VmPrefetchInformation, // ULONG
VmPagePriorityInformation, // OFFER_PRIORITY
VmCfgCallTargetInformation, // CFG_CALL_TARGET_LIST_INFORMATION // REDSTONE2
VmPageDirtyStateInformation, // REDSTONE3
VmImageHotPatchInformation, // 19H1
VmPhysicalContiguityInformation, // 20H1
VmVirtualMachinePrepopulateInformation,
VmRemoveFromWorkingSetInformation,
MaxVmInfoClass
} VIRTUAL_MEMORY_INFORMATION_CLASS;
typedef struct _MEMORY_RANGE_ENTRY
{
PVOID VirtualAddress;
SIZE_T NumberOfBytes;
} MEMORY_RANGE_ENTRY, *PMEMORY_RANGE_ENTRY;
typedef struct _CFG_CALL_TARGET_LIST_INFORMATION
{
ULONG NumberOfEntries;
ULONG Reserved;
PULONG NumberOfEntriesProcessed;
PCFG_CALL_TARGET_INFO CallTargetInfo;
PVOID Section; // since REDSTONE5
ULONGLONG FileOffset;
} CFG_CALL_TARGET_LIST_INFORMATION, *PCFG_CALL_TARGET_LIST_INFORMATION;
#endif
// end_private
#if (PHNT_MODE != PHNT_MODE_KERNEL)
#if (PHNT_VERSION >= PHNT_WIN8)
NTSYSCALLAPI
NTSTATUS
NTAPI
NtSetInformationVirtualMemory(
_In_ HANDLE ProcessHandle,
_In_ VIRTUAL_MEMORY_INFORMATION_CLASS VmInformationClass,
_In_ ULONG_PTR NumberOfEntries,
_In_reads_ (NumberOfEntries) PMEMORY_RANGE_ENTRY VirtualAddresses,
_In_reads_bytes_ (VmInformationLength) PVOID VmInformation,
_In_ ULONG VmInformationLength
);
#endif
#define MAP_PROCESS 1
#define MAP_SYSTEM 2
NTSYSCALLAPI
NTSTATUS
NTAPI
NtLockVirtualMemory(
_In_ HANDLE ProcessHandle,
_Inout_ PVOID *BaseAddress,
_Inout_ PSIZE_T RegionSize,
_In_ ULONG MapType
);
NTSYSCALLAPI
NTSTATUS
NTAPI
NtUnlockVirtualMemory(
_In_ HANDLE ProcessHandle,
_Inout_ PVOID *BaseAddress,
_Inout_ PSIZE_T RegionSize,
_In_ ULONG MapType
);
#endif
// Sections
#if (PHNT_MODE != PHNT_MODE_KERNEL)
NTSYSCALLAPI
NTSTATUS
NTAPI
NtCreateSection(
_Out_ PHANDLE SectionHandle,
_In_ ACCESS_MASK DesiredAccess,
_In_opt_ POBJECT_ATTRIBUTES ObjectAttributes,
_In_opt_ PLARGE_INTEGER MaximumSize,
_In_ ULONG SectionPageProtection,
_In_ ULONG AllocationAttributes,
_In_opt_ HANDLE FileHandle
);
#if (PHNT_VERSION >= PHNT_REDSTONE5)
NTSYSCALLAPI
NTSTATUS
NTAPI
NtCreateSectionEx(
_Out_ PHANDLE SectionHandle,
_In_ ACCESS_MASK DesiredAccess,
_In_opt_ POBJECT_ATTRIBUTES ObjectAttributes,
_In_opt_ PLARGE_INTEGER MaximumSize,
_In_ ULONG SectionPageProtection,
_In_ ULONG AllocationAttributes,
_In_opt_ HANDLE FileHandle,
_Inout_updates_opt_(ExtendedParameterCount) PMEM_EXTENDED_PARAMETER ExtendedParameters,
_In_ ULONG ExtendedParameterCount
);
#endif
NTSYSCALLAPI
NTSTATUS
NTAPI
NtOpenSection(
_Out_ PHANDLE SectionHandle,
_In_ ACCESS_MASK DesiredAccess,
_In_ POBJECT_ATTRIBUTES ObjectAttributes
);
NTSYSCALLAPI
NTSTATUS
NTAPI
NtMapViewOfSection(
_In_ HANDLE SectionHandle,
_In_ HANDLE ProcessHandle,
_Inout_ _At_(*BaseAddress, _Readable_bytes_(*ViewSize) _Writable_bytes_(*ViewSize) _Post_readable_byte_size_(*ViewSize)) PVOID *BaseAddress,
_In_ ULONG_PTR ZeroBits,
_In_ SIZE_T CommitSize,
_Inout_opt_ PLARGE_INTEGER SectionOffset,
_Inout_ PSIZE_T ViewSize,
_In_ SECTION_INHERIT InheritDisposition,
_In_ ULONG AllocationType,
_In_ ULONG Win32Protect
);
#if (PHNT_VERSION >= PHNT_REDSTONE5)
NTSYSCALLAPI
NTSTATUS
NTAPI
NtMapViewOfSectionEx(
_In_ HANDLE SectionHandle,
_In_ HANDLE ProcessHandle,
_Inout_ _At_(*BaseAddress, _Readable_bytes_(*ViewSize) _Writable_bytes_(*ViewSize) _Post_readable_byte_size_(*ViewSize)) PVOID *BaseAddress,
_Inout_opt_ PLARGE_INTEGER SectionOffset,
_Inout_ PSIZE_T ViewSize,
_In_ ULONG AllocationType,
_In_ ULONG Win32Protect,
_Inout_updates_opt_(ExtendedParameterCount) PMEM_EXTENDED_PARAMETER ExtendedParameters,
_In_ ULONG ExtendedParameterCount
);
#endif
NTSYSCALLAPI
NTSTATUS
NTAPI
NtUnmapViewOfSection(
_In_ HANDLE ProcessHandle,
_In_opt_ PVOID BaseAddress
);
#if (PHNT_VERSION >= PHNT_WIN8)
NTSYSCALLAPI
NTSTATUS
NTAPI
NtUnmapViewOfSectionEx(
_In_ HANDLE ProcessHandle,
_In_opt_ PVOID BaseAddress,
_In_ ULONG Flags
);
#endif
NTSYSCALLAPI
NTSTATUS
NTAPI
NtExtendSection(
_In_ HANDLE SectionHandle,
_Inout_ PLARGE_INTEGER NewSectionSize
);
NTSYSCALLAPI
NTSTATUS
NTAPI
NtQuerySection(
_In_ HANDLE SectionHandle,
_In_ SECTION_INFORMATION_CLASS SectionInformationClass,
_Out_writes_bytes_(SectionInformationLength) PVOID SectionInformation,
_In_ SIZE_T SectionInformationLength,
_Out_opt_ PSIZE_T ReturnLength
);
NTSYSCALLAPI
NTSTATUS
NTAPI
NtAreMappedFilesTheSame(
_In_ PVOID File1MappedAsAnImage,
_In_ PVOID File2MappedAsFile
);
#endif
// Partitions
#ifndef MEMORY_PARTITION_QUERY_ACCESS
#define MEMORY_PARTITION_QUERY_ACCESS 0x0001
#define MEMORY_PARTITION_MODIFY_ACCESS 0x0002
#define MEMORY_PARTITION_ALL_ACCESS \
(STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \
MEMORY_PARTITION_QUERY_ACCESS | MEMORY_PARTITION_MODIFY_ACCESS)
#endif
#if (PHNT_MODE != PHNT_MODE_KERNEL)
// private
typedef enum _PARTITION_INFORMATION_CLASS
{
SystemMemoryPartitionInformation, // q: MEMORY_PARTITION_CONFIGURATION_INFORMATION
SystemMemoryPartitionMoveMemory, // s: MEMORY_PARTITION_TRANSFER_INFORMATION
SystemMemoryPartitionAddPagefile, // s: MEMORY_PARTITION_PAGEFILE_INFORMATION
SystemMemoryPartitionCombineMemory, // q; s: MEMORY_PARTITION_PAGE_COMBINE_INFORMATION
SystemMemoryPartitionInitialAddMemory, // q; s: MEMORY_PARTITION_INITIAL_ADD_INFORMATION
SystemMemoryPartitionGetMemoryEvents, // MEMORY_PARTITION_MEMORY_EVENTS_INFORMATION // since REDSTONE2
SystemMemoryPartitionSetAttributes,
SystemMemoryPartitionNodeInformation,
SystemMemoryPartitionCreateLargePages,
SystemMemoryPartitionDedicatedMemoryInformation,
SystemMemoryPartitionOpenDedicatedMemory, // 10
SystemMemoryPartitionMemoryChargeAttributes,
SystemMemoryPartitionClearAttributes,
SystemMemoryPartitionSetMemoryThresholds, // since WIN11
SystemMemoryPartitionMax
} PARTITION_INFORMATION_CLASS, *PPARTITION_INFORMATION_CLASS;
#else
#define SystemMemoryPartitionInformation 0x0
#define SystemMemoryPartitionMoveMemory 0x1
#define SystemMemoryPartitionAddPagefile 0x2
#define SystemMemoryPartitionCombineMemory 0x3
#define SystemMemoryPartitionInitialAddMemory 0x4
#define SystemMemoryPartitionGetMemoryEvents 0x5
#define SystemMemoryPartitionSetAttributes 0x6
#define SystemMemoryPartitionNodeInformation 0x7
#define SystemMemoryPartitionCreateLargePages 0x8
#define SystemMemoryPartitionDedicatedMemoryInformation 0x9
#define SystemMemoryPartitionOpenDedicatedMemory 0xA
#define SystemMemoryPartitionMemoryChargeAttributes 0xB
#define SystemMemoryPartitionClearAttributes 0xC
#define SystemMemoryPartitionSetMemoryThresholds 0xD
#define SystemMemoryPartitionMax 0xE
#endif
// private
typedef struct _MEMORY_PARTITION_CONFIGURATION_INFORMATION
{
ULONG Flags;
ULONG NumaNode;
ULONG Channel;
ULONG NumberOfNumaNodes;
ULONG_PTR ResidentAvailablePages;
ULONG_PTR CommittedPages;
ULONG_PTR CommitLimit;
ULONG_PTR PeakCommitment;
ULONG_PTR TotalNumberOfPages;
ULONG_PTR AvailablePages;
ULONG_PTR ZeroPages;
ULONG_PTR FreePages;
ULONG_PTR StandbyPages;
ULONG_PTR StandbyPageCountByPriority[8]; // since REDSTONE2
ULONG_PTR RepurposedPagesByPriority[8];
ULONG_PTR MaximumCommitLimit;
ULONG_PTR Reserved; // DonatedPagesToPartitions
ULONG PartitionId; // since REDSTONE3
} MEMORY_PARTITION_CONFIGURATION_INFORMATION, *PMEMORY_PARTITION_CONFIGURATION_INFORMATION;
// private
typedef struct _MEMORY_PARTITION_TRANSFER_INFORMATION
{
ULONG_PTR NumberOfPages;
ULONG NumaNode;
ULONG Flags;
} MEMORY_PARTITION_TRANSFER_INFORMATION, *PMEMORY_PARTITION_TRANSFER_INFORMATION;
// private
typedef struct _MEMORY_PARTITION_PAGEFILE_INFORMATION
{
UNICODE_STRING PageFileName;
LARGE_INTEGER MinimumSize;
LARGE_INTEGER MaximumSize;
ULONG Flags;
} MEMORY_PARTITION_PAGEFILE_INFORMATION, *PMEMORY_PARTITION_PAGEFILE_INFORMATION;
// private
typedef struct _MEMORY_PARTITION_PAGE_COMBINE_INFORMATION
{
HANDLE StopHandle;
ULONG Flags;
ULONG_PTR TotalNumberOfPages;
} MEMORY_PARTITION_PAGE_COMBINE_INFORMATION, *PMEMORY_PARTITION_PAGE_COMBINE_INFORMATION;
// private
typedef struct _MEMORY_PARTITION_PAGE_RANGE
{
ULONG_PTR StartPage;
ULONG_PTR NumberOfPages;
} MEMORY_PARTITION_PAGE_RANGE, *PMEMORY_PARTITION_PAGE_RANGE;
// private
typedef struct _MEMORY_PARTITION_INITIAL_ADD_INFORMATION
{
ULONG Flags;
ULONG NumberOfRanges;
ULONG_PTR NumberOfPagesAdded;
MEMORY_PARTITION_PAGE_RANGE PartitionRanges[1];
} MEMORY_PARTITION_INITIAL_ADD_INFORMATION, *PMEMORY_PARTITION_INITIAL_ADD_INFORMATION;
// private
typedef struct _MEMORY_PARTITION_MEMORY_EVENTS_INFORMATION
{
union
{
struct
{
ULONG CommitEvents : 1;
ULONG Spare : 31;
};
ULONG AllFlags;
} Flags;
ULONG HandleAttributes;
ULONG DesiredAccess;
HANDLE LowCommitCondition; // \KernelObjects\LowCommitCondition
HANDLE HighCommitCondition; // \KernelObjects\HighCommitCondition
HANDLE MaximumCommitCondition; // \KernelObjects\MaximumCommitCondition
} MEMORY_PARTITION_MEMORY_EVENTS_INFORMATION, *PMEMORY_PARTITION_MEMORY_EVENTS_INFORMATION;
#if (PHNT_MODE != PHNT_MODE_KERNEL)
#if (PHNT_VERSION >= PHNT_THRESHOLD)
NTSYSCALLAPI
NTSTATUS
NTAPI
NtCreatePartition(
_In_opt_ HANDLE ParentPartitionHandle,
_Out_ PHANDLE PartitionHandle,
_In_ ACCESS_MASK DesiredAccess,
_In_opt_ POBJECT_ATTRIBUTES ObjectAttributes,
_In_ ULONG PreferredNode
);
NTSYSCALLAPI
NTSTATUS
NTAPI
NtOpenPartition(
_Out_ PHANDLE PartitionHandle,
_In_ ACCESS_MASK DesiredAccess,
_In_ POBJECT_ATTRIBUTES ObjectAttributes
);
NTSYSCALLAPI
NTSTATUS
NTAPI
NtManagePartition(
_In_ HANDLE TargetHandle,
_In_opt_ HANDLE SourceHandle,
_In_ PARTITION_INFORMATION_CLASS PartitionInformationClass,
_Inout_updates_bytes_(PartitionInformationLength) PVOID PartitionInformation,
_In_ ULONG PartitionInformationLength
);
#endif
#endif
// User physical pages
#if (PHNT_MODE != PHNT_MODE_KERNEL)
NTSYSCALLAPI
NTSTATUS
NTAPI
NtMapUserPhysicalPages(
_In_ PVOID VirtualAddress,
_In_ ULONG_PTR NumberOfPages,
_In_reads_opt_(NumberOfPages) PULONG_PTR UserPfnArray
);
NTSYSCALLAPI
NTSTATUS
NTAPI
NtMapUserPhysicalPagesScatter(
_In_reads_(NumberOfPages) PVOID *VirtualAddresses,
_In_ ULONG_PTR NumberOfPages,
_In_reads_opt_(NumberOfPages) PULONG_PTR UserPfnArray
);
NTSYSCALLAPI
NTSTATUS
NTAPI
NtAllocateUserPhysicalPages(
_In_ HANDLE ProcessHandle,
_Inout_ PULONG_PTR NumberOfPages,
_Out_writes_(*NumberOfPages) PULONG_PTR UserPfnArray
);
#if (PHNT_VERSION >= PHNT_THRESHOLD)
NTSYSCALLAPI
NTSTATUS
NTAPI
NtAllocateUserPhysicalPagesEx(
_In_ HANDLE ProcessHandle,
_Inout_ PULONG_PTR NumberOfPages,
_Out_writes_(*NumberOfPages) PULONG_PTR UserPfnArray,
_Inout_updates_opt_(ParameterCount) PMEM_EXTENDED_PARAMETER ExtendedParameters,
_In_ ULONG ExtendedParameterCount
);
#endif
NTSYSCALLAPI
NTSTATUS
NTAPI
NtFreeUserPhysicalPages(
_In_ HANDLE ProcessHandle,
_Inout_ PULONG_PTR NumberOfPages,
_In_reads_(*NumberOfPages) PULONG_PTR UserPfnArray
);
#endif
// Misc.
#if (PHNT_MODE != PHNT_MODE_KERNEL)
NTSYSCALLAPI
NTSTATUS
NTAPI
NtGetWriteWatch(
_In_ HANDLE ProcessHandle,
_In_ ULONG Flags,
_In_ PVOID BaseAddress,
_In_ SIZE_T RegionSize,
_Out_writes_(*EntriesInUserAddressArray) PVOID *UserAddressArray,
_Inout_ PULONG_PTR EntriesInUserAddressArray,
_Out_ PULONG Granularity
);
NTSYSCALLAPI
NTSTATUS
NTAPI
NtResetWriteWatch(
_In_ HANDLE ProcessHandle,
_In_ PVOID BaseAddress,
_In_ SIZE_T RegionSize
);
NTSYSCALLAPI
NTSTATUS
NTAPI
NtCreatePagingFile(
_In_ PUNICODE_STRING PageFileName,
_In_ PLARGE_INTEGER MinimumSize,
_In_ PLARGE_INTEGER MaximumSize,
_In_ ULONG Priority
);
NTSYSCALLAPI
NTSTATUS
NTAPI
NtFlushInstructionCache(
_In_ HANDLE ProcessHandle,
_In_opt_ PVOID BaseAddress,
_In_ SIZE_T Length
);
NTSYSCALLAPI
NTSTATUS
NTAPI
NtFlushWriteBuffer(
VOID
);
#endif
// Enclave support
NTSYSCALLAPI
NTSTATUS
NTAPI
NtCreateEnclave(
_In_ HANDLE ProcessHandle,
_Inout_ PVOID* BaseAddress,
_In_ ULONG_PTR ZeroBits,
_In_ SIZE_T Size,
_In_ SIZE_T InitialCommitment,
_In_ ULONG EnclaveType,
_In_reads_bytes_(EnclaveInformationLength) PVOID EnclaveInformation,
_In_ ULONG EnclaveInformationLength,
_Out_opt_ PULONG EnclaveError
);
NTSYSCALLAPI
NTSTATUS
NTAPI
NtLoadEnclaveData(
_In_ HANDLE ProcessHandle,
_In_ PVOID BaseAddress,
_In_reads_bytes_(BufferSize) PVOID Buffer,
_In_ SIZE_T BufferSize,
_In_ ULONG Protect,
_In_reads_bytes_(PageInformationLength) PVOID PageInformation,
_In_ ULONG PageInformationLength,
_Out_opt_ PSIZE_T NumberOfBytesWritten,
_Out_opt_ PULONG EnclaveError
);
NTSYSCALLAPI
NTSTATUS
NTAPI
NtInitializeEnclave(
_In_ HANDLE ProcessHandle,
_In_ PVOID BaseAddress,
_In_reads_bytes_(EnclaveInformationLength) PVOID EnclaveInformation,
_In_ ULONG EnclaveInformationLength,
_Out_opt_ PULONG EnclaveError
);
// rev
NTSYSCALLAPI
NTSTATUS
NTAPI
NtTerminateEnclave(
_In_ PVOID BaseAddress,
_In_ BOOLEAN WaitForThread
);
#if (PHNT_MODE != PHNT_MODE_KERNEL)
// rev
NTSYSCALLAPI
NTSTATUS
NTAPI
NtCallEnclave(
_In_ PENCLAVE_ROUTINE Routine,
_In_ PVOID Parameter,
_In_ BOOLEAN WaitForThread,
_Out_opt_ PVOID *ReturnValue
);
#endif
#endif
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.