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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7dbbfa3a7ee3fd2c6b836650067357b7a36fb46d
|
d169de4c5c6b281984df35536430dcc931a957a9
|
/source/component/ui/menusys/vsf_menusys.c
|
3c1a61c5285be01e55689f4a83d1d9dd84aadfce
|
[
"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
| 6,702
|
c
|
vsf_menusys.c
|
/*****************************************************************************
* Copyright(C)2009-2022 by VSF Team *
* *
* 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. *
* *
****************************************************************************/
/*============================ INCLUDES ======================================*/
#include "../vsf_ui_cfg.h"
#if VSF_USE_MENUSYS == ENABLED
#define __VSF_MENUSYS_IMPLEMENT
#include "./vsf_menusys.h"
#include "utilities/vsf_utilities.h"
/*============================ MACROS ========================================*/
/*============================ MACROFIED FUNCTIONS ===========================*/
/*============================ TYPES =========================================*/
/*============================ GLOBAL VARIABLES ==============================*/
/*============================ LOCAL VARIABLES ===============================*/
/*============================ PROTOTYPES ====================================*/
/*============================ IMPLEMENTATION ================================*/
void vsf_menusys_init(vsf_menusys_t *menusys)
{
VSF_UI_ASSERT(menusys != NULL);
menusys->screen_stack_pos = -1;
}
vsf_menusys_menu_t * vsf_menusys_poll(vsf_menusys_t *menusys, int_fast16_t *idx)
{
vsf_menusys_menu_t *menu;
VSF_UI_ASSERT((menusys != NULL) && (idx != NULL));
if (*idx < 0) {
*idx = 0;
}
if (menusys->screen_stack_pos >= 0) {
int_fast16_t idx_orig = *idx;
vsf_menusys_screen_t *cur_screen = menusys->screen_stack[menusys->screen_stack_pos];
while (*idx < cur_screen->menu_num) {
menu = &cur_screen->menus[(*idx)++];
if (menu->is_updating) {
return menu;
}
}
if (idx_orig != 0) {
*idx = 0;
return NULL;
}
}
*idx = -1;
return NULL;
}
void vsf_menusys_menu_updated(vsf_menusys_t *menusys, vsf_menusys_menu_t *menu)
{
menu->is_updating = false;
}
static vsf_menusys_menu_t * __vsf_menusys_get_menu(vsf_menusys_t *menusys, uint_fast8_t menu_idx)
{
VSF_UI_ASSERT((menusys != NULL) && (menusys->screen_stack_pos >= 0) && (menusys->screen_stack_pos < menusys->screen_stack_size));
vsf_menusys_screen_t *cur_screen = menusys->screen_stack[menusys->screen_stack_pos];
VSF_UI_ASSERT(cur_screen->menu_num > menu_idx);
return &cur_screen->menus[menu_idx];
}
void vsf_menusys_move_item_absolute(vsf_menusys_t *menusys, uint_fast8_t menu_idx, uint_fast8_t item_idx)
{
vsf_menusys_menu_t *menu = __vsf_menusys_get_menu(menusys, menu_idx);
if (!menu->is_updating) {
vsf_menusys_menu_info_t *info = menu->info;
uint_fast8_t old_idx = menu->item_pos;
VSF_UI_ASSERT(item_idx < info->item_num);
menu->item_pos = item_idx;
if (old_idx != menu->item_pos) {
menu->item_pos_pre = old_idx;
menu->is_switching = true;
menu->is_updating = true;
menu->update_state = 0;
}
}
}
void vsf_menusys_move_item_relative(vsf_menusys_t *menusys, uint_fast8_t menu_idx, int_fast8_t step)
{
vsf_menusys_menu_t *menu = __vsf_menusys_get_menu(menusys, menu_idx);
if (!menu->is_updating) {
vsf_menusys_menu_info_t *info = menu->info;
VSF_UI_ASSERT((step > -info->item_num) && (step < info->item_num));
vsf_menusys_move_item_absolute(menusys, menu_idx, (menu->item_pos + info->item_num + step) % info->item_num);
}
}
static void __vf_menusys_screen_clear_update(vsf_menusys_screen_t *screen)
{
vsf_menusys_menu_t *menu = &screen->menus[0];
for (uint_fast8_t i = 0; i < screen->menu_num; i++, menu++) {
menu->is_switching = false;
menu->is_updating = false;
menu->update_state = 0;
}
}
static void __vf_menusys_screen_set_update(vsf_menusys_screen_t *screen)
{
vsf_menusys_menu_t *menu = &screen->menus[0];
for (uint_fast8_t i = 0; i < screen->menu_num; i++, menu++) {
menu->is_switching = false;
menu->is_updating = true;
menu->update_state = 0;
}
}
void vsf_menusys_enter_screen(vsf_menusys_t *menusys, vsf_menusys_screen_t *screen)
{
VSF_UI_ASSERT((menusys != NULL) && (menusys->screen_stack_pos < menusys->screen_stack_size));
if (menusys->screen_stack_pos >= 0) {
__vf_menusys_screen_clear_update(menusys->screen_stack[menusys->screen_stack_pos]);
}
__vf_menusys_screen_set_update(screen);
menusys->screen_stack[++menusys->screen_stack_pos] = screen;
}
void vsf_menusys_leave_screen(vsf_menusys_t *menusys)
{
VSF_UI_ASSERT((menusys != NULL) && (menusys->screen_stack_pos >= 0));
menusys->screen_stack_pos--;
if (menusys->screen_stack_pos >= 0) {
__vf_menusys_screen_set_update(menusys->screen_stack[menusys->screen_stack_pos]);
}
}
void vsf_menusys_select_cur_item(vsf_menusys_t *menusys, uint_fast8_t menu_idx)
{
vsf_menusys_menu_t *menu = __vsf_menusys_get_menu(menusys, menu_idx);
VSF_UI_ASSERT(menu->item_pos < menu->info->item_num);
vsf_menusys_menu_info_t *menu_info = menu->info;
vsf_menusys_menu_item_t *menu_item = &menu_info->items[menu->item_pos];
switch (menu_item->anchor_type) {
case VSF_MENU_ITEM_ANCHOR_TYPE_MENU:
if (menu_item->anchor.screen != NULL) {
vsf_menusys_enter_screen(menusys, menu_item->anchor.screen);
} else {
vsf_menusys_leave_screen(menusys);
}
break;
case VSF_MENU_ITEM_ANCHOR_TYPE_CALLBACK:
if (menu_item->anchor.callback != NULL) {
menu_item->anchor.callback(menu, menu_idx);
}
break;
}
}
#endif // VSF_USE_MENUSYS
|
2e26f359b575d6b8ca0f0d6545b7e48a8a387e7f
|
2c73a693c2b3c162eae2ab94f649d8c4494878ba
|
/components/network/paho.mqtt.c/src/SocketBuffer.c
|
f6b817af5333185b82c79d26fa41c59407b23475
|
[
"MIT"
] |
permissive
|
openLuat/LuatOS
|
185e1e140aed908434168133571ddcafe98f4e12
|
4b29d5121ab4f7133630331e8502c526c7856897
|
refs/heads/master
| 2023-08-23T04:57:23.263539
| 2023-08-23T04:46:46
| 2023-08-23T04:46:46
| 230,403,844
| 378
| 93
|
MIT
| 2021-12-17T02:19:30
| 2019-12-27T08:29:19
|
C
|
UTF-8
|
C
| false
| false
| 10,658
|
c
|
SocketBuffer.c
|
/*******************************************************************************
* Copyright (c) 2009, 2020 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* https://www.eclipse.org/legal/epl-2.0/
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation
* Ian Craggs, Allan Stockdill-Mander - SSL updates
* Ian Craggs - fix for issue #244, issue #20
*******************************************************************************/
/**
* @file
* \brief Socket buffering related functions
*
* Some other related functions are in the Socket module
*/
#include "SocketBuffer.h"
#include "LinkedList.h"
#include "Log.h"
#include "Messages.h"
#include "StackTrace.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "Heap.h"
#if defined(_WIN32) || defined(_WIN64)
#define iov_len len
#define iov_base buf
#endif
/**
* Default input queue buffer
*/
static socket_queue* def_queue;
/**
* List of queued input buffers
*/
static List* queues;
/**
* List of queued write buffers
*/
static List writes;
int socketcompare(void* a, void* b);
int SocketBuffer_newDefQ(void);
void SocketBuffer_freeDefQ(void);
int pending_socketcompare(void* a, void* b);
/**
* List callback function for comparing socket_queues by socket
* @param a first integer value
* @param b second integer value
* @return boolean indicating whether a and b are equal
*/
int socketcompare(void* a, void* b)
{
return ((socket_queue*)a)->socket == *(int*)b;
}
/**
* Create a new default queue when one has just been used.
*/
int SocketBuffer_newDefQ(void)
{
int rc = PAHO_MEMORY_ERROR;
def_queue = malloc(sizeof(socket_queue));
if (def_queue)
{
def_queue->buflen = 1000;
def_queue->buf = malloc(def_queue->buflen);
if (def_queue->buf)
{
def_queue->socket = def_queue->index = 0;
def_queue->buflen = def_queue->datalen = def_queue->headerlen = 0;
rc = 0;
}
}
return rc;
}
/**
* Initialize the socketBuffer module
*/
int SocketBuffer_initialize(void)
{
int rc = 0;
FUNC_ENTRY;
rc = SocketBuffer_newDefQ();
if (rc == 0)
{
if ((queues = ListInitialize()) == NULL)
rc = PAHO_MEMORY_ERROR;
}
ListZero(&writes);
FUNC_EXIT_RC(rc);
return rc;
}
/**
* Free the default queue memory
*/
void SocketBuffer_freeDefQ(void)
{
free(def_queue->buf);
free(def_queue);
def_queue = NULL;
}
/**
* Terminate the socketBuffer module
*/
void SocketBuffer_terminate(void)
{
ListElement* cur = NULL;
ListEmpty(&writes);
FUNC_ENTRY;
while (ListNextElement(queues, &cur))
free(((socket_queue*)(cur->content))->buf);
ListFree(queues);
SocketBuffer_freeDefQ();
FUNC_EXIT;
}
/**
* Cleanup any buffers for a specific socket
* @param socket the socket to clean up
*/
void SocketBuffer_cleanup(int socket)
{
FUNC_ENTRY;
SocketBuffer_writeComplete(socket); /* clean up write buffers */
if (ListFindItem(queues, &socket, socketcompare))
{
free(((socket_queue*)(queues->current->content))->buf);
ListRemove(queues, queues->current->content);
}
if (def_queue->socket == socket)
{
def_queue->socket = def_queue->index = 0;
def_queue->headerlen = def_queue->datalen = 0;
}
FUNC_EXIT;
}
/**
* Get any queued data for a specific socket
* @param socket the socket to get queued data for
* @param bytes the number of bytes of data to retrieve
* @param actual_len the actual length returned
* @return the actual data
*/
char* SocketBuffer_getQueuedData(int socket, size_t bytes, size_t* actual_len)
{
socket_queue* queue = NULL;
FUNC_ENTRY;
if (ListFindItem(queues, &socket, socketcompare))
{ /* if there is queued data for this socket, add any data read to it */
queue = (socket_queue*)(queues->current->content);
*actual_len = queue->datalen;
}
else
{
*actual_len = 0;
queue = def_queue;
}
if (bytes > queue->buflen)
{
if (queue->datalen > 0)
{
void* newmem = malloc(bytes);
free(queue->buf);
queue->buf = newmem;
if (!newmem)
goto exit;
memcpy(newmem, queue->buf, queue->datalen);
}
else
queue->buf = realloc(queue->buf, bytes);
queue->buflen = bytes;
}
exit:
FUNC_EXIT;
return queue->buf;
}
/**
* Get any queued character for a specific socket
* @param socket the socket to get queued data for
* @param c the character returned if any
* @return completion code
*/
int SocketBuffer_getQueuedChar(int socket, char* c)
{
int rc = SOCKETBUFFER_INTERRUPTED;
FUNC_ENTRY;
if (ListFindItem(queues, &socket, socketcompare))
{ /* if there is queued data for this socket, read that first */
socket_queue* queue = (socket_queue*)(queues->current->content);
if (queue->index < queue->headerlen)
{
*c = queue->fixed_header[(queue->index)++];
Log(TRACE_MAX, -1, "index is now %d, headerlen %d", queue->index, (int)queue->headerlen);
rc = SOCKETBUFFER_COMPLETE;
goto exit;
}
else if (queue->index > 4)
{
Log(LOG_FATAL, -1, "header is already at full length");
rc = SOCKET_ERROR;
goto exit;
}
}
exit:
FUNC_EXIT_RC(rc);
return rc; /* there was no queued char if rc is SOCKETBUFFER_INTERRUPTED*/
}
/**
* A socket read was interrupted so we need to queue data
* @param socket the socket to get queued data for
* @param actual_len the actual length of data that was read
*/
void SocketBuffer_interrupted(int socket, size_t actual_len)
{
socket_queue* queue = NULL;
FUNC_ENTRY;
if (ListFindItem(queues, &socket, socketcompare))
queue = (socket_queue*)(queues->current->content);
else /* new saved queue */
{
queue = def_queue;
/* if SocketBuffer_queueChar() has not yet been called, then the socket number
in def_queue will not have been set. Issue #244.
If actual_len == 0 then we may not need to do anything - I'll leave that
optimization for another time. */
queue->socket = socket;
ListAppend(queues, def_queue, sizeof(socket_queue)+def_queue->buflen);
SocketBuffer_newDefQ();
}
queue->index = 0;
queue->datalen = actual_len;
FUNC_EXIT;
}
/**
* A socket read has now completed so we can get rid of the queue
* @param socket the socket for which the operation is now complete
* @return pointer to the default queue data
*/
char* SocketBuffer_complete(int socket)
{
FUNC_ENTRY;
if (ListFindItem(queues, &socket, socketcompare))
{
socket_queue* queue = (socket_queue*)(queues->current->content);
SocketBuffer_freeDefQ();
def_queue = queue;
ListDetach(queues, queue);
}
def_queue->socket = def_queue->index = 0;
def_queue->headerlen = def_queue->datalen = 0;
FUNC_EXIT;
return def_queue->buf;
}
/**
* Queued a Charactor to a specific socket
* @param socket the socket for which to queue char for
* @param c the character to queue
*/
void SocketBuffer_queueChar(int socket, char c)
{
int error = 0;
socket_queue* curq = def_queue;
FUNC_ENTRY;
if (ListFindItem(queues, &socket, socketcompare))
curq = (socket_queue*)(queues->current->content);
else if (def_queue->socket == 0)
{
def_queue->socket = socket;
def_queue->index = 0;
def_queue->datalen = 0;
}
else if (def_queue->socket != socket)
{
Log(LOG_FATAL, -1, "attempt to reuse socket queue");
error = 1;
}
if (curq->index > 4)
{
Log(LOG_FATAL, -1, "socket queue fixed_header field full");
error = 1;
}
if (!error)
{
curq->fixed_header[(curq->index)++] = c;
curq->headerlen = curq->index;
}
Log(TRACE_MAX, -1, "queueChar: index is now %d, headerlen %d", curq->index, (int)curq->headerlen);
FUNC_EXIT;
}
/**
* A socket write was interrupted so store the remaining data
* @param socket the socket for which the write was interrupted
* @param count the number of iovec buffers
* @param iovecs buffer array
* @param frees a set of flags indicating which of the iovecs array should be freed
* @param total total data length to be written
* @param bytes actual data length that was written
*/
#if defined(OPENSSL)
int SocketBuffer_pendingWrite(int socket, SSL* ssl, int count, iobuf* iovecs, int* frees, size_t total, size_t bytes)
#else
int SocketBuffer_pendingWrite(int socket, int count, iobuf* iovecs, int* frees, size_t total, size_t bytes)
#endif
{
int i = 0;
pending_writes* pw = NULL;
int rc = 0;
FUNC_ENTRY;
/* store the buffers until the whole packet is written */
if ((pw = malloc(sizeof(pending_writes))) == NULL)
{
rc = PAHO_MEMORY_ERROR;
goto exit;
}
pw->socket = socket;
#if defined(OPENSSL)
pw->ssl = ssl;
#endif
pw->bytes = bytes;
pw->total = total;
pw->count = count;
for (i = 0; i < count; i++)
{
pw->iovecs[i] = iovecs[i];
pw->frees[i] = frees[i];
}
ListAppend(&writes, pw, sizeof(pw) + total);
exit:
FUNC_EXIT_RC(rc);
return rc;
}
/**
* List callback function for comparing pending_writes by socket
* @param a first integer value
* @param b second integer value
* @return boolean indicating whether a and b are equal
*/
int pending_socketcompare(void* a, void* b)
{
return ((pending_writes*)a)->socket == *(int*)b;
}
/**
* Get any queued write data for a specific socket
* @param socket the socket to get queued data for
* @return pointer to the queued data or NULL
*/
pending_writes* SocketBuffer_getWrite(int socket)
{
ListElement* le = ListFindItem(&writes, &socket, pending_socketcompare);
return (le) ? (pending_writes*)(le->content) : NULL;
}
/**
* A socket write has now completed so we can get rid of the queue
* @param socket the socket for which the operation is now complete
* @return completion code, boolean - was the queue removed?
*/
int SocketBuffer_writeComplete(int socket)
{
return ListRemoveItem(&writes, &socket, pending_socketcompare);
}
/**
* Update the queued write data for a socket in the case of QoS 0 messages.
* @param socket the socket for which the operation is now complete
* @param topic the topic of the QoS 0 write
* @param payload the payload of the QoS 0 write
* @return pointer to the updated queued data structure, or NULL
*/
pending_writes* SocketBuffer_updateWrite(int socket, char* topic, char* payload)
{
pending_writes* pw = NULL;
ListElement* le = NULL;
FUNC_ENTRY;
if ((le = ListFindItem(&writes, &socket, pending_socketcompare)) != NULL)
{
pw = (pending_writes*)(le->content);
if (pw->count == 4)
{
pw->iovecs[2].iov_base = topic;
pw->iovecs[3].iov_base = payload;
}
}
FUNC_EXIT;
return pw;
}
|
c503cf4f1c9722adce66c275f3b00c61d21f7605
|
d2253070a3a64b14dee5ca0b3d311919178e590c
|
/include/clear_save_data_menu.h
|
86ba99849cdfe4b92f60602921c194ad6cc4e247
|
[] |
no_license
|
pret/pokeemerald
|
ce232eccdde78502f3c251d672b26af3e1d7e508
|
d67914e114c937c4c80ce128ddc5523d4dc2cd40
|
refs/heads/master
| 2023-08-31T11:23:13.877932
| 2023-08-27T23:40:59
| 2023-08-27T23:40:59
| 43,677,244
| 1,944
| 1,903
| null | 2023-09-12T22:48:06
| 2015-10-05T10:09:22
|
C
|
UTF-8
|
C
| false
| false
| 155
|
h
|
clear_save_data_menu.h
|
#ifndef GUARD_CLEAR_SAVE_DATA_MENU_H
#define GUARD_CLEAR_SAVE_DATA_MENU_H
void CB2_InitClearSaveDataScreen(void);
#endif // GUARD_CLEAR_SAVE_DATA_MENU_H
|
796ebed1a3a6c88c9d996268760df7394ef6f943
|
984bc4181baec6e5a4b05a657e666b0e9f89f3f3
|
/3rdparty/mongo-c-driver-1.21.2/src/libmongoc/src/mongoc/mongoc-array.c
|
756332eafe8192958ce63a414d697bc598711163
|
[
"Apache-2.0",
"BSD-3-Clause"
] |
permissive
|
treefrogframework/treefrog-framework
|
0173245ff92162d2107af79861505981980d1eca
|
a1df97793e8cc628779378e5adae9af6987460c1
|
refs/heads/master
| 2023-08-22T03:57:58.891846
| 2023-05-18T14:00:42
| 2023-05-18T14:00:42
| 7,067,532
| 1,152
| 263
|
BSD-3-Clause
| 2023-08-08T20:25:03
| 2012-12-08T13:17:01
|
C++
|
UTF-8
|
C
| false
| false
| 2,323
|
c
|
mongoc-array.c
|
/*
* Copyright 2013 MongoDB, 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 "mongoc-array-private.h"
void
_mongoc_array_init (mongoc_array_t *array, size_t element_size)
{
BSON_ASSERT (array);
BSON_ASSERT (element_size);
array->len = 0;
array->element_size = element_size;
array->allocated = 128;
array->data = (void *) bson_malloc0 (array->allocated);
}
/*
*--------------------------------------------------------------------------
*
* _mongoc_array_copy --
*
* Destroy dst and copy src into it. Both arrays must be initialized.
*
* Returns:
* None.
*
* Side effects:
* None.
*
*--------------------------------------------------------------------------
*/
void
_mongoc_array_copy (mongoc_array_t *dst, const mongoc_array_t *src)
{
_mongoc_array_destroy (dst);
dst->len = src->len;
dst->element_size = src->element_size;
dst->allocated = src->allocated;
dst->data = (void *) bson_malloc (dst->allocated);
memcpy (dst->data, src->data, dst->allocated);
}
void
_mongoc_array_destroy (mongoc_array_t *array)
{
if (array && array->data) {
bson_free (array->data);
}
}
void
_mongoc_array_append_vals (mongoc_array_t *array,
const void *data,
uint32_t n_elements)
{
size_t len;
size_t off;
size_t next_size;
BSON_ASSERT (array);
BSON_ASSERT (data);
off = array->element_size * array->len;
len = (size_t) n_elements * array->element_size;
if ((off + len) > array->allocated) {
next_size = bson_next_power_of_two (off + len);
array->data = (void *) bson_realloc (array->data, next_size);
array->allocated = next_size;
}
memcpy ((uint8_t *) array->data + off, data, len);
array->len += n_elements;
}
|
695d34b51555eb5fed8b6f4baaa56291f58aa367
|
1efd2de8bf77ec00eb2fcaf5749278495946d920
|
/src/include/daos/kv.h
|
5b4cde401a86e3eee8761dff0059406cd1c73cb9
|
[
"BSD-2-Clause",
"BSD-2-Clause-Patent"
] |
permissive
|
daos-stack/daos
|
6f55bf3061fd830d5b8d28506e1295e2d3a27c38
|
ed5eed5df43a68571afe123132a743824c02637a
|
refs/heads/master
| 2023-08-31T21:43:37.606145
| 2023-08-31T16:38:00
| 2023-08-31T16:38:00
| 69,390,670
| 631
| 300
|
NOASSERTION
| 2023-09-14T18:55:15
| 2016-09-27T19:21:29
|
C
|
UTF-8
|
C
| false
| false
| 586
|
h
|
kv.h
|
/**
* (C) Copyright 2017-2023 Intel Corporation.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
/**
* Kv task functions.
*/
#ifndef __DAOS_KVX_H__
#define __DAOS_KVX_H__
/* task function for HL operations */
int dc_kv_open(tse_task_t *task);
int dc_kv_close(tse_task_t *task);
int dc_kv_close_direct(daos_handle_t oh);
int dc_kv_destroy(tse_task_t *task);
int dc_kv_get(tse_task_t *task);
int dc_kv_put(tse_task_t *task);
int dc_kv_remove(tse_task_t *task);
int dc_kv_list(tse_task_t *task);
daos_handle_t daos_kv2objhandle(daos_handle_t oh);
#endif /* __DAOS_KVX_H__ */
|
42b162b1b01d06671541e18b6b3fc3a4554b13fb
|
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
|
/sys/arch/ofppc/isa/isa_machdep.c
|
498a7bfaf4fcf4c1bd7f91cb295170887d5ec0b2
|
[] |
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
| 3,433
|
c
|
isa_machdep.c
|
/* $NetBSD: isa_machdep.c,v 1.6 2011/07/01 20:51:14 dyoung Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Tim Rightnour
*
* 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: isa_machdep.c,v 1.6 2011/07/01 20:51:14 dyoung Exp $");
#include <sys/param.h>
#include <sys/bus.h>
#include <machine/pio.h>
#include <sys/extent.h>
#include <dev/isa/isavar.h>
#include <dev/isa/isareg.h>
#define IO_ELCR1 0x4d0
#define IO_ELCR2 0x4d1
struct powerpc_isa_chipset genppc_ict;
bus_space_handle_t io_icu1h, io_icu2h, io_elcrh;
/*
* These functions can *ONLY* be used to talk to the i8259. Leave them
* alone. I know they are greusome.
*/
int
map_isa_ioregs(void)
{
int err, noerr;
err = bus_space_map(&genppc_isa_io_space_tag, IO_ICU1, 2, 0,
&io_icu1h);
if (err != 0)
panic("Can't map IO_ICU1 error %d\n", err);
err = bus_space_map(&genppc_isa_io_space_tag, IO_ICU2, 2, 0,
&io_icu2h);
if (err != 0)
panic("Can't map IO_ICU2 error %d\n", err);
noerr = bus_space_map(&genppc_isa_io_space_tag, IO_ELCR1, 2, 0,
&io_elcrh);
if (noerr != 0)
aprint_error("Can't map IO_ELCR error %d\n", noerr);
return err;
}
uint8_t
isa_inb(uint32_t addr)
{
if (addr == IO_ICU1 || addr == IO_ICU1+1)
return bus_space_read_1(&genppc_isa_io_space_tag, io_icu1h,
addr-IO_ICU1);
if (addr == IO_ICU2 || addr == IO_ICU2+1)
return bus_space_read_1(&genppc_isa_io_space_tag, io_icu2h,
addr-IO_ICU2);
if (addr == IO_ELCR1 || addr == IO_ELCR2)
return bus_space_read_1(&genppc_isa_io_space_tag, io_elcrh,
addr-IO_ELCR1);
return 0;
}
void
isa_outb(uint32_t addr, uint8_t val)
{
if (addr == IO_ICU1 || addr == IO_ICU1+1)
bus_space_write_1(&genppc_isa_io_space_tag, io_icu1h,
addr-IO_ICU1, val);
if (addr == IO_ICU2 || addr == IO_ICU2+1)
bus_space_write_1(&genppc_isa_io_space_tag, io_icu2h,
addr-IO_ICU2, val);
if (addr == IO_ELCR1 || addr == IO_ELCR2)
bus_space_write_1(&genppc_isa_io_space_tag, io_elcrh,
addr-IO_ELCR1, val);
}
|
b4ed74a09268d3e948362cfad5bf59e06620b71d
|
07bbe7a0a829cfbc9789831d981aedf36e4e94d9
|
/source/lexbor/html/interfaces/track_element.h
|
6eabbe82737800a1516ce28aefd9ab2baaafc0b4
|
[
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
lexbor/lexbor
|
0bf3a22898d8e295fa20cc1391e31a68502c458a
|
31e3d9d7f9032cd475d5afa788999de2d4b891dd
|
refs/heads/master
| 2023-08-31T23:25:49.903737
| 2023-08-30T08:25:12
| 2023-08-30T08:25:12
| 122,375,902
| 758
| 95
|
Apache-2.0
| 2023-08-30T08:25:13
| 2018-02-21T18:28:52
|
C
|
UTF-8
|
C
| false
| false
| 679
|
h
|
track_element.h
|
/*
* Copyright (C) 2018 Alexander Borisov
*
* Author: Alexander Borisov <borisov@lexbor.com>
*/
#ifndef LEXBOR_HTML_TRACK_ELEMENT_H
#define LEXBOR_HTML_TRACK_ELEMENT_H
#ifdef __cplusplus
extern "C" {
#endif
#include "lexbor/html/interface.h"
#include "lexbor/html/interfaces/element.h"
struct lxb_html_track_element {
lxb_html_element_t element;
};
LXB_API lxb_html_track_element_t *
lxb_html_track_element_interface_create(lxb_html_document_t *document);
LXB_API lxb_html_track_element_t *
lxb_html_track_element_interface_destroy(lxb_html_track_element_t *track_element);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* LEXBOR_HTML_TRACK_ELEMENT_H */
|
d1fa97c85ff2ec907d6b0efb39553c6336e413fe
|
abb28a62de39d806d5a63f5b94305069ee5950ca
|
/src/gpusim/util.h
|
77cb7805bf7b796703323b5a55697884ae7b3a2d
|
[
"MIT"
] |
permissive
|
qulacs/qulacs
|
0d79074b83b8cc0faa3c31135178b08771be9987
|
413bcd3d02c01e2ad85a711abad252daadd5b832
|
refs/heads/main
| 2023-08-16T21:25:57.217422
| 2023-07-31T01:53:48
| 2023-07-31T01:53:48
| 151,675,481
| 349
| 121
|
MIT
| 2023-09-14T01:53:34
| 2018-10-05T05:39:51
|
C++
|
UTF-8
|
C
| false
| false
| 2,201
|
h
|
util.h
|
#ifndef _UTIL_CU_H_
#define _UTIL_CU_H_
#include <cuComplex.h>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
// #include <cuda_runtime.h>
// #include <cuda.h>
#include <complex>
#include "util_common.h"
// #include "util.cuh"
extern "C" DllExport void get_quantum_state_host(
void* state_gpu, void* psi_cpu_copy, ITYPE dim);
extern "C" DllExport void* allocate_quantum_state_host(ITYPE dim);
extern "C" DllExport void initialize_quantum_state_host(
void* state_gpu, ITYPE dim);
extern "C" DllExport void release_quantum_state_host(void* state_gpu);
extern "C" DllExport void print_quantum_state_host(void* state, ITYPE dim);
extern "C" DllExport void copy_quantum_state_host(
void* state_gpu_copy, void* state_gpu, ITYPE dim);
extern "C" DllExport __host__ void set_computational_basis_host(
ITYPE comp_basis, void* state, ITYPE dim);
void get_Pauli_masks_partial_list(const UINT* target_qubit_index_list,
const UINT* Pauli_operator_type_list, UINT target_qubit_index_count,
ITYPE* bit_flip_mask, ITYPE* phase_flip_mask,
UINT* global_phase_90rot_count, UINT* pivot_qubit_index);
void get_Pauli_masks_whole_list(const UINT* Pauli_operator_type_list,
UINT target_qubit_index_count, ITYPE* bit_flip_mask, ITYPE* phase_flip_mask,
UINT* global_phase_90rot_count, UINT* pivot_qubit_index);
// int cublass_zgemm_wrapper(ITYPE n, CTYPE alpha, const CTYPE *h_A, const CTYPE
// *h_B, CTYPE beta, CTYPE *h_C); int cublas_zgemv_wrapper(ITYPE n, CTYPE alpha,
// const CTYPE *h_A, const CTYPE *h_x, CTYPE beta, CTYPE *h_y); int
// cublas_zgemv_wrapper(ITYPE n, const CTYPE *h_matrix, GTYPE *d_state);
ITYPE
create_control_mask(
const UINT* qubit_index_list, const UINT* value_list, UINT size);
UINT* create_sorted_ui_list(const UINT* array, size_t size);
ITYPE* create_matrix_mask_list(
const UINT* qubit_index_list, UINT qubit_index_count);
UINT* create_sorted_ui_list_value(const UINT* array, size_t size, UINT value);
UINT* create_sorted_ui_list_list(
const UINT* array1, size_t size1, const UINT* array2, size_t size2);
ITYPE
insert_zero_to_basis_index(ITYPE basis_index, unsigned int qubit_index);
#endif // #ifndef _QCUDASIM_UTIL_H_
|
42d93b0a2734fe55b546086b3a5958235d4b0ec3
|
2d11442aa09b51e10c245ee2b64231aeb051744f
|
/platforms/Cross/plugins/IA32ABI/dabusiness.h
|
51a838558cbf69da74f4027da6b6011a52010526
|
[
"MIT"
] |
permissive
|
OpenSmalltalk/opensmalltalk-vm
|
622b01c10017a93fdff4f1ef2188c45342384c78
|
330d6779ad2ecbce1f07131f53d75cd168165f0b
|
refs/heads/Cog
| 2023-09-04T05:36:54.320281
| 2023-08-17T11:32:52
| 2023-08-31T12:26:44
| 59,481,716
| 556
| 153
|
NOASSERTION
| 2023-06-19T19:58:13
| 2016-05-23T12:40:27
|
C
|
UTF-8
|
C
| false
| false
| 4,980
|
h
|
dabusiness.h
|
/*
* dabusiness.h
*
* Written by Eliot Miranda 11/07.
* Updated 5/2011 to cope with Cog stack direction.
*
* Body of the various callIA32XXXReturn functions.
* Call a foreign function according to IA32-ish ABI rules.
* N.B. In Cog Stack and Cogit VMs numArgs is negative to access args from
* the downward-growing stack.
*/
long i, size;
sqInt funcAlien, resultMaybeAlien;
char *argvec;
#if STACK_ALIGN_BYTES
char *argstart;
#endif
#if STACKVM /* Need to access args downwards from first arg */
if (numArgs < 0)
for (i = size = 0; --i >= numArgs;) {
sqInt arg = argVector[i+1];
if (objIsAlien(arg) && sizeField(arg))
size += moduloPOT(sizeof(long),labs(sizeField(arg)));
else if (interpreterProxy->isFloatObject(arg))
size += sizeof(double);
else /* assume an integer or pointer. check below. */
size += sizeof(long);
}
else
#endif /* STACKVM */
for (i = numArgs, size = 0; --i >= 0;) {
sqInt arg = argVector[i];
if (objIsAlien(arg) && sizeField(arg))
size += moduloPOT(sizeof(long),labs(sizeField(arg)));
else if (interpreterProxy->isFloatObject(arg))
size += sizeof(double);
else /* assume an integer or pointer. check below. */
size += sizeof(long);
}
#if STACK_ALIGN_BYTES
/* At point of call stack must be aligned to STACK_ALIGN_BYTES. So alloca
* at least enough for this plus the argvector, and start writing argvector
* at aligned point. Then just prior to call cut-back stack to aligned.
*/
argvec = alloca(STACK_ALIGN_BYTES + moduloPOT(STACK_ALIGN_BYTES,size));
argvec = alignModuloPOT(STACK_ALIGN_BYTES, argvec);
argstart = argvec;
#else
argvec = alloca(moduloPOT(sizeof(long),size));
# if defined(__MINGW32__) && (__GNUC__ >= 3)
/*
* cygwin & MinGW's gcc 3.4.x's alloca is a library routine that answers
* %esp + 4, so the outgoing stack is offset by one word if uncorrected.
* Grab the actual stack pointer to correct.
*/
argvec = getsp();
# endif
#endif
#if STACKVM /* Need to access args downwards from first arg */
if (numArgs < 0)
for (i = size = 0; --i >= numArgs;) {
sqInt arg = argVector[i+1];
if (isSmallInt(arg)) {
*(long *)argvec = intVal(arg);
argvec += sizeof(long);
}
else if (objIsAlien(arg)) {
long argByteSize;
if (!(size = sizeField(arg)))
size = argByteSize = sizeof(void *);
else
argByteSize = labs(size);
memcpy(argvec, startOfDataWithSize(arg,size), argByteSize);
argvec += moduloPOT(sizeof(long), argByteSize);
}
else if (objIsUnsafeAlien(arg)) {
sqInt bitsObj = interpreterProxy->fetchPointerofObject(0,arg);
void *v = interpreterProxy->firstIndexableField(bitsObj);
*(void **)argvec = v;
argvec += sizeof(long);
}
else if (interpreterProxy->isFloatObject(arg)) {
double d = interpreterProxy->floatValueOf(arg);
*(double *)argvec = d;
argvec += sizeof(double);
}
else {
long v = interpreterProxy->signedMachineIntegerValueOf(arg);
if (interpreterProxy->failed()) {
interpreterProxy->primitiveFailFor(0);
v = interpreterProxy->positiveMachineIntegerValueOf(arg);
if (interpreterProxy->failed())
return PrimErrBadArgument;
}
*(long *)argvec = v;
argvec += sizeof(long);
}
}
else
#endif /* STACKVM */
for (i = 0; i < numArgs; i++) {
sqInt arg = argVector[i];
if (isSmallInt(arg)) {
*(long *)argvec = intVal(arg);
argvec += sizeof(long);
}
else if (objIsAlien(arg)) {
long argByteSize;
if (!(size = sizeField(arg)))
size = argByteSize = sizeof(void *);
else
argByteSize = labs(size);
memcpy(argvec, startOfDataWithSize(arg,size), argByteSize);
argvec += moduloPOT(sizeof(long), argByteSize);
}
else if (objIsUnsafeAlien(arg)) {
sqInt bitsObj = interpreterProxy->fetchPointerofObject(0,arg);
void *v = interpreterProxy->firstIndexableField(bitsObj);
*(void **)argvec = v;
argvec += sizeof(long);
}
else if (interpreterProxy->isFloatObject(arg)) {
double d = interpreterProxy->floatValueOf(arg);
*(double *)argvec = d;
argvec += sizeof(double);
}
else {
long v = interpreterProxy->signedMachineIntegerValueOf(arg);
if (interpreterProxy->failed()) {
interpreterProxy->primitiveFailFor(0);
v = interpreterProxy->positiveMachineIntegerValueOf(arg);
if (interpreterProxy->failed())
return PrimErrBadArgument;
}
*(long *)argvec = v;
argvec += sizeof(long);
}
}
funcAlien = interpreterProxy->stackValue(funcOffset);
f = *(void **)startOfParameterData(funcAlien);
#if STACK_ALIGN_BYTES
/* cut stack back to start of aligned args */
setsp(argstart);
#endif
r = f();
/* post call need to refresh stack pointer in case of call-back and GC. */
resultMaybeAlien = interpreterProxy->stackValue(resultOffset);
if (objIsAlien(resultMaybeAlien)) {
if (!(size = sizeField(resultMaybeAlien)))
size = sizeof(void *);
memcpy(startOfDataWithSize(resultMaybeAlien,size),
&r,
min((unsigned long)labs(size), sizeof(r)));
}
return PrimNoErr;
|
456b70e9bb8880a9d0a130987af4f922fa0cc1dd
|
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
|
/tests/usr.bin/xlint/lint1/msg_049.c
|
4afa65ba4d47823b91b522ddce290dd85df058b0
|
[] |
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
| 479
|
c
|
msg_049.c
|
/* $NetBSD: msg_049.c,v 1.6 2023/03/28 14:44:34 rillig Exp $ */
# 3 "msg_049.c"
/* Test for message: anonymous struct/union members is a C11 feature [49] */
/* lint1-flags: -Sw -X 351 */
struct {
unsigned int flag: 1;
/*
* This is an anonymous struct/union member, but that's not what
* message 49 is about.
*/
unsigned int :0;
union {
int int_value;
void *pointer_value;
};
/* expect-1: warning: anonymous struct/union members is a C11 feature [49] */
} s;
|
10aafea50ddc0ce162b2405389d2efd6e53e971b
|
356a2282db8276ed9830f87cdf841aaa759f2b40
|
/src/misc.c
|
543d9256c5278117518b5cf1c4b7a46451b617f4
|
[] |
no_license
|
t6x/reaver-wps-fork-t6x
|
67fe2a053f24aca43faaf71dfef708ac1faf32ad
|
bd0f38262224c1b88ba9f1f95cb5476a488d2295
|
refs/heads/master
| 2023-08-08T20:37:48.361660
| 2023-07-18T12:58:02
| 2023-07-19T11:33:36
| 33,783,491
| 1,738
| 529
| null | 2023-07-19T11:33:37
| 2015-04-11T16:36:37
|
C
|
UTF-8
|
C
| false
| false
| 3,578
|
c
|
misc.c
|
/*
* Reaver - Misc functions
* Copyright (c) 2011, Tactical Network Solutions, Craig Heffner <cheffner@tacnetsol.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.
*
* 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
*
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. * If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. * If you
* do not wish to do so, delete this exception statement from your
* version. * If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
#include "misc.h"
/* Converts a raw MAC address to a colon-delimited string */
/* buf holds the result & needs to be 18 bytes */
void mac2str_buf(unsigned char *mac, char delim, char* buf)
{
#define PAT "%.2X%c"
#define PRT(X) mac[X], delim
#define PBT "%.2X"
if(delim)
sprintf(buf, PAT PAT PAT PAT PAT PBT, PRT(0), PRT(1), PRT(2), PRT(3), PRT(4), mac[5]);
else
sprintf(buf, PBT PBT PBT PBT PBT PBT, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
}
/* Converts a raw MAC address to a colon-delimited string */
char *mac2str(unsigned char *mac, char delim) {
char nyu[6*3];
mac2str_buf(mac, delim, nyu);
return strdup(nyu);
}
/* Converts a colon-delimited string to a raw MAC address */
void str2mac(char *str, unsigned char *mac)
{
char *delim_ptr = NULL, *num_ptr = NULL, *tmp_str = NULL;
char delim = ':';
int count = 0;
tmp_str = strdup(str);
delim_ptr = num_ptr = tmp_str;
while((delim_ptr = strchr(delim_ptr, delim)) && count < (MAC_ADDR_LEN-1))
{
memset(delim_ptr, 0, 1);
mac[count] = strtol(num_ptr, NULL, 16);
delim_ptr++;
count++;
num_ptr = delim_ptr;
}
mac[count] = strtol(num_ptr, NULL, 16);
free(tmp_str);
return;
}
static int cprintf_muted;
void cprintf_mute() {
cprintf_muted = 1;
}
void cprintf_unmute() {
cprintf_muted = 0;
}
int cprintf_ismuted() { return cprintf_muted; }
/* Conditional printf wrapper */
void cprintf(enum debug_level level, const char *fmt, ...)
{
va_list arg;
if(!cprintf_muted && (level <= get_debug()))
{
va_start(arg, fmt);
vfprintf(get_log_file(), fmt, arg);
va_end(arg);
}
fflush(get_log_file());
}
/* Closes libpcap during sleep period to avoid stale packet data in pcap buffer */
void pcap_sleep(int seconds)
{
if(seconds > 0)
{
pcap_close(get_handle());
set_handle(NULL);
sleep(seconds);
set_handle(capture_init(get_iface()));
if(!get_handle())
{
cprintf(CRITICAL, "[-] Failed to re-initialize interface '%s'\n", get_iface());
}
}
}
|
d49daea2a785d58215bb32a5261d1545e0d8a5f3
|
5afa01fb706bc29154491c441ec801585622e38c
|
/verification/cbmc/stubs/memset_override_0.c
|
649969eef04e6dd09df16a528923f678eb84e3f0
|
[
"Apache-2.0",
"BSD-3-Clause",
"GPL-2.0-only"
] |
permissive
|
awslabs/aws-c-common
|
5af461d3b3586a569a1809c7b8f32091eec1a151
|
4dcc41cf4d1f868dcdd622c65c09bda972f75ad2
|
refs/heads/main
| 2023-08-29T14:07:10.856557
| 2023-08-25T07:40:54
| 2023-08-25T07:40:54
| 117,142,517
| 249
| 159
|
Apache-2.0
| 2023-09-12T19:02:25
| 2018-01-11T19:17:12
|
C
|
UTF-8
|
C
| false
| false
| 1,078
|
c
|
memset_override_0.c
|
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
/**
* FUNCTION: memset
*
* Override the version of memset used by CBMC.
* This takes advantage of the fact that 64bit operations require fewer array updates,
* which can make this version faster than the naive unrolling when used in CBMC.
* Benchmark your particular proof to know for sure.
*/
#include <assert.h>
#include <stddef.h>
#include <stdint.h>
void *memset_override_0_impl(void *dst, int c, size_t n) {
__CPROVER_precondition(__CPROVER_w_ok(dst, n), "memset destination region writeable");
assert(c == 0);
size_t num_uint64s = n >> 3;
size_t rem = n & 0x7;
assert(rem == 0);
uint64_t *d = (uint64_t *)dst;
for (size_t i = 0; i < num_uint64s; ++i) {
d[i] = 0;
}
return dst;
}
void *memset(void *s, int c, size_t n) {
return memset_override_0_impl(s, c, n);
}
void *__builtin___memset_chk(void *s, int c, size_t n, size_t os) {
(void)os;
return memset_override_0_impl(s, c, n);
}
|
9f6b134acadb6053de8539e374669359d94caa05
|
dfb59af794367d02891de53923aa3b67f7073472
|
/src/php/iterators/php_vector_iterator.h
|
380cc20cf2de7fb867c66aa9aeabb4ce4581ce03
|
[
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
php-ds/ext-ds
|
b31df34b05ad14af53a0d23ba7a7a15437f4004a
|
d42750d69beb684ec3ef7b3da48fba769ce57ffc
|
refs/heads/master
| 2023-08-26T11:28:53.328205
| 2023-07-29T04:04:32
| 2023-07-29T04:04:32
| 50,824,235
| 625
| 40
|
MIT
| 2023-07-29T04:04:33
| 2016-02-01T08:05:07
|
C
|
UTF-8
|
C
| false
| false
| 431
|
h
|
php_vector_iterator.h
|
#ifndef DS_VECTOR_ITERATOR_H
#define DS_VECTOR_ITERATOR_H
#include "php.h"
#include "../../ds/ds_vector.h"
typedef struct php_ds_vector_iterator {
zend_object_iterator intern;
zend_object *object;
ds_vector_t *vector;
zend_long position;
} php_ds_vector_iterator_t;
zend_object_iterator *php_ds_vector_get_iterator(zend_class_entry *ce, zval *obj, int by_ref);
#endif
|
c50bfe846ef3556fc419c7d19c33127daf62f746
|
e3cdfae1dd874479c928dad193b33a4e3b8a623e
|
/src/player_interface.c
|
05b6dae8640b6fd9cb39132a955fc579c81e5bbd
|
[] |
no_license
|
FireEmblemUniverse/fireemblem8u
|
11493bf94844617b33254110ba006316defb3510
|
b9ad9bcafd9d4ecb7fc13cc77a464e2a82ac8338
|
refs/heads/master
| 2023-09-05T23:39:53.791339
| 2023-09-04T17:31:47
| 2023-09-04T17:31:47
| 121,802,075
| 118
| 31
| null | 2023-09-11T13:08:37
| 2018-02-16T21:21:50
|
Assembly
|
UTF-8
|
C
| false
| false
| 43,466
|
c
|
player_interface.c
|
#include "global.h"
#include "fontgrp.h"
#include "bmunit.h"
#include "hardware.h"
#include "bmmap.h"
#include "ctc.h"
#include "bmtrick.h"
#include "icon.h"
#include "uiutils.h"
#include "uichapterstatus.h"
#include "chapterdata.h"
#include "face.h"
#include "bm.h"
#include "prepscreen.h"
#include "bmlib.h"
#include "constants/terrains.h"
struct PlayerInterfaceProc {
PROC_HEADER;
struct Text unk_2c[2];
s8 unk_3c;
s8 unk_3d;
s8 unk_3e;
s8 unk_3f;
s16* unk_40;
s16 unk_44;
s16 unk_46;
s16 unk_48;
u8 unk_4a;
u8 unk_4b;
u8 xCursorPrev;
u8 yCursorPrev;
u8 xCursor;
u8 yCursor;
s8 unk_50;
u8 unk_51;
u8 unk_52;
u8 unk_53;
u8 unk_54;
s8 unk_55;
s8 isRetracting;
s8 quadrant;
int unk_58;
};
struct PlayerInterfaceConfigEntry {
s8 xTerrain, yTerrain;
s8 xMinimug, yMinimug;
s8 xGoal, yGoal;
};
struct PlayerInterfaceConfigEntry sPlayerInterfaceConfigLut[4] = {
{
+1, +1,
-1, +1,
+1, -1,
},
{
-1, +1,
-1, -1,
+1, +1,
},
{
+1, +1,
-1, -1,
+1, -1,
},
{
-1, +1,
-1, -1,
+1, -1,
}
};
s8 gUnknown_08A01848[6] = {
1, 1, 1, 1, 1, 1
};
s8 gUnknown_08A0184E[18] = {
1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1,
3, 3, 3, 3, 3, 3
};
s8 gUnknown_08A01860[6] = {
0, -1, -6, 0, -1, -6
};
s8 gUnknown_08A01866[6] = {
-6, -6, -6, 3, 3, 3
};
u16* gUnknown_08A0186C[6] = {
gUnknown_08A175B4,
gUnknown_08A175B4,
gUnknown_08A175B4,
gUnknown_08A175C8,
gUnknown_08A175DC,
gUnknown_08A175F0
};
u16* gUnknown_08A01884[6] = {
gUnknown_08A1763C,
gUnknown_08A17650,
gUnknown_08A17664,
gUnknown_08A17678,
gUnknown_08A17678,
gUnknown_08A17678
};
s8 sMMBSlideInWidthLut[4] = {
5, 9, 11, 13
};
s8 sMMBSlideOutWidthLut[3] = {
11, 7, 0
};
s8 sTerrainSlideInWidthLut[3] = {
4, 5, 6
};
s8 sTerrainSlideOutWidthLut[6] = {
5, 4, 0, 0, 0, 0
};
void TerrainDisplay_Init(struct PlayerInterfaceProc* proc);
void TerrainDisplay_Loop_OnSideChange(struct PlayerInterfaceProc* proc);
void TerrainDisplay_Loop_SlideIn(struct PlayerInterfaceProc* proc);
void TerrainDisplay_Loop_Display(struct PlayerInterfaceProc* proc);
void TerrainDisplay_Loop_SlideOut(struct PlayerInterfaceProc* proc);
struct ProcCmd CONST_DATA gProcScr_TerrainDisplay[] = {
PROC_NAME("TI"),
PROC_15,
PROC_SLEEP(0),
PROC_CALL(TerrainDisplay_Init),
PROC_LABEL(0),
PROC_WHILE_EXISTS(gProcScr_CamMove),
PROC_REPEAT(TerrainDisplay_Loop_OnSideChange),
PROC_REPEAT(TerrainDisplay_Loop_SlideIn),
PROC_REPEAT(TerrainDisplay_Loop_Display),
PROC_REPEAT(TerrainDisplay_Loop_SlideOut),
PROC_GOTO(0),
PROC_END,
};
void MMB_Init(struct PlayerInterfaceProc* proc);
void MMB_Loop_OnSideChange(struct PlayerInterfaceProc* proc);
void MMB_Loop_SlideIn(struct PlayerInterfaceProc* proc);
void MMB_Loop_Display(struct PlayerInterfaceProc* proc);
void MMB_Loop_SlideOut(struct PlayerInterfaceProc* proc);
void MMB_CheckForUnit(struct PlayerInterfaceProc* proc);
struct ProcCmd CONST_DATA gProcScr_UnitDisplay_MinimugBox[] = {
PROC_NAME("UI1"),
PROC_15,
PROC_SLEEP(0),
PROC_CALL(MMB_Init),
PROC_LABEL(0),
PROC_WHILE_EXISTS(gProcScr_CamMove),
PROC_REPEAT(MMB_Loop_OnSideChange),
PROC_REPEAT(MMB_Loop_SlideIn),
// fallthrough
PROC_LABEL(2),
PROC_REPEAT(MMB_Loop_Display),
// fallthrough
PROC_LABEL(3),
PROC_REPEAT(MMB_Loop_SlideOut),
PROC_GOTO(0),
PROC_LABEL(1),
PROC_CALL(MMB_CheckForUnit),
PROC_GOTO(2),
PROC_END,
};
void BurstDisplay_Init(struct PlayerInterfaceProc* proc);
void BurstDisplay_Loop_Display(struct PlayerInterfaceProc* proc);
struct ProcCmd CONST_DATA gProcScr_UnitDisplay_Burst[] = {
PROC_NAME("UI2"),
PROC_15,
PROC_SLEEP(0),
PROC_CALL(BurstDisplay_Init),
PROC_REPEAT(BurstDisplay_Loop_Display),
PROC_END,
};
void InitPlayerPhaseInterface(void);
struct ProcCmd CONST_DATA gProcScr_SideWindowMaker[] = {
PROC_WHILE(DoesBMXFADEExist),
PROC_CALL(InitPlayerPhaseInterface),
PROC_END,
};
s8 sGoalSlideInWidthLut[5] = {
1, 3, 4, 5, 6
};
s8 sGoalSlideOutWidthLut[3] = {
3, 1, 0
};
void GoalDisplay_Init(struct PlayerInterfaceProc* proc);
void GoalDisplay_Loop_OnSideChange(struct PlayerInterfaceProc* proc);
void GoalDisplay_Loop_SlideIn(struct PlayerInterfaceProc* proc);
void GoalDisplay_Loop_Display(struct PlayerInterfaceProc* proc);
void GoalDisplay_Loop_SlideOut(struct PlayerInterfaceProc* proc);
struct ProcCmd CONST_DATA gProcScr_GoalDisplay[] = {
PROC_NAME("PI"),
PROC_15,
PROC_SLEEP(0),
PROC_CALL(GoalDisplay_Init),
PROC_LABEL(0),
PROC_WHILE_EXISTS(gProcScr_CamMove),
PROC_REPEAT(GoalDisplay_Loop_OnSideChange),
PROC_REPEAT(GoalDisplay_Loop_SlideIn),
PROC_REPEAT(GoalDisplay_Loop_Display),
PROC_REPEAT(GoalDisplay_Loop_SlideOut),
PROC_GOTO(0),
PROC_END,
};
void MenuButtonDisp_Init(struct PlayerInterfaceProc* proc);
s8 IsAnyPlayerSideWindowRetracting(void);
void MenuButtonDisp_UpdateCursorPos(struct PlayerInterfaceProc* proc);
void MenuButtonDisp_Loop_OnSlideIn(struct PlayerInterfaceProc* proc);
void MenuButtonDisp_Loop_Display(struct PlayerInterfaceProc* proc);
void MenuButtonDisp_Loop_OnSlideOut(struct PlayerInterfaceProc* proc);
struct ProcCmd CONST_DATA gProcScr_PrepMap_MenuButtonDisplay[] = {
PROC_15,
PROC_SLEEP(0),
PROC_CALL(MenuButtonDisp_Init),
PROC_LABEL(0),
PROC_WHILE_EXISTS(gProcScr_CamMove),
PROC_WHILE(IsAnyPlayerSideWindowRetracting),
PROC_CALL(MenuButtonDisp_UpdateCursorPos),
PROC_REPEAT(MenuButtonDisp_Loop_OnSlideIn),
PROC_REPEAT(MenuButtonDisp_Loop_Display),
PROC_REPEAT(MenuButtonDisp_Loop_OnSlideOut),
PROC_GOTO(0),
PROC_END,
};
void DrawUnitDisplayHpOrStatus(struct PlayerInterfaceProc*, struct Unit*);
int GetWindowQuadrant(int x, int y) {
if (x < 0) {
if (y < 0) {
return 0;
} else {
return 1;
}
} else if (y < 0) {
return 2;
} else {
return 3;
}
}
int GetCursorQuadrant() {
int cursorX;
int camX;
int cursorY;
int camY;
int x;
int y;
cursorX = (gBmSt.playerCursor.x * 16);
camX = (gBmSt.camera.x - 8);
x = cursorX - camX;
cursorY = (gBmSt.playerCursor.y * 16);
camY = (gBmSt.camera.y - 8);
y = cursorY - camY;
if ((x < 0x79) && (y < 0x51)) {
return 0;
}
if ((x >= 0x79) && (y < 0x51)) {
return 1;
}
if ((x < 0x79) && (y >= 0x51)) {
return 2;
}
if ((x >= 0x79) && (y >= 0x51)) {
return 3;
}
}
void GetHpBarLeftTile(s16* buffer, s16 hp, int tileBase) {
if (hp > 5) {
hp = 5;
}
*buffer = hp + tileBase;
return;
}
void GetHpBarMidTiles(s16* buffer, s16 hp, int tileBase) {
int i;
int hpEighth = hp >> 3;
int eighthTileIdx = hp & 7;
for (i = 0; i < 5; i++) {
int fullTileIdx = tileBase + 14;
int emptyTileIdx = tileBase + 6;
if (i < hpEighth) {
*buffer = fullTileIdx;
} else if (i == hpEighth) {
*buffer = emptyTileIdx + eighthTileIdx;
} else {
*buffer = emptyTileIdx;
}
buffer++;
}
return;
}
void GetHpBarRightTile(s16* buffer, s16 hp, int tileBase) {
int base;
if (hp >= 5) {
hp = 5;
}
if (hp < 0) {
hp = 0;
}
base = tileBase + 15;
*buffer = hp + base;
return;
}
void DrawHpBar(s16* buffer, struct Unit* unit, int tileBase) {
s16 hpCurrent = 50 * GetUnitCurrentHp(unit);
s16 hpPercent = Div(hpCurrent, GetUnitMaxHp(unit));
GetHpBarLeftTile(buffer, hpPercent, tileBase);
GetHpBarMidTiles(buffer + 1, hpPercent - 5, tileBase);
GetHpBarRightTile(buffer + 6, hpPercent - 45, tileBase);
return;
}
void MMB_Loop_SlideIn(struct PlayerInterfaceProc* proc) {
int tmIndex;
int width;
int y = sPlayerInterfaceConfigLut[proc->unk_50].yMinimug < 0 ? 0 : 14;
if (sPlayerInterfaceConfigLut[proc->unk_50].xMinimug < 0) {
tmIndex = TILEMAP_INDEX(0, y);
TileMap_FillRect(gBG0TilemapBuffer + tmIndex, 13, 6, 0);
TileMap_FillRect(gBG1TilemapBuffer + tmIndex, 13, 6, 0);
} else {
tmIndex = TILEMAP_INDEX(0, y);
TileMap_FillRect(gBG0TilemapBuffer + 0x11 + tmIndex, 13, 6, 0);
TileMap_FillRect(gBG1TilemapBuffer + 0x11 + tmIndex, 13, 6, 0);
}
tmIndex = TILEMAP_INDEX(0, y);
BG_EnableSyncByMask(BG0_SYNC_BIT | BG1_SYNC_BIT);
width = sMMBSlideInWidthLut[proc->unk_58];
if (sPlayerInterfaceConfigLut[proc->unk_50].xMinimug < 0) {
TileMap_CopyRect(gBmFrameTmap0 + (13 - width), gBG0TilemapBuffer + tmIndex, width, 6);
TileMap_CopyRect(gUnknown_0200422C + (13 - width), gBG1TilemapBuffer + tmIndex, width, 6);
} else {
TileMap_CopyRect(gBmFrameTmap0, gBG0TilemapBuffer + TILEMAP_INDEX(30 - width, y), width, 6);
TileMap_CopyRect(gUnknown_0200422C, gBG1TilemapBuffer + TILEMAP_INDEX(30 - width, y), width, 6);
}
proc->unk_58++;
if (proc->unk_58 == 4) {
proc->unk_55 = 0;
proc->unk_58 = 0;
Proc_Break(proc);
DrawUnitDisplayHpOrStatus(proc, GetUnit(gBmMapUnit[gBmSt.playerCursor.y][gBmSt.playerCursor.x]));
}
return;
}
void MMB_Loop_SlideOut(struct PlayerInterfaceProc* proc) {
int tmIndex;
int width;
int y = sPlayerInterfaceConfigLut[proc->unk_50].yMinimug < 0 ? 0 : 14;
proc->unk_55 = 1;
if (sPlayerInterfaceConfigLut[proc->unk_50].xMinimug < 0) {
tmIndex = TILEMAP_INDEX(0, y);
TileMap_FillRect(gBG0TilemapBuffer + tmIndex, 13, 6, 0);
TileMap_FillRect(gBG1TilemapBuffer + tmIndex, 13, 6, 0);
} else {
tmIndex = TILEMAP_INDEX(0, y);
TileMap_FillRect(gBG0TilemapBuffer + 0x11 + tmIndex, 13, 6, 0);
TileMap_FillRect(gBG1TilemapBuffer + 0x11 + tmIndex, 13, 6, 0);
}
tmIndex = TILEMAP_INDEX(0, y);
BG_EnableSyncByMask(BG0_SYNC_BIT | BG1_SYNC_BIT);
width = sMMBSlideOutWidthLut[proc->unk_58];
if (sPlayerInterfaceConfigLut[proc->unk_50].xMinimug < 0) {
TileMap_CopyRect(gBmFrameTmap0 + (13 - width), gBG0TilemapBuffer + tmIndex, width, 6);
TileMap_CopyRect(gUnknown_0200422C + (13 - width), gBG1TilemapBuffer + tmIndex, width, 6);
} else {
TileMap_CopyRect(gBmFrameTmap0, gBG0TilemapBuffer + TILEMAP_INDEX(30 - width, y), width, 6);
TileMap_CopyRect(gUnknown_0200422C, gBG1TilemapBuffer + TILEMAP_INDEX(30 - width, y), width, 6);
}
proc->unk_58++;
if (proc->unk_58 == 3) {
proc->isRetracting = 0;
proc->unk_58 = 0;
proc->quadrant = -1;
Proc_Break(proc);
}
return;
}
void TerrainDisplay_Loop_SlideIn(struct PlayerInterfaceProc* proc) {
int width;
if (sPlayerInterfaceConfigLut[proc->unk_50].xTerrain < 0) {
TileMap_FillRect(gBG0TilemapBuffer + 0x1A0, 7, 7, 0);
TileMap_FillRect(gBG1TilemapBuffer + 0x1A0, 7, 7, 0);
} else {
TileMap_FillRect(gBG0TilemapBuffer + 0x1B7, 7, 7, 0);
TileMap_FillRect(gBG1TilemapBuffer + 0x1B7, 7, 7, 0);
}
BG_EnableSyncByMask(BG0_SYNC_BIT | BG1_SYNC_BIT);
width = sTerrainSlideInWidthLut[proc->unk_58] + 1;
if (sPlayerInterfaceConfigLut[proc->unk_50].xTerrain < 0) {
TileMap_CopyRect(gBmFrameTmap0 + (327 - width), gBG0TilemapBuffer + 0x1A0, width, 7);
TileMap_CopyRect(gUnknown_0200422C + (327 - width), gBG1TilemapBuffer + 0x1A0, width, 7);
} else {
TileMap_CopyRect(gUnknown_02003FAC, gBG0TilemapBuffer + (446 - width), width, 7);
TileMap_CopyRect(gUnknown_020044AC, gBG1TilemapBuffer + (446 - width), width, 7);
}
proc->unk_58++;
if (proc->unk_58 == 3) {
proc->unk_58 = 0;
proc->unk_55 = 0;
Proc_Break(proc);
}
return;
}
void TerrainDisplay_Loop_SlideOut(struct PlayerInterfaceProc* proc) {
int width;
proc->unk_55 = 1;
if (sPlayerInterfaceConfigLut[proc->unk_50].xTerrain < 0) {
TileMap_FillRect(gBG0TilemapBuffer + 0x1A0, 7, 7, 0);
TileMap_FillRect(gBG1TilemapBuffer + 0x1A0, 7, 7, 0);
} else {
TileMap_FillRect(gBG0TilemapBuffer + 0x1B7, 7, 7, 0);
TileMap_FillRect(gBG1TilemapBuffer + 0x1B7, 7, 7, 0);
}
BG_EnableSyncByMask(BG0_SYNC_BIT | BG1_SYNC_BIT);
width = sTerrainSlideOutWidthLut[proc->unk_58];
if (sPlayerInterfaceConfigLut[proc->unk_50].xTerrain < 0) {
TileMap_CopyRect(gBmFrameTmap0 + (326 - width), gBG0TilemapBuffer + 0x1A0, width, 7);
TileMap_CopyRect(gUnknown_0200422C + (326 - width), gBG1TilemapBuffer + 0x1A0, width, 7);
} else {
TileMap_CopyRect(gUnknown_02003FAC, gBG0TilemapBuffer + (446 - width), width, 7);
TileMap_CopyRect(gUnknown_020044AC, gBG1TilemapBuffer + (446 - width), width, 7);
}
proc->unk_58++;
if (proc->unk_58 == 3) {
proc->unk_58 = 0;
proc->unk_55 = 0;
proc->isRetracting = 0;
Proc_Break(proc);
}
return;
}
void sub_808C234(struct PlayerInterfaceProc* proc) {
int x, y;
if (sPlayerInterfaceConfigLut[proc->unk_50].xMinimug < 0) {
x = 0;
} else {
x = 18;
}
if (sPlayerInterfaceConfigLut[proc->unk_50].yMinimug < 0) {
y = 0;
} else {
y = 14;
}
TileMap_CopyRect(gBmFrameTmap0, gBG0TilemapBuffer + TILEMAP_INDEX(x, y), 13, 6);
BG_EnableSyncByMask(BG0_SYNC_BIT | BG1_SYNC_BIT);
return;
}
void sub_808C288(struct PlayerInterfaceProc* proc) {
int x;
if (sPlayerInterfaceConfigLut[proc->unk_50].xTerrain < 0) {
x = 0;
} else {
x = 23;
}
TileMap_CopyRect(gUnknown_02003FAC, gBG0TilemapBuffer + 0x1A0 + x, 7, 7);
BG_EnableSyncByMask(BG0_SYNC_BIT | BG1_SYNC_BIT);
return;
}
void GetMinimugFactionPalette(int faction, int palId) {
u16* pal = NULL;
switch (faction) {
case FACTION_BLUE:
pal = gPal_PlayerInterface_Blue;
break;
case FACTION_RED:
pal = gPal_PlayerInterface_Red;
break;
case FACTION_GREEN:
pal = gPal_PlayerInterface_Green;
break;
default:
nullsub_8();
break;
}
ApplyPalette(pal, palId);
return;
}
int sub_808C314() {
if (((gBmSt.playerCursor.x * 16) - gBmSt.camera.x) < 0x70) {
return 1;
} else {
return -1;
}
}
int sub_808C33C() {
if (((gBmSt.playerCursor.x * 16) - gBmSt.camera.x) > 0x70) {
return -1;
} else {
return 1;
}
}
void sub_808C360(struct PlayerInterfaceProc* proc, s16* buffer, struct Unit* unit) {
buffer[0] = 0x2120;
buffer[1] = 0x2121;
buffer[2] = 0;
buffer[3] = 0;
buffer[4] = 0x2121 + 0x1D;
buffer[5] = 0;
buffer[6] = 0;
return;
}
void MMB_DrawStatusText(s16* buffer, struct Unit* unit) {
int offset;
int tileIdx = 0x16F;
if (!unit) {
return;
}
switch (unit->statusIndex) {
case UNIT_STATUS_POISON:
offset = 0;
break;
case UNIT_STATUS_SLEEP:
offset = 0xA0;
break;
case UNIT_STATUS_SILENCED:
offset = 0x140;
break;
case UNIT_STATUS_BERSERK:
offset = 0x1E0;
break;
case UNIT_STATUS_ATTACK:
offset = 0x280;
break;
case UNIT_STATUS_DEFENSE:
offset = 0x320;
break;
case UNIT_STATUS_CRIT:
offset = 0x3C0;
break;
case UNIT_STATUS_AVOID:
offset = 0x460;
break;
case UNIT_STATUS_PETRIFY:
case UNIT_STATUS_13:
offset = 0x500;
break;
case UNIT_STATUS_NONE:
case UNIT_STATUS_SICK:
case UNIT_STATUS_RECOVER:
return;
case UNIT_STATUS_12:
break;
}
CpuFastSet(gGfx_StatusText + offset, (void*)(VRAM + 0x2DE0), 0x28);
buffer[0] = tileIdx++;
buffer[1] = tileIdx++;
buffer[2] = tileIdx++;
buffer[3] = tileIdx++;
buffer[4] = tileIdx++;
buffer[5] = 0;
buffer[6] = unit->statusDuration + 0x1128;
return;
}
void DrawUnitDisplayHpOrStatus(struct PlayerInterfaceProc* proc, struct Unit* unit) {
s16 frameCount = proc->unk_44;
if (unit->statusIndex == UNIT_STATUS_RECOVER) {
frameCount = 0;
}
if ((frameCount & 0x3F) == 0) {
if ((frameCount & 0x40) != 0) {
MMB_DrawStatusText(proc->unk_40, unit);
BG_EnableSyncByMask(BG0_SYNC_BIT);
} else {
if (GetUnitCurrentHp(unit) >= 100) {
StoreNumberStringOrDashesToSmallBuffer(0xFF);
} else {
StoreNumberStringOrDashesToSmallBuffer(GetUnitCurrentHp(unit));
}
proc->unk_51 = gUnknown_02028E44[6] - 0x30;
proc->unk_52 = gUnknown_02028E44[7] - 0x30;
if (GetUnitMaxHp(unit) >= 100) {
StoreNumberStringOrDashesToSmallBuffer(0xFF);
} else {
StoreNumberStringOrDashesToSmallBuffer(GetUnitMaxHp(unit));
}
proc->unk_53 = gUnknown_02028E44[6] - 0x30;
proc->unk_54 = gUnknown_02028E44[7] - 0x30;
sub_808C360(proc, proc->unk_40, unit);
BG_EnableSyncByMask(BG0_SYNC_BIT);
}
}
if ((proc->unk_55 == 0) && ((frameCount & 0x40) == 0 || (unit->statusIndex == UNIT_STATUS_NONE))) {
int x;
int y;
int x2;
x = proc->unk_46 * 8;
x2 = x + 0x11;
y = proc->unk_48 * 8;
if (proc->unk_51 != 0xF0) {
CallARM_PushToSecondaryOAM(x2, y, gObject_8x8, proc->unk_51 + 0x82E0);
}
CallARM_PushToSecondaryOAM(x + 0x18, y, gObject_8x8, proc->unk_52 + 0x82E0);
if (proc->unk_53 != 0xF0) {
CallARM_PushToSecondaryOAM(x + 0x29, y, gObject_8x8, proc->unk_53 + 0x82E0);
}
CallARM_PushToSecondaryOAM(x + 0x30, y, gObject_8x8, proc->unk_54 + 0x82E0);
}
return;
}
void InitMinimugBoxMaybe(struct PlayerInterfaceProc* proc, struct Unit* unit) {
char* str;
int pos;
int faceId;
CpuFastFill(0, gBmFrameTmap0, 0x180);
str = GetStringFromIndex(unit->pCharacterData->nameTextId);
pos = GetStringTextCenteredPos(0x38, str);
ClearText(proc->unk_2c);
Text_SetParams(proc->unk_2c, pos, 5);
Text_DrawString(proc->unk_2c, str);
PutText(proc->unk_2c, gBmFrameTmap0 + 0x25);
faceId = GetUnitMiniPortraitId(unit);
if (unit->state & US_BIT23) {
faceId = faceId + 1;
}
PutFaceChibi(faceId, gBmFrameTmap0 + 0x21, 0xF0, 4, 0);
proc->unk_40 = gBmFrameTmap0 + 0x65;
proc->unk_44 = 0;
if (sPlayerInterfaceConfigLut[proc->unk_50].xMinimug < 0) {
proc->unk_46 = 5;
} else {
proc->unk_46 = 23;
}
if (sPlayerInterfaceConfigLut[proc->unk_50].yMinimug < 0) {
proc->unk_48 = 3;
} else {
proc->unk_48 = 17;
}
DrawUnitDisplayHpOrStatus(proc, unit);
DrawHpBar(gUnknown_02003E36, unit, 0x1140);
CallARM_FillTileRect(gUnknown_0200422C, gTSA_MinimugBox, 0x3000);
GetMinimugFactionPalette(UNIT_FACTION(unit), 3);
return;
}
int sub_808C710(int x, int y) {
int cursorQuadrant = GetCursorQuadrant();
int ret = 1;
if ((y < 6) || ((y < 12) && (sPlayerInterfaceConfigLut[cursorQuadrant].yGoal < 0))) {
ret = 4;
}
if (x < 2) {
ret = ret - 1;
}
if (x > 22) {
ret = ret + 1;
}
return ret;
}
void sub_808C750(struct PlayerInterfaceProc* proc, struct Unit* unit) {
int x;
int y;
int unk;
char* nameStr;
int pos;
int tmp = unit->xPos * 16 - gBmSt.camera.x;
if (tmp < 0) {
tmp += 7;
}
x = tmp >> 3;
tmp = unit->yPos * 16 - gBmSt.camera.y;
if (tmp < 0) {
tmp += 7;
}
y = tmp >> 3;
unk = sub_808C710(x, y);
x = x + gUnknown_08A01860[unk];
y = y + gUnknown_08A01866[unk];
proc->unk_3c = x;
proc->unk_3d = y;
proc->unk_3e = 8;
proc->unk_3f = 5;
nameStr = GetStringFromIndex(unit->pCharacterData->nameTextId);
pos = GetStringTextCenteredPos(0x38, nameStr);
ClearText(proc->unk_2c);
Text_SetParams(proc->unk_2c, pos, 5);
Text_DrawString(proc->unk_2c, nameStr);
PutText(
proc->unk_2c,
gBG0TilemapBuffer + TILEMAP_INDEX(x + gUnknown_08A01848[unk], y + gUnknown_08A0184E[unk])
);
proc->unk_40 = gBG0TilemapBuffer + TILEMAP_INDEX(x + 1, (y + 3));
proc->unk_44 = 0;
proc->unk_46 = x + 1;
proc->unk_48 = y + 3;
DrawUnitDisplayHpOrStatus(proc, unit);
CallARM_FillTileRect(gBG1TilemapBuffer + TILEMAP_INDEX(x, y), gUnknown_08A0186C[unk], 0x3100);
CallARM_FillTileRect(gBG1TilemapBuffer + TILEMAP_INDEX(x, (y + 1)), gUnknown_08A17604, 0x3100);
CallARM_FillTileRect(gBG1TilemapBuffer + TILEMAP_INDEX(x, (y + 4)), gUnknown_08A01884[unk], 0x3100);
BG_EnableSyncByMask(BG0_SYNC_BIT | BG1_SYNC_BIT);
GetMinimugFactionPalette(UNIT_FACTION(unit), 3);
return;
}
void sub_808C8EC(struct PlayerInterfaceProc* proc) {
if (proc->unk_3e == 8 && proc->unk_3f == 5) {
TileMap_FillRect(gBG0TilemapBuffer + TILEMAP_INDEX(proc->unk_3c, proc->unk_3d), proc->unk_3e, proc->unk_3f, 0);
TileMap_FillRect(gBG1TilemapBuffer + TILEMAP_INDEX(proc->unk_3c, proc->unk_3d), proc->unk_3e, proc->unk_3f, 0);
BG_EnableSyncByMask(BG0_SYNC_BIT | BG1_SYNC_BIT);
proc->unk_3e = 0;
proc->unk_3f = 0;
}
return;
}
void DrawTerrainDisplayWindow(struct PlayerInterfaceProc* proc) {
char* str;
int num;
int terrainId = gBmMapTerrain[gBmSt.playerCursor.y][gBmSt.playerCursor.x];
TileMap_FillRect(gUnknown_02003FAC, 14, 7, 0);
TileMap_FillRect(gUnknown_020044AC, 14, 7, 0);
str = GetTerrainName(terrainId);
num = GetStringTextCenteredPos(0x28, str);
ClearText(proc->unk_2c);
Text_SetParams(proc->unk_2c, num, 0);
Text_DrawString(proc->unk_2c, str);
PutText(proc->unk_2c, gUnknown_02003FAC + 0x41);
CallARM_FillTileRect(gUnknown_02003FAC + 0x81, gTSA_TerrainBox_Something, 0x2100);
if (gUnknown_0880B90C[terrainId] > 0) {
StoreNumberStringToSmallBuffer(gUnknown_0880C4BA[terrainId]);
PutDigits(gUnknown_02003FAC + 0x85, gUnknown_02028E44+7, 0x2128, 2);
StoreNumberStringToSmallBuffer(gUnknown_0880C479[terrainId]);
PutDigits(gUnknown_02003FAC + 0xA5, gUnknown_02028E44+7, 0x2128, 2);
}
switch (terrainId) {
case TERRAIN_SNAG:
case TERRAIN_WALL_1B:
CallARM_FillTileRect(gUnknown_020040AE, gTSA_TerrainBox_Destructable, 0x2100);
num = GetObstacleHpAt(gBmSt.playerCursor.x, gBmSt.playerCursor.y);
if (num == 100) {
CallARM_FillTileRect(gUnknown_020040AE + 0x23,gUnknown_08A176B4, 0x100);
} else {
StoreNumberStringToSmallBuffer(num);
PutDigits(gUnknown_020040AE + 0x24, gUnknown_02028E44+7, 0x2128, 2);
}
break;
case TERRAIN_BALLISTA_REGULAR:
case TERRAIN_BALLISTA_LONG:
case TERRAIN_BALLISTA_KILLER:
CallARM_FillTileRect(gUnknown_02003FAC + 0x81, gTSA_TerrainBox_Ballistae, 0x100);
StoreNumberStringToSmallBuffer(GetObstacleHpAt(gBmSt.playerCursor.x, gBmSt.playerCursor.y));
PutDigits(gUnknown_02003FAC + 0x85, gUnknown_02028E44+7, 0x2128, 2);
break;
}
CallARM_FillTileRect(gUnknown_020044EC, gTSA_TerrainBox, 0x1000);
return;
}
void TerrainDisplay_Init(struct PlayerInterfaceProc* proc) {
proc->quadrant = -1;
proc->isRetracting = 0;
proc->unk_58 = 0;
proc->unk_50 = 1;
InitTextDb(proc->unk_2c, 5);
return;
}
void TerrainDisplay_Loop_OnSideChange(struct PlayerInterfaceProc* proc) {
int quadrant;
struct PlayerInterfaceProc* ui1Proc;
struct PlayerInterfaceProc* piProc;
proc->unk_55 = 1;
proc->unk_50 = GetCursorQuadrant();
quadrant = GetWindowQuadrant(sPlayerInterfaceConfigLut[proc->unk_50].xTerrain, sPlayerInterfaceConfigLut[proc->unk_50].yTerrain);
ui1Proc = Proc_Find(gProcScr_UnitDisplay_MinimugBox);
if ((ui1Proc) && (ui1Proc->quadrant > -1) && (ui1Proc->quadrant == quadrant)) {
return;
}
piProc = Proc_Find(gProcScr_GoalDisplay);
// BUG?
if ((ui1Proc) && (piProc->quadrant > -1) && (piProc->quadrant == quadrant)) {
return;
}
proc->quadrant = quadrant;
DrawTerrainDisplayWindow(proc);
proc->xCursor = gBmSt.playerCursor.x;
proc->yCursor = gBmSt.playerCursor.y;
Proc_Break(proc);
return;
}
void TerrainDisplay_Loop_Display(struct PlayerInterfaceProc* proc) {
proc->xCursorPrev = proc->xCursor;
proc->yCursorPrev = proc->yCursor;
proc->xCursor = gBmSt.playerCursor.x;
proc->yCursor = gBmSt.playerCursor.y;
if ((proc->xCursor == proc->xCursorPrev) && (proc->yCursor == proc->yCursorPrev)) {
return;
}
if (!Proc_Find(gProcScr_CamMove)) {
int cursorQuadrant = GetCursorQuadrant();
if ((cursorQuadrant == proc->unk_50) || ((sPlayerInterfaceConfigLut[cursorQuadrant].xTerrain == sPlayerInterfaceConfigLut[proc->unk_50].xTerrain) && (sPlayerInterfaceConfigLut[cursorQuadrant].yTerrain == sPlayerInterfaceConfigLut[proc->unk_50].yTerrain))) {
DrawTerrainDisplayWindow(proc);
sub_808C288(proc);
return;
}
}
proc->isRetracting = 1;
Proc_Break(proc);
return;
}
void MMB_Init(struct PlayerInterfaceProc* proc) {
proc->quadrant = -1;
InitTextDb(proc->unk_2c, 7);
proc->unk_58 = 0;
proc->isRetracting = 0;
return;
}
void MMB_Loop_OnSideChange(struct PlayerInterfaceProc* proc) {
int quadrant;
struct PlayerInterfaceProc* tiProc;
struct Unit* unit = GetUnit(gBmMapUnit[gBmSt.playerCursor.y][gBmSt.playerCursor.x]);
if (!unit) {
return;
}
proc->unk_55 = 1;
proc->unk_50 = GetCursorQuadrant();
quadrant = GetWindowQuadrant(sPlayerInterfaceConfigLut[proc->unk_50].xMinimug, sPlayerInterfaceConfigLut[proc->unk_50].yMinimug);
tiProc = Proc_Find(gProcScr_TerrainDisplay);
if ((tiProc) && (tiProc->quadrant > -1) && (tiProc->quadrant == quadrant)) {
return;
}
proc->quadrant = quadrant;
proc->xCursor = gBmSt.playerCursor.x;
proc->yCursor = gBmSt.playerCursor.y;
InitMinimugBoxMaybe(proc, unit);
Proc_Break(proc);
return;
}
void MMB_Loop_Display(struct PlayerInterfaceProc* proc) {
struct Unit* unit = GetUnit(gBmMapUnit[gBmSt.playerCursor.y][gBmSt.playerCursor.x]);
proc->unk_44++;
DrawUnitDisplayHpOrStatus(proc, unit);
if ((proc->unk_44 & 0x3F) == 0) {
sub_808C234(proc);
}
proc->xCursorPrev = proc->xCursor;
proc->yCursorPrev = proc->yCursor;
proc->xCursor = gBmSt.playerCursor.x;
proc->yCursor = gBmSt.playerCursor.y;
if ((proc->xCursor == proc->xCursorPrev) && (proc->yCursor == proc->yCursorPrev)) {
return;
}
if (unit && !Proc_Find(gProcScr_CamMove)) {
int cursorQuadrant = GetCursorQuadrant();
if ((cursorQuadrant == proc->unk_50) || ((sPlayerInterfaceConfigLut[cursorQuadrant].xMinimug == sPlayerInterfaceConfigLut[proc->unk_50].xMinimug) && (sPlayerInterfaceConfigLut[cursorQuadrant].yMinimug == sPlayerInterfaceConfigLut[proc->unk_50].yMinimug))) {
Proc_Goto(proc, 1);
return;
}
}
proc->isRetracting = 1;
Proc_Break(proc);
return;
}
void MMB_CheckForUnit(struct PlayerInterfaceProc* proc) {
struct Unit* unit = GetUnit(gBmMapUnit[gBmSt.playerCursor.y][gBmSt.playerCursor.x]);
if (!unit) {
Proc_Goto(proc, 3);
} else {
InitMinimugBoxMaybe(proc, unit);
sub_808C234(proc);
}
return;
}
void BurstDisplay_Init(struct PlayerInterfaceProc* proc) {
InitTextDb(proc->unk_2c, 7);
proc->unk_4b = 0;
proc->unk_55 = 0;
proc->unk_58 = 0;
proc->unk_3e = 0;
proc->unk_3f = 0;
proc->isRetracting = 0;
return;
}
void BurstDisplay_Loop_Display(struct PlayerInterfaceProc* proc) {
struct PlayerInterfaceProc* tiProc;
struct PlayerInterfaceProc* piProc;
proc->unk_4a = proc->unk_4b;
proc->unk_4b = gBmMapUnit[gBmSt.playerCursor.y][gBmSt.playerCursor.x];
if ((proc->unk_4a != proc->unk_4b) && (proc->unk_4a != 0)) {
sub_808C8EC(proc);
proc->unk_58 = 0;
return;
}
if ((proc->unk_4b == 0) || (Proc_Find(gProcScr_CamMove) != 0)) {
return;
}
tiProc = Proc_Find(gProcScr_TerrainDisplay);
if ((tiProc) && (tiProc->unk_55 != 0)) {
if (proc->unk_58 < 4) {
proc->unk_58++;
}
return;
}
piProc = Proc_Find(gProcScr_GoalDisplay);
if ((piProc) && (piProc->unk_55 != 0)) {
if (proc->unk_58 < 4) {
proc->unk_58++;
}
return;
}
proc->unk_58++;
if (proc->unk_58 <= 7) {
return;
}
if (proc->unk_58 == 8) {
sub_808C750(proc, GetUnit(proc->unk_4b));
} else {
proc->unk_44++;
if (tiProc) {
proc->unk_55 = tiProc->unk_55;
} else {
proc->unk_55 = 0;
}
DrawUnitDisplayHpOrStatus(proc, GetUnit(proc->unk_4b));
}
return;
}
void InitPlayerPhaseInterface() {
gLCDControlBuffer.dispcnt.win0_on = 0;
gLCDControlBuffer.dispcnt.win1_on = 0;
gLCDControlBuffer.dispcnt.objWin_on = 0;
gLCDControlBuffer.wincnt.wout_enableBg0 = 1;
gLCDControlBuffer.wincnt.wout_enableBg1 = 1;
gLCDControlBuffer.wincnt.wout_enableBg2 = 1;
gLCDControlBuffer.wincnt.wout_enableBg3 = 1;
gLCDControlBuffer.wincnt.wout_enableObj = 1;
gLCDControlBuffer.wincnt.wout_enableBlend = 1;
BG_SetPosition(0, 0, 0);
BG_SetPosition(1, 0, 0);
BG_SetPosition(2, 0, 0);
SetSpecialColorEffectsParameters(1, 0xD, 3, 0);
SetBlendTargetA(0, 1, 0, 0, 0);
SetBlendBackdropA(0);
SetBlendTargetB(0, 0, 1, 1, 1);
Decompress(gGfx_PlayerInterfaceFontTiles, (void*)(VRAM + 0x2000));
Decompress(gGfx_PlayerInterfaceNumbers, (void*)(VRAM + 0x15C00));
CpuFastSet((void*)(VRAM + 0x2EA0), (void*)(VRAM + 0x15D40), 8);
ApplyPalette(gPaletteBuffer, 0x18);
LoadIconPalette(1, 2);
ResetTextFont();
if (gPlaySt.cfgDisableTerrainDisplay == 0) {
Proc_Start(gProcScr_TerrainDisplay, PROC_TREE_3);
}
if (gBmSt.gameStateBits & 0x10) {
Proc_Start(gProcScr_PrepMap_MenuButtonDisplay, PROC_TREE_3);
} else {
if ((gPlaySt.cfgDisableGoalDisplay == 0) && (CheckFlag(0x66) == 0)) {
Proc_Start(gProcScr_GoalDisplay, PROC_TREE_3);
}
}
if (gPlaySt.cfgUnitDisplayType == 0) {
Proc_Start(gProcScr_UnitDisplay_MinimugBox, PROC_TREE_3);
}
if (gPlaySt.cfgUnitDisplayType == 1) {
Proc_Start(gProcScr_UnitDisplay_Burst, PROC_TREE_3);
}
return;
}
void StartPlayerPhaseSideWindows() {
Proc_Start(gProcScr_SideWindowMaker, PROC_TREE_3);
return;
}
void EndPlayerPhaseSideWindows() {
Proc_EndEach(gProcScr_UnitDisplay_MinimugBox);
Proc_EndEach(gProcScr_UnitDisplay_Burst);
Proc_EndEach(gProcScr_TerrainDisplay);
Proc_EndEach(gProcScr_GoalDisplay);
Proc_EndEach(gProcScr_PrepMap_MenuButtonDisplay);
SetDefaultColorEffects();
ClearBg0Bg1();
return;
}
s8 sub_808D190() {
if (((gBmSt.playerCursor.y * 16) - gBmSt.camera.y) > 0x40) {
return 1;
}
return 0;
}
int sub_808D1B4() {
if (sub_808D190() != 0) {
if (sub_808C314() == -1) {
return 2;
}
if (sub_808C314() == 1) {
return 1;
}
} else {
if (sub_808C33C() == -1) {
return 4;
}
if (sub_808C33C() == 1) {
return 3;
}
}
return 0;
}
void sub_808D200(struct PlayerInterfaceProc* proc) {
TileMap_FillRect(gUnknown_020044D4, 11, 9, 0);
TileMap_FillRect(gUnknown_02004054, 11, 9, 0);
if (proc->unk_44 == 0) {
CallARM_FillTileRect(gUnknown_020044D4, gTSA_GoalBox_OneLine, 0x1000);
PutText(proc->unk_2c, gUnknown_02004054 + 0x21);
}
if (proc->unk_44 == 1) {
CallARM_FillTileRect(gUnknown_020044D4, gTSA_GoalBox_TwoLines, 0x1000);
PutText(&proc->unk_2c[0], gUnknown_02004054 + 0x21);
PutText(&proc->unk_2c[1], gUnknown_02004054 + 0x61);
}
return;
}
void GoalDisplay_Init(struct PlayerInterfaceProc* proc) {
int goalTextId;
int goalWindowType;
int turnNumber;
int lastTurnNumber;
char* str;
struct Text* th;
proc->unk_58 = 0;
proc->isRetracting = 0;
proc->unk_50 = 0;
proc->quadrant = -1;
InitText(&proc->unk_2c[0], 8);
InitText(&proc->unk_2c[1], 8);
StartGreenText((struct Proc*)proc);
ClearText(&proc->unk_2c[0]);
ClearText(&proc->unk_2c[1]);
if (GetChapterThing() != 2) {
goalTextId = GetROMChapterStruct(gPlaySt.chapterIndex)->goalWindowTextId;
} else {
goalTextId = 0x19E; // TODO: msgid "Defeat enemy"
}
str = GetStringFromIndex(goalTextId);
Text_InsertDrawString(&proc->unk_2c[0], GetStringTextCenteredPos(0x40, str), 0, str);
if (GetChapterThing() != 2) {
goalWindowType = GetROMChapterStruct(gPlaySt.chapterIndex)->goalWindowDataType;
} else {
goalWindowType = 1;
}
switch (goalWindowType) {
case 0:
case 3:
case 4:
proc->unk_44 = 0;
return;
case 1:
Text_InsertDrawString(&proc->unk_2c[1], 0x10, 0, GetStringFromIndex(0x1C1)); // TODO: msgid "Left"
if (gPlaySt.chapterVisionRange != 0) {
Text_InsertDrawString(&proc->unk_2c[1], 0x28, 1, GetStringFromIndex(0x535));
} else {
Text_InsertDrawNumberOrBlank(&proc->unk_2c[1], 0x30, 2, CountUnitsByFaction(FACTION_RED));
}
break;
case 2:
turnNumber = gPlaySt.chapterTurnNumber;
if (GetChapterThing() != 2) {
if (turnNumber >= (GetROMChapterStruct(gPlaySt.chapterIndex)->goalWindowEndTurnNumber - 1)) {
goto _0808D3DC;
}
} else {
if (turnNumber >= -1) {
_0808D3DC:
str = GetStringFromIndex(0x1C3); // TODO: msgid "Last Turn[.]"
Text_InsertDrawString(&proc->unk_2c[1], GetStringTextCenteredPos(0x40, str), 4, str);
break;
}
}
Text_InsertDrawNumberOrBlank(&proc->unk_2c[1], 0xA, 2, gPlaySt.chapterTurnNumber);
Text_InsertDrawString(&proc->unk_2c[1], 0x12, 0, GetStringFromIndex(0x539)); // TODO: msgid "/[.]"
th = &proc->unk_2c[1];
if (GetChapterThing() != 2) {
lastTurnNumber = GetROMChapterStruct(gPlaySt.chapterIndex)->goalWindowEndTurnNumber - 1;
} else {
lastTurnNumber = -1;
}
Text_InsertDrawNumberOrBlank(th, 0x22, 2, lastTurnNumber);
Text_InsertDrawString(&proc->unk_2c[1], 0x2A, 0, GetStringFromIndex(0x1C2)); // TODO: msgid "Turn"
break;
default:
return;
}
proc->unk_44 = 1;
return;
}
void GoalDisplay_Loop_OnSideChange(struct PlayerInterfaceProc* proc) {
int quadrant;
struct PlayerInterfaceProc* tiProc;
proc->unk_58 = 0;
proc->unk_55 = 1;
proc->unk_50 = GetCursorQuadrant();
quadrant = GetWindowQuadrant(sPlayerInterfaceConfigLut[proc->unk_50].xGoal, sPlayerInterfaceConfigLut[proc->unk_50].yGoal);
tiProc = Proc_Find(gProcScr_TerrainDisplay);
if ((tiProc) && (tiProc->quadrant > -1) && (tiProc->quadrant == quadrant)) {
return;
}
proc->quadrant = quadrant;
sub_808D200(proc);
proc->xCursor = gBmSt.playerCursor.x;
proc->yCursor = gBmSt.playerCursor.y;
proc->xCursorPrev = proc->xCursor;
proc->yCursorPrev = proc->yCursor;
Proc_Break(proc);
return;
}
void sub_808D514(int param_1, int param_2, int param_3) {
int x = sPlayerInterfaceConfigLut[param_1].xGoal;
int y = sPlayerInterfaceConfigLut[param_1].yGoal;
if ((x < 0) && (y < 0)) {
TileMap_FillRect(gBG1TilemapBuffer, 12, 6, 0);
TileMap_FillRect(gBG0TilemapBuffer, 12, 6, 0);
TileMap_CopyRect(gUnknown_02004254 + TILEMAP_INDEX(0, (16 - param_2)), gBG1TilemapBuffer, 12, param_2);
TileMap_CopyRect(gUnknown_02003D54 + TILEMAP_INDEX(0, (18 - param_2)), gBG0TilemapBuffer, 12, param_2);
}
if ((x > 0) && (y < 0)) {
TileMap_FillRect(gBG1TilemapBuffer + 0x13, 12, 6, 0);
TileMap_FillRect(gBG0TilemapBuffer + 0x13, 12, 6, 0);
TileMap_CopyRect(gUnknown_02004254 + TILEMAP_INDEX(0, (16 - param_2)), gBG1TilemapBuffer + 0x13, 12, param_2);
TileMap_CopyRect(gUnknown_02003D54 + TILEMAP_INDEX(0, (18 - param_2)), gBG0TilemapBuffer + 0x13, 12, param_2);
}
if ((x < 0) && (y > 0)) {
TileMap_FillRect(gBG1TilemapBuffer + 0x1C0, 12, 6, 0);
TileMap_FillRect(gBG0TilemapBuffer + 0x1C0, 12, 6, 0);
TileMap_CopyRect(gUnknown_020044D4, gBG1TilemapBuffer + 0x1C0 + 0x20 * (({ (1 - param_3) * 2 + 20; }) - param_2) - 0x1C0, 12, param_2);
TileMap_CopyRect(gUnknown_02004054, gBG0TilemapBuffer + 0x1C0 + 0x20 * (({ (1 - param_3) * 2 + 20; }) - param_2) - 0x1C0, 12, param_2);
}
if ((x > 0) && (y > 0)) {
TileMap_FillRect(gBG1TilemapBuffer + 0x1D3, 12, 6, 0);
TileMap_FillRect(gBG0TilemapBuffer + 0x1D3, 12, 6, 0);
TileMap_CopyRect(gUnknown_020044D4, gBG1TilemapBuffer + 0x1D3 + 0x20 * (({ (1 - param_3) * 2 + 20; }) - param_2) - 0x1C0, 12, param_2);
TileMap_CopyRect(gUnknown_02004054, gBG0TilemapBuffer + 0x1D3 + 0x20 * (({ (1 - param_3) * 2 + 20; }) - param_2) - 0x1C0, 12, param_2);
}
BG_EnableSyncByMask(BG0_SYNC_BIT | BG1_SYNC_BIT);
return;
}
void GoalDisplay_Loop_SlideIn(struct PlayerInterfaceProc* proc) {
int unk = sGoalSlideInWidthLut[proc->unk_58];
sub_808D514(proc->unk_50, unk, proc->unk_44);
proc->unk_58++;
if (proc->unk_58 == 5) {
proc->unk_58 = 0;
proc->unk_55 = 0;
Proc_Break(proc);
}
return;
}
void GoalDisplay_Loop_SlideOut(struct PlayerInterfaceProc* proc) {
int unk;
proc->unk_55 = 1;
unk = sGoalSlideOutWidthLut[proc->unk_58];
sub_808D514(proc->unk_50, unk, proc->unk_44);
proc->unk_58++;
if (proc->unk_58 == 3) {
proc->unk_58 = 0;
proc->unk_55 = 0;
proc->isRetracting = 0;
proc->quadrant = -1;
Proc_Break(proc);
}
return;
}
void sub_808D778() {
return;
}
void __malloc_unlock_0() {
return;
}
void sub_808D780() {
return;
}
void GoalDisplay_Loop_Display(struct PlayerInterfaceProc* proc) {
proc->xCursorPrev = proc->xCursor;
proc->yCursorPrev = proc->yCursor;
proc->xCursor = gBmSt.playerCursor.x;
proc->yCursor = gBmSt.playerCursor.y;
if (proc->xCursor == proc->xCursorPrev && proc->yCursor == proc->yCursorPrev) {
return;
}
if (!Proc_Find(gProcScr_CamMove)) {
int cursorQuadrant = GetCursorQuadrant();
int quadrant = proc->unk_50;
if (cursorQuadrant == quadrant) {
return;
}
if ((sPlayerInterfaceConfigLut[cursorQuadrant].xGoal == sPlayerInterfaceConfigLut[quadrant].xGoal) && (sPlayerInterfaceConfigLut[cursorQuadrant].yGoal == sPlayerInterfaceConfigLut[quadrant].yGoal)) {
return;
}
}
proc->isRetracting = 1;
Proc_Break(proc);
return;
}
s8 IsAnyPlayerSideWindowRetracting() {
struct PlayerInterfaceProc* proc;
proc = Proc_Find(gProcScr_UnitDisplay_MinimugBox);
if ((proc) && (proc->isRetracting != 0)) {
return 1;
}
proc = Proc_Find(gProcScr_TerrainDisplay);
if ((proc) && (proc->isRetracting != 0)) {
return 1;
}
proc = Proc_Find(gProcScr_GoalDisplay);
if ((proc) && (proc->isRetracting != 0)) {
return 1;
}
return 0;
}
void MenuButtonDisp_Init(struct PlayerInterfaceProc* proc) {
Decompress(gUnknown_08A199C8, OBJ_VRAM1 + 0x1000);
proc->unk_46 = 136;
proc->unk_48 = 140;
proc->isRetracting = 0;
return;
}
void sub_808D8A0(struct PlayerInterfaceProc* proc, int param_2, int param_3) {
int x = sPlayerInterfaceConfigLut[param_2].xGoal;
int y = sPlayerInterfaceConfigLut[param_2].yGoal;
if ((x < 0) && (y < 0)) {
proc->unk_46 = 8;
proc->unk_48 = param_3 - 20;
}
if ((x > 0) && (y < 0)) {
proc->unk_46 = 172;
proc->unk_48 = param_3 - 20;
}
if ((x < 0) && (y > 0)) {
proc->unk_46 = 8;
proc->unk_48 = 164 - param_3;
}
if ((x > 0) && (y > 0)) {
proc->unk_46 = 172;
proc->unk_48 = 164 - param_3;
}
return;
}
void sub_808D924(int param_1, int param_2) {
PutSprite(4, param_1 & 0x1FF, param_2 & 0xFF, gObject_32x16, 0x2280);
PutSprite(4, (param_1 + 0x20) & 0x1FF, param_2 & 0xFF, gObject_32x16, 0x2284);
return;
}
void MenuButtonDisp_UpdateCursorPos(struct PlayerInterfaceProc* proc) {
proc->unk_50 = GetCursorQuadrant();
sub_808D8A0(proc, proc->unk_50, proc->unk_58);
proc->unk_58 = 0;
proc->xCursor = gBmSt.playerCursor.x;
proc->yCursor = gBmSt.playerCursor.y;
return;
}
void MenuButtonDisp_Loop_OnSlideIn(struct PlayerInterfaceProc* proc) {
proc->unk_58 += 4;
sub_808D8A0(proc, proc->unk_50, proc->unk_58);
sub_808D924(proc->unk_46, proc->unk_48);
if (proc->unk_58 == 24) {
Proc_Break(proc);
proc->isRetracting = 0;
}
return;
}
void MenuButtonDisp_Loop_Display(struct PlayerInterfaceProc* proc) {
sub_808D924(proc->unk_46, proc->unk_48);
proc->xCursorPrev = proc->xCursor;
proc->yCursorPrev = proc->yCursor;
proc->xCursor = gBmSt.playerCursor.x;
proc->yCursor = gBmSt.playerCursor.y;
if (proc->xCursor == proc->xCursorPrev && proc->yCursor == proc->yCursorPrev) {
return;
}
if (!Proc_Find(gProcScr_CamMove)) {
int cursorQuadrant = GetCursorQuadrant();
int quadrant = proc->unk_50;
if (cursorQuadrant == quadrant) {
return;
}
if ((sPlayerInterfaceConfigLut[cursorQuadrant].xGoal == sPlayerInterfaceConfigLut[quadrant].xGoal) && (sPlayerInterfaceConfigLut[cursorQuadrant].yGoal == sPlayerInterfaceConfigLut[quadrant].yGoal)) {
return;
}
}
proc->isRetracting = 1;
Proc_Break(proc);
return;
}
void MenuButtonDisp_Loop_OnSlideOut(struct PlayerInterfaceProc* proc) {
proc->unk_58 -= 4;
sub_808D8A0(proc, proc->unk_50, proc->unk_58);
sub_808D924(proc->unk_46, proc->unk_48);
if (proc->unk_58 == 0) {
proc->isRetracting = 0;
Proc_Break(proc);
}
return;
}
|
ef1027fad413e506696c69890c12fac2f6d8b59d
|
c6759b857e55991fea3ef0b465dbcee53fa38714
|
/utils/gapy/gen-debug-info-src/ext/longlong.h
|
b25a594620559b2016e3e72ed4377b4a8462edec
|
[
"LicenseRef-scancode-bsd-3-clause-jtag",
"GPL-2.0-only",
"LGPL-2.1-only",
"Apache-2.0"
] |
permissive
|
GreenWaves-Technologies/gap_sdk
|
1b343bba97b7a5ce62a24162bd72eef5cc67e269
|
3fea306d52ee33f923f2423c5a75d9eb1c07e904
|
refs/heads/master
| 2023-09-01T14:38:34.270427
| 2023-08-10T09:04:44
| 2023-08-10T09:04:44
| 133,324,605
| 145
| 96
|
Apache-2.0
| 2023-08-27T19:03:52
| 2018-05-14T07:50:29
|
C
|
UTF-8
|
C
| false
| false
| 60,737
|
h
|
longlong.h
|
/* longlong.h -- definitions for mixed size 32/64 bit arithmetic.
Copyright (C) 1991-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
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.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file into
combinations with other programs, and to distribute those
combinations without any restriction coming from the use of this
file. (The Lesser General Public License restrictions do apply in
other respects; for example, they cover modification of the file,
and distribution when not linked into a combine executable.)
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
<http://www.gnu.org/licenses/>. */
/* You have to define the following before including this file:
UWtype -- An unsigned type, default type for operations (typically a "word")
UHWtype -- An unsigned type, at least half the size of UWtype.
UDWtype -- An unsigned type, at least twice as large a UWtype
W_TYPE_SIZE -- size in bits of UWtype
UQItype -- Unsigned 8 bit type.
SItype, USItype -- Signed and unsigned 32 bit types.
DItype, UDItype -- Signed and unsigned 64 bit types.
On a 32 bit machine UWtype should typically be USItype;
on a 64 bit machine, UWtype should typically be UDItype. */
#define __BITS4 (W_TYPE_SIZE / 4)
#define __ll_B ((UWtype) 1 << (W_TYPE_SIZE / 2))
#define __ll_lowpart(t) ((UWtype) (t) & (__ll_B - 1))
#define __ll_highpart(t) ((UWtype) (t) >> (W_TYPE_SIZE / 2))
#ifndef W_TYPE_SIZE
#define W_TYPE_SIZE 32
#define UWtype USItype
#define UHWtype USItype
#define UDWtype UDItype
#endif
/* Used in glibc only. */
#ifndef attribute_hidden
#define attribute_hidden
#endif
extern const UQItype __clz_tab[256] attribute_hidden;
/* Define auxiliary asm macros.
1) umul_ppmm(high_prod, low_prod, multiplier, multiplicand) multiplies two
UWtype integers MULTIPLIER and MULTIPLICAND, and generates a two UWtype
word product in HIGH_PROD and LOW_PROD.
2) __umulsidi3(a,b) multiplies two UWtype integers A and B, and returns a
UDWtype product. This is just a variant of umul_ppmm.
3) udiv_qrnnd(quotient, remainder, high_numerator, low_numerator,
denominator) divides a UDWtype, composed by the UWtype integers
HIGH_NUMERATOR and LOW_NUMERATOR, by DENOMINATOR and places the quotient
in QUOTIENT and the remainder in REMAINDER. HIGH_NUMERATOR must be less
than DENOMINATOR for correct operation. If, in addition, the most
significant bit of DENOMINATOR must be 1, then the pre-processor symbol
UDIV_NEEDS_NORMALIZATION is defined to 1.
4) sdiv_qrnnd(quotient, remainder, high_numerator, low_numerator,
denominator). Like udiv_qrnnd but the numbers are signed. The quotient
is rounded towards 0.
5) count_leading_zeros(count, x) counts the number of zero-bits from the
msb to the first nonzero bit in the UWtype X. This is the number of
steps X needs to be shifted left to set the msb. Undefined for X == 0,
unless the symbol COUNT_LEADING_ZEROS_0 is defined to some value.
6) count_trailing_zeros(count, x) like count_leading_zeros, but counts
from the least significant end.
7) add_ssaaaa(high_sum, low_sum, high_addend_1, low_addend_1,
high_addend_2, low_addend_2) adds two UWtype integers, composed by
HIGH_ADDEND_1 and LOW_ADDEND_1, and HIGH_ADDEND_2 and LOW_ADDEND_2
respectively. The result is placed in HIGH_SUM and LOW_SUM. Overflow
(i.e. carry out) is not stored anywhere, and is lost.
8) sub_ddmmss(high_difference, low_difference, high_minuend, low_minuend,
high_subtrahend, low_subtrahend) subtracts two two-word UWtype integers,
composed by HIGH_MINUEND_1 and LOW_MINUEND_1, and HIGH_SUBTRAHEND_2 and
LOW_SUBTRAHEND_2 respectively. The result is placed in HIGH_DIFFERENCE
and LOW_DIFFERENCE. Overflow (i.e. carry out) is not stored anywhere,
and is lost.
If any of these macros are left undefined for a particular CPU,
C macros are used. */
/* The CPUs come in alphabetical order below.
Please add support for more CPUs here, or improve the current support
for the CPUs below!
(E.g. WE32100, IBM360.) */
#if defined (__GNUC__) && !defined (NO_ASM)
/* We sometimes need to clobber "cc" with gcc2, but that would not be
understood by gcc1. Use cpp to avoid major code duplication. */
#if __GNUC__ < 2
#define __CLOBBER_CC
#define __AND_CLOBBER_CC
#else /* __GNUC__ >= 2 */
#define __CLOBBER_CC : "cc"
#define __AND_CLOBBER_CC , "cc"
#endif /* __GNUC__ < 2 */
#if defined (__aarch64__)
#if W_TYPE_SIZE == 32
#define count_leading_zeros(COUNT, X) ((COUNT) = __builtin_clz (X))
#define count_trailing_zeros(COUNT, X) ((COUNT) = __builtin_ctz (X))
#define COUNT_LEADING_ZEROS_0 32
#endif /* W_TYPE_SIZE == 32 */
#if W_TYPE_SIZE == 64
#define count_leading_zeros(COUNT, X) ((COUNT) = __builtin_clzll (X))
#define count_trailing_zeros(COUNT, X) ((COUNT) = __builtin_ctzll (X))
#define COUNT_LEADING_ZEROS_0 64
#endif /* W_TYPE_SIZE == 64 */
#endif /* __aarch64__ */
#if defined (__alpha) && W_TYPE_SIZE == 64
/* There is a bug in g++ before version 5 that
errors on __builtin_alpha_umulh. */
#if !defined(__cplusplus) || __GNUC__ >= 5
#define umul_ppmm(ph, pl, m0, m1) \
do { \
UDItype __m0 = (m0), __m1 = (m1); \
(ph) = __builtin_alpha_umulh (__m0, __m1); \
(pl) = __m0 * __m1; \
} while (0)
#define UMUL_TIME 46
#endif /* !c++ */
#ifndef LONGLONG_STANDALONE
#define udiv_qrnnd(q, r, n1, n0, d) \
do { UDItype __r; \
(q) = __udiv_qrnnd (&__r, (n1), (n0), (d)); \
(r) = __r; \
} while (0)
extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
#define UDIV_TIME 220
#endif /* LONGLONG_STANDALONE */
#ifdef __alpha_cix__
#define count_leading_zeros(COUNT,X) ((COUNT) = __builtin_clzl (X))
#define count_trailing_zeros(COUNT,X) ((COUNT) = __builtin_ctzl (X))
#define COUNT_LEADING_ZEROS_0 64
#else
#define count_leading_zeros(COUNT,X) \
do { \
UDItype __xr = (X), __t, __a; \
__t = __builtin_alpha_cmpbge (0, __xr); \
__a = __clz_tab[__t ^ 0xff] - 1; \
__t = __builtin_alpha_extbl (__xr, __a); \
(COUNT) = 64 - (__clz_tab[__t] + __a*8); \
} while (0)
#define count_trailing_zeros(COUNT,X) \
do { \
UDItype __xr = (X), __t, __a; \
__t = __builtin_alpha_cmpbge (0, __xr); \
__t = ~__t & -~__t; \
__a = ((__t & 0xCC) != 0) * 2; \
__a += ((__t & 0xF0) != 0) * 4; \
__a += ((__t & 0xAA) != 0); \
__t = __builtin_alpha_extbl (__xr, __a); \
__a <<= 3; \
__t &= -__t; \
__a += ((__t & 0xCC) != 0) * 2; \
__a += ((__t & 0xF0) != 0) * 4; \
__a += ((__t & 0xAA) != 0); \
(COUNT) = __a; \
} while (0)
#endif /* __alpha_cix__ */
#endif /* __alpha */
#if defined (__arc__) && W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("add.f %1, %4, %5\n\tadc %0, %2, %3" \
: "=r" ((USItype) (sh)), \
"=&r" ((USItype) (sl)) \
: "%r" ((USItype) (ah)), \
"rICal" ((USItype) (bh)), \
"%r" ((USItype) (al)), \
"rICal" ((USItype) (bl)))
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("sub.f %1, %4, %5\n\tsbc %0, %2, %3" \
: "=r" ((USItype) (sh)), \
"=&r" ((USItype) (sl)) \
: "r" ((USItype) (ah)), \
"rICal" ((USItype) (bh)), \
"r" ((USItype) (al)), \
"rICal" ((USItype) (bl)))
#define __umulsidi3(u,v) ((UDItype)(USItype)u*(USItype)v)
#ifdef __ARC_NORM__
#define count_leading_zeros(count, x) \
do \
{ \
SItype c_; \
\
__asm__ ("norm.f\t%0,%1\n\tmov.mi\t%0,-1" : "=r" (c_) : "r" (x) : "cc");\
(count) = c_ + 1; \
} \
while (0)
#define COUNT_LEADING_ZEROS_0 32
#endif /* __ARC_NORM__ */
#endif /* __arc__ */
#if defined (__arm__) && (defined (__thumb2__) || !defined (__thumb__)) \
&& W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("adds %1, %4, %5\n\tadc %0, %2, %3" \
: "=r" ((USItype) (sh)), \
"=&r" ((USItype) (sl)) \
: "%r" ((USItype) (ah)), \
"rI" ((USItype) (bh)), \
"%r" ((USItype) (al)), \
"rI" ((USItype) (bl)) __CLOBBER_CC)
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("subs %1, %4, %5\n\tsbc %0, %2, %3" \
: "=r" ((USItype) (sh)), \
"=&r" ((USItype) (sl)) \
: "r" ((USItype) (ah)), \
"rI" ((USItype) (bh)), \
"r" ((USItype) (al)), \
"rI" ((USItype) (bl)) __CLOBBER_CC)
# if defined(__ARM_ARCH_2__) || defined(__ARM_ARCH_2A__) \
|| defined(__ARM_ARCH_3__)
# define umul_ppmm(xh, xl, a, b) \
do { \
register USItype __t0, __t1, __t2; \
__asm__ ("%@ Inlined umul_ppmm\n" \
" mov %2, %5, lsr #16\n" \
" mov %0, %6, lsr #16\n" \
" bic %3, %5, %2, lsl #16\n" \
" bic %4, %6, %0, lsl #16\n" \
" mul %1, %3, %4\n" \
" mul %4, %2, %4\n" \
" mul %3, %0, %3\n" \
" mul %0, %2, %0\n" \
" adds %3, %4, %3\n" \
" addcs %0, %0, #65536\n" \
" adds %1, %1, %3, lsl #16\n" \
" adc %0, %0, %3, lsr #16" \
: "=&r" ((USItype) (xh)), \
"=r" ((USItype) (xl)), \
"=&r" (__t0), "=&r" (__t1), "=r" (__t2) \
: "r" ((USItype) (a)), \
"r" ((USItype) (b)) __CLOBBER_CC ); \
} while (0)
# define UMUL_TIME 20
# else
# define umul_ppmm(xh, xl, a, b) \
do { \
/* Generate umull, under compiler control. */ \
register UDItype __t0 = (UDItype)(USItype)(a) * (USItype)(b); \
(xl) = (USItype)__t0; \
(xh) = (USItype)(__t0 >> 32); \
} while (0)
# define UMUL_TIME 3
# endif
# define UDIV_TIME 100
#endif /* __arm__ */
#if defined(__arm__)
/* Let gcc decide how best to implement count_leading_zeros. */
#define count_leading_zeros(COUNT,X) ((COUNT) = __builtin_clz (X))
#define count_trailing_zeros(COUNT,X) ((COUNT) = __builtin_ctz (X))
#define COUNT_LEADING_ZEROS_0 32
#endif
#if defined (__AVR__)
#if W_TYPE_SIZE == 16
#define count_leading_zeros(COUNT,X) ((COUNT) = __builtin_clz (X))
#define count_trailing_zeros(COUNT,X) ((COUNT) = __builtin_ctz (X))
#define COUNT_LEADING_ZEROS_0 16
#endif /* W_TYPE_SIZE == 16 */
#if W_TYPE_SIZE == 32
#define count_leading_zeros(COUNT,X) ((COUNT) = __builtin_clzl (X))
#define count_trailing_zeros(COUNT,X) ((COUNT) = __builtin_ctzl (X))
#define COUNT_LEADING_ZEROS_0 32
#endif /* W_TYPE_SIZE == 32 */
#if W_TYPE_SIZE == 64
#define count_leading_zeros(COUNT,X) ((COUNT) = __builtin_clzll (X))
#define count_trailing_zeros(COUNT,X) ((COUNT) = __builtin_ctzll (X))
#define COUNT_LEADING_ZEROS_0 64
#endif /* W_TYPE_SIZE == 64 */
#endif /* defined (__AVR__) */
#if defined (__CRIS__)
#if __CRIS_arch_version >= 3
#define count_leading_zeros(COUNT, X) ((COUNT) = __builtin_clz (X))
#define COUNT_LEADING_ZEROS_0 32
#endif /* __CRIS_arch_version >= 3 */
#if __CRIS_arch_version >= 8
#define count_trailing_zeros(COUNT, X) ((COUNT) = __builtin_ctz (X))
#endif /* __CRIS_arch_version >= 8 */
#if __CRIS_arch_version >= 10
#define __umulsidi3(u,v) ((UDItype)(USItype) (u) * (UDItype)(USItype) (v))
#else
#define __umulsidi3 __umulsidi3
extern UDItype __umulsidi3 (USItype, USItype);
#endif /* __CRIS_arch_version >= 10 */
#define umul_ppmm(w1, w0, u, v) \
do { \
UDItype __x = __umulsidi3 (u, v); \
(w0) = (USItype) (__x); \
(w1) = (USItype) (__x >> 32); \
} while (0)
/* FIXME: defining add_ssaaaa and sub_ddmmss should be advantageous for
DFmode ("double" intrinsics, avoiding two of the three insns handling
carry), but defining them as open-code C composing and doing the
operation in DImode (UDImode) shows that the DImode needs work:
register pressure from requiring neighboring registers and the
traffic to and from them come to dominate, in the 4.7 series. */
#endif /* defined (__CRIS__) */
#if defined (__hppa) && W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("add %4,%5,%1\n\taddc %2,%3,%0" \
: "=r" ((USItype) (sh)), \
"=&r" ((USItype) (sl)) \
: "%rM" ((USItype) (ah)), \
"rM" ((USItype) (bh)), \
"%rM" ((USItype) (al)), \
"rM" ((USItype) (bl)))
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("sub %4,%5,%1\n\tsubb %2,%3,%0" \
: "=r" ((USItype) (sh)), \
"=&r" ((USItype) (sl)) \
: "rM" ((USItype) (ah)), \
"rM" ((USItype) (bh)), \
"rM" ((USItype) (al)), \
"rM" ((USItype) (bl)))
#if defined (_PA_RISC1_1)
#define umul_ppmm(w1, w0, u, v) \
do { \
union \
{ \
UDItype __f; \
struct {USItype __w1, __w0;} __w1w0; \
} __t; \
__asm__ ("xmpyu %1,%2,%0" \
: "=x" (__t.__f) \
: "x" ((USItype) (u)), \
"x" ((USItype) (v))); \
(w1) = __t.__w1w0.__w1; \
(w0) = __t.__w1w0.__w0; \
} while (0)
#define UMUL_TIME 8
#else
#define UMUL_TIME 30
#endif
#define UDIV_TIME 40
#define count_leading_zeros(count, x) \
do { \
USItype __tmp; \
__asm__ ( \
"ldi 1,%0\n" \
" extru,= %1,15,16,%%r0 ; Bits 31..16 zero?\n" \
" extru,tr %1,15,16,%1 ; No. Shift down, skip add.\n"\
" ldo 16(%0),%0 ; Yes. Perform add.\n" \
" extru,= %1,23,8,%%r0 ; Bits 15..8 zero?\n" \
" extru,tr %1,23,8,%1 ; No. Shift down, skip add.\n"\
" ldo 8(%0),%0 ; Yes. Perform add.\n" \
" extru,= %1,27,4,%%r0 ; Bits 7..4 zero?\n" \
" extru,tr %1,27,4,%1 ; No. Shift down, skip add.\n"\
" ldo 4(%0),%0 ; Yes. Perform add.\n" \
" extru,= %1,29,2,%%r0 ; Bits 3..2 zero?\n" \
" extru,tr %1,29,2,%1 ; No. Shift down, skip add.\n"\
" ldo 2(%0),%0 ; Yes. Perform add.\n" \
" extru %1,30,1,%1 ; Extract bit 1.\n" \
" sub %0,%1,%0 ; Subtract it.\n" \
: "=r" (count), "=r" (__tmp) : "1" (x)); \
} while (0)
#endif
#if (defined (__i370__) || defined (__s390__) || defined (__mvs__)) && W_TYPE_SIZE == 32
#if !defined (__zarch__)
#define smul_ppmm(xh, xl, m0, m1) \
do { \
union {DItype __ll; \
struct {USItype __h, __l;} __i; \
} __x; \
__asm__ ("lr %N0,%1\n\tmr %0,%2" \
: "=&r" (__x.__ll) \
: "r" (m0), "r" (m1)); \
(xh) = __x.__i.__h; (xl) = __x.__i.__l; \
} while (0)
#define sdiv_qrnnd(q, r, n1, n0, d) \
do { \
union {DItype __ll; \
struct {USItype __h, __l;} __i; \
} __x; \
__x.__i.__h = n1; __x.__i.__l = n0; \
__asm__ ("dr %0,%2" \
: "=r" (__x.__ll) \
: "0" (__x.__ll), "r" (d)); \
(q) = __x.__i.__l; (r) = __x.__i.__h; \
} while (0)
#else
#define smul_ppmm(xh, xl, m0, m1) \
do { \
register SItype __r0 __asm__ ("0"); \
register SItype __r1 __asm__ ("1") = (m0); \
\
__asm__ ("mr\t%%r0,%3" \
: "=r" (__r0), "=r" (__r1) \
: "r" (__r1), "r" (m1)); \
(xh) = __r0; (xl) = __r1; \
} while (0)
#define sdiv_qrnnd(q, r, n1, n0, d) \
do { \
register SItype __r0 __asm__ ("0") = (n1); \
register SItype __r1 __asm__ ("1") = (n0); \
\
__asm__ ("dr\t%%r0,%4" \
: "=r" (__r0), "=r" (__r1) \
: "r" (__r0), "r" (__r1), "r" (d)); \
(q) = __r1; (r) = __r0; \
} while (0)
#endif /* __zarch__ */
#endif
#if (defined (__i386__) || defined (__i486__)) && W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("add{l} {%5,%1|%1,%5}\n\tadc{l} {%3,%0|%0,%3}" \
: "=r" ((USItype) (sh)), \
"=&r" ((USItype) (sl)) \
: "%0" ((USItype) (ah)), \
"g" ((USItype) (bh)), \
"%1" ((USItype) (al)), \
"g" ((USItype) (bl)))
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("sub{l} {%5,%1|%1,%5}\n\tsbb{l} {%3,%0|%0,%3}" \
: "=r" ((USItype) (sh)), \
"=&r" ((USItype) (sl)) \
: "0" ((USItype) (ah)), \
"g" ((USItype) (bh)), \
"1" ((USItype) (al)), \
"g" ((USItype) (bl)))
#define umul_ppmm(w1, w0, u, v) \
__asm__ ("mul{l} %3" \
: "=a" ((USItype) (w0)), \
"=d" ((USItype) (w1)) \
: "%0" ((USItype) (u)), \
"rm" ((USItype) (v)))
#define udiv_qrnnd(q, r, n1, n0, dv) \
__asm__ ("div{l} %4" \
: "=a" ((USItype) (q)), \
"=d" ((USItype) (r)) \
: "0" ((USItype) (n0)), \
"1" ((USItype) (n1)), \
"rm" ((USItype) (dv)))
#define count_leading_zeros(count, x) ((count) = __builtin_clz (x))
#define count_trailing_zeros(count, x) ((count) = __builtin_ctz (x))
#define UMUL_TIME 40
#define UDIV_TIME 40
#endif /* 80x86 */
#if defined (__x86_64__) && W_TYPE_SIZE == 64
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("add{q} {%5,%1|%1,%5}\n\tadc{q} {%3,%0|%0,%3}" \
: "=r" ((UDItype) (sh)), \
"=&r" ((UDItype) (sl)) \
: "%0" ((UDItype) (ah)), \
"rme" ((UDItype) (bh)), \
"%1" ((UDItype) (al)), \
"rme" ((UDItype) (bl)))
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("sub{q} {%5,%1|%1,%5}\n\tsbb{q} {%3,%0|%0,%3}" \
: "=r" ((UDItype) (sh)), \
"=&r" ((UDItype) (sl)) \
: "0" ((UDItype) (ah)), \
"rme" ((UDItype) (bh)), \
"1" ((UDItype) (al)), \
"rme" ((UDItype) (bl)))
#define umul_ppmm(w1, w0, u, v) \
__asm__ ("mul{q} %3" \
: "=a" ((UDItype) (w0)), \
"=d" ((UDItype) (w1)) \
: "%0" ((UDItype) (u)), \
"rm" ((UDItype) (v)))
#define udiv_qrnnd(q, r, n1, n0, dv) \
__asm__ ("div{q} %4" \
: "=a" ((UDItype) (q)), \
"=d" ((UDItype) (r)) \
: "0" ((UDItype) (n0)), \
"1" ((UDItype) (n1)), \
"rm" ((UDItype) (dv)))
#define count_leading_zeros(count, x) ((count) = __builtin_clzll (x))
#define count_trailing_zeros(count, x) ((count) = __builtin_ctzll (x))
#define UMUL_TIME 40
#define UDIV_TIME 40
#endif /* x86_64 */
#if defined (__i960__) && W_TYPE_SIZE == 32
#define umul_ppmm(w1, w0, u, v) \
({union {UDItype __ll; \
struct {USItype __l, __h;} __i; \
} __xx; \
__asm__ ("emul %2,%1,%0" \
: "=d" (__xx.__ll) \
: "%dI" ((USItype) (u)), \
"dI" ((USItype) (v))); \
(w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
#define __umulsidi3(u, v) \
({UDItype __w; \
__asm__ ("emul %2,%1,%0" \
: "=d" (__w) \
: "%dI" ((USItype) (u)), \
"dI" ((USItype) (v))); \
__w; })
#endif /* __i960__ */
#if defined (__ia64) && W_TYPE_SIZE == 64
/* This form encourages gcc (pre-release 3.4 at least) to emit predicated
"sub r=r,r" and "sub r=r,r,1", giving a 2 cycle latency. The generic
code using "al<bl" arithmetically comes out making an actual 0 or 1 in a
register, which takes an extra cycle. */
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
do { \
UWtype __x; \
__x = (al) - (bl); \
if ((al) < (bl)) \
(sh) = (ah) - (bh) - 1; \
else \
(sh) = (ah) - (bh); \
(sl) = __x; \
} while (0)
/* Do both product parts in assembly, since that gives better code with
all gcc versions. Some callers will just use the upper part, and in
that situation we waste an instruction, but not any cycles. */
#define umul_ppmm(ph, pl, m0, m1) \
__asm__ ("xma.hu %0 = %2, %3, f0\n\txma.l %1 = %2, %3, f0" \
: "=&f" (ph), "=f" (pl) \
: "f" (m0), "f" (m1))
#define count_leading_zeros(count, x) \
do { \
UWtype _x = (x), _y, _a, _c; \
__asm__ ("mux1 %0 = %1, @rev" : "=r" (_y) : "r" (_x)); \
__asm__ ("czx1.l %0 = %1" : "=r" (_a) : "r" (-_y | _y)); \
_c = (_a - 1) << 3; \
_x >>= _c; \
if (_x >= 1 << 4) \
_x >>= 4, _c += 4; \
if (_x >= 1 << 2) \
_x >>= 2, _c += 2; \
_c += _x >> 1; \
(count) = W_TYPE_SIZE - 1 - _c; \
} while (0)
/* similar to what gcc does for __builtin_ffs, but 0 based rather than 1
based, and we don't need a special case for x==0 here */
#define count_trailing_zeros(count, x) \
do { \
UWtype __ctz_x = (x); \
__asm__ ("popcnt %0 = %1" \
: "=r" (count) \
: "r" ((__ctz_x-1) & ~__ctz_x)); \
} while (0)
#define UMUL_TIME 14
#endif
#if defined (__M32R__) && W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
/* The cmp clears the condition bit. */ \
__asm__ ("cmp %0,%0\n\taddx %1,%5\n\taddx %0,%3" \
: "=r" ((USItype) (sh)), \
"=&r" ((USItype) (sl)) \
: "0" ((USItype) (ah)), \
"r" ((USItype) (bh)), \
"1" ((USItype) (al)), \
"r" ((USItype) (bl)) \
: "cbit")
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
/* The cmp clears the condition bit. */ \
__asm__ ("cmp %0,%0\n\tsubx %1,%5\n\tsubx %0,%3" \
: "=r" ((USItype) (sh)), \
"=&r" ((USItype) (sl)) \
: "0" ((USItype) (ah)), \
"r" ((USItype) (bh)), \
"1" ((USItype) (al)), \
"r" ((USItype) (bl)) \
: "cbit")
#endif /* __M32R__ */
#if defined (__mc68000__) && W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("add%.l %5,%1\n\taddx%.l %3,%0" \
: "=d" ((USItype) (sh)), \
"=&d" ((USItype) (sl)) \
: "%0" ((USItype) (ah)), \
"d" ((USItype) (bh)), \
"%1" ((USItype) (al)), \
"g" ((USItype) (bl)))
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("sub%.l %5,%1\n\tsubx%.l %3,%0" \
: "=d" ((USItype) (sh)), \
"=&d" ((USItype) (sl)) \
: "0" ((USItype) (ah)), \
"d" ((USItype) (bh)), \
"1" ((USItype) (al)), \
"g" ((USItype) (bl)))
/* The '020, '030, '040, '060 and CPU32 have 32x32->64 and 64/32->32q-32r. */
#if (defined (__mc68020__) && !defined (__mc68060__))
#define umul_ppmm(w1, w0, u, v) \
__asm__ ("mulu%.l %3,%1:%0" \
: "=d" ((USItype) (w0)), \
"=d" ((USItype) (w1)) \
: "%0" ((USItype) (u)), \
"dmi" ((USItype) (v)))
#define UMUL_TIME 45
#define udiv_qrnnd(q, r, n1, n0, d) \
__asm__ ("divu%.l %4,%1:%0" \
: "=d" ((USItype) (q)), \
"=d" ((USItype) (r)) \
: "0" ((USItype) (n0)), \
"1" ((USItype) (n1)), \
"dmi" ((USItype) (d)))
#define UDIV_TIME 90
#define sdiv_qrnnd(q, r, n1, n0, d) \
__asm__ ("divs%.l %4,%1:%0" \
: "=d" ((USItype) (q)), \
"=d" ((USItype) (r)) \
: "0" ((USItype) (n0)), \
"1" ((USItype) (n1)), \
"dmi" ((USItype) (d)))
#elif defined (__mcoldfire__) /* not mc68020 */
#define umul_ppmm(xh, xl, a, b) \
__asm__ ("| Inlined umul_ppmm\n" \
" move%.l %2,%/d0\n" \
" move%.l %3,%/d1\n" \
" move%.l %/d0,%/d2\n" \
" swap %/d0\n" \
" move%.l %/d1,%/d3\n" \
" swap %/d1\n" \
" move%.w %/d2,%/d4\n" \
" mulu %/d3,%/d4\n" \
" mulu %/d1,%/d2\n" \
" mulu %/d0,%/d3\n" \
" mulu %/d0,%/d1\n" \
" move%.l %/d4,%/d0\n" \
" clr%.w %/d0\n" \
" swap %/d0\n" \
" add%.l %/d0,%/d2\n" \
" add%.l %/d3,%/d2\n" \
" jcc 1f\n" \
" add%.l %#65536,%/d1\n" \
"1: swap %/d2\n" \
" moveq %#0,%/d0\n" \
" move%.w %/d2,%/d0\n" \
" move%.w %/d4,%/d2\n" \
" move%.l %/d2,%1\n" \
" add%.l %/d1,%/d0\n" \
" move%.l %/d0,%0" \
: "=g" ((USItype) (xh)), \
"=g" ((USItype) (xl)) \
: "g" ((USItype) (a)), \
"g" ((USItype) (b)) \
: "d0", "d1", "d2", "d3", "d4")
#define UMUL_TIME 100
#define UDIV_TIME 400
#else /* not ColdFire */
/* %/ inserts REGISTER_PREFIX, %# inserts IMMEDIATE_PREFIX. */
#define umul_ppmm(xh, xl, a, b) \
__asm__ ("| Inlined umul_ppmm\n" \
" move%.l %2,%/d0\n" \
" move%.l %3,%/d1\n" \
" move%.l %/d0,%/d2\n" \
" swap %/d0\n" \
" move%.l %/d1,%/d3\n" \
" swap %/d1\n" \
" move%.w %/d2,%/d4\n" \
" mulu %/d3,%/d4\n" \
" mulu %/d1,%/d2\n" \
" mulu %/d0,%/d3\n" \
" mulu %/d0,%/d1\n" \
" move%.l %/d4,%/d0\n" \
" eor%.w %/d0,%/d0\n" \
" swap %/d0\n" \
" add%.l %/d0,%/d2\n" \
" add%.l %/d3,%/d2\n" \
" jcc 1f\n" \
" add%.l %#65536,%/d1\n" \
"1: swap %/d2\n" \
" moveq %#0,%/d0\n" \
" move%.w %/d2,%/d0\n" \
" move%.w %/d4,%/d2\n" \
" move%.l %/d2,%1\n" \
" add%.l %/d1,%/d0\n" \
" move%.l %/d0,%0" \
: "=g" ((USItype) (xh)), \
"=g" ((USItype) (xl)) \
: "g" ((USItype) (a)), \
"g" ((USItype) (b)) \
: "d0", "d1", "d2", "d3", "d4")
#define UMUL_TIME 100
#define UDIV_TIME 400
#endif /* not mc68020 */
/* The '020, '030, '040 and '060 have bitfield insns.
cpu32 disguises as a 68020, but lacks them. */
#if defined (__mc68020__) && !defined (__mcpu32__)
#define count_leading_zeros(count, x) \
__asm__ ("bfffo %1{%b2:%b2},%0" \
: "=d" ((USItype) (count)) \
: "od" ((USItype) (x)), "n" (0))
/* Some ColdFire architectures have a ff1 instruction supported via
__builtin_clz. */
#elif defined (__mcfisaaplus__) || defined (__mcfisac__)
#define count_leading_zeros(count,x) ((count) = __builtin_clz (x))
#define COUNT_LEADING_ZEROS_0 32
#endif
#endif /* mc68000 */
#if defined (__m88000__) && W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("addu.co %1,%r4,%r5\n\taddu.ci %0,%r2,%r3" \
: "=r" ((USItype) (sh)), \
"=&r" ((USItype) (sl)) \
: "%rJ" ((USItype) (ah)), \
"rJ" ((USItype) (bh)), \
"%rJ" ((USItype) (al)), \
"rJ" ((USItype) (bl)))
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("subu.co %1,%r4,%r5\n\tsubu.ci %0,%r2,%r3" \
: "=r" ((USItype) (sh)), \
"=&r" ((USItype) (sl)) \
: "rJ" ((USItype) (ah)), \
"rJ" ((USItype) (bh)), \
"rJ" ((USItype) (al)), \
"rJ" ((USItype) (bl)))
#define count_leading_zeros(count, x) \
do { \
USItype __cbtmp; \
__asm__ ("ff1 %0,%1" \
: "=r" (__cbtmp) \
: "r" ((USItype) (x))); \
(count) = __cbtmp ^ 31; \
} while (0)
#define COUNT_LEADING_ZEROS_0 63 /* sic */
#if defined (__mc88110__)
#define umul_ppmm(wh, wl, u, v) \
do { \
union {UDItype __ll; \
struct {USItype __h, __l;} __i; \
} __xx; \
__asm__ ("mulu.d %0,%1,%2" \
: "=r" (__xx.__ll) \
: "r" ((USItype) (u)), \
"r" ((USItype) (v))); \
(wh) = __xx.__i.__h; \
(wl) = __xx.__i.__l; \
} while (0)
#define udiv_qrnnd(q, r, n1, n0, d) \
({union {UDItype __ll; \
struct {USItype __h, __l;} __i; \
} __xx; \
USItype __q; \
__xx.__i.__h = (n1); __xx.__i.__l = (n0); \
__asm__ ("divu.d %0,%1,%2" \
: "=r" (__q) \
: "r" (__xx.__ll), \
"r" ((USItype) (d))); \
(r) = (n0) - __q * (d); (q) = __q; })
#define UMUL_TIME 5
#define UDIV_TIME 25
#else
#define UMUL_TIME 17
#define UDIV_TIME 150
#endif /* __mc88110__ */
#endif /* __m88000__ */
#if defined (__mn10300__)
# if defined (__AM33__)
# define count_leading_zeros(COUNT,X) ((COUNT) = __builtin_clz (X))
# define umul_ppmm(w1, w0, u, v) \
asm("mulu %3,%2,%1,%0" : "=r"(w0), "=r"(w1) : "r"(u), "r"(v))
# define smul_ppmm(w1, w0, u, v) \
asm("mul %3,%2,%1,%0" : "=r"(w0), "=r"(w1) : "r"(u), "r"(v))
# else
# define umul_ppmm(w1, w0, u, v) \
asm("nop; nop; mulu %3,%0" : "=d"(w0), "=z"(w1) : "%0"(u), "d"(v))
# define smul_ppmm(w1, w0, u, v) \
asm("nop; nop; mul %3,%0" : "=d"(w0), "=z"(w1) : "%0"(u), "d"(v))
# endif
# define add_ssaaaa(sh, sl, ah, al, bh, bl) \
do { \
DWunion __s, __a, __b; \
__a.s.low = (al); __a.s.high = (ah); \
__b.s.low = (bl); __b.s.high = (bh); \
__s.ll = __a.ll + __b.ll; \
(sl) = __s.s.low; (sh) = __s.s.high; \
} while (0)
# define sub_ddmmss(sh, sl, ah, al, bh, bl) \
do { \
DWunion __s, __a, __b; \
__a.s.low = (al); __a.s.high = (ah); \
__b.s.low = (bl); __b.s.high = (bh); \
__s.ll = __a.ll - __b.ll; \
(sl) = __s.s.low; (sh) = __s.s.high; \
} while (0)
# define udiv_qrnnd(q, r, nh, nl, d) \
asm("divu %2,%0" : "=D"(q), "=z"(r) : "D"(d), "0"(nl), "1"(nh))
# define sdiv_qrnnd(q, r, nh, nl, d) \
asm("div %2,%0" : "=D"(q), "=z"(r) : "D"(d), "0"(nl), "1"(nh))
# define UMUL_TIME 3
# define UDIV_TIME 38
#endif
#if defined (__mips__) && W_TYPE_SIZE == 32
#define umul_ppmm(w1, w0, u, v) \
do { \
UDItype __x = (UDItype) (USItype) (u) * (USItype) (v); \
(w1) = (USItype) (__x >> 32); \
(w0) = (USItype) (__x); \
} while (0)
#define UMUL_TIME 10
#define UDIV_TIME 100
#if (__mips == 32 || __mips == 64) && ! defined (__mips16)
#define count_leading_zeros(COUNT,X) ((COUNT) = __builtin_clz (X))
#define COUNT_LEADING_ZEROS_0 32
#endif
#endif /* __mips__ */
#if defined (__ns32000__) && W_TYPE_SIZE == 32
#define umul_ppmm(w1, w0, u, v) \
({union {UDItype __ll; \
struct {USItype __l, __h;} __i; \
} __xx; \
__asm__ ("meid %2,%0" \
: "=g" (__xx.__ll) \
: "%0" ((USItype) (u)), \
"g" ((USItype) (v))); \
(w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
#define __umulsidi3(u, v) \
({UDItype __w; \
__asm__ ("meid %2,%0" \
: "=g" (__w) \
: "%0" ((USItype) (u)), \
"g" ((USItype) (v))); \
__w; })
#define udiv_qrnnd(q, r, n1, n0, d) \
({union {UDItype __ll; \
struct {USItype __l, __h;} __i; \
} __xx; \
__xx.__i.__h = (n1); __xx.__i.__l = (n0); \
__asm__ ("deid %2,%0" \
: "=g" (__xx.__ll) \
: "0" (__xx.__ll), \
"g" ((USItype) (d))); \
(r) = __xx.__i.__l; (q) = __xx.__i.__h; })
#define count_trailing_zeros(count,x) \
do { \
__asm__ ("ffsd %2,%0" \
: "=r" ((USItype) (count)) \
: "0" ((USItype) 0), \
"r" ((USItype) (x))); \
} while (0)
#endif /* __ns32000__ */
/* FIXME: We should test _IBMR2 here when we add assembly support for the
system vendor compilers.
FIXME: What's needed for gcc PowerPC VxWorks? __vxworks__ is not good
enough, since that hits ARM and m68k too. */
#if (defined (_ARCH_PPC) /* AIX */ \
|| defined (__powerpc__) /* gcc */ \
|| defined (__POWERPC__) /* BEOS */ \
|| defined (__ppc__) /* Darwin */ \
|| (defined (PPC) && ! defined (CPU_FAMILY)) /* gcc 2.7.x GNU&SysV */ \
|| (defined (PPC) && defined (CPU_FAMILY) /* VxWorks */ \
&& CPU_FAMILY == PPC) \
) && W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
do { \
if (__builtin_constant_p (bh) && (bh) == 0) \
__asm__ ("add%I4c %1,%3,%4\n\taddze %0,%2" \
: "=r" (sh), "=&r" (sl) : "r" (ah), "%r" (al), "rI" (bl));\
else if (__builtin_constant_p (bh) && (bh) == ~(USItype) 0) \
__asm__ ("add%I4c %1,%3,%4\n\taddme %0,%2" \
: "=r" (sh), "=&r" (sl) : "r" (ah), "%r" (al), "rI" (bl));\
else \
__asm__ ("add%I5c %1,%4,%5\n\tadde %0,%2,%3" \
: "=r" (sh), "=&r" (sl) \
: "%r" (ah), "r" (bh), "%r" (al), "rI" (bl)); \
} while (0)
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
do { \
if (__builtin_constant_p (ah) && (ah) == 0) \
__asm__ ("subf%I3c %1,%4,%3\n\tsubfze %0,%2" \
: "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\
else if (__builtin_constant_p (ah) && (ah) == ~(USItype) 0) \
__asm__ ("subf%I3c %1,%4,%3\n\tsubfme %0,%2" \
: "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\
else if (__builtin_constant_p (bh) && (bh) == 0) \
__asm__ ("subf%I3c %1,%4,%3\n\taddme %0,%2" \
: "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\
else if (__builtin_constant_p (bh) && (bh) == ~(USItype) 0) \
__asm__ ("subf%I3c %1,%4,%3\n\taddze %0,%2" \
: "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\
else \
__asm__ ("subf%I4c %1,%5,%4\n\tsubfe %0,%3,%2" \
: "=r" (sh), "=&r" (sl) \
: "r" (ah), "r" (bh), "rI" (al), "r" (bl)); \
} while (0)
#define count_leading_zeros(count, x) \
__asm__ ("cntlzw %0,%1" : "=r" (count) : "r" (x))
#define COUNT_LEADING_ZEROS_0 32
#if defined (_ARCH_PPC) || defined (__powerpc__) || defined (__POWERPC__) \
|| defined (__ppc__) \
|| (defined (PPC) && ! defined (CPU_FAMILY)) /* gcc 2.7.x GNU&SysV */ \
|| (defined (PPC) && defined (CPU_FAMILY) /* VxWorks */ \
&& CPU_FAMILY == PPC)
#define umul_ppmm(ph, pl, m0, m1) \
do { \
USItype __m0 = (m0), __m1 = (m1); \
__asm__ ("mulhwu %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1)); \
(pl) = __m0 * __m1; \
} while (0)
#define UMUL_TIME 15
#define smul_ppmm(ph, pl, m0, m1) \
do { \
SItype __m0 = (m0), __m1 = (m1); \
__asm__ ("mulhw %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1)); \
(pl) = __m0 * __m1; \
} while (0)
#define SMUL_TIME 14
#define UDIV_TIME 120
#endif
#endif /* 32-bit POWER architecture variants. */
/* We should test _IBMR2 here when we add assembly support for the system
vendor compilers. */
#if (defined (_ARCH_PPC64) || defined (__powerpc64__)) && W_TYPE_SIZE == 64
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
do { \
if (__builtin_constant_p (bh) && (bh) == 0) \
__asm__ ("add%I4c %1,%3,%4\n\taddze %0,%2" \
: "=r" (sh), "=&r" (sl) : "r" (ah), "%r" (al), "rI" (bl));\
else if (__builtin_constant_p (bh) && (bh) == ~(UDItype) 0) \
__asm__ ("add%I4c %1,%3,%4\n\taddme %0,%2" \
: "=r" (sh), "=&r" (sl) : "r" (ah), "%r" (al), "rI" (bl));\
else \
__asm__ ("add%I5c %1,%4,%5\n\tadde %0,%2,%3" \
: "=r" (sh), "=&r" (sl) \
: "%r" (ah), "r" (bh), "%r" (al), "rI" (bl)); \
} while (0)
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
do { \
if (__builtin_constant_p (ah) && (ah) == 0) \
__asm__ ("subf%I3c %1,%4,%3\n\tsubfze %0,%2" \
: "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\
else if (__builtin_constant_p (ah) && (ah) == ~(UDItype) 0) \
__asm__ ("subf%I3c %1,%4,%3\n\tsubfme %0,%2" \
: "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\
else if (__builtin_constant_p (bh) && (bh) == 0) \
__asm__ ("subf%I3c %1,%4,%3\n\taddme %0,%2" \
: "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\
else if (__builtin_constant_p (bh) && (bh) == ~(UDItype) 0) \
__asm__ ("subf%I3c %1,%4,%3\n\taddze %0,%2" \
: "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\
else \
__asm__ ("subf%I4c %1,%5,%4\n\tsubfe %0,%3,%2" \
: "=r" (sh), "=&r" (sl) \
: "r" (ah), "r" (bh), "rI" (al), "r" (bl)); \
} while (0)
#define count_leading_zeros(count, x) \
__asm__ ("cntlzd %0,%1" : "=r" (count) : "r" (x))
#define COUNT_LEADING_ZEROS_0 64
#define umul_ppmm(ph, pl, m0, m1) \
do { \
UDItype __m0 = (m0), __m1 = (m1); \
__asm__ ("mulhdu %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1)); \
(pl) = __m0 * __m1; \
} while (0)
#define UMUL_TIME 15
#define smul_ppmm(ph, pl, m0, m1) \
do { \
DItype __m0 = (m0), __m1 = (m1); \
__asm__ ("mulhd %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1)); \
(pl) = __m0 * __m1; \
} while (0)
#define SMUL_TIME 14 /* ??? */
#define UDIV_TIME 120 /* ??? */
#endif /* 64-bit PowerPC. */
#if defined (__ibm032__) /* RT/ROMP */ && W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("a %1,%5\n\tae %0,%3" \
: "=r" ((USItype) (sh)), \
"=&r" ((USItype) (sl)) \
: "%0" ((USItype) (ah)), \
"r" ((USItype) (bh)), \
"%1" ((USItype) (al)), \
"r" ((USItype) (bl)))
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("s %1,%5\n\tse %0,%3" \
: "=r" ((USItype) (sh)), \
"=&r" ((USItype) (sl)) \
: "0" ((USItype) (ah)), \
"r" ((USItype) (bh)), \
"1" ((USItype) (al)), \
"r" ((USItype) (bl)))
#define umul_ppmm(ph, pl, m0, m1) \
do { \
USItype __m0 = (m0), __m1 = (m1); \
__asm__ ( \
"s r2,r2\n" \
" mts r10,%2\n" \
" m r2,%3\n" \
" m r2,%3\n" \
" m r2,%3\n" \
" m r2,%3\n" \
" m r2,%3\n" \
" m r2,%3\n" \
" m r2,%3\n" \
" m r2,%3\n" \
" m r2,%3\n" \
" m r2,%3\n" \
" m r2,%3\n" \
" m r2,%3\n" \
" m r2,%3\n" \
" m r2,%3\n" \
" m r2,%3\n" \
" m r2,%3\n" \
" cas %0,r2,r0\n" \
" mfs r10,%1" \
: "=r" ((USItype) (ph)), \
"=r" ((USItype) (pl)) \
: "%r" (__m0), \
"r" (__m1) \
: "r2"); \
(ph) += ((((SItype) __m0 >> 31) & __m1) \
+ (((SItype) __m1 >> 31) & __m0)); \
} while (0)
#define UMUL_TIME 20
#define UDIV_TIME 200
#define count_leading_zeros(count, x) \
do { \
if ((x) >= 0x10000) \
__asm__ ("clz %0,%1" \
: "=r" ((USItype) (count)) \
: "r" ((USItype) (x) >> 16)); \
else \
{ \
__asm__ ("clz %0,%1" \
: "=r" ((USItype) (count)) \
: "r" ((USItype) (x))); \
(count) += 16; \
} \
} while (0)
#endif
#if defined(__sh__) && W_TYPE_SIZE == 32
#ifndef __sh1__
#define umul_ppmm(w1, w0, u, v) \
__asm__ ( \
"dmulu.l %2,%3\n\tsts%M1 macl,%1\n\tsts%M0 mach,%0" \
: "=r<" ((USItype)(w1)), \
"=r<" ((USItype)(w0)) \
: "r" ((USItype)(u)), \
"r" ((USItype)(v)) \
: "macl", "mach")
#define UMUL_TIME 5
#endif
/* This is the same algorithm as __udiv_qrnnd_c. */
#define UDIV_NEEDS_NORMALIZATION 1
#ifdef __FDPIC__
/* FDPIC needs a special version of the asm fragment to extract the
code address from the function descriptor. __udiv_qrnnd_16 is
assumed to be local and not to use the GOT, so loading r12 is
not needed. */
#define udiv_qrnnd(q, r, n1, n0, d) \
do { \
extern UWtype __udiv_qrnnd_16 (UWtype, UWtype) \
__attribute__ ((visibility ("hidden"))); \
/* r0: rn r1: qn */ /* r0: n1 r4: n0 r5: d r6: d1 */ /* r2: __m */ \
__asm__ ( \
"mov%M4 %4,r5\n" \
" swap.w %3,r4\n" \
" swap.w r5,r6\n" \
" mov.l @%5,r2\n" \
" jsr @r2\n" \
" shll16 r6\n" \
" swap.w r4,r4\n" \
" mov.l @%5,r2\n" \
" jsr @r2\n" \
" swap.w r1,%0\n" \
" or r1,%0" \
: "=r" (q), "=&z" (r) \
: "1" (n1), "r" (n0), "rm" (d), "r" (&__udiv_qrnnd_16) \
: "r1", "r2", "r4", "r5", "r6", "pr", "t"); \
} while (0)
#else
#define udiv_qrnnd(q, r, n1, n0, d) \
do { \
extern UWtype __udiv_qrnnd_16 (UWtype, UWtype) \
__attribute__ ((visibility ("hidden"))); \
/* r0: rn r1: qn */ /* r0: n1 r4: n0 r5: d r6: d1 */ /* r2: __m */ \
__asm__ ( \
"mov%M4 %4,r5\n" \
" swap.w %3,r4\n" \
" swap.w r5,r6\n" \
" jsr @%5\n" \
" shll16 r6\n" \
" swap.w r4,r4\n" \
" jsr @%5\n" \
" swap.w r1,%0\n" \
" or r1,%0" \
: "=r" (q), "=&z" (r) \
: "1" (n1), "r" (n0), "rm" (d), "r" (&__udiv_qrnnd_16) \
: "r1", "r2", "r4", "r5", "r6", "pr", "t"); \
} while (0)
#endif /* __FDPIC__ */
#define UDIV_TIME 80
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("clrt;subc %5,%1; subc %4,%0" \
: "=r" (sh), "=r" (sl) \
: "0" (ah), "1" (al), "r" (bh), "r" (bl) : "t")
#endif /* __sh__ */
#if defined (__sparc__) && !defined (__arch64__) && !defined (__sparcv9) \
&& W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("addcc %r4,%5,%1\n\taddx %r2,%3,%0" \
: "=r" ((USItype) (sh)), \
"=&r" ((USItype) (sl)) \
: "%rJ" ((USItype) (ah)), \
"rI" ((USItype) (bh)), \
"%rJ" ((USItype) (al)), \
"rI" ((USItype) (bl)) \
__CLOBBER_CC)
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("subcc %r4,%5,%1\n\tsubx %r2,%3,%0" \
: "=r" ((USItype) (sh)), \
"=&r" ((USItype) (sl)) \
: "rJ" ((USItype) (ah)), \
"rI" ((USItype) (bh)), \
"rJ" ((USItype) (al)), \
"rI" ((USItype) (bl)) \
__CLOBBER_CC)
#if defined (__sparc_v9__)
#define umul_ppmm(w1, w0, u, v) \
do { \
register USItype __g1 asm ("g1"); \
__asm__ ("umul\t%2,%3,%1\n\t" \
"srlx\t%1, 32, %0" \
: "=r" ((USItype) (w1)), \
"=r" (__g1) \
: "r" ((USItype) (u)), \
"r" ((USItype) (v))); \
(w0) = __g1; \
} while (0)
#define udiv_qrnnd(__q, __r, __n1, __n0, __d) \
__asm__ ("mov\t%2,%%y\n\t" \
"udiv\t%3,%4,%0\n\t" \
"umul\t%0,%4,%1\n\t" \
"sub\t%3,%1,%1" \
: "=&r" ((USItype) (__q)), \
"=&r" ((USItype) (__r)) \
: "r" ((USItype) (__n1)), \
"r" ((USItype) (__n0)), \
"r" ((USItype) (__d)))
#else
#if defined (__sparc_v8__)
#define umul_ppmm(w1, w0, u, v) \
__asm__ ("umul %2,%3,%1;rd %%y,%0" \
: "=r" ((USItype) (w1)), \
"=r" ((USItype) (w0)) \
: "r" ((USItype) (u)), \
"r" ((USItype) (v)))
#define udiv_qrnnd(__q, __r, __n1, __n0, __d) \
__asm__ ("mov %2,%%y;nop;nop;nop;udiv %3,%4,%0;umul %0,%4,%1;sub %3,%1,%1"\
: "=&r" ((USItype) (__q)), \
"=&r" ((USItype) (__r)) \
: "r" ((USItype) (__n1)), \
"r" ((USItype) (__n0)), \
"r" ((USItype) (__d)))
#else
#if defined (__sparclite__)
/* This has hardware multiply but not divide. It also has two additional
instructions scan (ffs from high bit) and divscc. */
#define umul_ppmm(w1, w0, u, v) \
__asm__ ("umul %2,%3,%1;rd %%y,%0" \
: "=r" ((USItype) (w1)), \
"=r" ((USItype) (w0)) \
: "r" ((USItype) (u)), \
"r" ((USItype) (v)))
#define udiv_qrnnd(q, r, n1, n0, d) \
__asm__ ("! Inlined udiv_qrnnd\n" \
" wr %%g0,%2,%%y ! Not a delayed write for sparclite\n" \
" tst %%g0\n" \
" divscc %3,%4,%%g1\n" \
" divscc %%g1,%4,%%g1\n" \
" divscc %%g1,%4,%%g1\n" \
" divscc %%g1,%4,%%g1\n" \
" divscc %%g1,%4,%%g1\n" \
" divscc %%g1,%4,%%g1\n" \
" divscc %%g1,%4,%%g1\n" \
" divscc %%g1,%4,%%g1\n" \
" divscc %%g1,%4,%%g1\n" \
" divscc %%g1,%4,%%g1\n" \
" divscc %%g1,%4,%%g1\n" \
" divscc %%g1,%4,%%g1\n" \
" divscc %%g1,%4,%%g1\n" \
" divscc %%g1,%4,%%g1\n" \
" divscc %%g1,%4,%%g1\n" \
" divscc %%g1,%4,%%g1\n" \
" divscc %%g1,%4,%%g1\n" \
" divscc %%g1,%4,%%g1\n" \
" divscc %%g1,%4,%%g1\n" \
" divscc %%g1,%4,%%g1\n" \
" divscc %%g1,%4,%%g1\n" \
" divscc %%g1,%4,%%g1\n" \
" divscc %%g1,%4,%%g1\n" \
" divscc %%g1,%4,%%g1\n" \
" divscc %%g1,%4,%%g1\n" \
" divscc %%g1,%4,%%g1\n" \
" divscc %%g1,%4,%%g1\n" \
" divscc %%g1,%4,%%g1\n" \
" divscc %%g1,%4,%%g1\n" \
" divscc %%g1,%4,%%g1\n" \
" divscc %%g1,%4,%%g1\n" \
" divscc %%g1,%4,%0\n" \
" rd %%y,%1\n" \
" bl,a 1f\n" \
" add %1,%4,%1\n" \
"1: ! End of inline udiv_qrnnd" \
: "=r" ((USItype) (q)), \
"=r" ((USItype) (r)) \
: "r" ((USItype) (n1)), \
"r" ((USItype) (n0)), \
"rI" ((USItype) (d)) \
: "g1" __AND_CLOBBER_CC)
#define UDIV_TIME 37
#define count_leading_zeros(count, x) \
do { \
__asm__ ("scan %1,1,%0" \
: "=r" ((USItype) (count)) \
: "r" ((USItype) (x))); \
} while (0)
/* Early sparclites return 63 for an argument of 0, but they warn that future
implementations might change this. Therefore, leave COUNT_LEADING_ZEROS_0
undefined. */
#else
/* SPARC without integer multiplication and divide instructions.
(i.e. at least Sun4/20,40,60,65,75,110,260,280,330,360,380,470,490) */
#define umul_ppmm(w1, w0, u, v) \
__asm__ ("! Inlined umul_ppmm\n" \
" wr %%g0,%2,%%y ! SPARC has 0-3 delay insn after a wr\n"\
" sra %3,31,%%o5 ! Don't move this insn\n" \
" and %2,%%o5,%%o5 ! Don't move this insn\n" \
" andcc %%g0,0,%%g1 ! Don't move this insn\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,%3,%%g1\n" \
" mulscc %%g1,0,%%g1\n" \
" add %%g1,%%o5,%0\n" \
" rd %%y,%1" \
: "=r" ((USItype) (w1)), \
"=r" ((USItype) (w0)) \
: "%rI" ((USItype) (u)), \
"r" ((USItype) (v)) \
: "g1", "o5" __AND_CLOBBER_CC)
#define UMUL_TIME 39 /* 39 instructions */
/* It's quite necessary to add this much assembler for the sparc.
The default udiv_qrnnd (in C) is more than 10 times slower! */
#define udiv_qrnnd(__q, __r, __n1, __n0, __d) \
__asm__ ("! Inlined udiv_qrnnd\n" \
" mov 32,%%g1\n" \
" subcc %1,%2,%%g0\n" \
"1: bcs 5f\n" \
" addxcc %0,%0,%0 ! shift n1n0 and a q-bit in lsb\n" \
" sub %1,%2,%1 ! this kills msb of n\n" \
" addx %1,%1,%1 ! so this can't give carry\n" \
" subcc %%g1,1,%%g1\n" \
"2: bne 1b\n" \
" subcc %1,%2,%%g0\n" \
" bcs 3f\n" \
" addxcc %0,%0,%0 ! shift n1n0 and a q-bit in lsb\n" \
" b 3f\n" \
" sub %1,%2,%1 ! this kills msb of n\n" \
"4: sub %1,%2,%1\n" \
"5: addxcc %1,%1,%1\n" \
" bcc 2b\n" \
" subcc %%g1,1,%%g1\n" \
"! Got carry from n. Subtract next step to cancel this carry.\n" \
" bne 4b\n" \
" addcc %0,%0,%0 ! shift n1n0 and a 0-bit in lsb\n" \
" sub %1,%2,%1\n" \
"3: xnor %0,0,%0\n" \
" ! End of inline udiv_qrnnd" \
: "=&r" ((USItype) (__q)), \
"=&r" ((USItype) (__r)) \
: "r" ((USItype) (__d)), \
"1" ((USItype) (__n1)), \
"0" ((USItype) (__n0)) : "g1" __AND_CLOBBER_CC)
#define UDIV_TIME (3+7*32) /* 7 instructions/iteration. 32 iterations. */
#endif /* __sparclite__ */
#endif /* __sparc_v8__ */
#endif /* __sparc_v9__ */
#endif /* sparc32 */
#if ((defined (__sparc__) && defined (__arch64__)) || defined (__sparcv9)) \
&& W_TYPE_SIZE == 64
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
do { \
UDItype __carry = 0; \
__asm__ ("addcc\t%r5,%6,%1\n\t" \
"add\t%r3,%4,%0\n\t" \
"movcs\t%%xcc, 1, %2\n\t" \
"add\t%0, %2, %0" \
: "=r" ((UDItype)(sh)), \
"=&r" ((UDItype)(sl)), \
"+r" (__carry) \
: "%rJ" ((UDItype)(ah)), \
"rI" ((UDItype)(bh)), \
"%rJ" ((UDItype)(al)), \
"rI" ((UDItype)(bl)) \
__CLOBBER_CC); \
} while (0)
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
do { \
UDItype __carry = 0; \
__asm__ ("subcc\t%r5,%6,%1\n\t" \
"sub\t%r3,%4,%0\n\t" \
"movcs\t%%xcc, 1, %2\n\t" \
"sub\t%0, %2, %0" \
: "=r" ((UDItype)(sh)), \
"=&r" ((UDItype)(sl)), \
"+r" (__carry) \
: "%rJ" ((UDItype)(ah)), \
"rI" ((UDItype)(bh)), \
"%rJ" ((UDItype)(al)), \
"rI" ((UDItype)(bl)) \
__CLOBBER_CC); \
} while (0)
#define umul_ppmm(wh, wl, u, v) \
do { \
UDItype tmp1, tmp2, tmp3, tmp4; \
__asm__ __volatile__ ( \
"srl %7,0,%3\n\t" \
"mulx %3,%6,%1\n\t" \
"srlx %6,32,%2\n\t" \
"mulx %2,%3,%4\n\t" \
"sllx %4,32,%5\n\t" \
"srl %6,0,%3\n\t" \
"sub %1,%5,%5\n\t" \
"srlx %5,32,%5\n\t" \
"addcc %4,%5,%4\n\t" \
"srlx %7,32,%5\n\t" \
"mulx %3,%5,%3\n\t" \
"mulx %2,%5,%5\n\t" \
"sethi %%hi(0x80000000),%2\n\t" \
"addcc %4,%3,%4\n\t" \
"srlx %4,32,%4\n\t" \
"add %2,%2,%2\n\t" \
"movcc %%xcc,%%g0,%2\n\t" \
"addcc %5,%4,%5\n\t" \
"sllx %3,32,%3\n\t" \
"add %1,%3,%1\n\t" \
"add %5,%2,%0" \
: "=r" ((UDItype)(wh)), \
"=&r" ((UDItype)(wl)), \
"=&r" (tmp1), "=&r" (tmp2), "=&r" (tmp3), "=&r" (tmp4) \
: "r" ((UDItype)(u)), \
"r" ((UDItype)(v)) \
__CLOBBER_CC); \
} while (0)
#define UMUL_TIME 96
#define UDIV_TIME 230
#endif /* sparc64 */
#if defined (__vax__) && W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("addl2 %5,%1\n\tadwc %3,%0" \
: "=g" ((USItype) (sh)), \
"=&g" ((USItype) (sl)) \
: "%0" ((USItype) (ah)), \
"g" ((USItype) (bh)), \
"%1" ((USItype) (al)), \
"g" ((USItype) (bl)))
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("subl2 %5,%1\n\tsbwc %3,%0" \
: "=g" ((USItype) (sh)), \
"=&g" ((USItype) (sl)) \
: "0" ((USItype) (ah)), \
"g" ((USItype) (bh)), \
"1" ((USItype) (al)), \
"g" ((USItype) (bl)))
#define umul_ppmm(xh, xl, m0, m1) \
do { \
union { \
UDItype __ll; \
struct {USItype __l, __h;} __i; \
} __xx; \
USItype __m0 = (m0), __m1 = (m1); \
__asm__ ("emul %1,%2,$0,%0" \
: "=r" (__xx.__ll) \
: "g" (__m0), \
"g" (__m1)); \
(xh) = __xx.__i.__h; \
(xl) = __xx.__i.__l; \
(xh) += ((((SItype) __m0 >> 31) & __m1) \
+ (((SItype) __m1 >> 31) & __m0)); \
} while (0)
#define sdiv_qrnnd(q, r, n1, n0, d) \
do { \
union {DItype __ll; \
struct {SItype __l, __h;} __i; \
} __xx; \
__xx.__i.__h = n1; __xx.__i.__l = n0; \
__asm__ ("ediv %3,%2,%0,%1" \
: "=g" (q), "=g" (r) \
: "g" (__xx.__ll), "g" (d)); \
} while (0)
#endif /* __vax__ */
#ifdef _TMS320C6X
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
do \
{ \
UDItype __ll; \
__asm__ ("addu .l1 %1, %2, %0" \
: "=a" (__ll) : "a" (al), "a" (bl)); \
(sl) = (USItype)__ll; \
(sh) = ((USItype)(__ll >> 32)) + (ah) + (bh); \
} \
while (0)
#ifdef _TMS320C6400_PLUS
#define __umulsidi3(u,v) ((UDItype)(USItype)u*(USItype)v)
#define umul_ppmm(w1, w0, u, v) \
do { \
UDItype __x = (UDItype) (USItype) (u) * (USItype) (v); \
(w1) = (USItype) (__x >> 32); \
(w0) = (USItype) (__x); \
} while (0)
#endif /* _TMS320C6400_PLUS */
#define count_leading_zeros(count, x) ((count) = __builtin_clz (x))
#ifdef _TMS320C6400
#define count_trailing_zeros(count, x) ((count) = __builtin_ctz (x))
#endif
#define UMUL_TIME 4
#define UDIV_TIME 40
#endif /* _TMS320C6X */
#if defined (__xtensa__) && W_TYPE_SIZE == 32
/* This code is not Xtensa-configuration-specific, so rely on the compiler
to expand builtin functions depending on what configuration features
are available. This avoids library calls when the operation can be
performed in-line. */
#define umul_ppmm(w1, w0, u, v) \
do { \
DWunion __w; \
__w.ll = __builtin_umulsidi3 (u, v); \
w1 = __w.s.high; \
w0 = __w.s.low; \
} while (0)
#define __umulsidi3(u, v) __builtin_umulsidi3 (u, v)
#define count_leading_zeros(COUNT, X) ((COUNT) = __builtin_clz (X))
#define count_trailing_zeros(COUNT, X) ((COUNT) = __builtin_ctz (X))
#endif /* __xtensa__ */
#if defined xstormy16
extern UHItype __stormy16_count_leading_zeros (UHItype);
#define count_leading_zeros(count, x) \
do \
{ \
UHItype size; \
\
/* We assume that W_TYPE_SIZE is a multiple of 16... */ \
for ((count) = 0, size = W_TYPE_SIZE; size; size -= 16) \
{ \
UHItype c; \
\
c = __clzhi2 ((x) >> (size - 16)); \
(count) += c; \
if (c != 16) \
break; \
} \
} \
while (0)
#define COUNT_LEADING_ZEROS_0 W_TYPE_SIZE
#endif
#if defined (__z8000__) && W_TYPE_SIZE == 16
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("add %H1,%H5\n\tadc %H0,%H3" \
: "=r" ((unsigned int)(sh)), \
"=&r" ((unsigned int)(sl)) \
: "%0" ((unsigned int)(ah)), \
"r" ((unsigned int)(bh)), \
"%1" ((unsigned int)(al)), \
"rQR" ((unsigned int)(bl)))
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("sub %H1,%H5\n\tsbc %H0,%H3" \
: "=r" ((unsigned int)(sh)), \
"=&r" ((unsigned int)(sl)) \
: "0" ((unsigned int)(ah)), \
"r" ((unsigned int)(bh)), \
"1" ((unsigned int)(al)), \
"rQR" ((unsigned int)(bl)))
#define umul_ppmm(xh, xl, m0, m1) \
do { \
union {long int __ll; \
struct {unsigned int __h, __l;} __i; \
} __xx; \
unsigned int __m0 = (m0), __m1 = (m1); \
__asm__ ("mult %S0,%H3" \
: "=r" (__xx.__i.__h), \
"=r" (__xx.__i.__l) \
: "%1" (__m0), \
"rQR" (__m1)); \
(xh) = __xx.__i.__h; (xl) = __xx.__i.__l; \
(xh) += ((((signed int) __m0 >> 15) & __m1) \
+ (((signed int) __m1 >> 15) & __m0)); \
} while (0)
#endif /* __z8000__ */
#endif /* __GNUC__ */
/* If this machine has no inline assembler, use C macros. */
#if !defined (add_ssaaaa)
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
do { \
UWtype __x; \
__x = (al) + (bl); \
(sh) = (ah) + (bh) + (__x < (al)); \
(sl) = __x; \
} while (0)
#endif
#if !defined (sub_ddmmss)
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
do { \
UWtype __x; \
__x = (al) - (bl); \
(sh) = (ah) - (bh) - (__x > (al)); \
(sl) = __x; \
} while (0)
#endif
/* If we lack umul_ppmm but have smul_ppmm, define umul_ppmm in terms of
smul_ppmm. */
#if !defined (umul_ppmm) && defined (smul_ppmm)
#define umul_ppmm(w1, w0, u, v) \
do { \
UWtype __w1; \
UWtype __xm0 = (u), __xm1 = (v); \
smul_ppmm (__w1, w0, __xm0, __xm1); \
(w1) = __w1 + (-(__xm0 >> (W_TYPE_SIZE - 1)) & __xm1) \
+ (-(__xm1 >> (W_TYPE_SIZE - 1)) & __xm0); \
} while (0)
#endif
/* If we still don't have umul_ppmm, define it using plain C. */
#if !defined (umul_ppmm)
#define umul_ppmm(w1, w0, u, v) \
do { \
UWtype __x0, __x1, __x2, __x3; \
UHWtype __ul, __vl, __uh, __vh; \
\
__ul = __ll_lowpart (u); \
__uh = __ll_highpart (u); \
__vl = __ll_lowpart (v); \
__vh = __ll_highpart (v); \
\
__x0 = (UWtype) __ul * __vl; \
__x1 = (UWtype) __ul * __vh; \
__x2 = (UWtype) __uh * __vl; \
__x3 = (UWtype) __uh * __vh; \
\
__x1 += __ll_highpart (__x0);/* this can't give carry */ \
__x1 += __x2; /* but this indeed can */ \
if (__x1 < __x2) /* did we get it? */ \
__x3 += __ll_B; /* yes, add it in the proper pos. */ \
\
(w1) = __x3 + __ll_highpart (__x1); \
(w0) = __ll_lowpart (__x1) * __ll_B + __ll_lowpart (__x0); \
} while (0)
#endif
#if !defined (__umulsidi3)
#define __umulsidi3(u, v) \
({DWunion __w; \
umul_ppmm (__w.s.high, __w.s.low, u, v); \
__w.ll; })
#endif
/* Define this unconditionally, so it can be used for debugging. */
#define __udiv_qrnnd_c(q, r, n1, n0, d) \
do { \
UWtype __d1, __d0, __q1, __q0; \
UWtype __r1, __r0, __m; \
__d1 = __ll_highpart (d); \
__d0 = __ll_lowpart (d); \
\
__r1 = (n1) % __d1; \
__q1 = (n1) / __d1; \
__m = (UWtype) __q1 * __d0; \
__r1 = __r1 * __ll_B | __ll_highpart (n0); \
if (__r1 < __m) \
{ \
__q1--, __r1 += (d); \
if (__r1 >= (d)) /* i.e. we didn't get carry when adding to __r1 */\
if (__r1 < __m) \
__q1--, __r1 += (d); \
} \
__r1 -= __m; \
\
__r0 = __r1 % __d1; \
__q0 = __r1 / __d1; \
__m = (UWtype) __q0 * __d0; \
__r0 = __r0 * __ll_B | __ll_lowpart (n0); \
if (__r0 < __m) \
{ \
__q0--, __r0 += (d); \
if (__r0 >= (d)) \
if (__r0 < __m) \
__q0--, __r0 += (d); \
} \
__r0 -= __m; \
\
(q) = (UWtype) __q1 * __ll_B | __q0; \
(r) = __r0; \
} while (0)
/* If the processor has no udiv_qrnnd but sdiv_qrnnd, go through
__udiv_w_sdiv (defined in libgcc or elsewhere). */
#if !defined (udiv_qrnnd) && defined (sdiv_qrnnd)
#define udiv_qrnnd(q, r, nh, nl, d) \
do { \
extern UWtype __udiv_w_sdiv (UWtype *, UWtype, UWtype, UWtype); \
UWtype __r; \
(q) = __udiv_w_sdiv (&__r, nh, nl, d); \
(r) = __r; \
} while (0)
#endif
/* If udiv_qrnnd was not defined for this processor, use __udiv_qrnnd_c. */
#if !defined (udiv_qrnnd)
#define UDIV_NEEDS_NORMALIZATION 1
#define udiv_qrnnd __udiv_qrnnd_c
#endif
#if !defined (count_leading_zeros)
#define count_leading_zeros(count, x) \
do { \
UWtype __xr = (x); \
UWtype __a; \
\
if (W_TYPE_SIZE <= 32) \
{ \
__a = __xr < ((UWtype)1<<2*__BITS4) \
? (__xr < ((UWtype)1<<__BITS4) ? 0 : __BITS4) \
: (__xr < ((UWtype)1<<3*__BITS4) ? 2*__BITS4 : 3*__BITS4); \
} \
else \
{ \
for (__a = W_TYPE_SIZE - 8; __a > 0; __a -= 8) \
if (((__xr >> __a) & 0xff) != 0) \
break; \
} \
\
(count) = W_TYPE_SIZE - (__clz_tab[__xr >> __a] + __a); \
} while (0)
#define COUNT_LEADING_ZEROS_0 W_TYPE_SIZE
#endif
#if !defined (count_trailing_zeros)
/* Define count_trailing_zeros using count_leading_zeros. The latter might be
defined in asm, but if it is not, the C version above is good enough. */
#define count_trailing_zeros(count, x) \
do { \
UWtype __ctz_x = (x); \
UWtype __ctz_c; \
count_leading_zeros (__ctz_c, __ctz_x & -__ctz_x); \
(count) = W_TYPE_SIZE - 1 - __ctz_c; \
} while (0)
#endif
#ifndef UDIV_NEEDS_NORMALIZATION
#define UDIV_NEEDS_NORMALIZATION 0
#endif
|
6af098c8e51657a19d25fd0c7d02e253a8bb0d89
|
79d343002bb63a44f8ab0dbac0c9f4ec54078c3a
|
/lib/libc/wasi/libc-bottom-half/cloudlibc/src/libc/unistd/sleep.c
|
970287b62fb1babece575f166e0a7644ecb8b616
|
[
"MIT",
"LLVM-exception",
"Apache-2.0",
"NCSA",
"BSD-2-Clause"
] |
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
| 322
|
c
|
sleep.c
|
// Copyright (c) 2015 Nuxi, https://nuxi.nl/
//
// SPDX-License-Identifier: BSD-2-Clause
#include <time.h>
#include <unistd.h>
unsigned int sleep(unsigned int seconds) {
struct timespec ts = {.tv_sec = seconds, .tv_nsec = 0};
if (clock_nanosleep(CLOCK_REALTIME, 0, &ts, NULL) != 0)
return seconds;
return 0;
}
|
77145d2ea3d25fb571a57ca58e58ba0dcc1be745
|
1efb2283837c9b70bc6449cec877799e4efa3268
|
/test/mpi/rma/accpscw1.c
|
0b29fc7a021058ba746c3e9d483ed61c887bd643
|
[
"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
| 6,023
|
c
|
accpscw1.c
|
/*
* Copyright (C) by Argonne National Laboratory
* See COPYRIGHT in top-level directory
*/
#include "mpitest.h"
#include "mpi.h"
#include <stdio.h>
#include <stdlib.h>
#include "dtpools.h"
#include "mtest_dtp.h"
#include <assert.h>
/*
static char MTEST_Descrip[] = "Accumulate/replace with Post/Start/Complete/Wait";
*/
int world_rank, world_size;
static int accpscw_test(int seed, int testsize, int count, const char *basic_type,
mtest_mem_type_e origmem, mtest_mem_type_e targetmem)
{
int errs = 0, err;
int rank, size, orig_rank, target_rank;
int minsize = 2;
int i;
MPI_Aint origcount, targetcount;
MPI_Comm comm;
MPI_Win win;
MPI_Aint extent, lb;
MPI_Group wingroup, neighbors;
MPI_Datatype origtype, targettype;
DTP_pool_s dtp;
struct mtest_obj orig, target;
static char test_desc[200];
snprintf(test_desc, 200,
"./accpscw1 -seed=%d -testsize=%d -type=%s -count=%d -origmem=%s -targetmem=%s",
seed, testsize, basic_type, count, MTest_memtype_name(origmem),
MTest_memtype_name(targetmem));
if (world_rank == 0) {
MTestPrintfMsg(1, " %s\n", test_desc);
}
err = DTP_pool_create(basic_type, count, seed, &dtp);
if (err != DTP_SUCCESS) {
fprintf(stderr, "Error while creating orig pool (%s,%d)\n", basic_type, count);
fflush(stderr);
}
if (MTestIsBasicDtype(dtp.DTP_base_type)) {
MPI_Type_get_extent(dtp.DTP_base_type, &lb, &extent);
} else {
/* accumulate tests cannot use struct types */
goto fn_exit;
}
MTest_dtp_obj_start(&orig, "origin", dtp, origmem, 0, false);
MTest_dtp_obj_start(&target, "target", dtp, targetmem, 1, true);
/* The following illustrates the use of the routines to
* run through a selection of communicators and datatypes.
* Use subsets of these for tests that do not involve combinations
* of communicators, datatypes, and counts of datatypes */
while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
if (comm == MPI_COMM_NULL) {
/* for NULL comms, make sure these processes create the
* same number of objects, so the target knows what
* datatype layout to check for */
errs += MTEST_CREATE_AND_FREE_DTP_OBJS(dtp, testsize);
errs += MTEST_CREATE_AND_FREE_DTP_OBJS(dtp, testsize);
continue;
}
/* Determine the sender and receiver */
MPI_Comm_rank(comm, &rank);
MPI_Comm_size(comm, &size);
orig_rank = 0;
target_rank = size - 1;
MPI_Win_create(target.buf, target.maxbufsize, extent, MPI_INFO_NULL, comm, &win);
MPI_Win_get_group(win, &wingroup);
/* To improve reporting of problems about operations, we
* change the error handler to errors return */
MPI_Win_set_errhandler(win, MPI_ERRORS_RETURN);
for (i = 0; i < testsize; i++) {
errs += MTest_dtp_create(&orig, rank == orig_rank);
errs += MTest_dtp_create(&target, false);
MTest_dtp_init(&target, -1, -1, count);
targetcount = target.dtp_obj.DTP_type_count;
targettype = target.dtp_obj.DTP_datatype;
if (rank == orig_rank) {
MTest_dtp_init(&orig, 0, 1, count);
origcount = orig.dtp_obj.DTP_type_count;
origtype = orig.dtp_obj.DTP_datatype;
/* Neighbor is target only */
MPI_Group_incl(wingroup, 1, &target_rank, &neighbors);
err = MPI_Win_start(neighbors, 0, win);
if (err) {
errs++;
if (errs < 10) {
MTestPrintError(err);
}
}
MPI_Group_free(&neighbors);
err = MPI_Accumulate((char *) orig.buf + orig.dtp_obj.DTP_buf_offset, origcount,
origtype, target_rank, target.dtp_obj.DTP_buf_offset / extent,
targetcount, targettype, MPI_REPLACE, win);
if (err) {
errs++;
MTestPrintError(err);
}
err = MPI_Win_complete(win);
if (err) {
errs++;
if (errs < 10) {
MTestPrintError(err);
}
}
} else if (rank == target_rank) {
MPI_Group_incl(wingroup, 1, &orig_rank, &neighbors);
MPI_Win_post(neighbors, 0, win);
MPI_Group_free(&neighbors);
MPI_Win_wait(win);
/* This should have the same effect, in terms of
* transferring data, as a send/recv pair */
errs += MTest_dtp_check(&target, 0, 1, count, &orig, errs < 10);
} else {
/* Nothing; the other processes need not call any
* MPI routines */
;
}
MTest_dtp_destroy(&orig);
MTest_dtp_destroy(&target);
}
MPI_Win_free(&win);
MPI_Group_free(&wingroup);
MTestFreeComm(&comm);
}
MTest_dtp_obj_finish(&orig);
MTest_dtp_obj_finish(&target);
fn_exit:
DTP_pool_free(dtp);
return errs;
}
int main(int argc, char *argv[])
{
int errs = 0;
MTest_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &world_size);
MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
struct dtp_args dtp_args;
dtp_args_init(&dtp_args, MTEST_DTP_RMA, argc, argv);
while (dtp_args_get_next(&dtp_args)) {
errs += accpscw_test(dtp_args.seed, dtp_args.testsize,
dtp_args.count, dtp_args.basic_type,
dtp_args.u.rma.origmem, dtp_args.u.rma.targetmem);
}
dtp_args_finalize(&dtp_args);
MTest_Finalize(errs);
return MTestReturnValue(errs);
}
|
e6481d6135b4dc23478d04df6e68de4db22ab0c4
|
9ceacf33fd96913cac7ef15492c126d96cae6911
|
/sys/dev/ic/atwvar.h
|
f31f71487b2e0bc36d8df40db108701e196b6ba3
|
[] |
no_license
|
openbsd/src
|
ab97ef834fd2d5a7f6729814665e9782b586c130
|
9e79f3a0ebd11a25b4bff61e900cb6de9e7795e9
|
refs/heads/master
| 2023-09-02T18:54:56.624627
| 2023-09-02T15:16:12
| 2023-09-02T15:16:12
| 66,966,208
| 3,394
| 1,235
| null | 2023-08-08T02:42:25
| 2016-08-30T18:18:25
|
C
|
UTF-8
|
C
| false
| false
| 14,081
|
h
|
atwvar.h
|
/* $OpenBSD: atwvar.h,v 1.26 2013/12/06 21:03:02 deraadt Exp $ */
/* $NetBSD: atwvar.h,v 1.13 2004/07/23 07:07:55 dyoung Exp $ */
/*
* Copyright (c) 2003, 2004 The NetBSD Foundation, Inc. All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by David Young.
*
* 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 David Young 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 David Young
* 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 _DEV_IC_ATWVAR_H_
#define _DEV_IC_ATWVAR_H_
#include <sys/queue.h>
#include <sys/time.h>
#include <sys/timeout.h>
/*
* Some misc. statics, useful for debugging.
*/
struct atw_stats {
u_long ts_tx_tuf; /* transmit underflow errors */
u_long ts_tx_tro; /* transmit jabber timeouts */
u_long ts_tx_trt; /* retry count exceeded */
u_long ts_tx_tlt; /* lifetime exceeded */
u_long ts_tx_sofbr; /* packet size mismatch */
};
/*
* Transmit descriptor list size. This is arbitrary, but allocate
* enough descriptors for 64 pending transmissions and 16 segments
* per packet. Since a descriptor holds 2 buffer addresses, that's
* 8 descriptors per packet. This MUST work out to a power of 2.
*/
#define ATW_NTXSEGS 16
#define ATW_TXQUEUELEN 64
#define ATW_NTXDESC (ATW_TXQUEUELEN * ATW_NTXSEGS)
#define ATW_NTXDESC_MASK (ATW_NTXDESC - 1)
#define ATW_NEXTTX(x) ((x + 1) & ATW_NTXDESC_MASK)
/*
* Receive descriptor list size. We have one Rx buffer per incoming
* packet, so this logic is a little simpler.
*/
#define ATW_NRXDESC 64
#define ATW_NRXDESC_MASK (ATW_NRXDESC - 1)
#define ATW_NEXTRX(x) ((x + 1) & ATW_NRXDESC_MASK)
/*
* Control structures are DMA'd to the ADM8211 chip. We allocate them in
* a single clump that maps to a single DMA segment to make several things
* easier.
*/
struct atw_control_data {
/*
* The transmit descriptors.
*/
struct atw_txdesc acd_txdescs[ATW_NTXDESC];
/*
* The receive descriptors.
*/
struct atw_rxdesc acd_rxdescs[ATW_NRXDESC];
};
#define ATW_CDOFF(x) offsetof(struct atw_control_data, x)
#define ATW_CDTXOFF(x) ATW_CDOFF(acd_txdescs[(x)])
#define ATW_CDRXOFF(x) ATW_CDOFF(acd_rxdescs[(x)])
struct atw_duration {
uint16_t d_rts_dur;
uint16_t d_data_dur;
uint16_t d_plcp_len;
uint8_t d_residue; /* unused octets in time slot */
};
/*
* Software state for transmit jobs.
*/
struct atw_txsoft {
struct mbuf *txs_mbuf; /* head of our mbuf chain */
bus_dmamap_t txs_dmamap; /* our DMA map */
int txs_firstdesc; /* first descriptor in packet */
int txs_lastdesc; /* last descriptor in packet */
int txs_ndescs; /* number of descriptors */
struct atw_duration txs_d0;
struct atw_duration txs_dn;
SIMPLEQ_ENTRY(atw_txsoft) txs_q;
};
SIMPLEQ_HEAD(atw_txsq, atw_txsoft);
/*
* Software state for receive jobs.
*/
struct atw_rxsoft {
struct mbuf *rxs_mbuf; /* head of our mbuf chain */
bus_dmamap_t rxs_dmamap; /* our DMA map */
};
/*
* Table which describes the transmit threshold mode. We generally
* start at index 0. Whenever we get a transmit underrun, we increment
* our index, falling back if we encounter the NULL terminator.
*/
struct atw_txthresh_tab {
u_int32_t txth_opmode; /* OPMODE bits */
const char *txth_name; /* name of mode */
};
enum atw_rftype { ATW_RFTYPE_INTERSIL = 0, ATW_RFTYPE_RFMD = 1,
ATW_RFTYPE_MARVEL = 2 };
enum atw_bbptype { ATW_BBPTYPE_INTERSIL = 0, ATW_BBPTYPE_RFMD = 1,
ATW_BBPTYPE_MARVEL = 2, ATW_C_BBPTYPE_RFMD = 5 };
/* Radio capture format for ADMtek. */
#define ATW_RX_RADIOTAP_PRESENT \
((1 << IEEE80211_RADIOTAP_FLAGS) | (1 << IEEE80211_RADIOTAP_RATE) | \
(1 << IEEE80211_RADIOTAP_CHANNEL) | \
(1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL))
struct atw_rx_radiotap_header {
struct ieee80211_radiotap_header ar_ihdr;
u_int8_t ar_flags;
u_int8_t ar_rate;
u_int16_t ar_chan_freq;
u_int16_t ar_chan_flags;
u_int8_t ar_antsignal;
} __packed;
#define ATW_TX_RADIOTAP_PRESENT ((1 << IEEE80211_RADIOTAP_FLAGS) | \
(1 << IEEE80211_RADIOTAP_RATE) | \
(1 << IEEE80211_RADIOTAP_CHANNEL))
struct atw_tx_radiotap_header {
struct ieee80211_radiotap_header at_ihdr;
u_int8_t at_flags;
u_int8_t at_rate;
u_int16_t at_chan_freq;
u_int16_t at_chan_flags;
} __packed;
enum atw_revision {
ATW_REVISION_AB = 0x11, /* ADM8211A */
ATW_REVISION_AF = 0x15, /* ADM8211A? */
ATW_REVISION_BA = 0x20, /* ADM8211B */
ATW_REVISION_CA = 0x30 /* ADM8211C/CR */
};
struct atw_softc {
struct device sc_dev;
struct ieee80211com sc_ic;
int (*sc_enable)(struct atw_softc *);
void (*sc_disable)(struct atw_softc *);
void (*sc_power)(struct atw_softc *, int);
int (*sc_newstate)(struct ieee80211com *,
enum ieee80211_state, int);
void (*sc_recv_mgmt)(struct ieee80211com *,
struct mbuf *, struct ieee80211_node *,
struct ieee80211_rxinfo *, int);
struct ieee80211_node *(*sc_node_alloc)(struct ieee80211com *);
void (*sc_node_free)(struct ieee80211com *,
struct ieee80211_node *);
struct atw_stats sc_stats; /* debugging stats */
int sc_tx_timer;
int sc_rescan_timer;
bus_space_tag_t sc_st; /* bus space tag */
bus_space_handle_t sc_sh; /* bus space handle */
bus_size_t sc_mapsize; /* mapping size */
bus_dma_tag_t sc_dmat; /* bus dma tag */
u_int32_t sc_cacheline; /* cache line size */
u_int32_t sc_maxburst; /* maximum burst length */
const struct atw_txthresh_tab *sc_txth;
int sc_txthresh; /* current tx threshold */
u_int sc_cur_chan; /* current channel */
int sc_flags;
u_int16_t *sc_srom;
u_int16_t sc_sromsz;
caddr_t sc_radiobpf;
bus_dma_segment_t sc_cdseg; /* control data memory */
int sc_cdnseg; /* number of segments */
bus_dmamap_t sc_cddmamap; /* control data DMA map */
#define sc_cddma sc_cddmamap->dm_segs[0].ds_addr
/*
* Software state for transmit and receive descriptors.
*/
struct atw_txsoft sc_txsoft[ATW_TXQUEUELEN];
struct atw_rxsoft sc_rxsoft[ATW_NRXDESC];
/*
* Control data structures.
*/
struct atw_control_data *sc_control_data;
#define sc_txdescs sc_control_data->acd_txdescs
#define sc_rxdescs sc_control_data->acd_rxdescs
#define sc_setup_desc sc_control_data->acd_setup_desc
int sc_txfree; /* number of free Tx descriptors */
int sc_txnext; /* next ready Tx descriptor */
int sc_ntxsegs; /* number of transmit segs per pkt */
struct atw_txsq sc_txfreeq; /* free Tx descsofts */
struct atw_txsq sc_txdirtyq; /* dirty Tx descsofts */
int sc_rxptr; /* next ready RX descriptor/descsoft */
u_int32_t sc_busmode; /* copy of ATW_PAR */
u_int32_t sc_opmode; /* copy of ATW_NAR */
u_int32_t sc_inten; /* copy of ATW_IER */
u_int32_t sc_wepctl; /* copy of ATW_WEPCTL */
u_int32_t sc_rxint_mask; /* mask of Rx interrupts we want */
u_int32_t sc_txint_mask; /* mask of Tx interrupts we want */
u_int32_t sc_linkint_mask;/* link-state interrupts mask */
enum atw_rftype sc_rftype;
enum atw_bbptype sc_bbptype;
u_int32_t sc_synctl_rd;
u_int32_t sc_synctl_wr;
u_int32_t sc_bbpctl_rd;
u_int32_t sc_bbpctl_wr;
void (*sc_recv_beacon)(struct ieee80211com *, struct mbuf *,
int, u_int32_t);
void (*sc_recv_prresp)(struct ieee80211com *, struct mbuf *,
int, u_int32_t);
/* ADM8211 state variables. */
u_int8_t sc_sram[ATW_SRAM_MAXSIZE];
u_int sc_sramlen;
u_int8_t sc_bssid[IEEE80211_ADDR_LEN];
u_int8_t sc_rev;
u_int8_t sc_rf3000_options1;
u_int8_t sc_rf3000_options2;
struct timeval sc_last_beacon;
struct timeout sc_scan_to;
union {
struct atw_rx_radiotap_header tap;
u_int8_t pad[64];
} sc_rxtapu;
union {
struct atw_tx_radiotap_header tap;
u_int8_t pad[64];
} sc_txtapu;
};
#define sc_rxtap sc_rxtapu.tap
#define sc_txtap sc_txtapu.tap
#define sc_if sc_ic.ic_if
/* XXX this is fragile. try not to introduce any u_int32_t's. */
struct atw_frame {
/*00*/ u_int8_t atw_dst[IEEE80211_ADDR_LEN];
/*06*/ u_int8_t atw_rate; /* TX rate in 100Kbps */
/*07*/ u_int8_t atw_service; /* 0 */
/*08*/ u_int16_t atw_paylen; /* payload length */
/*0a*/ u_int8_t atw_fc[2]; /* 802.11 Frame
* Control
*/
/* 802.11 PLCP Length for first & last fragment */
/*0c*/ u_int16_t atw_tail_plcplen;
/*0e*/ u_int16_t atw_head_plcplen;
/* 802.11 Duration for first & last fragment */
/*10*/ u_int16_t atw_tail_dur;
/*12*/ u_int16_t atw_head_dur;
/*14*/ u_int8_t atw_addr4[IEEE80211_ADDR_LEN];
union {
struct {
/*1a*/ u_int16_t hdrctl; /*transmission control*/
/*1c*/ u_int16_t fragthr;/* fragmentation threshold
* [0:11], zero [12:15].
*/
/*1e*/ u_int8_t fragnum;/* fragment number [4:7],
* zero [0:3].
*/
/*1f*/ u_int8_t rtylmt; /* retry limit */
/*20*/ u_int8_t wepkey0[4];/* ??? */
/*24*/ u_int8_t wepkey1[4];/* ??? */
/*28*/ u_int8_t wepkey2[4];/* ??? */
/*2c*/ u_int8_t wepkey3[4];/* ??? */
/*30*/ u_int8_t keyid;
/*31*/ u_int8_t reserved0[7];
} s1;
struct {
u_int8_t pad[6];
struct ieee80211_frame ihdr;
} s2;
} u;
} __packed;
#define atw_hdrctl u.s1.hdrctl
#define atw_fragthr u.s1.fragthr
#define atw_fragnum u.s1.fragnum
#define atw_rtylmt u.s1.rtylmt
#define atw_keyid u.s1.keyid
#define atw_ihdr u.s2.ihdr
#define ATW_HDRCTL_SHORT_PREAMBLE (1<<0) /* use short preamble */
#define ATW_HDRCTL_RTSCTS (1<<4) /* send RTS */
#define ATW_HDRCTL_WEP (1<<5)
#define ATW_HDRCTL_UNKNOWN1 (1<<15) /* MAC adds FCS? */
#define ATW_HDRCTL_UNKNOWN2 (1<<8)
#define ATW_FRAGTHR_FRAGTHR_MASK 0x0fff
#define ATW_FRAGNUM_FRAGNUM_MASK 0x00f0
/* Values for sc_flags. */
#define ATWF_MRL 0x00000010 /* memory read line okay */
#define ATWF_MRM 0x00000020 /* memory read multi okay */
#define ATWF_MWI 0x00000040 /* memory write inval okay */
#define ATWF_SHORT_PREAMBLE 0x00000080 /* short preamble enabled */
#define ATWF_RTSCTS 0x00000100 /* RTS/CTS enabled */
#define ATWF_ATTACHED 0x00000800 /* attach has succeeded */
#define ATWF_ENABLED 0x00001000 /* chip is enabled */
#define ATW_IS_ENABLED(sc) ((sc)->sc_flags & ATWF_ENABLED)
#define ATW_CDTXADDR(sc, x) ((sc)->sc_cddma + ATW_CDTXOFF((x)))
#define ATW_CDRXADDR(sc, x) ((sc)->sc_cddma + ATW_CDRXOFF((x)))
#define ATW_CDTXSYNC(sc, x, n, ops) \
do { \
int __x, __n; \
\
__x = (x); \
__n = (n); \
\
/* If it will wrap around, sync to the end of the ring. */ \
if ((__x + __n) > ATW_NTXDESC) { \
bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap, \
ATW_CDTXOFF(__x), sizeof(struct atw_txdesc) * \
(ATW_NTXDESC - __x), (ops)); \
__n -= (ATW_NTXDESC - __x); \
__x = 0; \
} \
\
/* Now sync whatever is left. */ \
bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap, \
ATW_CDTXOFF(__x), sizeof(struct atw_txdesc) * __n, (ops)); \
} while (0)
#define ATW_CDRXSYNC(sc, x, ops) \
bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap, \
ATW_CDRXOFF((x)), sizeof(struct atw_rxdesc), (ops))
/*
* Note we rely on MCLBYTES being a power of two. Because the `length'
* field is only 11 bits, we must subtract 1 from the length to avoid
* having it truncated to 0!
*/
#define ATW_INIT_RXDESC(sc, x) \
do { \
struct atw_rxsoft *__rxs = &sc->sc_rxsoft[(x)]; \
struct atw_rxdesc *__rxd = &sc->sc_rxdescs[(x)]; \
struct mbuf *__m = __rxs->rxs_mbuf; \
\
__rxd->ar_buf1 = \
htole32(__rxs->rxs_dmamap->dm_segs[0].ds_addr); \
__rxd->ar_buf2 = /* for descriptor chaining */ \
htole32(ATW_CDRXADDR((sc), ATW_NEXTRX((x)))); \
__rxd->ar_ctl = \
htole32(LSHIFT(((__m->m_ext.ext_size - 1) & ~0x3U), \
ATW_RXCTL_RBS1_MASK) | \
0 /* ATW_RXCTL_RCH */ | \
((x) == (ATW_NRXDESC - 1) ? ATW_RXCTL_RER : 0)); \
__rxd->ar_stat = htole32(ATW_RXSTAT_OWN); \
\
ATW_CDRXSYNC((sc), (x), \
BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); \
} while (0)
/* country codes from ADM8211 SROM */
#define ATW_COUNTRY_FCC 0 /* USA 1-11 */
#define ATW_COUNTRY_IC 1 /* Canada 1-11 */
#define ATW_COUNTRY_ETSI 2 /* European Union (?) 1-13 */
#define ATW_COUNTRY_SPAIN 3 /* 10-11 */
#define ATW_COUNTRY_FRANCE 4 /* 10-13 */
#define ATW_COUNTRY_MKK 5 /* Japan: 14 */
#define ATW_COUNTRY_MKK2 6 /* Japan: 1-14 */
/*
* register space access macros
*/
#define ATW_READ(sc, reg) \
bus_space_read_4((sc)->sc_st, (sc)->sc_sh, (reg))
#define ATW_WRITE(sc, reg, val) \
bus_space_write_4((sc)->sc_st, (sc)->sc_sh, (reg), (val))
#define ATW_SET(sc, reg, mask) \
ATW_WRITE((sc), (reg), ATW_READ((sc), (reg)) | (mask))
#define ATW_CLR(sc, reg, mask) \
ATW_WRITE((sc), (reg), ATW_READ((sc), (reg)) & ~(mask))
#define ATW_ISSET(sc, reg, mask) \
(ATW_READ((sc), (reg)) & (mask))
void atw_attach(struct atw_softc *);
int atw_detach(struct atw_softc *);
int atw_activate(struct device *, int);
int atw_intr(void *arg);
int atw_enable(struct atw_softc *);
void atw_wakeup(struct atw_softc *);
#endif /* _DEV_IC_ATWVAR_H_ */
|
1be5d53040401150b2fb3663826484e80b099991
|
d169de4c5c6b281984df35536430dcc931a957a9
|
/source/service/simple_stream/mem_stream/vsf_mem_stream.c
|
ba108b1853be36cba7d7fa665b24286270320db8
|
[
"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
| 9,189
|
c
|
vsf_mem_stream.c
|
/*****************************************************************************
* Copyright(C)2009-2022 by VSF Team *
* *
* 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. *
* *
****************************************************************************/
/*============================ INCLUDES ======================================*/
#include "service/vsf_service_cfg.h"
#if VSF_USE_SIMPLE_STREAM == ENABLED
#define __VSF_SIMPLE_STREAM_CLASS_INHERIT__
#define __VSF_MEM_STREAM_CLASS_IMPLEMENT
#include "../vsf_simple_stream.h"
#include "./vsf_mem_stream.h"
#include "kernel/vsf_kernel.h"
/*============================ MACROS ========================================*/
#ifndef VSF_MEM_STREAM_CFG_PROTECT_LEVEL
/*! \note By default, the driver tries to make all APIs interrupt-safe,
*!
*! in the case when you want to disable it,
*! please use following macro:
*! #define VSF_MEM_STREAM_CFG_PROTECT_LEVEL none
*!
*! in the case when you want to use scheduler-safe,
*! please use following macro:
*! #define VSF_MEM_STREAM_CFG_PROTECT_LEVEL scheduler
*!
*! NOTE: This macro should be defined in vsf_usr_cfg.h
*/
# define VSF_MEM_STREAM_CFG_PROTECT_LEVEL interrupt
#endif
/*============================ MACROFIED FUNCTIONS ===========================*/
#define __vsf_mem_stream_protect vsf_protect(VSF_MEM_STREAM_CFG_PROTECT_LEVEL)
#define __vsf_mem_stream_unprotect vsf_unprotect(VSF_MEM_STREAM_CFG_PROTECT_LEVEL)
/*============================ TYPES =========================================*/
/*============================ PROTOTYPES ====================================*/
static void __vsf_mem_stream_init(vsf_stream_t *stream);
static uint_fast32_t __vsf_mem_stream_write(vsf_stream_t *stream, uint8_t *buf, uint_fast32_t size);
static uint_fast32_t __vsf_mem_stream_read(vsf_stream_t *stream, uint8_t *buf, uint_fast32_t size);
static uint_fast32_t __vsf_mem_stream_get_buff_length(vsf_stream_t *stream);
static uint_fast32_t __vsf_mem_stream_get_data_length(vsf_stream_t *stream);
static uint_fast32_t __vsf_mem_stream_get_avail_length(vsf_stream_t *stream);
static uint_fast32_t __vsf_mem_stream_get_wbuf(vsf_stream_t *stream, uint8_t **ptr);
static uint_fast32_t __vsf_mem_stream_get_rbuf(vsf_stream_t *stream, uint8_t **ptr);
/*============================ LOCAL VARIABLES ===============================*/
/*============================ GLOBAL VARIABLES ==============================*/
const vsf_stream_op_t vsf_mem_stream_op = {
.init = __vsf_mem_stream_init,
.fini = __vsf_mem_stream_init,
.write = __vsf_mem_stream_write,
.read = __vsf_mem_stream_read,
.get_buff_length = __vsf_mem_stream_get_buff_length,
.get_data_length = __vsf_mem_stream_get_data_length,
.get_avail_length = __vsf_mem_stream_get_avail_length,
.get_wbuf = __vsf_mem_stream_get_wbuf,
.get_rbuf = __vsf_mem_stream_get_rbuf,
};
/*============================ IMPLEMENTATION ================================*/
static void __vsf_mem_stream_init(vsf_stream_t *stream)
{
vsf_mem_stream_t *mem_stream = (vsf_mem_stream_t *)stream;
mem_stream->is_writing = false;
mem_stream->rpos = mem_stream->wpos = 0;
mem_stream->data_size = 0;
if (!mem_stream->align) {
mem_stream->align = 1;
}
VSF_SERVICE_ASSERT(!(mem_stream->align & (mem_stream->align - 1)));
mem_stream->align -= 1;
}
static uint_fast32_t __vsf_mem_stream_get_buff_length(vsf_stream_t *stream)
{
vsf_mem_stream_t *mem_stream = (vsf_mem_stream_t *)stream;
return mem_stream->size;
}
static uint_fast32_t __vsf_mem_stream_get_data_length(vsf_stream_t *stream)
{
vsf_mem_stream_t *mem_stream = (vsf_mem_stream_t *)stream;
uint_fast32_t data_size;
vsf_protect_t orig = __vsf_mem_stream_protect();
data_size = mem_stream->data_size;
__vsf_mem_stream_unprotect(orig);
return data_size;
}
static uint_fast32_t __vsf_mem_stream_get_avail_length(vsf_stream_t *stream)
{
vsf_mem_stream_t *mem_stream = (vsf_mem_stream_t *)stream;
return (mem_stream->wpos & mem_stream->align) ? 0 :
mem_stream->use_as__vsf_mem_t.size - __vsf_mem_stream_get_data_length(stream);
}
static uint_fast32_t __vsf_mem_stream_get_wbuf(vsf_stream_t *stream, uint8_t **ptr)
{
vsf_mem_stream_t *mem_stream = (vsf_mem_stream_t *)stream;
uint_fast32_t avail_len = __vsf_mem_stream_get_avail_length(stream);
uint_fast32_t wlen = mem_stream->use_as__vsf_mem_t.size - mem_stream->wpos;
uint8_t *p = (avail_len > 0) ?
mem_stream->use_as__vsf_mem_t.buffer + mem_stream->wpos : NULL;
if (ptr != NULL) {
*ptr = p;
mem_stream->is_writing = true;
}
return vsf_min(wlen, avail_len);
}
static uint_fast32_t __vsf_mem_stream_get_rbuf(vsf_stream_t *stream, uint8_t **ptr)
{
vsf_mem_stream_t *mem_stream = (vsf_mem_stream_t *)stream;
uint_fast32_t data_len = __vsf_mem_stream_get_data_length(stream);
uint_fast32_t rlen = mem_stream->use_as__vsf_mem_t.size - mem_stream->rpos;
uint8_t *p = (data_len > 0) ?
mem_stream->use_as__vsf_mem_t.buffer + mem_stream->rpos : NULL;
if (ptr != NULL) {
*ptr = p;
}
return vsf_min(rlen, data_len);
}
static uint_fast32_t __vsf_mem_stream_write(vsf_stream_t *stream, uint8_t *buf, uint_fast32_t size)
{
vsf_mem_stream_t *mem_stream = (vsf_mem_stream_t *)stream;
uint_fast32_t avail_len = __vsf_mem_stream_get_avail_length(stream);
uint_fast32_t wsize = vsf_min(avail_len, size);
VSF_SERVICE_ASSERT(!(mem_stream->wpos & mem_stream->align));
mem_stream->is_writing = true;
if ((buf != NULL) && (buf != &mem_stream->use_as__vsf_mem_t.buffer[mem_stream->wpos])) {
uint_fast32_t totalsize = wsize;
uint_fast32_t curlen = mem_stream->use_as__vsf_mem_t.size - mem_stream->wpos;
curlen = vsf_min(totalsize, curlen);
memcpy(mem_stream->use_as__vsf_mem_t.buffer + mem_stream->wpos, buf, curlen);
totalsize -= curlen;
buf += curlen;
if (totalsize > 0) {
memcpy(mem_stream->use_as__vsf_mem_t.buffer, buf, totalsize);
}
}
vsf_protect_t orig = __vsf_mem_stream_protect();
mem_stream->data_size += wsize;
mem_stream->wpos += wsize;
mem_stream->wpos %= mem_stream->use_as__vsf_mem_t.size;
__vsf_mem_stream_unprotect(orig);
mem_stream->is_writing = false;
return wsize;
}
static uint_fast32_t __vsf_mem_stream_read(vsf_stream_t *stream, uint8_t *buf, uint_fast32_t size)
{
vsf_mem_stream_t *mem_stream = (vsf_mem_stream_t *)stream;
uint_fast32_t data_len = __vsf_mem_stream_get_data_length(stream);
uint_fast32_t rsize = vsf_min(data_len, size);
VSF_SERVICE_ASSERT(!(mem_stream->rpos & mem_stream->align));
if (size < data_len) {
rsize &= ~mem_stream->align;
}
if ((buf != NULL) && (buf != &mem_stream->use_as__vsf_mem_t.buffer[mem_stream->rpos])) {
uint_fast32_t totalsize = rsize;
uint_fast32_t curlen = mem_stream->use_as__vsf_mem_t.size - mem_stream->rpos;
curlen = vsf_min(totalsize, curlen);
memcpy(buf, mem_stream->use_as__vsf_mem_t.buffer + mem_stream->rpos, curlen);
totalsize -= curlen;
buf += curlen;
if (totalsize > 0) {
memcpy(buf, mem_stream->use_as__vsf_mem_t.buffer, totalsize);
}
}
vsf_protect_t orig = __vsf_mem_stream_protect();
mem_stream->data_size -= rsize;
if ((size < data_len) || mem_stream->is_writing) {
mem_stream->rpos += rsize;
mem_stream->rpos %= mem_stream->use_as__vsf_mem_t.size;
} else {
mem_stream->rpos = mem_stream->wpos = 0;
}
__vsf_mem_stream_unprotect(orig);
return rsize;
}
#endif // VSF_USE_SIMPLE_STREAM
|
ae96fabec82cd00016d4d697aea32216aa339bb7
|
b9dc55919b29da24c24f8ee367c5618c9532f56f
|
/Code_source/Compiled/control/format.c
|
ed8054f49259560b99b1be298ccf6f60e155eb45
|
[
"WTFPL",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
porres/pd-else
|
075e8b7ac7a78f442055fbd30d6602cae49c887e
|
b30e8c13c88bb9752c08f78514d64c6206d6678b
|
refs/heads/master
| 2023-08-18T22:26:31.120893
| 2023-08-18T00:46:59
| 2023-08-18T00:46:59
| 56,870,805
| 238
| 42
|
WTFPL
| 2023-09-12T15:55:56
| 2016-04-22T16:45:29
|
C
|
UTF-8
|
C
| false
| false
| 15,177
|
c
|
format.c
|
// based on cyclone sprintf
#include "m_pd.h"
#include <string.h>
// Pattern types
#define format_LITERAL 1
#define format_MINSLOTTYPE 2
#define format_INT 2
#define format_FLOAT 3
#define format_CHAR 4
#define format_STRING 5
/* Numbers: assuming max 62 digits preceding a decimal point in any
fixed-point representation of a t_float (39 in my system)
-- need to be sure, that using max precision would never produce
a representation longer than max width. If this is so, then no number
representation would exceed max width (presumably...).
Strings: for the time being, any string longer than max width would
be truncated (somehow compatible with Str256, but LATER warn-and-allow). */
/* LATER rethink it all */
#define format_MAXPRECISION 192
#define format_MAXWIDTH 512
typedef struct _format{
t_object x_ob;
int x_nslots;
int x_nproxies; // as requested (and allocated)
t_pd **x_proxies;
int x_fsize; // as allocated (i.e. including a terminating 0)
char *x_fstring;
}t_format;
typedef struct _format_proxy{
t_object p_ob;
t_format *p_master;
int p_id;
int p_type; // value #defined above
char *p_pattern;
char *p_pattend;
t_atom p_atom; // input
int p_size;
int p_valid;
}t_format_proxy;
static t_class *format_class;
static t_class *format_proxy_class;
// LATER: use snprintf (should be available on all systems)
static void format_proxy_checkit(t_format_proxy *x, char *buf){
int result = 0, valid = 0;
char *pattend = x->p_pattend;
if(pattend){
char tmp = *pattend;
*pattend = 0;
if(x->p_atom.a_type == A_FLOAT){
t_float f = x->p_atom.a_w.w_float;
if(x->p_type == format_INT) // CHECKME large/negative values
result = sprintf(buf, x->p_pattern, (long)f);
else if(x->p_type == format_FLOAT)
result = sprintf(buf, x->p_pattern, f);
else if(x->p_type == format_CHAR) // a 0 input into %c nulls output
// float into %c is truncated, but CHECKME large/negative values
result = sprintf(buf, x->p_pattern, (unsigned char)f);
else if(x->p_type == format_STRING){ // a float into %s is ok
char temp[64]; // rethink
sprintf(temp, "%g", f);
result = sprintf(buf, x->p_pattern, temp);
}
else
pd_error(x, "[format]: can't convert float (this shouldn't happen)");
if(result > 0)
valid = 1;
}
else if (x->p_atom.a_type == A_SYMBOL){
t_symbol *s = x->p_atom.a_w.w_symbol;
if(x->p_type == format_STRING){
if (strlen(s->s_name) > format_MAXWIDTH){
strncpy(buf, s->s_name, format_MAXWIDTH);
buf[format_MAXWIDTH] = 0;
result = format_MAXWIDTH;
}
else result = sprintf(buf, x->p_pattern, s->s_name);
if (result >= 0)
valid = 1;
}
else
pd_error(x, "[format]: can't convert (type mismatch)");
}
*pattend = tmp;
}
else
pd_error(x, "format_proxy_checkit"); // ????
if((x->p_valid = valid))
x->p_size = result;
else
x->p_size = 0;
}
static void format_dooutput(t_format *x){
int i, outsize;
char *outstring;
outsize = x->x_fsize; // strlen() + 1
// LATER consider subtracting format pattern sizes
for(i = 0; i < x->x_nslots; i++){
t_format_proxy *y = (t_format_proxy *)x->x_proxies[i];
if (y->p_valid)
outsize += y->p_size;
else // invalid input
return;
}
if(outsize > 0 && (outstring = getbytes(outsize))){
char *inp = x->x_fstring;
char *outp = outstring;
for(i = 0; i < x->x_nslots; i++){
t_format_proxy *y = (t_format_proxy *)x->x_proxies[i];
int len = y->p_pattern - inp;
if(len > 0){
strncpy(outp, inp, len);
outp += len;
}
format_proxy_checkit(y, outp);
outp += y->p_size; /* p_size is never negative */
inp = y->p_pattend;
}
strcpy(outp, inp);
outp = outstring;
while(*outp == ' ' || *outp == '\t' || *outp == '\n' || *outp == '\r')
outp++;
if(*outp){
t_binbuf *bb = binbuf_new();
int ac;
t_atom *av;
binbuf_text(bb, outp, strlen(outp));
ac = binbuf_getnatom(bb);
av = binbuf_getvec(bb);
if(ac){
if(av->a_type == A_SYMBOL)
outlet_anything(((t_object *)x)->ob_outlet, av->a_w.w_symbol, ac - 1, av + 1);
else if(av->a_type == A_FLOAT){
if(ac > 1)
outlet_list(((t_object *)x)->ob_outlet, &s_list, ac, av);
else
outlet_float(((t_object *)x)->ob_outlet, av->a_w.w_float);
}
}
binbuf_free(bb);
};
freebytes(outstring, outsize);
}
}
static void format_proxy_float(t_format_proxy *x, t_float f){
char buf[format_MAXWIDTH + 1]; // LATER rethink
SETFLOAT(&x->p_atom, f);
format_proxy_checkit(x, buf);
if (x->p_id == 0 && x->p_valid)
format_dooutput(x->p_master); // CHECKED: only first inlet
}
static void format_proxy_symbol(t_format_proxy *x, t_symbol *s){
char buf[format_MAXWIDTH + 1]; // LATER rethink
if(s && *s->s_name)
SETSYMBOL(&x->p_atom, s);
else
SETFLOAT(&x->p_atom, 0);
format_proxy_checkit(x, buf);
if(x->p_id == 0 && x->p_valid)
format_dooutput(x->p_master); // CHECKED: only first inlet
}
static void format_dolist(t_format *x, t_symbol *s, int ac, t_atom *av, int startid){
s = NULL;
int cnt = x->x_nslots - startid;
if(ac > cnt)
ac = cnt;
if(ac-- > 0){
int id;
for(id = startid + ac, av += ac; id >= startid; id--, av--){
if(av->a_type == A_FLOAT)
format_proxy_float((t_format_proxy *)x->x_proxies[id], av->a_w.w_float);
else if(av->a_type == A_SYMBOL)
format_proxy_symbol((t_format_proxy *)x->x_proxies[id], av->a_w.w_symbol);
}
}
}
static void format_doanything(t_format *x, t_symbol *s, int ac, t_atom *av, int startid){
if(s && s != &s_){
format_dolist(x, 0, ac, av, startid + 1);
format_proxy_symbol((t_format_proxy *)x->x_proxies[startid], s);
}
else
format_dolist(x, 0, ac, av, startid);
}
static void format_proxy_list(t_format_proxy *x, t_symbol *s, int ac, t_atom *av){
if(!ac) // bang
format_dooutput(x->p_master);
else
format_dolist(x->p_master, s, ac, av, x->p_id);
}
static void format_proxy_anything(t_format_proxy *x, t_symbol *s, int ac, t_atom *av){
format_doanything(x->p_master, s, ac, av, x->p_id);
}
static void format_list(t_format *x, t_symbol *s, int ac, t_atom *av){
if(x->x_nslots){
if(!ac) // bang
format_dooutput(x);
else
format_dolist(x, s, ac, av, 0);
}
else
pd_error(x, "[format]: no variable arguments given");
}
static void format_anything(t_format *x, t_symbol *s, int ac, t_atom *av){
if (x->x_nslots)
format_doanything(x, s, ac, av, 0);
else
pd_error(x, "[format]: no variable arguments given");
}
// adjusted binbuf_gettext(), LATER do it right
static char *makename_getstring(int ac, t_atom *av, int *sizep){
char *buf = getbytes(1);
int size = 1;
char atomtext[MAXPDSTRING];
while (ac--){
char *newbuf;
int newsize;
if (buf[size-1] == 0 || av->a_type == A_SEMI || av->a_type == A_COMMA)
size--;
atom_string(av, atomtext, MAXPDSTRING);
newsize = size + strlen(atomtext) + 1;
if (!(newbuf = resizebytes(buf, size, newsize))){
*sizep = 1;
return (getbytes(1));
}
buf = newbuf;
strcpy(buf + size, atomtext);
size = newsize;
buf[size-1] = ' ';
av++;
}
buf[size-1] = 0;
*sizep = size;
return (buf);
}
// used 2x, 1st (x==0) counts valid patterns, 2nd inits proxies and shrinks %%
static int format_get_type(t_format *x, char **patternp){
int type = 0;
char errstring[MAXPDSTRING];
char *ptr;
// char modifier = 0;
int width = 0;
int precision = 0;
int *numfield = &width;
int dotseen = 0;
*errstring = 0;
for(ptr = *patternp; *ptr; ptr++){
if(*ptr >= '0' && *ptr <= '9'){
if(!numfield){
if(x)
sprintf(errstring, "extra number field");
break;
}
*numfield = 10 * *numfield + *ptr - '0';
if(dotseen){
if(precision > format_MAXPRECISION){
if(x)
sprintf(errstring, "precision field too large");
break;
}
}
else{
if(width > format_MAXWIDTH){
if(x)
sprintf(errstring, "width field too large");
break;
}
}
continue;
}
if(*numfield)
numfield = 0;
if(strchr("pdiouxX", *ptr)){ // INT
type = format_INT;
break;
}
else if(strchr("eEfFgG", *ptr)){ // FLOAT
// needed to include if(modifier) to prevent %lf and stuff
type = format_FLOAT;
break;
}
else if(strchr("c", *ptr)){ // CHAR
type = format_CHAR;
break;
}
else if(strchr("s", *ptr)){
type = format_STRING;
break;
}
else if(*ptr == '%'){
type = format_LITERAL;
if(x){ // buffer-shrinking hack
char *p1 = ptr, *p2 = ptr + 1;
do
*p1++ = *p2;
while (*p2++);
ptr--;
}
break;
}
/* else if(strchr("l", *ptr)){ // remove longs for now
if(modifier){
if(x)
sprintf(errstring, "only single modifier is supported");
break;
}
modifier = *ptr;
}*/
else if(*ptr == '.'){
if(dotseen){
if(x)
sprintf(errstring, "multiple dots");
break;
}
numfield = &precision;
dotseen = 1;
}
else if(*ptr == '$'){
if(x)
sprintf(errstring, "parameter number field not supported");
break;
}
else if(*ptr == '*'){
if(x)
sprintf(errstring, "%s parameter not supported", (dotseen ? "precision" : "width"));
break;
}
else if(!strchr("-+ #\'", *ptr)){
if (x)
sprintf(errstring, "\'%c\' format character not supported", *ptr);
break;
}
}
if(*ptr)
ptr++; // LATER rethink
else
if(x)
sprintf(errstring, "type not specified");
*patternp = ptr;
return(type);
}
static void format_free(t_format *x){
if (x->x_proxies){
int i = x->x_nslots;
while (i--){
t_format_proxy *y = (t_format_proxy *)x->x_proxies[i];
pd_free((t_pd *)y);
}
freebytes(x->x_proxies, x->x_nproxies * sizeof(*x->x_proxies));
}
if (x->x_fstring)
freebytes(x->x_fstring, x->x_fsize);
}
static void *format_new(t_symbol *s, int ac, t_atom *av){
t_symbol *dummy = s;
dummy = NULL;
t_format *x;
int fsize;
char *fstring;
char *p1, *p2;
int i = 1, nslots, nproxies = 0;
t_pd **proxies;
fstring = makename_getstring(ac, av, &fsize);
p1 = fstring;
while((p2 = strchr(p1, '%'))){
int type;
p1 = p2 + 1;
type = format_get_type(0, &p1);
if(type >= format_MINSLOTTYPE)
nproxies++;
}
if(!nproxies){ // no arguments creates with an inlet and prints errors
x = (t_format *)pd_new(format_class);
x->x_nslots = 0;
x->x_nproxies = 0;
x->x_proxies = 0;
x->x_fsize = fsize;
x->x_fstring = fstring;
p1 = fstring;
while ((p2 = strchr(p1, '%'))){
p1 = p2 + 1;
format_get_type(x, &p1);
};
outlet_new((t_object *)x, &s_symbol);
return (x);
}
if (!(proxies = (t_pd **)getbytes(nproxies * sizeof(*proxies)))){
freebytes(fstring, fsize);
return (0);
}
for (nslots = 0; nslots < nproxies; nslots++)
if (!(proxies[nslots] = pd_new(format_proxy_class))) break;
if (!nslots){
freebytes(fstring, fsize);
freebytes(proxies, nproxies * sizeof(*proxies));
return (0);
}
x = (t_format *)pd_new(format_class);
x->x_nslots = nslots;
x->x_nproxies = nproxies;
x->x_proxies = proxies;
x->x_fsize = fsize;
x->x_fstring = fstring;
p1 = fstring;
i = 0;
while((p2 = strchr(p1, '%'))){
int type;
p1 = p2 + 1;
type = format_get_type(x, &p1);
if(type >= format_MINSLOTTYPE){
if(i < nslots){
char buf[format_MAXWIDTH + 1]; // LATER rethink
t_format_proxy *y = (t_format_proxy *)proxies[i];
y->p_master = x;
y->p_id = i;
y->p_type = type;
y->p_pattern = p2;
y->p_pattend = p1;
if(type == format_STRING)
SETSYMBOL(&y->p_atom, &s_);
else
SETFLOAT(&y->p_atom, 0);
y->p_size = 0;
y->p_valid = 0;
if(i) // creates inlets for valid '%'
inlet_new((t_object *)x, (t_pd *)y, 0, 0);
format_proxy_checkit(y, buf);
i++;
}
}
}
outlet_new((t_object *)x, &s_symbol);
return(x);
}
void format_setup(void){
format_class = class_new(gensym("format"), (t_newmethod)format_new,
(t_method)format_free, sizeof(t_format), 0, A_GIMME, 0);
class_addlist(format_class, format_list);
class_addanything(format_class, format_anything);
format_proxy_class = class_new(gensym("_format_proxy"), 0, 0,
sizeof(t_format_proxy), CLASS_PD | CLASS_NOINLET, 0);
/* class_addbang(format_proxy_class, format_proxy_bang);
class_addfloat(format_proxy_class, format_proxy_float);
class_addsymbol(format_proxy_class, format_proxy_symbol);*/
class_addlist(format_proxy_class, format_proxy_list);
class_addanything(format_proxy_class, format_proxy_anything);
}
|
0a7dab3370264cab493b3e3e916f7fd1eddd3024
|
7df190df28da7e4ff166e55dc8ce780f11236a9f
|
/src/router/services/services/snmp.c
|
e4bc570966ef711b8fa8712b35cf9505126164f0
|
[] |
no_license
|
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
| 2,628
|
c
|
snmp.c
|
/*
* snmp.c
*
* Copyright (C) 2006 Sebastian Gottschall <s.gottschall@dd-wrt.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.
*
* 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.
*
* $Id:
*/
#ifdef HAVE_SNMP
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include <stdio.h>
#include <sys/types.h>
#include <bcmnvram.h>
#include <shutils.h>
#include <utils.h>
#include <syslog.h>
#include <services.h>
#include "snmp.h"
char *snmp_deps(void)
{
return "snmpd_enable snmpd_syslocation snmpd_syscontact snmpd_sysname snmpd_rocommunity snmpd_rwcommunity";
}
char *snmp_proc(void)
{
return "snmpd";
}
void start_snmp(void)
{
char path[64];
char *snmpd_argv[] = { "snmpd", "-c", getdefaultconfig("snmp", path, sizeof(path), "snmpd.conf"), NULL };
FILE *fp = NULL;
if (!nvram_invmatchi("snmpd_enable", 0)) {
stop_snmp();
return;
}
fp = fopen(getdefaultconfig("snmp", path, sizeof(path), "snmpd.conf"), "w");
if (NULL == fp)
return;
if (*(nvram_safe_get("snmpd_syslocation")))
fprintf(fp, "syslocation %s\n", nvram_safe_get("snmpd_syslocation"));
if (*(nvram_safe_get("snmpd_syscontact")))
fprintf(fp, "syscontact %s\n", nvram_safe_get("snmpd_syscontact"));
if (*(nvram_safe_get("snmpd_sysname")))
fprintf(fp, "sysname %s\n", nvram_safe_get("snmpd_sysname"));
if (*(nvram_safe_get("snmpd_rocommunity")))
fprintf(fp, "rocommunity %s\n", nvram_safe_get("snmpd_rocommunity"));
if (*(nvram_safe_get("snmpd_rwcommunity")))
fprintf(fp, "rwcommunity %s\n", nvram_safe_get("snmpd_rwcommunity"));
fprintf(fp, "sysservices 9\n");
#ifdef HAVE_RAYTRONIK
fprintf(fp, "pass_persist .1.3.6.1.4.1.41404.255 /etc/config/wl_snmpd.sh\n");
#else
fprintf(fp, "pass_persist .1.3.6.1.4.1.2021.255 /etc/wl_snmpd.sh\n");
#endif
fclose(fp);
if (reload_process("snmpd")) {
_log_evalpid(snmpd_argv, NULL, 0, NULL);
}
return;
}
void restart_snmp(void)
{
start_snmp();
}
void stop_snmp(void)
{
stop_process("snmpd", "daemon");
nvram_delstates(snmp_deps());
return;
}
#endif
|
7a33ea09eaf77955f6b62315b1d7500d578cee98
|
b4995c17067e4c16e287b4d0d454a9437ed38751
|
/src/njs_lexer_tables.h
|
e65032529765f1773cb672f8b46542e869d7feb4
|
[
"BSD-2-Clause"
] |
permissive
|
nginx/njs
|
95f44a9128d26f8ed6a052b2e00dd7cff1410efb
|
e694d61a94c711b7c48b0ae23909a4cef7c65700
|
refs/heads/master
| 2023-08-24T18:52:57.529281
| 2023-08-23T17:09:22
| 2023-08-23T17:09:22
| 43,038,779
| 742
| 120
|
BSD-2-Clause
| 2023-07-30T09:23:31
| 2015-09-24T02:03:58
|
C
|
UTF-8
|
C
| false
| false
| 9,732
|
h
|
njs_lexer_tables.h
|
/*
* Copyright (C) Nginx, Inc.
*
* Do not edit, generated by: utils/lexer_keyword.py.
*/
#ifndef _NJS_LEXER_TABLES_H_INCLUDED_
#define _NJS_LEXER_TABLES_H_INCLUDED_
static const njs_keyword_t njs_lexer_kws[54] =
{
{
.entry = { njs_str("arguments") },
.type = NJS_TOKEN_ARGUMENTS,
.reserved = 0
},
{
.entry = { njs_str("async") },
.type = NJS_TOKEN_ASYNC,
.reserved = 0
},
{
.entry = { njs_str("await") },
.type = NJS_TOKEN_AWAIT,
.reserved = 1
},
{
.entry = { njs_str("break") },
.type = NJS_TOKEN_BREAK,
.reserved = 1
},
{
.entry = { njs_str("case") },
.type = NJS_TOKEN_CASE,
.reserved = 1
},
{
.entry = { njs_str("catch") },
.type = NJS_TOKEN_CATCH,
.reserved = 1
},
{
.entry = { njs_str("class") },
.type = NJS_TOKEN_CLASS,
.reserved = 1
},
{
.entry = { njs_str("const") },
.type = NJS_TOKEN_CONST,
.reserved = 1
},
{
.entry = { njs_str("continue") },
.type = NJS_TOKEN_CONTINUE,
.reserved = 1
},
{
.entry = { njs_str("debugger") },
.type = NJS_TOKEN_DEBUGGER,
.reserved = 1
},
{
.entry = { njs_str("default") },
.type = NJS_TOKEN_DEFAULT,
.reserved = 1
},
{
.entry = { njs_str("delete") },
.type = NJS_TOKEN_DELETE,
.reserved = 1
},
{
.entry = { njs_str("do") },
.type = NJS_TOKEN_DO,
.reserved = 1
},
{
.entry = { njs_str("else") },
.type = NJS_TOKEN_ELSE,
.reserved = 1
},
{
.entry = { njs_str("enum") },
.type = NJS_TOKEN_ENUM,
.reserved = 1
},
{
.entry = { njs_str("eval") },
.type = NJS_TOKEN_EVAL,
.reserved = 0
},
{
.entry = { njs_str("export") },
.type = NJS_TOKEN_EXPORT,
.reserved = 1
},
{
.entry = { njs_str("extends") },
.type = NJS_TOKEN_EXTENDS,
.reserved = 1
},
{
.entry = { njs_str("false") },
.type = NJS_TOKEN_FALSE,
.reserved = 1
},
{
.entry = { njs_str("finally") },
.type = NJS_TOKEN_FINALLY,
.reserved = 1
},
{
.entry = { njs_str("for") },
.type = NJS_TOKEN_FOR,
.reserved = 1
},
{
.entry = { njs_str("from") },
.type = NJS_TOKEN_FROM,
.reserved = 0
},
{
.entry = { njs_str("function") },
.type = NJS_TOKEN_FUNCTION,
.reserved = 1
},
{
.entry = { njs_str("if") },
.type = NJS_TOKEN_IF,
.reserved = 1
},
{
.entry = { njs_str("implements") },
.type = NJS_TOKEN_IMPLEMENTS,
.reserved = 1
},
{
.entry = { njs_str("import") },
.type = NJS_TOKEN_IMPORT,
.reserved = 1
},
{
.entry = { njs_str("in") },
.type = NJS_TOKEN_IN,
.reserved = 1
},
{
.entry = { njs_str("instanceof") },
.type = NJS_TOKEN_INSTANCEOF,
.reserved = 1
},
{
.entry = { njs_str("interface") },
.type = NJS_TOKEN_INTERFACE,
.reserved = 1
},
{
.entry = { njs_str("let") },
.type = NJS_TOKEN_LET,
.reserved = 1
},
{
.entry = { njs_str("meta") },
.type = NJS_TOKEN_META,
.reserved = 0
},
{
.entry = { njs_str("new") },
.type = NJS_TOKEN_NEW,
.reserved = 1
},
{
.entry = { njs_str("null") },
.type = NJS_TOKEN_NULL,
.reserved = 1
},
{
.entry = { njs_str("of") },
.type = NJS_TOKEN_OF,
.reserved = 0
},
{
.entry = { njs_str("package") },
.type = NJS_TOKEN_PACKAGE,
.reserved = 1
},
{
.entry = { njs_str("private") },
.type = NJS_TOKEN_PRIVATE,
.reserved = 1
},
{
.entry = { njs_str("protected") },
.type = NJS_TOKEN_PROTECTED,
.reserved = 1
},
{
.entry = { njs_str("public") },
.type = NJS_TOKEN_PUBLIC,
.reserved = 1
},
{
.entry = { njs_str("return") },
.type = NJS_TOKEN_RETURN,
.reserved = 1
},
{
.entry = { njs_str("static") },
.type = NJS_TOKEN_STATIC,
.reserved = 1
},
{
.entry = { njs_str("super") },
.type = NJS_TOKEN_SUPER,
.reserved = 1
},
{
.entry = { njs_str("switch") },
.type = NJS_TOKEN_SWITCH,
.reserved = 1
},
{
.entry = { njs_str("target") },
.type = NJS_TOKEN_TARGET,
.reserved = 0
},
{
.entry = { njs_str("this") },
.type = NJS_TOKEN_THIS,
.reserved = 1
},
{
.entry = { njs_str("throw") },
.type = NJS_TOKEN_THROW,
.reserved = 1
},
{
.entry = { njs_str("true") },
.type = NJS_TOKEN_TRUE,
.reserved = 1
},
{
.entry = { njs_str("try") },
.type = NJS_TOKEN_TRY,
.reserved = 1
},
{
.entry = { njs_str("typeof") },
.type = NJS_TOKEN_TYPEOF,
.reserved = 1
},
{
.entry = { njs_str("undefined") },
.type = NJS_TOKEN_UNDEFINED,
.reserved = 0
},
{
.entry = { njs_str("var") },
.type = NJS_TOKEN_VAR,
.reserved = 1
},
{
.entry = { njs_str("void") },
.type = NJS_TOKEN_VOID,
.reserved = 1
},
{
.entry = { njs_str("while") },
.type = NJS_TOKEN_WHILE,
.reserved = 1
},
{
.entry = { njs_str("with") },
.type = NJS_TOKEN_WITH,
.reserved = 1
},
{
.entry = { njs_str("yield") },
.type = NJS_TOKEN_YIELD,
.reserved = 1
},
};
static const njs_lexer_keyword_entry_t njs_lexer_keyword_entries[99] =
{
{ NULL, NULL, 98, 0 },
{ "continue", &njs_lexer_kws[8], 8, 0 },
{ "finally", &njs_lexer_kws[19], 7, 0 },
{ "return", &njs_lexer_kws[38], 6, 0 },
{ "static", &njs_lexer_kws[39], 6, 0 },
{ "async", &njs_lexer_kws[1], 5, 0 },
{ "break", &njs_lexer_kws[3], 5, 0 },
{ "interface", &njs_lexer_kws[28], 9, 0 },
{ "case", &njs_lexer_kws[4], 4, 0 },
{ "import", &njs_lexer_kws[25], 6, 0 },
{ "protected", &njs_lexer_kws[36], 9, 0 },
{ "switch", &njs_lexer_kws[41], 6, 0 },
{ "catch", &njs_lexer_kws[5], 5, 1 },
{ "delete", &njs_lexer_kws[11], 6, 0 },
{ "else", &njs_lexer_kws[13], 4, 0 },
{ "private", &njs_lexer_kws[35], 7, 0 },
{ "extends", &njs_lexer_kws[17], 7, 0 },
{ "this", &njs_lexer_kws[43], 4, 0 },
{ "false", &njs_lexer_kws[18], 5, 0 },
{ "await", &njs_lexer_kws[2], 5, 0 },
{ NULL, NULL, 0, 0 },
{ "public", &njs_lexer_kws[37], 6, 0 },
{ NULL, NULL, 0, 0 },
{ "class", &njs_lexer_kws[6], 5, 0 },
{ "const", &njs_lexer_kws[7], 5, 4 },
{ NULL, NULL, 0, 0 },
{ "try", &njs_lexer_kws[46], 3, 0 },
{ "null", &njs_lexer_kws[32], 4, 0 },
{ NULL, NULL, 0, 0 },
{ "do", &njs_lexer_kws[12], 2, 0 },
{ "var", &njs_lexer_kws[49], 3, 0 },
{ "if", &njs_lexer_kws[23], 2, 7 },
{ "implements", &njs_lexer_kws[24], 10, 0 },
{ "with", &njs_lexer_kws[52], 4, 0 },
{ NULL, NULL, 0, 0 },
{ "eval", &njs_lexer_kws[15], 4, 9 },
{ NULL, NULL, 0, 0 },
{ "target", &njs_lexer_kws[42], 6, 0 },
{ "enum", &njs_lexer_kws[14], 4, 10 },
{ "instanceof", &njs_lexer_kws[27], 10, 0 },
{ NULL, NULL, 0, 0 },
{ "debugger", &njs_lexer_kws[9], 8, 0 },
{ NULL, NULL, 0, 0 },
{ NULL, NULL, 0, 0 },
{ "default", &njs_lexer_kws[10], 7, 0 },
{ "void", &njs_lexer_kws[50], 4, 0 },
{ NULL, NULL, 0, 0 },
{ NULL, NULL, 0, 0 },
{ "undefined", &njs_lexer_kws[48], 9, 0 },
{ "from", &njs_lexer_kws[21], 4, 0 },
{ "package", &njs_lexer_kws[34], 7, 15 },
{ NULL, NULL, 0, 0 },
{ "yield", &njs_lexer_kws[53], 5, 0 },
{ NULL, NULL, 0, 0 },
{ NULL, NULL, 0, 0 },
{ "of", &njs_lexer_kws[33], 2, 0 },
{ NULL, NULL, 0, 0 },
{ "function", &njs_lexer_kws[22], 8, 0 },
{ NULL, NULL, 0, 0 },
{ "true", &njs_lexer_kws[45], 4, 16 },
{ "new", &njs_lexer_kws[31], 3, 0 },
{ "export", &njs_lexer_kws[16], 6, 0 },
{ NULL, NULL, 0, 0 },
{ NULL, NULL, 0, 0 },
{ NULL, NULL, 0, 0 },
{ NULL, NULL, 0, 0 },
{ NULL, NULL, 0, 0 },
{ NULL, NULL, 0, 0 },
{ "for", &njs_lexer_kws[20], 3, 0 },
{ "while", &njs_lexer_kws[51], 5, 0 },
{ NULL, NULL, 0, 0 },
{ NULL, NULL, 0, 0 },
{ NULL, NULL, 0, 0 },
{ NULL, NULL, 0, 0 },
{ NULL, NULL, 0, 0 },
{ NULL, NULL, 0, 0 },
{ NULL, NULL, 0, 0 },
{ NULL, NULL, 0, 0 },
{ NULL, NULL, 0, 0 },
{ "typeof", &njs_lexer_kws[47], 6, 0 },
{ NULL, NULL, 0, 0 },
{ NULL, NULL, 0, 0 },
{ "super", &njs_lexer_kws[40], 5, 0 },
{ NULL, NULL, 0, 0 },
{ NULL, NULL, 0, 0 },
{ NULL, NULL, 0, 0 },
{ "let", &njs_lexer_kws[29], 3, 19 },
{ "in", &njs_lexer_kws[26], 2, 0 },
{ NULL, NULL, 0, 0 },
{ NULL, NULL, 0, 0 },
{ "throw", &njs_lexer_kws[44], 5, 0 },
{ "arguments", &njs_lexer_kws[0], 9, 0 },
{ "meta", &njs_lexer_kws[30], 4, 0 },
{ NULL, NULL, 0, 0 },
{ NULL, NULL, 0, 0 },
{ NULL, NULL, 0, 0 },
{ NULL, NULL, 0, 0 },
{ NULL, NULL, 0, 0 },
{ NULL, NULL, 0, 0 },
};
#endif /* _NJS_LEXER_TABLES_H_INCLUDED_ */
|
cf260fac1838b4ed0fecf059c73cd08e3d6effc6
|
b01b4365ab6c9afeb6664563dd314df4f269014f
|
/builtins/exit.c
|
390ad6c36401a1937c63d4d35e1c3cd02a4cbaed
|
[
"MIT"
] |
permissive
|
malxau/yori
|
6208011ca60485cfbf141c7639e9f941a160e002
|
027f9b42c08cc5fcc682ecb7fb67e6de5363b8de
|
refs/heads/master
| 2023-09-01T13:11:19.083028
| 2023-08-28T00:00:02
| 2023-08-28T00:00:02
| 127,679,677
| 1,234
| 31
|
MIT
| 2023-04-23T04:54:56
| 2018-04-01T23:29:17
|
C
|
UTF-8
|
C
| false
| false
| 3,605
|
c
|
exit.c
|
/**
* @file builtins/exit.c
*
* Yori shell exit
*
* Copyright (c) 2017-2020 Malcolm J. Smith
*
* 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 <yoripch.h>
#include <yorilib.h>
#include <yoricall.h>
/**
Help text to display to the user.
*/
const
CHAR strExitHelpText[] =
"\n"
"Exit the shell optionally specifying exit code.\n"
"\n"
"EXIT [exitcode]\n";
/**
Display usage text to the user.
*/
BOOL
ExitHelp(VOID)
{
YoriLibOutput(YORI_LIB_OUTPUT_STDOUT, _T("Exit %i.%02i\n"), YORI_VER_MAJOR, YORI_VER_MINOR);
#if YORI_BUILD_ID
YoriLibOutput(YORI_LIB_OUTPUT_STDOUT, _T(" Build %i\n"), YORI_BUILD_ID);
#endif
YoriLibOutput(YORI_LIB_OUTPUT_STDOUT, _T("%hs"), strExitHelpText);
return TRUE;
}
/**
The main entrypoint for the exit cmdlet.
@param ArgC The number of arguments.
@param ArgV An array of arguments.
@return ExitCode, zero for success, nonzero for failure.
*/
DWORD
YORI_BUILTIN_FN
YoriCmd_EXIT(
__in DWORD ArgC,
__in YORI_STRING ArgV[]
)
{
BOOL ArgumentUnderstood;
DWORD i;
DWORD StartArg;
DWORD ExitCode;
YORI_STRING Arg;
YoriLibLoadNtDllFunctions();
YoriLibLoadKernel32Functions();
StartArg = 0;
for (i = 1; i < ArgC; i++) {
ArgumentUnderstood = FALSE;
ASSERT(YoriLibIsStringNullTerminated(&ArgV[i]));
if (YoriLibIsCommandLineOption(&ArgV[i], &Arg)) {
if (YoriLibCompareStringWithLiteralInsensitive(&Arg, _T("?")) == 0) {
ExitHelp();
return EXIT_SUCCESS;
} else if (YoriLibCompareStringWithLiteralInsensitive(&Arg, _T("license")) == 0) {
YoriLibDisplayMitLicense(_T("2017-2020"));
return EXIT_SUCCESS;
}
} else {
StartArg = i;
ArgumentUnderstood = TRUE;
break;
}
if (!ArgumentUnderstood) {
YoriLibOutput(YORI_LIB_OUTPUT_STDERR, _T("Argument not understood, ignored: %y\n"), &ArgV[i]);
}
}
if (StartArg == 0) {
ExitCode = EXIT_SUCCESS;
} else {
LONGLONG llTemp;
DWORD CharsConsumed;
if (!YoriLibStringToNumber(&ArgV[StartArg], FALSE, &llTemp, &CharsConsumed) ||
CharsConsumed == 0) {
return EXIT_FAILURE;
}
ExitCode = (DWORD)llTemp;
}
YoriCallExitProcess(ExitCode);
return ExitCode;
}
// vim:sw=4:ts=4:et:
|
ef2c3546156bd1c028de5d57299019a5ad5ea387
|
f9e7d65cb784c01a0200145ba8d289afe41d4a56
|
/board/puff/gpio.inc
|
7e62488cee77c1d7145de74f29968b033cfbfa89
|
[
"BSD-3-Clause"
] |
permissive
|
FrameworkComputer/EmbeddedController
|
ad7086769e87d0a4179eae96a7c9ff5e383ff54e
|
f6d6b927eed71550d3475411cfc3e59abe5cef2a
|
refs/heads/hx20-hx30
| 2023-08-08T20:45:10.621169
| 2023-05-26T07:03:59
| 2023-05-26T07:03:59
| 447,021,040
| 846
| 48
|
BSD-3-Clause
| 2023-05-26T07:04:59
| 2022-01-12T00:11:14
|
C
|
UTF-8
|
C
| false
| false
| 8,359
|
inc
|
gpio.inc
|
/* -*- mode:c -*-
*
* Copyright 2019 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* Declare symbolic names for all the GPIOs that we care about.
* Pin names follow the schematic, and are aliased to other names if necessary.
* Note: Those with interrupt handlers must be declared first. */
/* Latency on this interrupt is extremely critical, so it comes first to ensure
* it gets placed first in gpio_wui_table so gpio_interrupt() needs to do
* minimal scanning. */
GPIO_INT(CPU_C10_GATE_L, PIN(6, 7), GPIO_INT_BOTH, c10_gate_interrupt)
/* Wake Source interrupts */
GPIO_INT(EC_WP_ODL, PIN(A, 1), GPIO_INT_BOTH, switch_interrupt)
GPIO_INT(H1_EC_PWR_BTN_ODL, PIN(0, 1), GPIO_INT_BOTH, power_button_interrupt)
/* Power sequencing interrupts */
GPIO_INT(PG_PP5000_A_OD, PIN(D, 7), GPIO_INT_BOTH, power_signal_interrupt)
GPIO_INT(PG_PP1800_A_OD, PIN(3, 1), GPIO_INT_BOTH, power_signal_interrupt)
GPIO_INT(PG_VPRIM_CORE_A_OD, PIN(2, 3), GPIO_INT_BOTH, power_signal_interrupt)
GPIO_INT(PG_PP1050_A_OD, PIN(2, 2), GPIO_INT_BOTH, power_signal_interrupt)
/* EC output, but also interrupt so this can be polled as a power signal */
GPIO_INT(EC_PCH_RSMRST_L, PIN(A, 6), GPIO_OUTPUT | GPIO_INT_F_RISING | GPIO_INT_F_FALLING, power_signal_interrupt)
#ifndef CONFIG_HOSTCMD_ESPI_VW_SLP_S4
GPIO_INT(SLP_S4_L, PIN(D, 4), GPIO_INT_BOTH, power_signal_interrupt)
#endif
GPIO_INT(PG_PP2500_DRAM_U_OD, PIN(2, 0), GPIO_INT_BOTH, power_signal_interrupt)
GPIO_INT(PG_PP1200_U_OD, PIN(2, 1), GPIO_INT_BOTH, power_signal_interrupt)
#ifndef CONFIG_HOSTCMD_ESPI_VW_SLP_S3
GPIO_INT(SLP_S3_L, PIN(A, 5), GPIO_INT_BOTH, slp_s3_interrupt)
#endif
GPIO_INT(PG_PP950_VCCIO_OD, PIN(1, 7), GPIO_INT_BOTH, power_signal_interrupt)
GPIO_INT(SLP_S0_L, PIN(D, 5), GPIO_INT_BOTH, power_signal_interrupt)
GPIO_INT(IMVP8_VRRDY_OD, PIN(1, 6), GPIO_INT_BOTH, power_signal_interrupt)
/* Other interrupts */
GPIO_INT(USB_C0_TCPPC_INT_ODL, PIN(E, 0), GPIO_INT_FALLING, ppc_interrupt)
GPIO_INT(USB_C0_TCPC_INT_ODL, PIN(6, 2), GPIO_INT_FALLING, tcpc_alert_event)
/*
* Directly connected recovery button (not available on some boards).
*/
GPIO_INT(EC_RECOVERY_BTN_ODL, PIN(F, 1), GPIO_INT_BOTH, button_interrupt)
/*
* Recovery button input from H1.
*/
GPIO_INT(H1_EC_RECOVERY_BTN_ODL, PIN(2, 4), GPIO_INT_BOTH, button_interrupt)
GPIO_INT(BJ_ADP_PRESENT_L, PIN(8, 2), GPIO_INT_BOTH | GPIO_PULL_UP, adp_connect_interrupt)
/* Port power control interrupts */
GPIO_INT(HDMI_CONN0_OC_ODL, PIN(0, 7), GPIO_INT_BOTH, port_ocp_interrupt)
GPIO_INT(HDMI_CONN1_OC_ODL, PIN(0, 6), GPIO_INT_BOTH, port_ocp_interrupt)
GPIO_INT(USB_A0_OC_ODL, PIN(E, 4), GPIO_INT_BOTH, port_ocp_interrupt)
GPIO_INT(USB_A1_OC_ODL, PIN(A, 2), GPIO_INT_BOTH, port_ocp_interrupt)
GPIO_INT(USB_A2_OC_ODL, PIN(F, 5), GPIO_INT_BOTH, port_ocp_interrupt)
GPIO_INT(USB_A3_OC_ODL, PIN(0, 3), GPIO_INT_BOTH, port_ocp_interrupt)
/* May be reconfigured as input */
GPIO_INT(USB_A4_OC_ODL, PIN(B, 0), GPIO_OUT_LOW | GPIO_INT_BOTH, port_ocp_interrupt)
/* PCH/CPU signals */
GPIO(EC_PCH_PWROK, PIN(0, 5), GPIO_OUT_LOW)
GPIO(EC_PCH_SYS_PWROK, PIN(3, 7), GPIO_OUT_LOW)
GPIO(EC_PCH_PWR_BTN_ODL, PIN(C, 1), GPIO_ODR_HIGH)
GPIO(EC_PCH_RTCRST, PIN(7, 6), GPIO_ODR_HIGH)
GPIO(EC_PCH_WAKE_ODL, PIN(7, 4), GPIO_ODR_HIGH)
GPIO(EC_PROCHOT_IN_OD, PIN(3, 4), GPIO_INPUT)
GPIO(EC_PROCHOT_ODL, PIN(6, 3), GPIO_ODR_HIGH)
GPIO(SYS_RST_ODL, PIN(C, 5), GPIO_ODR_HIGH)
/* Power control outputs */
GPIO(EN_PP5000_A, PIN(A, 4), GPIO_OUT_LOW)
GPIO(EN_PP3300_INA_H1_EC_ODL, PIN(5, 7), GPIO_ODR_HIGH)
GPIO(EN_PP1800_A, PIN(1, 5), GPIO_OUT_LOW)
GPIO(VCCST_PG_OD, PIN(1, 4), GPIO_ODR_LOW)
GPIO(EN_S0_RAILS, PIN(1, 1), GPIO_OUT_LOW)
GPIO(EN_ROA_RAILS, PIN(A, 3), GPIO_OUT_LOW)
GPIO(EN_PP950_VCCIO, PIN(1, 0), GPIO_OUT_LOW)
GPIO(EC_IMVP8_PE, PIN(A, 7), GPIO_OUT_LOW)
GPIO(EN_IMVP8_VR, PIN(F, 4), GPIO_OUT_LOW)
/* Barreljack */
GPIO(EN_PPVAR_BJ_ADP_L, PIN(0, 4), GPIO_OUT_LOW)
/* USB type A */
GPIO(EN_PP5000_USB_VBUS, PIN(8, 3), GPIO_OUT_LOW)
GPIO(USB_A_LOW_PWR_OD, PIN(9, 4), GPIO_ODR_LOW)
GPIO(USB_A2_STATUS_L, PIN(6, 1), GPIO_INPUT)
GPIO(USB_A3_STATUS_L, PIN(C, 7), GPIO_INPUT)
/* USB type C */
GPIO(USB_C0_TCPC_RST, PIN(9, 7), GPIO_OUT_LOW)
/* Misc. */
GPIO(M2_SSD_PLN, PIN(A, 0), GPIO_INPUT)
GPIO(EC_ENTERING_RW, PIN(E, 3), GPIO_OUT_LOW)
GPIO(CCD_MODE_ODL, PIN(E, 5), GPIO_ODR_HIGH)
GPIO(EN_PP_MST_OD, PIN(9, 6), GPIO_ODR_HIGH)
GPIO(PACKET_MODE_EN, PIN(7, 5), GPIO_OUT_LOW)
/* HDMI/CEC */
GPIO(EN_PP5000_HDMI, PIN(5, 0), GPIO_OUT_LOW)
GPIO(HDMI_CONN0_CEC_OUT, PIN(B, 1), GPIO_ODR_HIGH)
GPIO(HDMI_CONN0_CEC_IN, PIN(4, 0), GPIO_INPUT)
GPIO(HDMI_CONN1_CEC_OUT, PIN(9, 5), GPIO_ODR_HIGH)
GPIO(HDMI_CONN1_CEC_IN, PIN(D, 3), GPIO_INPUT)
/* I2C pins - Alternate function below configures I2C module on these pins */
GPIO(I2C0_SCL, PIN(B, 5), GPIO_INPUT) /* EC_I2C_INA_SCL */
GPIO(I2C0_SDA, PIN(B, 4), GPIO_INPUT) /* EC_I2C_INA_SDA */
GPIO(I2C1_SCL, PIN(9, 0), GPIO_INPUT) /* EC_I2C_USB_C0_TCPPC_SCL */
GPIO(I2C1_SDA, PIN(8, 7), GPIO_INPUT) /* EC_I2C_USB_C0_TCPPC_SDA */
GPIO(I2C3_SCL, PIN(D, 1), GPIO_INPUT) /* EC_I2C_USB_C0_TCPC_SCL */
GPIO(I2C3_SDA, PIN(D, 0), GPIO_INPUT) /* EC_I2C_USB_C0_TCPC_SDA */
GPIO(I2C5_SCL, PIN(3, 3), GPIO_INPUT) /* EC_I2C_IMVP8_SCL */
GPIO(I2C5_SDA, PIN(3, 6), GPIO_INPUT) /* EC_I2C_IMVP8_SDA */
GPIO(I2C7_SCL, PIN(B, 3), GPIO_INPUT) /* EC_I2C_EEPROM_SCL */
GPIO(I2C7_SDA, PIN(B, 2), GPIO_INPUT) /* EC_I2C_EEPROM_SDA */
/* Alternate functions GPIO definitions */
ALTERNATE(PIN_MASK(B, 0x30), 0, MODULE_I2C, 0) /* I2C0 */
ALTERNATE(PIN_MASK(9, 0x01), 0, MODULE_I2C, 0) /* I2C1 SCL */
ALTERNATE(PIN_MASK(8, 0x80), 0, MODULE_I2C, 0) /* I2C1 SDA */
ALTERNATE(PIN_MASK(D, 0x03), 0, MODULE_I2C, 0) /* I2C3 */
ALTERNATE(PIN_MASK(3, 0x48), 0, MODULE_I2C, 0) /* I2C5 */
ALTERNATE(PIN_MASK(B, 0x0C), 0, MODULE_I2C, 0) /* I2C7 */
/* PWM */
ALTERNATE(PIN_MASK(C, 0x08), 0, MODULE_PWM, 0) /* PWM0 - Red Led */
ALTERNATE(PIN_MASK(C, 0x10), 0, MODULE_PWM, 0) /* PWM2 - Green Led */
ALTERNATE(PIN_MASK(B, 0x80), 0, MODULE_PWM, 0) /* PWM5 - Fan 1 */
ALTERNATE(PIN_MASK(7, 0x08), 0, MODULE_PWM, 0) /* TA2 - Fan Tachometer */
/* ADC */
ALTERNATE(PIN_MASK(4, 0x2A), 0, MODULE_ADC, 0) /* ADC0, ADC2, ADC4 */
ALTERNATE(PIN_MASK(E, 0x02), 0, MODULE_ADC, 0) /* ADC7 */
ALTERNATE(PIN_MASK(F, 0x01), 0, MODULE_ADC, 0) /* ADC9 */
/* UART */
ALTERNATE(PIN_MASK(6, 0x30), 0, MODULE_UART, 0) /* UART from EC to Servo */
/* Unused pins */
UNUSED(PIN(1, 3)) /* EC_GP_SEL1_ODL */
UNUSED(PIN(F, 2)) /* EC_I2C_RFU_SDA */
UNUSED(PIN(F, 3)) /* EC_I2C_RFU_SCL */
UNUSED(PIN(C, 0)) /* FAN_PWM_2 */
UNUSED(PIN(8, 0)) /* LED_BLUE_L */
UNUSED(PIN(4, 4)) /* ADC1/TEMP_SENSOR_2 */
UNUSED(PIN(4, 2)) /* ADC3/TEMP_SENSOR_3 */
UNUSED(PIN(C, 2)) /* A12 NC */
UNUSED(PIN(9, 2)) /* K8 NC */
UNUSED(PIN(9, 1)) /* L8 NC */
UNUSED(PIN(1, 2)) /* C6 NC */
UNUSED(PIN(6, 6)) /* H4 NC */
UNUSED(PIN(8, 1)) /* L6 NC */
UNUSED(PIN(C, 6)) /* B11 NC */
UNUSED(PIN(E, 2)) /* B8 NC */
UNUSED(PIN(8, 5)) /* L7 NC */
UNUSED(PIN(0, 0)) /* D11 NC */
UNUSED(PIN(3, 2)) /* E5 NC */
UNUSED(PIN(D, 6)) /* F6 NC */
UNUSED(PIN(3, 5)) /* F5 NC */
UNUSED(PIN(5, 6)) /* M2 NC */
UNUSED(PIN(D, 2)) /* C11 NC */
UNUSED(PIN(8, 6)) /* J8 NC */
UNUSED(PIN(9, 3)) /* M11 NC */
UNUSED(PIN(7, 2)) /* H6 NC */
|
ef6cd470ca317f5fbdae98902e7591a0a2f2a4a4
|
7df190df28da7e4ff166e55dc8ce780f11236a9f
|
/src/router/oled/font_microtech_10.h
|
e3a4b18e106716f92f7b57f2fd88b6a7358e051d
|
[] |
no_license
|
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
| 45,356
|
h
|
font_microtech_10.h
|
/* $Id$ */
#ifndef FONT_MicroTech10_H
#define FONT_MicroTech10_H
/* Font name: <MicroTech> */
/* Font size: <10> */
struct _FontInfo
{
const unsigned char *Ptr;
unsigned char Width;
unsigned char Height;
};
const unsigned char MicroTech10FChar000[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar001[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar002[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar003[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar004[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar005[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar006[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar007[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar008[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar009[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar010[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar011[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar012[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar013[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar014[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar015[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar016[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar017[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar018[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar019[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar020[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar021[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar022[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar023[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar024[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar025[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar026[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar027[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar028[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar029[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar030[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar031[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar032[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar033[]={0x00, 0x00, 0x70, 0x04, 0x00, 0x00};
const unsigned char MicroTech10FChar034[]={0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar035[]={0x00, 0x00, 0x40, 0x02, 0xF0, 0x07, 0x40, 0x02, 0x40, 0x02, 0xF0, 0x07, 0x40, 0x02, 0x40, 0x02};
const unsigned char MicroTech10FChar036[]={0x00, 0x00, 0xF0, 0x04, 0x90, 0x04, 0x90, 0x04, 0xF8, 0x0F, 0x90, 0x04, 0x90, 0x04, 0x90, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar037[]={0x10, 0x00, 0x10, 0x04, 0x10, 0x02, 0x00, 0x01, 0xC0, 0x00, 0x60, 0x04, 0x30, 0x04, 0x10, 0x04, 0x00, 0x00};
const unsigned char MicroTech10FChar038[]={0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0xF8, 0x0F, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x00, 0x00};
const unsigned char MicroTech10FChar039[]={0x00, 0x00, 0x0C, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar040[]={0xFE, 0x3F, 0x02, 0x20, 0x02, 0x20, 0x00, 0x00};
const unsigned char MicroTech10FChar041[]={0x02, 0x20, 0x02, 0x20, 0xFE, 0x3F, 0x00, 0x00};
const unsigned char MicroTech10FChar042[]={0x80, 0x00, 0xC0, 0x02, 0x80, 0x01, 0xF0, 0x07, 0xC0, 0x02, 0xA0, 0x00, 0x80, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar043[]={0x00, 0x00, 0x80, 0x00, 0xC0, 0x03, 0x80, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar044[]={0x00, 0x00, 0x00, 0x0C, 0x00, 0x00};
const unsigned char MicroTech10FChar045[]={0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar046[]={0x00, 0x00, 0x00, 0x04, 0x00, 0x00};
const unsigned char MicroTech10FChar047[]={0x00, 0x00, 0x00, 0x04, 0x00, 0x02, 0x80, 0x01, 0xC0, 0x00, 0x60, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar048[]={0xF0, 0x07, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar049[]={0x40, 0x00, 0x40, 0x00, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar050[]={0x90, 0x07, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0xF0, 0x04, 0x00, 0x00};
const unsigned char MicroTech10FChar051[]={0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar052[]={0xF0, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar053[]={0xF0, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar054[]={0xF0, 0x07, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar055[]={0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar056[]={0xF0, 0x07, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar057[]={0xF0, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar058[]={0x00, 0x00, 0x40, 0x04, 0x00, 0x00};
const unsigned char MicroTech10FChar059[]={0x00, 0x00, 0x40, 0x0E, 0x00, 0x00};
const unsigned char MicroTech10FChar060[]={0x00, 0x00, 0xC0, 0x00, 0xE0, 0x03, 0x30, 0x06, 0x10, 0x04, 0x00, 0x00};
const unsigned char MicroTech10FChar061[]={0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x00, 0x00};
const unsigned char MicroTech10FChar062[]={0x00, 0x00, 0x10, 0x04, 0x30, 0x07, 0xE0, 0x01, 0xC0, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar063[]={0x00, 0x00, 0x90, 0x04, 0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0xF0, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar064[]={0x00, 0x00, 0xF0, 0x07, 0x10, 0x04, 0x90, 0x04, 0x10, 0x04, 0x10, 0x04, 0x90, 0x04, 0x90, 0x04, 0xF0, 0x04};
const unsigned char MicroTech10FChar065[]={0x00, 0x00, 0x10, 0x07, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar066[]={0xFC, 0x07, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar067[]={0xF0, 0x07, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x00, 0x00};
const unsigned char MicroTech10FChar068[]={0xF0, 0x07, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0xFC, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar069[]={0x00, 0x00, 0xF0, 0x07, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x00, 0x00};
const unsigned char MicroTech10FChar070[]={0xF0, 0x07, 0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar071[]={0xF0, 0x27, 0x10, 0x24, 0x10, 0x24, 0x10, 0x24, 0x10, 0x24, 0x10, 0x24, 0x10, 0x24, 0xF0, 0x3F, 0x00, 0x00};
const unsigned char MicroTech10FChar072[]={0xFC, 0x07, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar073[]={0x00, 0x00, 0xF4, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar074[]={0x00, 0x00, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0xF4, 0x3F, 0x00, 0x00};
const unsigned char MicroTech10FChar075[]={0x00, 0x00, 0xFC, 0x07, 0x80, 0x01, 0x40, 0x03, 0x20, 0x02, 0x20, 0x04, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar076[]={0x00, 0x00, 0xFC, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar077[]={0x00, 0x00, 0xF0, 0x07, 0x10, 0x00, 0x10, 0x00, 0xF0, 0x07, 0x10, 0x00, 0x10, 0x00, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar078[]={0x00, 0x00, 0xF0, 0x07, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0xE0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar079[]={0xF0, 0x07, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar080[]={0xF0, 0x3F, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar081[]={0xF0, 0x07, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0xF0, 0x3F, 0x00, 0x00};
const unsigned char MicroTech10FChar082[]={0xF0, 0x07, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar083[]={0xF0, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar084[]={0xFC, 0x07, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x00, 0x00};
const unsigned char MicroTech10FChar085[]={0xF0, 0x07, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar086[]={0x10, 0x00, 0x60, 0x00, 0x80, 0x01, 0x00, 0x06, 0x00, 0x06, 0x80, 0x01, 0x70, 0x00, 0x10, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar087[]={0x00, 0x00, 0xF0, 0x03, 0x00, 0x04, 0x00, 0x04, 0xF0, 0x07, 0x00, 0x04, 0x00, 0x04, 0xF0, 0x03, 0x00, 0x00};
const unsigned char MicroTech10FChar088[]={0x10, 0x00, 0x30, 0x04, 0x60, 0x02, 0x80, 0x01, 0xC0, 0x01, 0x60, 0x02, 0x30, 0x04, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar089[]={0x00, 0x00, 0xF0, 0x23, 0x00, 0x24, 0x00, 0x24, 0x00, 0x24, 0x00, 0x24, 0x00, 0x24, 0xF0, 0x3F, 0x00, 0x00};
const unsigned char MicroTech10FChar090[]={0x10, 0x00, 0x10, 0x04, 0x10, 0x06, 0x10, 0x05, 0x90, 0x04, 0x70, 0x04, 0x30, 0x04, 0x00, 0x04, 0x00, 0x00};
const unsigned char MicroTech10FChar091[]={0xFE, 0x3F, 0x02, 0x20, 0x02, 0x20, 0x00, 0x00};
const unsigned char MicroTech10FChar092[]={0x00, 0x00, 0x10, 0x00, 0x30, 0x00, 0x60, 0x00, 0x80, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x04, 0x00, 0x00};
const unsigned char MicroTech10FChar093[]={0x02, 0x20, 0x02, 0x20, 0xFE, 0x3F, 0x00, 0x00};
const unsigned char MicroTech10FChar094[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar095[]={0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30};
const unsigned char MicroTech10FChar096[]={0x00, 0x00, 0x0C, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar097[]={0x00, 0x00, 0x10, 0x07, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar098[]={0xFC, 0x07, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar099[]={0xF0, 0x07, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x00, 0x00};
const unsigned char MicroTech10FChar100[]={0xF0, 0x07, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0xFC, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar101[]={0x00, 0x00, 0xF0, 0x07, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x00, 0x00};
const unsigned char MicroTech10FChar102[]={0xF0, 0x07, 0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar103[]={0xF0, 0x27, 0x10, 0x24, 0x10, 0x24, 0x10, 0x24, 0x10, 0x24, 0x10, 0x24, 0x10, 0x24, 0xF0, 0x3F, 0x00, 0x00};
const unsigned char MicroTech10FChar104[]={0xFC, 0x07, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar105[]={0x00, 0x00, 0xF4, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar106[]={0x00, 0x00, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0xF4, 0x3F, 0x00, 0x00};
const unsigned char MicroTech10FChar107[]={0x00, 0x00, 0xFC, 0x07, 0x80, 0x01, 0x40, 0x03, 0x20, 0x02, 0x20, 0x04, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar108[]={0x00, 0x00, 0xFC, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar109[]={0x00, 0x00, 0xF0, 0x07, 0x10, 0x00, 0x10, 0x00, 0xF0, 0x07, 0x10, 0x00, 0x10, 0x00, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar110[]={0x00, 0x00, 0xF0, 0x07, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0xE0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar111[]={0xF0, 0x07, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar112[]={0xF0, 0x3F, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar113[]={0xF0, 0x07, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0xF0, 0x3F, 0x00, 0x00};
const unsigned char MicroTech10FChar114[]={0xF0, 0x07, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar115[]={0xF0, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar116[]={0xFC, 0x07, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x00, 0x00};
const unsigned char MicroTech10FChar117[]={0xF0, 0x07, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar118[]={0x10, 0x00, 0x60, 0x00, 0x80, 0x01, 0x00, 0x06, 0x00, 0x06, 0x80, 0x01, 0x70, 0x00, 0x10, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar119[]={0x00, 0x00, 0xF0, 0x03, 0x00, 0x04, 0x00, 0x04, 0xF0, 0x07, 0x00, 0x04, 0x00, 0x04, 0xF0, 0x03, 0x00, 0x00};
const unsigned char MicroTech10FChar120[]={0x10, 0x00, 0x30, 0x04, 0x60, 0x02, 0x80, 0x01, 0xC0, 0x01, 0x60, 0x02, 0x30, 0x04, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar121[]={0x00, 0x00, 0xF0, 0x23, 0x00, 0x24, 0x00, 0x24, 0x00, 0x24, 0x00, 0x24, 0x00, 0x24, 0xF0, 0x3F, 0x00, 0x00};
const unsigned char MicroTech10FChar122[]={0x10, 0x00, 0x10, 0x04, 0x10, 0x06, 0x10, 0x05, 0x90, 0x04, 0x70, 0x04, 0x30, 0x04, 0x00, 0x04, 0x00, 0x00};
const unsigned char MicroTech10FChar123[]={0xFE, 0x3F, 0x02, 0x20, 0x02, 0x20, 0x00, 0x00};
const unsigned char MicroTech10FChar124[]={0x00, 0x00, 0xFC, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar125[]={0x02, 0x20, 0x02, 0x20, 0xFE, 0x3F, 0x00, 0x00};
const unsigned char MicroTech10FChar126[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar127[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar128[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar129[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar130[]={0x00, 0x00, 0x00, 0x0C, 0x00, 0x00};
const unsigned char MicroTech10FChar131[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar132[]={0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00};
const unsigned char MicroTech10FChar133[]={0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00};
const unsigned char MicroTech10FChar134[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar135[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar136[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar137[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar138[]={0x00, 0x00, 0x00, 0x04, 0x00, 0x07, 0xC0, 0x01, 0x70, 0x00, 0xF0, 0x07, 0x80, 0x04, 0x80, 0x04, 0x80, 0x04, 0x80, 0x07};
const unsigned char MicroTech10FChar139[]={0x00, 0x00, 0xC0, 0x00, 0xE0, 0x03, 0x30, 0x06, 0x10, 0x04, 0x00, 0x00};
const unsigned char MicroTech10FChar140[]={0x00, 0x00, 0xF0, 0x07, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xF0, 0x07, 0x80, 0x04, 0x80, 0x04, 0x80, 0x04, 0x80, 0x07};
const unsigned char MicroTech10FChar141[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar142[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar143[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar144[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar145[]={0x00, 0x00, 0x0C, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar146[]={0x00, 0x00, 0x0C, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar147[]={0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar148[]={0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar149[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar150[]={0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar151[]={0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar152[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar153[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar154[]={0x00, 0x00, 0x00, 0x04, 0x00, 0x07, 0xC0, 0x01, 0x70, 0x00, 0xF0, 0x07, 0x80, 0x04, 0x80, 0x04, 0x80, 0x04, 0x80, 0x07};
const unsigned char MicroTech10FChar155[]={0x00, 0x00, 0x10, 0x04, 0x30, 0x07, 0xE0, 0x01, 0xC0, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar156[]={0x00, 0x00, 0xF0, 0x07, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xF0, 0x07, 0x80, 0x04, 0x80, 0x04, 0x80, 0x04, 0x80, 0x07};
const unsigned char MicroTech10FChar157[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar158[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar159[]={0x00, 0x00, 0xF0, 0x07, 0x00, 0x04, 0x00, 0x04, 0x00, 0x0C, 0x00, 0x04, 0x00, 0x04, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar160[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar161[]={0x00, 0x00, 0xF0, 0x23, 0x04, 0x24, 0x04, 0x24, 0x04, 0x24, 0x04, 0x24, 0x04, 0x24, 0xF0, 0x3F, 0x00, 0x00};
const unsigned char MicroTech10FChar162[]={0x00, 0x00, 0xF0, 0x23, 0x04, 0x24, 0x04, 0x24, 0x04, 0x24, 0x04, 0x24, 0x04, 0x24, 0xF0, 0x3F, 0x00, 0x00};
const unsigned char MicroTech10FChar163[]={0x00, 0x00, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0xF4, 0x3F, 0x00, 0x00};
const unsigned char MicroTech10FChar164[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar165[]={0x00, 0x00, 0xF0, 0x07, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x30, 0x00, 0x30, 0x00, 0x38, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar166[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar167[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar168[]={0x00, 0x00, 0xF0, 0x07, 0x94, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x94, 0x04, 0x90, 0x04, 0x00, 0x00};
const unsigned char MicroTech10FChar169[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar170[]={0x00, 0x00, 0xE0, 0x03, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x00, 0x00};
const unsigned char MicroTech10FChar171[]={0x00, 0x00, 0xC0, 0x00, 0xE0, 0x03, 0xB0, 0x06, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar172[]={0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x03, 0x00, 0x00};
const unsigned char MicroTech10FChar173[]={0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar174[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar175[]={0x04, 0x00, 0xF0, 0x07, 0x04, 0x00};
const unsigned char MicroTech10FChar176[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar177[]={0x00, 0x00, 0x80, 0x08, 0xC0, 0x09, 0x80, 0x08, 0x00, 0x08};
const unsigned char MicroTech10FChar178[]={0x00, 0x00, 0xF4, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar179[]={0x00, 0x00, 0xF4, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar180[]={0x00, 0x00, 0xF0, 0x07, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x30, 0x00, 0x30, 0x00, 0x38, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar181[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar182[]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar183[]={0x00, 0x00, 0x80, 0x01, 0x80, 0x01};
const unsigned char MicroTech10FChar184[]={0x00, 0x00, 0xF0, 0x07, 0x94, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x94, 0x04, 0x90, 0x04, 0x00, 0x00};
const unsigned char MicroTech10FChar185[]={0x00, 0x00, 0x40, 0x02, 0xF0, 0x07, 0x40, 0x02, 0x40, 0x02, 0xF0, 0x07, 0x40, 0x02, 0x40, 0x02};
const unsigned char MicroTech10FChar186[]={0x00, 0x00, 0xE0, 0x03, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x00, 0x00};
const unsigned char MicroTech10FChar187[]={0x00, 0x00, 0xF0, 0x07, 0xB0, 0x06, 0xE0, 0x01, 0xC0, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar188[]={0x00, 0x00, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0xF4, 0x3F, 0x00, 0x00};
const unsigned char MicroTech10FChar189[]={0xF0, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar190[]={0xF0, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar191[]={0x04, 0x00, 0xF0, 0x07, 0x04, 0x00};
const unsigned char MicroTech10FChar192[]={0x00, 0x00, 0x10, 0x07, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar193[]={0x00, 0x00, 0xF0, 0x07, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x10, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar194[]={0x00, 0x00, 0xF0, 0x07, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x70, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar195[]={0xF0, 0x07, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar196[]={0xF0, 0x27, 0x10, 0x24, 0x10, 0x24, 0x10, 0x24, 0x10, 0x24, 0x10, 0x24, 0x10, 0x24, 0xF0, 0x3F, 0x00, 0x00};
const unsigned char MicroTech10FChar197[]={0x00, 0x00, 0xF0, 0x07, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x00, 0x00};
const unsigned char MicroTech10FChar198[]={0x00, 0x00, 0x00, 0x04, 0x30, 0x06, 0x60, 0x03, 0xC0, 0x01, 0xF0, 0x07, 0xC0, 0x01, 0x60, 0x03, 0x30, 0x06, 0x00, 0x04};
const unsigned char MicroTech10FChar199[]={0x00, 0x00, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x70, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar200[]={0x00, 0x00, 0xF0, 0x03, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar201[]={0x00, 0x00, 0xF0, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar202[]={0x00, 0x00, 0xF0, 0x07, 0xC0, 0x01, 0x60, 0x03, 0x30, 0x02, 0x10, 0x04, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar203[]={0x00, 0x00, 0x00, 0x06, 0x80, 0x03, 0xE0, 0x00, 0x30, 0x00, 0xE0, 0x00, 0x80, 0x03, 0x00, 0x06, 0x00, 0x00};
const unsigned char MicroTech10FChar204[]={0x00, 0x00, 0xF0, 0x07, 0x10, 0x00, 0x10, 0x00, 0xE0, 0x07, 0x10, 0x00, 0x10, 0x00, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar205[]={0x00, 0x00, 0xF0, 0x07, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar206[]={0xF0, 0x07, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar207[]={0xF0, 0x07, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar208[]={0xF0, 0x3F, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar209[]={0xF0, 0x07, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x00, 0x00};
const unsigned char MicroTech10FChar210[]={0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0xF0, 0x07, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar211[]={0x00, 0x00, 0xF0, 0x23, 0x00, 0x24, 0x00, 0x24, 0x00, 0x24, 0x00, 0x24, 0x00, 0x24, 0xF0, 0x3F, 0x00, 0x00};
const unsigned char MicroTech10FChar212[]={0x00, 0x00, 0xF0, 0x07, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0xF0, 0x3F, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0xF0, 0x07};
const unsigned char MicroTech10FChar213[]={0x10, 0x00, 0x30, 0x04, 0x60, 0x02, 0x80, 0x01, 0xC0, 0x01, 0x60, 0x02, 0x30, 0x04, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar214[]={0x00, 0x00, 0xF0, 0x03, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0xF0, 0x07, 0x00, 0x04, 0x00, 0x00};
const unsigned char MicroTech10FChar215[]={0x00, 0x00, 0x70, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar216[]={0x00, 0x00, 0xF0, 0x03, 0x00, 0x04, 0x00, 0x04, 0xF0, 0x07, 0x00, 0x04, 0x00, 0x04, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar217[]={0x00, 0x00, 0xF0, 0x03, 0x00, 0x04, 0x00, 0x04, 0xF0, 0x07, 0x00, 0x04, 0x00, 0x04, 0xF0, 0x07, 0x00, 0x04, 0x00, 0x00};
const unsigned char MicroTech10FChar218[]={0x10, 0x00, 0x10, 0x00, 0xF0, 0x07, 0x80, 0x04, 0x80, 0x04, 0x80, 0x04, 0x80, 0x04, 0x80, 0x04, 0x80, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar219[]={0x00, 0x00, 0xF0, 0x07, 0x80, 0x04, 0x80, 0x04, 0x80, 0x04, 0x80, 0x04, 0x80, 0x04, 0x90, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar220[]={0x00, 0x00, 0xF0, 0x07, 0x80, 0x04, 0x80, 0x04, 0x80, 0x04, 0x80, 0x04, 0x80, 0x04, 0x80, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar221[]={0x00, 0x00, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0xE0, 0x03, 0x00, 0x00};
const unsigned char MicroTech10FChar222[]={0x00, 0x00, 0xF0, 0x07, 0x80, 0x00, 0xF0, 0x07, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0xF0, 0x07};
const unsigned char MicroTech10FChar223[]={0x00, 0x00, 0xF0, 0x04, 0x90, 0x03, 0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar224[]={0x00, 0x00, 0x10, 0x07, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar225[]={0x00, 0x00, 0xF0, 0x07, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x10, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar226[]={0x00, 0x00, 0xF0, 0x07, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x70, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar227[]={0xF0, 0x07, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar228[]={0xF0, 0x27, 0x10, 0x24, 0x10, 0x24, 0x10, 0x24, 0x10, 0x24, 0x10, 0x24, 0x10, 0x24, 0xF0, 0x3F, 0x00, 0x00};
const unsigned char MicroTech10FChar229[]={0x00, 0x00, 0xF0, 0x07, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x00, 0x00};
const unsigned char MicroTech10FChar230[]={0x00, 0x00, 0x00, 0x04, 0x30, 0x06, 0x60, 0x03, 0xC0, 0x01, 0xF0, 0x07, 0xC0, 0x01, 0x60, 0x03, 0x30, 0x06, 0x00, 0x04};
const unsigned char MicroTech10FChar231[]={0x00, 0x00, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x70, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar232[]={0x00, 0x00, 0xF0, 0x03, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar233[]={0x00, 0x00, 0xF0, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar234[]={0x00, 0x00, 0xF0, 0x07, 0xC0, 0x01, 0x60, 0x03, 0x30, 0x02, 0x10, 0x04, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar235[]={0x00, 0x00, 0x00, 0x06, 0x80, 0x03, 0xE0, 0x00, 0x30, 0x00, 0xE0, 0x00, 0x80, 0x03, 0x00, 0x06, 0x00, 0x00};
const unsigned char MicroTech10FChar236[]={0x00, 0x00, 0xF0, 0x07, 0x10, 0x00, 0x10, 0x00, 0xE0, 0x07, 0x10, 0x00, 0x10, 0x00, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar237[]={0x00, 0x00, 0xF0, 0x07, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar238[]={0xF0, 0x07, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar239[]={0xF0, 0x07, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar240[]={0xF0, 0x3F, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar241[]={0xF0, 0x07, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x00, 0x00};
const unsigned char MicroTech10FChar242[]={0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0xF0, 0x07, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar243[]={0x00, 0x00, 0xF0, 0x23, 0x00, 0x24, 0x00, 0x24, 0x00, 0x24, 0x00, 0x24, 0x00, 0x24, 0xF0, 0x3F, 0x00, 0x00};
const unsigned char MicroTech10FChar244[]={0x00, 0x00, 0xF0, 0x07, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0xF0, 0x3F, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0xF0, 0x07};
const unsigned char MicroTech10FChar245[]={0x10, 0x00, 0x30, 0x04, 0x60, 0x02, 0x80, 0x01, 0xC0, 0x01, 0x60, 0x02, 0x30, 0x04, 0x00, 0x00, 0x00, 0x00};
const unsigned char MicroTech10FChar246[]={0x00, 0x00, 0xF0, 0x03, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0xF0, 0x07, 0x00, 0x04, 0x00, 0x00};
const unsigned char MicroTech10FChar247[]={0x00, 0x00, 0x70, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar248[]={0x00, 0x00, 0xF0, 0x03, 0x00, 0x04, 0x00, 0x04, 0xF0, 0x07, 0x00, 0x04, 0x00, 0x04, 0xF0, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar249[]={0x00, 0x00, 0xF0, 0x03, 0x00, 0x04, 0x00, 0x04, 0xF0, 0x07, 0x00, 0x04, 0x00, 0x04, 0xF0, 0x07, 0x00, 0x04, 0x00, 0x00};
const unsigned char MicroTech10FChar250[]={0x10, 0x00, 0x10, 0x00, 0xF0, 0x07, 0x80, 0x04, 0x80, 0x04, 0x80, 0x04, 0x80, 0x04, 0x80, 0x04, 0x80, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar251[]={0x00, 0x00, 0xF0, 0x07, 0x80, 0x04, 0x80, 0x04, 0x80, 0x04, 0x80, 0x04, 0x80, 0x04, 0x90, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar252[]={0x00, 0x00, 0xF0, 0x07, 0x80, 0x04, 0x80, 0x04, 0x80, 0x04, 0x80, 0x04, 0x80, 0x04, 0x80, 0x07, 0x00, 0x00};
const unsigned char MicroTech10FChar253[]={0x00, 0x00, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0x90, 0x04, 0xE0, 0x03, 0x00, 0x00};
const unsigned char MicroTech10FChar254[]={0x00, 0x00, 0xF0, 0x07, 0x80, 0x00, 0xF0, 0x07, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0xF0, 0x07};
const unsigned char MicroTech10FChar255[]={0x00, 0x00, 0xF0, 0x04, 0x90, 0x03, 0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0xF0, 0x07, 0x00, 0x00};
const struct _FontInfo MicroTech10FontInfo[]={
{MicroTech10FChar000, 7, 14}, /* [0] */
{MicroTech10FChar001, 7, 14}, /* [1] */
{MicroTech10FChar002, 7, 14}, /* [2] */
{MicroTech10FChar003, 7, 14}, /* [3] */
{MicroTech10FChar004, 7, 14}, /* [4] */
{MicroTech10FChar005, 7, 14}, /* [5] */
{MicroTech10FChar006, 7, 14}, /* [6] */
{MicroTech10FChar007, 7, 14}, /* [7] */
{MicroTech10FChar008, 7, 14}, /* [8] */
{MicroTech10FChar009, 7, 14}, /* [9] */
{MicroTech10FChar010, 7, 14}, /* [10] */
{MicroTech10FChar011, 7, 14}, /* [11] */
{MicroTech10FChar012, 7, 14}, /* [12] */
{MicroTech10FChar013, 7, 14}, /* [13] */
{MicroTech10FChar014, 7, 14}, /* [14] */
{MicroTech10FChar015, 7, 14}, /* [15] */
{MicroTech10FChar016, 7, 14}, /* [16] */
{MicroTech10FChar017, 7, 14}, /* [17] */
{MicroTech10FChar018, 7, 14}, /* [18] */
{MicroTech10FChar019, 7, 14}, /* [19] */
{MicroTech10FChar020, 7, 14}, /* [20] */
{MicroTech10FChar021, 7, 14}, /* [21] */
{MicroTech10FChar022, 7, 14}, /* [22] */
{MicroTech10FChar023, 7, 14}, /* [23] */
{MicroTech10FChar024, 7, 14}, /* [24] */
{MicroTech10FChar025, 7, 14}, /* [25] */
{MicroTech10FChar026, 7, 14}, /* [26] */
{MicroTech10FChar027, 7, 14}, /* [27] */
{MicroTech10FChar028, 7, 14}, /* [28] */
{MicroTech10FChar029, 7, 14}, /* [29] */
{MicroTech10FChar030, 7, 14}, /* [30] */
{MicroTech10FChar031, 7, 14}, /* [31] */
{MicroTech10FChar032, 5, 14}, /* */
{MicroTech10FChar033, 3, 14}, /* ! */
{MicroTech10FChar034, 5, 14}, /* " */
{MicroTech10FChar035, 8, 14}, /* # */
{MicroTech10FChar036, 9, 14}, /* $ */
{MicroTech10FChar037, 9, 14}, /* % */
{MicroTech10FChar038, 9, 14}, /* & */
{MicroTech10FChar039, 3, 14}, /* ' */
{MicroTech10FChar040, 4, 14}, /* ( */
{MicroTech10FChar041, 4, 14}, /* ) */
{MicroTech10FChar042, 8, 14}, /* * */
{MicroTech10FChar043, 5, 14}, /* + */
{MicroTech10FChar044, 3, 14}, /* , */
{MicroTech10FChar045, 5, 14}, /* - */
{MicroTech10FChar046, 3, 14}, /* . */
{MicroTech10FChar047, 9, 14}, /* / */
{MicroTech10FChar048, 9, 14}, /* 0 */
{MicroTech10FChar049, 4, 14}, /* 1 */
{MicroTech10FChar050, 9, 14}, /* 2 */
{MicroTech10FChar051, 9, 14}, /* 3 */
{MicroTech10FChar052, 9, 14}, /* 4 */
{MicroTech10FChar053, 9, 14}, /* 5 */
{MicroTech10FChar054, 9, 14}, /* 6 */
{MicroTech10FChar055, 9, 14}, /* 7 */
{MicroTech10FChar056, 9, 14}, /* 8 */
{MicroTech10FChar057, 9, 14}, /* 9 */
{MicroTech10FChar058, 3, 14}, /* : */
{MicroTech10FChar059, 3, 14}, /* ; */
{MicroTech10FChar060, 6, 14}, /* < */
{MicroTech10FChar061, 5, 14}, /* = */
{MicroTech10FChar062, 6, 14}, /* > */
{MicroTech10FChar063, 8, 14}, /* ? */
{MicroTech10FChar064, 9, 14}, /* @ */
{MicroTech10FChar065, 9, 14}, /* A */
{MicroTech10FChar066, 9, 14}, /* B */
{MicroTech10FChar067, 9, 14}, /* C */
{MicroTech10FChar068, 9, 14}, /* D */
{MicroTech10FChar069, 9, 14}, /* E */
{MicroTech10FChar070, 9, 14}, /* F */
{MicroTech10FChar071, 9, 14}, /* G */
{MicroTech10FChar072, 9, 14}, /* H */
{MicroTech10FChar073, 3, 14}, /* I */
{MicroTech10FChar074, 6, 14}, /* J */
{MicroTech10FChar075, 8, 14}, /* K */
{MicroTech10FChar076, 3, 14}, /* L */
{MicroTech10FChar077, 9, 14}, /* M */
{MicroTech10FChar078, 9, 14}, /* N */
{MicroTech10FChar079, 9, 14}, /* O */
{MicroTech10FChar080, 9, 14}, /* P */
{MicroTech10FChar081, 9, 14}, /* Q */
{MicroTech10FChar082, 9, 14}, /* R */
{MicroTech10FChar083, 9, 14}, /* S */
{MicroTech10FChar084, 9, 14}, /* T */
{MicroTech10FChar085, 9, 14}, /* U */
{MicroTech10FChar086, 9, 14}, /* V */
{MicroTech10FChar087, 9, 14}, /* W */
{MicroTech10FChar088, 9, 14}, /* X */
{MicroTech10FChar089, 9, 14}, /* Y */
{MicroTech10FChar090, 9, 14}, /* Z */
{MicroTech10FChar091, 4, 14}, /* [ */
{MicroTech10FChar092, 9, 14}, /* \ */
{MicroTech10FChar093, 4, 14}, /* ] */
{MicroTech10FChar094, 7, 14}, /* ^ */
{MicroTech10FChar095, 5, 14}, /* _ */
{MicroTech10FChar096, 3, 14}, /* ` */
{MicroTech10FChar097, 9, 14}, /* a */
{MicroTech10FChar098, 9, 14}, /* b */
{MicroTech10FChar099, 9, 14}, /* c */
{MicroTech10FChar100, 9, 14}, /* d */
{MicroTech10FChar101, 9, 14}, /* e */
{MicroTech10FChar102, 9, 14}, /* f */
{MicroTech10FChar103, 9, 14}, /* g */
{MicroTech10FChar104, 9, 14}, /* h */
{MicroTech10FChar105, 3, 14}, /* i */
{MicroTech10FChar106, 6, 14}, /* j */
{MicroTech10FChar107, 8, 14}, /* k */
{MicroTech10FChar108, 3, 14}, /* l */
{MicroTech10FChar109, 9, 14}, /* m */
{MicroTech10FChar110, 9, 14}, /* n */
{MicroTech10FChar111, 9, 14}, /* o */
{MicroTech10FChar112, 9, 14}, /* p */
{MicroTech10FChar113, 9, 14}, /* q */
{MicroTech10FChar114, 9, 14}, /* r */
{MicroTech10FChar115, 9, 14}, /* s */
{MicroTech10FChar116, 9, 14}, /* t */
{MicroTech10FChar117, 9, 14}, /* u */
{MicroTech10FChar118, 9, 14}, /* v */
{MicroTech10FChar119, 9, 14}, /* w */
{MicroTech10FChar120, 9, 14}, /* x */
{MicroTech10FChar121, 9, 14}, /* y */
{MicroTech10FChar122, 9, 14}, /* z */
{MicroTech10FChar123, 4, 14}, /* { */
{MicroTech10FChar124, 3, 14}, /* | */
{MicroTech10FChar125, 4, 14}, /* } */
{MicroTech10FChar126, 7, 14}, /* ~ */
{MicroTech10FChar127, 7, 14}, /* [127] */
{MicroTech10FChar128, 7, 14}, /* [128] */
{MicroTech10FChar129, 7, 14}, /* [129] */
{MicroTech10FChar130, 3, 14}, /* [130] */
{MicroTech10FChar131, 7, 14}, /* [131] */
{MicroTech10FChar132, 5, 14}, /* [132] */
{MicroTech10FChar133, 8, 14}, /* [133] */
{MicroTech10FChar134, 7, 14}, /* [134] */
{MicroTech10FChar135, 7, 14}, /* [135] */
{MicroTech10FChar136, 7, 14}, /* [136] */
{MicroTech10FChar137, 7, 14}, /* [137] */
{MicroTech10FChar138, 10, 14}, /* [138] */
{MicroTech10FChar139, 6, 14}, /* [139] */
{MicroTech10FChar140, 10, 14}, /* [140] */
{MicroTech10FChar141, 7, 14}, /* [141] */
{MicroTech10FChar142, 7, 14}, /* [142] */
{MicroTech10FChar143, 7, 14}, /* [143] */
{MicroTech10FChar144, 7, 14}, /* [144] */
{MicroTech10FChar145, 3, 14}, /* [145] */
{MicroTech10FChar146, 3, 14}, /* [146] */
{MicroTech10FChar147, 5, 14}, /* [147] */
{MicroTech10FChar148, 5, 14}, /* [148] */
{MicroTech10FChar149, 7, 14}, /* [149] */
{MicroTech10FChar150, 5, 14}, /* [150] */
{MicroTech10FChar151, 8, 14}, /* [151] */
{MicroTech10FChar152, 7, 14}, /* [152] */
{MicroTech10FChar153, 7, 14}, /* [153] */
{MicroTech10FChar154, 10, 14}, /* [154] */
{MicroTech10FChar155, 6, 14}, /* [155] */
{MicroTech10FChar156, 10, 14}, /* [156] */
{MicroTech10FChar157, 7, 14}, /* [157] */
{MicroTech10FChar158, 7, 14}, /* [158] */
{MicroTech10FChar159, 9, 14}, /* [159] */
{MicroTech10FChar160, 5, 14}, /* [160] */
{MicroTech10FChar161, 9, 14}, /* [161] */
{MicroTech10FChar162, 9, 14}, /* [162] */
{MicroTech10FChar163, 6, 14}, /* [163] */
{MicroTech10FChar164, 7, 14}, /* [164] */
{MicroTech10FChar165, 9, 14}, /* [165] */
{MicroTech10FChar166, 7, 14}, /* [166] */
{MicroTech10FChar167, 7, 14}, /* [167] */
{MicroTech10FChar168, 9, 14}, /* [168] */
{MicroTech10FChar169, 7, 14}, /* [169] */
{MicroTech10FChar170, 9, 14}, /* [170] */
{MicroTech10FChar171, 6, 14}, /* [171] */
{MicroTech10FChar172, 8, 14}, /* [172] */
{MicroTech10FChar173, 5, 14}, /* [173] */
{MicroTech10FChar174, 7, 14}, /* [174] */
{MicroTech10FChar175, 3, 14}, /* [175] */
{MicroTech10FChar176, 7, 14}, /* [176] */
{MicroTech10FChar177, 5, 14}, /* [177] */
{MicroTech10FChar178, 3, 14}, /* [178] */
{MicroTech10FChar179, 3, 14}, /* [179] */
{MicroTech10FChar180, 9, 14}, /* [180] */
{MicroTech10FChar181, 7, 14}, /* [181] */
{MicroTech10FChar182, 7, 14}, /* [182] */
{MicroTech10FChar183, 3, 14}, /* [183] */
{MicroTech10FChar184, 9, 14}, /* [184] */
{MicroTech10FChar185, 8, 14}, /* [185] */
{MicroTech10FChar186, 9, 14}, /* [186] */
{MicroTech10FChar187, 6, 14}, /* [187] */
{MicroTech10FChar188, 6, 14}, /* [188] */
{MicroTech10FChar189, 9, 14}, /* [189] */
{MicroTech10FChar190, 9, 14}, /* [190] */
{MicroTech10FChar191, 3, 14}, /* [191] */
{MicroTech10FChar192, 9, 14}, /* [192] */
{MicroTech10FChar193, 9, 14}, /* [193] */
{MicroTech10FChar194, 9, 14}, /* [194] */
{MicroTech10FChar195, 9, 14}, /* [195] */
{MicroTech10FChar196, 9, 14}, /* [196] */
{MicroTech10FChar197, 9, 14}, /* [197] */
{MicroTech10FChar198, 10, 14}, /* [198] */
{MicroTech10FChar199, 9, 14}, /* [199] */
{MicroTech10FChar200, 9, 14}, /* [200] */
{MicroTech10FChar201, 9, 14}, /* [201] */
{MicroTech10FChar202, 8, 14}, /* [202] */
{MicroTech10FChar203, 9, 14}, /* [203] */
{MicroTech10FChar204, 9, 14}, /* [204] */
{MicroTech10FChar205, 9, 14}, /* [205] */
{MicroTech10FChar206, 9, 14}, /* [206] */
{MicroTech10FChar207, 9, 14}, /* [207] */
{MicroTech10FChar208, 9, 14}, /* [208] */
{MicroTech10FChar209, 9, 14}, /* [209] */
{MicroTech10FChar210, 9, 14}, /* [210] */
{MicroTech10FChar211, 9, 14}, /* [211] */
{MicroTech10FChar212, 10, 14}, /* [212] */
{MicroTech10FChar213, 9, 14}, /* [213] */
{MicroTech10FChar214, 10, 14}, /* [214] */
{MicroTech10FChar215, 9, 14}, /* [215] */
{MicroTech10FChar216, 9, 14}, /* [216] */
{MicroTech10FChar217, 10, 14}, /* [217] */
{MicroTech10FChar218, 10, 14}, /* [218] */
{MicroTech10FChar219, 9, 14}, /* [219] */
{MicroTech10FChar220, 9, 14}, /* [220] */
{MicroTech10FChar221, 9, 14}, /* [221] */
{MicroTech10FChar222, 10, 14}, /* [222] */
{MicroTech10FChar223, 9, 14}, /* [223] */
{MicroTech10FChar224, 9, 14}, /* [224] */
{MicroTech10FChar225, 9, 14}, /* [225] */
{MicroTech10FChar226, 9, 14}, /* [226] */
{MicroTech10FChar227, 9, 14}, /* [227] */
{MicroTech10FChar228, 9, 14}, /* [228] */
{MicroTech10FChar229, 9, 14}, /* [229] */
{MicroTech10FChar230, 10, 14}, /* [230] */
{MicroTech10FChar231, 9, 14}, /* [231] */
{MicroTech10FChar232, 9, 14}, /* [232] */
{MicroTech10FChar233, 9, 14}, /* [233] */
{MicroTech10FChar234, 8, 14}, /* [234] */
{MicroTech10FChar235, 9, 14}, /* [235] */
{MicroTech10FChar236, 9, 14}, /* [236] */
{MicroTech10FChar237, 9, 14}, /* [237] */
{MicroTech10FChar238, 9, 14}, /* [238] */
{MicroTech10FChar239, 9, 14}, /* [239] */
{MicroTech10FChar240, 9, 14}, /* [240] */
{MicroTech10FChar241, 9, 14}, /* [241] */
{MicroTech10FChar242, 9, 14}, /* [242] */
{MicroTech10FChar243, 9, 14}, /* [243] */
{MicroTech10FChar244, 10, 14}, /* [244] */
{MicroTech10FChar245, 9, 14}, /* [245] */
{MicroTech10FChar246, 10, 14}, /* [246] */
{MicroTech10FChar247, 9, 14}, /* [247] */
{MicroTech10FChar248, 9, 14}, /* [248] */
{MicroTech10FChar249, 10, 14}, /* [249] */
{MicroTech10FChar250, 10, 14}, /* [250] */
{MicroTech10FChar251, 9, 14}, /* [251] */
{MicroTech10FChar252, 9, 14}, /* [252] */
{MicroTech10FChar253, 9, 14}, /* [253] */
{MicroTech10FChar254, 10, 14}, /* [254] */
{MicroTech10FChar255, 9, 14}, /* [255] */
{NULL, 0, 0}};
#endif
|
fa316904e19c3d03b748b6329637a80ce61220a1
|
a411a55762de11dc2c9d913ff33d2f1477ac02cf
|
/lte/gateway/c/core/oai/include/TrackingAreaIdentity.h
|
689cfd97f8d8c3bf6e791b8e39705ac0716c45b7
|
[
"BSD-3-Clause"
] |
permissive
|
magma/magma
|
0dc48c1513d9968bd05fb7589f302c192b7c0f94
|
0e1d895dfe625681229e181fbc2dbad83e13c5cb
|
refs/heads/master
| 2023-09-04T09:31:56.140395
| 2023-08-29T13:54:49
| 2023-08-29T13:54:49
| 170,803,235
| 1,219
| 525
|
NOASSERTION
| 2023-09-07T17:45:42
| 2019-02-15T04:46:24
|
C++
|
UTF-8
|
C
| false
| false
| 5,528
|
h
|
TrackingAreaIdentity.h
|
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the terms found in the LICENSE file in the root of this source tree.
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include "lte/gateway/c/core/oai/lib/3gpp/3gpp_23.003.h"
#ifndef TRACKING_AREA_IDENTITY_SEEN
#define TRACKING_AREA_IDENTITY_SEEN
#define TRACKING_AREA_IDENTITY_MINIMUM_LENGTH 6
#define TRACKING_AREA_IDENTITY_MAXIMUM_LENGTH 6
// currently maximum num of TAIs is 16, but it can be upto 256
#define TRACKING_AREA_IDENTITY_MAX_NUM_OF_TAIS 16
#define INVALID_TAC_0000 \
(uint16_t)0x0000 /*!< \brief The following are reserved hexadecimal values \
of the TAC: 0000, and FFFE. */
#define INVALID_TAC_FFFE \
(uint16_t)0xFFFE /*!< \brief The following are reserved hexadecimal values \
of the TAC: 0000, and FFFE. */
typedef uint16_t tac_t; /*!< \brief Tracking Area Code (TAC) is a fixed length
code (of 2 octets) identifying a Tracking Area within
a PLMN. This part of the tracking area identification
shall be coded using a full hexadecimal
representation. The following are reserved
hexadecimal values of the TAC: 0000, and FFFE. */
typedef struct tai_s {
plmn_t plmn;
tac_t tac;
} tai_t;
typedef struct paging_tai_list_s {
uint8_t numoftac;
tai_t tai_list[TRACKING_AREA_IDENTITY_MAX_NUM_OF_TAIS];
} paging_tai_list_t;
/* Checks Mobile Country Code equality */
#define MCCS_ARE_EQUAL(n1, n2) \
(((n1).mcc_digit1 == (n2).mcc_digit1) && \
((n1).mcc_digit2 == (n2).mcc_digit2) && \
((n1).mcc_digit3 == (n2).mcc_digit3))
/* Checks Mobile Network Code equality */
#define MNCS_ARE_EQUAL(n1, n2) \
(((n1).mnc_digit1 == (n2).mnc_digit1) && \
((n1).mnc_digit2 == (n2).mnc_digit2) && \
((n1).mnc_digit3 == (n2).mnc_digit3))
/* Checks PLMNs equality */
#define PLMNS_ARE_EQUAL(p1, p2) \
((MCCS_ARE_EQUAL((p1), (p2))) && (MNCS_ARE_EQUAL((p1), (p2))))
// MCC digit 2 MCC digit 1 octet 1
// MNC digit 3 MCC digit 3 octet 2
// MNC digit 2 MNC digit 1 octet 3
// The coding of this field is the responsibility of each administration but BCD
// coding shall be used. The MNC shall consist of 2 or 3 digits. If a network
// operator decides to use only two digits in the MNC, bits 5 to 8 of octet 2
// shall be coded as "1111".
#define PLMN_FMT "%c%c%c.%c%c%c"
#define PLMN_ARG(PlMn_PtR) \
(char)((PlMn_PtR)->mcc_digit1 + 0x30), \
(char)((PlMn_PtR)->mcc_digit2 + 0x30), \
(char)((PlMn_PtR)->mcc_digit3 + 0x30), \
(char)((PlMn_PtR)->mnc_digit1 + 0x30), \
(char)((PlMn_PtR)->mnc_digit2 + 0x30), \
(((PlMn_PtR)->mnc_digit3) == 0x0f) \
? ' ' \
: (char)((PlMn_PtR)->mnc_digit3 + 0x30)
/* Checks PLMN validity !?! */
#define PLMN_IS_VALID(plmn) \
(((plmn).mcc_digit1 & (plmn).mcc_digit2 & (plmn).mcc_digit3) != 0x0F)
/* Checks TAIs equality */
#define TAIS_ARE_EQUAL(t1, t2) \
((PLMNS_ARE_EQUAL((t1), (t2))) && ((t1).tac == (t2).tac))
#define TAC_FMT "0x%" PRIx16
#define TAI_FMT PLMN_FMT "-" TAC_FMT
#define TAI_ARG(tAi_PtR) PLMN_ARG(&((tAi_PtR)->plmn)), (tAi_PtR)->tac
/* Checks TAC validity */
#define TAC_IS_VALID(tac) \
(((tac) != INVALID_TAC_0000) && ((tac) != INVALID_TAC_FFFE))
/* Checks TAI validity */
#define TAI_IS_VALID(tai) (PLMN_IS_VALID((tai).plmn) && TAC_IS_VALID((tai).tac))
// defined in 24.008_xml.h
#if !defined(MOBILE_COUNTRY_CODE_ATTR_XML_STR)
#define MOBILE_COUNTRY_CODE_ATTR_XML_STR "mcc"
#endif
// defined in 24.008_xml.h
#if !defined(MOBILE_NETWORK_CODE_ATTR_XML_STR)
#define MOBILE_NETWORK_CODE_ATTR_XML_STR "mnc"
#endif
// Copy TAIs
#define COPY_TAI(tai_dst, tai_src) \
do { \
tai_dst.plmn.mcc_digit2 = tai_src.plmn.mcc_digit2; \
tai_dst.plmn.mcc_digit1 = tai_src.plmn.mcc_digit1; \
tai_dst.plmn.mnc_digit3 = tai_src.plmn.mnc_digit3; \
tai_dst.plmn.mcc_digit3 = tai_src.plmn.mcc_digit3; \
tai_dst.plmn.mnc_digit2 = tai_src.plmn.mnc_digit2; \
tai_dst.plmn.mnc_digit1 = tai_src.plmn.mnc_digit1; \
tai_dst.tac = tai_src.tac; \
} while (0)
#ifdef __cplusplus
extern "C" {
#endif
int encode_tracking_area_identity(tai_t* tai, uint8_t iei, uint8_t* buffer,
uint32_t len);
int decode_tracking_area_identity(tai_t* tai, uint8_t iei, uint8_t* buffer,
uint32_t len);
#ifdef __cplusplus
}
#endif
void clear_tai(tai_t* const tai);
#endif /* TRACKING AREA IDENTITY_SEEN */
|
f9ba44f77be7b790b244b0f088946adde5b7cea8
|
3a30cfb29aac91e5c75d4dbcefddfd1f34d5f18c
|
/c-tests/new/issue366.c
|
c832493cd87ec262f8e7e6ad8e4b01b6ee31877e
|
[
"MIT",
"MPL-1.0",
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0",
"LGPL-2.0-only"
] |
permissive
|
vnmakarov/mir
|
a1725bc9c828e8580df6b7ae94e04175db8abe93
|
928e28fb3acaa50d051a906e76a55cc48a556574
|
refs/heads/master
| 2023-09-02T11:10:37.434581
| 2023-08-25T19:25:40
| 2023-08-25T19:25:40
| 178,932,492
| 2,005
| 156
|
MIT
| 2023-08-01T20:29:59
| 2019-04-01T19:24:56
|
C
|
UTF-8
|
C
| false
| false
| 75
|
c
|
issue366.c
|
#define _00i0d00(E, X) X
_00i0d00(,()
#define _00i0d00(E, X)0)
_00i0d00(,)
|
f82bda314eddca011fac2685c5f0bc9cab467a06
|
ac3281345cb13c00e0150b4cfde5a6fffa3d0e0b
|
/src/MagnumExternal/Vulkan/flextVkGlobal.h
|
f762c9f981aa42f117695354c2f61485ac1915e9
|
[
"MIT"
] |
permissive
|
mosra/magnum
|
dc2fc08d634dceaf454c0b8190d2ebd530bb8fa9
|
c9a2752545aa2aa8b7db4879834d3998c6cac655
|
refs/heads/master
| 2023-09-03T21:02:39.001932
| 2023-09-03T13:49:25
| 2023-09-03T16:07:04
| 1,182,756
| 4,747
| 535
|
NOASSERTION
| 2023-07-23T07:36:34
| 2010-12-19T22:19:59
|
C++
|
UTF-8
|
C
| false
| false
| 23,723
|
h
|
flextVkGlobal.h
|
#ifndef _flextVkGlobal_h_
#define _flextVkGlobal_h_
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019,
2020, 2021, 2022, 2023 Vladimír Vondruš <mosra@centrum.cz>
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 "MagnumExternal/Vulkan/flextVk.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef DOXYGEN_GENERATING_OUTPUT /* So the macro names are preserved in the docs */
/* Per-instance function pointers */
extern FLEXTVK_EXPORT FlextVkInstance flextVkInstance;
/* VK_EXT_debug_marker */
/* VK_EXT_debug_report */
#define vkCreateDebugReportCallbackEXT flextVkInstance.CreateDebugReportCallbackEXT
#define vkDebugReportMessageEXT flextVkInstance.DebugReportMessageEXT
#define vkDestroyDebugReportCallbackEXT flextVkInstance.DestroyDebugReportCallbackEXT
/* VK_EXT_debug_utils */
#define vkCreateDebugUtilsMessengerEXT flextVkInstance.CreateDebugUtilsMessengerEXT
#define vkDestroyDebugUtilsMessengerEXT flextVkInstance.DestroyDebugUtilsMessengerEXT
#define vkSubmitDebugUtilsMessageEXT flextVkInstance.SubmitDebugUtilsMessageEXT
/* VK_EXT_extended_dynamic_state */
/* VK_EXT_host_query_reset */
/* VK_KHR_acceleration_structure */
/* VK_KHR_bind_memory2 */
/* VK_KHR_buffer_device_address */
/* VK_KHR_copy_commands2 */
/* VK_KHR_create_renderpass2 */
/* VK_KHR_deferred_host_operations */
/* VK_KHR_descriptor_update_template */
/* VK_KHR_device_group */
/* VK_KHR_device_group_creation */
#define vkEnumeratePhysicalDeviceGroupsKHR flextVkInstance.EnumeratePhysicalDeviceGroupsKHR
/* VK_KHR_draw_indirect_count */
/* VK_KHR_external_fence_capabilities */
#define vkGetPhysicalDeviceExternalFencePropertiesKHR flextVkInstance.GetPhysicalDeviceExternalFencePropertiesKHR
/* VK_KHR_external_memory_capabilities */
#define vkGetPhysicalDeviceExternalBufferPropertiesKHR flextVkInstance.GetPhysicalDeviceExternalBufferPropertiesKHR
/* VK_KHR_external_semaphore_capabilities */
#define vkGetPhysicalDeviceExternalSemaphorePropertiesKHR flextVkInstance.GetPhysicalDeviceExternalSemaphorePropertiesKHR
/* VK_KHR_get_memory_requirements2 */
/* VK_KHR_get_physical_device_properties2 */
#define vkGetPhysicalDeviceFeatures2KHR flextVkInstance.GetPhysicalDeviceFeatures2KHR
#define vkGetPhysicalDeviceFormatProperties2KHR flextVkInstance.GetPhysicalDeviceFormatProperties2KHR
#define vkGetPhysicalDeviceImageFormatProperties2KHR flextVkInstance.GetPhysicalDeviceImageFormatProperties2KHR
#define vkGetPhysicalDeviceMemoryProperties2KHR flextVkInstance.GetPhysicalDeviceMemoryProperties2KHR
#define vkGetPhysicalDeviceProperties2KHR flextVkInstance.GetPhysicalDeviceProperties2KHR
#define vkGetPhysicalDeviceQueueFamilyProperties2KHR flextVkInstance.GetPhysicalDeviceQueueFamilyProperties2KHR
#define vkGetPhysicalDeviceSparseImageFormatProperties2KHR flextVkInstance.GetPhysicalDeviceSparseImageFormatProperties2KHR
/* VK_KHR_maintenance1 */
/* VK_KHR_maintenance3 */
/* VK_KHR_ray_tracing_pipeline */
/* VK_KHR_sampler_ycbcr_conversion */
/* VK_KHR_timeline_semaphore */
/* VK_VERSION_1_0 */
#define vkCreateDevice flextVkInstance.CreateDevice
#define vkDestroyInstance flextVkInstance.DestroyInstance
#define vkEnumerateDeviceExtensionProperties flextVkInstance.EnumerateDeviceExtensionProperties
#define vkEnumeratePhysicalDevices flextVkInstance.EnumeratePhysicalDevices
#define vkGetDeviceProcAddr flextVkInstance.GetDeviceProcAddr
#define vkGetPhysicalDeviceFeatures flextVkInstance.GetPhysicalDeviceFeatures
#define vkGetPhysicalDeviceFormatProperties flextVkInstance.GetPhysicalDeviceFormatProperties
#define vkGetPhysicalDeviceImageFormatProperties flextVkInstance.GetPhysicalDeviceImageFormatProperties
#define vkGetPhysicalDeviceMemoryProperties flextVkInstance.GetPhysicalDeviceMemoryProperties
#define vkGetPhysicalDeviceProperties flextVkInstance.GetPhysicalDeviceProperties
#define vkGetPhysicalDeviceQueueFamilyProperties flextVkInstance.GetPhysicalDeviceQueueFamilyProperties
#define vkGetPhysicalDeviceSparseImageFormatProperties flextVkInstance.GetPhysicalDeviceSparseImageFormatProperties
/* VK_VERSION_1_1 */
#define vkEnumeratePhysicalDeviceGroups flextVkInstance.EnumeratePhysicalDeviceGroups
#define vkGetPhysicalDeviceExternalBufferProperties flextVkInstance.GetPhysicalDeviceExternalBufferProperties
#define vkGetPhysicalDeviceExternalFenceProperties flextVkInstance.GetPhysicalDeviceExternalFenceProperties
#define vkGetPhysicalDeviceExternalSemaphoreProperties flextVkInstance.GetPhysicalDeviceExternalSemaphoreProperties
#define vkGetPhysicalDeviceFeatures2 flextVkInstance.GetPhysicalDeviceFeatures2
#define vkGetPhysicalDeviceFormatProperties2 flextVkInstance.GetPhysicalDeviceFormatProperties2
#define vkGetPhysicalDeviceImageFormatProperties2 flextVkInstance.GetPhysicalDeviceImageFormatProperties2
#define vkGetPhysicalDeviceMemoryProperties2 flextVkInstance.GetPhysicalDeviceMemoryProperties2
#define vkGetPhysicalDeviceProperties2 flextVkInstance.GetPhysicalDeviceProperties2
#define vkGetPhysicalDeviceQueueFamilyProperties2 flextVkInstance.GetPhysicalDeviceQueueFamilyProperties2
#define vkGetPhysicalDeviceSparseImageFormatProperties2 flextVkInstance.GetPhysicalDeviceSparseImageFormatProperties2
/* VK_VERSION_1_2 */
/* Per-device function pointers */
extern FLEXTVK_EXPORT FlextVkDevice flextVkDevice;
/* VK_EXT_debug_marker */
#define vkCmdDebugMarkerBeginEXT flextVkDevice.CmdDebugMarkerBeginEXT
#define vkCmdDebugMarkerEndEXT flextVkDevice.CmdDebugMarkerEndEXT
#define vkCmdDebugMarkerInsertEXT flextVkDevice.CmdDebugMarkerInsertEXT
#define vkDebugMarkerSetObjectNameEXT flextVkDevice.DebugMarkerSetObjectNameEXT
#define vkDebugMarkerSetObjectTagEXT flextVkDevice.DebugMarkerSetObjectTagEXT
/* VK_EXT_debug_report */
/* VK_EXT_debug_utils */
#define vkCmdBeginDebugUtilsLabelEXT flextVkDevice.CmdBeginDebugUtilsLabelEXT
#define vkCmdEndDebugUtilsLabelEXT flextVkDevice.CmdEndDebugUtilsLabelEXT
#define vkCmdInsertDebugUtilsLabelEXT flextVkDevice.CmdInsertDebugUtilsLabelEXT
#define vkQueueBeginDebugUtilsLabelEXT flextVkDevice.QueueBeginDebugUtilsLabelEXT
#define vkQueueEndDebugUtilsLabelEXT flextVkDevice.QueueEndDebugUtilsLabelEXT
#define vkQueueInsertDebugUtilsLabelEXT flextVkDevice.QueueInsertDebugUtilsLabelEXT
#define vkSetDebugUtilsObjectNameEXT flextVkDevice.SetDebugUtilsObjectNameEXT
#define vkSetDebugUtilsObjectTagEXT flextVkDevice.SetDebugUtilsObjectTagEXT
/* VK_EXT_extended_dynamic_state */
#define vkCmdBindVertexBuffers2EXT flextVkDevice.CmdBindVertexBuffers2EXT
#define vkCmdSetCullModeEXT flextVkDevice.CmdSetCullModeEXT
#define vkCmdSetDepthBoundsTestEnableEXT flextVkDevice.CmdSetDepthBoundsTestEnableEXT
#define vkCmdSetDepthCompareOpEXT flextVkDevice.CmdSetDepthCompareOpEXT
#define vkCmdSetDepthTestEnableEXT flextVkDevice.CmdSetDepthTestEnableEXT
#define vkCmdSetDepthWriteEnableEXT flextVkDevice.CmdSetDepthWriteEnableEXT
#define vkCmdSetFrontFaceEXT flextVkDevice.CmdSetFrontFaceEXT
#define vkCmdSetPrimitiveTopologyEXT flextVkDevice.CmdSetPrimitiveTopologyEXT
#define vkCmdSetScissorWithCountEXT flextVkDevice.CmdSetScissorWithCountEXT
#define vkCmdSetStencilOpEXT flextVkDevice.CmdSetStencilOpEXT
#define vkCmdSetStencilTestEnableEXT flextVkDevice.CmdSetStencilTestEnableEXT
#define vkCmdSetViewportWithCountEXT flextVkDevice.CmdSetViewportWithCountEXT
/* VK_EXT_host_query_reset */
#define vkResetQueryPoolEXT flextVkDevice.ResetQueryPoolEXT
/* VK_KHR_acceleration_structure */
#define vkBuildAccelerationStructuresKHR flextVkDevice.BuildAccelerationStructuresKHR
#define vkCmdBuildAccelerationStructuresIndirectKHR flextVkDevice.CmdBuildAccelerationStructuresIndirectKHR
#define vkCmdBuildAccelerationStructuresKHR flextVkDevice.CmdBuildAccelerationStructuresKHR
#define vkCmdCopyAccelerationStructureKHR flextVkDevice.CmdCopyAccelerationStructureKHR
#define vkCmdCopyAccelerationStructureToMemoryKHR flextVkDevice.CmdCopyAccelerationStructureToMemoryKHR
#define vkCmdCopyMemoryToAccelerationStructureKHR flextVkDevice.CmdCopyMemoryToAccelerationStructureKHR
#define vkCmdWriteAccelerationStructuresPropertiesKHR flextVkDevice.CmdWriteAccelerationStructuresPropertiesKHR
#define vkCopyAccelerationStructureKHR flextVkDevice.CopyAccelerationStructureKHR
#define vkCopyAccelerationStructureToMemoryKHR flextVkDevice.CopyAccelerationStructureToMemoryKHR
#define vkCopyMemoryToAccelerationStructureKHR flextVkDevice.CopyMemoryToAccelerationStructureKHR
#define vkCreateAccelerationStructureKHR flextVkDevice.CreateAccelerationStructureKHR
#define vkDestroyAccelerationStructureKHR flextVkDevice.DestroyAccelerationStructureKHR
#define vkGetAccelerationStructureBuildSizesKHR flextVkDevice.GetAccelerationStructureBuildSizesKHR
#define vkGetAccelerationStructureDeviceAddressKHR flextVkDevice.GetAccelerationStructureDeviceAddressKHR
#define vkGetDeviceAccelerationStructureCompatibilityKHR flextVkDevice.GetDeviceAccelerationStructureCompatibilityKHR
#define vkWriteAccelerationStructuresPropertiesKHR flextVkDevice.WriteAccelerationStructuresPropertiesKHR
/* VK_KHR_bind_memory2 */
#define vkBindBufferMemory2KHR flextVkDevice.BindBufferMemory2KHR
#define vkBindImageMemory2KHR flextVkDevice.BindImageMemory2KHR
/* VK_KHR_buffer_device_address */
#define vkGetBufferDeviceAddressKHR flextVkDevice.GetBufferDeviceAddressKHR
#define vkGetBufferOpaqueCaptureAddressKHR flextVkDevice.GetBufferOpaqueCaptureAddressKHR
#define vkGetDeviceMemoryOpaqueCaptureAddressKHR flextVkDevice.GetDeviceMemoryOpaqueCaptureAddressKHR
/* VK_KHR_copy_commands2 */
#define vkCmdBlitImage2KHR flextVkDevice.CmdBlitImage2KHR
#define vkCmdCopyBuffer2KHR flextVkDevice.CmdCopyBuffer2KHR
#define vkCmdCopyBufferToImage2KHR flextVkDevice.CmdCopyBufferToImage2KHR
#define vkCmdCopyImage2KHR flextVkDevice.CmdCopyImage2KHR
#define vkCmdCopyImageToBuffer2KHR flextVkDevice.CmdCopyImageToBuffer2KHR
#define vkCmdResolveImage2KHR flextVkDevice.CmdResolveImage2KHR
/* VK_KHR_create_renderpass2 */
#define vkCmdBeginRenderPass2KHR flextVkDevice.CmdBeginRenderPass2KHR
#define vkCmdEndRenderPass2KHR flextVkDevice.CmdEndRenderPass2KHR
#define vkCmdNextSubpass2KHR flextVkDevice.CmdNextSubpass2KHR
#define vkCreateRenderPass2KHR flextVkDevice.CreateRenderPass2KHR
/* VK_KHR_deferred_host_operations */
#define vkCreateDeferredOperationKHR flextVkDevice.CreateDeferredOperationKHR
#define vkDeferredOperationJoinKHR flextVkDevice.DeferredOperationJoinKHR
#define vkDestroyDeferredOperationKHR flextVkDevice.DestroyDeferredOperationKHR
#define vkGetDeferredOperationMaxConcurrencyKHR flextVkDevice.GetDeferredOperationMaxConcurrencyKHR
#define vkGetDeferredOperationResultKHR flextVkDevice.GetDeferredOperationResultKHR
/* VK_KHR_descriptor_update_template */
#define vkCreateDescriptorUpdateTemplateKHR flextVkDevice.CreateDescriptorUpdateTemplateKHR
#define vkDestroyDescriptorUpdateTemplateKHR flextVkDevice.DestroyDescriptorUpdateTemplateKHR
#define vkUpdateDescriptorSetWithTemplateKHR flextVkDevice.UpdateDescriptorSetWithTemplateKHR
/* VK_KHR_device_group */
#define vkCmdDispatchBaseKHR flextVkDevice.CmdDispatchBaseKHR
#define vkCmdSetDeviceMaskKHR flextVkDevice.CmdSetDeviceMaskKHR
#define vkGetDeviceGroupPeerMemoryFeaturesKHR flextVkDevice.GetDeviceGroupPeerMemoryFeaturesKHR
/* VK_KHR_device_group_creation */
/* VK_KHR_draw_indirect_count */
#define vkCmdDrawIndexedIndirectCountKHR flextVkDevice.CmdDrawIndexedIndirectCountKHR
#define vkCmdDrawIndirectCountKHR flextVkDevice.CmdDrawIndirectCountKHR
/* VK_KHR_external_fence_capabilities */
/* VK_KHR_external_memory_capabilities */
/* VK_KHR_external_semaphore_capabilities */
/* VK_KHR_get_memory_requirements2 */
#define vkGetBufferMemoryRequirements2KHR flextVkDevice.GetBufferMemoryRequirements2KHR
#define vkGetImageMemoryRequirements2KHR flextVkDevice.GetImageMemoryRequirements2KHR
#define vkGetImageSparseMemoryRequirements2KHR flextVkDevice.GetImageSparseMemoryRequirements2KHR
/* VK_KHR_get_physical_device_properties2 */
/* VK_KHR_maintenance1 */
#define vkTrimCommandPoolKHR flextVkDevice.TrimCommandPoolKHR
/* VK_KHR_maintenance3 */
#define vkGetDescriptorSetLayoutSupportKHR flextVkDevice.GetDescriptorSetLayoutSupportKHR
/* VK_KHR_ray_tracing_pipeline */
#define vkCmdSetRayTracingPipelineStackSizeKHR flextVkDevice.CmdSetRayTracingPipelineStackSizeKHR
#define vkCmdTraceRaysIndirectKHR flextVkDevice.CmdTraceRaysIndirectKHR
#define vkCmdTraceRaysKHR flextVkDevice.CmdTraceRaysKHR
#define vkCreateRayTracingPipelinesKHR flextVkDevice.CreateRayTracingPipelinesKHR
#define vkGetRayTracingCaptureReplayShaderGroupHandlesKHR flextVkDevice.GetRayTracingCaptureReplayShaderGroupHandlesKHR
#define vkGetRayTracingShaderGroupHandlesKHR flextVkDevice.GetRayTracingShaderGroupHandlesKHR
#define vkGetRayTracingShaderGroupStackSizeKHR flextVkDevice.GetRayTracingShaderGroupStackSizeKHR
/* VK_KHR_sampler_ycbcr_conversion */
#define vkCreateSamplerYcbcrConversionKHR flextVkDevice.CreateSamplerYcbcrConversionKHR
#define vkDestroySamplerYcbcrConversionKHR flextVkDevice.DestroySamplerYcbcrConversionKHR
/* VK_KHR_timeline_semaphore */
#define vkGetSemaphoreCounterValueKHR flextVkDevice.GetSemaphoreCounterValueKHR
#define vkSignalSemaphoreKHR flextVkDevice.SignalSemaphoreKHR
#define vkWaitSemaphoresKHR flextVkDevice.WaitSemaphoresKHR
/* VK_VERSION_1_0 */
#define vkAllocateCommandBuffers flextVkDevice.AllocateCommandBuffers
#define vkAllocateDescriptorSets flextVkDevice.AllocateDescriptorSets
#define vkAllocateMemory flextVkDevice.AllocateMemory
#define vkBeginCommandBuffer flextVkDevice.BeginCommandBuffer
#define vkBindBufferMemory flextVkDevice.BindBufferMemory
#define vkBindImageMemory flextVkDevice.BindImageMemory
#define vkCmdBeginQuery flextVkDevice.CmdBeginQuery
#define vkCmdBeginRenderPass flextVkDevice.CmdBeginRenderPass
#define vkCmdBindDescriptorSets flextVkDevice.CmdBindDescriptorSets
#define vkCmdBindIndexBuffer flextVkDevice.CmdBindIndexBuffer
#define vkCmdBindPipeline flextVkDevice.CmdBindPipeline
#define vkCmdBindVertexBuffers flextVkDevice.CmdBindVertexBuffers
#define vkCmdBlitImage flextVkDevice.CmdBlitImage
#define vkCmdClearAttachments flextVkDevice.CmdClearAttachments
#define vkCmdClearColorImage flextVkDevice.CmdClearColorImage
#define vkCmdClearDepthStencilImage flextVkDevice.CmdClearDepthStencilImage
#define vkCmdCopyBuffer flextVkDevice.CmdCopyBuffer
#define vkCmdCopyBufferToImage flextVkDevice.CmdCopyBufferToImage
#define vkCmdCopyImage flextVkDevice.CmdCopyImage
#define vkCmdCopyImageToBuffer flextVkDevice.CmdCopyImageToBuffer
#define vkCmdCopyQueryPoolResults flextVkDevice.CmdCopyQueryPoolResults
#define vkCmdDispatch flextVkDevice.CmdDispatch
#define vkCmdDispatchIndirect flextVkDevice.CmdDispatchIndirect
#define vkCmdDraw flextVkDevice.CmdDraw
#define vkCmdDrawIndexed flextVkDevice.CmdDrawIndexed
#define vkCmdDrawIndexedIndirect flextVkDevice.CmdDrawIndexedIndirect
#define vkCmdDrawIndirect flextVkDevice.CmdDrawIndirect
#define vkCmdEndQuery flextVkDevice.CmdEndQuery
#define vkCmdEndRenderPass flextVkDevice.CmdEndRenderPass
#define vkCmdExecuteCommands flextVkDevice.CmdExecuteCommands
#define vkCmdFillBuffer flextVkDevice.CmdFillBuffer
#define vkCmdNextSubpass flextVkDevice.CmdNextSubpass
#define vkCmdPipelineBarrier flextVkDevice.CmdPipelineBarrier
#define vkCmdPushConstants flextVkDevice.CmdPushConstants
#define vkCmdResetEvent flextVkDevice.CmdResetEvent
#define vkCmdResetQueryPool flextVkDevice.CmdResetQueryPool
#define vkCmdResolveImage flextVkDevice.CmdResolveImage
#define vkCmdSetBlendConstants flextVkDevice.CmdSetBlendConstants
#define vkCmdSetDepthBias flextVkDevice.CmdSetDepthBias
#define vkCmdSetDepthBounds flextVkDevice.CmdSetDepthBounds
#define vkCmdSetEvent flextVkDevice.CmdSetEvent
#define vkCmdSetLineWidth flextVkDevice.CmdSetLineWidth
#define vkCmdSetScissor flextVkDevice.CmdSetScissor
#define vkCmdSetStencilCompareMask flextVkDevice.CmdSetStencilCompareMask
#define vkCmdSetStencilReference flextVkDevice.CmdSetStencilReference
#define vkCmdSetStencilWriteMask flextVkDevice.CmdSetStencilWriteMask
#define vkCmdSetViewport flextVkDevice.CmdSetViewport
#define vkCmdUpdateBuffer flextVkDevice.CmdUpdateBuffer
#define vkCmdWaitEvents flextVkDevice.CmdWaitEvents
#define vkCmdWriteTimestamp flextVkDevice.CmdWriteTimestamp
#define vkCreateBuffer flextVkDevice.CreateBuffer
#define vkCreateBufferView flextVkDevice.CreateBufferView
#define vkCreateCommandPool flextVkDevice.CreateCommandPool
#define vkCreateComputePipelines flextVkDevice.CreateComputePipelines
#define vkCreateDescriptorPool flextVkDevice.CreateDescriptorPool
#define vkCreateDescriptorSetLayout flextVkDevice.CreateDescriptorSetLayout
#define vkCreateEvent flextVkDevice.CreateEvent
#define vkCreateFence flextVkDevice.CreateFence
#define vkCreateFramebuffer flextVkDevice.CreateFramebuffer
#define vkCreateGraphicsPipelines flextVkDevice.CreateGraphicsPipelines
#define vkCreateImage flextVkDevice.CreateImage
#define vkCreateImageView flextVkDevice.CreateImageView
#define vkCreatePipelineCache flextVkDevice.CreatePipelineCache
#define vkCreatePipelineLayout flextVkDevice.CreatePipelineLayout
#define vkCreateQueryPool flextVkDevice.CreateQueryPool
#define vkCreateRenderPass flextVkDevice.CreateRenderPass
#define vkCreateSampler flextVkDevice.CreateSampler
#define vkCreateSemaphore flextVkDevice.CreateSemaphore
#define vkCreateShaderModule flextVkDevice.CreateShaderModule
#define vkDestroyBuffer flextVkDevice.DestroyBuffer
#define vkDestroyBufferView flextVkDevice.DestroyBufferView
#define vkDestroyCommandPool flextVkDevice.DestroyCommandPool
#define vkDestroyDescriptorPool flextVkDevice.DestroyDescriptorPool
#define vkDestroyDescriptorSetLayout flextVkDevice.DestroyDescriptorSetLayout
#define vkDestroyDevice flextVkDevice.DestroyDevice
#define vkDestroyEvent flextVkDevice.DestroyEvent
#define vkDestroyFence flextVkDevice.DestroyFence
#define vkDestroyFramebuffer flextVkDevice.DestroyFramebuffer
#define vkDestroyImage flextVkDevice.DestroyImage
#define vkDestroyImageView flextVkDevice.DestroyImageView
#define vkDestroyPipeline flextVkDevice.DestroyPipeline
#define vkDestroyPipelineCache flextVkDevice.DestroyPipelineCache
#define vkDestroyPipelineLayout flextVkDevice.DestroyPipelineLayout
#define vkDestroyQueryPool flextVkDevice.DestroyQueryPool
#define vkDestroyRenderPass flextVkDevice.DestroyRenderPass
#define vkDestroySampler flextVkDevice.DestroySampler
#define vkDestroySemaphore flextVkDevice.DestroySemaphore
#define vkDestroyShaderModule flextVkDevice.DestroyShaderModule
#define vkDeviceWaitIdle flextVkDevice.DeviceWaitIdle
#define vkEndCommandBuffer flextVkDevice.EndCommandBuffer
#define vkFlushMappedMemoryRanges flextVkDevice.FlushMappedMemoryRanges
#define vkFreeCommandBuffers flextVkDevice.FreeCommandBuffers
#define vkFreeDescriptorSets flextVkDevice.FreeDescriptorSets
#define vkFreeMemory flextVkDevice.FreeMemory
#define vkGetBufferMemoryRequirements flextVkDevice.GetBufferMemoryRequirements
#define vkGetDeviceMemoryCommitment flextVkDevice.GetDeviceMemoryCommitment
#define vkGetDeviceQueue flextVkDevice.GetDeviceQueue
#define vkGetEventStatus flextVkDevice.GetEventStatus
#define vkGetFenceStatus flextVkDevice.GetFenceStatus
#define vkGetImageMemoryRequirements flextVkDevice.GetImageMemoryRequirements
#define vkGetImageSparseMemoryRequirements flextVkDevice.GetImageSparseMemoryRequirements
#define vkGetImageSubresourceLayout flextVkDevice.GetImageSubresourceLayout
#define vkGetPipelineCacheData flextVkDevice.GetPipelineCacheData
#define vkGetQueryPoolResults flextVkDevice.GetQueryPoolResults
#define vkGetRenderAreaGranularity flextVkDevice.GetRenderAreaGranularity
#define vkInvalidateMappedMemoryRanges flextVkDevice.InvalidateMappedMemoryRanges
#define vkMapMemory flextVkDevice.MapMemory
#define vkMergePipelineCaches flextVkDevice.MergePipelineCaches
#define vkQueueBindSparse flextVkDevice.QueueBindSparse
#define vkQueueSubmit flextVkDevice.QueueSubmit
#define vkQueueWaitIdle flextVkDevice.QueueWaitIdle
#define vkResetCommandBuffer flextVkDevice.ResetCommandBuffer
#define vkResetCommandPool flextVkDevice.ResetCommandPool
#define vkResetDescriptorPool flextVkDevice.ResetDescriptorPool
#define vkResetEvent flextVkDevice.ResetEvent
#define vkResetFences flextVkDevice.ResetFences
#define vkSetEvent flextVkDevice.SetEvent
#define vkUnmapMemory flextVkDevice.UnmapMemory
#define vkUpdateDescriptorSets flextVkDevice.UpdateDescriptorSets
#define vkWaitForFences flextVkDevice.WaitForFences
/* VK_VERSION_1_1 */
#define vkBindBufferMemory2 flextVkDevice.BindBufferMemory2
#define vkBindImageMemory2 flextVkDevice.BindImageMemory2
#define vkCmdDispatchBase flextVkDevice.CmdDispatchBase
#define vkCmdSetDeviceMask flextVkDevice.CmdSetDeviceMask
#define vkCreateDescriptorUpdateTemplate flextVkDevice.CreateDescriptorUpdateTemplate
#define vkCreateSamplerYcbcrConversion flextVkDevice.CreateSamplerYcbcrConversion
#define vkDestroyDescriptorUpdateTemplate flextVkDevice.DestroyDescriptorUpdateTemplate
#define vkDestroySamplerYcbcrConversion flextVkDevice.DestroySamplerYcbcrConversion
#define vkGetBufferMemoryRequirements2 flextVkDevice.GetBufferMemoryRequirements2
#define vkGetDescriptorSetLayoutSupport flextVkDevice.GetDescriptorSetLayoutSupport
#define vkGetDeviceGroupPeerMemoryFeatures flextVkDevice.GetDeviceGroupPeerMemoryFeatures
#define vkGetDeviceQueue2 flextVkDevice.GetDeviceQueue2
#define vkGetImageMemoryRequirements2 flextVkDevice.GetImageMemoryRequirements2
#define vkGetImageSparseMemoryRequirements2 flextVkDevice.GetImageSparseMemoryRequirements2
#define vkTrimCommandPool flextVkDevice.TrimCommandPool
#define vkUpdateDescriptorSetWithTemplate flextVkDevice.UpdateDescriptorSetWithTemplate
/* VK_VERSION_1_2 */
#define vkCmdBeginRenderPass2 flextVkDevice.CmdBeginRenderPass2
#define vkCmdDrawIndexedIndirectCount flextVkDevice.CmdDrawIndexedIndirectCount
#define vkCmdDrawIndirectCount flextVkDevice.CmdDrawIndirectCount
#define vkCmdEndRenderPass2 flextVkDevice.CmdEndRenderPass2
#define vkCmdNextSubpass2 flextVkDevice.CmdNextSubpass2
#define vkCreateRenderPass2 flextVkDevice.CreateRenderPass2
#define vkGetBufferDeviceAddress flextVkDevice.GetBufferDeviceAddress
#define vkGetBufferOpaqueCaptureAddress flextVkDevice.GetBufferOpaqueCaptureAddress
#define vkGetDeviceMemoryOpaqueCaptureAddress flextVkDevice.GetDeviceMemoryOpaqueCaptureAddress
#define vkGetSemaphoreCounterValue flextVkDevice.GetSemaphoreCounterValue
#define vkResetQueryPool flextVkDevice.ResetQueryPool
#define vkSignalSemaphore flextVkDevice.SignalSemaphore
#define vkWaitSemaphores flextVkDevice.WaitSemaphores
#endif
#ifdef __cplusplus
}
#endif
#endif
|
4db404bb8e33106a2821d29136d2ee0aa92eee5d
|
fbe98e4d9986c00b4f2a43d91da5ca849ba7f58e
|
/hde64c/examples/example.c
|
ed7d0b63ffe0356da9a71f8f3d363708280f1972
|
[
"BSD-2-Clause"
] |
permissive
|
jevinskie/substrate
|
434e04d094dd5d571807a709b785f5a07864d8d1
|
97fa4bae349b867ae789bb756f6c45c311d16e7d
|
refs/heads/master
| 2021-01-23T08:43:44.120431
| 2014-03-30T16:48:36
| 2014-03-30T16:48:36
| 12,574,975
| 109
| 56
| null | null | null | null |
UTF-8
|
C
| false
| false
| 537
|
c
|
example.c
|
#include <stdio.h>
#include "../include/hde64.h"
char fmt[] = "\n"
" mov rax,0x1122334455667788\n\n"
" length of command: 0x%02x\n"
" immediate64: 0x%08x%08x\n";
unsigned char code[] = {0x48,0xb8,0x88,0x77,0x66,0x55,0x44,0x33,0x22,0x11};
int main(void)
{
hde64s hs;
unsigned int length = hde64_disasm(code,&hs);
if (hs.flags & F_ERROR)
printf("Invalid instruction !\n");
else
printf(fmt,length,(uint32_t)(hs.imm.imm64 >> 32),
(uint32_t)hs.imm.imm64);
return 0;
}
|
496aed04130a6fa84bd5eaa53c459bbcc4295c90
|
21c8a3598e467713ecc72d2ef3106b4b6f6b14e0
|
/test/theme-parser-test.c
|
7eeb450893d902849deec783cadc336447a9d5ab
|
[
"MIT"
] |
permissive
|
davatorium/rofi
|
b129e7dc5d0656d3c005db491829af664eceade1
|
664f1b929706f39bb402e09e2284c9de50b205af
|
refs/heads/next
| 2023-08-16T17:50:01.303076
| 2023-08-15T17:34:11
| 2023-08-15T17:34:11
| 7,715,820
| 8,308
| 673
|
NOASSERTION
| 2023-08-23T20:19:08
| 2013-01-20T11:54:45
|
C
|
UTF-8
|
C
| false
| false
| 83,280
|
c
|
theme-parser-test.c
|
/*
* rofi
*
* MIT/X11 License
* Copyright © 2013-2017 Qball Cow <qball@gmpclient.org>
*
* 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 "css-colors.h"
#include "display.h"
#include "rofi-icon-fetcher.h"
#include "rofi.h"
#include "settings.h"
#include "theme.h"
#include "widgets/textbox.h"
#include "widgets/widget-internal.h"
#include "xcb-internal.h"
#include "xcb.h"
#include <assert.h>
#include <glib.h>
#include <helper.h>
#include <locale.h>
#include <stdio.h>
#include <string.h>
#include <xcb/xcb_ewmh.h>
#include <check.h>
#define REAL_COMPARE_DELTA 0.001
uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name,
G_GNUC_UNUSED const int size) {
return 0;
}
void rofi_clear_error_messages(void) {}
void rofi_clear_warning_messages(void) {}
uint32_t
rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name,
G_GNUC_UNUSED G_GNUC_UNUSED const int wsize,
G_GNUC_UNUSED const int hsize) {
return 0;
}
cairo_surface_t *rofi_icon_fetcher_get(G_GNUC_UNUSED const uint32_t uid) {
return NULL;
}
int rofi_view_error_dialog(const char *msg, G_GNUC_UNUSED int markup) {
fputs(msg, stderr);
return TRUE;
}
void rofi_view_get_current_monitor(int *width, int *height) {
if (width) {
*width = 1920;
}
if (height) {
*height = 1080;
}
}
double textbox_get_estimated_char_height(void) { return 16.0; }
double textbox_get_estimated_ch(void) { return 8.0; }
int monitor_active(G_GNUC_UNUSED workarea *mon) { return 0; }
void display_startup_notification(
G_GNUC_UNUSED RofiHelperExecuteContext *context,
G_GNUC_UNUSED GSpawnChildSetupFunc *child_setup,
G_GNUC_UNUSED gpointer *user_data) {}
#ifndef _ck_assert_ptr_null
/* Pointer against NULL comparison macros with improved output
* compared to ck_assert(). */
/* OP may only be == or != */
#define _ck_assert_ptr_null(X, OP) \
do { \
const void *_ck_x = (X); \
ck_assert_msg(_ck_x OP NULL, "Assertion '%s' failed: %s == %#x", \
#X " " #OP " NULL", #X, _ck_x); \
} while (0)
#define ck_assert_ptr_null(X) _ck_assert_ptr_null(X, ==)
#define ck_assert_ptr_nonnull(X) _ck_assert_ptr_null(X, !=)
#endif
gboolean error = FALSE;
GString *error_msg = NULL;
gboolean warning = FALSE;
GString *warning_msg = NULL;
void rofi_add_error_message(GString *msg) {
ck_assert_ptr_null(error_msg);
error_msg = msg;
error = TRUE;
}
void rofi_add_warning_message(GString *msg) {
ck_assert_ptr_null(warning_msg);
warning_msg = msg;
warning = TRUE;
}
static void theme_parser_setup(void) { error = 0; }
static void theme_parser_teardown(void) {
ck_assert_ptr_null(error_msg);
ck_assert_int_eq(error, 0);
rofi_theme_free(rofi_theme);
rofi_theme = NULL;
}
START_TEST(test_core_empty_string) {
rofi_theme_parse_string("");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
}
END_TEST
START_TEST(test_core_empty_global_section) {
rofi_theme_parse_string(" * {}");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
}
END_TEST
START_TEST(test_core_empty_section) {
rofi_theme_parse_string(" #test {}");
ck_assert_ptr_nonnull(rofi_theme);
ck_assert_ptr_nonnull(rofi_theme->widgets);
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
// ck_assert_str_eq ( rofi_theme->widgets[3]->name, "test" );
// ck_assert_ptr_null ( rofi_theme->widgets[3]->properties );
// ck_assert_ptr_eq ( rofi_theme->widgets[3]->parent, rofi_theme );
}
END_TEST
START_TEST(test_core_error_root) {
rofi_theme_parse_string("Blaat");
ck_assert_int_eq(error, 1);
ck_assert_ptr_null(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
// ck_assert_ptr_null ( rofi_theme->properties );
// ck_assert_ptr_null ( rofi_theme->parent );
const char *error_str =
"<big><b>Error while parsing theme:</b></big> <i>Blaat</i>\n"
" Parser error: <span size=\"smaller\" style=\"italic\">syntax error, "
"unexpected end of file, expecting "bracket open "
"('{')" or "Selector separator "
"(',')"</span>\n"
" Location: line 1 column 6 to line 1 column 6\n";
ck_assert_str_eq(error_msg->str, error_str);
g_string_free(error_msg, TRUE);
error_msg = NULL;
error = 0;
}
END_TEST
START_TEST(test_core_comments) {
rofi_theme_parse_string("// Random comments // /*test */");
rofi_theme_parse_string("/* test /* aap */ */");
rofi_theme_parse_string("// Random comments\n// /*test */");
rofi_theme_parse_string("/* test \n*\n* /* aap */ */");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
// Test comment on last lines
rofi_theme_parse_string("// c++ style");
rofi_theme_parse_string("/* c style");
}
END_TEST
START_TEST(test_core_newline) {
rofi_theme_parse_string("\r\n\n\r\n\n/*\r\n*/");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
}
END_TEST
START_TEST(test_properties_boolean) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
/** Boolean property */
rofi_theme_parse_string("*{ test: true; test2:/* inline */false; }");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_nonnull(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_int_eq(rofi_theme_get_boolean(&wid, "test", FALSE), TRUE);
ck_assert_int_eq(rofi_theme_get_boolean(&wid, "test2", TRUE), FALSE);
}
END_TEST
START_TEST(test_properties_boolean_reference) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string(
"* { test: true; test2:/* inline */false;} *{ a:@test; b:@test2;}");
ck_assert_ptr_nonnull(rofi_theme);
ck_assert_int_eq(rofi_theme_get_boolean(&wid, "test", FALSE), TRUE);
ck_assert_int_eq(rofi_theme_get_boolean(&wid, "b", TRUE), FALSE);
ck_assert_int_eq(rofi_theme_get_boolean(&wid, "a", FALSE), TRUE);
ck_assert_int_eq(rofi_theme_get_boolean(&wid, "test2", TRUE), FALSE);
}
END_TEST
START_TEST(test_properties_distance_em) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { test: 10em;}");
ck_assert_ptr_nonnull(rofi_theme);
RofiDistance d = (RofiDistance){
{1, ROFI_PU_PX, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL}, ROFI_HL_SOLID};
RofiPadding pi = (RofiPadding){d, d, d, d};
RofiPadding p = rofi_theme_get_padding(&wid, "test", pi);
ck_assert_int_eq(p.left.base.distance, 10);
ck_assert_int_eq(p.left.base.type, ROFI_PU_EM);
ck_assert_int_eq(p.left.style, ROFI_HL_SOLID);
}
END_TEST
START_TEST(test_properties_distance_em_linestyle) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { sol: 1.3em solid; dash: 1.5em dash;}");
ck_assert_ptr_nonnull(rofi_theme);
RofiDistance d = (RofiDistance){
{1, ROFI_PU_PX, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL}, ROFI_HL_SOLID};
RofiPadding pi = (RofiPadding){d, d, d, d};
RofiPadding p = rofi_theme_get_padding(&wid, "sol", pi);
ck_assert_double_eq_tol(p.left.base.distance, 1.3, REAL_COMPARE_DELTA);
ck_assert_int_eq(p.left.base.type, ROFI_PU_EM);
ck_assert_int_eq(p.left.style, ROFI_HL_SOLID);
p = rofi_theme_get_padding(&wid, "dash", pi);
ck_assert_double_eq_tol(p.left.base.distance, 1.5, REAL_COMPARE_DELTA);
ck_assert_int_eq(p.left.base.type, ROFI_PU_EM);
ck_assert_int_eq(p.left.style, ROFI_HL_DASH);
}
END_TEST
START_TEST(test_properties_distance_ch) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { test: 10ch;}");
ck_assert_ptr_nonnull(rofi_theme);
RofiDistance d = (RofiDistance){
{1, ROFI_PU_PX, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL}, ROFI_HL_SOLID};
RofiPadding pi = (RofiPadding){d, d, d, d};
RofiPadding p = rofi_theme_get_padding(&wid, "test", pi);
ck_assert_int_eq(p.left.base.distance, 10);
ck_assert_int_eq(p.left.base.type, ROFI_PU_CH);
ck_assert_int_eq(p.left.style, ROFI_HL_SOLID);
}
END_TEST
START_TEST(test_properties_distance_ch_linestyle) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { sol: 1.3ch solid; dash: 1.5ch dash;}");
ck_assert_ptr_nonnull(rofi_theme);
RofiDistance d = (RofiDistance){
{1, ROFI_PU_PX, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL}, ROFI_HL_SOLID};
RofiPadding pi = (RofiPadding){d, d, d, d};
RofiPadding p = rofi_theme_get_padding(&wid, "sol", pi);
ck_assert_double_eq_tol(p.left.base.distance, 1.3, REAL_COMPARE_DELTA);
ck_assert_int_eq(p.left.base.type, ROFI_PU_CH);
ck_assert_int_eq(p.left.style, ROFI_HL_SOLID);
p = rofi_theme_get_padding(&wid, "dash", pi);
ck_assert_double_eq_tol(p.left.base.distance, 1.5, REAL_COMPARE_DELTA);
ck_assert_int_eq(p.left.base.type, ROFI_PU_CH);
ck_assert_int_eq(p.left.style, ROFI_HL_DASH);
}
END_TEST
START_TEST(test_properties_distance_px) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { test: 10px;}");
ck_assert_ptr_nonnull(rofi_theme);
RofiDistance d = (RofiDistance){
{1, ROFI_PU_EM, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL}, ROFI_HL_DASH};
RofiPadding pi = (RofiPadding){d, d, d, d};
RofiPadding p = rofi_theme_get_padding(&wid, "test", pi);
ck_assert_double_eq_tol(p.left.base.distance, 10.0, REAL_COMPARE_DELTA);
ck_assert_int_eq(p.left.base.type, ROFI_PU_PX);
ck_assert_int_eq(p.left.style, ROFI_HL_SOLID);
}
END_TEST
START_TEST(test_properties_distance_px_linestyle) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { sol: 10px solid; dash: 14px dash;}");
ck_assert_ptr_nonnull(rofi_theme);
RofiDistance d = (RofiDistance){
{1, ROFI_PU_EM, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL}, ROFI_HL_DASH};
RofiPadding pi = (RofiPadding){d, d, d, d};
RofiPadding p = rofi_theme_get_padding(&wid, "sol", pi);
ck_assert_double_eq_tol(p.left.base.distance, 10.0, REAL_COMPARE_DELTA);
ck_assert_int_eq(p.left.base.type, ROFI_PU_PX);
ck_assert_int_eq(p.left.style, ROFI_HL_SOLID);
p = rofi_theme_get_padding(&wid, "dash", pi);
ck_assert_double_eq_tol(p.left.base.distance, 14.0, REAL_COMPARE_DELTA);
ck_assert_int_eq(p.left.base.type, ROFI_PU_PX);
ck_assert_int_eq(p.left.style, ROFI_HL_DASH);
}
END_TEST
START_TEST(test_properties_distance_percent) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { test: 10%;}");
ck_assert_ptr_nonnull(rofi_theme);
RofiDistance d = (RofiDistance){
{1, ROFI_PU_EM, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL}, ROFI_HL_DASH};
RofiPadding pi = (RofiPadding){d, d, d, d};
RofiPadding p = rofi_theme_get_padding(&wid, "test", pi);
ck_assert_double_eq_tol(p.left.base.distance, 10.0, REAL_COMPARE_DELTA);
ck_assert_int_eq(p.left.base.type, ROFI_PU_PERCENT);
ck_assert_int_eq(p.left.style, ROFI_HL_SOLID);
}
END_TEST
START_TEST(test_properties_distance_percent_linestyle) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { sol: 10% solid; dash: 10% dash;}");
ck_assert_ptr_nonnull(rofi_theme);
RofiDistance d = (RofiDistance){
{1, ROFI_PU_EM, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL}, ROFI_HL_DASH};
RofiPadding pi = (RofiPadding){d, d, d, d};
RofiPadding p = rofi_theme_get_padding(&wid, "sol", pi);
ck_assert_double_eq_tol(p.left.base.distance, 10.0, REAL_COMPARE_DELTA);
ck_assert_int_eq(p.left.base.type, ROFI_PU_PERCENT);
ck_assert_int_eq(p.left.style, ROFI_HL_SOLID);
p = rofi_theme_get_padding(&wid, "dash", pi);
ck_assert_double_eq_tol(p.left.base.distance, 10, REAL_COMPARE_DELTA);
ck_assert_int_eq(p.left.base.type, ROFI_PU_PERCENT);
ck_assert_int_eq(p.left.style, ROFI_HL_DASH);
}
END_TEST
START_TEST(test_properties_distance_mm) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { test: 10mm;}");
ck_assert_ptr_nonnull(rofi_theme);
RofiDistance d = (RofiDistance){
{1, ROFI_PU_EM, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL}, ROFI_HL_DASH};
RofiPadding pi = (RofiPadding){d, d, d, d};
RofiPadding p = rofi_theme_get_padding(&wid, "test", pi);
ck_assert_double_eq_tol(p.left.base.distance, 10.0, REAL_COMPARE_DELTA);
ck_assert_int_eq(p.left.base.type, ROFI_PU_MM);
ck_assert_int_eq(p.left.style, ROFI_HL_SOLID);
}
END_TEST
START_TEST(test_properties_distance_mm_linestyle) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { sol: 10mm solid; dash: 10mm dash;}");
ck_assert_ptr_nonnull(rofi_theme);
RofiDistance d = (RofiDistance){
{1, ROFI_PU_EM, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL}, ROFI_HL_DASH};
RofiPadding pi = (RofiPadding){d, d, d, d};
RofiPadding p = rofi_theme_get_padding(&wid, "sol", pi);
ck_assert_double_eq_tol(p.left.base.distance, 10.0, REAL_COMPARE_DELTA);
ck_assert_int_eq(p.left.base.type, ROFI_PU_MM);
ck_assert_int_eq(p.left.style, ROFI_HL_SOLID);
p = rofi_theme_get_padding(&wid, "dash", pi);
ck_assert_double_eq_tol(p.left.base.distance, 10, REAL_COMPARE_DELTA);
ck_assert_int_eq(p.left.base.type, ROFI_PU_MM);
ck_assert_int_eq(p.left.style, ROFI_HL_DASH);
}
END_TEST
START_TEST(test_properties_position) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { center: center; east: east; west: west; south: "
"south; north:north;}");
ck_assert_int_eq(rofi_theme_get_position(&wid, "center", WL_SOUTH),
WL_CENTER);
ck_assert_int_eq(rofi_theme_get_position(&wid, "south", WL_EAST), WL_SOUTH);
ck_assert_int_eq(rofi_theme_get_position(&wid, "east", WL_WEST), WL_EAST);
ck_assert_int_eq(rofi_theme_get_position(&wid, "west", WL_NORTH), WL_WEST);
ck_assert_int_eq(rofi_theme_get_position(&wid, "north", WL_CENTER), WL_NORTH);
rofi_theme_parse_string("* { southwest: southwest; southeast: southeast; "
"northwest: northwest; northeast:northeast;}");
ck_assert_int_eq(rofi_theme_get_position(&wid, "southwest", WL_EAST),
WL_SOUTH_WEST);
ck_assert_int_eq(rofi_theme_get_position(&wid, "southeast", WL_WEST),
WL_SOUTH_EAST);
ck_assert_int_eq(rofi_theme_get_position(&wid, "northwest", WL_NORTH),
WL_NORTH_WEST);
ck_assert_int_eq(rofi_theme_get_position(&wid, "northeast", WL_CENTER),
WL_NORTH_EAST);
rofi_theme_parse_string("* { southwest: south west; southeast: south east; "
"northwest: north west; northeast:north east;}");
ck_assert_int_eq(rofi_theme_get_position(&wid, "southwest", WL_EAST),
WL_SOUTH_WEST);
ck_assert_int_eq(rofi_theme_get_position(&wid, "southeast", WL_WEST),
WL_SOUTH_EAST);
ck_assert_int_eq(rofi_theme_get_position(&wid, "northwest", WL_NORTH),
WL_NORTH_WEST);
ck_assert_int_eq(rofi_theme_get_position(&wid, "northeast", WL_CENTER),
WL_NORTH_EAST);
rofi_theme_parse_string("* { westsouth: westsouth; eastsouth: eastsouth; "
"westnorth: westnorth; eastnorth:eastnorth;}");
ck_assert_int_eq(rofi_theme_get_position(&wid, "westsouth", WL_EAST),
WL_SOUTH_WEST);
ck_assert_int_eq(rofi_theme_get_position(&wid, "eastsouth", WL_WEST),
WL_SOUTH_EAST);
ck_assert_int_eq(rofi_theme_get_position(&wid, "westnorth", WL_NORTH),
WL_NORTH_WEST);
ck_assert_int_eq(rofi_theme_get_position(&wid, "eastnorth", WL_CENTER),
WL_NORTH_EAST);
rofi_theme_parse_string("* { westsouth: west south; eastsouth: east south; "
"westnorth: west north; eastnorth:east north;}");
ck_assert_int_eq(rofi_theme_get_position(&wid, "westsouth", WL_EAST),
WL_SOUTH_WEST);
ck_assert_int_eq(rofi_theme_get_position(&wid, "eastsouth", WL_WEST),
WL_SOUTH_EAST);
ck_assert_int_eq(rofi_theme_get_position(&wid, "westnorth", WL_NORTH),
WL_NORTH_WEST);
ck_assert_int_eq(rofi_theme_get_position(&wid, "eastnorth", WL_CENTER),
WL_NORTH_EAST);
rofi_theme_parse_string("* { westeast: west east;}");
// Should return error.
// TODO: check error message.
g_string_free(error_msg, TRUE);
error_msg = NULL;
error = 0;
}
END_TEST
START_TEST(test_properties_style) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { none: none; bold: bold; underline: underline; "
"italic: italic; st: italic strikethrough;}");
RofiHighlightColorStyle th = {ROFI_HL_BOLD, {0.0, 0.0, 0.0, 0.0}};
th = rofi_theme_get_highlight(&wid, "none", th);
ck_assert_int_eq(th.style, ROFI_HL_NONE);
th = rofi_theme_get_highlight(&wid, "underline", th);
ck_assert_int_eq(th.style, ROFI_HL_UNDERLINE);
th = rofi_theme_get_highlight(&wid, "italic", th);
ck_assert_int_eq(th.style, ROFI_HL_ITALIC);
th = rofi_theme_get_highlight(&wid, "bold", th);
ck_assert_int_eq(th.style, ROFI_HL_BOLD);
th = rofi_theme_get_highlight(&wid, "st", th);
ck_assert_int_eq(th.style, ROFI_HL_ITALIC | ROFI_HL_STRIKETHROUGH);
}
END_TEST
START_TEST(test_properties_style2) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string(
"* { boldu: bold underline ; boldi: bold italic; underlinei: underline "
"italic; italicu: italic underline;}");
RofiHighlightColorStyle th = {ROFI_HL_BOLD, {0.0, 0.0, 0.0, 0.0}};
th = rofi_theme_get_highlight(&wid, "boldu", th);
ck_assert_int_eq(th.style, (ROFI_HL_UNDERLINE | ROFI_HL_BOLD));
th = rofi_theme_get_highlight(&wid, "boldi", th);
ck_assert_int_eq(th.style, (ROFI_HL_ITALIC | ROFI_HL_BOLD));
th = rofi_theme_get_highlight(&wid, "underlinei", th);
ck_assert_int_eq(th.style, (ROFI_HL_ITALIC | ROFI_HL_UNDERLINE));
th = rofi_theme_get_highlight(&wid, "italicu", th);
ck_assert_int_eq(th.style, (ROFI_HL_ITALIC | ROFI_HL_UNDERLINE));
}
END_TEST
START_TEST(test_properties_style_color) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { comb: bold #123; }");
RofiHighlightColorStyle th = {ROFI_HL_BOLD, {0.0, 0.0, 0.0, 0.0}};
th = rofi_theme_get_highlight(&wid, "comb", th);
ck_assert_int_eq(th.style, (ROFI_HL_BOLD | ROFI_HL_COLOR));
ck_assert_double_eq_tol(th.color.red, (1 / 15.0), REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(th.color.green, (2 / 15.0), REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(th.color.blue, (3 / 15.0), REAL_COMPARE_DELTA);
}
END_TEST
START_TEST(test_properties_color_h3) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { red: #F00; green: #0F0; blue: #00F; }");
ThemeWidget *twid = rofi_theme_find_widget(wid.name, wid.state, FALSE);
Property *p = rofi_theme_find_property(twid, P_COLOR, "red", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.red, 1, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 0, REAL_COMPARE_DELTA);
p = rofi_theme_find_property(twid, P_COLOR, "green", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.red, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 1, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 0, REAL_COMPARE_DELTA);
p = rofi_theme_find_property(twid, P_COLOR, "blue", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.red, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 1, REAL_COMPARE_DELTA);
}
END_TEST
START_TEST(test_properties_color_h6) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { red: #FF0000; green: #00FF00; blue: #0000FF; }");
ThemeWidget *twid = rofi_theme_find_widget(wid.name, wid.state, FALSE);
Property *p = rofi_theme_find_property(twid, P_COLOR, "red", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.red, 1, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 0, REAL_COMPARE_DELTA);
p = rofi_theme_find_property(twid, P_COLOR, "green", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.red, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 1, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 0, REAL_COMPARE_DELTA);
p = rofi_theme_find_property(twid, P_COLOR, "blue", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.red, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 1, REAL_COMPARE_DELTA);
}
END_TEST
START_TEST(test_properties_color_h4) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { red: #F003; green: #0F02; blue: #00F1; }");
ThemeWidget *twid = rofi_theme_find_widget(wid.name, wid.state, FALSE);
Property *p = rofi_theme_find_property(twid, P_COLOR, "red", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 0.2, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 1, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 0, REAL_COMPARE_DELTA);
p = rofi_theme_find_property(twid, P_COLOR, "green", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 1 / 7.5, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 1, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 0, REAL_COMPARE_DELTA);
p = rofi_theme_find_property(twid, P_COLOR, "blue", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 1 / 15.0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 1, REAL_COMPARE_DELTA);
}
END_TEST
START_TEST(test_properties_color_h8) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string(
"* { red: #FF000033; green: #00FF0022; blue: #0000FF11; }");
ThemeWidget *twid = rofi_theme_find_widget(wid.name, wid.state, FALSE);
Property *p = rofi_theme_find_property(twid, P_COLOR, "red", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 0.2, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 1, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 0, REAL_COMPARE_DELTA);
p = rofi_theme_find_property(twid, P_COLOR, "green", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 1 / 7.5, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 1, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 0, REAL_COMPARE_DELTA);
p = rofi_theme_find_property(twid, P_COLOR, "blue", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 1 / 15.0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 1, REAL_COMPARE_DELTA);
}
END_TEST
START_TEST(test_properties_color_rgb) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { red: rgb(100%,0%,0%); green: rgb(0%,100%,0%); "
"blue: rgb(0%,0%,100%); }");
ThemeWidget *twid = rofi_theme_find_widget(wid.name, wid.state, FALSE);
Property *p = rofi_theme_find_property(twid, P_COLOR, "red", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.red, 1, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 0, REAL_COMPARE_DELTA);
p = rofi_theme_find_property(twid, P_COLOR, "green", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.red, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 1, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 0, REAL_COMPARE_DELTA);
p = rofi_theme_find_property(twid, P_COLOR, "blue", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.red, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 1, REAL_COMPARE_DELTA);
}
END_TEST
START_TEST(test_properties_color_rgba_p) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string(
"* { red: rgba(100%,0%,0%,0.3); green: rgba(0%,100%,0%,0.2); blue: "
"rgba(0%,0%,100%,0.7); }");
ThemeWidget *twid = rofi_theme_find_widget(wid.name, wid.state, FALSE);
Property *p = rofi_theme_find_property(twid, P_COLOR, "red", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 0.3, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 1, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 0, REAL_COMPARE_DELTA);
p = rofi_theme_find_property(twid, P_COLOR, "green", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 0.2, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 1, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 0, REAL_COMPARE_DELTA);
p = rofi_theme_find_property(twid, P_COLOR, "blue", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 0.7, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 1, REAL_COMPARE_DELTA);
}
END_TEST
START_TEST(test_properties_color_rgba_percent_p) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string(
"* { red: rgba(100%,0%,0%,30%); green: rgba(0%,100%,0%,20%); blue: "
"rgba(0% 0% 100%/70.0%); }");
ThemeWidget *twid = rofi_theme_find_widget(wid.name, wid.state, FALSE);
Property *p = rofi_theme_find_property(twid, P_COLOR, "red", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 0.3, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 1, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 0, REAL_COMPARE_DELTA);
p = rofi_theme_find_property(twid, P_COLOR, "green", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 0.2, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 1, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 0, REAL_COMPARE_DELTA);
p = rofi_theme_find_property(twid, P_COLOR, "blue", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 0.7, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 1, REAL_COMPARE_DELTA);
}
END_TEST
START_TEST(test_properties_color_rgb_p) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string(
"* { red: rgb(255,0,0); green: rgb(0,255,0); blue: rgb(0,0,255); }");
ThemeWidget *twid = rofi_theme_find_widget(wid.name, wid.state, FALSE);
Property *p = rofi_theme_find_property(twid, P_COLOR, "red", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.red, 1, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 0, REAL_COMPARE_DELTA);
p = rofi_theme_find_property(twid, P_COLOR, "green", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.red, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 1, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 0, REAL_COMPARE_DELTA);
p = rofi_theme_find_property(twid, P_COLOR, "blue", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.red, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 1, REAL_COMPARE_DELTA);
}
END_TEST
START_TEST(test_properties_color_rgba) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { red: rgba(255,0,0,0.3); green: "
"rgba(0,255,0,0.2); blue: rgba(0 0 255 /0.7); }");
ThemeWidget *twid = rofi_theme_find_widget(wid.name, wid.state, FALSE);
ck_assert_ptr_nonnull(twid);
Property *p = rofi_theme_find_property(twid, P_COLOR, "red", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 0.3, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 1, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 0, REAL_COMPARE_DELTA);
p = rofi_theme_find_property(twid, P_COLOR, "green", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 0.2, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 1, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 0, REAL_COMPARE_DELTA);
p = rofi_theme_find_property(twid, P_COLOR, "blue", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 0.7, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 1, REAL_COMPARE_DELTA);
}
END_TEST
START_TEST(test_properties_color_rgba_percent) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { red: rgba(255,0,0,30%); green: "
"rgba(0,255,0,20%); blue: rgba(0,0,255,70.0%); }");
ThemeWidget *twid = rofi_theme_find_widget(wid.name, wid.state, FALSE);
Property *p = rofi_theme_find_property(twid, P_COLOR, "red", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 0.3, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 1, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 0, REAL_COMPARE_DELTA);
p = rofi_theme_find_property(twid, P_COLOR, "green", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 0.2, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 1, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 0, REAL_COMPARE_DELTA);
p = rofi_theme_find_property(twid, P_COLOR, "blue", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 0.7, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 1, REAL_COMPARE_DELTA);
}
END_TEST
START_TEST(test_properties_color_argb) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string(
"* { red: argb:33FF0000; green: argb:2200FF00; blue: argb:110000FF; }");
ThemeWidget *twid = rofi_theme_find_widget(wid.name, wid.state, FALSE);
Property *p = rofi_theme_find_property(twid, P_COLOR, "red", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 0.2, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 1, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 0, REAL_COMPARE_DELTA);
p = rofi_theme_find_property(twid, P_COLOR, "green", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 1 / 7.5, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 1, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 0, REAL_COMPARE_DELTA);
p = rofi_theme_find_property(twid, P_COLOR, "blue", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 1 / 15.0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.green, 0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.blue, 1, REAL_COMPARE_DELTA);
}
END_TEST
START_TEST(test_properties_color_hsl) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { test1: hsl(127,40%,66.66666%); test2: hsl(0, "
"100%, 50%); testa: hsl(127,40%, 66.66666%, 30%);}");
ThemeWidget *twid = rofi_theme_find_widget(wid.name, wid.state, FALSE);
Property *p = rofi_theme_find_property(twid, P_COLOR, "test1", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 1.0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 0x88 / 255.0, 0.004);
ck_assert_double_eq_tol(p->value.color.green, 0xcd / 255.0, 0.004);
ck_assert_double_eq_tol(p->value.color.blue, 0x90 / 255.0, 0.004);
p = rofi_theme_find_property(twid, P_COLOR, "test2", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 1.0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 1, 0.004);
ck_assert_double_eq_tol(p->value.color.green, 0, 0.004);
ck_assert_double_eq_tol(p->value.color.blue, 0, 0.004);
p = rofi_theme_find_property(twid, P_COLOR, "testa", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 0.3, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 0x88 / 255.0, 0.004);
ck_assert_double_eq_tol(p->value.color.green, 0xcd / 255.0, 0.004);
ck_assert_double_eq_tol(p->value.color.blue, 0x90 / 255.0, 0.004);
}
END_TEST
START_TEST(test_properties_color_hsla) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { test1: hsla(127,40%,66.66666%, 40%); test2: "
"hsla(0, 100%, 50%,55%); }");
ThemeWidget *twid = rofi_theme_find_widget(wid.name, wid.state, FALSE);
Property *p = rofi_theme_find_property(twid, P_COLOR, "test1", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 0.4, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 0x88 / 255.0, 0.004);
ck_assert_double_eq_tol(p->value.color.green, 0xcd / 255.0, 0.004);
ck_assert_double_eq_tol(p->value.color.blue, 0x90 / 255.0, 0.004);
p = rofi_theme_find_property(twid, P_COLOR, "test2", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 0.55, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 1, 0.004);
ck_assert_double_eq_tol(p->value.color.green, 0, 0.004);
ck_assert_double_eq_tol(p->value.color.blue, 0, 0.004);
}
END_TEST
START_TEST(test_properties_color_hsl_ws) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string(
"* { test1: hsl(127 40% 66.66666%); test2: hsl(0 100% 50%); testa: "
"hsl(127 40% 66.66666% / 30%);}");
ThemeWidget *twid = rofi_theme_find_widget(wid.name, wid.state, FALSE);
Property *p = rofi_theme_find_property(twid, P_COLOR, "test1", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 1.0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 0x88 / 255.0, 0.004);
ck_assert_double_eq_tol(p->value.color.green, 0xcd / 255.0, 0.004);
ck_assert_double_eq_tol(p->value.color.blue, 0x90 / 255.0, 0.004);
p = rofi_theme_find_property(twid, P_COLOR, "test2", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 1.0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 1, 0.004);
ck_assert_double_eq_tol(p->value.color.green, 0, 0.004);
ck_assert_double_eq_tol(p->value.color.blue, 0, 0.004);
p = rofi_theme_find_property(twid, P_COLOR, "testa", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 0.3, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 0x88 / 255.0, 0.004);
ck_assert_double_eq_tol(p->value.color.green, 0xcd / 255.0, 0.004);
ck_assert_double_eq_tol(p->value.color.blue, 0x90 / 255.0, 0.004);
}
END_TEST
START_TEST(test_properties_color_hsla_ws) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { test1: hsla(127 40% 66.66666% / 0.3); test2: "
"hsla(0 100% 50%/ 55%); }");
ThemeWidget *twid = rofi_theme_find_widget(wid.name, wid.state, FALSE);
Property *p = rofi_theme_find_property(twid, P_COLOR, "test1", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 0.3, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 0x88 / 255.0, 0.004);
ck_assert_double_eq_tol(p->value.color.green, 0xcd / 255.0, 0.004);
ck_assert_double_eq_tol(p->value.color.blue, 0x90 / 255.0, 0.004);
p = rofi_theme_find_property(twid, P_COLOR, "test2", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 0.55, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 1, 0.004);
ck_assert_double_eq_tol(p->value.color.green, 0, 0.004);
ck_assert_double_eq_tol(p->value.color.blue, 0, 0.004);
}
END_TEST
START_TEST(test_properties_color_hwb) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { test1: hwb(190,65%,0%); test2: hwb(265, 31%, "
"29%); testa: hwb(265, 31%, 29%, 40%); }");
ThemeWidget *twid = rofi_theme_find_widget(wid.name, wid.state, FALSE);
Property *p = rofi_theme_find_property(twid, P_COLOR, "test2", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 1.0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 0x7a / 255.0, 0.004);
ck_assert_double_eq_tol(p->value.color.green, 0x4f / 255.0, 0.004);
ck_assert_double_eq_tol(p->value.color.blue, 0xb5 / 255.0, 0.004);
p = rofi_theme_find_property(twid, P_COLOR, "test1", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 1.0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 166 / 255.0, 0.004);
ck_assert_double_eq_tol(p->value.color.green, 240 / 255.0, 0.004);
ck_assert_double_eq_tol(p->value.color.blue, 255 / 255.0, 0.004);
p = rofi_theme_find_property(twid, P_COLOR, "testa", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 0.4, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 0x7a / 255.0, 0.004);
ck_assert_double_eq_tol(p->value.color.green, 0x4f / 255.0, 0.004);
ck_assert_double_eq_tol(p->value.color.blue, 0xb5 / 255.0, 0.004);
}
END_TEST
START_TEST(test_properties_color_hwb_ws) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string(
"* { test1: hwb(190 deg 65 %0%); test2: hwb(295 grad 31% 29%);testa: "
"hwb(0.736 turn 31% 29% / 40%); rada: hwb(0.2 rad 30% 30%/40%); }");
ThemeWidget *twid = rofi_theme_find_widget(wid.name, wid.state, FALSE);
Property *p = rofi_theme_find_property(twid, P_COLOR, "test2", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 1.0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 0x7a / 255.0, 0.004);
ck_assert_double_eq_tol(p->value.color.green, 0x4f / 255.0, 0.004);
ck_assert_double_eq_tol(p->value.color.blue, 0xb5 / 255.0, 0.004);
p = rofi_theme_find_property(twid, P_COLOR, "test1", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 1.0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 166 / 255.0, 0.004);
ck_assert_double_eq_tol(p->value.color.green, 240 / 255.0, 0.004);
ck_assert_double_eq_tol(p->value.color.blue, 255 / 255.0, 0.004);
p = rofi_theme_find_property(twid, P_COLOR, "testa", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 0.4, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 0x7a / 255.0, 0.004);
ck_assert_double_eq_tol(p->value.color.green, 0x4f / 255.0, 0.004);
ck_assert_double_eq_tol(p->value.color.blue, 0xb5 / 255.0, 0.004);
p = rofi_theme_find_property(twid, P_COLOR, "rada", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 0.4, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 0.7, 0.004);
ck_assert_double_eq_tol(p->value.color.green, 0.376, 0.004);
ck_assert_double_eq_tol(p->value.color.blue, 0.3, 0.004);
}
END_TEST
START_TEST(test_properties_color_cmyk) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string(
"* { test1: cmyk ( 41%, 0%, 100%, 0%); test2: cmyk ( 0, 1.0, 1.0, 0);}");
ThemeWidget *twid = rofi_theme_find_widget(wid.name, wid.state, FALSE);
Property *p = rofi_theme_find_property(twid, P_COLOR, "test1", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 1.0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 0x96 / 255.0, 0.004);
ck_assert_double_eq_tol(p->value.color.green, 1.0, 0.004);
ck_assert_double_eq_tol(p->value.color.blue, 0.0, 0.004);
p = rofi_theme_find_property(twid, P_COLOR, "test2", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 1.0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 1, 0.004);
ck_assert_double_eq_tol(p->value.color.green, 0, 0.004);
ck_assert_double_eq_tol(p->value.color.blue, 0, 0.004);
}
END_TEST
START_TEST(test_properties_color_cmyk_ws) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string(
"* { test1: cmyk ( 41% 0% 100% 0%); test2: cmyk ( 0 1.0 1.0 0);}");
ThemeWidget *twid = rofi_theme_find_widget(wid.name, wid.state, FALSE);
Property *p = rofi_theme_find_property(twid, P_COLOR, "test1", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 1.0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 0x96 / 255.0, 0.004);
ck_assert_double_eq_tol(p->value.color.green, 1.0, 0.004);
ck_assert_double_eq_tol(p->value.color.blue, 0.0, 0.004);
p = rofi_theme_find_property(twid, P_COLOR, "test2", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 1.0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 1, 0.004);
ck_assert_double_eq_tol(p->value.color.green, 0, 0.004);
ck_assert_double_eq_tol(p->value.color.blue, 0, 0.004);
}
END_TEST
START_TEST(test_properties_color_names) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
for (unsigned int iter = 0; iter < num_CSSColors; iter++) {
char *str = g_strdup_printf("* { color: %s;}", CSSColors[iter].name);
rofi_theme_parse_string(str);
ThemeWidget *twid = rofi_theme_find_widget(wid.name, wid.state, FALSE);
Property *p = rofi_theme_find_property(twid, P_COLOR, "text-color", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 1.0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, CSSColors[iter].r / 255.0,
0.004);
ck_assert_double_eq_tol(p->value.color.green, CSSColors[iter].g / 255.0,
0.004);
ck_assert_double_eq_tol(p->value.color.blue, CSSColors[iter].b / 255.0,
0.004);
g_free(str);
}
{
rofi_theme_parse_string("* {color: transparent;}");
ThemeWidget *twid = rofi_theme_find_widget(wid.name, wid.state, FALSE);
Property *p = rofi_theme_find_property(twid, P_COLOR, "text-color", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, 0.0, REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, 0.0, 0.004);
ck_assert_double_eq_tol(p->value.color.green, 0.0, 0.004);
ck_assert_double_eq_tol(p->value.color.blue, 0.0, 0.004);
}
}
END_TEST
START_TEST(test_properties_color_names_alpha) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
for (unsigned int iter = 0; iter < num_CSSColors; iter++) {
char *str = g_strdup_printf("* { color: %s / %d %%;}", CSSColors[iter].name,
iter % 101);
rofi_theme_parse_string(str);
ThemeWidget *twid = rofi_theme_find_widget(wid.name, wid.state, FALSE);
Property *p = rofi_theme_find_property(twid, P_COLOR, "text-color", FALSE);
ck_assert_ptr_nonnull(p);
ck_assert_double_eq_tol(p->value.color.alpha, (iter % 101) / 100.0,
REAL_COMPARE_DELTA);
ck_assert_double_eq_tol(p->value.color.red, CSSColors[iter].r / 255.0,
0.004);
ck_assert_double_eq_tol(p->value.color.green, CSSColors[iter].g / 255.0,
0.004);
ck_assert_double_eq_tol(p->value.color.blue, CSSColors[iter].b / 255.0,
0.004);
g_free(str);
}
}
END_TEST
START_TEST(test_properties_padding_2) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { test: 10px 20px;}");
RofiDistance d = (RofiDistance){
{1, ROFI_PU_PX, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL}, ROFI_HL_SOLID};
RofiPadding pi = (RofiPadding){d, d, d, d};
RofiPadding p = rofi_theme_get_padding(&wid, "test", pi);
ck_assert_double_eq_tol(p.left.base.distance, 20, REAL_COMPARE_DELTA);
ck_assert_int_eq(p.left.base.type, ROFI_PU_PX);
ck_assert_double_eq_tol(p.right.base.distance, 20, REAL_COMPARE_DELTA);
ck_assert_int_eq(p.right.base.type, ROFI_PU_PX);
ck_assert_double_eq_tol(p.top.base.distance, 10, REAL_COMPARE_DELTA);
ck_assert_int_eq(p.top.base.type, ROFI_PU_PX);
ck_assert_double_eq_tol(p.bottom.base.distance, 10, REAL_COMPARE_DELTA);
ck_assert_int_eq(p.bottom.base.type, ROFI_PU_PX);
}
END_TEST
START_TEST(test_properties_padding_3) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { test: 10px 30px 20px;}");
RofiDistance d = (RofiDistance){
{1, ROFI_PU_PX, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL}, ROFI_HL_SOLID};
RofiPadding pi = (RofiPadding){d, d, d, d};
RofiPadding p = rofi_theme_get_padding(&wid, "test", pi);
ck_assert_double_eq_tol(p.left.base.distance, 30, REAL_COMPARE_DELTA);
ck_assert_int_eq(p.left.base.type, ROFI_PU_PX);
ck_assert_double_eq_tol(p.right.base.distance, 30, REAL_COMPARE_DELTA);
ck_assert_int_eq(p.right.base.type, ROFI_PU_PX);
ck_assert_double_eq_tol(p.top.base.distance, 10, REAL_COMPARE_DELTA);
ck_assert_int_eq(p.top.base.type, ROFI_PU_PX);
ck_assert_double_eq_tol(p.bottom.base.distance, 20, REAL_COMPARE_DELTA);
ck_assert_int_eq(p.bottom.base.type, ROFI_PU_PX);
}
END_TEST
START_TEST(test_properties_padding_4) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { test: 10px 30px 20px 40px;}");
RofiDistance d = (RofiDistance){
{1, ROFI_PU_PX, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL}, ROFI_HL_SOLID};
RofiPadding pi = (RofiPadding){d, d, d, d};
RofiPadding p = rofi_theme_get_padding(&wid, "test", pi);
ck_assert_double_eq_tol(p.left.base.distance, 40, REAL_COMPARE_DELTA);
ck_assert_int_eq(p.left.base.type, ROFI_PU_PX);
ck_assert_double_eq_tol(p.right.base.distance, 30, REAL_COMPARE_DELTA);
ck_assert_int_eq(p.right.base.type, ROFI_PU_PX);
ck_assert_double_eq_tol(p.top.base.distance, 10, REAL_COMPARE_DELTA);
ck_assert_int_eq(p.top.base.type, ROFI_PU_PX);
ck_assert_double_eq_tol(p.bottom.base.distance, 20, REAL_COMPARE_DELTA);
ck_assert_int_eq(p.bottom.base.type, ROFI_PU_PX);
}
END_TEST
START_TEST(test_properties_string_escape) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string(
"* { font: \"aap\" noot\" mies \";\ntest: \"'123.432'\"; }");
const char *str = rofi_theme_get_string(&wid, "font", NULL);
ck_assert_ptr_nonnull(str);
ck_assert_int_eq(g_utf8_collate(str, "aap\" noot\" mies "), 0);
const char *str2 = rofi_theme_get_string(&wid, "test", NULL);
ck_assert_ptr_nonnull(str2);
ck_assert_int_eq(g_utf8_collate(str2, "'123.432'"), 0);
}
END_TEST
START_TEST(test_properties_string) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { font: \"blaat€\"; test: 123.432; }");
const char *str = rofi_theme_get_string(&wid, "font", NULL);
ck_assert_ptr_nonnull(str);
ck_assert_int_eq(g_utf8_collate(str, "blaat€"), 0);
}
END_TEST
START_TEST(test_properties_double) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { test: 123.432; }");
ck_assert_double_eq_tol(rofi_theme_get_double(&wid, "test", 0.0), 123.432,
REAL_COMPARE_DELTA);
}
END_TEST
START_TEST(test_properties_integer) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { yoffset: 4; }");
ck_assert_int_eq(rofi_theme_get_integer(&wid, "yoffset", 0), 4);
}
END_TEST
START_TEST(test_properties_orientation) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { vert: vertical; hori: horizontal; }");
ck_assert_int_eq(
rofi_theme_get_orientation(&wid, "vert", ROFI_ORIENTATION_HORIZONTAL),
ROFI_ORIENTATION_VERTICAL);
ck_assert_int_eq(
rofi_theme_get_orientation(&wid, "hori", ROFI_ORIENTATION_VERTICAL),
ROFI_ORIENTATION_HORIZONTAL);
// default propagation
ck_assert_int_eq(
rofi_theme_get_orientation(&wid, "notfo", ROFI_ORIENTATION_HORIZONTAL),
ROFI_ORIENTATION_HORIZONTAL);
ck_assert_int_eq(
rofi_theme_get_orientation(&wid, "notfo", ROFI_ORIENTATION_VERTICAL),
ROFI_ORIENTATION_VERTICAL);
}
END_TEST
START_TEST(test_properties_orientation_case) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { vert: Vertical; hori: HoriZonTal;}");
ck_assert_int_eq(
rofi_theme_get_orientation(&wid, "vert", ROFI_ORIENTATION_HORIZONTAL),
ROFI_ORIENTATION_VERTICAL);
ck_assert_int_eq(
rofi_theme_get_orientation(&wid, "hori", ROFI_ORIENTATION_VERTICAL),
ROFI_ORIENTATION_HORIZONTAL);
}
END_TEST
START_TEST(test_properties_cursor) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { def: default; ptr: pointer; txt: text; }");
ck_assert_int_eq(rofi_theme_get_cursor_type(&wid, "def", ROFI_CURSOR_TEXT),
ROFI_CURSOR_DEFAULT);
ck_assert_int_eq(rofi_theme_get_cursor_type(&wid, "ptr", ROFI_CURSOR_DEFAULT),
ROFI_CURSOR_POINTER);
ck_assert_int_eq(rofi_theme_get_cursor_type(&wid, "txt", ROFI_CURSOR_DEFAULT),
ROFI_CURSOR_TEXT);
}
END_TEST
START_TEST(test_properties_cursor_case) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string("* { def: dEfault; ptr: POINter; txt: tExt; }");
ck_assert_int_eq(rofi_theme_get_cursor_type(&wid, "def", ROFI_CURSOR_TEXT),
ROFI_CURSOR_DEFAULT);
ck_assert_int_eq(rofi_theme_get_cursor_type(&wid, "ptr", ROFI_CURSOR_DEFAULT),
ROFI_CURSOR_POINTER);
ck_assert_int_eq(rofi_theme_get_cursor_type(&wid, "txt", ROFI_CURSOR_DEFAULT),
ROFI_CURSOR_TEXT);
}
END_TEST
START_TEST(test_properties_list) {
widget wid;
wid.name = "blaat";
wid.state = NULL;
rofi_theme_parse_string(
"#blaat { liste: []; list1: [ one ]; list2: [ one, two ];}");
GList *list = rofi_theme_get_list_strings(&wid, "liste");
ck_assert_ptr_null(list);
list = rofi_theme_get_list_strings(&wid, "list1");
ck_assert_ptr_nonnull(list);
ck_assert_str_eq((char *)list->data, "one");
g_list_free_full(list, (GDestroyNotify)g_free);
list = rofi_theme_get_list_strings(&wid, "list2");
ck_assert_ptr_nonnull(list);
ck_assert_int_eq(g_list_length(list), 2);
list = g_list_first(list);
ck_assert_str_eq((char *)list->data, "one");
ck_assert_str_eq((char *)list->next->data, "two");
g_list_free_full(list, (GDestroyNotify)g_free);
}
END_TEST
START_TEST(test_configuration) {
rofi_theme_parse_string("configuration { font: \"blaat€\"; yoffset: 4; }");
ck_assert_int_eq(g_utf8_collate(config.menu_font, "blaat€"), 0);
ck_assert_int_eq(config.y_offset, 4);
}
END_TEST
START_TEST(test_parse_file_empty) {
rofi_theme_parse_file("/dev/null");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
}
END_TEST
START_TEST(test_parse_file_not_existing) {
rofi_theme_parse_file("/not-existing-file.rasi");
ck_assert_ptr_null(rofi_theme);
ck_assert_int_eq(error, 1);
ck_assert_str_eq(
error_msg->str,
"Failed to open theme: <i>/not-existing-file.rasi</i>\nError: <b>No such "
"file or directory</b>");
g_string_free(error_msg, TRUE);
error_msg = NULL;
error = 0;
}
END_TEST
START_TEST(test_import_empty) {
rofi_theme_parse_string("@import \"/dev/null\"");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
}
END_TEST
START_TEST(test_core_properties_error) {
rofi_theme_parse_string(" * { test: cmky(a,e,3); }");
const char *errstr =
"<big><b>Error while parsing theme:</b></big> <i> * { test: cmky(a,e,3); "
"}</i>\n"
" Parser error: <span size=\"smaller\" style=\"italic\">syntax error, "
"unexpected invalid property value</span>\n"
" Location: line 1 column 11 to line 1 column 23\n";
ck_assert_int_eq(error, 1);
ck_assert_str_eq(error_msg->str, errstr);
g_string_free(error_msg, TRUE);
error_msg = NULL;
error = 0;
const char *errstr2 =
"<big><b>Error while parsing theme:</b></big> <i></i>\n"
" Parser error: <span size=\"smaller\" style=\"italic\">Value out of "
"range: \n"
" Value: X = 500.00;\n"
" Range: 0.00 <= X <= 360.00.</span>\n"
" Location: line 0 column 15 to line 0 column 18\n";
rofi_theme_parse_string(" * { test: hsl(500, 100% 10% ); }");
ck_assert_int_eq(error, 1);
ck_assert_str_eq(error_msg->str, errstr2);
g_string_free(error_msg, TRUE);
error_msg = NULL;
error = 0;
}
END_TEST
START_TEST(test_import_error) {
rofi_theme_parse_string("@import \"/non-existing-file.rasi\"");
const char *errstr = "Failed to open theme: <i>/non-existing-file.rasi</i>\n"
"Error: <b>No such file or directory</b>";
ck_assert_int_eq(warning, 1);
ck_assert_str_eq(warning_msg->str, errstr);
g_string_free(warning_msg, TRUE);
warning_msg = NULL;
warning = 0;
}
END_TEST
START_TEST(test_prepare_array) {
widget wid;
wid.name = "element-text";
wid.state = "normal.normal";
rofi_theme_parse_string("element-text { tabs: [ 10, 20px, 30px, 40px ];}");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
GList *l = rofi_theme_get_list_distance(&wid, "tabs");
ck_assert_int_eq(g_list_length(l), 4);
int i = 10;
for (GList *iter = g_list_first(l); iter != NULL; iter = g_list_next(iter)) {
RofiDistance *d = (RofiDistance *)iter->data;
ck_assert_int_eq(d->base.distance, i);
i += 10;
}
g_list_free_full(l, g_free);
}
END_TEST
START_TEST(test_prepare_math_floor) {
widget wid;
wid.name = "window";
wid.state = "";
rofi_theme_parse_string("window { width: calc( 1024 floor 30 );}");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
ck_assert_int_eq(dist, 1020);
}
END_TEST
START_TEST(test_prepare_math_ceil) {
widget wid;
wid.name = "window";
wid.state = "";
rofi_theme_parse_string("window { width: calc( 1024 ceil 30 );}");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
ck_assert_int_eq(dist, 1050);
}
END_TEST
START_TEST(test_prepare_math_round) {
widget wid;
wid.name = "window";
wid.state = "";
rofi_theme_parse_string("window { width: calc( 1036 round 30 );}");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
ck_assert_int_eq(dist, 1050);
}
END_TEST
START_TEST(test_prepare_math_add) {
widget wid;
wid.name = "window";
wid.state = "";
rofi_theme_parse_string("window { width: calc( 1036 + 30 );}");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
ck_assert_int_eq(dist, 1066);
}
END_TEST
START_TEST(test_prepare_math_subtract) {
widget wid;
wid.name = "window";
wid.state = "";
rofi_theme_parse_string("window { width: calc( 1036 - 30 );}");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
ck_assert_int_eq(dist, 1006);
}
END_TEST
START_TEST(test_prepare_math_multiply) {
widget wid;
wid.name = "window";
wid.state = "";
rofi_theme_parse_string("window { width: calc( 256*4 );}");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
ck_assert_int_eq(dist, 1024);
}
END_TEST
START_TEST(test_prepare_math_modulo) {
widget wid;
wid.name = "window";
wid.state = "";
rofi_theme_parse_string("window { width: calc( 255 modulo 4 modulo 5 );}");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
ck_assert_int_eq(dist, 3);
}
END_TEST
START_TEST(test_prepare_math_min) {
widget wid;
wid.name = "window";
wid.state = "";
rofi_theme_parse_string("window { width: calc( 256 min 4 );}");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
ck_assert_int_eq(dist, 4);
}
END_TEST
START_TEST(test_prepare_math_max) {
widget wid;
wid.name = "window";
wid.state = "";
rofi_theme_parse_string("window { width: calc( 256 max 4 );}");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
ck_assert_int_eq(dist, 256);
}
END_TEST
START_TEST(test_prepare_math_failure) {
widget wid;
wid.name = "window";
wid.state = "";
rofi_theme_parse_string("window { width: calc( 1/2 * 500 );}");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
ck_assert_int_eq(dist, 250);
}
END_TEST
START_TEST(test_prepare_math_failure2) {
widget wid;
wid.name = "window";
wid.state = "";
rofi_theme_parse_string("window { width: calc( -16/2 * 1.5 );}");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
ck_assert_int_eq(dist, -12);
}
END_TEST
START_TEST(test_prepare_math_failure3) {
widget wid;
wid.name = "window";
wid.state = "";
rofi_theme_parse_string("window { width: calc(10+3);}");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
ck_assert_int_eq(dist, 13);
}
END_TEST
START_TEST(test_prepare_math_failure4) {
widget wid;
wid.name = "window";
wid.state = "";
rofi_theme_parse_string("window { width: calc(10.0+3.2);}");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
ck_assert_int_eq(dist, 13);
}
END_TEST
START_TEST(test_prepare_math_failure5) {
widget wid;
wid.name = "window";
wid.state = "";
rofi_theme_parse_string("window { width: calc(10-3);}");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
ck_assert_int_eq(dist, 7);
}
END_TEST
START_TEST(test_prepare_math_failure6) {
widget wid;
wid.name = "window";
wid.state = "";
rofi_theme_parse_string("window { width: calc(10.0-3.2);}");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
ck_assert_int_eq(dist, 6);
}
END_TEST
START_TEST(test_prepare_math_failure7) {
widget wid;
wid.name = "window";
wid.state = "";
rofi_theme_parse_string("window { width: calc(-10--3);}");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
ck_assert_int_eq(dist, -7);
}
END_TEST
START_TEST(test_prepare_math_failure8) {
widget wid;
wid.name = "window";
wid.state = "";
rofi_theme_parse_string("window { width: calc(-10.0--3.2);}");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
ck_assert_int_eq(dist, -6);
}
END_TEST
START_TEST(test_prepare_math_failure9) {
widget wid;
wid.name = "window";
wid.state = "";
rofi_theme_parse_string("window { width: -128;}");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
ck_assert_int_eq(dist, -128);
}
END_TEST
START_TEST(test_prepare_default) {
rofi_theme_parse_string("@import \"default\"");
ck_assert_ptr_null(error_msg);
ck_assert_ptr_nonnull(rofi_theme);
}
END_TEST
START_TEST(test_prepare_environment_nf) {
widget wid;
wid.name = "window";
wid.state = "";
rofi_theme_parse_string("window { width: env(QER_TEST,128); }");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
ck_assert_int_eq(dist, 128);
}
END_TEST
START_TEST(test_prepare_environment_f) {
widget wid;
wid.name = "window";
wid.state = "";
setenv("QER_TEST", "64", 1);
rofi_theme_parse_string("window { width: env(QER_TEST,128); }");
unsetenv("QER_TEST");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
ck_assert_int_eq(dist, 64);
}
END_TEST
START_TEST(test_prepare_environment_old_style) {
widget wid;
wid.name = "window";
wid.state = "";
setenv("QER_TEST", "64", 1);
rofi_theme_parse_string("window { width: ${QER_TEST}; }");
rofi_theme_parse_process_conditionals();
unsetenv("QER_TEST");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
ck_assert_int_eq(dist, 64);
}
END_TEST
START_TEST(test_prepare_environment_media_f) {
widget wid;
wid.name = "window";
wid.state = "";
setenv("QER_TEST", "true", 1);
rofi_theme_parse_string("window { width: 32; } @media( enabled: "
"env(QER_TEST,false)){ window {width:64; }}");
rofi_theme_parse_process_conditionals();
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
unsetenv("QER_TEST");
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
ck_assert_int_eq(dist, 64);
}
END_TEST
START_TEST(test_prepare_environment_media_nf) {
widget wid;
wid.name = "window";
wid.state = "";
rofi_theme_parse_string("window { width: 32; } @media( enabled: "
"env(QER_TEST,false)){ window {width:64; }}");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
ck_assert_ptr_null(rofi_theme->parent);
ck_assert_str_eq(rofi_theme->name, "Root");
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
ck_assert_int_eq(dist, 32);
}
END_TEST
START_TEST(test_prepare_path) {
char *current_dir = g_get_current_dir();
ck_assert_ptr_nonnull(current_dir);
char *f = rofi_theme_parse_prepare_file("../");
ck_assert_ptr_nonnull(f);
ck_assert_int_eq(*f, '/');
ck_assert_str_ne(f, current_dir);
ck_assert(g_str_has_prefix(current_dir, f) == TRUE);
g_free(f);
g_free(current_dir);
}
END_TEST
START_TEST(test_properties_types_names) {
ck_assert_str_eq(PropertyTypeName[P_INTEGER], "Integer");
ck_assert_str_eq(PropertyTypeName[P_DOUBLE], "Double");
ck_assert_str_eq(PropertyTypeName[P_STRING], "String");
ck_assert_str_eq(PropertyTypeName[P_BOOLEAN], "Boolean");
ck_assert_str_eq(PropertyTypeName[P_COLOR], "Color");
ck_assert_str_eq(PropertyTypeName[P_PADDING], "Padding");
ck_assert_str_eq(PropertyTypeName[P_LINK], "Reference");
ck_assert_str_eq(PropertyTypeName[P_POSITION], "Position");
ck_assert_str_eq(PropertyTypeName[P_HIGHLIGHT], "Highlight");
ck_assert_str_eq(PropertyTypeName[P_LIST], "List");
ck_assert_str_eq(PropertyTypeName[P_ORIENTATION], "Orientation");
}
END_TEST
static Suite *theme_parser_suite(void) {
Suite *s;
s = suite_create("Theme");
/* Core test case */
{
TCase *tc_core = tcase_create("Core");
tcase_add_checked_fixture(tc_core, theme_parser_setup,
theme_parser_teardown);
tcase_add_test(tc_core, test_properties_types_names);
tcase_add_test(tc_core, test_core_empty_string);
tcase_add_test(tc_core, test_core_empty_global_section);
tcase_add_test(tc_core, test_core_empty_section);
tcase_add_test(tc_core, test_core_error_root);
tcase_add_test(tc_core, test_core_comments);
tcase_add_test(tc_core, test_core_newline);
tcase_add_test(tc_core, test_core_properties_error);
suite_add_tcase(s, tc_core);
}
{
TCase *tc_prop_bool = tcase_create("PropertiesBoolean");
tcase_add_checked_fixture(tc_prop_bool, theme_parser_setup,
theme_parser_teardown);
tcase_add_test(tc_prop_bool, test_properties_boolean);
tcase_add_test(tc_prop_bool, test_properties_boolean_reference);
suite_add_tcase(s, tc_prop_bool);
}
{
TCase *tc_prop_distance = tcase_create("PropertiesDistance");
tcase_add_checked_fixture(tc_prop_distance, theme_parser_setup,
theme_parser_teardown);
tcase_add_test(tc_prop_distance, test_properties_distance_em);
tcase_add_test(tc_prop_distance, test_properties_distance_ch);
tcase_add_test(tc_prop_distance, test_properties_distance_px);
tcase_add_test(tc_prop_distance, test_properties_distance_percent);
tcase_add_test(tc_prop_distance, test_properties_distance_em_linestyle);
tcase_add_test(tc_prop_distance, test_properties_distance_ch_linestyle);
tcase_add_test(tc_prop_distance, test_properties_distance_px_linestyle);
tcase_add_test(tc_prop_distance, test_properties_distance_mm);
tcase_add_test(tc_prop_distance, test_properties_distance_mm_linestyle);
tcase_add_test(tc_prop_distance,
test_properties_distance_percent_linestyle);
suite_add_tcase(s, tc_prop_distance);
}
{
TCase *tc_prop_position = tcase_create("PropertiesPosition");
tcase_add_checked_fixture(tc_prop_position, theme_parser_setup,
theme_parser_teardown);
tcase_add_test(tc_prop_position, test_properties_position);
suite_add_tcase(s, tc_prop_position);
}
{
TCase *tc_prop_style = tcase_create("PropertiesStyle");
tcase_add_checked_fixture(tc_prop_style, theme_parser_setup,
theme_parser_teardown);
tcase_add_test(tc_prop_style, test_properties_style);
tcase_add_test(tc_prop_style, test_properties_style2);
tcase_add_test(tc_prop_style, test_properties_style_color);
suite_add_tcase(s, tc_prop_style);
}
{
TCase *tc_prop_color = tcase_create("PropertiesColor");
tcase_add_checked_fixture(tc_prop_color, theme_parser_setup,
theme_parser_teardown);
tcase_add_test(tc_prop_color, test_properties_color_h3);
tcase_add_test(tc_prop_color, test_properties_color_h4);
tcase_add_test(tc_prop_color, test_properties_color_h6);
tcase_add_test(tc_prop_color, test_properties_color_h8);
tcase_add_test(tc_prop_color, test_properties_color_rgb);
tcase_add_test(tc_prop_color, test_properties_color_rgba);
tcase_add_test(tc_prop_color, test_properties_color_rgba_percent);
tcase_add_test(tc_prop_color, test_properties_color_rgb_p);
tcase_add_test(tc_prop_color, test_properties_color_rgba_p);
tcase_add_test(tc_prop_color, test_properties_color_rgba_percent_p);
tcase_add_test(tc_prop_color, test_properties_color_argb);
tcase_add_test(tc_prop_color, test_properties_color_hsl);
tcase_add_test(tc_prop_color, test_properties_color_hsla);
tcase_add_test(tc_prop_color, test_properties_color_hsl_ws);
tcase_add_test(tc_prop_color, test_properties_color_hsla_ws);
tcase_add_test(tc_prop_color, test_properties_color_hwb);
tcase_add_test(tc_prop_color, test_properties_color_hwb_ws);
tcase_add_test(tc_prop_color, test_properties_color_cmyk);
tcase_add_test(tc_prop_color, test_properties_color_cmyk_ws);
tcase_add_test(tc_prop_color, test_properties_color_names);
tcase_add_test(tc_prop_color, test_properties_color_names_alpha);
suite_add_tcase(s, tc_prop_color);
}
{
TCase *tc_prop_padding = tcase_create("PropertiesPadding");
tcase_add_checked_fixture(tc_prop_padding, theme_parser_setup,
theme_parser_teardown);
tcase_add_test(tc_prop_padding, test_properties_padding_2);
tcase_add_test(tc_prop_padding, test_properties_padding_3);
tcase_add_test(tc_prop_padding, test_properties_padding_4);
suite_add_tcase(s, tc_prop_padding);
}
{
TCase *tc_prop_string = tcase_create("PropertiesString");
tcase_add_checked_fixture(tc_prop_string, theme_parser_setup,
theme_parser_teardown);
tcase_add_test(tc_prop_string, test_properties_string);
tcase_add_test(tc_prop_string, test_properties_string_escape);
suite_add_tcase(s, tc_prop_string);
}
{
TCase *tc_prop_double = tcase_create("PropertiesDouble");
tcase_add_checked_fixture(tc_prop_double, theme_parser_setup,
theme_parser_teardown);
tcase_add_test(tc_prop_double, test_properties_double);
suite_add_tcase(s, tc_prop_double);
}
{
TCase *tc_prop_integer = tcase_create("PropertiesInteger");
tcase_add_checked_fixture(tc_prop_integer, theme_parser_setup,
theme_parser_teardown);
tcase_add_test(tc_prop_integer, test_properties_integer);
suite_add_tcase(s, tc_prop_integer);
}
{
TCase *tc_prop_orientation = tcase_create("Propertiesorientation");
tcase_add_checked_fixture(tc_prop_orientation, theme_parser_setup,
theme_parser_teardown);
tcase_add_test(tc_prop_orientation, test_properties_orientation);
tcase_add_test(tc_prop_orientation, test_properties_orientation_case);
suite_add_tcase(s, tc_prop_orientation);
}
{
TCase *tc_prop_cursor = tcase_create("Propertiescursor");
tcase_add_checked_fixture(tc_prop_cursor, theme_parser_setup,
theme_parser_teardown);
tcase_add_test(tc_prop_cursor, test_properties_cursor);
tcase_add_test(tc_prop_cursor, test_properties_cursor_case);
suite_add_tcase(s, tc_prop_cursor);
}
{
TCase *tc_prop_configuration = tcase_create("Configuration");
tcase_add_checked_fixture(tc_prop_configuration, theme_parser_setup,
theme_parser_teardown);
tcase_add_test(tc_prop_configuration, test_configuration);
suite_add_tcase(s, tc_prop_configuration);
}
{
TCase *tc_prop_list = tcase_create("Propertieslist");
tcase_add_checked_fixture(tc_prop_list, theme_parser_setup,
theme_parser_teardown);
tcase_add_test(tc_prop_list, test_properties_list);
suite_add_tcase(s, tc_prop_list);
}
{
TCase *tc_prop_parse_file = tcase_create("ParseFile");
tcase_add_checked_fixture(tc_prop_parse_file, theme_parser_setup,
theme_parser_teardown);
tcase_add_test(tc_prop_parse_file, test_parse_file_empty);
tcase_add_test(tc_prop_parse_file, test_parse_file_not_existing);
suite_add_tcase(s, tc_prop_parse_file);
}
{
TCase *tc_prop_import = tcase_create("Import");
tcase_add_checked_fixture(tc_prop_import, theme_parser_setup,
theme_parser_teardown);
tcase_add_test(tc_prop_import, test_import_empty);
tcase_add_test(tc_prop_import, test_import_error);
suite_add_tcase(s, tc_prop_import);
}
{
TCase *tc_prepare_path = tcase_create("prepare_path");
tcase_add_test(tc_prepare_path, test_prepare_path);
suite_add_tcase(s, tc_prepare_path);
}
{
TCase *tc_prepare_array = tcase_create("array");
tcase_add_test(tc_prepare_array, test_prepare_array);
suite_add_tcase(s, tc_prepare_array);
}
{
TCase *tc_prepare_default = tcase_create("default");
tcase_add_test(tc_prepare_default, test_prepare_default);
suite_add_tcase(s, tc_prepare_default);
}
{
TCase *tc_prepare_math = tcase_create("math");
tcase_add_test(tc_prepare_math, test_prepare_math_add);
tcase_add_test(tc_prepare_math, test_prepare_math_subtract);
tcase_add_test(tc_prepare_math, test_prepare_math_multiply);
tcase_add_test(tc_prepare_math, test_prepare_math_modulo);
tcase_add_test(tc_prepare_math, test_prepare_math_floor);
tcase_add_test(tc_prepare_math, test_prepare_math_ceil);
tcase_add_test(tc_prepare_math, test_prepare_math_round);
tcase_add_test(tc_prepare_math, test_prepare_math_min);
tcase_add_test(tc_prepare_math, test_prepare_math_max);
tcase_add_test(tc_prepare_math, test_prepare_math_failure);
tcase_add_test(tc_prepare_math, test_prepare_math_failure2);
tcase_add_test(tc_prepare_math, test_prepare_math_failure3);
tcase_add_test(tc_prepare_math, test_prepare_math_failure4);
tcase_add_test(tc_prepare_math, test_prepare_math_failure5);
tcase_add_test(tc_prepare_math, test_prepare_math_failure6);
tcase_add_test(tc_prepare_math, test_prepare_math_failure7);
tcase_add_test(tc_prepare_math, test_prepare_math_failure8);
tcase_add_test(tc_prepare_math, test_prepare_math_failure9);
suite_add_tcase(s, tc_prepare_math);
}
{
TCase *tc_prepare_default = tcase_create("environment");
tcase_add_test(tc_prepare_default, test_prepare_environment_nf);
tcase_add_test(tc_prepare_default, test_prepare_environment_f);
tcase_add_test(tc_prepare_default, test_prepare_environment_old_style);
tcase_add_test(tc_prepare_default, test_prepare_environment_media_f);
tcase_add_test(tc_prepare_default, test_prepare_environment_media_nf);
suite_add_tcase(s, tc_prepare_default);
}
return s;
}
int main(int argc, char **argv) {
cmd_set_arguments(argc, argv);
if (setlocale(LC_ALL, "C") == NULL) {
fprintf(stderr, "Failed to set locale.\n");
return EXIT_FAILURE;
}
Suite *s;
SRunner *sr;
s = theme_parser_suite();
sr = srunner_create(s);
srunner_run_all(sr, CK_NORMAL);
int number_failed = srunner_ntests_failed(sr);
srunner_free(sr);
return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
|
0a1b42838d9abd04be06313063e26b6b70e3d950
|
a8194cf6ffd12f7551eaba53572744080a0bfef3
|
/module/vfu_device/vfu_virtio_internal.h
|
992cf722d370befe4ee3acbe3b6acfa10b2d8747
|
[
"Intel",
"BSD-2-Clause",
"BSD-3-Clause"
] |
permissive
|
spdk/spdk
|
51294f67104b8c3d18f19147d63a212e9486c687
|
d62a3810364cb87be352c66acf7c7f968508ca17
|
refs/heads/master
| 2023-08-08T16:07:41.263000
| 2023-08-02T09:06:56
| 2023-08-08T07:01:20
| 39,042,157
| 2,708
| 1,158
|
NOASSERTION
| 2023-08-11T09:50:50
| 2015-07-13T23:15:15
|
C
|
UTF-8
|
C
| false
| false
| 12,165
|
h
|
vfu_virtio_internal.h
|
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (C) 2022 Intel Corporation.
* All rights reserved.
*/
#ifndef _VFU_VIRTIO_INTERNAL_H
#define _VFU_VIRTIO_INTERNAL_H
#include <linux/virtio_config.h>
#include <linux/virtio_ring.h>
#include <linux/virtio_pci.h>
#include "spdk/vfu_target.h"
#define VIRTIO_HOST_SUPPORTED_FEATURES ((1ULL << VIRTIO_F_VERSION_1) | \
(1ULL << VIRTIO_RING_F_INDIRECT_DESC) | \
(1ULL << VIRTIO_F_RING_PACKED))
/* virtio device layout:
*
* region 1: MSI-X Table
* region 2: MSI-X PBA
* region 4: virtio modern memory 64bits BAR
* Common configuration 0x0 - 0x1000
* ISR access 0x1000 - 0x2000
* Device specific configuration 0x2000 - 0x3000
* Notifications 0x3000 - 0x4000
*/
#define VIRTIO_PCI_COMMON_CFG_OFFSET (0x0)
#define VIRTIO_PCI_COMMON_CFG_LENGTH (0x1000)
#define VIRTIO_PCI_ISR_ACCESS_OFFSET (VIRTIO_PCI_COMMON_CFG_OFFSET + VIRTIO_PCI_COMMON_CFG_LENGTH)
#define VIRTIO_PCI_ISR_ACCESS_LENGTH (0x1000)
#define VIRTIO_PCI_SPECIFIC_CFG_OFFSET (VIRTIO_PCI_ISR_ACCESS_OFFSET + VIRTIO_PCI_ISR_ACCESS_LENGTH)
#define VIRTIO_PCI_SPECIFIC_CFG_LENGTH (0x1000)
#define VIRTIO_PCI_NOTIFICATIONS_OFFSET (VIRTIO_PCI_SPECIFIC_CFG_OFFSET + VIRTIO_PCI_SPECIFIC_CFG_LENGTH)
#define VIRTIO_PCI_NOTIFICATIONS_LENGTH (0x1000)
#define VIRTIO_PCI_BAR4_LENGTH (VIRTIO_PCI_NOTIFICATIONS_OFFSET + VIRTIO_PCI_NOTIFICATIONS_LENGTH)
#define VIRTIO_DEV_MAX_IOVS (129)
/* Maximum number of requests which can be processed one time */
#define VIRTIO_DEV_VRING_MAX_REQS (32)
/* Maximum number of queues can be supported by virtio device */
#define VIRTIO_DEV_MAX_VQS (64)
/* Default queue size */
#define VIRTIO_VQ_DEFAULT_SIZE (128)
/* Maximum queue size */
#define VIRTIO_VQ_MAX_SIZE (1024)
struct vfu_virtio_endpoint;
struct vfu_virtio_req;
struct virtio_pci_cfg {
/* Common PCI configuration */
uint32_t guest_feat_lo;
uint32_t guest_feat_hi;
/* Negotiated feature bits */
uint64_t guest_features;
uint32_t host_feature_select;
uint32_t guest_feature_select;
uint16_t msix_config;
uint8_t device_status;
uint8_t config_generation;
uint16_t queue_select;
/* ISR access */
uint8_t isr;
};
enum vfu_vq_state {
VFU_VQ_CREATED = 0,
VFU_VQ_ACTIVE,
VFU_VQ_INACTIVE,
};
struct q_mapping {
/* iov of local process mapping. */
struct iovec iov;
/* Stored sg, needed for unmap. */
dma_sg_t *sg;
/* physical address */
uint64_t phys_addr;
/* virtual address */
union {
void *addr;
struct vring_desc *desc;
struct vring_packed_desc *desc_packed;
struct vring_avail *avail;
struct vring_packed_desc_event *driver_event;
struct vring_used *used;
struct vring_packed_desc_event *device_event;
};
/* size in bytes */
uint64_t len;
};
struct vfu_virtio_vq {
/* Read Only */
uint16_t id;
uint16_t qsize;
bool enabled;
uint16_t vector;
enum vfu_vq_state q_state;
STAILQ_HEAD(, vfu_virtio_req) free_reqs;
uint32_t desc_lo;
uint32_t desc_hi;
uint32_t avail_lo;
uint32_t avail_hi;
uint32_t used_lo;
uint32_t used_hi;
struct q_mapping avail;
struct q_mapping used;
struct q_mapping desc;
uint16_t last_avail_idx;
uint16_t last_used_idx;
struct {
/* To mark a descriptor as available in packed ring
* Equal to avail_wrap_counter in spec.
*/
uint8_t avail_phase : 1;
/* To mark a descriptor as used in packed ring
* Equal to used_wrap_counter in spec.
*/
uint8_t used_phase : 1;
uint8_t padding : 5;
bool packed_ring : 1;
} packed;
/* Request count from last event */
uint16_t used_req_cnt;
/* Next time when we need to send event */
uint64_t next_event_time;
};
struct vfu_virtio_dev {
char name[SPDK_VFU_MAX_NAME_LEN];
/* RO for Guest Driver */
uint16_t num_queues;
/* Supported feature bits by host driver, RO for Guest Driver */
uint64_t host_features;
struct virtio_pci_cfg cfg;
struct vfu_virtio_vq vqs[VIRTIO_DEV_MAX_VQS];
struct vfu_virtio_endpoint *virtio_endpoint;
/* VIRTIO_DEV_MAX_VQS * 3 worth of dma_sg_size() */
uint8_t sg[];
};
struct vfu_virtio_ops {
uint64_t (*get_device_features)(struct vfu_virtio_endpoint *virtio_endpoint);
struct vfu_virtio_req *(*alloc_req)(struct vfu_virtio_endpoint *virtio_endpoint,
struct vfu_virtio_vq *vq);
void (*free_req)(struct vfu_virtio_endpoint *virtio_endpoint, struct vfu_virtio_vq *vq,
struct vfu_virtio_req *req);
int (*exec_request)(struct vfu_virtio_endpoint *virtio_endpoint, struct vfu_virtio_vq *vq,
struct vfu_virtio_req *req);
int (*get_config)(struct vfu_virtio_endpoint *virtio_endpoint, char *buf, uint64_t offset,
uint64_t count);
int (*set_config)(struct vfu_virtio_endpoint *virtio_endpoint, char *buf, uint64_t offset,
uint64_t count);
int (*start_device)(struct vfu_virtio_endpoint *virtio_endpoint);
int (*stop_device)(struct vfu_virtio_endpoint *virtio_endpoint);
};
struct vfu_virtio_endpoint {
struct vfu_virtio_dev *dev;
int devmem_fd;
volatile uint32_t *doorbells;
uint16_t num_queues;
uint16_t qsize;
bool packed_ring;
uint32_t coalescing_delay_us;
struct spdk_vfu_endpoint *endpoint;
struct spdk_thread *thread;
struct vfu_virtio_ops virtio_ops;
/* quiesce poller */
uint32_t io_outstanding;
bool quiesce_in_progress;
struct spdk_poller *quiesce_poller;
};
struct vfu_virtio_req {
struct vfu_virtio_dev *dev;
struct vfu_virtio_vq *vq;
STAILQ_ENTRY(vfu_virtio_req) link;
uint32_t payload_size;
uint32_t used_len;
/* split vring */
uint16_t req_idx;
/* packed vring */
uint16_t buffer_id;
uint16_t num_descs;
uint16_t iovcnt;
struct iovec iovs[VIRTIO_DEV_MAX_IOVS + 1];
uint8_t desc_writeable[VIRTIO_DEV_MAX_IOVS + 1];
struct iovec *indirect_iov;
dma_sg_t *indirect_sg;
/* VIRIO_DEV_MAX_IOVS + 1 worth of dma_sg_size() */
uint8_t sg[];
};
static inline bool
virtio_guest_has_feature(struct vfu_virtio_dev *dev, uint32_t feature_bit)
{
assert(feature_bit <= 64);
return !!(dev->cfg.guest_features & (1ULL << feature_bit));
}
static inline uint64_t
virtio_queue_desc_size(struct vfu_virtio_dev *dev, struct vfu_virtio_vq *vq)
{
return sizeof(struct vring_desc) * vq->qsize;
}
static inline uint64_t
virtio_queue_avail_size(struct vfu_virtio_dev *dev, struct vfu_virtio_vq *vq)
{
uint16_t event_size;
if (virtio_guest_has_feature(dev, VIRTIO_F_RING_PACKED)) {
return sizeof(struct vring_packed_desc_event);
}
event_size = virtio_guest_has_feature(dev, VIRTIO_RING_F_EVENT_IDX) ? 2 : 0;
return (sizeof(struct vring_avail) + sizeof(uint16_t) * vq->qsize
+ event_size);
}
static inline uint64_t
virtio_queue_used_size(struct vfu_virtio_dev *dev, struct vfu_virtio_vq *vq)
{
uint16_t event_size;
if (virtio_guest_has_feature(dev, VIRTIO_F_RING_PACKED)) {
return sizeof(struct vring_packed_desc_event);
}
event_size = virtio_guest_has_feature(dev, VIRTIO_RING_F_EVENT_IDX) ? 2 : 0;
return (sizeof(struct vring_used) + sizeof(struct vring_used_elem) * vq->qsize
+ event_size);
}
static inline bool
virtio_queue_event_is_suppressed(struct vfu_virtio_dev *dev, struct vfu_virtio_vq *vq)
{
bool is_suppressed = false;
if (virtio_guest_has_feature(dev, VIRTIO_F_RING_PACKED)) {
is_suppressed = vq->avail.driver_event->flags & VRING_PACKED_EVENT_FLAG_DISABLE;
} else {
is_suppressed = vq->avail.avail->flags & VRING_AVAIL_F_NO_INTERRUPT;
}
return is_suppressed;
}
static inline bool
virtio_dev_is_started(struct vfu_virtio_dev *dev)
{
return !!(dev->cfg.device_status & VIRTIO_CONFIG_S_DRIVER_OK);
}
static inline bool
virtio_vring_split_desc_is_indirect(struct vring_desc *desc)
{
return !!(desc->flags & VRING_DESC_F_INDIRECT);
}
static inline bool
virtio_vring_packed_desc_is_indirect(struct vring_packed_desc *desc)
{
return !!(desc->flags & VRING_DESC_F_INDIRECT);
}
static inline bool
virtio_vring_split_desc_is_wr(struct vring_desc *desc)
{
return !!(desc->flags & VRING_DESC_F_WRITE);
}
static inline bool
virtio_vring_packed_desc_is_wr(struct vring_packed_desc *desc)
{
return !!(desc->flags & VRING_DESC_F_WRITE);
}
static inline bool
virtio_vring_packed_is_avail(struct vring_packed_desc *desc, bool avail_phase)
{
bool avail_flag, used_flag;
uint16_t flags = desc->flags;
avail_flag = !!(flags & (1 << VRING_PACKED_DESC_F_AVAIL));
used_flag = !!(flags & (1 << VRING_PACKED_DESC_F_USED));
/* To mark a desc as available, the driver sets the F_AVAIL bit in flags
* to match the internal avail wrap counter. It also sets the F_USED bit to
* match the inverse value but it's not mandatory.
*/
return (avail_flag != used_flag) && (avail_flag == avail_phase);
}
static inline bool
virtio_vring_packed_is_used(struct vring_packed_desc *desc, bool used_phase)
{
bool avail_flag, used_flag;
uint16_t flags = desc->flags;
avail_flag = !!(flags & (1 << VRING_PACKED_DESC_F_AVAIL));
used_flag = !!(flags & (1 << VRING_PACKED_DESC_F_USED));
/* When the descriptor is used, two flags in descriptor
* avail flag and used flag are set to equal
* and used flag value == used_wrap_counter.
*/
return (used_flag == avail_flag) && (used_flag == used_phase);
}
static inline bool
virtio_req_iov_is_wr(struct vfu_virtio_req *req, uint32_t iov_num)
{
assert(iov_num <= VIRTIO_DEV_MAX_IOVS);
return req->desc_writeable[iov_num];
}
static inline struct vfu_virtio_req *
vfu_virtio_vq_alloc_req(struct vfu_virtio_endpoint *endpoint, struct vfu_virtio_vq *vq)
{
assert(endpoint->virtio_ops.alloc_req != NULL);
return endpoint->virtio_ops.alloc_req(endpoint, vq);
}
static inline void
vfu_virtio_vq_free_req(struct vfu_virtio_endpoint *endpoint, struct vfu_virtio_vq *vq,
struct vfu_virtio_req *req)
{
assert(endpoint->virtio_ops.free_req);
endpoint->virtio_ops.free_req(endpoint, vq, req);
}
void virtio_vq_used_ring_split_enqueue(struct vfu_virtio_vq *vq, uint16_t req_idx,
uint32_t used_len);
void virtio_vq_used_ring_packed_enqueue(struct vfu_virtio_vq *vq, uint16_t buffer_id,
uint32_t num_descs, uint32_t used_len);
struct vfu_virtio_req *virito_dev_packed_ring_get_next_avail_req(struct vfu_virtio_dev *dev,
struct vfu_virtio_vq *vq);
struct vfu_virtio_req *virito_dev_split_ring_get_next_avail_req(struct vfu_virtio_dev *dev,
struct vfu_virtio_vq *vq);
int vfu_virtio_quiesce_cb(struct spdk_vfu_endpoint *endpoint);
void vfu_virtio_dev_put_req(struct vfu_virtio_req *req);
void vfu_virtio_finish_req(struct vfu_virtio_req *req);
void vfu_virtio_vq_flush_irq(struct vfu_virtio_dev *dev, struct vfu_virtio_vq *vq);
int vfu_virito_dev_process_packed_ring(struct vfu_virtio_dev *dev, struct vfu_virtio_vq *vq);
int vfu_virito_dev_process_split_ring(struct vfu_virtio_dev *dev, struct vfu_virtio_vq *vq);
void vfu_virtio_notify_config(struct vfu_virtio_endpoint *virtio_endpoint);
int vfu_virtio_endpoint_setup(struct vfu_virtio_endpoint *virtio_endpoint,
struct spdk_vfu_endpoint *endpoint,
char *basename, const char *endpoint_name,
struct vfu_virtio_ops *ops);
int vfu_virtio_endpoint_destruct(struct vfu_virtio_endpoint *virtio_endpoint);
void vfu_virtio_get_device_info(struct vfu_virtio_endpoint *virtio_endpoint,
struct spdk_vfu_pci_device *device_info);
int vfu_virtio_attach_device(struct spdk_vfu_endpoint *endpoint);
int vfu_virtio_detach_device(struct spdk_vfu_endpoint *endpoint);
uint16_t vfu_virtio_get_vendor_capability(struct spdk_vfu_endpoint *endpoint, char *buf,
uint16_t buf_len, uint16_t idx);
int vfu_virtio_post_memory_add(struct spdk_vfu_endpoint *endpoint, void *map_start, void *map_end);
int vfu_virtio_pre_memory_remove(struct spdk_vfu_endpoint *endpoint, void *map_start,
void *map_end);
int vfu_virtio_pci_reset_cb(struct spdk_vfu_endpoint *endpoint);
int vfu_virtio_blk_add_bdev(const char *name, const char *bdev_name,
uint16_t num_queues, uint16_t qsize, bool packed_ring);
/* virtio_scsi */
int vfu_virtio_scsi_add_target(const char *name, uint8_t scsi_target_num,
const char *bdev_name);
int vfu_virtio_scsi_remove_target(const char *name, uint8_t scsi_target_num);
int vfu_virtio_scsi_set_options(const char *name, uint16_t num_io_queues, uint16_t qsize,
bool packed_ring);
#endif
|
b08f50fe4244fb2a3b0cfa92a6596a6c2860394f
|
2d5f297ec3274ce93f1f5592d5b80c2605f8edc5
|
/pcg.h
|
55859a1e63d15d1d5d0b110c28561a064c5a446c
|
[
"Apache-2.0"
] |
permissive
|
BachiLi/diffvg
|
9ec3e3e7b3674c82ca42b18fe49c69991c076370
|
6f60468bfdef5b9fec8cc3fa47b441dc2720eefc
|
refs/heads/master
| 2023-06-21T18:49:09.604301
| 2023-06-13T17:16:46
| 2023-06-13T17:16:46
| 292,727,955
| 747
| 134
|
Apache-2.0
| 2023-06-13T17:16:47
| 2020-09-04T02:23:40
|
Python
|
UTF-8
|
C
| false
| false
| 1,151
|
h
|
pcg.h
|
#pragma once
#include "diffvg.h"
// http://www.pcg-random.org/download.html
struct pcg32_state {
uint64_t state;
uint64_t inc;
};
DEVICE inline uint32_t next_pcg32(pcg32_state *rng) {
uint64_t oldstate = rng->state;
// Advance internal state
rng->state = oldstate * 6364136223846793005ULL + (rng->inc|1);
// Calculate output function (XSH RR), uses old state for max ILP
uint32_t xorshifted = ((oldstate >> 18u) ^ oldstate) >> 27u;
uint32_t rot = oldstate >> 59u;
return (xorshifted >> rot) | (xorshifted << ((-rot) & 31));
}
// https://github.com/wjakob/pcg32/blob/master/pcg32.h
DEVICE inline float next_pcg32_float(pcg32_state *rng) {
union {
uint32_t u;
float f;
} x;
x.u = (next_pcg32(rng) >> 9) | 0x3f800000u;
return x.f - 1.0f;
}
// Initialize each pixel with a PCG rng with a different stream
DEVICE inline pcg32_state init_pcg32(int idx, uint64_t seed) {
pcg32_state state;
state.state = 0U;
state.inc = (((uint64_t)idx + 1) << 1u) | 1u;
next_pcg32(&state);
state.state += (0x853c49e6748fea9bULL + seed);
next_pcg32(&state);
return state;
}
|
f274414289a5e77708fc9610c3a4b9b2b1bd8a72
|
229a28fc18c13bfe1ba7fc81c38b03651ed8e93b
|
/sw/vendor/riscv-isa-sim/dummy_rocc/dummy_rocc_test.c
|
94de8c041e77e615c1d1ff7f433db5af14421753
|
[
"LicenseRef-scancode-bsd-3-clause-jtag",
"GPL-3.0-or-later",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
pulp-platform/snitch
|
d3967742434fa21e8af71afa6be35ea5420166ca
|
d026f47843f0ea6c269244c4e6851e0e09141ec3
|
refs/heads/master
| 2023-08-24T08:42:36.230951
| 2023-06-19T09:34:05
| 2023-06-19T09:34:05
| 289,236,605
| 194
| 44
|
Apache-2.0
| 2023-07-11T12:46:26
| 2020-08-21T09:57:34
|
SystemVerilog
|
UTF-8
|
C
| false
| false
| 977
|
c
|
dummy_rocc_test.c
|
// The following is a RISC-V program to test the functionality of the
// dummy RoCC accelerator.
// Compile with riscv64-unknown-elf-gcc dummy_rocc_test.c
// Run with spike --extension=dummy_rocc pk a.out
#include <assert.h>
#include <stdio.h>
#include <stdint.h>
int main() {
uint64_t x = 123, y = 456, z = 0;
// load x into accumulator 2 (funct=0)
asm volatile ("custom0 x0, %0, 2, 0" : : "r"(x));
// read it back into z (funct=1) to verify it
asm volatile ("custom0 %0, x0, 2, 1" : "=r"(z));
assert(z == x);
// accumulate 456 into it (funct=3)
asm volatile ("custom0 x0, %0, 2, 3" : : "r"(y));
// verify it
asm volatile ("custom0 %0, x0, 2, 1" : "=r"(z));
assert(z == x+y);
// do it all again, but initialize acc2 via memory this time (funct=2)
asm volatile ("custom0 x0, %0, 2, 2" : : "r"(&x));
asm volatile ("custom0 x0, %0, 2, 3" : : "r"(y));
asm volatile ("custom0 %0, x0, 2, 1" : "=r"(z));
assert(z == x+y);
printf("success!\n");
}
|
842cd108757ea7fc4a3332c040f331c1c6ab4b83
|
5f86fc385c7dcfcb5b166cdea7c8b13057b8bb5f
|
/3rdparty/sgxsdk/include/sgx_quote.h
|
a08f6d3098b6c487a329dece483019910d6bd7a0
|
[
"BSD-3-Clause",
"OpenSSL",
"MIT",
"Apache-2.0",
"LicenseRef-scancode-public-domain"
] |
permissive
|
openenclave/openenclave
|
54a38e12d9aa73357d9f438a07cd8c07ffe5e6df
|
cdeb95c1ec163117de409295333b6b2702013e08
|
refs/heads/master
| 2023-08-14T16:43:32.049533
| 2023-07-21T15:58:54
| 2023-07-21T15:58:54
| 101,804,230
| 800
| 372
|
MIT
| 2023-09-12T20:26:02
| 2017-08-29T20:31:38
|
C
|
UTF-8
|
C
| false
| false
| 5,060
|
h
|
sgx_quote.h
|
/*
* Copyright (C) 2011-2020 Intel Corporation. All rights reserved.
*
* 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 Intel Corporation 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.
*
*/
/**
* File: sgx_quote.h
* Description: Definition for quote structure.
*
* Quote structure and all relative structure will be defined in this file.
*/
#ifndef _SGX_QUOTE_H_
#define _SGX_QUOTE_H_
#include "sgx_report.h"
#ifdef __cplusplus
extern "C" {
#endif
#pragma pack(push, 1)
typedef uint8_t sgx_epid_group_id_t[4];
typedef struct _spid_t
{
uint8_t id[16];
} sgx_spid_t;
typedef struct _basename_t
{
uint8_t name[32];
} sgx_basename_t;
typedef struct _quote_nonce
{
uint8_t rand[16];
} sgx_quote_nonce_t;
typedef enum
{
SGX_UNLINKABLE_SIGNATURE,
SGX_LINKABLE_SIGNATURE
} sgx_quote_sign_type_t;
typedef struct _quote_t
{
uint16_t version; /* 0 */
uint16_t sign_type; /* 2 */
sgx_epid_group_id_t epid_group_id; /* 4 */
sgx_isv_svn_t qe_svn; /* 8 */
sgx_isv_svn_t pce_svn; /* 10 */
uint32_t xeid; /* 12 */
sgx_basename_t basename; /* 16 */
sgx_report_body_t report_body; /* 48 */
uint32_t signature_len; /* 432 */
uint8_t signature[]; /* 436 */
} sgx_quote_t;
#define SGX_PLATFORM_INFO_SIZE 101
typedef struct _platform_info
{
uint8_t platform_info[SGX_PLATFORM_INFO_SIZE];
} sgx_platform_info_t;
typedef struct _update_info_bit
{
int ucodeUpdate;
int csmeFwUpdate;
int pswUpdate;
} sgx_update_info_bit_t;
typedef struct _att_key_id_t {
uint8_t att_key_id[256];
}sgx_att_key_id_t;
/** Describes a single attestation key. Contains both QE identity and the attestation algorithm ID. */
typedef struct _sgx_ql_att_key_id_t {
uint16_t id; ///< Structure ID
uint16_t version; ///< Structure version
uint16_t mrsigner_length; ///< Number of valid bytes in MRSIGNER.
uint8_t mrsigner[48]; ///< SHA256 or SHA384 hash of the Public key that signed the QE.
///< The lower bytes contain MRSIGNER. Bytes beyond mrsigner_length '0'
uint32_t prod_id; ///< Legacy Product ID of the QE
uint8_t extended_prod_id[16]; ///< Extended Product ID or the QE. All 0's for legacy format enclaves.
uint8_t config_id[64]; ///< Config ID of the QE.
uint8_t family_id[16]; ///< Family ID of the QE.
uint32_t algorithm_id; ///< Identity of the attestation key algorithm.
}sgx_ql_att_key_id_t;
/** Describes an extended attestation key. Contains sgx_ql_att_key_id_t, spid and quote_type */
typedef struct _sgx_att_key_id_ext_t {
sgx_ql_att_key_id_t base;
uint8_t spid[16]; ///< Service Provider ID, should be 0s for ECDSA quote
uint16_t att_key_type; ///< For non-EPID quote, it should be 0
///< For EPID quote, it equals to sgx_quote_sign_type_t
uint8_t reserved[80]; ///< It should have the same size of sgx_att_key_id_t
}sgx_att_key_id_ext_t;
typedef struct _qe_report_info_t {
sgx_quote_nonce_t nonce;
sgx_target_info_t app_enclave_target_info;
sgx_report_t qe_report;
}sgx_qe_report_info_t;
#pragma pack(pop)
#ifdef __cplusplus
}
#endif
#endif
|
f0571ee5265bbd5c0ff46cb5b8030a2757689ab6
|
99bdb3251fecee538e0630f15f6574054dfc1468
|
/bsp/raspberry-pi/raspi3-64/driver/drv_spi.c
|
bb3c7479c6987b55893bc86da4eca4a0f6ac8309
|
[
"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
| 7,767
|
c
|
drv_spi.c
|
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2019-07-29 zdzn first version
*/
#include "drv_spi.h"
#include "raspi.h"
#ifdef RT_USING_SPI
#define RPI_CORE_CLK_HZ 250000000
#define BSP_SPI_MAX_HZ (30* 1000 *1000)
#define SPITIMEOUT 0x0FFF
void spi_gpio_write(rt_uint8_t pin, rt_uint8_t val)
{
if (val)
BCM283X_GPIO_GPSET((pin / 32)) = 1 << (pin % 32);
else
BCM283X_GPIO_GPCLR((pin / 32)) = 1 << (pin % 32);
}
struct raspi_spi_hw_config
{
rt_uint8_t spi_num;
raspi_gpio_pin sclk_pin;
raspi_pin_select sclk_mode;
raspi_gpio_pin mosi_pin;
raspi_pin_select mosi_mode;
raspi_gpio_pin miso_pin;
raspi_pin_select miso_mode;
#if defined (BSP_USING_SPI0_DEVICE0) || defined (BSP_USING_SPI1_DEVICE0)
raspi_gpio_pin ce0_pin;
raspi_pin_select ce0_mode;
#endif
#if defined (BSP_USING_SPI0_DEVICE1) || defined (BSP_USING_SPI1_DEVICE1)
raspi_gpio_pin ce1_pin;
raspi_pin_select ce1_mode;
#endif
#if defined (BSP_USING_SPI1_DEVICE2)
raspi_gpio_pin ce2_pin;
raspi_pin_select ce2_mode;
#endif
};
struct raspi_spi_device
{
char *device_name;
struct rt_spi_bus *spi_bus;
struct rt_spi_device *spi_device;
raspi_gpio_pin cs_pin;
};
static rt_err_t raspi_spi_configure(struct rt_spi_device *device, struct rt_spi_configuration *cfg)
{
RT_ASSERT(cfg != RT_NULL);
RT_ASSERT(device != RT_NULL);
rt_uint16_t divider;
// spi clear fifo
BCM283X_SPI0_CS(BCM283X_SPI0_BASE) |= BCM283X_SPI0_CS_CLEAR;
if (cfg->mode & RT_SPI_CPOL)
BCM283X_SPI0_CS(BCM283X_SPI0_BASE) |= BCM283X_SPI0_CS_CPOL;
if (cfg->mode & RT_SPI_CPHA)
BCM283X_SPI0_CS(BCM283X_SPI0_BASE) |= BCM283X_SPI0_CS_CPHA;
if (cfg->mode & RT_SPI_CS_HIGH)
BCM283X_SPI0_CS(BCM283X_SPI0_BASE) |= BCM283X_SPI0_CS_CSPOL;
//set clk
if (cfg->max_hz > BSP_SPI_MAX_HZ)
cfg->max_hz = BSP_SPI_MAX_HZ;
divider = (rt_uint16_t) ((rt_uint32_t) RPI_CORE_CLK_HZ / cfg->max_hz);
divider &= 0xFFFE;
BCM283X_SPI0_CLK(BCM283X_SPI0_BASE) = divider;
return RT_EOK;
}
rt_uint8_t correct_order(rt_uint8_t b, rt_uint8_t flag)
{
if (flag)
return raspi_byte_reverse_table[b];
else
return b;
}
static rt_err_t spi_transfernb(rt_uint8_t* tbuf, rt_uint8_t* rbuf, rt_uint32_t len, rt_uint8_t flag)
{
rt_uint32_t TXCnt=0;
rt_uint32_t RXCnt=0;
/* Clear TX and RX fifos */
BCM283X_SPI0_CS(BCM283X_SPI0_BASE) |= (BCM283X_SPI0_CS_CLEAR & BCM283X_SPI0_CS_CLEAR);
/* Set TA = 1 */
BCM283X_SPI0_CS(BCM283X_SPI0_BASE) |= (BCM283X_SPI0_CS_TA & BCM283X_SPI0_CS_TA);
/* Use the FIFO's to reduce the interbyte times */
while ((TXCnt < len) || (RXCnt < len))
{
/* TX fifo not full, so add some more bytes */
while (((BCM283X_SPI0_CS(BCM283X_SPI0_BASE) & BCM283X_SPI0_CS_TXD)) && (TXCnt < len))
{
BCM283X_SPI0_FIFO(BCM283X_SPI0_BASE) = correct_order(tbuf[TXCnt],flag);
TXCnt++;
}
/* Rx fifo not empty, so get the next received bytes */
while (((BCM283X_SPI0_CS(BCM283X_SPI0_BASE) & BCM283X_SPI0_CS_RXD)) && (RXCnt < len))
{
rbuf[RXCnt] = correct_order(BCM283X_SPI0_FIFO(BCM283X_SPI0_BASE),flag);
RXCnt++;
}
}
/* Wait for DONE to be set */
while (!(BCM283X_SPI0_CS(BCM283X_SPI0_BASE) & BCM283X_SPI0_CS_DONE));
/* Set TA = 0, and also set the barrier */
BCM283X_SPI0_CS(BCM283X_SPI0_BASE) |= (0 & BCM283X_SPI0_CS_TA);
return RT_EOK;
}
static rt_ssize_t raspi_spi_xfer(struct rt_spi_device *device, struct rt_spi_message *message)
{
RT_ASSERT(device != RT_NULL);
RT_ASSERT(device->bus != RT_NULL);
RT_ASSERT(device->parent.user_data != RT_NULL);
RT_ASSERT(message->send_buf != RT_NULL || message->recv_buf != RT_NULL);
rt_err_t res;
rt_uint8_t flag;
struct rt_spi_configuration config = device->config;
raspi_gpio_pin cs_pin = (raspi_gpio_pin)device->parent.user_data;
if (config.mode & RT_SPI_MSB)
flag = 0;
else
flag = 1;
if (message->cs_take);
// (config.mode & RT_SPI_CS_HIGH)?
// spi_gpio_write(cs_pin, 1):
// spi_gpio_write(cs_pin, 0);
/* deal data */
res = spi_transfernb((rt_uint8_t *)message->send_buf, (rt_uint8_t *)message->recv_buf,
(rt_int32_t)message->length, flag);
if (message->cs_release)
(config.mode & RT_SPI_CS_HIGH)?
spi_gpio_write(cs_pin, 0):
spi_gpio_write(cs_pin, 1);
if (res != RT_EOK)
return res;
return message->length;
}
rt_err_t raspi_spi_bus_attach_device(const char *bus_name, struct raspi_spi_device *device)
{
rt_err_t ret;
RT_ASSERT(device != RT_NULL);
ret = rt_spi_bus_attach_device(device->spi_device, device->device_name, bus_name, (void *)(device->cs_pin));
return ret;
}
rt_err_t raspi_spi_hw_init(struct raspi_spi_hw_config *hwcfg)
{
GPIO_FSEL(hwcfg->sclk_pin, hwcfg->sclk_mode);
GPIO_FSEL(hwcfg->miso_pin, hwcfg->miso_mode);
GPIO_FSEL(hwcfg->mosi_pin, hwcfg->mosi_mode);
#if defined (BSP_USING_SPI0_DEVICE0)
GPIO_FSEL(hwcfg->ce0_pin, hwcfg->ce0_mode);
#endif
#if defined (BSP_USING_SPI0_DEVICE1)
GPIO_FSEL(hwcfg->ce1_pin, hwcfg->ce1_mode);
#endif
BCM283X_SPI0_CS(BCM283X_SPI0_BASE) = 0;
BCM283X_SPI0_CS(BCM283X_SPI0_BASE) = BCM283X_SPI0_CS_CLEAR;
//enable chip select
#if defined (BSP_USING_SPI0_DEVICE0)
BCM283X_SPI0_CS(BCM283X_SPI0_BASE) |= 0;
#endif
#if defined (BSP_USING_SPI0_DEVICE1)
BCM283X_SPI0_CS(BCM283X_SPI0_BASE) |= 0x2;
#endif
#if defined (BSP_USING_SPI0_DEVICE0) && defined (BSP_USING_SPI0_DEVICE1)
BCM283X_SPI0_CS(BCM283X_SPI0_BASE) |= BCM283X_SPI0_CS_CS;
#endif
return RT_EOK;
}
static struct rt_spi_ops raspi_spi_ops =
{
.configure = raspi_spi_configure,
.xfer = raspi_spi_xfer
};
#if defined (BSP_USING_SPI0_BUS)
#define SPI0_BUS_NAME "spi0"
#define SPI0_DEVICE0_NAME "spi0.0"
#define SPI0_DEVICE1_NAME "spi0.1"
struct rt_spi_bus spi0_bus;
#if defined (BSP_USING_SPI0_DEVICE0)
struct rt_spi_device spi0_device0;
#endif
#if defined (BSP_USING_SPI0_DEVICE1)
static struct rt_spi_device spi0_device1;
#endif
struct raspi_spi_hw_config raspi_spi0_hw =
{
.spi_num = 0,
.sclk_pin = RPI_GPIO_P1_23,
.sclk_mode = BCM283X_GPIO_FSEL_ALT0,
.mosi_pin = RPI_GPIO_P1_19,
.mosi_mode = BCM283X_GPIO_FSEL_ALT0,
.miso_pin = RPI_GPIO_P1_21,
.miso_mode = BCM283X_GPIO_FSEL_ALT0,
#if defined (BSP_USING_SPI0_DEVICE0)
.ce0_pin = RPI_GPIO_P1_24,
.ce0_mode = BCM283X_GPIO_FSEL_ALT0,
#endif
#if defined (BSP_USING_SPI0_DEVICE1)
.ce1_pin = RPI_GPIO_P1_26,
.ce1_mode = BCM283X_GPIO_FSEL_ALT0,
#endif
};
#endif
int rt_hw_spi_init(void)
{
#if defined (BSP_USING_SPI0_BUS)
raspi_spi_hw_init(&raspi_spi0_hw);
rt_spi_bus_register(&spi0_bus, SPI0_BUS_NAME, &raspi_spi_ops);
#if defined (BSP_USING_SPI0_DEVICE0)
struct raspi_spi_device raspi_spi0_device0 =
{
.device_name = SPI0_DEVICE0_NAME,
.spi_bus = &spi0_bus,
.spi_device = &spi0_device0,
.cs_pin = raspi_spi0_hw.ce0_pin,
};
raspi_spi_bus_attach_device(SPI0_BUS_NAME, &raspi_spi0_device0);
#endif
#if defined (BSP_USING_SPI0_DEVICE1)
struct raspi_spi_device raspi_spi0_device1 =
{
.device_name = SPI0_DEVICE1_NAME,
.spi_bus = &spi0_bus,
.spi_device = &spi0_device1,
.cs_pin = raspi_spi0_hw.ce1_pin,
};
raspi_spi_bus_attach_device(SPI0_BUS_NAME, &raspi_spi0_device1);
#endif
#endif
return RT_EOK;
}
INIT_DEVICE_EXPORT(rt_hw_spi_init);
#endif
|
3e2e09c4f7956b12657ab0b2c261d42a7e4331b2
|
b04663400b05fd638e41f3d7f61953c514d835ed
|
/secure_c/src/swprintf_s.c
|
b5ffb39691334f18ad07475bfd2c2edd886f798f
|
[] |
permissive
|
LiteOS/LiteOS_Lab
|
0ee3edc08eb9d4c9ea5b52099da307adf1c06bfd
|
187e628b3f151515d920801b402bf38a19eee98c
|
refs/heads/iot-device-sdk-tiny
| 2023-09-04T16:22:21.579294
| 2023-04-25T03:09:46
| 2023-04-25T03:09:46
| 154,946,914
| 141
| 125
|
BSD-3-Clause
| 2022-08-25T09:12:56
| 2018-10-27T09:25:01
|
C
|
UTF-8
|
C
| false
| false
| 1,777
|
c
|
swprintf_s.c
|
/*
* Copyright (c) [2019] Huawei Technologies Co.,Ltd.All rights reserved.
*
* OpenArkCompiler is licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
*
* http://license.coscl.org.cn/MulanPSL
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR
* FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v1 for more details.
*/
#include "securec.h"
/*
* <FUNCTION DESCRIPTION>
* The swprintf_s function is the wide-character equivalent of the sprintf_s function
*
* <INPUT PARAMETERS>
* strDest Storage location for the output.
* destMax Maximum number of characters to store.
* format Format-control string.
* ... Optional arguments
*
* <OUTPUT PARAMETERS>
* strDest is updated
*
* <RETURN VALUE>
* return the number of wide characters stored in strDest, not counting the terminating null wide character.
* return -1 if an error occurred.
*
* If there is a runtime-constraint violation, strDest[0] will be set to the '\0' when strDest and destMax valid
*/
int swprintf_s(wchar_t *strDest, size_t destMax, const wchar_t *format, ...)
{
int ret; /* If initialization causes e838 */
va_list argList;
va_start(argList, format);
ret = vswprintf_s(strDest, destMax, format, argList);
va_end(argList);
(void)argList; /* to clear e438 last value assigned not used , the compiler will optimize this code */
return ret;
}
|
097b09a42b9dee6f0447595ed4aaf6f8f4efb472
|
c6759b857e55991fea3ef0b465dbcee53fa38714
|
/rtos/pmsis/implem/malloc/alloc_pool.c
|
a2b9a50436ffbaa4b2e9d9d0524187604478edd6
|
[
"Apache-2.0"
] |
permissive
|
GreenWaves-Technologies/gap_sdk
|
1b343bba97b7a5ce62a24162bd72eef5cc67e269
|
3fea306d52ee33f923f2423c5a75d9eb1c07e904
|
refs/heads/master
| 2023-09-01T14:38:34.270427
| 2023-08-10T09:04:44
| 2023-08-10T09:04:44
| 133,324,605
| 145
| 96
|
Apache-2.0
| 2023-08-27T19:03:52
| 2018-05-14T07:50:29
|
C
|
UTF-8
|
C
| false
| false
| 6,946
|
c
|
alloc_pool.c
|
/*
* Copyright (C) 2019 GreenWaves Technologies
*
* 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.
*/
/*
* Authors: Eric Flamand, GreenWaves Technologies (eric.flamand@greenwaves-technologies.com)
* Germain Haugou, GreenWaves Technologies (eric.flamand@greenwaves-technologies.com)
*/
#include "pmsis.h"
#include <malloc/alloc.h>
#include <malloc/alloc_pool.h>
#include <chips/gap9/linker.h>
#include <string.h>
#include <stdio.h>
#ifdef __FREERTOS__
// TODO put in utils.h ?
#define hal_cluster_id() __builtin_pulp_ClusterId()
static inline void pos_task_init_from_cluster(pi_task_t *task) {}
#endif /* __FREERTOS__ */
//FIXME
#ifndef INIT_INF
#define INIT_INF(...)
//#define INIT_INF(...) printf(__VA_ARGS__)
#endif
//FIXME
#ifndef CONFIG_ALLOC_L2_PWD_NB_BANKS
#define CONFIG_ALLOC_TRACK_PWD 1
#define CONFIG_ALLOC_L2_PWD_NB_BANKS 12
#define CONFIG_ALLOC_L2_PWD_BANK_SIZE_LOG2 17
#endif
#if defined(CHIP_HAS_L1)
pos_alloc_t pos_alloc_l1[CHIP_NB_CLUSTER];
#endif
#if defined(CHIP_HAS_FC_TCDM)
pos_alloc_t pos_alloc_fc_tcdm;
#endif
#if defined(CHIP_HAS_L2)
pos_alloc_t pos_alloc_l2[POS_NB_ALLOC_L2];
#endif
#ifdef CONFIG_ALLOC_L2_PWD_NB_BANKS
static uint32_t pos_alloc_account_0[CONFIG_ALLOC_L2_PWD_NB_BANKS];
static uint32_t pos_alloc_account_1[CONFIG_ALLOC_L2_PWD_NB_BANKS];
#endif
#if defined(CHIP_HAS_FC_TCDM)
static inline pos_alloc_t *get_fc_alloc() { return &pos_alloc_fc_tcdm; }
#else
static inline pos_alloc_t *get_fc_alloc() { return &pos_alloc_l2[0]; }
#endif
#ifdef CHIP_HAS_L1
void pos_alloc_init_l1(int cid, void *base, uint32_t size)
{
INIT_INF("Initializing L1 allocator (cluster: %d, base: 0x%8x, size: 0x%8x)\n", cid, (int)base, size);
pos_alloc_init(&pos_alloc_l1[cid], base, size);
}
#endif
void pos_allocs_init()
{
//printf("Initializing allocator\n");
#if defined(CHIP_HAS_L2)
#if defined(CHIP_HAS_L2_MULTI)
//INIT_INF("Initializing L2 private bank0 allocator (base: 0x%8x, size: 0x%8x)\n", (int)pos_l2_priv0_base(), pos_l2_priv0_size());
pos_alloc_init(&pos_alloc_l2[0], pos_l2_priv0_base(), pos_l2_priv0_size());
//INIT_INF("Initializing L2 shared banks allocator (base: 0x%8x, size: 0x%8x)\n", (int)pos_l2_shared_base(), pos_l2_shared_size());
pos_alloc_init(&pos_alloc_l2[1], pos_l2_shared_base(), pos_l2_shared_size());
#ifdef CONFIG_ALLOC_L2_PWD_NB_BANKS
pos_alloc_l2[1].track_pwd = 1;
pos_alloc_l2[1].pwd_count = pos_alloc_account_0;
pos_alloc_l2[1].ret_count = pos_alloc_account_1;
for (int i=0; i<CONFIG_ALLOC_L2_PWD_NB_BANKS; i++)
{
pos_alloc_l2[1].pwd_count[i] = 0;
pos_alloc_l2[1].ret_count[i] = 0;
}
pos_alloc_l2[1].bank_size_log2 = CONFIG_ALLOC_L2_PWD_BANK_SIZE_LOG2;
pos_alloc_l2[1].first_bank_addr = CHIP_L2_SHARED_ADDR;
pos_alloc_account_free(&pos_alloc_l2[1], pos_l2_shared_base() + sizeof(pos_alloc_chunk_t), pos_l2_shared_size() - sizeof(pos_alloc_chunk_t));
#endif
#else
pos_alloc_init(&pos_alloc_l2[0], pos_l2_base(), pos_l2_size());
#endif
#endif
#if defined(CHIP_HAS_FC_TCDM)
pos_alloc_init(&pos_alloc_fc_tcdm, pos_fc_tcdm_base(), pos_fc_tcdm_size());
#endif
}
#if defined(ARCHI_HAS_CLUSTER)
void pos_alloc_cluster_req(void *_req)
{
pi_cl_alloc_req_t *req = (pi_cl_alloc_req_t *)_req;
if (req->is_l2)
req->result = pi_l2_malloc(req->size);
hal_compiler_barrier();
req->done = 1;
pi_cluster_notif_req_done(req->cid);
}
void pos_free_cluster_req(void *_req)
{
pi_cl_free_req_t *req = (pi_cl_free_req_t *)_req;
if (req->is_l2)
pi_l2_free(req->chunk, req->size);
hal_compiler_barrier();
req->done = 1;
pi_cluster_notif_req_done(req->cid);
}
void pos_alloc_cluster(int is_l2, int size, pi_cl_alloc_req_t *req)
{
req->is_l2 = is_l2;
req->size = size;
req->cid = hal_cluster_id();
req->done = 0;
pos_task_init_from_cluster(&req->task);
pi_task_callback(&req->task, pos_alloc_cluster_req, (void* )req);
pi_cl_send_task_to_fc(&req->task);
}
void pos_free_cluster(int is_l2, void *chunk, int size, pi_cl_free_req_t *req)
{
req->is_l2 = is_l2;
req->size = size;
req->chunk = chunk;
req->cid = hal_cluster_id();
req->done = 0;
pos_task_init_from_cluster(&req->task);
pi_task_callback(&req->task, pos_free_cluster_req, (void* )req);
pi_cl_send_task_to_fc(&req->task);
}
void pi_cl_l2_malloc(int size, pi_cl_alloc_req_t *req)
{
pos_alloc_cluster(1, size, req);
}
void pi_cl_l2_free(void *chunk, int size, pi_cl_free_req_t *req)
{
pos_free_cluster(1, chunk, size, req);
}
void *pi_cl_l1_malloc(struct pi_device *device, uint32_t size)
{
int cid = 0;
if (device)
{
pi_cluster_t *data = (pi_cluster_t *)device->data;
cid = data->cid;
}
return pos_alloc(&pos_alloc_l1[cid], size);
}
void pi_cl_l1_free(struct pi_device *device, void *_chunk, int size)
{
int cid = 0;
if (device)
{
pi_cluster_t *data = (pi_cluster_t *)device->data;
cid = data->cid;
}
return pos_free(&pos_alloc_l1[cid], _chunk, size);
}
#endif
void *pi_l2_malloc(int size)
{
return pos_alloc(&pos_alloc_l2[1], size);
}
void pi_l2_free(void *_chunk, int size)
{
return pos_free(&pos_alloc_l2[1], _chunk, size);
}
#if defined(CHIP_HAS_FC_TCDM)
void *pi_fc_l1_malloc(int size)
{
return pos_alloc(&pos_alloc_fc_tcdm, size);
}
void pi_fc_l1_free(void *_chunk, int size)
{
return pos_free(&pos_alloc_fc_tcdm, _chunk, size);
}
#else
void *pi_fc_l1_malloc(int size)
{
return pos_alloc(&pos_alloc_l2[0], size);
}
void pi_fc_l1_free(void *_chunk, int size)
{
return pos_free(&pos_alloc_l2[0], _chunk, size);
}
#endif
void pi_l2_ret_ctrl(void *chunk, int size, int retentive)
{
pos_alloc_t *a = &pos_alloc_l2[1];
#ifdef ARCHI_MEMORY_POWER
if (a->track_pwd)
{
if (retentive)
pos_alloc_account(a, chunk, size, 1, 1);
else
pos_alloc_account(a, chunk, size, -1, 1);
}
#endif
}
void pi_l2_pwd_ctrl(void *chunk, int size, int up)
{
pos_alloc_t *a = &pos_alloc_l2[1];
#ifdef ARCHI_MEMORY_POWER
if (a->track_pwd)
{
if (up)
pos_alloc_account(a, chunk, size, -1, 0);
else
pos_alloc_account(a, chunk, size, 1, 0);
}
#endif
}
void pi_l2_malloc_dump(void)
{
pos_alloc_dump(&pos_alloc_l2[1]);
}
void pi_fc_l1_malloc_dump(void)
{
pos_alloc_dump(&pos_alloc_l2[0]);
}
void pi_cl_l1_malloc_dump(struct pi_device *device)
{
int cid = 0;
pos_alloc_dump(&pos_alloc_l1[cid]);
}
|
6081534e86aaf7fe3bd4cbcf14d4e82a9ace5b5a
|
76f9898ff7a555f4a729d725056a317af818375d
|
/assets/objects/object_gi_dekupouch/object_gi_dekupouch.c
|
f235cef46d8912217cdf43d3f08a126e09729ed0
|
[] |
no_license
|
z64proto/sw97
|
0b65837ab2f2a4073faca5670761d7fe0e74d29d
|
f571505ade2cefd4a5b5d19da06d33e7c6b02c60
|
refs/heads/master
| 2023-08-01T02:47:42.895871
| 2022-05-15T20:29:08
| 2022-05-15T20:29:08
| 430,216,978
| 208
| 29
| null | 2021-11-22T12:23:50
| 2021-11-20T21:52:59
|
C
|
UTF-8
|
C
| false
| false
| 16,371
|
c
|
object_gi_dekupouch.c
|
#include "ultra64.h"
#include "z64.h"
#include "macros.h"
#include "object_gi_dekupouch.h"
static Vtx object_gi_dekupouchVtx_000300[3];
static Vtx object_gi_dekupouchVtx_000330[32];
static Vtx object_gi_dekupouchVtx_000530[3];
static Vtx object_gi_dekupouchVtx_000560[4];
static Vtx object_gi_dekupouchVtx_0005A0[32];
static Vtx object_gi_dekupouchVtx_0007A0[9];
static Vtx object_gi_dekupouchVtx_000830[3];
static Vtx object_gi_dekupouchVtx_000860[18];
static Vtx object_gi_dekupouchVtx_000980[7];
static Vtx object_gi_dekupouchVtx_0009F0[11];
static Vtx object_gi_dekupouchVtx_000AA0[5];
u64 object_gi_dekupouchTex_000000[] = {
#include "assets/objects/object_gi_dekupouch//object_gi_dekupouchTex_000000.i8.inc.c"
};
u64 object_gi_dekupouchTex_000100[] = {
#include "assets/objects/object_gi_dekupouch//object_gi_dekupouchTex_000100.i8.inc.c"
};
static Vtx object_gi_dekupouchVtx_000300[3] = {
VTX(-21, 29, 0, 0, 1226, 147, 208, 2, 255),
VTX(-16, 19, -1, -16, 1246, 161, 250, 184, 255),
VTX(-16, 19, 2, 17, 1246, 163, 253, 75, 255),
};
static Vtx object_gi_dekupouchVtx_000330[32] = {
VTX(-12, 32, 13, 144, 1185, 215, 192, 92, 255),
VTX(-16, 19, 2, 17, 1246, 163, 253, 75, 255),
VTX(0, 19, 5, 273, 1109, 255, 246, 119, 255),
VTX(11, 29, 13, 376, 1202, 41, 188, 90, 255),
VTX(16, 19, 2, 496, 1256, 96, 255, 71, 255),
VTX(20, 32, 0, 512, 1214, 114, 221, 255, 255),
VTX(16, 19, -1, 527, 1256, 95, 1, 183, 255),
VTX(11, 32, -13, 648, 1191, 45, 193, 165, 255),
VTX(0, 19, -5, 751, 1107, 3, 245, 137, 255),
VTX(-12, 29, -13, 880, 1199, 219, 184, 168, 255),
VTX(-16, 19, -1, 1008, 1246, 161, 250, 184, 255),
VTX(-11, 8, -10, 897, 1366, 217, 37, 149, 255),
VTX(-22, 9, 0, 1024, 1405, 143, 38, 0, 255),
VTX(-22, 9, 0, 0, 1405, 143, 38, 0, 255),
VTX(-11, 8, 10, 127, 1366, 217, 36, 107, 255),
VTX(11, 8, 10, 394, 1388, 39, 34, 108, 255),
VTX(22, 6, 0, 512, 1447, 115, 34, 0, 255),
VTX(11, 8, -10, 630, 1388, 39, 34, 148, 255),
VTX(-1, -21, -15, 774, 1843, 253, 221, 142, 255),
VTX(-24, -18, -7, 973, 1746, 164, 234, 183, 255),
VTX(-24, -18, -7, -51, 1746, 164, 234, 183, 255),
VTX(-24, -18, 7, 51, 1746, 169, 215, 70, 255),
VTX(-1, -21, 15, 250, 1843, 254, 228, 116, 255),
VTX(23, -21, 7, 461, 1770, 82, 208, 72, 255),
VTX(23, -21, -7, 563, 1770, 89, 228, 182, 255),
VTX(-21, 29, 0, 0, 1226, 147, 208, 2, 255),
VTX(-16, 19, -1, -16, 1246, 161, 250, 184, 255),
VTX(-12, 29, -13, -144, 1199, 219, 184, 168, 255),
VTX(-16, -29, -4, -41, 1890, 210, 151, 222, 255),
VTX(14, -31, -4, 553, 1897, 35, 147, 222, 255),
VTX(-2, -32, 5, 227, 1995, 249, 152, 58, 255),
VTX(-16, -29, -4, 983, 1890, 210, 151, 222, 255),
};
static Vtx object_gi_dekupouchVtx_000530[3] = {
VTX(11, 8, -10, -357, 903, 39, 34, 148, 255),
VTX(0, 19, -5, 509, -45, 3, 245, 137, 255),
VTX(16, 19, -1, -713, -215, 95, 1, 183, 255),
};
static Vtx object_gi_dekupouchVtx_000560[4] = {
VTX(-11, 8, -10, 1331, 871, 217, 37, 149, 255),
VTX(-16, 19, -1, 1727, -186, 161, 250, 184, 255),
VTX(0, 19, -5, 509, -45, 3, 245, 137, 255),
VTX(11, 8, -10, -357, 903, 39, 34, 148, 255),
};
static Vtx object_gi_dekupouchVtx_0005A0[32] = {
VTX(25, 7, 8, 461, 1571, 14, 65, 99, 255),
VTX(28, 1, 9, 462, 1628, 222, 1, 114, 255),
VTX(28, 1, 4, 485, 1629, 81, 10, 169, 255),
VTX(25, 16, -5, 545, 1458, 82, 11, 170, 255),
VTX(27, 7, 4, 488, 1569, 114, 11, 221, 255),
VTX(22, 5, 5, 477, 1600, 173, 186, 205, 255),
VTX(13, 15, -2, 528, 1412, 74, 162, 5, 255),
VTX(16, 16, -7, 578, 1420, 196, 153, 6, 255),
VTX(16, 19, -5, 558, 1364, 60, 93, 45, 255),
VTX(21, 13, -4, 541, 1477, 167, 185, 219, 255),
VTX(24, 16, -1, 519, 1445, 7, 58, 104, 255),
VTX(14, 19, -9, 601, 1364, 249, 22, 139, 255),
VTX(25, 0, 6, 473, 1655, 153, 199, 238, 255),
VTX(11, 19, -3, 548, 1323, 155, 53, 221, 255),
VTX(15, 19, 0, 511, 1360, 93, 65, 38, 255),
VTX(-28, 6, 5, 29, 1578, 196, 91, 50, 255),
VTX(-27, 9, -4, -25, 1541, 144, 30, 228, 255),
VTX(-28, 3, 2, 13, 1612, 197, 173, 194, 255),
VTX(-23, 6, -4, 1000, 1583, 51, 166, 197, 255),
VTX(-27, 9, -4, 999, 1541, 144, 30, 228, 255),
VTX(-24, 13, -9, 970, 1486, 177, 22, 169, 255),
VTX(-19, 19, -4, 993, 1379, 184, 66, 68, 255),
VTX(-18, 16, -6, 974, 1431, 69, 162, 26, 255),
VTX(-14, 15, -2, 1008, 1412, 200, 155, 31, 255),
VTX(-23, 6, -4, -24, 1583, 51, 166, 197, 255),
VTX(-26, 9, 0, 1024, 1542, 54, 69, 81, 255),
VTX(-20, 11, -7, 970, 1512, 106, 202, 1, 255),
VTX(-23, 14, -4, 994, 1474, 229, 41, 109, 255),
VTX(-17, 19, -8, 950, 1376, 60, 27, 156, 255),
VTX(-26, 3, 4, 28, 1618, 110, 245, 46, 255),
VTX(-26, 9, 0, 0, 1542, 54, 69, 81, 255),
VTX(-12, 19, -3, 988, 1323, 82, 55, 189, 255),
};
static Vtx object_gi_dekupouchVtx_0007A0[9] = {
VTX(-19, 19, -4, -31, 1379, 184, 66, 68, 255),
VTX(-15, 19, 0, 1, 1360, 185, 58, 77, 255),
VTX(-12, 19, -3, -36, 1323, 82, 55, 189, 255),
VTX(-14, 15, -2, -16, 1412, 200, 155, 31, 255),
VTX(-12, 19, -3, 988, 1323, 82, 55, 189, 255),
VTX(-14, 15, -2, 1008, 1412, 200, 155, 31, 255),
VTX(-18, 16, -6, 974, 1431, 69, 162, 26, 255),
VTX(-17, 19, -8, 950, 1376, 60, 27, 156, 255),
VTX(-19, 19, -4, 993, 1379, 184, 66, 68, 255),
};
static Vtx object_gi_dekupouchVtx_000830[3] = {
VTX(28, 1, 4, 520, 1514, 255, 107, 202, 255),
VTX(28, 1, 9, 496, 1515, 244, 98, 68, 255),
VTX(32, 1, 7, 507, 1519, 102, 60, 16, 255),
};
static Vtx object_gi_dekupouchVtx_000860[18] = {
VTX(24, -3, 11, 480, 1571, 179, 250, 92, 255),
VTX(28, 1, 9, 496, 1515, 244, 98, 68, 255),
VTX(25, 0, 6, 511, 1532, 156, 64, 243, 255),
VTX(26, -2, 1, 542, 1555, 209, 22, 148, 255),
VTX(28, 1, 4, 520, 1514, 255, 107, 202, 255),
VTX(32, 1, 7, 507, 1519, 102, 60, 16, 255),
VTX(31, -7, 6, 512, 1606, 66, 157, 249, 255),
VTX(-32, 5, 5, 1019, 1476, 151, 47, 224, 255),
VTX(-28, 6, 5, 1018, 1460, 14, 111, 215, 255),
VTX(-28, 3, 2, 1002, 1495, 237, 11, 139, 255),
VTX(-26, 3, 4, -11, 1489, 100, 27, 196, 255),
VTX(-28, 6, 5, -6, 1460, 14, 111, 215, 255),
VTX(-24, 5, 11, 32, 1458, 83, 71, 48, 255),
VTX(-26, 3, 4, 1013, 1489, 100, 27, 196, 255),
VTX(-26, -1, 3, 1010, 1544, 38, 171, 181, 255),
VTX(-32, 5, 5, -5, 1476, 151, 47, 224, 255),
VTX(-26, -1, 3, -14, 1544, 38, 171, 181, 255),
VTX(-31, -2, 9, 19, 1547, 188, 181, 63, 255),
};
static Vtx object_gi_dekupouchVtx_000980[7] = {
VTX(0, 20, 0, 768, 193, 249, 119, 255, 255),
VTX(-21, 29, 0, 768, 51, 46, 110, 245, 255),
VTX(-12, 32, 13, 905, 0, 26, 97, 191, 255),
VTX(-12, 29, -13, 631, 48, 17, 104, 56, 255),
VTX(11, 32, -13, 400, 0, 220, 98, 58, 255),
VTX(20, 32, 0, 1280, 0, 195, 103, 9, 255),
VTX(11, 29, 13, 1136, 38, 229, 104, 204, 255),
};
static Vtx object_gi_dekupouchVtx_0009F0[11] = {
VTX(-11, 8, -10, 1235, 1015, 204, 32, 153, 255),
VTX(-16, 19, -1, 1643, -206, 160, 248, 186, 255),
VTX(0, 19, -5, 536, -98, 3, 243, 137, 255),
VTX(11, 8, -10, -293, 1043, 52, 29, 152, 255),
VTX(16, 19, -1, -563, -264, 96, 0, 185, 255),
VTX(-11, 8, 10, 450, 1412, 204, 32, 103, 255),
VTX(0, 19, 5, 1571, -74, 255, 244, 119, 255),
VTX(-16, 19, 2, -307, -102, 161, 252, 73, 255),
VTX(11, 8, 10, 713, 1343, 52, 28, 104, 255),
VTX(16, 19, 2, 1453, -78, 97, 254, 69, 255),
VTX(0, 19, 5, -500, -71, 255, 244, 119, 255),
};
static Vtx object_gi_dekupouchVtx_000AA0[5] = {
VTX(11, 8, 10, 886, -58, 39, 34, 108, 255),
VTX(-1, -21, 15, 505, 1070, 254, 228, 116, 255),
VTX(23, -21, 7, 1319, 1070, 82, 208, 72, 255),
VTX(-11, 8, 10, 129, -62, 217, 36, 107, 255),
VTX(-24, -18, 7, -275, 1011, 169, 215, 70, 255),
};
Gfx gGiBulletBagColorDL[] = {
gsDPPipeSync(),
gsDPSetPrimColor(0, 0, 255, 160, 0, 255),
gsDPSetEnvColor(20, 20, 0, 255),
gsSPEndDisplayList(),
};
Gfx gGiBulletBag50ColorDL[] = {
gsDPPipeSync(),
gsDPSetPrimColor(0, 0, 255, 100, 0, 255),
gsDPSetEnvColor(20, 0, 0, 255),
gsSPEndDisplayList(),
};
Gfx gGiBulletBagStringColorDL[] = {
gsDPPipeSync(),
gsDPSetPrimColor(0, 0, 60, 40, 0, 255),
gsDPSetEnvColor(100, 60, 0, 255),
gsSPEndDisplayList(),
};
Gfx gGiBulletBag50StringColorDL[] = {
gsDPPipeSync(),
gsDPSetPrimColor(0, 0, 200, 120, 40, 255),
gsDPSetEnvColor(100, 60, 0, 255),
gsSPEndDisplayList(),
};
Gfx gGiBulletBagDL[] = {
gsDPPipeSync(),
gsDPSetRenderMode(G_RM_PASS, G_RM_AA_ZB_TEX_EDGE2),
gsDPSetCombineLERP(PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, 0, 0, 0, 1,
COMBINED, K5, SHADE, COMBINED_ALPHA, 0, 0, 0, 1),
gsDPSetTextureLUT(G_TT_NONE),
gsSPTexture(1500, 1500, 0, 0, G_ON),
gsDPSetTextureImage(G_IM_FMT_I, G_IM_SIZ_16b, 1, 0x04032490),
gsDPSetTile(G_IM_FMT_I, G_IM_SIZ_16b, 0, 0, 7, 0, 0, 5, 1, 0, 5, 1),
gsDPLoadSync(),
gsDPLoadBlock(7, 0, 0, 511, 512),
gsDPPipeSync(),
gsDPSetTile(G_IM_FMT_I, G_IM_SIZ_8b, 4, 0, 0, 0, 0, 5, 1, 0, 5, 1),
gsDPSetTileSize(0, 0, 0, 124, 124),
gsSPClearGeometryMode(G_TEXTURE_ENABLE | G_FOG),
gsSPSetGeometryMode(G_TEXTURE_ENABLE | G_CULL_BACK | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR),
gsSPVertex(&object_gi_dekupouchVtx_000300[0], 3, 0),
gsSP1Triangle(0, 1, 2, 0),
gsSPVertex(&object_gi_dekupouchVtx_000330[0], 32, 0),
gsSP2Triangles(0, 1, 2, 0, 3, 2, 4, 0),
gsSP2Triangles(5, 4, 6, 0, 7, 6, 8, 0),
gsSP2Triangles(9, 8, 10, 0, 10, 11, 12, 0),
gsSP2Triangles(1, 13, 14, 0, 2, 14, 15, 0),
gsSP2Triangles(4, 15, 16, 0, 6, 16, 17, 0),
gsSP2Triangles(11, 18, 19, 0, 13, 20, 21, 0),
gsSP2Triangles(14, 21, 22, 0, 15, 22, 23, 0),
gsSP2Triangles(16, 23, 24, 0, 17, 24, 18, 0),
gsSP2Triangles(21, 14, 13, 0, 19, 12, 11, 0),
gsSP2Triangles(18, 11, 17, 0, 24, 17, 16, 0),
gsSP2Triangles(22, 15, 14, 0, 23, 16, 15, 0),
gsSP2Triangles(1, 0, 25, 0, 2, 3, 0, 0),
gsSP2Triangles(4, 5, 3, 0, 6, 7, 5, 0),
gsSP2Triangles(8, 9, 7, 0, 26, 25, 27, 0),
gsSP2Triangles(13, 1, 26, 0, 14, 2, 1, 0),
gsSP2Triangles(15, 4, 2, 0, 16, 6, 4, 0),
gsSP2Triangles(28, 29, 30, 0, 18, 29, 31, 0),
gsSP2Triangles(18, 31, 19, 0, 28, 21, 20, 0),
gsSP2Triangles(21, 28, 30, 0, 22, 21, 30, 0),
gsSP2Triangles(22, 30, 23, 0, 23, 30, 29, 0),
gsSP2Triangles(29, 24, 23, 0, 24, 29, 18, 0),
gsDPPipeSync(),
gsDPSetTextureImage(G_IM_FMT_I, G_IM_SIZ_16b, 1, object_gi_dekupouchTex_000000),
gsDPSetTile(G_IM_FMT_I, G_IM_SIZ_16b, 0, 0, 7, 0, 0, 4, 1, 0, 5, 1),
gsDPLoadSync(),
gsDPLoadBlock(7, 0, 0, 127, 1024),
gsDPPipeSync(),
gsDPSetTile(G_IM_FMT_I, G_IM_SIZ_4b, 2, 0, 0, 0, 0, 4, 1, 0, 5, 1),
gsDPSetTileSize(0, 0, 0, 124, 60),
gsSPVertex(&object_gi_dekupouchVtx_000530[0], 3, 0),
gsSP1Triangle(0, 1, 2, 0),
gsSPVertex(&object_gi_dekupouchVtx_000560[0], 4, 0),
gsSP2Triangles(0, 1, 2, 0, 2, 3, 0, 0),
gsDPPipeSync(),
gsDPSetPrimColor(0, 0, 190, 200, 170, 255),
gsDPSetEnvColor(160, 170, 140, 255),
gsSPTexture(65535, 65535, 0, 0, G_ON),
gsDPSetTextureImage(G_IM_FMT_I, G_IM_SIZ_16b, 1, 0x04032490),
gsDPSetTile(G_IM_FMT_I, G_IM_SIZ_16b, 0, 0, 7, 0, 0, 5, 0, 0, 5, 0),
gsDPLoadSync(),
gsDPLoadBlock(7, 0, 0, 511, 512),
gsDPPipeSync(),
gsDPSetTile(G_IM_FMT_I, G_IM_SIZ_8b, 4, 0, 0, 0, 0, 5, 0, 0, 5, 0),
gsDPSetTileSize(0, 0, 0, 124, 124),
gsSPClearGeometryMode(G_TEXTURE_ENABLE | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR),
gsSPVertex(&object_gi_dekupouchVtx_0005A0[0], 32, 0),
gsSP2Triangles(0, 1, 2, 0, 3, 4, 5, 0),
gsSP2Triangles(6, 7, 8, 0, 4, 2, 5, 0),
gsSP2Triangles(9, 5, 0, 0, 8, 10, 3, 0),
gsSP2Triangles(10, 0, 4, 0, 11, 3, 9, 0),
gsSP2Triangles(12, 5, 2, 0, 5, 9, 3, 0),
gsSP2Triangles(7, 9, 10, 0, 5, 12, 1, 0),
gsSP2Triangles(10, 8, 7, 0, 0, 10, 9, 0),
gsSP2Triangles(1, 0, 5, 0, 3, 11, 8, 0),
gsSP2Triangles(4, 3, 10, 0, 2, 4, 0, 0),
gsSP2Triangles(9, 7, 11, 0, 13, 11, 7, 0),
gsSP2Triangles(13, 14, 8, 0, 8, 14, 6, 0),
gsSP2Triangles(7, 6, 13, 0, 8, 11, 13, 0),
gsSP2Triangles(15, 16, 17, 0, 18, 19, 20, 0),
gsSP2Triangles(21, 22, 23, 0, 24, 17, 16, 0),
gsSP2Triangles(25, 18, 26, 0, 20, 27, 21, 0),
gsSP2Triangles(19, 25, 27, 0, 26, 20, 28, 0),
gsSP2Triangles(17, 24, 29, 0, 20, 26, 18, 0),
gsSP2Triangles(27, 26, 22, 0, 24, 30, 29, 0),
gsSP2Triangles(22, 21, 27, 0, 26, 27, 25, 0),
gsSP2Triangles(15, 29, 30, 0, 21, 28, 20, 0),
gsSP2Triangles(27, 20, 19, 0, 16, 15, 30, 0),
gsSP2Triangles(28, 22, 26, 0, 22, 28, 31, 0),
gsSPVertex(&object_gi_dekupouchVtx_0007A0[0], 9, 0),
gsSP2Triangles(0, 1, 2, 0, 3, 1, 0, 0),
gsSP2Triangles(4, 5, 6, 0, 4, 7, 8, 0),
gsDPPipeSync(),
gsDPSetCombineLERP(TEXEL1, PRIMITIVE, PRIM_LOD_FRAC, TEXEL0, 0, 0, 0, 1,
PRIMITIVE, ENVIRONMENT, COMBINED, ENVIRONMENT, 0, 0, 0, 1),
gsDPSetPrimColor(0, 128, 255, 255, 170, 255),
gsDPSetEnvColor(150, 120, 0, 255),
gsSPTexture(3000, 3000, 0, 0, G_ON),
gsDPSetTextureImage(G_IM_FMT_I, G_IM_SIZ_16b, 1, 0x04032490),
gsDPSetTile(G_IM_FMT_I, G_IM_SIZ_16b, 0, 0, 7, 0, 0, 5, 1, 0, 5, 1),
gsDPLoadSync(),
gsDPLoadBlock(7, 0, 0, 511, 512),
gsDPPipeSync(),
gsDPSetTile(G_IM_FMT_I, G_IM_SIZ_8b, 4, 0, 0, 0, 0, 5, 1, 0, 5, 1),
gsDPSetTileSize(0, 0, 0, 124, 124),
gsSPSetGeometryMode(G_TEXTURE_ENABLE | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR),
gsSPVertex(&object_gi_dekupouchVtx_000830[0], 3, 0),
gsSP1Triangle(0, 1, 2, 0),
gsSPVertex(&object_gi_dekupouchVtx_000860[0], 18, 0),
gsSP2Triangles(0, 1, 2, 0, 3, 2, 4, 0),
gsSP2Triangles(1, 0, 5, 0, 5, 3, 4, 0),
gsSP2Triangles(2, 3, 0, 0, 6, 5, 0, 0),
gsSP2Triangles(3, 5, 6, 0, 0, 3, 6, 0),
gsSP2Triangles(7, 8, 9, 0, 10, 11, 12, 0),
gsSP2Triangles(9, 13, 14, 0, 15, 12, 11, 0),
gsSP2Triangles(9, 14, 7, 0, 12, 16, 10, 0),
gsSP2Triangles(12, 15, 17, 0, 17, 15, 16, 0),
gsSP1Triangle(17, 16, 12, 0),
gsDPPipeSync(),
gsDPSetCombineLERP(PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, 0, 0, 0, 1,
COMBINED, K5, SHADE, COMBINED_ALPHA, 0, 0, 0, 1),
gsDPSetPrimColor(0, 0, 80, 50, 0, 255),
gsDPSetEnvColor(0, 0, 0, 255),
gsSPTexture(1500, 1500, 0, 0, G_ON),
gsSPVertex(&object_gi_dekupouchVtx_000980[0], 7, 0),
gsSP2Triangles(0, 1, 2, 0, 0, 3, 1, 0),
gsSP2Triangles(0, 4, 3, 0, 0, 5, 4, 0),
gsSP2Triangles(5, 0, 6, 0, 6, 0, 2, 0),
gsSPEndDisplayList(),
};
Gfx gGiBulletBagStringDL[] = {
gsDPPipeSync(),
gsDPSetRenderMode(G_RM_OPA_SURF, G_RM_AA_ZB_XLU_DECAL2),
gsDPSetCombineLERP(PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, 0, 0, 0, TEXEL0,
COMBINED, K5, SHADE, COMBINED_ALPHA, 0, 0, 0, COMBINED),
gsDPSetPrimColor(0, 0, 190, 200, 170, 255),
gsDPSetEnvColor(160, 170, 140, 255),
gsDPSetTextureLUT(G_TT_NONE),
gsSPTexture(65535, 65535, 0, 0, G_ON),
gsDPSetTextureImage(G_IM_FMT_I, G_IM_SIZ_16b, 1, object_gi_dekupouchTex_000000),
gsDPSetTile(G_IM_FMT_I, G_IM_SIZ_16b, 0, 0, 7, 0, 2, 4, 0, 2, 5, 0),
gsDPLoadSync(),
gsDPLoadBlock(7, 0, 0, 127, 1024),
gsDPPipeSync(),
gsDPSetTile(G_IM_FMT_I, G_IM_SIZ_4b, 2, 0, 0, 0, 2, 4, 0, 2, 5, 0),
gsDPSetTileSize(0, 0, 0, 124, 60),
gsSPClearGeometryMode(G_TEXTURE_ENABLE | G_FOG | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR),
gsSPSetGeometryMode(G_TEXTURE_ENABLE | G_CULL_BACK | G_LIGHTING),
gsSPVertex(&object_gi_dekupouchVtx_0009F0[0], 11, 0),
gsSP2Triangles(0, 1, 2, 0, 2, 3, 0, 0),
gsSP2Triangles(3, 2, 4, 0, 5, 6, 7, 0),
gsSP1Triangle(8, 9, 10, 0),
gsSPEndDisplayList(),
};
Gfx gGiBulletBagWritingDL[] = {
gsDPPipeSync(),
gsDPSetTextureImage(G_IM_FMT_I, G_IM_SIZ_16b, 1, object_gi_dekupouchTex_000100),
gsDPSetTile(G_IM_FMT_I, G_IM_SIZ_16b, 0, 0, 7, 0, 2, 5, 0, 2, 5, 0),
gsDPLoadSync(),
gsDPLoadBlock(7, 0, 0, 255, 1024),
gsDPPipeSync(),
gsDPSetTile(G_IM_FMT_I, G_IM_SIZ_4b, 2, 0, 0, 0, 2, 5, 0, 2, 5, 0),
gsDPSetTileSize(0, 0, 0, 124, 124),
gsSPVertex(&object_gi_dekupouchVtx_000AA0[0], 5, 0),
gsSP2Triangles(0, 1, 2, 0, 1, 0, 3, 0),
gsSP1Triangle(3, 4, 1, 0),
gsSPEndDisplayList(),
};
|
b2569d97250d0d3e3b8a243d794c2cb7145641ca
|
b0dd7779c225971e71ae12c1093dc75ed9889921
|
/tools/build/v2/engine/compile.c
|
5e6185ae41733262516d425dc57ee3a6d9da3829
|
[
"LicenseRef-scancode-warranty-disclaimer",
"BSL-1.0"
] |
permissive
|
blackberry/Boost
|
6e653cd91a7806855a162347a5aeebd2a8c055a2
|
fc90c3fde129c62565c023f091eddc4a7ed9902b
|
refs/heads/1_48_0-gnu
| 2021-01-15T14:31:33.706351
| 2013-06-25T16:02:41
| 2013-06-25T16:02:41
| 2,599,411
| 244
| 154
|
BSL-1.0
| 2018-10-13T18:35:09
| 2011-10-18T14:25:18
|
C++
|
UTF-8
|
C
| false
| false
| 11,482
|
c
|
compile.c
|
/*
* Copyright 1993, 2000 Christopher Seiwald.
*
* This file is part of Jam - see jam.c for Copyright information.
*/
/* This file is ALSO:
* Copyright 2001-2004 David Abrahams.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
*/
# include "jam.h"
# include "lists.h"
# include "parse.h"
# include "compile.h"
# include "variable.h"
# include "rules.h"
# include "object.h"
# include "make.h"
# include "search.h"
# include "hdrmacro.h"
# include "hash.h"
# include "modules.h"
# include "strings.h"
# include "builtins.h"
# include "class.h"
# include "constants.h"
# include <assert.h>
# include <string.h>
# include <stdarg.h>
/*
* compile.c - compile parsed jam statements
*
* External routines:
*
* compile_append() - append list results of two statements
* compile_eval() - evaluate if to determine which leg to compile
* compile_foreach() - compile the "for x in y" statement
* compile_if() - compile 'if' rule
* compile_while() - compile 'while' rule
* compile_include() - support for 'include' - call include() on file
* compile_list() - expand and return a list
* compile_local() - declare (and set) local variables
* compile_null() - do nothing -- a stub for parsing
* compile_on() - run rule under influence of on-target variables
* compile_rule() - compile a single user defined rule
* compile_rules() - compile a chain of rules
* compile_set() - compile the "set variable" statement
* compile_setcomp() - support for `rule` - save parse tree
* compile_setexec() - support for `actions` - save execution string
* compile_settings() - compile the "on =" (set variable on exec) statement
* compile_switch() - compile 'switch' rule
*
* Internal routines:
*
* debug_compile() - printf with indent to show rule expansion.
* evaluate_rule() - execute a rule invocation
*
* builtin_depends() - DEPENDS/INCLUDES rule
* builtin_echo() - ECHO rule
* builtin_exit() - EXIT rule
* builtin_flags() - NOCARE, NOTFILE, TEMPORARY rule
*
* 02/03/94 (seiwald) - Changed trace output to read "setting" instead of
* the awkward sounding "settings".
* 04/12/94 (seiwald) - Combined build_depends() with build_includes().
* 04/12/94 (seiwald) - actionlist() now just appends a single action.
* 04/13/94 (seiwald) - added shorthand L0 for null list pointer
* 05/13/94 (seiwald) - include files are now bound as targets, and thus
* can make use of $(SEARCH)
* 06/01/94 (seiwald) - new 'actions existing' does existing sources
* 08/23/94 (seiwald) - Support for '+=' (append to variable)
* 12/20/94 (seiwald) - NOTIME renamed NOTFILE.
* 01/22/95 (seiwald) - Exit rule.
* 02/02/95 (seiwald) - Always rule; LEAVES rule.
* 02/14/95 (seiwald) - NoUpdate rule.
* 09/11/00 (seiwald) - new evaluate_rule() for headers().
* 09/11/00 (seiwald) - compile_xxx() now return LIST *.
* New compile_append() and compile_list() in
* support of building lists here, rather than
* in jamgram.yy.
* 01/10/00 (seiwald) - built-ins split out to builtin.c.
*/
static void debug_compile( int which, const char * s, FRAME * frame );
int glob( const char * s, const char * c );
/* Internal functions from builtins.c */
void backtrace( FRAME * frame );
void backtrace_line( FRAME * frame );
void print_source_line( FRAME * frame );
struct frame * frame_before_python_call;
static OBJECT * module_scope;
void frame_init( FRAME* frame )
{
frame->prev = 0;
frame->prev_user = 0;
lol_init(frame->args);
frame->module = root_module();
frame->rulename = "module scope";
frame->file = 0;
frame->line = -1;
}
void frame_free( FRAME* frame )
{
lol_free( frame->args );
}
/*
* evaluate_rule() - execute a rule invocation.
*/
LIST *
evaluate_rule(
OBJECT * rulename,
FRAME * frame )
{
LIST * result = L0;
RULE * rule;
profile_frame prof[1];
module_t * prev_module = frame->module;
rule = bindrule( rulename, frame->module );
if ( DEBUG_COMPILE )
{
/* Try hard to indicate in which module the rule is going to execute. */
if ( rule->module != frame->module
&& rule->procedure != 0 && !object_equal( rulename, function_rulename( rule->procedure ) ) )
{
char buf[256] = "";
if ( rule->module->name )
{
strncat( buf, object_str( rule->module->name ), sizeof( buf ) - 1 );
strncat( buf, ".", sizeof( buf ) - 1 );
}
strncat( buf, object_str( rule->name ), sizeof( buf ) - 1 );
debug_compile( 1, buf, frame );
}
else
{
debug_compile( 1, object_str( rulename ), frame );
}
lol_print( frame->args );
printf( "\n" );
}
if ( rule->procedure && rule->module != prev_module )
{
/* Propagate current module to nested rule invocations. */
frame->module = rule->module;
}
/* Record current rule name in frame. */
if ( rule->procedure )
{
frame->rulename = object_str( rulename );
/* And enter record profile info. */
if ( DEBUG_PROFILE )
profile_enter( function_rulename( rule->procedure ), prof );
}
/* Check traditional targets $(<) and sources $(>). */
if ( !rule->actions && !rule->procedure )
{
backtrace_line( frame->prev );
if ( frame->module->name )
{
printf( "rule %s unknown in module %s\n", object_str( rule->name ), object_str( frame->module->name ) );
}
else
{
printf( "rule %s unknown in module \n", object_str( rule->name ) );
}
backtrace( frame->prev );
exit( 1 );
}
/* If this rule will be executed for updating the targets then construct the
* action for make().
*/
if ( rule->actions )
{
TARGETS * t;
ACTION * action;
/* The action is associated with this instance of this rule. */
action = (ACTION *)BJAM_MALLOC( sizeof( ACTION ) );
memset( (char *)action, '\0', sizeof( *action ) );
action->rule = rule;
action->targets = targetlist( (TARGETS *)0, lol_get( frame->args, 0 ) );
action->sources = targetlist( (TARGETS *)0, lol_get( frame->args, 1 ) );
action->refs = 1;
/* If we have a group of targets all being built using the same action
* then we must not allow any of them to be used as sources unless they
* had all already been built in the first place or their joined action
* has had a chance to finish its work and build all of them anew.
*
* Without this it might be possible, in case of a multi-process build,
* for their action, triggered by buiding one of the targets, to still
* be running when another target in the group reports as done in order
* to avoid triggering the same action again and gets used prematurely.
*
* As a quick-fix to achieve this effect we make all the targets list
* each other as 'included targets'. More precisely, we mark the first
* listed target as including all the other targets in the list and vice
* versa. This makes anyone depending on any of those targets implicitly
* depend on all of them, thus making sure none of those targets can be
* used as sources until all of them have been built. Note that direct
* dependencies could not have been used due to the 'circular
* dependency' issue.
*
* TODO: Although the current implementation solves the problem of one
* of the targets getting used before its action completes its work it
* also forces the action to run whenever any of the targets in the
* group is not up to date even though some of them might not actually
* be used by the targets being built. We should see how we can
* correctly recognize such cases and use that to avoid running the
* action if possible and not rebuild targets not actually depending on
* targets that are not up to date.
*
* TODO: Using the 'include' feature might have side-effects due to
* interaction with the actual 'inclusion scanning' system. This should
* be checked.
*/
if ( action->targets )
{
TARGET * t0 = action->targets->target;
for ( t = action->targets->next; t; t = t->next )
{
target_include( t->target, t0 );
target_include( t0, t->target );
}
}
/* Append this action to the actions of each target. */
for ( t = action->targets; t; t = t->next )
t->target->actions = actionlist( t->target->actions, action );
action_free( action );
}
/* Now recursively compile any parse tree associated with this rule.
* function_refer()/function_free() call pair added to ensure rule not freed
* during use.
*/
if ( rule->procedure )
{
FUNCTION * function = rule->procedure;
function_refer( function );
result = function_run( function, frame, stack_global() );
function_free( function );
}
if ( DEBUG_PROFILE && rule->procedure )
profile_exit( prof );
if ( DEBUG_COMPILE )
debug_compile( -1, 0, frame);
return result;
}
/*
* Call the given rule with the specified parameters. The parameters should be
* of type LIST* and end with a NULL pointer. This differs from 'evaluate_rule'
* in that frame for the called rule is prepared inside 'call_rule'.
*
* This function is useful when a builtin rule (in C) wants to call another rule
* which might be implemented in Jam.
*/
LIST * call_rule( OBJECT * rulename, FRAME * caller_frame, ... )
{
va_list va;
LIST * result;
FRAME inner[1];
frame_init( inner );
inner->prev = caller_frame;
inner->prev_user = caller_frame->module->user_module ?
caller_frame : caller_frame->prev_user;
inner->module = caller_frame->module;
va_start( va, caller_frame );
for ( ; ; )
{
LIST * l = va_arg( va, LIST* );
if ( !l )
break;
lol_add( inner->args, l );
}
va_end( va );
result = evaluate_rule( rulename, inner );
frame_free( inner );
return result;
}
/*
* debug_compile() - printf with indent to show rule expansion.
*/
static void debug_compile( int which, const char * s, FRAME * frame )
{
static int level = 0;
static char indent[36] = ">>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|";
if ( which >= 0 )
{
int i;
print_source_line( frame );
i = ( level + 1 ) * 2;
while ( i > 35 )
{
fputs( indent, stdout );
i -= 35;
}
printf( "%*.*s ", i, i, indent );
}
if ( s )
printf( "%s ", s );
level += which;
}
|
eef09555c1e8bbc689a48a9a2cf25d1952c4e37d
|
a3f2c5dcf6eac598fdcf74c863bbcb2cb270b1cc
|
/Chapter5/Exercise 5-02/getch.h
|
db0ab716e0100a5ce3bd670600f59d8d63bec505
|
[] |
no_license
|
ccpalettes/the-c-programming-language-second-edition-solutions
|
3908c3731f40bb9434563d157cb7e35ba0e08c4d
|
96c17173e05310c9475edfaf2566c525e0970178
|
refs/heads/master
| 2022-07-19T16:30:38.494508
| 2022-07-18T09:33:58
| 2022-07-18T09:33:58
| 8,107,202
| 681
| 240
| null | 2020-12-19T05:01:15
| 2013-02-09T07:08:51
|
C
|
UTF-8
|
C
| false
| false
| 85
|
h
|
getch.h
|
/**
* Solution for Exercise 5-02, Chapter5.
*/
int getch(void);
void ungetch(int);
|
85aa21af1847e637677bf8806ab43eb95f2fc7aa
|
b452bbb87214f174122f425f6f98f4c3890c3cca
|
/internal/ccall/glcomp/glcompimage.c
|
ca0bb4963999b5ada0cf735ad935daad0919f5f7
|
[
"MIT"
] |
permissive
|
goccy/go-graphviz
|
bea9bc86b42734aff7ffae283aeae71702ca588a
|
865af036ddbb745c4424bbd2fdaa9a75668cf0d4
|
refs/heads/master
| 2023-07-20T08:05:39.868377
| 2023-03-21T23:49:44
| 2023-03-21T23:49:44
| 236,740,615
| 511
| 66
|
MIT
| 2023-07-07T13:53:28
| 2020-01-28T13:24:09
|
Go
|
UTF-8
|
C
| false
| false
| 5,573
|
c
|
glcompimage.c
|
/* $Id$Revision: */
/* vim:set shiftwidth=4 ts=8: */
/*************************************************************************
* Copyright (c) 2011 AT&T Intellectual Property
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors: See CVS logs. Details at http://www.graphviz.org/
*************************************************************************/
#include "glcompimage.h"
#include "glcompfont.h"
#include "glcompset.h"
#include "glutils.h"
#include "glcomptexture.h"
#include "memory.h"
glCompImage *glCompImageNew(glCompObj * par, GLfloat x, GLfloat y)
{
glCompImage *p;
p = NEW(glCompImage);
glCompInitCommon((glCompObj *) p, par, x, y);
p->objType = glImageObj;
//typedef enum {glPanelObj,glbuttonObj,glLabelObj,glImageObj}glObjType;
p->objType = glImageObj;
p->stretch = 0;
#if 0
p->pngFile = (char *) 0;
#endif
p->texture = NULL;
p->common.functions.draw = glCompImageDraw;
return p;
}
/* glCompImageNewFile:
* Creates image from given input file.
* At present, we assume png input.
* Return 0 on failure.
*/
glCompImage *glCompImageNewFile (glCompObj * par, GLfloat x, GLfloat y, char* imgfile, int is2D)
{
int imageWidth, imageHeight;
unsigned char *data = glCompLoadPng (imgfile, &imageWidth, &imageHeight);
glCompImage *p;
if (!data) return NULL;
p = glCompImageNew (par, x, y);
if (!glCompImageLoad (p, data, imageWidth, imageHeight, is2D)) {
glCompImageDelete (p);
return NULL;
}
return p;
}
void glCompImageDelete(glCompImage * p)
{
glCompEmptyCommon(&p->common);
#if 0
if (p->pngFile)
free(p->pngFile);
#endif
if (p->texture)
glCompDeleteTexture(p->texture);
free(p);
}
int glCompImageLoad(glCompImage * i, unsigned char *data, int width,
int height,int is2D)
{
if (data != NULL) { /*valid image data */
glCompDeleteTexture(i->texture);
i->texture =
glCompSetAddNewTexImage(i->common.compset, width, height, data,
is2D);
if (i->texture) {
i->common.width = width;
i->common.height = height;
return 1;
}
}
return 0;
}
int glCompImageLoadPng(glCompImage * i, char *pngFile,int is2D)
{
int imageWidth, imageHeight;
unsigned char *data;
data = glCompLoadPng (pngFile, &imageWidth, &imageHeight);
return glCompImageLoad(i, data, imageWidth, imageHeight,is2D);
}
#if 0
int glCompImageLoadRaw(glCompSet * s, glCompImage * i, char *rawFile,int is2D)
{
int imageWidth, imageHeight;
unsigned char *data;
data = glCompLoadPng (rawFile, &imageWidth, &imageHeight);
return glCompImageLoad(i, data, imageWidth, imageHeight,is2D);
}
#endif
void glCompImageDraw(void *obj)
{
glCompImage *p = (glCompImage *) obj;
glCompCommon ref = p->common;
GLfloat w,h,d;
glCompCalcWidget((glCompCommon *) p->common.parent, &p->common, &ref);
if (!p->common.visible)
return;
if (!p->texture)
return;
if(p->texture->id <=0)
{
glRasterPos2f(ref.pos.x, ref.pos.y);
glDrawPixels(p->texture->width, p->texture->height, GL_RGBA,GL_UNSIGNED_BYTE, p->texture->data);
}
else
{
#if 0
w=ref.width;
h=ref.height;
#endif
w = p->width;
h = p->height;
d=(GLfloat)p->common.layer* (GLfloat)GLCOMPSET_BEVEL_DIFF;
glDisable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glBindTexture(GL_TEXTURE_2D,p->texture->id);
glBegin(GL_QUADS);
glTexCoord2d(0.0f, 1.0f);glVertex3d(ref.pos.x,ref.pos.y,d);
glTexCoord2d(1.0f, 1.0f);glVertex3d(ref.pos.x+w,ref.pos.y,d);
glTexCoord2d(1.0f, 0.0f);glVertex3d(ref.pos.x+w,ref.pos.y+h,d);
glTexCoord2d(0.0f, 0.0f);glVertex3d(ref.pos.x,ref.pos.y+h,d);
glEnd();
glDisable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
}
}
void glCompImageClick(glCompObj * o, GLfloat x, GLfloat y,
glMouseButtonType t)
{
if (o->common.callbacks.click)
o->common.callbacks.click(o, x, y, t);
}
void glCompImageDoubleClick(glCompObj * obj, GLfloat x, GLfloat y,
glMouseButtonType t)
{
/*Put your internal code here */
if (((glCompImage *) obj)->common.callbacks.doubleclick)
((glCompImage *) obj)->common.callbacks.doubleclick(obj, x, y, t);
}
void glCompImageMouseDown(glCompObj * obj, GLfloat x, GLfloat y,
glMouseButtonType t)
{
/*Put your internal code here */
if (((glCompImage *) obj)->common.callbacks.mousedown)
((glCompImage *) obj)->common.callbacks.mousedown(obj, x, y, t);
}
void glCompImageMouseIn(glCompObj * obj, GLfloat x, GLfloat y)
{
/*Put your internal code here */
if (((glCompImage *) obj)->common.callbacks.mousein)
((glCompImage *) obj)->common.callbacks.mousein(obj, x, y);
}
void glCompImageMouseOut(glCompObj * obj, GLfloat x, GLfloat y)
{
/*Put your internal code here */
if (((glCompImage *) obj)->common.callbacks.mouseout)
((glCompImage *) obj)->common.callbacks.mouseout(obj, x, y);
}
void glCompImageMouseOver(glCompObj * obj, GLfloat x, GLfloat y)
{
/*Put your internal code here */
if (((glCompImage *) obj)->common.callbacks.mouseover)
((glCompImage *) obj)->common.callbacks.mouseover(obj, x, y);
}
void glCompImageMouseUp(glCompObj * obj, GLfloat x, GLfloat y,
glMouseButtonType t)
{
/*Put your internal code here */
if (((glCompImage *) obj)->common.callbacks.mouseup)
((glCompImage *) obj)->common.callbacks.mouseup(obj, x, y, t);
}
|
ec8640eeacb9ed033b10e6372c324f0c341fb5c7
|
235796802c0aa76ae6b5c6d324365d79244a6b6a
|
/Software/libthunderscope/examples/thunderscopehwdump/thunderscopehwdump.c
|
8fcfe0c843873c7a6b31fb21a2cf479b471c9d18
|
[
"MIT"
] |
permissive
|
EEVengers/ThunderScope
|
eab21035ef65725a0852d6c13bafdc40abbf6d02
|
da9c78158bb9d96b82579c7c0f4b14f45ec6a766
|
refs/heads/master
| 2023-08-31T07:05:58.323945
| 2023-08-11T02:51:32
| 2023-08-11T02:51:32
| 190,029,235
| 437
| 114
|
MIT
| 2023-08-11T02:51:33
| 2019-06-03T15:09:39
|
VHDL
|
UTF-8
|
C
| false
| false
| 8,591
|
c
|
thunderscopehwdump.c
|
#include "thunderscopehw.h"
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <string.h>
#ifdef WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif
void write32(uint64_t x, FILE* f) {
uint32_t v = 0;
if (x < (uint64_t)0xFFFFFFFF) v = (uint32_t)x;
if (fwrite(&v, 1, 4, f) != 4) {
perror("fwrite");
exit(1);
}
}
struct Option {
const char* name;
bool needs_argument;
int return_value;
};
struct Option options[] = {
{"device", true, 1 },
{"samples", true, 2 },
{"output-samplerate", true, 3 },
{"help", false, 4 },
{"bw-all", true, 0x10 },
{"bw1", true, 0x11 },
{"bw2", true, 0x12 },
{"bw3", true, 0x13 },
{"bw4", true, 0x14 },
{"vdiv-all", true, 0x20 },
{"vdiv1", true, 0x21 },
{"vdiv2", true, 0x22 },
{"vdiv3", true, 0x23 },
{"vdiv4", true, 0x24 },
{"voffset-all", true, 0x30 },
{"voffset1", true, 0x31 },
{"voffset2", true, 0x32 },
{"voffset3", true, 0x33 },
{"voffset4", true, 0x34 },
{"ac-all", false, 0x40 },
{"ac1", false, 0x41 },
{"ac2", false, 0x42 },
{"ac3", false, 0x43 },
{"ac4", false, 0x44 },
{"dc-all", false, 0x50 },
{"dc1", false, 0x51 },
{"dc2", false, 0x52 },
{"dc3", false, 0x53 },
{"dc4", false, 0x54 },
{"enable-all", false, 0x60 },
{"enable1", false, 0x61 },
{"enable2", false, 0x62 },
{"enable3", false, 0x63 },
{"enable4", false, 0x64 },
};
void usage()
{
fprintf(stderr,
"thunderscopehwdump [options] [filename.wav]\n"
" --device=<deviceid>\n"
" --samples=<number of samples> must be divisable by 4096\n"
" --output-samplerate=<rate> samplerate used in wav file\n"
" --bw[1/2/3/4/-all]=20/100/200/350 (Hz)\n"
" --vdiv[1/2/3/4/-all]=1/2/5/10/20/50/100/200/500/1000/2000/5000/10000 (mV)\n"
" --voffset[1/2/3/4/-all]=<voltage offset> (volts)\n"
" --ac[1/2/3/4/-all]\n"
" --dc[1/2/3/4/-all]\n"
" --enable[1/2/3/4/-all]\n");
}
char* optarg;
int optind = 1;
int mygetopt(int argc, char** argv) {
if (optind >= argc) return -1;
if (!argv[optind][0] == '-' || argv[optind][1] != '-') return -1;
char *arg = strchr(argv[optind], '=');
for (size_t i = 0; i < sizeof(options) / sizeof(options[0]); i++) {
size_t len = strlen(options[i].name);
if (strncmp(options[i].name, argv[optind] + 2, len)) continue;
if (options[i].needs_argument) {
if (!arg) continue;
if (argv[optind] + 2 + len != arg) continue;
optarg = arg + 1;
} else {
if (arg) continue;
if (argv[optind][2 + len]) continue;
optarg = NULL;
}
optind++;
return options[i].return_value;
}
fprintf(stderr, "Unknown option: %s\n", argv[optind]);
usage();
exit(1);
}
int main(int argc, char** argv) {
uint64_t scope_id = 0;
uint64_t samples = 0;
int samplerate = 0;
while (1) {
switch (mygetopt(argc, argv)) {
case 1:
if (!sscanf(optarg, "%" PRIx64, &scope_id)) {
fprintf(stderr, "Scope ID must be hexadecimal.\n");
exit(1);
}
continue;
case 2:
if (!sscanf(optarg, "%" PRId64, &samples)) {
fprintf(stderr, "Number of samples must be a number.\n");
exit(1);
}
continue;
case 3:
if (!sscanf(optarg, "%d", &samplerate)) {
fprintf(stderr, "Output samplerate must be a number.\n");
exit(1);
}
continue;
case 4:
usage();
exit(0);
default:
continue;
case -1:
break;
}
break;
}
if (scope_id == 0) {
uint64_t scope_ids[32];
int scopes = thunderscopehw_scan(scope_ids, 32);
if (scopes == 0) {
fprintf(stderr, "No thunderscopehw hardware found.\n");
exit(1);
}
if (scopes > 1) {
fprintf(stderr, "Multiple scopes found, please select one with --device.\n");
for (int i = 0; i < scopes; i++) {
fprintf(stderr, " %0" PRIx64 "\n", scope_ids[i]);
}
exit(1);
}
scope_id = scope_ids[0];
}
struct ThunderScopeHW *ts = thunderscopehw_create();
enum ThunderScopeHWStatus ret;
ret = thunderscopehw_connect(ts, scope_id);
if (ret != THUNDERSCOPEHW_STATUS_OK) {
fprintf(stderr, "Failed to connecto to thunderscope, error = %s\n", thunderscopehw_describe_error(ret));
exit(1);
}
int enabled_channels = 0;
int num_channels = 0;
optind = 1;
while (1) {
int c = mygetopt(argc, argv);
if (c == -1) break;
if (!(c >> 4)) continue;
for (int channel = 0; channel < 4; channel++) {
if ((c & 0xf) != channel+1 && (c & 0xf) != 0) continue;
switch (c >> 4) {
case 1: // bw
ret = thunderscopehw_bandwidth_set(ts, channel, atoi(optarg));
if (ret != THUNDERSCOPEHW_STATUS_OK) {
fprintf(stderr, "Failed to set bandwidth. error =%s\n", thunderscopehw_describe_error(ret));
exit(1);
}
break;
case 2: // vdiv
ret = thunderscopehw_voltage_division_set(ts, channel, atoi(optarg));
if (ret != THUNDERSCOPEHW_STATUS_OK) {
fprintf(stderr, "Failed to set vdiv. error =%s\n", thunderscopehw_describe_error(ret));
exit(1);
}
break;
case 3: // voffset
ret = thunderscopehw_voltage_offset_set(ts, channel, atof(optarg));
if (ret != THUNDERSCOPEHW_STATUS_OK) {
fprintf(stderr, "Failed to set voffset. error =%s\n", thunderscopehw_describe_error(ret));
exit(1);
}
break;
case 4: // ac
ret = thunderscopehw_ac_couple(ts, channel);
if (ret != THUNDERSCOPEHW_STATUS_OK) {
fprintf(stderr, "Failed to set AC coupling. error =%s\n", thunderscopehw_describe_error(ret));
exit(1);
}
break;
case 5: // dc
ret = thunderscopehw_dc_couple(ts, channel);
if (ret != THUNDERSCOPEHW_STATUS_OK) {
fprintf(stderr, "Failed to set DC coupling. error =%s\n", thunderscopehw_describe_error(ret));
exit(1);
}
break;
}
if ((c >> 4) == 6 || (c & 0xf)) {
ret = thunderscopehw_enable_channel(ts, channel);
if (ret != THUNDERSCOPEHW_STATUS_OK) {
fprintf(stderr, "Failed to enable channel. error =%s\n", thunderscopehw_describe_error(ret));
exit(1);
}
if (!(enabled_channels & (1 << channel))) {
num_channels++;
enabled_channels |= 1 << channel;
}
}
}
}
if (!num_channels) {
fprintf(stderr, "No channels selected.\n");
exit(1);
}
if (samples <= 0) {
fprintf(stderr, "Must select number of samples.\n");
exit(1);
}
if (samples & 4095) {
fprintf(stderr, "Number of samples must be divisible by 4096\n");
exit(1);
}
FILE* outfile = stdout;
if (optind < argc) {
outfile = fopen(argv[optind], "wb");
if (!outfile) {
perror("open output file");
exit(1);
}
}
struct Fmt {
uint16_t pcm;
uint16_t channels;
uint32_t rate;
uint32_t byterate;
uint16_t block_align;
uint16_t bits_per_sample;
};
#ifdef WIN32
Sleep(500);
#else
usleep(500000);
#endif
struct Fmt fmt;
fmt.pcm = 1;
fmt.channels = num_channels;
if (samplerate) {
fmt.rate = samplerate;
} else {
fmt.rate = 1000000000 / fmt.channels;
}
fmt.byterate = 1000000000;
fmt.block_align = 0;
fmt.bits_per_sample = 8;
fwrite("RIFF", 4, 1, outfile);
write32(4ull +
16 + 8 + /* fmt */
samples * fmt.channels + 8 /* data */, outfile);
fwrite("WAVEfmt ", 8, 1, outfile);
write32(16, outfile);
fwrite(&fmt, 16, 1, outfile);
fwrite("data", 4, 1, outfile);
write32(samples * fmt.channels, outfile);
ret = thunderscopehw_start(ts);
if (ret != THUNDERSCOPEHW_STATUS_OK) {
fprintf(stderr, "Failed to start thunderscope, error=%d\n", ret);
exit(1);
}
#define BUFFER_SIZE samples
uint8_t* buffer;
#ifdef _WIN32
buffer = _aligned_malloc(BUFFER_SIZE, 4096);
#else
posix_memalign((void**)&buffer, 4096, BUFFER_SIZE);
#endif
while (samples) {
int64_t to_copy = samples;
if (to_copy > BUFFER_SIZE) to_copy = BUFFER_SIZE;
ret = thunderscopehw_read(ts, buffer, to_copy);
if (ret != THUNDERSCOPEHW_STATUS_OK) {
fprintf(stderr, "Thunderscope read error, error = %s\n", thunderscopehw_describe_error(ret));
exit(1);
}
// Convert signed output to unsigned output
for (size_t i = 0; i < BUFFER_SIZE; i++) {
buffer[i] += 0x80;
}
if (fwrite(buffer, 1, to_copy, outfile) != to_copy) {
perror("fwrite");
exit(1);
}
samples -= to_copy;
}
}
|
7799a660f480a0d5d570f6ab1e9f4ca852e93f6e
|
fd016aacb50a65dbda2f0e2b35cec38a63baf68d
|
/targets/ChibiOS/ORGPAL_PALTHREE/target_system_io_ports_config.h
|
28c69cb60cc443e988d50cb8038041926176cc2a
|
[
"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
| 544
|
h
|
target_system_io_ports_config.h
|
//
// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
///////////
// UART2 //
///////////
// enable USART2
#define NF_SERIAL_COMM_STM32_UART_USE_USART2 TRUE
///////////
// UART3 //
///////////
// enable USART3
#define NF_SERIAL_COMM_STM32_UART_USE_USART3 TRUE
///////////
// UART6 //
///////////
// enable USART6
#define NF_SERIAL_COMM_STM32_UART_USE_USART6 TRUE
///////////
// UART7 //
///////////
// enable UART7
#define NF_SERIAL_COMM_STM32_UART_USE_UART7 TRUE
|
4d4b629ac68c53714a64b56a6a60ee2dcb4124cc
|
b4d452fe6df9ba0b3b49e0e6e9569b2c7ba26cfb
|
/tl/codec/model.c
|
d7a92f902596aa573f30444f2a301466b07c7c32
|
[] |
no_license
|
gliptic/liero
|
a798707d184593a4544fa2137983e36c9d76cd8d
|
a1a292e3ef46d31ef8475cbc255846e5e26ba5cb
|
refs/heads/master
| 2023-01-04T22:16:56.544448
| 2022-10-17T21:23:19
| 2022-10-17T21:23:19
| 21,991,791
| 224
| 45
| null | 2022-12-29T16:12:29
| 2014-07-18T19:26:21
|
C
|
UTF-8
|
C
| false
| false
| 257
|
c
|
model.c
|
#include "model.h"
#include <string.h>
void tl_model_init_(tl_model* self, int size, int n)
{
int i;
memset(self, 0, size);
for(i = 0; i < n; ++i)
{
self->symbols[i].freq = 1;
}
self->sum = n;
self->symbols[n].freq = 0xffffffff;
self->n = n;
}
|
dde534e4dc9ef4d014d3aaef999bd669275519dd
|
83b8b30ebb633eecd29ca0a7a20cc43a293c9333
|
/shared-bindings/vectorio/VectorShape.c
|
e5c806b94376a4896df99c269fb228cd97f830d2
|
[
"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
| 12,290
|
c
|
VectorShape.c
|
#include "shared-module/vectorio/__init__.h"
#include "shared-bindings/vectorio/VectorShape.h"
#include "shared-bindings/vectorio/Circle.h"
#include "shared-bindings/vectorio/Polygon.h"
#include "shared-bindings/vectorio/Rectangle.h"
#include "shared-bindings/displayio/ColorConverter.h"
#include "shared-bindings/displayio/Palette.h"
#include <stdint.h>
#include "shared/runtime/context_manager_helpers.h"
#include "py/binary.h"
#include "py/objproperty.h"
#include "py/objtype.h"
#include "py/runtime.h"
#include "supervisor/shared/translate/translate.h"
// shape: The shape implementation to draw.
// pixel_shader: The pixel shader that produces colors from values. The shader can be a displayio.Palette(1); it will be asked to color pixel value 0.
// x: Initial x position of the center axis of the shape within the parent.
// y: Initial y position of the center axis of the shape within the parent."""
mp_obj_t vectorio_vector_shape_make_new(const mp_obj_t shape, const mp_obj_t pixel_shader, int32_t x, int32_t y) {
if (!mp_obj_is_type(pixel_shader, &displayio_colorconverter_type) &&
!mp_obj_is_type(pixel_shader, &displayio_palette_type)) {
mp_raise_TypeError_varg(translate("unsupported %q type"), MP_QSTR_pixel_shader);
}
vectorio_ishape_t ishape;
// Wire up shape functions
if (mp_obj_is_type(shape, &vectorio_polygon_type)) {
ishape.shape = shape;
ishape.get_area = &common_hal_vectorio_polygon_get_area;
ishape.get_pixel = &common_hal_vectorio_polygon_get_pixel;
} else if (mp_obj_is_type(shape, &vectorio_rectangle_type)) {
ishape.shape = shape;
ishape.get_area = &common_hal_vectorio_rectangle_get_area;
ishape.get_pixel = &common_hal_vectorio_rectangle_get_pixel;
} else if (mp_obj_is_type(shape, &vectorio_circle_type)) {
ishape.shape = shape;
ishape.get_area = &common_hal_vectorio_circle_get_area;
ishape.get_pixel = &common_hal_vectorio_circle_get_pixel;
} else {
mp_raise_TypeError_varg(translate("unsupported %q type"), MP_QSTR_shape);
}
vectorio_vector_shape_t *self = m_new_obj(vectorio_vector_shape_t);
self->base.type = &vectorio_vector_shape_type;
common_hal_vectorio_vector_shape_construct(self,
ishape, pixel_shader, x, y
);
// Wire up event callbacks
vectorio_event_t on_dirty = {
.obj = self,
.event = &common_hal_vectorio_vector_shape_set_dirty
};
if (mp_obj_is_type(shape, &vectorio_polygon_type)) {
common_hal_vectorio_polygon_set_on_dirty(self->ishape.shape, on_dirty);
} else if (mp_obj_is_type(shape, &vectorio_rectangle_type)) {
common_hal_vectorio_rectangle_set_on_dirty(self->ishape.shape, on_dirty);
} else if (mp_obj_is_type(shape, &vectorio_circle_type)) {
common_hal_vectorio_circle_set_on_dirty(self->ishape.shape, on_dirty);
} else {
mp_raise_TypeError_varg(translate("unsupported %q type"), MP_QSTR_shape);
}
return MP_OBJ_FROM_PTR(self);
}
vectorio_draw_protocol_impl_t vectorio_vector_shape_draw_protocol_impl = {
.draw_fill_area = (draw_fill_area_fun)vectorio_vector_shape_fill_area,
.draw_get_dirty_area = (draw_get_dirty_area_fun)vectorio_vector_shape_get_dirty_area,
.draw_update_transform = (draw_update_transform_fun)vectorio_vector_shape_update_transform,
.draw_finish_refresh = (draw_finish_refresh_fun)vectorio_vector_shape_finish_refresh,
.draw_get_refresh_areas = (draw_get_refresh_areas_fun)vectorio_vector_shape_get_refresh_areas,
.draw_set_dirty = (draw_set_dirty_fun)common_hal_vectorio_vector_shape_set_dirty,
};
// Stub checker does not approve of these shared properties.
// x: int
// y: int
// """true if x,y lies inside the shape."""
//
STATIC mp_obj_t vectorio_vector_shape_obj_contains(mp_obj_t wrapper_shape, mp_obj_t x_obj, mp_obj_t y_obj) {
// Relies on the fact that only vector_shape impl gets matched with a VectorShape.
const vectorio_draw_protocol_t *draw_protocol = mp_proto_get(MP_QSTR_protocol_draw, wrapper_shape);
vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(draw_protocol->draw_get_protocol_self(wrapper_shape));
mp_int_t x = mp_obj_get_int(x_obj);
mp_int_t y = mp_obj_get_int(y_obj);
return mp_obj_new_bool(common_hal_vectorio_vector_shape_contains(self, x, y));
}
MP_DEFINE_CONST_FUN_OBJ_3(vectorio_vector_shape_contains_obj, vectorio_vector_shape_obj_contains);
// Stub checker does not approve of these shared properties.
// x: int
// """X position of the center point of the shape in the parent."""
//
STATIC mp_obj_t vectorio_vector_shape_obj_get_x(mp_obj_t wrapper_shape) {
// Relies on the fact that only vector_shape impl gets matched with a VectorShape.
const vectorio_draw_protocol_t *draw_protocol = mp_proto_get(MP_QSTR_protocol_draw, wrapper_shape);
vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(draw_protocol->draw_get_protocol_self(wrapper_shape));
return MP_OBJ_NEW_SMALL_INT(common_hal_vectorio_vector_shape_get_x(self));
}
MP_DEFINE_CONST_FUN_OBJ_1(vectorio_vector_shape_get_x_obj, vectorio_vector_shape_obj_get_x);
STATIC mp_obj_t vectorio_vector_shape_obj_set_x(mp_obj_t wrapper_shape, mp_obj_t x_obj) {
// Relies on the fact that only vector_shape impl gets matched with a VectorShape.
const vectorio_draw_protocol_t *draw_protocol = mp_proto_get(MP_QSTR_protocol_draw, wrapper_shape);
vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(draw_protocol->draw_get_protocol_self(wrapper_shape));
mp_int_t x = mp_obj_get_int(x_obj);
common_hal_vectorio_vector_shape_set_x(self, x);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_2(vectorio_vector_shape_set_x_obj, vectorio_vector_shape_obj_set_x);
MP_PROPERTY_GETSET(vectorio_vector_shape_x_obj,
(mp_obj_t)&vectorio_vector_shape_get_x_obj,
(mp_obj_t)&vectorio_vector_shape_set_x_obj);
// y: int
// """Y position of the center point of the shape in the parent."""
//
STATIC mp_obj_t vectorio_vector_shape_obj_get_y(mp_obj_t wrapper_shape) {
// Relies on the fact that only vector_shape impl gets matched with a VectorShape.
const vectorio_draw_protocol_t *draw_protocol = mp_proto_get(MP_QSTR_protocol_draw, wrapper_shape);
vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(draw_protocol->draw_get_protocol_self(wrapper_shape));
return MP_OBJ_NEW_SMALL_INT(common_hal_vectorio_vector_shape_get_y(self));
}
MP_DEFINE_CONST_FUN_OBJ_1(vectorio_vector_shape_get_y_obj, vectorio_vector_shape_obj_get_y);
STATIC mp_obj_t vectorio_vector_shape_obj_set_y(mp_obj_t wrapper_shape, mp_obj_t y_obj) {
// Relies on the fact that only vector_shape impl gets matched with a VectorShape.
const vectorio_draw_protocol_t *draw_protocol = mp_proto_get(MP_QSTR_protocol_draw, wrapper_shape);
vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(draw_protocol->draw_get_protocol_self(wrapper_shape));
mp_int_t y = mp_obj_get_int(y_obj);
common_hal_vectorio_vector_shape_set_y(self, y);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_2(vectorio_vector_shape_set_y_obj, vectorio_vector_shape_obj_set_y);
MP_PROPERTY_GETSET(vectorio_vector_shape_y_obj,
(mp_obj_t)&vectorio_vector_shape_get_y_obj,
(mp_obj_t)&vectorio_vector_shape_set_y_obj);
// location: Tuple[int, int]
// """location of the center point of the shape in the parent."""
//
STATIC mp_obj_t vectorio_vector_shape_obj_get_location(mp_obj_t wrapper_shape) {
// Relies on the fact that only vector_shape impl gets matched with a VectorShape.
const vectorio_draw_protocol_t *draw_protocol = mp_proto_get(MP_QSTR_protocol_draw, wrapper_shape);
vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(draw_protocol->draw_get_protocol_self(wrapper_shape));
return MP_OBJ_TO_PTR(common_hal_vectorio_vector_shape_get_location(self));
}
MP_DEFINE_CONST_FUN_OBJ_1(vectorio_vector_shape_get_location_obj, vectorio_vector_shape_obj_get_location);
STATIC mp_obj_t vectorio_vector_shape_obj_set_location(mp_obj_t wrapper_shape, mp_obj_t location_obj) {
// Relies on the fact that only vector_shape impl gets matched with a VectorShape.
const vectorio_draw_protocol_t *draw_protocol = mp_proto_get(MP_QSTR_protocol_draw, wrapper_shape);
vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(draw_protocol->draw_get_protocol_self(wrapper_shape));
common_hal_vectorio_vector_shape_set_location(self, location_obj);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_2(vectorio_vector_shape_set_location_obj, vectorio_vector_shape_obj_set_location);
MP_PROPERTY_GETSET(vectorio_vector_shape_location_obj,
(mp_obj_t)&vectorio_vector_shape_get_location_obj,
(mp_obj_t)&vectorio_vector_shape_set_location_obj);
// Stub checker does not approve of these shared properties.
// hidden: bool
// """Hide the shape or not."""
//
STATIC mp_obj_t vectorio_vector_shape_obj_get_hidden(mp_obj_t wrapper_shape) {
// Relies on the fact that only vector_shape impl gets matched with a VectorShape.
const vectorio_draw_protocol_t *draw_protocol = mp_proto_get(MP_QSTR_protocol_draw, wrapper_shape);
vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(draw_protocol->draw_get_protocol_self(wrapper_shape));
return mp_obj_new_bool(common_hal_vectorio_vector_shape_get_hidden(self));
}
MP_DEFINE_CONST_FUN_OBJ_1(vectorio_vector_shape_get_hidden_obj, vectorio_vector_shape_obj_get_hidden);
STATIC mp_obj_t vectorio_vector_shape_obj_set_hidden(mp_obj_t wrapper_shape, mp_obj_t hidden_obj) {
// Relies on the fact that only vector_shape impl gets matched with a VectorShape.
const vectorio_draw_protocol_t *draw_protocol = mp_proto_get(MP_QSTR_protocol_draw, wrapper_shape);
vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(draw_protocol->draw_get_protocol_self(wrapper_shape));
common_hal_vectorio_vector_shape_set_hidden(self, mp_obj_is_true(hidden_obj));
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_2(vectorio_vector_shape_set_hidden_obj, vectorio_vector_shape_obj_set_hidden);
MP_PROPERTY_GETSET(vectorio_vector_shape_hidden_obj,
(mp_obj_t)&vectorio_vector_shape_get_hidden_obj,
(mp_obj_t)&vectorio_vector_shape_set_hidden_obj);
// pixel_shader: Union[ColorConverter, Palette]
// """The pixel shader of the shape."""
//
STATIC mp_obj_t vectorio_vector_shape_obj_get_pixel_shader(mp_obj_t wrapper_shape) {
// Relies on the fact that only vector_shape impl gets matched with a VectorShape.
const vectorio_draw_protocol_t *draw_protocol = mp_proto_get(MP_QSTR_protocol_draw, wrapper_shape);
vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(draw_protocol->draw_get_protocol_self(wrapper_shape));
return common_hal_vectorio_vector_shape_get_pixel_shader(self);
}
MP_DEFINE_CONST_FUN_OBJ_1(vectorio_vector_shape_get_pixel_shader_obj, vectorio_vector_shape_obj_get_pixel_shader);
STATIC mp_obj_t vectorio_vector_shape_obj_set_pixel_shader(mp_obj_t wrapper_shape, mp_obj_t pixel_shader) {
// Relies on the fact that only vector_shape impl gets matched with a VectorShape.
const vectorio_draw_protocol_t *draw_protocol = mp_proto_get(MP_QSTR_protocol_draw, wrapper_shape);
vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(draw_protocol->draw_get_protocol_self(wrapper_shape));
if (!mp_obj_is_type(pixel_shader, &displayio_palette_type) && !mp_obj_is_type(pixel_shader, &displayio_colorconverter_type)) {
mp_raise_TypeError(translate("pixel_shader must be displayio.Palette or displayio.ColorConverter"));
}
common_hal_vectorio_vector_shape_set_pixel_shader(self, pixel_shader);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_2(vectorio_vector_shape_set_pixel_shader_obj, vectorio_vector_shape_obj_set_pixel_shader);
MP_PROPERTY_GETSET(vectorio_vector_shape_pixel_shader_obj,
(mp_obj_t)&vectorio_vector_shape_get_pixel_shader_obj,
(mp_obj_t)&vectorio_vector_shape_set_pixel_shader_obj);
STATIC const mp_rom_map_elem_t vectorio_vector_shape_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(vectorio_vector_shape_locals_dict, vectorio_vector_shape_locals_dict_table);
const mp_obj_type_t vectorio_vector_shape_type = {
{ &mp_type_type },
.name = MP_QSTR_VectorShape,
.locals_dict = (mp_obj_dict_t *)&vectorio_vector_shape_locals_dict,
};
|
b6afedbc4e8a0c8d71ef2bfb13565e9ff328a4ad
|
58fe7cb3949dd1930e709696659a0296500b64a6
|
/tls/s2n_tls13_certificate_verify.c
|
f8babab4c7b0fcacf22ea46117e23ff7579d7ffa
|
[
"Apache-2.0",
"MIT"
] |
permissive
|
aws/s2n-tls
|
3344638a6a69c6f20665cf6847e1bc4b85f2e558
|
62dc7a6d4876e5eee0dea3690d528a4c7080a1d5
|
refs/heads/main
| 2023-08-31T23:26:33.780048
| 2023-08-31T05:17:33
| 2023-08-31T05:17:33
| 21,287,076
| 513
| 213
|
Apache-2.0
| 2023-09-13T23:52:29
| 2014-06-27T19:37:59
|
C
|
UTF-8
|
C
| false
| false
| 9,137
|
c
|
s2n_tls13_certificate_verify.c
|
/*
* Copyright Amazon.com, Inc. or its affiliates. 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.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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 "tls/s2n_tls13_certificate_verify.h"
#include <stdint.h>
#include "crypto/s2n_hash.h"
#include "error/s2n_errno.h"
#include "stuffer/s2n_stuffer.h"
#include "tls/s2n_async_pkey.h"
#include "tls/s2n_connection.h"
#include "tls/s2n_tls13_handshake.h"
#include "utils/s2n_safety.h"
/**
* Specified in https://tools.ietf.org/html/rfc8446#section-4.4.3
*
* Servers MUST send this message when authenticating via a certificate.
* Clients MUST send this message whenever authenticating via a certificate.
* When sent, this message MUST appear immediately after the Certificate
* message and immediately prior to the Finished message.
**/
/* 64 'space' characters (0x20) */
const uint8_t S2N_CERT_VERIFY_PREFIX[] = { 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 };
/* 'TLS 1.3, server CertificateVerify' with 0x00 separator */
const uint8_t S2N_SERVER_CERT_VERIFY_CONTEXT[] = { 0x54, 0x4c, 0x53, 0x20, 0x31, 0x2e, 0x33,
0x2c, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69,
0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x00 };
/* 'TLS 1.3, client CertificateVerify' with 0x00 separator */
const uint8_t S2N_CLIENT_CERT_VERIFY_CONTEXT[] = { 0x54, 0x4c, 0x53, 0x20, 0x31, 0x2e, 0x33,
0x2c, 0x20, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69,
0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x00 };
static int s2n_tls13_write_cert_verify_signature(struct s2n_connection *conn,
struct s2n_signature_scheme *chosen_sig_scheme);
static int s2n_tls13_write_signature(struct s2n_connection *conn, struct s2n_blob *signature);
static int s2n_tls13_generate_unsigned_cert_verify_content(struct s2n_connection *conn,
struct s2n_stuffer *unsigned_content, s2n_mode mode);
static int s2n_tls13_cert_read_and_verify_signature(struct s2n_connection *conn,
struct s2n_signature_scheme *chosen_sig_scheme);
static uint8_t s2n_tls13_cert_verify_header_length(s2n_mode mode);
int s2n_tls13_cert_verify_send(struct s2n_connection *conn)
{
S2N_ASYNC_PKEY_GUARD(conn);
if (conn->mode == S2N_SERVER) {
/* Write digital signature */
POSIX_GUARD(s2n_tls13_write_cert_verify_signature(conn, &conn->handshake_params.conn_sig_scheme));
} else {
/* Write digital signature */
POSIX_GUARD(s2n_tls13_write_cert_verify_signature(conn, &conn->handshake_params.client_cert_sig_scheme));
}
return 0;
}
int s2n_tls13_write_cert_verify_signature(struct s2n_connection *conn, struct s2n_signature_scheme *chosen_sig_scheme)
{
POSIX_ENSURE_REF(conn->handshake_params.our_chain_and_key);
/* Write the SignatureScheme out */
struct s2n_stuffer *out = &conn->handshake.io;
POSIX_GUARD(s2n_stuffer_write_uint16(out, chosen_sig_scheme->iana_value));
DEFER_CLEANUP(struct s2n_hash_state message_hash = { 0 }, s2n_hash_free);
POSIX_GUARD(s2n_hash_new(&message_hash));
POSIX_GUARD(s2n_hash_init(&message_hash, chosen_sig_scheme->hash_alg));
DEFER_CLEANUP(struct s2n_stuffer unsigned_content = { 0 }, s2n_stuffer_free);
POSIX_GUARD(s2n_tls13_generate_unsigned_cert_verify_content(conn, &unsigned_content, conn->mode));
POSIX_GUARD(s2n_hash_update(&message_hash, unsigned_content.blob.data,
s2n_stuffer_data_available(&unsigned_content)));
S2N_ASYNC_PKEY_SIGN(conn, chosen_sig_scheme->sig_alg, &message_hash, s2n_tls13_write_signature);
}
int s2n_tls13_write_signature(struct s2n_connection *conn, struct s2n_blob *signature)
{
struct s2n_stuffer *out = &conn->handshake.io;
POSIX_GUARD(s2n_stuffer_write_uint16(out, signature->size));
POSIX_GUARD(s2n_stuffer_write_bytes(out, signature->data, signature->size));
return 0;
}
int s2n_tls13_generate_unsigned_cert_verify_content(struct s2n_connection *conn,
struct s2n_stuffer *unsigned_content, s2n_mode mode)
{
s2n_tls13_connection_keys(tls13_ctx, conn);
uint8_t hash_digest_length = tls13_ctx.size;
uint8_t digest_out[S2N_MAX_DIGEST_LEN];
/* Get current handshake hash */
POSIX_ENSURE_REF(conn->handshake.hashes);
struct s2n_hash_state *hash_state = &conn->handshake.hashes->hash_workspace;
POSIX_GUARD_RESULT(s2n_handshake_copy_hash_state(conn, tls13_ctx.hash_algorithm, hash_state));
POSIX_GUARD(s2n_hash_digest(hash_state, digest_out, hash_digest_length));
/* Concatenate the content to be signed/verified */
POSIX_GUARD(s2n_stuffer_alloc(unsigned_content, hash_digest_length + s2n_tls13_cert_verify_header_length(mode)));
POSIX_GUARD(s2n_stuffer_write_bytes(unsigned_content, S2N_CERT_VERIFY_PREFIX, sizeof(S2N_CERT_VERIFY_PREFIX)));
if (mode == S2N_CLIENT) {
POSIX_GUARD(s2n_stuffer_write_bytes(unsigned_content, S2N_CLIENT_CERT_VERIFY_CONTEXT,
sizeof(S2N_CLIENT_CERT_VERIFY_CONTEXT)));
} else {
POSIX_GUARD(s2n_stuffer_write_bytes(unsigned_content, S2N_SERVER_CERT_VERIFY_CONTEXT,
sizeof(S2N_SERVER_CERT_VERIFY_CONTEXT)));
}
POSIX_GUARD(s2n_stuffer_write_bytes(unsigned_content, digest_out, hash_digest_length));
return 0;
}
uint8_t s2n_tls13_cert_verify_header_length(s2n_mode mode)
{
if (mode == S2N_CLIENT) {
return sizeof(S2N_CERT_VERIFY_PREFIX) + sizeof(S2N_CLIENT_CERT_VERIFY_CONTEXT);
}
return sizeof(S2N_CERT_VERIFY_PREFIX) + sizeof(S2N_SERVER_CERT_VERIFY_CONTEXT);
}
int s2n_tls13_cert_verify_recv(struct s2n_connection *conn)
{
if (conn->mode == S2N_SERVER) {
/* Read the algorithm and update sig_scheme */
POSIX_GUARD(s2n_get_and_validate_negotiated_signature_scheme(conn, &conn->handshake.io,
&conn->handshake_params.client_cert_sig_scheme));
/* Read the rest of the signature and verify */
POSIX_GUARD(s2n_tls13_cert_read_and_verify_signature(conn,
&conn->handshake_params.client_cert_sig_scheme));
} else {
/* Read the algorithm and update sig_scheme */
POSIX_GUARD(s2n_get_and_validate_negotiated_signature_scheme(conn, &conn->handshake.io,
&conn->handshake_params.conn_sig_scheme));
/* Read the rest of the signature and verify */
POSIX_GUARD(s2n_tls13_cert_read_and_verify_signature(conn, &conn->handshake_params.conn_sig_scheme));
}
return 0;
}
int s2n_tls13_cert_read_and_verify_signature(struct s2n_connection *conn,
struct s2n_signature_scheme *chosen_sig_scheme)
{
struct s2n_stuffer *in = &conn->handshake.io;
DEFER_CLEANUP(struct s2n_blob signed_content = { 0 }, s2n_free);
DEFER_CLEANUP(struct s2n_stuffer unsigned_content = { 0 }, s2n_stuffer_free);
DEFER_CLEANUP(struct s2n_hash_state message_hash = { 0 }, s2n_hash_free);
POSIX_GUARD(s2n_hash_new(&message_hash));
/* Get signature size */
uint16_t signature_size;
POSIX_GUARD(s2n_stuffer_read_uint16(in, &signature_size));
S2N_ERROR_IF(signature_size > s2n_stuffer_data_available(in), S2N_ERR_BAD_MESSAGE);
/* Get wire signature */
POSIX_GUARD(s2n_alloc(&signed_content, signature_size));
signed_content.size = signature_size;
POSIX_GUARD(s2n_stuffer_read_bytes(in, signed_content.data, signature_size));
/* Verify signature. We send the opposite mode as we are trying to verify what was sent to us */
if (conn->mode == S2N_CLIENT) {
POSIX_GUARD(s2n_tls13_generate_unsigned_cert_verify_content(conn, &unsigned_content, S2N_SERVER));
} else {
POSIX_GUARD(s2n_tls13_generate_unsigned_cert_verify_content(conn, &unsigned_content, S2N_CLIENT));
}
POSIX_GUARD(s2n_hash_init(&message_hash, chosen_sig_scheme->hash_alg));
POSIX_GUARD(s2n_hash_update(&message_hash, unsigned_content.blob.data,
s2n_stuffer_data_available(&unsigned_content)));
if (conn->mode == S2N_CLIENT) {
POSIX_GUARD(s2n_pkey_verify(&conn->handshake_params.server_public_key, chosen_sig_scheme->sig_alg,
&message_hash, &signed_content));
} else {
POSIX_GUARD(s2n_pkey_verify(&conn->handshake_params.client_public_key, chosen_sig_scheme->sig_alg,
&message_hash, &signed_content));
}
return 0;
}
|
f2e499f81040ae99fcf9a512d06f6a6919eb8fff
|
7f6c235b0598353549959c18f69eefd20b766907
|
/src/sccz80/lex.c
|
a5c00ad2ee363c17daec7c60a2e477ccae9f04f5
|
[
"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
| 2,650
|
c
|
lex.c
|
/*
/ Small C+ Compiler
*
* Lexical routines - string matching etc
*
* $Id: lex.c,v 1.3 2007-07-19 18:42:37 dom Exp $
*/
#include "ccdefs.h"
int streq(char str1[], char str2[])
{
int k;
k = 0;
while (*str2) {
if ((*str1++) != (*str2++))
return 0;
++k;
}
return k;
}
/*
* compare strings
* match only if we reach end of both strings or if, at end of one of the
* strings, the other one has reached a non-alphanumeric character
* (so that, for example, astreq("if", "ifline") is not a match)
*/
int astreq(char* str1, char* str2)
{
int k;
k = 0;
while (*str1 && *str2) {
if (*str1 != *str2)
break;
++str1;
++str2;
++k;
}
if (an(*str1) || an(*str2))
return 0;
return k;
}
int match(char* lit)
{
int k,i;
blanks();
if ((k = streq(line + lptr, lit))) {
for ( i = 0; i < buffer_fps_num; i++ )
fprintf(buffer_fps[i],"%s",lit);
lptr += k;
return 1;
}
return 0;
}
int cmatch(char lit)
{
int i;
blanks();
if (eof)
errorfmt("Unexpected end of file", 1);
if (toupper(line[lptr]) == toupper(lit)) {
for ( i = 0; i < buffer_fps_num; i++ ) {
fprintf(buffer_fps[i],"%c",line[lptr]);
}
++lptr;
return 1;
}
return 0;
}
/* Get the next character, don't skip spaces */
int acmatch(char lit)
{
int i;
if (eof)
errorfmt("Unexpected end of file", 1);
if (line[lptr] == lit) {
for ( i = 0; i < buffer_fps_num; i++ )
fprintf(buffer_fps[i],"%c",line[lptr]);
++lptr;
return 1;
}
return 0;
}
int checkws(void)
{
return isspace( *(line+lptr));
}
int rmatch2(char* lit)
{
int k;
blanks();
if ((k = streq(line + lptr, lit)))
return 1;
return 0;
}
/*
* djm, reversible character match (case insensitive)
*/
int rcmatch(char lit)
{
blanks();
if (eof)
errorfmt("Unexpected end of file", 1);
if (toupper(line[lptr]) == toupper(lit)) {
return 1;
}
return 0;
}
int amatch_impl(char* lit,int buffer)
{
int k;
blanks();
if ((k = astreq(line + lptr, lit))) {
lptr += k;
if ( buffer ) {
for ( k = 0; k < buffer_fps_num; k++ ) {
fprintf(buffer_fps[k],"%s",lit);
}
}
return 1;
}
return 0;
}
int amatch(char* lit)
{
return amatch_impl(lit,1);
}
/*
* Consume unecessary identifiers (if present)
*/
int swallow(char* lit)
{
return amatch_impl(lit,0);
}
|
f88324eb36dec1f8579a56f5e446475ced59b52d
|
6990e821e521b2314a8f747f934281077aa33160
|
/libckteec/src/ck_debug.c
|
49a50154fd708c18d6726e1c26a38d17ac6f3967
|
[
"BSD-2-Clause"
] |
permissive
|
OP-TEE/optee_client
|
d325892e6f071fabb278cc2a2c5003ab47b98958
|
8533e0e6329840ee96cf81b6453f257204227e6c
|
refs/heads/master
| 2023-06-01T08:33:07.127997
| 2023-03-09T15:48:15
| 2023-03-20T09:52:16
| 19,610,475
| 168
| 230
|
NOASSERTION
| 2023-08-26T12:23:00
| 2014-05-09T12:33:33
|
C
|
UTF-8
|
C
| false
| false
| 13,909
|
c
|
ck_debug.c
|
// SPDX-License-Identifier: BSD-2-Clause
/*
* Copyright (c) 2017-2020, Linaro Limited
*/
#include <ck_debug.h>
#include <pkcs11.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "local_utils.h"
#define CK2STR_ENTRY(id) case id: return #id
const char *ckr2str(CK_RV id)
{
switch (id) {
CK2STR_ENTRY(CKR_OK);
CK2STR_ENTRY(CKR_CANCEL);
CK2STR_ENTRY(CKR_HOST_MEMORY);
CK2STR_ENTRY(CKR_SLOT_ID_INVALID);
CK2STR_ENTRY(CKR_GENERAL_ERROR);
CK2STR_ENTRY(CKR_FUNCTION_FAILED);
CK2STR_ENTRY(CKR_ARGUMENTS_BAD);
CK2STR_ENTRY(CKR_NO_EVENT);
CK2STR_ENTRY(CKR_NEED_TO_CREATE_THREADS);
CK2STR_ENTRY(CKR_CANT_LOCK);
CK2STR_ENTRY(CKR_ATTRIBUTE_READ_ONLY);
CK2STR_ENTRY(CKR_ATTRIBUTE_SENSITIVE);
CK2STR_ENTRY(CKR_ATTRIBUTE_TYPE_INVALID);
CK2STR_ENTRY(CKR_ATTRIBUTE_VALUE_INVALID);
CK2STR_ENTRY(CKR_ACTION_PROHIBITED);
CK2STR_ENTRY(CKR_DATA_INVALID);
CK2STR_ENTRY(CKR_DATA_LEN_RANGE);
CK2STR_ENTRY(CKR_DEVICE_ERROR);
CK2STR_ENTRY(CKR_DEVICE_MEMORY);
CK2STR_ENTRY(CKR_DEVICE_REMOVED);
CK2STR_ENTRY(CKR_ENCRYPTED_DATA_INVALID);
CK2STR_ENTRY(CKR_ENCRYPTED_DATA_LEN_RANGE);
CK2STR_ENTRY(CKR_FUNCTION_CANCELED);
CK2STR_ENTRY(CKR_FUNCTION_NOT_PARALLEL);
CK2STR_ENTRY(CKR_FUNCTION_NOT_SUPPORTED);
CK2STR_ENTRY(CKR_KEY_HANDLE_INVALID);
CK2STR_ENTRY(CKR_KEY_SIZE_RANGE);
CK2STR_ENTRY(CKR_KEY_TYPE_INCONSISTENT);
CK2STR_ENTRY(CKR_KEY_NOT_NEEDED);
CK2STR_ENTRY(CKR_KEY_CHANGED);
CK2STR_ENTRY(CKR_KEY_NEEDED);
CK2STR_ENTRY(CKR_KEY_INDIGESTIBLE);
CK2STR_ENTRY(CKR_KEY_FUNCTION_NOT_PERMITTED);
CK2STR_ENTRY(CKR_KEY_NOT_WRAPPABLE);
CK2STR_ENTRY(CKR_KEY_UNEXTRACTABLE);
CK2STR_ENTRY(CKR_MECHANISM_INVALID);
CK2STR_ENTRY(CKR_MECHANISM_PARAM_INVALID);
CK2STR_ENTRY(CKR_OBJECT_HANDLE_INVALID);
CK2STR_ENTRY(CKR_OPERATION_ACTIVE);
CK2STR_ENTRY(CKR_OPERATION_NOT_INITIALIZED);
CK2STR_ENTRY(CKR_PIN_INCORRECT);
CK2STR_ENTRY(CKR_PIN_INVALID);
CK2STR_ENTRY(CKR_PIN_LEN_RANGE);
CK2STR_ENTRY(CKR_PIN_EXPIRED);
CK2STR_ENTRY(CKR_PIN_LOCKED);
CK2STR_ENTRY(CKR_SESSION_CLOSED);
CK2STR_ENTRY(CKR_SESSION_COUNT);
CK2STR_ENTRY(CKR_SESSION_HANDLE_INVALID);
CK2STR_ENTRY(CKR_SESSION_PARALLEL_NOT_SUPPORTED);
CK2STR_ENTRY(CKR_SESSION_READ_ONLY);
CK2STR_ENTRY(CKR_SESSION_EXISTS);
CK2STR_ENTRY(CKR_SESSION_READ_ONLY_EXISTS);
CK2STR_ENTRY(CKR_SESSION_READ_WRITE_SO_EXISTS);
CK2STR_ENTRY(CKR_SIGNATURE_INVALID);
CK2STR_ENTRY(CKR_SIGNATURE_LEN_RANGE);
CK2STR_ENTRY(CKR_TEMPLATE_INCOMPLETE);
CK2STR_ENTRY(CKR_TEMPLATE_INCONSISTENT);
CK2STR_ENTRY(CKR_TOKEN_NOT_PRESENT);
CK2STR_ENTRY(CKR_TOKEN_NOT_RECOGNIZED);
CK2STR_ENTRY(CKR_TOKEN_WRITE_PROTECTED);
CK2STR_ENTRY(CKR_UNWRAPPING_KEY_HANDLE_INVALID);
CK2STR_ENTRY(CKR_UNWRAPPING_KEY_SIZE_RANGE);
CK2STR_ENTRY(CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT);
CK2STR_ENTRY(CKR_USER_ALREADY_LOGGED_IN);
CK2STR_ENTRY(CKR_USER_NOT_LOGGED_IN);
CK2STR_ENTRY(CKR_USER_PIN_NOT_INITIALIZED);
CK2STR_ENTRY(CKR_USER_TYPE_INVALID);
CK2STR_ENTRY(CKR_USER_ANOTHER_ALREADY_LOGGED_IN);
CK2STR_ENTRY(CKR_USER_TOO_MANY_TYPES);
CK2STR_ENTRY(CKR_WRAPPED_KEY_INVALID);
CK2STR_ENTRY(CKR_WRAPPED_KEY_LEN_RANGE);
CK2STR_ENTRY(CKR_WRAPPING_KEY_HANDLE_INVALID);
CK2STR_ENTRY(CKR_WRAPPING_KEY_SIZE_RANGE);
CK2STR_ENTRY(CKR_WRAPPING_KEY_TYPE_INCONSISTENT);
CK2STR_ENTRY(CKR_RANDOM_SEED_NOT_SUPPORTED);
CK2STR_ENTRY(CKR_RANDOM_NO_RNG);
CK2STR_ENTRY(CKR_DOMAIN_PARAMS_INVALID);
CK2STR_ENTRY(CKR_CURVE_NOT_SUPPORTED);
CK2STR_ENTRY(CKR_BUFFER_TOO_SMALL);
CK2STR_ENTRY(CKR_SAVED_STATE_INVALID);
CK2STR_ENTRY(CKR_INFORMATION_SENSITIVE);
CK2STR_ENTRY(CKR_STATE_UNSAVEABLE);
CK2STR_ENTRY(CKR_CRYPTOKI_NOT_INITIALIZED);
CK2STR_ENTRY(CKR_CRYPTOKI_ALREADY_INITIALIZED);
CK2STR_ENTRY(CKR_MUTEX_BAD);
CK2STR_ENTRY(CKR_MUTEX_NOT_LOCKED);
CK2STR_ENTRY(CKR_NEW_PIN_MODE);
CK2STR_ENTRY(CKR_NEXT_OTP);
CK2STR_ENTRY(CKR_EXCEEDED_MAX_ITERATIONS);
CK2STR_ENTRY(CKR_FIPS_SELF_TEST_FAILED);
CK2STR_ENTRY(CKR_LIBRARY_LOAD_FAILED);
CK2STR_ENTRY(CKR_PIN_TOO_WEAK);
CK2STR_ENTRY(CKR_PUBLIC_KEY_INVALID);
CK2STR_ENTRY(CKR_FUNCTION_REJECTED);
default:
if (id & CKR_VENDOR_DEFINED)
return "Vendor defined";
else
return "Unknown ID";
}
}
const char *ckm2str(CK_MECHANISM_TYPE id)
{
switch (id) {
CK2STR_ENTRY(CKM_RSA_PKCS_KEY_PAIR_GEN);
CK2STR_ENTRY(CKM_RSA_PKCS);
CK2STR_ENTRY(CKM_RSA_9796);
CK2STR_ENTRY(CKM_RSA_X_509);
CK2STR_ENTRY(CKM_MD5_RSA_PKCS);
CK2STR_ENTRY(CKM_SHA1_RSA_PKCS);
CK2STR_ENTRY(CKM_RSA_PKCS_OAEP);
CK2STR_ENTRY(CKM_RSA_PKCS_PSS);
CK2STR_ENTRY(CKM_SHA1_RSA_PKCS_PSS);
CK2STR_ENTRY(CKM_SHA256_RSA_PKCS);
CK2STR_ENTRY(CKM_SHA384_RSA_PKCS);
CK2STR_ENTRY(CKM_SHA512_RSA_PKCS);
CK2STR_ENTRY(CKM_SHA256_RSA_PKCS_PSS);
CK2STR_ENTRY(CKM_SHA384_RSA_PKCS_PSS);
CK2STR_ENTRY(CKM_SHA512_RSA_PKCS_PSS);
CK2STR_ENTRY(CKM_SHA224_RSA_PKCS);
CK2STR_ENTRY(CKM_SHA224_RSA_PKCS_PSS);
CK2STR_ENTRY(CKM_SHA512_224);
CK2STR_ENTRY(CKM_SHA512_224_HMAC);
CK2STR_ENTRY(CKM_SHA512_224_HMAC_GENERAL);
CK2STR_ENTRY(CKM_SHA512_224_KEY_DERIVATION);
CK2STR_ENTRY(CKM_SHA512_256);
CK2STR_ENTRY(CKM_SHA512_256_HMAC);
CK2STR_ENTRY(CKM_SHA512_256_HMAC_GENERAL);
CK2STR_ENTRY(CKM_SHA512_256_KEY_DERIVATION);
CK2STR_ENTRY(CKM_MD5);
CK2STR_ENTRY(CKM_MD5_HMAC);
CK2STR_ENTRY(CKM_MD5_HMAC_GENERAL);
CK2STR_ENTRY(CKM_SHA_1);
CK2STR_ENTRY(CKM_SHA_1_HMAC);
CK2STR_ENTRY(CKM_SHA_1_HMAC_GENERAL);
CK2STR_ENTRY(CKM_SHA256);
CK2STR_ENTRY(CKM_SHA256_HMAC);
CK2STR_ENTRY(CKM_SHA256_HMAC_GENERAL);
CK2STR_ENTRY(CKM_SHA224);
CK2STR_ENTRY(CKM_SHA224_HMAC);
CK2STR_ENTRY(CKM_SHA224_HMAC_GENERAL);
CK2STR_ENTRY(CKM_SHA384);
CK2STR_ENTRY(CKM_SHA384_HMAC);
CK2STR_ENTRY(CKM_SHA384_HMAC_GENERAL);
CK2STR_ENTRY(CKM_SHA512);
CK2STR_ENTRY(CKM_SHA512_HMAC);
CK2STR_ENTRY(CKM_SHA512_HMAC_GENERAL);
CK2STR_ENTRY(CKM_HOTP_KEY_GEN);
CK2STR_ENTRY(CKM_HOTP);
CK2STR_ENTRY(CKM_GENERIC_SECRET_KEY_GEN);
CK2STR_ENTRY(CKM_SHA1_KEY_DERIVATION);
CK2STR_ENTRY(CKM_SHA256_KEY_DERIVATION);
CK2STR_ENTRY(CKM_SHA384_KEY_DERIVATION);
CK2STR_ENTRY(CKM_SHA512_KEY_DERIVATION);
CK2STR_ENTRY(CKM_SHA224_KEY_DERIVATION);
CK2STR_ENTRY(CKM_EC_KEY_PAIR_GEN);
CK2STR_ENTRY(CKM_ECDSA);
CK2STR_ENTRY(CKM_ECDSA_SHA1);
CK2STR_ENTRY(CKM_ECDSA_SHA224);
CK2STR_ENTRY(CKM_ECDSA_SHA256);
CK2STR_ENTRY(CKM_ECDSA_SHA384);
CK2STR_ENTRY(CKM_ECDSA_SHA512);
CK2STR_ENTRY(CKM_ECDH1_DERIVE);
CK2STR_ENTRY(CKM_ECDH1_COFACTOR_DERIVE);
CK2STR_ENTRY(CKM_ECMQV_DERIVE);
CK2STR_ENTRY(CKM_ECDH_AES_KEY_WRAP);
CK2STR_ENTRY(CKM_RSA_AES_KEY_WRAP);
CK2STR_ENTRY(CKM_AES_KEY_GEN);
CK2STR_ENTRY(CKM_AES_ECB);
CK2STR_ENTRY(CKM_AES_CBC);
CK2STR_ENTRY(CKM_AES_MAC);
CK2STR_ENTRY(CKM_AES_MAC_GENERAL);
CK2STR_ENTRY(CKM_AES_CBC_PAD);
CK2STR_ENTRY(CKM_AES_CTR);
CK2STR_ENTRY(CKM_AES_GCM);
CK2STR_ENTRY(CKM_AES_CCM);
CK2STR_ENTRY(CKM_AES_CTS);
CK2STR_ENTRY(CKM_AES_CMAC);
CK2STR_ENTRY(CKM_AES_CMAC_GENERAL);
CK2STR_ENTRY(CKM_AES_XCBC_MAC);
CK2STR_ENTRY(CKM_AES_XCBC_MAC_96);
CK2STR_ENTRY(CKM_AES_GMAC);
CK2STR_ENTRY(CKM_DES3_ECB_ENCRYPT_DATA);
CK2STR_ENTRY(CKM_DES3_CBC_ENCRYPT_DATA);
CK2STR_ENTRY(CKM_AES_ECB_ENCRYPT_DATA);
CK2STR_ENTRY(CKM_AES_CBC_ENCRYPT_DATA);
CK2STR_ENTRY(CKM_AES_KEY_WRAP);
CK2STR_ENTRY(CKM_AES_KEY_WRAP_PAD);
default:
if (id & CKM_VENDOR_DEFINED)
return "Vendor defined";
else
return "Unknown ID";
}
}
const char *slot_ckf2str(CK_ULONG flag)
{
switch (flag) {
CK2STR_ENTRY(CKF_TOKEN_PRESENT);
CK2STR_ENTRY(CKF_REMOVABLE_DEVICE);
CK2STR_ENTRY(CKF_HW_SLOT);
default:
return "Unknown flag";
}
}
const char *token_ckf2str(CK_ULONG flag)
{
switch (flag) {
CK2STR_ENTRY(CKF_RNG);
CK2STR_ENTRY(CKF_WRITE_PROTECTED);
CK2STR_ENTRY(CKF_LOGIN_REQUIRED);
CK2STR_ENTRY(CKF_USER_PIN_INITIALIZED);
CK2STR_ENTRY(CKF_RESTORE_KEY_NOT_NEEDED);
CK2STR_ENTRY(CKF_CLOCK_ON_TOKEN);
CK2STR_ENTRY(CKF_PROTECTED_AUTHENTICATION_PATH);
CK2STR_ENTRY(CKF_DUAL_CRYPTO_OPERATIONS);
CK2STR_ENTRY(CKF_TOKEN_INITIALIZED);
CK2STR_ENTRY(CKF_SECONDARY_AUTHENTICATION);
CK2STR_ENTRY(CKF_USER_PIN_COUNT_LOW);
CK2STR_ENTRY(CKF_USER_PIN_FINAL_TRY);
CK2STR_ENTRY(CKF_USER_PIN_LOCKED);
CK2STR_ENTRY(CKF_USER_PIN_TO_BE_CHANGED);
CK2STR_ENTRY(CKF_SO_PIN_COUNT_LOW);
CK2STR_ENTRY(CKF_SO_PIN_FINAL_TRY);
CK2STR_ENTRY(CKF_SO_PIN_LOCKED);
CK2STR_ENTRY(CKF_SO_PIN_TO_BE_CHANGED);
CK2STR_ENTRY(CKF_ERROR_STATE);
default:
return "Unknown flag";
}
}
const char *mecha_ckf2str(CK_ULONG flag)
{
switch (flag) {
CK2STR_ENTRY(CKF_HW);
CK2STR_ENTRY(CKF_ENCRYPT);
CK2STR_ENTRY(CKF_DECRYPT);
CK2STR_ENTRY(CKF_DIGEST);
CK2STR_ENTRY(CKF_SIGN);
CK2STR_ENTRY(CKF_SIGN_RECOVER);
CK2STR_ENTRY(CKF_VERIFY);
CK2STR_ENTRY(CKF_VERIFY_RECOVER);
CK2STR_ENTRY(CKF_GENERATE);
CK2STR_ENTRY(CKF_GENERATE_KEY_PAIR);
CK2STR_ENTRY(CKF_WRAP);
CK2STR_ENTRY(CKF_UNWRAP);
CK2STR_ENTRY(CKF_DERIVE);
CK2STR_ENTRY(CKF_EC_F_P);
CK2STR_ENTRY(CKF_EC_F_2M);
CK2STR_ENTRY(CKF_EC_ECPARAMETERS);
CK2STR_ENTRY(CKF_EC_NAMEDCURVE);
CK2STR_ENTRY(CKF_EC_UNCOMPRESS);
CK2STR_ENTRY(CKF_EC_COMPRESS);
CK2STR_ENTRY(CKF_EXTENSION);
default:
return "Unknown flag";
}
}
const char *session_ckf2str(CK_ULONG flag)
{
switch (flag) {
CK2STR_ENTRY(CKF_RW_SESSION);
CK2STR_ENTRY(CKF_SERIAL_SESSION);
default:
return "Unknown flag";
}
}
const char *session_cks2str(CK_ULONG flag)
{
switch (flag) {
CK2STR_ENTRY(CKS_RO_PUBLIC_SESSION);
CK2STR_ENTRY(CKS_RO_USER_FUNCTIONS);
CK2STR_ENTRY(CKS_RW_PUBLIC_SESSION);
CK2STR_ENTRY(CKS_RW_USER_FUNCTIONS);
CK2STR_ENTRY(CKS_RW_SO_FUNCTIONS);
default:
return "Unknown flag";
}
}
const char *cka2str(CK_ATTRIBUTE_TYPE id)
{
switch (id) {
/* Standard CK attributes */
CK2STR_ENTRY(CKA_CLASS);
CK2STR_ENTRY(CKA_TOKEN);
CK2STR_ENTRY(CKA_PRIVATE);
CK2STR_ENTRY(CKA_LABEL);
CK2STR_ENTRY(CKA_APPLICATION);
CK2STR_ENTRY(CKA_VALUE);
CK2STR_ENTRY(CKA_OBJECT_ID);
CK2STR_ENTRY(CKA_CERTIFICATE_TYPE);
CK2STR_ENTRY(CKA_ISSUER);
CK2STR_ENTRY(CKA_SERIAL_NUMBER);
CK2STR_ENTRY(CKA_AC_ISSUER);
CK2STR_ENTRY(CKA_OWNER);
CK2STR_ENTRY(CKA_ATTR_TYPES);
CK2STR_ENTRY(CKA_TRUSTED);
CK2STR_ENTRY(CKA_CERTIFICATE_CATEGORY);
CK2STR_ENTRY(CKA_JAVA_MIDP_SECURITY_DOMAIN);
CK2STR_ENTRY(CKA_URL);
CK2STR_ENTRY(CKA_HASH_OF_SUBJECT_PUBLIC_KEY);
CK2STR_ENTRY(CKA_HASH_OF_ISSUER_PUBLIC_KEY);
CK2STR_ENTRY(CKA_NAME_HASH_ALGORITHM);
CK2STR_ENTRY(CKA_CHECK_VALUE);
CK2STR_ENTRY(CKA_KEY_TYPE);
CK2STR_ENTRY(CKA_SUBJECT);
CK2STR_ENTRY(CKA_ID);
CK2STR_ENTRY(CKA_SENSITIVE);
CK2STR_ENTRY(CKA_ENCRYPT);
CK2STR_ENTRY(CKA_DECRYPT);
CK2STR_ENTRY(CKA_WRAP);
CK2STR_ENTRY(CKA_UNWRAP);
CK2STR_ENTRY(CKA_SIGN);
CK2STR_ENTRY(CKA_SIGN_RECOVER);
CK2STR_ENTRY(CKA_VERIFY);
CK2STR_ENTRY(CKA_VERIFY_RECOVER);
CK2STR_ENTRY(CKA_DERIVE);
CK2STR_ENTRY(CKA_START_DATE);
CK2STR_ENTRY(CKA_END_DATE);
CK2STR_ENTRY(CKA_MODULUS);
CK2STR_ENTRY(CKA_MODULUS_BITS);
CK2STR_ENTRY(CKA_PUBLIC_EXPONENT);
CK2STR_ENTRY(CKA_PRIVATE_EXPONENT);
CK2STR_ENTRY(CKA_PRIME_1);
CK2STR_ENTRY(CKA_PRIME_2);
CK2STR_ENTRY(CKA_EXPONENT_1);
CK2STR_ENTRY(CKA_EXPONENT_2);
CK2STR_ENTRY(CKA_COEFFICIENT);
CK2STR_ENTRY(CKA_PUBLIC_KEY_INFO);
CK2STR_ENTRY(CKA_PRIME);
CK2STR_ENTRY(CKA_SUBPRIME);
CK2STR_ENTRY(CKA_BASE);
CK2STR_ENTRY(CKA_PRIME_BITS);
CK2STR_ENTRY(CKA_SUBPRIME_BITS);
CK2STR_ENTRY(CKA_VALUE_BITS);
CK2STR_ENTRY(CKA_VALUE_LEN);
CK2STR_ENTRY(CKA_EXTRACTABLE);
CK2STR_ENTRY(CKA_LOCAL);
CK2STR_ENTRY(CKA_NEVER_EXTRACTABLE);
CK2STR_ENTRY(CKA_ALWAYS_SENSITIVE);
CK2STR_ENTRY(CKA_KEY_GEN_MECHANISM);
CK2STR_ENTRY(CKA_MODIFIABLE);
CK2STR_ENTRY(CKA_COPYABLE);
CK2STR_ENTRY(CKA_DESTROYABLE);
CK2STR_ENTRY(CKA_EC_PARAMS);
CK2STR_ENTRY(CKA_EC_POINT);
CK2STR_ENTRY(CKA_ALWAYS_AUTHENTICATE);
CK2STR_ENTRY(CKA_WRAP_WITH_TRUSTED);
CK2STR_ENTRY(CKA_WRAP_TEMPLATE);
CK2STR_ENTRY(CKA_UNWRAP_TEMPLATE);
CK2STR_ENTRY(CKA_DERIVE_TEMPLATE);
CK2STR_ENTRY(CKA_OTP_FORMAT);
CK2STR_ENTRY(CKA_OTP_LENGTH);
CK2STR_ENTRY(CKA_OTP_TIME_INTERVAL);
CK2STR_ENTRY(CKA_OTP_USER_FRIENDLY_MODE);
CK2STR_ENTRY(CKA_OTP_CHALLENGE_REQUIREMENT);
CK2STR_ENTRY(CKA_OTP_TIME_REQUIREMENT);
CK2STR_ENTRY(CKA_OTP_COUNTER_REQUIREMENT);
CK2STR_ENTRY(CKA_OTP_PIN_REQUIREMENT);
CK2STR_ENTRY(CKA_OTP_COUNTER);
CK2STR_ENTRY(CKA_OTP_TIME);
CK2STR_ENTRY(CKA_OTP_USER_IDENTIFIER);
CK2STR_ENTRY(CKA_OTP_SERVICE_IDENTIFIER);
CK2STR_ENTRY(CKA_OTP_SERVICE_LOGO);
CK2STR_ENTRY(CKA_OTP_SERVICE_LOGO_TYPE);
CK2STR_ENTRY(CKA_GOSTR3410_PARAMS);
CK2STR_ENTRY(CKA_GOSTR3411_PARAMS);
CK2STR_ENTRY(CKA_GOST28147_PARAMS);
CK2STR_ENTRY(CKA_HW_FEATURE_TYPE);
CK2STR_ENTRY(CKA_RESET_ON_INIT);
CK2STR_ENTRY(CKA_HAS_RESET);
CK2STR_ENTRY(CKA_PIXEL_X);
CK2STR_ENTRY(CKA_PIXEL_Y);
CK2STR_ENTRY(CKA_RESOLUTION);
CK2STR_ENTRY(CKA_CHAR_ROWS);
CK2STR_ENTRY(CKA_CHAR_COLUMNS);
CK2STR_ENTRY(CKA_COLOR);
CK2STR_ENTRY(CKA_BITS_PER_PIXEL);
CK2STR_ENTRY(CKA_CHAR_SETS);
CK2STR_ENTRY(CKA_ENCODING_METHODS);
CK2STR_ENTRY(CKA_MIME_TYPES);
CK2STR_ENTRY(CKA_MECHANISM_TYPE);
CK2STR_ENTRY(CKA_REQUIRED_CMS_ATTRIBUTES);
CK2STR_ENTRY(CKA_DEFAULT_CMS_ATTRIBUTES);
CK2STR_ENTRY(CKA_SUPPORTED_CMS_ATTRIBUTES);
CK2STR_ENTRY(CKA_ALLOWED_MECHANISMS);
CK2STR_ENTRY(CKA_VENDOR_DEFINED);
default:
if (id & CKA_VENDOR_DEFINED)
return "Vendor defined";
else
return "Unknown ID";
}
}
const char *cko2str(CK_OBJECT_CLASS id)
{
switch (id) {
CK2STR_ENTRY(CKO_DATA);
CK2STR_ENTRY(CKO_CERTIFICATE);
CK2STR_ENTRY(CKO_PUBLIC_KEY);
CK2STR_ENTRY(CKO_PRIVATE_KEY);
CK2STR_ENTRY(CKO_SECRET_KEY);
CK2STR_ENTRY(CKO_HW_FEATURE);
CK2STR_ENTRY(CKO_DOMAIN_PARAMETERS);
CK2STR_ENTRY(CKO_MECHANISM);
CK2STR_ENTRY(CKO_OTP_KEY);
CK2STR_ENTRY(CKO_VENDOR_DEFINED);
default:
return "Unknown";
}
}
const char *ckk2str(CK_KEY_TYPE id)
{
switch (id) {
CK2STR_ENTRY(CKK_RSA);
CK2STR_ENTRY(CKK_DSA);
CK2STR_ENTRY(CKK_DH);
CK2STR_ENTRY(CKK_ECDSA);
CK2STR_ENTRY(CKK_GENERIC_SECRET);
CK2STR_ENTRY(CKK_DES3);
CK2STR_ENTRY(CKK_AES);
CK2STR_ENTRY(CKK_HOTP);
CK2STR_ENTRY(CKK_MD5_HMAC);
CK2STR_ENTRY(CKK_SHA_1_HMAC);
CK2STR_ENTRY(CKK_SHA256_HMAC);
CK2STR_ENTRY(CKK_SHA384_HMAC);
CK2STR_ENTRY(CKK_SHA512_HMAC);
CK2STR_ENTRY(CKK_SHA224_HMAC);
CK2STR_ENTRY(CKK_VENDOR_DEFINED);
default:
return "Unknown";
}
}
|
88585a9b03634a494cb9dc26f7ef16685b73a5d6
|
3f308bd1e45dc44276d57c089e7698b4fcda79a4
|
/x/valve/jdialog.c
|
56becf2bb662922887597dee012a0b81a1a9c745
|
[] |
no_license
|
jhallen/joes-sandbox
|
b5b6d1acf3f66645c3a00757f217f7a8fe2cad27
|
0ec8c38756e4cdc40fc5f881b7c87e2628d15f24
|
refs/heads/master
| 2022-01-18T21:38:24.514745
| 2022-01-03T01:08:53
| 2022-01-03T01:08:53
| 25,269,713
| 760
| 42
| null | 2020-10-27T05:34:56
| 2014-10-15T19:21:16
|
C
|
UTF-8
|
C
| false
| false
| 1,732
|
c
|
jdialog.c
|
/* Job dialog widget */
#include <notif.h>
#include "jdialog.h"
static void jdialogst(b,n)
Jdialog *b;
Jctrl *n;
{
b->jctrl=n;
}
struct jdialogfuncs jdialogfuncs;
static int doclr(stat,b)
Jdialog *b;
{
if(!stat)
{
canit(b->jctrl->name);
redraw(b->jctrl);
rm(b);
}
}
static int jdocan(stat,b)
Jdialog *b;
{
if(!stat)
{
rm(b);
}
}
static int udialogpress1(stat,m,junk,key,state,x,y,org)
Jdialog *m;
{
if(!stat)
{
if(x<0 || x>=gtwidth(m) || y<0 || y>=gtheight(m))
{ /* Mouse press is out of our window */
}
else
{ /* Mouse press is in our window */
calcpointer();
/* Event is for one of our kids maybe */
doevent(gtmain(m),&ev);
}
}
return stat;
}
void jdialogrm(b)
Jdialog *b;
{
modalpop();
(widgetfuncs.rm)(b);
}
Jdialog *mkJdialog(b)
Jdialog *b;
{
Text *t;
mkWidget(b);
if(!jdialogfuncs.on)
{
mcpy(&jdialogfuncs,&widgetfuncs,sizeof(struct widgetfuncs));
jdialogfuncs.st=jdialogst;
jdialogfuncs.rm=jdialogrm;
kcpy(jdialogfuncs.kmap,widgetfuncs.kmap);
kadd(jdialogfuncs.kmap,NULL,"Press1",udialogpress1,NULL);
}
b->funcs= &jdialogfuncs;
modal(b);
stflg(b,gtflg(b)|flgoverride);
stborder(b,mk(Titlebar));
st((Titlebar *)gtborder(b),"Job control");
t=mk(Text);
st(t,"Cancel job?");
add(b,t);
sth(b,80);
ltor(b,NULL,0);
bedge(b,0);
b->can=mk(Button);
stborder(b->can,mkIkborder(malloc(sizeof(Iborder))));
stw(b->can,70);
sth(b->can,42);
sttext(b->can," No ");
stfn(b->can,fn1(b->canfn,jdocan,b));
add(b,b->can);
b->clr=mk(Button);
stborder(b->clr,mkIkborder(malloc(sizeof(Iborder))));
stw(b->clr,70);
sth(b->clr,42);
sttext(b->clr," OK ");
stfn(b->clr,fn1(b->clrfn,doclr,b));
add(b,b->clr);
return b;
}
|
0cdc460f9491ca53a73b9046e0416ccdaa2fbfd6
|
e73547787354afd9b717ea57fe8dd0695d161821
|
/src/world/area_kzn/kzn_19/kzn_19_0_header.c
|
01b0692b0c103081262859991a8eb8eff736f702
|
[] |
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
| 497
|
c
|
kzn_19_0_header.c
|
#include "kzn_19.h"
extern EvtScript N(EVS_Main);
EntryList N(Entrances) = {
[kzn_19_ENTRY_0] { -435.0, 250.0, -350.0, 90.0 },
[kzn_19_ENTRY_1] { -490.0, 25.0, -30.0, 90.0 },
[kzn_19_ENTRY_2] { 440.0, 25.0, -50.0, 270.0 },
[kzn_19_ENTRY_3] { 440.0, 25.0, -50.0, 90.0 },
};
MapSettings N(settings) = {
.main = &N(EVS_Main),
.entryList = &N(Entrances),
.entryCount = ENTRY_COUNT(N(Entrances)),
.tattle = { MSG_MapTattle_kzn_19 },
};
|
ac0d40a2d82142f7989f6f69ddeee599634b4763
|
78c8fdab5c566067cc2dd3b0c0f874abd1452932
|
/c/src/Structural/Bridge/supersizesoda.c
|
85e52ec0240908aef04c042942bab9715904d399
|
[] |
no_license
|
markmontymark/patterns
|
acca4aa6918f3d7986c9401a28860cade3cc14e7
|
03e3ae83b7ee9bbfd528fe74c5100a75113df95a
|
refs/heads/master
| 2022-06-19T20:58:38.639252
| 2022-06-03T17:51:12
| 2022-06-03T17:51:12
| 10,532,052
| 113
| 18
| null | 2015-10-01T16:42:55
| 2013-06-06T17:18:41
|
Shell
|
UTF-8
|
C
| false
| false
| 264
|
c
|
supersizesoda.c
|
#include "stdio.h"
#include "SodaImp.h"
//SuperSizeSoda - two of two classes extending the Abstract
void supersizesoda_pourSoda()
{
int i;
void (*pourSodaImp)() = SodaImp_get();
for (i = 0; i < 5; i++)
{
printf("...glug...\n");
pourSodaImp();
}
}
|
e88c41ad5c5b075666a7be95b74b81abc30f5f68
|
e910318d01528d82040507a49eeeb8dade45b31f
|
/ports/nrf/boards/microbit/modules/microbitdisplay.c
|
c2eaf4179bcdf9d7a1034ad8a07acba9cb669dd9
|
[
"MIT"
] |
permissive
|
pfalcon/pycopy
|
e844480a5e5cd463530328889daed2ba87552b8a
|
3ac90ae9c3c6bbebfba9cada2d37025e35c62796
|
refs/heads/pfalcon
| 2023-08-30T09:39:52.290147
| 2022-09-08T16:42:38
| 2022-09-08T16:42:38
| 15,507,576
| 753
| 71
|
MIT
| 2021-05-08T04:59:21
| 2013-12-29T11:38:47
|
C
|
UTF-8
|
C
| false
| false
| 21,532
|
c
|
microbitdisplay.c
|
/*
* This file is part of the Micro Python project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2015 Damien P. George
*
* 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 <string.h>
#include "py/obj.h"
#include "py/runtime.h"
#include "py/gc.h"
#include "nrf_gpio.h"
#include "microbitimage.h"
#include "microbitdisplay.h"
#include "iters.h"
#include "ticker.h"
#define min(a,b) (((a)<(b))?(a):(b))
void microbit_display_show(microbit_display_obj_t *display, microbit_image_obj_t *image) {
mp_int_t w = min(imageWidth(image), 5);
mp_int_t h = min(imageHeight(image), 5);
mp_int_t x = 0;
mp_int_t brightnesses = 0;
for (; x < w; ++x) {
mp_int_t y = 0;
for (; y < h; ++y) {
uint8_t pix = imageGetPixelValue(image, x, y);
display->image_buffer[x][y] = pix;
brightnesses |= (1 << pix);
}
for (; y < 5; ++y) {
display->image_buffer[x][y] = 0;
}
}
for (; x < 5; ++x) {
for (mp_int_t y = 0; y < 5; ++y) {
display->image_buffer[x][y] = 0;
}
}
display->brightnesses = brightnesses;
}
#define DEFAULT_PRINT_SPEED 400
mp_obj_t microbit_display_show_func(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
// Cancel any animations.
MP_STATE_PORT(async_data)[0] = NULL;
MP_STATE_PORT(async_data)[1] = NULL;
static const mp_arg_t show_allowed_args[] = {
{ MP_QSTR_image, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_delay, MP_ARG_INT, {.u_int = DEFAULT_PRINT_SPEED} },
{ MP_QSTR_clear, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} },
{ MP_QSTR_wait, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = true} },
{ MP_QSTR_loop, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} },
};
// Parse the args.
microbit_display_obj_t *self = (microbit_display_obj_t*)pos_args[0];
mp_arg_val_t args[MP_ARRAY_SIZE(show_allowed_args)];
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(show_allowed_args), show_allowed_args, args);
mp_obj_t image = args[0].u_obj;
mp_int_t delay = args[1].u_int;
bool clear = args[2].u_bool;
bool wait = args[3].u_bool;
bool loop = args[4].u_bool;
if (mp_obj_is_str(image)) {
// arg is a string object
size_t len;
const char *str = mp_obj_str_get_data(image, &len);
if (len == 0) {
// There are no chars; do nothing.
return mp_const_none;
} else if (len == 1) {
if (!clear && !loop) {
// A single char; convert to an image and print that.
image = microbit_image_for_char(str[0]);
goto single_image_immediate;
}
}
image = microbit_string_facade(image);
} else if (mp_obj_get_type(image) == µbit_image_type) {
if (!clear && !loop) {
goto single_image_immediate;
}
image = mp_obj_new_tuple(1, &image);
}
// iterable:
if (args[4].u_bool) { /*loop*/
image = microbit_repeat_iterator(image);
}
microbit_display_animate(self, image, delay, clear, wait);
return mp_const_none;
single_image_immediate:
microbit_display_show(self, (microbit_image_obj_t *)image);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_KW(microbit_display_show_obj, 1, microbit_display_show_func);
static uint8_t async_mode;
static mp_obj_t async_iterator = NULL;
// Record if an error occurs in async animation. Unfortunately there is no way to report this.
static volatile bool wakeup_event = false;
static mp_uint_t async_delay = 1000;
static mp_uint_t async_tick = 0;
static bool async_clear = false;
bool microbit_display_active_animation(void) {
return async_mode == ASYNC_MODE_ANIMATION;
}
STATIC void async_stop(void) {
async_iterator = NULL;
async_mode = ASYNC_MODE_STOPPED;
async_tick = 0;
async_delay = 1000;
async_clear = false;
MP_STATE_PORT(async_data)[0] = NULL;
MP_STATE_PORT(async_data)[1] = NULL;
wakeup_event = true;
}
STATIC void wait_for_event(void) {
while (!wakeup_event) {
// allow CTRL-C to stop the animation
if (MP_STATE_VM(mp_pending_exception) != MP_OBJ_NULL) {
async_stop();
return;
}
__WFI();
}
wakeup_event = false;
}
typedef struct {
uint8_t x;
uint8_t y;
} DisplayPoint;
#define NO_CONN 0
#define ROW_COUNT 3
#define COLUMN_COUNT 9
static const DisplayPoint display_map[COLUMN_COUNT][ROW_COUNT] = {
{{0,0}, {4,2}, {2,4}},
{{2,0}, {0,2}, {4,4}},
{{4,0}, {2,2}, {0,4}},
{{4,3}, {1,0}, {0,1}},
{{3,3}, {3,0}, {1,1}},
{{2,3}, {3,4}, {2,1}},
{{1,3}, {1,4}, {3,1}},
{{0,3}, {NO_CONN,NO_CONN}, {4,1}},
{{1,2}, {NO_CONN,NO_CONN}, {3,2}}
};
#define MIN_COLUMN_PIN 4
#define COLUMN_PINS_MASK 0x1ff0
#define MIN_ROW_PIN 13
#define MAX_ROW_PIN 15
#define ROW_PINS_MASK 0xe000
static inline void displaySetPinsForRow(microbit_display_obj_t * p_display, uint8_t brightness) {
if (brightness == 0) {
nrf_gpio_port_out_clear(NRF_GPIO, COLUMN_PINS_MASK & ~p_display->pins_for_brightness[brightness]);
} else {
nrf_gpio_pin_set(p_display->pins_for_brightness[brightness]);
}
}
/* This is the primary PWM driver/display driver. It will operate on one row
* (9 pins) per invocation. It will turn on LEDs with maximum brightness,
* then let the "callback" callback turn off the LEDs as appropriate for the
* required brightness level.
*
* For each row
* Turn off all the LEDs in the previous row
* Set the column bits high (off)
* Set the row strobe low (off)
* Turn on all the LEDs in the current row that have maximum brightness
* Set the row strobe high (on)
* Set some/all column bits low (on)
* Register the PWM callback
* For each callback start with brightness 0
* If brightness 0
* Turn off the LEDs specified at this level
* Else
* Turn on the LEDs specified at this level
* If brightness max
* Disable the PWM callback
* Else
* Re-queue the PWM callback after the appropriate delay
*/
static void displayAdvanceRow(microbit_display_obj_t * p_display) {
/* Clear all of the column bits */
nrf_gpio_port_out_set(NRF_GPIO, COLUMN_PINS_MASK);
/* Clear the strobe bit for this row */
nrf_gpio_pin_clear(p_display->strobe_row + MIN_ROW_PIN);
/* Move to the next row. Before this, "this row" refers to the row
* manipulated by the previous invocation of this function. After this,
* "this row" refers to the row manipulated by the current invocation of
* this function. */
p_display->strobe_row++;
// Reset the row counts and bit mask when we have hit the max.
if (p_display->strobe_row == ROW_COUNT) {
p_display->strobe_row = 0;
}
// Set pin for this row.
// Prepare row for rendering.
for (int i = 0; i <= MAX_BRIGHTNESS; i++) {
p_display->pins_for_brightness[i] = 0;
}
for (int i = 0; i < COLUMN_COUNT; i++) {
int x = display_map[i][p_display->strobe_row].x;
int y = display_map[i][p_display->strobe_row].y;
int brightness = microbit_display_obj.image_buffer[x][y];
p_display->pins_for_brightness[brightness] |= (1<<(i+MIN_COLUMN_PIN));
(void)brightness;
}
/* Enable the strobe bit for this row */
nrf_gpio_pin_set(p_display->strobe_row + MIN_ROW_PIN);
/* Enable the column bits for all pins that need to be on. */
nrf_gpio_port_out_clear(NRF_GPIO, p_display->pins_for_brightness[MAX_BRIGHTNESS]);
}
static const uint16_t render_timings[] =
// The scale is (approximately) exponential,
// each step is approx x1.9 greater than the previous.
{ 0, // Bright, Ticks Duration, Relative power
2, // 1, 2, 32us, inf
2, // 2, 4, 64us, 200%
4, // 3, 8, 128us, 200%
7, // 4, 15, 240us, 187%
13, // 5, 28, 448us, 187%
25, // 6, 53, 848us, 189%
49, // 7, 102, 1632us, 192%
97, // 8, 199, 3184us, 195%
// Always on 9, 375, 6000us, 188%
};
#define DISPLAY_TICKER_SLOT 1
/* This is the PWM callback. It is registered by the animation callback and
* will unregister itself when all of the brightness steps are complete. */
static int32_t callback(void) {
microbit_display_obj_t *display = µbit_display_obj;
mp_uint_t brightness = display->previous_brightness;
displaySetPinsForRow(display, brightness);
brightness += 1;
if (brightness == MAX_BRIGHTNESS) {
clear_ticker_callback(DISPLAY_TICKER_SLOT);
return -1;
}
display->previous_brightness = brightness;
// Return interval (in 16us ticks) until next callback
return render_timings[brightness];
}
static void draw_object(mp_obj_t obj) {
microbit_display_obj_t *display = (microbit_display_obj_t*)MP_STATE_PORT(async_data)[0];
if (obj == MP_OBJ_STOP_ITERATION) {
if (async_clear) {
microbit_display_show(µbit_display_obj, BLANK_IMAGE);
async_clear = false;
} else {
async_stop();
}
} else if (mp_obj_get_type(obj) == µbit_image_type) {
microbit_display_show(display, (microbit_image_obj_t *)obj);
} else if (mp_obj_is_str(obj)) {
size_t len;
const char *str = mp_obj_str_get_data(obj, &len);
if (len == 1) {
microbit_display_show(display, microbit_image_for_char(str[0]));
} else {
async_stop();
}
} else {
mp_sched_exception(mp_obj_new_exception_msg(&mp_type_TypeError, MP_ERROR_TEXT("not an image.")));
async_stop();
}
}
static void microbit_display_update(void) {
async_tick += MILLISECONDS_PER_MACRO_TICK;
if (async_tick < async_delay) {
return;
}
async_tick = 0;
switch (async_mode) {
case ASYNC_MODE_ANIMATION:
{
if (MP_STATE_PORT(async_data)[0] == NULL || MP_STATE_PORT(async_data)[1] == NULL) {
async_stop();
break;
}
/* WARNING: We are executing in an interrupt handler.
* If an exception is raised here then we must hand it to the VM. */
mp_obj_t obj;
nlr_buf_t nlr;
gc_lock();
if (nlr_push(&nlr) == 0) {
obj = mp_iternext_allow_raise(async_iterator);
nlr_pop();
gc_unlock();
} else {
gc_unlock();
if (!mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(((mp_obj_base_t*)nlr.ret_val)->type),
MP_OBJ_FROM_PTR(&mp_type_StopIteration))) {
// An exception other than StopIteration, so set it for the VM to raise later
// If memory error, write an appropriate message.
if (mp_obj_get_type(nlr.ret_val) == &mp_type_MemoryError) {
mp_printf(&mp_plat_print, "Allocation in interrupt handler");
}
mp_sched_exception(MP_OBJ_FROM_PTR(nlr.ret_val));
}
obj = MP_OBJ_STOP_ITERATION;
}
draw_object(obj);
break;
}
case ASYNC_MODE_CLEAR:
microbit_display_show(µbit_display_obj, BLANK_IMAGE);
async_stop();
break;
}
}
#define GREYSCALE_MASK ((1<<MAX_BRIGHTNESS)-2)
/* This is the top-level animation/display registered callback. */
void microbit_display_tick(void) {
/* Do nothing if the display is not active. */
if (!microbit_display_obj.active) {
return;
}
displayAdvanceRow(µbit_display_obj);
microbit_display_update();
microbit_display_obj.previous_brightness = 0;
if (microbit_display_obj.brightnesses & GREYSCALE_MASK) {
set_ticker_callback(DISPLAY_TICKER_SLOT, callback, 1800);
}
}
void microbit_display_animate(microbit_display_obj_t *self, mp_obj_t iterable, mp_int_t delay, bool clear, bool wait) {
// Reset the repeat state.
MP_STATE_PORT(async_data)[0] = NULL;
MP_STATE_PORT(async_data)[1] = NULL;
async_iterator = mp_getiter(iterable, NULL);
async_delay = delay;
async_clear = clear;
MP_STATE_PORT(async_data)[0] = self; // so it doesn't get GC'd
MP_STATE_PORT(async_data)[1] = async_iterator;
wakeup_event = false;
mp_obj_t obj = mp_iternext_allow_raise(async_iterator);
draw_object(obj);
async_tick = 0;
async_mode = ASYNC_MODE_ANIMATION;
if (wait) {
wait_for_event();
}
}
// Delay in ms in between moving display one column to the left.
#define DEFAULT_SCROLL_SPEED 150
void microbit_display_scroll(microbit_display_obj_t *self, const char* str, bool wait) {
mp_obj_t iterable = scrolling_string_image_iterable(str, strlen(str), NULL, false, false);
microbit_display_animate(self, iterable, DEFAULT_SCROLL_SPEED, false, wait);
}
mp_obj_t microbit_display_scroll_func(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
static const mp_arg_t scroll_allowed_args[] = {
{ MP_QSTR_text, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_delay, MP_ARG_INT, {.u_int = DEFAULT_SCROLL_SPEED} },
{ MP_QSTR_wait, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = true} },
{ MP_QSTR_monospace, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} },
{ MP_QSTR_loop, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} },
};
// Parse the args.
microbit_display_obj_t *self = (microbit_display_obj_t*)pos_args[0];
mp_arg_val_t args[MP_ARRAY_SIZE(scroll_allowed_args)];
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(scroll_allowed_args), scroll_allowed_args, args);
size_t len;
const char* str = mp_obj_str_get_data(args[0].u_obj, &len);
mp_obj_t iterable = scrolling_string_image_iterable(str, len, args[0].u_obj, args[3].u_bool /*monospace?*/, args[4].u_bool /*loop*/);
microbit_display_animate(self, iterable, args[1].u_int /*delay*/, false/*clear*/, args[2].u_bool/*wait?*/);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_KW(microbit_display_scroll_obj, 1, microbit_display_scroll_func);
mp_obj_t microbit_display_on_func(mp_obj_t obj) {
microbit_display_obj_t *self = (microbit_display_obj_t*)obj;
/* Try to reclaim the pins we need */
/*
microbit_obj_pin_fail_if_cant_acquire(µbit_p3_obj);
microbit_obj_pin_fail_if_cant_acquire(µbit_p4_obj);
microbit_obj_pin_fail_if_cant_acquire(µbit_p6_obj);
microbit_obj_pin_fail_if_cant_acquire(µbit_p7_obj);
microbit_obj_pin_fail_if_cant_acquire(µbit_p9_obj);
microbit_obj_pin_fail_if_cant_acquire(µbit_p10_obj);
microbit_obj_pin_acquire(µbit_p3_obj, microbit_pin_mode_display);
microbit_obj_pin_acquire(µbit_p4_obj, microbit_pin_mode_display);
microbit_obj_pin_acquire(µbit_p6_obj, microbit_pin_mode_display);
microbit_obj_pin_acquire(µbit_p7_obj, microbit_pin_mode_display);
microbit_obj_pin_acquire(µbit_p9_obj, microbit_pin_mode_display);
microbit_obj_pin_acquire(µbit_p10_obj, microbit_pin_mode_display);
*/
/* Make sure all pins are in the correct state */
microbit_display_init();
/* Re-enable the display loop. This will resume any animations in
* progress and display any static image. */
self->active = true;
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_1(microbit_display_on_obj, microbit_display_on_func);
mp_obj_t microbit_display_off_func(mp_obj_t obj) {
microbit_display_obj_t *self = (microbit_display_obj_t*)obj;
/* Disable the display loop. This will pause any animations in progress.
* It will not prevent a user from attempting to modify the state, but
* modifications will not appear to have any effect until the display loop
* is re-enabled. */
self->active = false;
/* Disable the row strobes, allowing the columns to be used freely for
* GPIO. */
nrf_gpio_port_out_clear(0, ROW_PINS_MASK);
/* Free pins for other uses */
/*
microbit_obj_pin_free(µbit_p3_obj);
microbit_obj_pin_free(µbit_p4_obj);
microbit_obj_pin_free(µbit_p6_obj);
microbit_obj_pin_free(µbit_p7_obj);
microbit_obj_pin_free(µbit_p9_obj);
microbit_obj_pin_free(µbit_p10_obj);
*/
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_1(microbit_display_off_obj, microbit_display_off_func);
mp_obj_t microbit_display_is_on_func(mp_obj_t obj) {
microbit_display_obj_t *self = (microbit_display_obj_t*)obj;
if (self->active) {
return mp_const_true;
}
else {
return mp_const_false;
}
}
MP_DEFINE_CONST_FUN_OBJ_1(microbit_display_is_on_obj, microbit_display_is_on_func);
void microbit_display_clear(void) {
// Reset repeat state, cancel animation and clear screen.
wakeup_event = false;
async_mode = ASYNC_MODE_CLEAR;
async_tick = async_delay - MILLISECONDS_PER_MACRO_TICK;
wait_for_event();
}
mp_obj_t microbit_display_clear_func(mp_obj_t self_in) {
microbit_display_clear();
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_1(microbit_display_clear_obj, microbit_display_clear_func);
void microbit_display_set_pixel(microbit_display_obj_t *display, mp_int_t x, mp_int_t y, mp_int_t bright) {
if (x < 0 || y < 0 || x > 4 || y > 4) {
mp_raise_ValueError(MP_ERROR_TEXT("index out of bounds."));
}
if (bright < 0 || bright > MAX_BRIGHTNESS) {
mp_raise_ValueError(MP_ERROR_TEXT("brightness out of bounds."));
}
display->image_buffer[x][y] = bright;
display->brightnesses |= (1 << bright);
}
STATIC mp_obj_t microbit_display_set_pixel_func(mp_uint_t n_args, const mp_obj_t *args) {
(void)n_args;
microbit_display_obj_t *self = (microbit_display_obj_t*)args[0];
microbit_display_set_pixel(self, mp_obj_get_int(args[1]), mp_obj_get_int(args[2]), mp_obj_get_int(args[3]));
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(microbit_display_set_pixel_obj, 4, 4, microbit_display_set_pixel_func);
mp_int_t microbit_display_get_pixel(microbit_display_obj_t *display, mp_int_t x, mp_int_t y) {
if (x < 0 || y < 0 || x > 4 || y > 4) {
mp_raise_ValueError(MP_ERROR_TEXT("index out of bounds."));
}
return display->image_buffer[x][y];
}
STATIC mp_obj_t microbit_display_get_pixel_func(mp_obj_t self_in, mp_obj_t x_in, mp_obj_t y_in) {
microbit_display_obj_t *self = (microbit_display_obj_t*)self_in;
return MP_OBJ_NEW_SMALL_INT(microbit_display_get_pixel(self, mp_obj_get_int(x_in), mp_obj_get_int(y_in)));
}
MP_DEFINE_CONST_FUN_OBJ_3(microbit_display_get_pixel_obj, microbit_display_get_pixel_func);
STATIC const mp_rom_map_elem_t microbit_display_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_get_pixel), MP_ROM_PTR(µbit_display_get_pixel_obj) },
{ MP_ROM_QSTR(MP_QSTR_set_pixel), MP_ROM_PTR(µbit_display_set_pixel_obj) },
{ MP_ROM_QSTR(MP_QSTR_show), MP_ROM_PTR(µbit_display_show_obj) },
{ MP_ROM_QSTR(MP_QSTR_scroll), MP_ROM_PTR(µbit_display_scroll_obj) },
{ MP_ROM_QSTR(MP_QSTR_clear), MP_ROM_PTR(µbit_display_clear_obj) },
{ MP_ROM_QSTR(MP_QSTR_on), MP_ROM_PTR(µbit_display_on_obj) },
{ MP_ROM_QSTR(MP_QSTR_off), MP_ROM_PTR(µbit_display_off_obj) },
{ MP_ROM_QSTR(MP_QSTR_is_on), MP_ROM_PTR(µbit_display_is_on_obj) },
};
STATIC MP_DEFINE_CONST_DICT(microbit_display_locals_dict, microbit_display_locals_dict_table);
const mp_obj_type_t microbit_display_type = {
{ &mp_type_type },
.name = MP_QSTR_MicroBitDisplay,
.print = NULL,
.make_new = NULL,
.call = NULL,
.unary_op = NULL,
.binary_op = NULL,
.attr = NULL,
.subscr = NULL,
.getiter = NULL,
.iternext = NULL,
.buffer_p = {NULL},
.locals_dict = (mp_obj_dict_t*)µbit_display_locals_dict,
};
microbit_display_obj_t microbit_display_obj = {
{µbit_display_type},
{{ 0, }},
.previous_brightness = 0,
.active = 1,
.strobe_row = 0,
.brightnesses = 0,
.pins_for_brightness = { 0 },
};
void microbit_display_init(void) {
// Set pins as output.
for (int i = MIN_COLUMN_PIN; i <= MAX_ROW_PIN; i++) {
nrf_gpio_cfg_output(i);
}
}
|
0664b0d5112a984fbd3315cfcbee6c1e07b9da1c
|
88ef8cd31759f6221dee73f117a102680229eceb
|
/rnd/sfmt/SFMT-sse2.h
|
99a33ff1f8e3895ac42a8d277229da591dd1a916
|
[
"BSD-3-Clause"
] |
permissive
|
cpmech/gosl
|
095fe22f5b507a6492741faaf6df28c8c8b53ce4
|
e349d650c7a4b5057cc87bb420c44f7794248d6c
|
refs/heads/main
| 2023-06-07T17:37:52.813809
| 2023-05-25T07:10:31
| 2023-05-25T07:10:31
| 30,563,502
| 1,956
| 181
|
BSD-3-Clause
| 2021-09-04T09:02:18
| 2015-02-09T23:00:38
|
Go
|
UTF-8
|
C
| false
| false
| 3,210
|
h
|
SFMT-sse2.h
|
#pragma once
/**
* @file SFMT-sse2.h
* @brief SIMD oriented Fast Mersenne Twister(SFMT) for Intel SSE2
*
* @author Mutsuo Saito (Hiroshima University)
* @author Makoto Matsumoto (Hiroshima University)
*
* @note We assume LITTLE ENDIAN in this file
*
* Copyright (C) 2006, 2007 Mutsuo Saito, Makoto Matsumoto and Hiroshima
* University. All rights reserved.
*
* The new BSD License is applied to this software, see LICENSE.txt
*/
#ifndef SFMT_SSE2_H
#define SFMT_SSE2_H
inline static void mm_recursion(__m128i * r, __m128i a, __m128i b,
__m128i c, __m128i d);
/**
* This function represents the recursion formula.
* @param r an output
* @param a a 128-bit part of the interal state array
* @param b a 128-bit part of the interal state array
* @param c a 128-bit part of the interal state array
* @param d a 128-bit part of the interal state array
*/
inline static void mm_recursion(__m128i * r, __m128i a, __m128i b,
__m128i c, __m128i d)
{
__m128i v, x, y, z;
y = _mm_srli_epi32(b, SFMT_SR1);
z = _mm_srli_si128(c, SFMT_SR2);
v = _mm_slli_epi32(d, SFMT_SL1);
z = _mm_xor_si128(z, a);
z = _mm_xor_si128(z, v);
x = _mm_slli_si128(a, SFMT_SL2);
y = _mm_and_si128(y, sse2_param_mask.si);
z = _mm_xor_si128(z, x);
z = _mm_xor_si128(z, y);
*r = z;
}
/**
* This function fills the internal state array with pseudorandom
* integers.
* @param sfmt SFMT internal state
*/
void sfmt_gen_rand_all(sfmt_t * sfmt) {
int i;
__m128i r1, r2;
w128_t * pstate = sfmt->state;
r1 = pstate[SFMT_N - 2].si;
r2 = pstate[SFMT_N - 1].si;
for (i = 0; i < SFMT_N - SFMT_POS1; i++) {
mm_recursion(&pstate[i].si, pstate[i].si,
pstate[i + SFMT_POS1].si, r1, r2);
r1 = r2;
r2 = pstate[i].si;
}
for (; i < SFMT_N; i++) {
mm_recursion(&pstate[i].si, pstate[i].si,
pstate[i + SFMT_POS1 - SFMT_N].si,
r1, r2);
r1 = r2;
r2 = pstate[i].si;
}
}
/**
* This function fills the user-specified array with pseudorandom
* integers.
* @param sfmt SFMT internal state.
* @param array an 128-bit array to be filled by pseudorandom numbers.
* @param size number of 128-bit pseudorandom numbers to be generated.
*/
static void gen_rand_array(sfmt_t * sfmt, w128_t * array, int size)
{
int i, j;
__m128i r1, r2;
w128_t * pstate = sfmt->state;
r1 = pstate[SFMT_N - 2].si;
r2 = pstate[SFMT_N - 1].si;
for (i = 0; i < SFMT_N - SFMT_POS1; i++) {
mm_recursion(&array[i].si, pstate[i].si,
pstate[i + SFMT_POS1].si, r1, r2);
r1 = r2;
r2 = array[i].si;
}
for (; i < SFMT_N; i++) {
mm_recursion(&array[i].si, pstate[i].si,
array[i + SFMT_POS1 - SFMT_N].si, r1, r2);
r1 = r2;
r2 = array[i].si;
}
for (; i < size - SFMT_N; i++) {
mm_recursion(&array[i].si, array[i - SFMT_N].si,
array[i + SFMT_POS1 - SFMT_N].si, r1, r2);
r1 = r2;
r2 = array[i].si;
}
for (j = 0; j < 2 * SFMT_N - size; j++) {
pstate[j] = array[j + size - SFMT_N];
}
for (; i < size; i++, j++) {
mm_recursion(&array[i].si, array[i - SFMT_N].si,
array[i + SFMT_POS1 - SFMT_N].si, r1, r2);
r1 = r2;
r2 = array[i].si;
pstate[j] = array[i];
}
}
#endif
|
a3e4eca4cb354ba94c1d44d1eb738b93dad8712b
|
d066c77e614e6ef05b44eee0120e84588f8b9741
|
/RLogin/zm.h
|
878d8f6288f99930f4599b74d2fed2b7f5a5c9ec
|
[
"MIT"
] |
permissive
|
kmiya-culti/RLogin
|
7b01f2591fefbf22430ac9b0cca7b2093b463259
|
c4f120ad617857a27f96aedd210e1e8b680024ec
|
refs/heads/master
| 2023-08-25T20:03:45.341336
| 2023-08-03T22:10:00
| 2023-08-03T22:10:00
| 98,845,585
| 436
| 28
|
MIT
| 2021-03-23T14:55:33
| 2017-07-31T03:44:42
|
C++
|
UTF-8
|
C
| false
| false
| 5,367
|
h
|
zm.h
|
/*
* Z M O D E M . H Manifest constants for ZMODEM
* application to application file transfer protocol
* 04-17-89 Chuck Forsberg Omen Technology Inc
*/
#define ZPAD '*' /* 052 Padding character begins frames */
#define ZDLE 030 /* Ctrl-X Zmodem escape - `ala BISYNC DLE */
#define ZDLEE (ZDLE^0100) /* Escaped ZDLE as transmitted */
#define ZBIN 'A' /* Binary frame indicator (CRC-16) */
#define ZHEX 'B' /* HEX frame indicator */
#define ZBIN32 'C' /* Binary frame with 32 bit FCS */
#define ZBINR32 'D' /* RLE packed Binary frame with 32 bit FCS */
#define ZVBIN 'a' /* Binary frame indicator (CRC-16) */
#define ZVHEX 'b' /* HEX frame indicator */
#define ZVBIN32 'c' /* Binary frame with 32 bit FCS */
#define ZVBINR32 'd' /* RLE packed Binary frame with 32 bit FCS */
#define ZRESC 0176 /* RLE flag/escape character */
#define ZMAXHLEN 16 /* Max header information length NEVER CHANGE */
#define ZMAXSPLEN 1024 /* Max subpacket length NEVER CHANGE */
/* Frame types (see array "frametypes" in zm.c) */
#define ZRQINIT 0 /* Request receive init */
#define ZRINIT 1 /* Receive init */
#define ZSINIT 2 /* Send init sequence (optional) */
#define ZACK 3 /* ACK to above */
#define ZFILE 4 /* File name from sender */
#define ZSKIP 5 /* To sender: skip this file */
#define ZNAK 6 /* Last packet was garbled */
#define ZABORT 7 /* Abort batch transfers */
#define ZFIN 8 /* Finish session */
#define ZRPOS 9 /* Resume data trans at this position */
#define ZDATA 10 /* Data packet(s) follow */
#define ZEOF 11 /* End of file */
#define ZFERR 12 /* Fatal Read or Write error Detected */
#define ZCRC 13 /* Request for file CRC and response */
#define ZCHALLENGE 14 /* Receiver's Challenge */
#define ZCOMPL 15 /* Request is complete */
#define ZCAN 16 /* Other end canned session with CAN*5 */
#define ZFREECNT 17 /* Request for free bytes on filesystem */
#define ZCOMMAND 18 /* Command from sending program */
#define ZSTDERR 19 /* Output to standard error, data follows */
/* ZDLE sequences */
#define ZCRCE 'h' /* CRC next, frame ends, header packet follows */
#define ZCRCG 'i' /* CRC next, frame continues nonstop */
#define ZCRCQ 'j' /* CRC next, frame continues, ZACK expected */
#define ZCRCW 'k' /* CRC next, ZACK expected, end of frame */
#define ZRUB0 'l' /* Translate to rubout 0177 */
#define ZRUB1 'm' /* Translate to rubout 0377 */
/* zdlread return values (internal) */
/* -1 is general error, -2 is timeout */
#define GOTOR 0400
#define GOTCRCE (ZCRCE|GOTOR) /* ZDLE-ZCRCE received */
#define GOTCRCG (ZCRCG|GOTOR) /* ZDLE-ZCRCG received */
#define GOTCRCQ (ZCRCQ|GOTOR) /* ZDLE-ZCRCQ received */
#define GOTCRCW (ZCRCW|GOTOR) /* ZDLE-ZCRCW received */
#define GOTCAN (GOTOR|030) /* CAN*5 seen */
/* Byte positions within header array */
#define ZF0 3 /* First flags byte */
#define ZF1 2
#define ZF2 1
#define ZF3 0
#define ZP0 0 /* Low order 8 bits of position */
#define ZP1 1
#define ZP2 2
#define ZP3 3 /* High order 8 bits of file position */
/* Bit Masks for ZRINIT flags byte ZF0 */
#define CANFDX 01 /* Rx can send and receive true FDX */
#define CANOVIO 02 /* Rx can receive data during disk I/O */
#define CANBRK 04 /* Rx can send a break signal */
#define CANRLE 010 /* Receiver can decode RLE */
#define CANLZW 020 /* Receiver can uncompress */
#define CANFC32 040 /* Receiver can use 32 bit Frame Check */
#define ESCCTL 0100 /* Receiver expects ctl chars to be escaped */
#define ESC8 0200 /* Receiver expects 8th bit to be escaped */
/* Bit Masks for ZRINIT flags byte ZF1 */
#define CANVHDR 01 /* Variable headers OK */
/* Parameters for ZSINIT frame */
#define ZATTNLEN 32 /* Max length of attention string */
#define ALTCOFF ZF1 /* Offset to alternate canit string, 0 if not used */
/* Bit Masks for ZSINIT flags byte ZF0 */
#define TESCCTL 0100 /* Transmitter expects ctl chars to be escaped */
#define TESC8 0200 /* Transmitter expects 8th bit to be escaped */
/* Parameters for ZFILE frame */
/* Conversion options one of these in ZF0 */
#define ZCBIN 1 /* Binary transfer - inhibit conversion */
#define ZCNL 2 /* Convert NL to local end of line convention */
#define ZCRESUM 3 /* Resume interrupted file transfer */
/* Management include options, one of these ored in ZF1 */
#define ZMSKNOLOC 0200 /* Skip file if not present at rx */
/* Management options, one of these ored in ZF1 */
#define ZMMASK 037 /* Mask for the choices below */
#define ZMNEWL 1 /* Transfer if source newer or longer */
#define ZMCRC 2 /* Transfer if different file CRC or length */
#define ZMAPND 3 /* Append contents to existing file (if any) */
#define ZMCLOB 4 /* Replace existing file */
#define ZMNEW 5 /* Transfer if source newer */
/* Number 5 is alive ... */
#define ZMDIFF 6 /* Transfer if dates or lengths different */
#define ZMPROT 7 /* Protect destination file */
/* Transport options, one of these in ZF2 */
#define ZTLZW 1 /* Lempel-Ziv compression */
#define ZTRLE 3 /* Run Length encoding */
/* Extended options for ZF3, bit encoded */
#define ZXSPARS 64 /* Encoding for sparse file operations */
#define ZCANVHDR 01 /* Variable headers OK */
/* Parameters for ZCOMMAND frame ZF0 (otherwise 0) */
#define ZCACK1 1 /* Acknowledge, then do command */
/* End of ZMODEM.H */
|
d625aa4d0823d30b9b12a96e0abbc760706552f6
|
aa3befea459382dc5c01c925653d54f435b3fb0f
|
/include/sys/statfs.h
|
bf458b9be88e0daab8e58759994f0849c37b8748
|
[
"MIT-open-group",
"BSD-3-Clause",
"HPND-sell-variant",
"BSD-4-Clause-UC",
"LicenseRef-scancode-warranty-disclaimer",
"MIT-0",
"LicenseRef-scancode-bsd-atmel",
"LicenseRef-scancode-gary-s-brown",
"LicenseRef-scancode-proprietary-license",
"SunPro",
"MIT",
"LicenseRef-scancode-public-domain-disclaimer",
"LicenseRef-scancode-other-permissive",
"HPND",
"ISC",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"GPL-1.0-or-later",
"CC-BY-2.0",
"CC-BY-4.0"
] |
permissive
|
apache/nuttx
|
14519a7bff4a87935d94fb8fb2b19edb501c7cec
|
606b6d9310fb25c7d92c6f95bf61737e3c79fa0f
|
refs/heads/master
| 2023-08-25T06:55:45.822534
| 2023-08-23T16:03:31
| 2023-08-24T21:25:47
| 228,103,273
| 407
| 241
|
Apache-2.0
| 2023-09-14T18:26:05
| 2019-12-14T23:27:55
|
C
|
UTF-8
|
C
| false
| false
| 5,397
|
h
|
statfs.h
|
/****************************************************************************
* include/sys/statfs.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
*
* 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 __INCLUDE_SYS_STATFS_H
#define __INCLUDE_SYS_STATFS_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <stdint.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* struct statfs file system types. */
#define ADFS_SUPER_MAGIC 0xadf5
#define AFFS_SUPER_MAGIC 0xadff
#define BEFS_SUPER_MAGIC 0x42465331
#define BFS_MAGIC 0x1badface
#define CIFS_MAGIC_NUMBER 0xff534d42
#define CODA_SUPER_MAGIC 0x73757245
#define COH_SUPER_MAGIC 0x012ff7b7
#define CRAMFS_MAGIC 0x28cd3d45
#define DEVFS_SUPER_MAGIC 0x1373
#define EFS_SUPER_MAGIC 0x00414a53
#define EXT_SUPER_MAGIC 0x137d
#define EXT2_OLD_SUPER_MAGIC 0xef51
#define EXT2_SUPER_MAGIC 0xef53
#define EXT3_SUPER_MAGIC 0xef53
#define HFS_SUPER_MAGIC 0x4244
#define HPFS_SUPER_MAGIC 0xf995e849
#define HUGETLBFS_MAGIC 0x958458f6
#define ISOFS_SUPER_MAGIC 0x9660
#define JFFS2_SUPER_MAGIC 0x72b6
#define JFS_SUPER_MAGIC 0x3153464a
#define MINIX_SUPER_MAGIC 0x137f /* orig. minix */
#define MINIX_SUPER_MAGIC2 0x138f /* 30 char minix */
#define MINIX2_SUPER_MAGIC 0x2468 /* minix V2 */
#define MINIX2_SUPER_MAGIC2 0x2478 /* minix V2, 30 char names */
#define MSDOS_SUPER_MAGIC 0x4d44
#define NCP_SUPER_MAGIC 0x564c
#define NFS_SUPER_MAGIC 0x6969
#define NTFS_SB_MAGIC 0x5346544e
#define OPENPROM_SUPER_MAGIC 0x9fa1
#define PROC_SUPER_MAGIC 0x9fa0
#define QNX4_SUPER_MAGIC 0x002f
#define REISERFS_SUPER_MAGIC 0x52654973
#define ROMFS_MAGIC 0x7275
#define SMB_SUPER_MAGIC 0x517B
#define SYSV2_SUPER_MAGIC 0x012ff7b6
#define SYSV4_SUPER_MAGIC 0x012FF7B5
#define TMPFS_MAGIC 0x01021994
#define UDF_SUPER_MAGIC 0x15013346
#define UFS_MAGIC 0x00011954
#define USBDEVICE_SUPER_MAGIC 0x9fa2
#define VXFS_SUPER_MAGIC 0xa501fcf5
#define XENIX_SUPER_MAGIC 0x012ff7b4
#define XFS_SUPER_MAGIC 0x58465342
#define _XIAFS_SUPER_MAGIC 0x012fd16d
#define SPIFFS_SUPER_MAGIC 0x20090315
#define LITTLEFS_SUPER_MAGIC 0x0a732923
/* NuttX specific file-systems */
#define BINFS_MAGIC 0x4242
#define PROCFS_MAGIC 0x434f5250
#define NXFFS_MAGIC 0x4747
#define SMARTFS_MAGIC 0x54524D53
#define UNIONFS_MAGIC 0x53464e55
#define HOSTFS_MAGIC 0x54534f48
#define USERFS_MAGIC 0x52455355
#define CROMFS_MAGIC 0x4d4f5243
#define RPMSGFS_MAGIC 0x54534f47
#if defined(CONFIG_FS_LARGEFILE)
# define statfs64 statfs
# define fstatfs64 fstatfs
#endif
/****************************************************************************
* Type Definitions
****************************************************************************/
typedef struct fsid_s fsid_t;
struct statfs
{
uint32_t f_type; /* Type of filesystem (see definitions above) */
size_t f_namelen; /* Maximum length of filenames */
size_t f_bsize; /* Optimal block size for transfers */
fsblkcnt_t f_blocks; /* Total data blocks in the file system of this size */
fsblkcnt_t f_bfree; /* Free blocks in the file system */
fsblkcnt_t f_bavail; /* Free blocks avail to non-superuser */
fsfilcnt_t f_files; /* Total file nodes in the file system */
fsfilcnt_t f_ffree; /* Free file nodes in the file system */
fsid_t f_fsid; /* Encode device type, not yet in use */
};
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/* Inspired by Linux statfs() which was, in turn, inspired by
* the BSD statfs(). None of these implementations agree in the
* form of the struct statfs.
*/
int statfs(FAR const char *path, FAR struct statfs *buf);
int fstatfs(int fd, FAR struct statfs *buf);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __INCLUDE_SYS_STATFS_H */
|
e0f5af709e3a6e2153046923c765fc5a6569935e
|
55540f3e86f1d5d86ef6b5d295a63518e274efe3
|
/components/platform/soc/bl808/bl808_std/BSP_Common/lcd/lcd.c
|
4718191825939b1ce5f071506b14e5f08cea1875
|
[
"Apache-2.0"
] |
permissive
|
bouffalolab/bl_iot_sdk
|
bc5eaf036b70f8c65dd389439062b169f8d09daa
|
b90664de0bd4c1897a9f1f5d9e360a9631d38b34
|
refs/heads/master
| 2023-08-31T03:38:03.369853
| 2023-08-16T08:50:33
| 2023-08-18T09:13:27
| 307,347,250
| 244
| 101
|
Apache-2.0
| 2023-08-28T06:29:02
| 2020-10-26T11:16:30
|
C
|
UTF-8
|
C
| false
| false
| 16,384
|
c
|
lcd.c
|
/*
* Copyright (c) 2016-2023 Bouffalolab.
*
* This file is part of
* *** Bouffalolab Software Dev Kit ***
* (see www.bouffalolab.com).
*
* 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 Bouffalo Lab 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.
*/
#include "lcd.h"
#include "font.h"
#include "bflb_platform.h"
//#include "drv_device.h"
struct device *lcd_dev_ifs = NULL;
struct device *lcd_dev_ifs_dma = NULL;
uint8_t lcd_dir = 0;
uint16_t lcd_max_x = LCD_W - 1, lcd_max_y = LCD_H - 1;
/* MCU LCD Common interface */
#if (LCD_INTERFACE_TYPE == LCD_INTERFACE_DBI) || (LCD_INTERFACE_TYPE == LCD_INTERFACE_SPI)
/**
* @brief LCD init
*
* @return int
*/
int lcd_init(void)
{
int res;
res = _LCD_FUNC_DEFINE(init);
lcd_dev_ifs = device_find("lcd_dev_ifs");
lcd_dev_ifs_dma = device_find("lcd_dev_ifs_dma");
return res;
}
int lcd_async_callback_register(void (*callback)(void))
{
_LCD_FUNC_DEFINE(async_callback_register, callback);
return 0;
}
/**
* @brief Set display direction and mir
*
* @param dir 0~3 : 0~270 Angle
* @param mir_flag 0:normal 1:Horizontal Mirroring(if support)
* @return int
*/
int lcd_set_dir(uint8_t dir, uint8_t mir_flag)
{
dir %= 4;
lcd_dir = dir;
if (dir == 0 || dir == 2) {
lcd_max_x = LCD_W - 1;
lcd_max_y = LCD_H - 1;
} else {
lcd_max_x = LCD_H - 1;
lcd_max_y = LCD_W - 1;
}
return _LCD_FUNC_DEFINE(set_dir, dir, mir_flag);
}
/**
* @brief Draws a point at the specified position
*
* @param x X coordinate
* @param y Y coordinate
* @param color
* @return int
*/
int lcd_draw_point(uint16_t x, uint16_t y, lcd_color_t color)
{
_LCD_FUNC_DEFINE(draw_point, x, y, color);
return 0;
}
/**
* @brief Draw a monochrome rectangle (May be less efficient)
*
* @param x1 start coordinate
* @param y1 start coordinate
* @param x2 end coordinate
* @param y2 end coordinate
* @param color
* @return int
*/
int lcd_draw_area(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, lcd_color_t color)
{
_LCD_FUNC_DEFINE(draw_area, x1, y1, x2, y2, color);
return 0;
}
/**
* @brief Draw a picture in the designated area(blocking),Will wait for the drawing to finish
*
* @param x1 start coordinate
* @param y1 start coordinate
* @param x2 end coordinate
* @param y2 end coordinate
* @param picture
* @return int
*/
int lcd_draw_picture_blocking(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, lcd_color_t *picture)
{
_LCD_FUNC_DEFINE(draw_picture_blocking, x1, y1, x2, y2, picture);
return 0;
}
/**
* @brief Draw a picture in the designated area(nonblocking,if it supports),
* Must be calle lcd_draw_is_busy! and (lcd_draw_is_busyd()==1) before performing other drawing and changing picture data!
*
* @param x1 start coordinate
* @param y1 start coordinate
* @param x2 end coordinate
* @param y2 end coordinate
* @param picture
* @return int
*/
int lcd_draw_picture_nonblocking(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, lcd_color_t *picture)
{
_LCD_FUNC_DEFINE(draw_picture_nonblocking, x1, y1, x2, y2, picture);
return 0;
}
/**
* @brief Check if it is drawing, must call it After call lcd_draw_picture_nonblocking
*
* @return int 1:lcd Drawing,Prohibit other operations! 0:Drawing is over
*/
int lcd_draw_is_busy(void)
{
return _LCD_FUNC_DEFINE(draw_is_busy);
}
/**
* @brief clear lcd
*
* @param color
* @return int
*/
int lcd_clear(lcd_color_t color)
{
lcd_draw_area(0, 0, lcd_max_x, lcd_max_y, color);
return 0;
}
/**
* @brief
*
* @param x1 start coordinate
* @param y1 start coordinate
* @param x2 end coordinate
* @param y2 end coordinate
* @param color
* @return int
*/
int lcd_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, lcd_color_t color)
{
int xVariation, yVariation, temp;
int absX, absY, i;
xVariation = x2 - x1;
yVariation = y2 - y1;
absX = ABS(xVariation);
absY = ABS(yVariation);
if (absX > absY) {
for (i = 0; i < absX + 1; i++) {
temp = yVariation * 100 / absX * i / 100;
if (xVariation > 0) {
lcd_draw_point(x1 + i, y1 + temp, color);
} else {
lcd_draw_point(x1 - i, y1 + temp, color);
}
}
} else {
for (i = 0; i < absY + 1; i++) {
temp = xVariation * 100 / absY * i / 100;
if (yVariation > 0) {
lcd_draw_point(x1 + temp, y1 + i, color);
} else {
lcd_draw_point(x1 + temp, y1 - i, color);
}
}
}
return 0;
}
/**
* @brief
*
* @param x1 start coordinate
* @param y1 start coordinate
* @param x2 end coordinate
* @param y2 end coordinate
* @param color
* @return int
*/
int lcd_draw_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, lcd_color_t color)
{
lcd_draw_line(x1, y1, x2, y1, color);
lcd_draw_line(x2, y1, x2, y2, color);
lcd_draw_line(x2, y2, x1, y2, color);
lcd_draw_line(x1, y2, x1, y1, color);
return 0;
}
/**
* @brief draw a circle
*
* @param x coordinate
* @param y coordinate
* @param r
* @param color
* @return int
*/
int lcd_draw_circle(uint16_t x, uint16_t y, uint16_t r, lcd_color_t color)
{
int a = 0, b;
int di;
b = r;
di = 3 - (r << 1);
while (a <= b) {
lcd_draw_point(x - b, y - a, color);
lcd_draw_point(x + b, y - a, color);
lcd_draw_point(x - a, y + b, color);
lcd_draw_point(x - b, y - a, color);
lcd_draw_point(x - a, y - b, color);
lcd_draw_point(x + b, y + a, color);
lcd_draw_point(x + a, y - b, color);
lcd_draw_point(x + a, y + b, color);
lcd_draw_point(x - b, y + a, color);
a++;
if (di < 0) {
di += 4 * a + 6;
} else {
di += 10 + 4 * (a - b);
b--;
}
lcd_draw_point(x + a, y + b, color);
}
return 0;
}
#if FONT_ASCII_16X8
/**
* @brief Draw font(16*8) ,Use double buffer to speed up drawing
*
* @param x start coordinate
* @param y start coordinate
* @param color font color
* @param bk_color Background color
* @param str The string to be displayed
* @param num number of characters displayed
* @return int
*/
int lcd_draw_str_ascii16(uint16_t x, uint16_t y, lcd_color_t color, lcd_color_t bk_color, uint8_t *str, uint8_t num)
{
lcd_color_t draw_buff[2][16 * 8];
uint16_t buff_color_num;
uint8_t buff_using_num = 0;
uint8_t ch, temp;
uint16_t x0 = x;
for (uint16_t i = 0; i < num && str[i]; i++) {
if (str[i] < 128) {
// if (x > LCD_W - 8) {
// x = x0;
// y += 16;
// }
if (x > LCD_W - 8 || y > LCD_H - 16)
break;
ch = str[i];
if (ch >= ' ') {
ch = ch - ' ';
} else if (ch == '\n') {
x = x0;
y += 16;
continue;
} else {
continue;
}
buff_color_num = 0;
for (uint8_t j = 0; j < 16; j++) {
temp = font_ascii_16x8[ch * 16 + j];
for (uint8_t k = 0; k < 8; k++) {
if (temp & (0x80 >> k))
draw_buff[buff_using_num][buff_color_num++] = color;
else
draw_buff[buff_using_num][buff_color_num++] = bk_color;
}
}
while (lcd_draw_is_busy()) {
};
lcd_draw_picture_nonblocking(x, y, x + 7, y + 15, draw_buff[buff_using_num]);
buff_using_num = !buff_using_num;
x += 8;
} else {
continue;
}
}
while (lcd_draw_is_busy()) {
};
return 0;
}
#endif
/* RGB LCD Common interface */
#elif (LCD_INTERFACE_TYPE == LCD_INTERFACE_DPI) || (LCD_INTERFACE_TYPE == LCD_INTERFACE_DSI_VIDIO)
/**
* @brief lcd_dpi_init
*
* @param screen_buffer First screen memory
* @return int
*/
int lcd_init(lcd_color_t *screen_buffer)
{
return _LCD_FUNC_DEFINE(init, screen_buffer);
}
/**
* @brief Switch the screen, If it is in single-screen mode, there is no effect
*
* @param screen_id screen id
* @return int
*/
int lcd_screen_switch(lcd_color_t *screen_buffer)
{
return _LCD_FUNC_DEFINE(screen_switch, screen_buffer);
}
/**
* @brief Gets the id of the screen in use
*
* @return int screen id
*/
lcd_color_t *lcd_get_screen_using(void)
{
return _LCD_FUNC_DEFINE(get_screen_using);
}
int lcd_frame_callback_register(uint32_t callback_type, void (*callback)(void))
{
return _LCD_FUNC_DEFINE(frame_callback_register, callback_type, callback);
}
int lcd_draw_point(lcd_color_t *screen_buffer, uint16_t x, uint16_t y, lcd_color_t color)
{
if (screen_buffer == NULL) {
return -1;
} else if (x >= LCD_W || y >= LCD_H) {
return -2;
}
screen_buffer[x * LCD_W + y] = color;
return 0;
}
int lcd_draw_area(lcd_color_t *screen_buffer, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, lcd_color_t color)
{
if (screen_buffer == NULL) {
return -1;
} else if (x1 >= LCD_W || y1 >= LCD_H) {
return -2;
}
screen_buffer += y1 * LCD_W;
x2 = (x2 < LCD_W) ? x2 : (LCD_W - 1);
y2 = (y2 < LCD_H) ? y2 : (LCD_H - 1);
for (uint16_t i = y1; i <= y2; i++) {
for (uint16_t j = x1; j <= x2; j++) {
screen_buffer[j] = color;
}
screen_buffer += LCD_W;
}
return 0;
}
int lcd_clear(lcd_color_t *screen_buffer, lcd_color_t color)
{
if (screen_buffer == NULL) {
return -1;
}
return lcd_draw_area(screen_buffer, 0, 0, LCD_W, LCD_H, color);
}
int lcd_draw_picture(lcd_color_t *screen_buffer, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, lcd_color_t *picture)
{
if (screen_buffer == NULL) {
return -1;
} else if (x1 >= LCD_W || y1 >= LCD_H || x2 >= LCD_W || y2 >= LCD_H) {
return -2;
}
screen_buffer += y1 * LCD_W;
for (uint16_t i = y1; i <= y2; i++) {
for (uint16_t j = x1; j <= x2; j++) {
screen_buffer[j] = *picture;
picture++;
}
screen_buffer += LCD_W;
}
return 0;
}
int lcd_draw_line(lcd_color_t *screen_buffer, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, lcd_color_t color)
{
if (screen_buffer == NULL) {
return -1;
} else if (x1 >= LCD_W || y1 >= LCD_H || x2 >= LCD_W || y2 >= LCD_H) {
return -2;
}
if (x1 == x2) {
if (y1 > y2) {
uint16_t a = y1;
y1 = y2;
y2 = a;
}
screen_buffer += y1 * LCD_W;
for (; y1 <= y2; y1++) {
screen_buffer[x1] = color;
screen_buffer += LCD_W;
}
} else if (y1 == y2) {
if (x1 > x2) {
uint16_t b = x1;
x1 = x2;
x2 = b;
}
screen_buffer += y1 * LCD_W;
for (; x1 <= x2; x1++) {
screen_buffer[x1] = color;
}
} else {
int xVariation, yVariation, temp;
int absX, absY, i;
xVariation = x2 - x1;
yVariation = y2 - y1;
absX = ABS(xVariation);
absY = ABS(yVariation);
if (absX > absY) {
for (i = 0; i < absX + 1; i++) {
temp = yVariation * 100 / absX * i / 100;
if (xVariation > 0) {
screen_buffer[(x1 + i) * LCD_W + (y1 + temp)] = color;
} else {
screen_buffer[(x1 - i) * LCD_W + (y1 + temp)] = color;
}
}
} else {
for (i = 0; i < absY + 1; i++) {
temp = xVariation * 100 / absY * i / 100;
if (yVariation > 0) {
screen_buffer[(x1 + i) * LCD_W + (y1 + temp)] = color;
} else {
screen_buffer[(x1 + i) * LCD_W + (y1 - temp)] = color;
}
}
}
}
return 0;
}
int lcd_draw_rectangle(lcd_color_t *screen_buffer, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, lcd_color_t color)
{
lcd_draw_line(screen_buffer, x1, y1, x2, y1, color);
lcd_draw_line(screen_buffer, x2, y1, x2, y2, color);
lcd_draw_line(screen_buffer, x2, y2, x1, y2, color);
lcd_draw_line(screen_buffer, x1, y2, x1, y1, color);
return 0;
}
int lcd_draw_circle(lcd_color_t *screen_buffer, uint16_t x, uint16_t y, uint16_t r, lcd_color_t color)
{
int a = 0, b;
int di;
b = r;
di = 1 - r;
while (a <= b) {
screen_buffer[(x - b) * LCD_W + (y - a)] = color;
screen_buffer[(x + b) * LCD_W + (y - a)] = color;
screen_buffer[(x - a) * LCD_W + (y + b)] = color;
screen_buffer[(x - b) * LCD_W + (y - a)] = color;
screen_buffer[(x - a) * LCD_W + (y - b)] = color;
screen_buffer[(x + b) * LCD_W + (y + a)] = color;
screen_buffer[(x + a) * LCD_W + (y - b)] = color;
screen_buffer[(x + a) * LCD_W + (y + b)] = color;
screen_buffer[(x - b) * LCD_W + (y + a)] = color;
a++;
if (di < 0) {
di += (a << 1) + 3;
} else {
di += ((a - b) << 1) + 5;
b--;
}
}
return 0;
}
#if FONT_ASCII_16X8
/**
* @brief Draw font(16*8)
*
* @param x start coordinate
* @param y start coordinate
* @param color font color
* @param bk_color Background color
* @param str The string to be displayed
* @param num number of characters displayed
* @return int
*/
int lcd_draw_str_ascii16(lcd_color_t *screen_buffer, uint16_t x, uint16_t y, lcd_color_t color, lcd_color_t bk_color, uint8_t *str, uint8_t num)
{
lcd_color_t draw_buff[16 * 8];
uint16_t buff_color_num;
uint8_t ch, temp;
uint16_t x0 = x;
for (uint16_t i = 0; i < num && str[i]; i++) {
if (str[i] < 128) {
// if (x > LCD_W - 8) {
// x = x0;
// y += 16;
// }
if (x > LCD_W - 8 || y > LCD_H - 16)
break;
ch = str[i];
if (ch >= ' ') {
ch = ch - ' ';
} else if (ch == '\n') {
x = x0;
y += 16;
continue;
} else {
continue;
}
buff_color_num = 0;
for (uint8_t j = 0; j < 16; j++) {
temp = font_ascii_16x8[ch * 16 + j];
for (uint8_t k = 0; k < 8; k++) {
if (temp & (0x80 >> k))
draw_buff[buff_color_num++] = color;
else
draw_buff[buff_color_num++] = bk_color;
}
}
lcd_draw_picture(screen_buffer, x, y, x + 7, y + 15, draw_buff);
x += 8;
} else {
continue;
}
}
return 0;
}
#endif
#endif
|
f253ba495731f1282b7cbccbf9471897dbfc2005
|
7d232f51e2330a4f537c50ede9c6bc023d656fd4
|
/src/core/lib/transport/status_conversion.h
|
83a68d62d2652c456a83ba664d26c243f0bf8cb5
|
[
"BSD-3-Clause",
"MPL-2.0",
"Apache-2.0"
] |
permissive
|
grpc/grpc
|
6975af3ba6f07a6fe965b875a0c09abf18999a52
|
e4d598ab64aa54f1da78c6ed6133b741742d11d4
|
refs/heads/master
| 2023-08-31T01:10:22.666618
| 2023-08-30T22:35:17
| 2023-08-30T22:35:17
| 27,729,880
| 42,330
| 13,022
|
Apache-2.0
| 2023-09-14T21:54:19
| 2014-12-08T18:58:53
|
C++
|
UTF-8
|
C
| false
| false
| 1,425
|
h
|
status_conversion.h
|
//
//
// Copyright 2015 gRPC authors.
//
// 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 GRPC_SRC_CORE_LIB_TRANSPORT_STATUS_CONVERSION_H
#define GRPC_SRC_CORE_LIB_TRANSPORT_STATUS_CONVERSION_H
#include <grpc/support/port_platform.h>
#include <grpc/status.h>
#include "src/core/lib/gprpp/time.h"
#include "src/core/lib/transport/http2_errors.h"
// Conversion of grpc status codes to http2 error codes (for RST_STREAM)
grpc_http2_error_code grpc_status_to_http2_error(grpc_status_code status);
grpc_status_code grpc_http2_error_to_grpc_status(grpc_http2_error_code error,
grpc_core::Timestamp deadline);
// Conversion of HTTP status codes (:status) to grpc status codes
grpc_status_code grpc_http2_status_to_grpc_status(int status);
int grpc_status_to_http2_status(grpc_status_code status);
#endif // GRPC_SRC_CORE_LIB_TRANSPORT_STATUS_CONVERSION_H
|
73a45774c582a5f2eba404965cafdaa17957c8a9
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/drivers/pinctrl/pinctrl-sirf.c
|
bc9d1be27fb09c49ed52ba972c055605af4ff19a
|
[
"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
| 48,483
|
c
|
pinctrl-sirf.c
|
/*
* pinmux driver for CSR SiRFprimaII
*
* Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company.
*
* Licensed under GPLv2 or later.
*/
#include <linux/init.h>
#include <linux/module.h>
#include <linux/irq.h>
#include <linux/platform_device.h>
#include <linux/io.h>
#include <linux/slab.h>
#include <linux/err.h>
#include <linux/irqdomain.h>
#include <linux/irqchip/chained_irq.h>
#include <linux/pinctrl/pinctrl.h>
#include <linux/pinctrl/pinmux.h>
#include <linux/pinctrl/consumer.h>
#include <linux/pinctrl/machine.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/of_platform.h>
#include <linux/bitops.h>
#include <linux/gpio.h>
#include <linux/of_gpio.h>
#define DRIVER_NAME "pinmux-sirf"
#define SIRFSOC_NUM_PADS 622
#define SIRFSOC_RSC_PIN_MUX 0x4
#define SIRFSOC_GPIO_PAD_EN(g) ((g)*0x100 + 0x84)
#define SIRFSOC_GPIO_PAD_EN_CLR(g) ((g)*0x100 + 0x90)
#define SIRFSOC_GPIO_CTRL(g, i) ((g)*0x100 + (i)*4)
#define SIRFSOC_GPIO_DSP_EN0 (0x80)
#define SIRFSOC_GPIO_INT_STATUS(g) ((g)*0x100 + 0x8C)
#define SIRFSOC_GPIO_CTL_INTR_LOW_MASK 0x1
#define SIRFSOC_GPIO_CTL_INTR_HIGH_MASK 0x2
#define SIRFSOC_GPIO_CTL_INTR_TYPE_MASK 0x4
#define SIRFSOC_GPIO_CTL_INTR_EN_MASK 0x8
#define SIRFSOC_GPIO_CTL_INTR_STS_MASK 0x10
#define SIRFSOC_GPIO_CTL_OUT_EN_MASK 0x20
#define SIRFSOC_GPIO_CTL_DATAOUT_MASK 0x40
#define SIRFSOC_GPIO_CTL_DATAIN_MASK 0x80
#define SIRFSOC_GPIO_CTL_PULL_MASK 0x100
#define SIRFSOC_GPIO_CTL_PULL_HIGH 0x200
#define SIRFSOC_GPIO_CTL_DSP_INT 0x400
#define SIRFSOC_GPIO_NO_OF_BANKS 5
#define SIRFSOC_GPIO_BANK_SIZE 32
#define SIRFSOC_GPIO_NUM(bank, index) (((bank)*(32)) + (index))
struct sirfsoc_gpio_bank {
struct of_mm_gpio_chip chip;
struct irq_domain *domain;
int id;
int parent_irq;
spinlock_t lock;
bool is_marco; /* for marco, some registers are different with prima2 */
};
static struct sirfsoc_gpio_bank sgpio_bank[SIRFSOC_GPIO_NO_OF_BANKS];
static DEFINE_SPINLOCK(sgpio_lock);
/*
* pad list for the pinmux subsystem
* refer to CS-131858-DC-6A.xls
*/
static const struct pinctrl_pin_desc sirfsoc_pads[] = {
PINCTRL_PIN(0, "gpio0-0"),
PINCTRL_PIN(1, "gpio0-1"),
PINCTRL_PIN(2, "gpio0-2"),
PINCTRL_PIN(3, "gpio0-3"),
PINCTRL_PIN(4, "pwm0"),
PINCTRL_PIN(5, "pwm1"),
PINCTRL_PIN(6, "pwm2"),
PINCTRL_PIN(7, "pwm3"),
PINCTRL_PIN(8, "warm_rst_b"),
PINCTRL_PIN(9, "odo_0"),
PINCTRL_PIN(10, "odo_1"),
PINCTRL_PIN(11, "dr_dir"),
PINCTRL_PIN(12, "viprom_fa"),
PINCTRL_PIN(13, "scl_1"),
PINCTRL_PIN(14, "ntrst"),
PINCTRL_PIN(15, "sda_1"),
PINCTRL_PIN(16, "x_ldd[16]"),
PINCTRL_PIN(17, "x_ldd[17]"),
PINCTRL_PIN(18, "x_ldd[18]"),
PINCTRL_PIN(19, "x_ldd[19]"),
PINCTRL_PIN(20, "x_ldd[20]"),
PINCTRL_PIN(21, "x_ldd[21]"),
PINCTRL_PIN(22, "x_ldd[22]"),
PINCTRL_PIN(23, "x_ldd[23], lcdrom_frdy"),
PINCTRL_PIN(24, "gps_sgn"),
PINCTRL_PIN(25, "gps_mag"),
PINCTRL_PIN(26, "gps_clk"),
PINCTRL_PIN(27, "sd_cd_b_1"),
PINCTRL_PIN(28, "sd_vcc_on_1"),
PINCTRL_PIN(29, "sd_wp_b_1"),
PINCTRL_PIN(30, "sd_clk_3"),
PINCTRL_PIN(31, "sd_cmd_3"),
PINCTRL_PIN(32, "x_sd_dat_3[0]"),
PINCTRL_PIN(33, "x_sd_dat_3[1]"),
PINCTRL_PIN(34, "x_sd_dat_3[2]"),
PINCTRL_PIN(35, "x_sd_dat_3[3]"),
PINCTRL_PIN(36, "x_sd_clk_4"),
PINCTRL_PIN(37, "x_sd_cmd_4"),
PINCTRL_PIN(38, "x_sd_dat_4[0]"),
PINCTRL_PIN(39, "x_sd_dat_4[1]"),
PINCTRL_PIN(40, "x_sd_dat_4[2]"),
PINCTRL_PIN(41, "x_sd_dat_4[3]"),
PINCTRL_PIN(42, "x_cko_1"),
PINCTRL_PIN(43, "x_ac97_bit_clk"),
PINCTRL_PIN(44, "x_ac97_dout"),
PINCTRL_PIN(45, "x_ac97_din"),
PINCTRL_PIN(46, "x_ac97_sync"),
PINCTRL_PIN(47, "x_txd_1"),
PINCTRL_PIN(48, "x_txd_2"),
PINCTRL_PIN(49, "x_rxd_1"),
PINCTRL_PIN(50, "x_rxd_2"),
PINCTRL_PIN(51, "x_usclk_0"),
PINCTRL_PIN(52, "x_utxd_0"),
PINCTRL_PIN(53, "x_urxd_0"),
PINCTRL_PIN(54, "x_utfs_0"),
PINCTRL_PIN(55, "x_urfs_0"),
PINCTRL_PIN(56, "x_usclk_1"),
PINCTRL_PIN(57, "x_utxd_1"),
PINCTRL_PIN(58, "x_urxd_1"),
PINCTRL_PIN(59, "x_utfs_1"),
PINCTRL_PIN(60, "x_urfs_1"),
PINCTRL_PIN(61, "x_usclk_2"),
PINCTRL_PIN(62, "x_utxd_2"),
PINCTRL_PIN(63, "x_urxd_2"),
PINCTRL_PIN(64, "x_utfs_2"),
PINCTRL_PIN(65, "x_urfs_2"),
PINCTRL_PIN(66, "x_df_we_b"),
PINCTRL_PIN(67, "x_df_re_b"),
PINCTRL_PIN(68, "x_txd_0"),
PINCTRL_PIN(69, "x_rxd_0"),
PINCTRL_PIN(78, "x_cko_0"),
PINCTRL_PIN(79, "x_vip_pxd[7]"),
PINCTRL_PIN(80, "x_vip_pxd[6]"),
PINCTRL_PIN(81, "x_vip_pxd[5]"),
PINCTRL_PIN(82, "x_vip_pxd[4]"),
PINCTRL_PIN(83, "x_vip_pxd[3]"),
PINCTRL_PIN(84, "x_vip_pxd[2]"),
PINCTRL_PIN(85, "x_vip_pxd[1]"),
PINCTRL_PIN(86, "x_vip_pxd[0]"),
PINCTRL_PIN(87, "x_vip_vsync"),
PINCTRL_PIN(88, "x_vip_hsync"),
PINCTRL_PIN(89, "x_vip_pxclk"),
PINCTRL_PIN(90, "x_sda_0"),
PINCTRL_PIN(91, "x_scl_0"),
PINCTRL_PIN(92, "x_df_ry_by"),
PINCTRL_PIN(93, "x_df_cs_b[1]"),
PINCTRL_PIN(94, "x_df_cs_b[0]"),
PINCTRL_PIN(95, "x_l_pclk"),
PINCTRL_PIN(96, "x_l_lck"),
PINCTRL_PIN(97, "x_l_fck"),
PINCTRL_PIN(98, "x_l_de"),
PINCTRL_PIN(99, "x_ldd[0]"),
PINCTRL_PIN(100, "x_ldd[1]"),
PINCTRL_PIN(101, "x_ldd[2]"),
PINCTRL_PIN(102, "x_ldd[3]"),
PINCTRL_PIN(103, "x_ldd[4]"),
PINCTRL_PIN(104, "x_ldd[5]"),
PINCTRL_PIN(105, "x_ldd[6]"),
PINCTRL_PIN(106, "x_ldd[7]"),
PINCTRL_PIN(107, "x_ldd[8]"),
PINCTRL_PIN(108, "x_ldd[9]"),
PINCTRL_PIN(109, "x_ldd[10]"),
PINCTRL_PIN(110, "x_ldd[11]"),
PINCTRL_PIN(111, "x_ldd[12]"),
PINCTRL_PIN(112, "x_ldd[13]"),
PINCTRL_PIN(113, "x_ldd[14]"),
PINCTRL_PIN(114, "x_ldd[15]"),
};
/**
* @dev: a pointer back to containing device
* @virtbase: the offset to the controller in virtual memory
*/
struct sirfsoc_pmx {
struct device *dev;
struct pinctrl_dev *pmx;
void __iomem *gpio_virtbase;
void __iomem *rsc_virtbase;
bool is_marco;
};
/* SIRFSOC_GPIO_PAD_EN set */
struct sirfsoc_muxmask {
unsigned long group;
unsigned long mask;
};
struct sirfsoc_padmux {
unsigned long muxmask_counts;
const struct sirfsoc_muxmask *muxmask;
/* RSC_PIN_MUX set */
unsigned long funcmask;
unsigned long funcval;
};
/**
* struct sirfsoc_pin_group - describes a SiRFprimaII pin group
* @name: the name of this specific pin group
* @pins: an array of discrete physical pins used in this group, taken
* from the driver-local pin enumeration space
* @num_pins: the number of pins in this group array, i.e. the number of
* elements in .pins so we can iterate over that array
*/
struct sirfsoc_pin_group {
const char *name;
const unsigned int *pins;
const unsigned num_pins;
};
static const struct sirfsoc_muxmask lcd_16bits_sirfsoc_muxmask[] = {
{
.group = 3,
.mask = BIT(0) | BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(5) | BIT(6) | BIT(7) | BIT(8) |
BIT(9) | BIT(10) | BIT(11) | BIT(12) | BIT(13) | BIT(14) | BIT(15) | BIT(16) |
BIT(17) | BIT(18),
}, {
.group = 2,
.mask = BIT(31),
},
};
static const struct sirfsoc_padmux lcd_16bits_padmux = {
.muxmask_counts = ARRAY_SIZE(lcd_16bits_sirfsoc_muxmask),
.muxmask = lcd_16bits_sirfsoc_muxmask,
.funcmask = BIT(4),
.funcval = 0,
};
static const unsigned lcd_16bits_pins[] = { 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112, 113, 114 };
static const struct sirfsoc_muxmask lcd_18bits_muxmask[] = {
{
.group = 3,
.mask = BIT(0) | BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(5) | BIT(6) | BIT(7) | BIT(8) |
BIT(9) | BIT(10) | BIT(11) | BIT(12) | BIT(13) | BIT(14) | BIT(15) | BIT(16) |
BIT(17) | BIT(18),
}, {
.group = 2,
.mask = BIT(31),
}, {
.group = 0,
.mask = BIT(16) | BIT(17),
},
};
static const struct sirfsoc_padmux lcd_18bits_padmux = {
.muxmask_counts = ARRAY_SIZE(lcd_18bits_muxmask),
.muxmask = lcd_18bits_muxmask,
.funcmask = BIT(4),
.funcval = 0,
};
static const unsigned lcd_18bits_pins[] = { 16, 17, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112, 113, 114};
static const struct sirfsoc_muxmask lcd_24bits_muxmask[] = {
{
.group = 3,
.mask = BIT(0) | BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(5) | BIT(6) | BIT(7) | BIT(8) |
BIT(9) | BIT(10) | BIT(11) | BIT(12) | BIT(13) | BIT(14) | BIT(15) | BIT(16) |
BIT(17) | BIT(18),
}, {
.group = 2,
.mask = BIT(31),
}, {
.group = 0,
.mask = BIT(16) | BIT(17) | BIT(18) | BIT(19) | BIT(20) | BIT(21) | BIT(22) | BIT(23),
},
};
static const struct sirfsoc_padmux lcd_24bits_padmux = {
.muxmask_counts = ARRAY_SIZE(lcd_24bits_muxmask),
.muxmask = lcd_24bits_muxmask,
.funcmask = BIT(4),
.funcval = 0,
};
static const unsigned lcd_24bits_pins[] = { 16, 17, 18, 19, 20, 21, 22, 23, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112, 113, 114 };
static const struct sirfsoc_muxmask lcdrom_muxmask[] = {
{
.group = 3,
.mask = BIT(0) | BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(5) | BIT(6) | BIT(7) | BIT(8) |
BIT(9) | BIT(10) | BIT(11) | BIT(12) | BIT(13) | BIT(14) | BIT(15) | BIT(16) |
BIT(17) | BIT(18),
}, {
.group = 2,
.mask = BIT(31),
}, {
.group = 0,
.mask = BIT(23),
},
};
static const struct sirfsoc_padmux lcdrom_padmux = {
.muxmask_counts = ARRAY_SIZE(lcdrom_muxmask),
.muxmask = lcdrom_muxmask,
.funcmask = BIT(4),
.funcval = BIT(4),
};
static const unsigned lcdrom_pins[] = { 23, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112, 113, 114 };
static const struct sirfsoc_muxmask uart0_muxmask[] = {
{
.group = 2,
.mask = BIT(4) | BIT(5),
}, {
.group = 1,
.mask = BIT(23) | BIT(28),
},
};
static const struct sirfsoc_padmux uart0_padmux = {
.muxmask_counts = ARRAY_SIZE(uart0_muxmask),
.muxmask = uart0_muxmask,
.funcmask = BIT(9),
.funcval = BIT(9),
};
static const unsigned uart0_pins[] = { 55, 60, 68, 69 };
static const struct sirfsoc_muxmask uart0_nostreamctrl_muxmask[] = {
{
.group = 2,
.mask = BIT(4) | BIT(5),
},
};
static const struct sirfsoc_padmux uart0_nostreamctrl_padmux = {
.muxmask_counts = ARRAY_SIZE(uart0_nostreamctrl_muxmask),
.muxmask = uart0_nostreamctrl_muxmask,
};
static const unsigned uart0_nostreamctrl_pins[] = { 68, 39 };
static const struct sirfsoc_muxmask uart1_muxmask[] = {
{
.group = 1,
.mask = BIT(15) | BIT(17),
},
};
static const struct sirfsoc_padmux uart1_padmux = {
.muxmask_counts = ARRAY_SIZE(uart1_muxmask),
.muxmask = uart1_muxmask,
};
static const unsigned uart1_pins[] = { 47, 49 };
static const struct sirfsoc_muxmask uart2_muxmask[] = {
{
.group = 1,
.mask = BIT(16) | BIT(18) | BIT(24) | BIT(27),
},
};
static const struct sirfsoc_padmux uart2_padmux = {
.muxmask_counts = ARRAY_SIZE(uart2_muxmask),
.muxmask = uart2_muxmask,
.funcmask = BIT(10),
.funcval = BIT(10),
};
static const unsigned uart2_pins[] = { 48, 50, 56, 59 };
static const struct sirfsoc_muxmask uart2_nostreamctrl_muxmask[] = {
{
.group = 1,
.mask = BIT(16) | BIT(18),
},
};
static const struct sirfsoc_padmux uart2_nostreamctrl_padmux = {
.muxmask_counts = ARRAY_SIZE(uart2_nostreamctrl_muxmask),
.muxmask = uart2_nostreamctrl_muxmask,
};
static const unsigned uart2_nostreamctrl_pins[] = { 48, 50 };
static const struct sirfsoc_muxmask sdmmc3_muxmask[] = {
{
.group = 0,
.mask = BIT(30) | BIT(31),
}, {
.group = 1,
.mask = BIT(0) | BIT(1) | BIT(2) | BIT(3),
},
};
static const struct sirfsoc_padmux sdmmc3_padmux = {
.muxmask_counts = ARRAY_SIZE(sdmmc3_muxmask),
.muxmask = sdmmc3_muxmask,
.funcmask = BIT(7),
.funcval = 0,
};
static const unsigned sdmmc3_pins[] = { 30, 31, 32, 33, 34, 35 };
static const struct sirfsoc_muxmask spi0_muxmask[] = {
{
.group = 1,
.mask = BIT(0) | BIT(1) | BIT(2) | BIT(3),
},
};
static const struct sirfsoc_padmux spi0_padmux = {
.muxmask_counts = ARRAY_SIZE(spi0_muxmask),
.muxmask = spi0_muxmask,
.funcmask = BIT(7),
.funcval = BIT(7),
};
static const unsigned spi0_pins[] = { 32, 33, 34, 35 };
static const struct sirfsoc_muxmask sdmmc4_muxmask[] = {
{
.group = 1,
.mask = BIT(4) | BIT(5) | BIT(6) | BIT(7) | BIT(8) | BIT(9),
},
};
static const struct sirfsoc_padmux sdmmc4_padmux = {
.muxmask_counts = ARRAY_SIZE(sdmmc4_muxmask),
.muxmask = sdmmc4_muxmask,
};
static const unsigned sdmmc4_pins[] = { 36, 37, 38, 39, 40, 41 };
static const struct sirfsoc_muxmask cko1_muxmask[] = {
{
.group = 1,
.mask = BIT(10),
},
};
static const struct sirfsoc_padmux cko1_padmux = {
.muxmask_counts = ARRAY_SIZE(cko1_muxmask),
.muxmask = cko1_muxmask,
.funcmask = BIT(3),
.funcval = 0,
};
static const unsigned cko1_pins[] = { 42 };
static const struct sirfsoc_muxmask i2s_muxmask[] = {
{
.group = 1,
.mask =
BIT(10) | BIT(11) | BIT(12) | BIT(13) | BIT(14) | BIT(19)
| BIT(23) | BIT(28),
},
};
static const struct sirfsoc_padmux i2s_padmux = {
.muxmask_counts = ARRAY_SIZE(i2s_muxmask),
.muxmask = i2s_muxmask,
.funcmask = BIT(3) | BIT(9),
.funcval = BIT(3),
};
static const unsigned i2s_pins[] = { 42, 43, 44, 45, 46, 51, 55, 60 };
static const struct sirfsoc_muxmask ac97_muxmask[] = {
{
.group = 1,
.mask = BIT(11) | BIT(12) | BIT(13) | BIT(14),
},
};
static const struct sirfsoc_padmux ac97_padmux = {
.muxmask_counts = ARRAY_SIZE(ac97_muxmask),
.muxmask = ac97_muxmask,
.funcmask = BIT(8),
.funcval = 0,
};
static const unsigned ac97_pins[] = { 33, 34, 35, 36 };
static const struct sirfsoc_muxmask spi1_muxmask[] = {
{
.group = 1,
.mask = BIT(11) | BIT(12) | BIT(13) | BIT(14),
},
};
static const struct sirfsoc_padmux spi1_padmux = {
.muxmask_counts = ARRAY_SIZE(spi1_muxmask),
.muxmask = spi1_muxmask,
.funcmask = BIT(8),
.funcval = BIT(8),
};
static const unsigned spi1_pins[] = { 43, 44, 45, 46 };
static const struct sirfsoc_muxmask sdmmc1_muxmask[] = {
{
.group = 0,
.mask = BIT(27) | BIT(28) | BIT(29),
},
};
static const struct sirfsoc_padmux sdmmc1_padmux = {
.muxmask_counts = ARRAY_SIZE(sdmmc1_muxmask),
.muxmask = sdmmc1_muxmask,
};
static const unsigned sdmmc1_pins[] = { 27, 28, 29 };
static const struct sirfsoc_muxmask gps_muxmask[] = {
{
.group = 0,
.mask = BIT(24) | BIT(25) | BIT(26),
},
};
static const struct sirfsoc_padmux gps_padmux = {
.muxmask_counts = ARRAY_SIZE(gps_muxmask),
.muxmask = gps_muxmask,
.funcmask = BIT(12) | BIT(13) | BIT(14),
.funcval = BIT(12),
};
static const unsigned gps_pins[] = { 24, 25, 26 };
static const struct sirfsoc_muxmask sdmmc5_muxmask[] = {
{
.group = 0,
.mask = BIT(24) | BIT(25) | BIT(26),
}, {
.group = 1,
.mask = BIT(29),
}, {
.group = 2,
.mask = BIT(0) | BIT(1),
},
};
static const struct sirfsoc_padmux sdmmc5_padmux = {
.muxmask_counts = ARRAY_SIZE(sdmmc5_muxmask),
.muxmask = sdmmc5_muxmask,
.funcmask = BIT(13) | BIT(14),
.funcval = BIT(13) | BIT(14),
};
static const unsigned sdmmc5_pins[] = { 24, 25, 26, 61, 64, 65 };
static const struct sirfsoc_muxmask usp0_muxmask[] = {
{
.group = 1,
.mask = BIT(19) | BIT(20) | BIT(21) | BIT(22) | BIT(23),
},
};
static const struct sirfsoc_padmux usp0_padmux = {
.muxmask_counts = ARRAY_SIZE(usp0_muxmask),
.muxmask = usp0_muxmask,
.funcmask = BIT(1) | BIT(2) | BIT(6) | BIT(9),
.funcval = 0,
};
static const unsigned usp0_pins[] = { 51, 52, 53, 54, 55 };
static const struct sirfsoc_muxmask usp1_muxmask[] = {
{
.group = 1,
.mask = BIT(24) | BIT(25) | BIT(26) | BIT(27) | BIT(28),
},
};
static const struct sirfsoc_padmux usp1_padmux = {
.muxmask_counts = ARRAY_SIZE(usp1_muxmask),
.muxmask = usp1_muxmask,
.funcmask = BIT(1) | BIT(9) | BIT(10) | BIT(11),
.funcval = 0,
};
static const unsigned usp1_pins[] = { 56, 57, 58, 59, 60 };
static const struct sirfsoc_muxmask usp2_muxmask[] = {
{
.group = 1,
.mask = BIT(29) | BIT(30) | BIT(31),
}, {
.group = 2,
.mask = BIT(0) | BIT(1),
},
};
static const struct sirfsoc_padmux usp2_padmux = {
.muxmask_counts = ARRAY_SIZE(usp2_muxmask),
.muxmask = usp2_muxmask,
.funcmask = BIT(13) | BIT(14),
.funcval = 0,
};
static const unsigned usp2_pins[] = { 61, 62, 63, 64, 65 };
static const struct sirfsoc_muxmask nand_muxmask[] = {
{
.group = 2,
.mask = BIT(2) | BIT(3) | BIT(28) | BIT(29) | BIT(30),
},
};
static const struct sirfsoc_padmux nand_padmux = {
.muxmask_counts = ARRAY_SIZE(nand_muxmask),
.muxmask = nand_muxmask,
.funcmask = BIT(5),
.funcval = 0,
};
static const unsigned nand_pins[] = { 64, 65, 92, 93, 94 };
static const struct sirfsoc_padmux sdmmc0_padmux = {
.muxmask_counts = 0,
.funcmask = BIT(5),
.funcval = 0,
};
static const unsigned sdmmc0_pins[] = { };
static const struct sirfsoc_muxmask sdmmc2_muxmask[] = {
{
.group = 2,
.mask = BIT(2) | BIT(3),
},
};
static const struct sirfsoc_padmux sdmmc2_padmux = {
.muxmask_counts = ARRAY_SIZE(sdmmc2_muxmask),
.muxmask = sdmmc2_muxmask,
.funcmask = BIT(5),
.funcval = BIT(5),
};
static const unsigned sdmmc2_pins[] = { 66, 67 };
static const struct sirfsoc_muxmask cko0_muxmask[] = {
{
.group = 2,
.mask = BIT(14),
},
};
static const struct sirfsoc_padmux cko0_padmux = {
.muxmask_counts = ARRAY_SIZE(cko0_muxmask),
.muxmask = cko0_muxmask,
};
static const unsigned cko0_pins[] = { 78 };
static const struct sirfsoc_muxmask vip_muxmask[] = {
{
.group = 2,
.mask = BIT(15) | BIT(16) | BIT(17) | BIT(18) | BIT(19)
| BIT(20) | BIT(21) | BIT(22) | BIT(23) | BIT(24) |
BIT(25),
},
};
static const struct sirfsoc_padmux vip_padmux = {
.muxmask_counts = ARRAY_SIZE(vip_muxmask),
.muxmask = vip_muxmask,
.funcmask = BIT(0),
.funcval = 0,
};
static const unsigned vip_pins[] = { 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89 };
static const struct sirfsoc_muxmask i2c0_muxmask[] = {
{
.group = 2,
.mask = BIT(26) | BIT(27),
},
};
static const struct sirfsoc_padmux i2c0_padmux = {
.muxmask_counts = ARRAY_SIZE(i2c0_muxmask),
.muxmask = i2c0_muxmask,
};
static const unsigned i2c0_pins[] = { 90, 91 };
static const struct sirfsoc_muxmask i2c1_muxmask[] = {
{
.group = 0,
.mask = BIT(13) | BIT(15),
},
};
static const struct sirfsoc_padmux i2c1_padmux = {
.muxmask_counts = ARRAY_SIZE(i2c1_muxmask),
.muxmask = i2c1_muxmask,
};
static const unsigned i2c1_pins[] = { 13, 15 };
static const struct sirfsoc_muxmask viprom_muxmask[] = {
{
.group = 2,
.mask = BIT(15) | BIT(16) | BIT(17) | BIT(18) | BIT(19)
| BIT(20) | BIT(21) | BIT(22) | BIT(23) | BIT(24) |
BIT(25),
}, {
.group = 0,
.mask = BIT(12),
},
};
static const struct sirfsoc_padmux viprom_padmux = {
.muxmask_counts = ARRAY_SIZE(viprom_muxmask),
.muxmask = viprom_muxmask,
.funcmask = BIT(0),
.funcval = BIT(0),
};
static const unsigned viprom_pins[] = { 12, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89 };
static const struct sirfsoc_muxmask pwm0_muxmask[] = {
{
.group = 0,
.mask = BIT(4),
},
};
static const struct sirfsoc_padmux pwm0_padmux = {
.muxmask_counts = ARRAY_SIZE(pwm0_muxmask),
.muxmask = pwm0_muxmask,
.funcmask = BIT(12),
.funcval = 0,
};
static const unsigned pwm0_pins[] = { 4 };
static const struct sirfsoc_muxmask pwm1_muxmask[] = {
{
.group = 0,
.mask = BIT(5),
},
};
static const struct sirfsoc_padmux pwm1_padmux = {
.muxmask_counts = ARRAY_SIZE(pwm1_muxmask),
.muxmask = pwm1_muxmask,
};
static const unsigned pwm1_pins[] = { 5 };
static const struct sirfsoc_muxmask pwm2_muxmask[] = {
{
.group = 0,
.mask = BIT(6),
},
};
static const struct sirfsoc_padmux pwm2_padmux = {
.muxmask_counts = ARRAY_SIZE(pwm2_muxmask),
.muxmask = pwm2_muxmask,
};
static const unsigned pwm2_pins[] = { 6 };
static const struct sirfsoc_muxmask pwm3_muxmask[] = {
{
.group = 0,
.mask = BIT(7),
},
};
static const struct sirfsoc_padmux pwm3_padmux = {
.muxmask_counts = ARRAY_SIZE(pwm3_muxmask),
.muxmask = pwm3_muxmask,
};
static const unsigned pwm3_pins[] = { 7 };
static const struct sirfsoc_muxmask warm_rst_muxmask[] = {
{
.group = 0,
.mask = BIT(8),
},
};
static const struct sirfsoc_padmux warm_rst_padmux = {
.muxmask_counts = ARRAY_SIZE(warm_rst_muxmask),
.muxmask = warm_rst_muxmask,
};
static const unsigned warm_rst_pins[] = { 8 };
static const struct sirfsoc_muxmask usb0_utmi_drvbus_muxmask[] = {
{
.group = 1,
.mask = BIT(22),
},
};
static const struct sirfsoc_padmux usb0_utmi_drvbus_padmux = {
.muxmask_counts = ARRAY_SIZE(usb0_utmi_drvbus_muxmask),
.muxmask = usb0_utmi_drvbus_muxmask,
.funcmask = BIT(6),
.funcval = BIT(6), /* refer to PAD_UTMI_DRVVBUS0_ENABLE */
};
static const unsigned usb0_utmi_drvbus_pins[] = { 54 };
static const struct sirfsoc_muxmask usb1_utmi_drvbus_muxmask[] = {
{
.group = 1,
.mask = BIT(27),
},
};
static const struct sirfsoc_padmux usb1_utmi_drvbus_padmux = {
.muxmask_counts = ARRAY_SIZE(usb1_utmi_drvbus_muxmask),
.muxmask = usb1_utmi_drvbus_muxmask,
.funcmask = BIT(11),
.funcval = BIT(11), /* refer to PAD_UTMI_DRVVBUS1_ENABLE */
};
static const unsigned usb1_utmi_drvbus_pins[] = { 59 };
static const struct sirfsoc_muxmask pulse_count_muxmask[] = {
{
.group = 0,
.mask = BIT(9) | BIT(10) | BIT(11),
},
};
static const struct sirfsoc_padmux pulse_count_padmux = {
.muxmask_counts = ARRAY_SIZE(pulse_count_muxmask),
.muxmask = pulse_count_muxmask,
};
static const unsigned pulse_count_pins[] = { 9, 10, 11 };
#define SIRFSOC_PIN_GROUP(n, p) \
{ \
.name = n, \
.pins = p, \
.num_pins = ARRAY_SIZE(p), \
}
static const struct sirfsoc_pin_group sirfsoc_pin_groups[] = {
SIRFSOC_PIN_GROUP("lcd_16bitsgrp", lcd_16bits_pins),
SIRFSOC_PIN_GROUP("lcd_18bitsgrp", lcd_18bits_pins),
SIRFSOC_PIN_GROUP("lcd_24bitsgrp", lcd_24bits_pins),
SIRFSOC_PIN_GROUP("lcdrom_grp", lcdrom_pins),
SIRFSOC_PIN_GROUP("uart0grp", uart0_pins),
SIRFSOC_PIN_GROUP("uart1grp", uart1_pins),
SIRFSOC_PIN_GROUP("uart2grp", uart2_pins),
SIRFSOC_PIN_GROUP("uart2_nostreamctrlgrp", uart2_nostreamctrl_pins),
SIRFSOC_PIN_GROUP("usp0grp", usp0_pins),
SIRFSOC_PIN_GROUP("usp1grp", usp1_pins),
SIRFSOC_PIN_GROUP("usp2grp", usp2_pins),
SIRFSOC_PIN_GROUP("i2c0grp", i2c0_pins),
SIRFSOC_PIN_GROUP("i2c1grp", i2c1_pins),
SIRFSOC_PIN_GROUP("pwm0grp", pwm0_pins),
SIRFSOC_PIN_GROUP("pwm1grp", pwm1_pins),
SIRFSOC_PIN_GROUP("pwm2grp", pwm2_pins),
SIRFSOC_PIN_GROUP("pwm3grp", pwm3_pins),
SIRFSOC_PIN_GROUP("vipgrp", vip_pins),
SIRFSOC_PIN_GROUP("vipromgrp", viprom_pins),
SIRFSOC_PIN_GROUP("warm_rstgrp", warm_rst_pins),
SIRFSOC_PIN_GROUP("cko0_rstgrp", cko0_pins),
SIRFSOC_PIN_GROUP("cko1_rstgrp", cko1_pins),
SIRFSOC_PIN_GROUP("sdmmc0grp", sdmmc0_pins),
SIRFSOC_PIN_GROUP("sdmmc1grp", sdmmc1_pins),
SIRFSOC_PIN_GROUP("sdmmc2grp", sdmmc2_pins),
SIRFSOC_PIN_GROUP("sdmmc3grp", sdmmc3_pins),
SIRFSOC_PIN_GROUP("sdmmc4grp", sdmmc4_pins),
SIRFSOC_PIN_GROUP("sdmmc5grp", sdmmc5_pins),
SIRFSOC_PIN_GROUP("usb0_utmi_drvbusgrp", usb0_utmi_drvbus_pins),
SIRFSOC_PIN_GROUP("usb1_utmi_drvbusgrp", usb1_utmi_drvbus_pins),
SIRFSOC_PIN_GROUP("pulse_countgrp", pulse_count_pins),
SIRFSOC_PIN_GROUP("i2sgrp", i2s_pins),
SIRFSOC_PIN_GROUP("ac97grp", ac97_pins),
SIRFSOC_PIN_GROUP("nandgrp", nand_pins),
SIRFSOC_PIN_GROUP("spi0grp", spi0_pins),
SIRFSOC_PIN_GROUP("spi1grp", spi1_pins),
SIRFSOC_PIN_GROUP("gpsgrp", gps_pins),
};
static int sirfsoc_get_groups_count(struct pinctrl_dev *pctldev)
{
return ARRAY_SIZE(sirfsoc_pin_groups);
}
static const char *sirfsoc_get_group_name(struct pinctrl_dev *pctldev,
unsigned selector)
{
return sirfsoc_pin_groups[selector].name;
}
static int sirfsoc_get_group_pins(struct pinctrl_dev *pctldev, unsigned selector,
const unsigned **pins,
unsigned *num_pins)
{
*pins = sirfsoc_pin_groups[selector].pins;
*num_pins = sirfsoc_pin_groups[selector].num_pins;
return 0;
}
static void sirfsoc_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
unsigned offset)
{
seq_printf(s, " " DRIVER_NAME);
}
static int sirfsoc_dt_node_to_map(struct pinctrl_dev *pctldev,
struct device_node *np_config,
struct pinctrl_map **map, unsigned *num_maps)
{
struct sirfsoc_pmx *spmx = pinctrl_dev_get_drvdata(pctldev);
struct device_node *np;
struct property *prop;
const char *function, *group;
int ret, index = 0, count = 0;
/* calculate number of maps required */
for_each_child_of_node(np_config, np) {
ret = of_property_read_string(np, "sirf,function", &function);
if (ret < 0)
return ret;
ret = of_property_count_strings(np, "sirf,pins");
if (ret < 0)
return ret;
count += ret;
}
if (!count) {
dev_err(spmx->dev, "No child nodes passed via DT\n");
return -ENODEV;
}
*map = kzalloc(sizeof(**map) * count, GFP_KERNEL);
if (!*map)
return -ENOMEM;
for_each_child_of_node(np_config, np) {
of_property_read_string(np, "sirf,function", &function);
of_property_for_each_string(np, "sirf,pins", prop, group) {
(*map)[index].type = PIN_MAP_TYPE_MUX_GROUP;
(*map)[index].data.mux.group = group;
(*map)[index].data.mux.function = function;
index++;
}
}
*num_maps = count;
return 0;
}
static void sirfsoc_dt_free_map(struct pinctrl_dev *pctldev,
struct pinctrl_map *map, unsigned num_maps)
{
kfree(map);
}
static const struct pinctrl_ops sirfsoc_pctrl_ops = {
.get_groups_count = sirfsoc_get_groups_count,
.get_group_name = sirfsoc_get_group_name,
.get_group_pins = sirfsoc_get_group_pins,
.pin_dbg_show = sirfsoc_pin_dbg_show,
.dt_node_to_map = sirfsoc_dt_node_to_map,
.dt_free_map = sirfsoc_dt_free_map,
};
struct sirfsoc_pmx_func {
const char *name;
const char * const *groups;
const unsigned num_groups;
const struct sirfsoc_padmux *padmux;
};
static const char * const lcd_16bitsgrp[] = { "lcd_16bitsgrp" };
static const char * const lcd_18bitsgrp[] = { "lcd_18bitsgrp" };
static const char * const lcd_24bitsgrp[] = { "lcd_24bitsgrp" };
static const char * const lcdromgrp[] = { "lcdromgrp" };
static const char * const uart0grp[] = { "uart0grp" };
static const char * const uart1grp[] = { "uart1grp" };
static const char * const uart2grp[] = { "uart2grp" };
static const char * const uart2_nostreamctrlgrp[] = { "uart2_nostreamctrlgrp" };
static const char * const usp0grp[] = { "usp0grp" };
static const char * const usp1grp[] = { "usp1grp" };
static const char * const usp2grp[] = { "usp2grp" };
static const char * const i2c0grp[] = { "i2c0grp" };
static const char * const i2c1grp[] = { "i2c1grp" };
static const char * const pwm0grp[] = { "pwm0grp" };
static const char * const pwm1grp[] = { "pwm1grp" };
static const char * const pwm2grp[] = { "pwm2grp" };
static const char * const pwm3grp[] = { "pwm3grp" };
static const char * const vipgrp[] = { "vipgrp" };
static const char * const vipromgrp[] = { "vipromgrp" };
static const char * const warm_rstgrp[] = { "warm_rstgrp" };
static const char * const cko0grp[] = { "cko0grp" };
static const char * const cko1grp[] = { "cko1grp" };
static const char * const sdmmc0grp[] = { "sdmmc0grp" };
static const char * const sdmmc1grp[] = { "sdmmc1grp" };
static const char * const sdmmc2grp[] = { "sdmmc2grp" };
static const char * const sdmmc3grp[] = { "sdmmc3grp" };
static const char * const sdmmc4grp[] = { "sdmmc4grp" };
static const char * const sdmmc5grp[] = { "sdmmc5grp" };
static const char * const usb0_utmi_drvbusgrp[] = { "usb0_utmi_drvbusgrp" };
static const char * const usb1_utmi_drvbusgrp[] = { "usb1_utmi_drvbusgrp" };
static const char * const pulse_countgrp[] = { "pulse_countgrp" };
static const char * const i2sgrp[] = { "i2sgrp" };
static const char * const ac97grp[] = { "ac97grp" };
static const char * const nandgrp[] = { "nandgrp" };
static const char * const spi0grp[] = { "spi0grp" };
static const char * const spi1grp[] = { "spi1grp" };
static const char * const gpsgrp[] = { "gpsgrp" };
#define SIRFSOC_PMX_FUNCTION(n, g, m) \
{ \
.name = n, \
.groups = g, \
.num_groups = ARRAY_SIZE(g), \
.padmux = &m, \
}
static const struct sirfsoc_pmx_func sirfsoc_pmx_functions[] = {
SIRFSOC_PMX_FUNCTION("lcd_16bits", lcd_16bitsgrp, lcd_16bits_padmux),
SIRFSOC_PMX_FUNCTION("lcd_18bits", lcd_18bitsgrp, lcd_18bits_padmux),
SIRFSOC_PMX_FUNCTION("lcd_24bits", lcd_24bitsgrp, lcd_24bits_padmux),
SIRFSOC_PMX_FUNCTION("lcdrom", lcdromgrp, lcdrom_padmux),
SIRFSOC_PMX_FUNCTION("uart0", uart0grp, uart0_padmux),
SIRFSOC_PMX_FUNCTION("uart1", uart1grp, uart1_padmux),
SIRFSOC_PMX_FUNCTION("uart2", uart2grp, uart2_padmux),
SIRFSOC_PMX_FUNCTION("uart2_nostreamctrl", uart2_nostreamctrlgrp, uart2_nostreamctrl_padmux),
SIRFSOC_PMX_FUNCTION("usp0", usp0grp, usp0_padmux),
SIRFSOC_PMX_FUNCTION("usp1", usp1grp, usp1_padmux),
SIRFSOC_PMX_FUNCTION("usp2", usp2grp, usp2_padmux),
SIRFSOC_PMX_FUNCTION("i2c0", i2c0grp, i2c0_padmux),
SIRFSOC_PMX_FUNCTION("i2c1", i2c1grp, i2c1_padmux),
SIRFSOC_PMX_FUNCTION("pwm0", pwm0grp, pwm0_padmux),
SIRFSOC_PMX_FUNCTION("pwm1", pwm1grp, pwm1_padmux),
SIRFSOC_PMX_FUNCTION("pwm2", pwm2grp, pwm2_padmux),
SIRFSOC_PMX_FUNCTION("pwm3", pwm3grp, pwm3_padmux),
SIRFSOC_PMX_FUNCTION("vip", vipgrp, vip_padmux),
SIRFSOC_PMX_FUNCTION("viprom", vipromgrp, viprom_padmux),
SIRFSOC_PMX_FUNCTION("warm_rst", warm_rstgrp, warm_rst_padmux),
SIRFSOC_PMX_FUNCTION("cko0", cko0grp, cko0_padmux),
SIRFSOC_PMX_FUNCTION("cko1", cko1grp, cko1_padmux),
SIRFSOC_PMX_FUNCTION("sdmmc0", sdmmc0grp, sdmmc0_padmux),
SIRFSOC_PMX_FUNCTION("sdmmc1", sdmmc1grp, sdmmc1_padmux),
SIRFSOC_PMX_FUNCTION("sdmmc2", sdmmc2grp, sdmmc2_padmux),
SIRFSOC_PMX_FUNCTION("sdmmc3", sdmmc3grp, sdmmc3_padmux),
SIRFSOC_PMX_FUNCTION("sdmmc4", sdmmc4grp, sdmmc4_padmux),
SIRFSOC_PMX_FUNCTION("sdmmc5", sdmmc5grp, sdmmc5_padmux),
SIRFSOC_PMX_FUNCTION("usb0_utmi_drvbus", usb0_utmi_drvbusgrp, usb0_utmi_drvbus_padmux),
SIRFSOC_PMX_FUNCTION("usb1_utmi_drvbus", usb1_utmi_drvbusgrp, usb1_utmi_drvbus_padmux),
SIRFSOC_PMX_FUNCTION("pulse_count", pulse_countgrp, pulse_count_padmux),
SIRFSOC_PMX_FUNCTION("i2s", i2sgrp, i2s_padmux),
SIRFSOC_PMX_FUNCTION("ac97", ac97grp, ac97_padmux),
SIRFSOC_PMX_FUNCTION("nand", nandgrp, nand_padmux),
SIRFSOC_PMX_FUNCTION("spi0", spi0grp, spi0_padmux),
SIRFSOC_PMX_FUNCTION("spi1", spi1grp, spi1_padmux),
SIRFSOC_PMX_FUNCTION("gps", gpsgrp, gps_padmux),
};
static void sirfsoc_pinmux_endisable(struct sirfsoc_pmx *spmx, unsigned selector,
bool enable)
{
int i;
const struct sirfsoc_padmux *mux = sirfsoc_pmx_functions[selector].padmux;
const struct sirfsoc_muxmask *mask = mux->muxmask;
for (i = 0; i < mux->muxmask_counts; i++) {
u32 muxval;
if (!spmx->is_marco) {
muxval = readl(spmx->gpio_virtbase + SIRFSOC_GPIO_PAD_EN(mask[i].group));
if (enable)
muxval = muxval & ~mask[i].mask;
else
muxval = muxval | mask[i].mask;
writel(muxval, spmx->gpio_virtbase + SIRFSOC_GPIO_PAD_EN(mask[i].group));
} else {
if (enable)
writel(mask[i].mask, spmx->gpio_virtbase +
SIRFSOC_GPIO_PAD_EN_CLR(mask[i].group));
else
writel(mask[i].mask, spmx->gpio_virtbase +
SIRFSOC_GPIO_PAD_EN(mask[i].group));
}
}
if (mux->funcmask && enable) {
u32 func_en_val;
func_en_val =
readl(spmx->rsc_virtbase + SIRFSOC_RSC_PIN_MUX);
func_en_val =
(func_en_val & ~mux->funcmask) | (mux->
funcval);
writel(func_en_val, spmx->rsc_virtbase + SIRFSOC_RSC_PIN_MUX);
}
}
static int sirfsoc_pinmux_enable(struct pinctrl_dev *pmxdev, unsigned selector,
unsigned group)
{
struct sirfsoc_pmx *spmx;
spmx = pinctrl_dev_get_drvdata(pmxdev);
sirfsoc_pinmux_endisable(spmx, selector, true);
return 0;
}
static void sirfsoc_pinmux_disable(struct pinctrl_dev *pmxdev, unsigned selector,
unsigned group)
{
struct sirfsoc_pmx *spmx;
spmx = pinctrl_dev_get_drvdata(pmxdev);
sirfsoc_pinmux_endisable(spmx, selector, false);
}
static int sirfsoc_pinmux_get_funcs_count(struct pinctrl_dev *pmxdev)
{
return ARRAY_SIZE(sirfsoc_pmx_functions);
}
static const char *sirfsoc_pinmux_get_func_name(struct pinctrl_dev *pctldev,
unsigned selector)
{
return sirfsoc_pmx_functions[selector].name;
}
static int sirfsoc_pinmux_get_groups(struct pinctrl_dev *pctldev, unsigned selector,
const char * const **groups,
unsigned * const num_groups)
{
*groups = sirfsoc_pmx_functions[selector].groups;
*num_groups = sirfsoc_pmx_functions[selector].num_groups;
return 0;
}
static int sirfsoc_pinmux_request_gpio(struct pinctrl_dev *pmxdev,
struct pinctrl_gpio_range *range, unsigned offset)
{
struct sirfsoc_pmx *spmx;
int group = range->id;
u32 muxval;
spmx = pinctrl_dev_get_drvdata(pmxdev);
if (!spmx->is_marco) {
muxval = readl(spmx->gpio_virtbase + SIRFSOC_GPIO_PAD_EN(group));
muxval = muxval | (1 << (offset - range->pin_base));
writel(muxval, spmx->gpio_virtbase + SIRFSOC_GPIO_PAD_EN(group));
} else {
writel(1 << (offset - range->pin_base), spmx->gpio_virtbase +
SIRFSOC_GPIO_PAD_EN(group));
}
return 0;
}
static const struct pinmux_ops sirfsoc_pinmux_ops = {
.enable = sirfsoc_pinmux_enable,
.disable = sirfsoc_pinmux_disable,
.get_functions_count = sirfsoc_pinmux_get_funcs_count,
.get_function_name = sirfsoc_pinmux_get_func_name,
.get_function_groups = sirfsoc_pinmux_get_groups,
.gpio_request_enable = sirfsoc_pinmux_request_gpio,
};
static struct pinctrl_desc sirfsoc_pinmux_desc = {
.name = DRIVER_NAME,
.pins = sirfsoc_pads,
.npins = ARRAY_SIZE(sirfsoc_pads),
.pctlops = &sirfsoc_pctrl_ops,
.pmxops = &sirfsoc_pinmux_ops,
.owner = THIS_MODULE,
};
/*
* Todo: bind irq_chip to every pinctrl_gpio_range
*/
static struct pinctrl_gpio_range sirfsoc_gpio_ranges[] = {
{
.name = "sirfsoc-gpio*",
.id = 0,
.base = 0,
.pin_base = 0,
.npins = 32,
}, {
.name = "sirfsoc-gpio*",
.id = 1,
.base = 32,
.pin_base = 32,
.npins = 32,
}, {
.name = "sirfsoc-gpio*",
.id = 2,
.base = 64,
.pin_base = 64,
.npins = 32,
}, {
.name = "sirfsoc-gpio*",
.id = 3,
.base = 96,
.pin_base = 96,
.npins = 19,
},
};
static void __iomem *sirfsoc_rsc_of_iomap(void)
{
const struct of_device_id rsc_ids[] = {
{ .compatible = "sirf,prima2-rsc" },
{ .compatible = "sirf,marco-rsc" },
{}
};
struct device_node *np;
np = of_find_matching_node(NULL, rsc_ids);
if (!np)
panic("unable to find compatible rsc node in dtb\n");
return of_iomap(np, 0);
}
static int sirfsoc_gpio_of_xlate(struct gpio_chip *gc,
const struct of_phandle_args *gpiospec,
u32 *flags)
{
if (gpiospec->args[0] > SIRFSOC_GPIO_NO_OF_BANKS * SIRFSOC_GPIO_BANK_SIZE)
return -EINVAL;
if (gc != &sgpio_bank[gpiospec->args[0] / SIRFSOC_GPIO_BANK_SIZE].chip.gc)
return -EINVAL;
if (flags)
*flags = gpiospec->args[1];
return gpiospec->args[0] % SIRFSOC_GPIO_BANK_SIZE;
}
static int sirfsoc_pinmux_probe(struct platform_device *pdev)
{
int ret;
struct sirfsoc_pmx *spmx;
struct device_node *np = pdev->dev.of_node;
int i;
/* Create state holders etc for this driver */
spmx = devm_kzalloc(&pdev->dev, sizeof(*spmx), GFP_KERNEL);
if (!spmx)
return -ENOMEM;
spmx->dev = &pdev->dev;
platform_set_drvdata(pdev, spmx);
spmx->gpio_virtbase = of_iomap(np, 0);
if (!spmx->gpio_virtbase) {
ret = -ENOMEM;
dev_err(&pdev->dev, "can't map gpio registers\n");
goto out_no_gpio_remap;
}
spmx->rsc_virtbase = sirfsoc_rsc_of_iomap();
if (!spmx->rsc_virtbase) {
ret = -ENOMEM;
dev_err(&pdev->dev, "can't map rsc registers\n");
goto out_no_rsc_remap;
}
if (of_device_is_compatible(np, "sirf,marco-pinctrl"))
spmx->is_marco = 1;
/* Now register the pin controller and all pins it handles */
spmx->pmx = pinctrl_register(&sirfsoc_pinmux_desc, &pdev->dev, spmx);
if (!spmx->pmx) {
dev_err(&pdev->dev, "could not register SIRFSOC pinmux driver\n");
ret = -EINVAL;
goto out_no_pmx;
}
for (i = 0; i < ARRAY_SIZE(sirfsoc_gpio_ranges); i++) {
sirfsoc_gpio_ranges[i].gc = &sgpio_bank[i].chip.gc;
pinctrl_add_gpio_range(spmx->pmx, &sirfsoc_gpio_ranges[i]);
}
dev_info(&pdev->dev, "initialized SIRFSOC pinmux driver\n");
return 0;
out_no_pmx:
iounmap(spmx->rsc_virtbase);
out_no_rsc_remap:
iounmap(spmx->gpio_virtbase);
out_no_gpio_remap:
platform_set_drvdata(pdev, NULL);
return ret;
}
static const struct of_device_id pinmux_ids[] = {
{ .compatible = "sirf,prima2-pinctrl" },
{ .compatible = "sirf,marco-pinctrl" },
{}
};
static struct platform_driver sirfsoc_pinmux_driver = {
.driver = {
.name = DRIVER_NAME,
.owner = THIS_MODULE,
.of_match_table = pinmux_ids,
},
.probe = sirfsoc_pinmux_probe,
};
static int __init sirfsoc_pinmux_init(void)
{
return platform_driver_register(&sirfsoc_pinmux_driver);
}
arch_initcall(sirfsoc_pinmux_init);
static inline int sirfsoc_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
{
struct sirfsoc_gpio_bank *bank = container_of(to_of_mm_gpio_chip(chip),
struct sirfsoc_gpio_bank, chip);
return irq_create_mapping(bank->domain, offset);
}
static inline int sirfsoc_gpio_to_offset(unsigned int gpio)
{
return gpio % SIRFSOC_GPIO_BANK_SIZE;
}
static inline struct sirfsoc_gpio_bank *sirfsoc_gpio_to_bank(unsigned int gpio)
{
return &sgpio_bank[gpio / SIRFSOC_GPIO_BANK_SIZE];
}
static inline struct sirfsoc_gpio_bank *sirfsoc_irqchip_to_bank(struct gpio_chip *chip)
{
return container_of(to_of_mm_gpio_chip(chip), struct sirfsoc_gpio_bank, chip);
}
static void sirfsoc_gpio_irq_ack(struct irq_data *d)
{
struct sirfsoc_gpio_bank *bank = irq_data_get_irq_chip_data(d);
int idx = d->hwirq % SIRFSOC_GPIO_BANK_SIZE;
u32 val, offset;
unsigned long flags;
offset = SIRFSOC_GPIO_CTRL(bank->id, idx);
spin_lock_irqsave(&sgpio_lock, flags);
val = readl(bank->chip.regs + offset);
writel(val, bank->chip.regs + offset);
spin_unlock_irqrestore(&sgpio_lock, flags);
}
static void __sirfsoc_gpio_irq_mask(struct sirfsoc_gpio_bank *bank, int idx)
{
u32 val, offset;
unsigned long flags;
offset = SIRFSOC_GPIO_CTRL(bank->id, idx);
spin_lock_irqsave(&sgpio_lock, flags);
val = readl(bank->chip.regs + offset);
val &= ~SIRFSOC_GPIO_CTL_INTR_EN_MASK;
val &= ~SIRFSOC_GPIO_CTL_INTR_STS_MASK;
writel(val, bank->chip.regs + offset);
spin_unlock_irqrestore(&sgpio_lock, flags);
}
static void sirfsoc_gpio_irq_mask(struct irq_data *d)
{
struct sirfsoc_gpio_bank *bank = irq_data_get_irq_chip_data(d);
__sirfsoc_gpio_irq_mask(bank, d->hwirq % SIRFSOC_GPIO_BANK_SIZE);
}
static void sirfsoc_gpio_irq_unmask(struct irq_data *d)
{
struct sirfsoc_gpio_bank *bank = irq_data_get_irq_chip_data(d);
int idx = d->hwirq % SIRFSOC_GPIO_BANK_SIZE;
u32 val, offset;
unsigned long flags;
offset = SIRFSOC_GPIO_CTRL(bank->id, idx);
spin_lock_irqsave(&sgpio_lock, flags);
val = readl(bank->chip.regs + offset);
val &= ~SIRFSOC_GPIO_CTL_INTR_STS_MASK;
val |= SIRFSOC_GPIO_CTL_INTR_EN_MASK;
writel(val, bank->chip.regs + offset);
spin_unlock_irqrestore(&sgpio_lock, flags);
}
static int sirfsoc_gpio_irq_type(struct irq_data *d, unsigned type)
{
struct sirfsoc_gpio_bank *bank = irq_data_get_irq_chip_data(d);
int idx = d->hwirq % SIRFSOC_GPIO_BANK_SIZE;
u32 val, offset;
unsigned long flags;
offset = SIRFSOC_GPIO_CTRL(bank->id, idx);
spin_lock_irqsave(&sgpio_lock, flags);
val = readl(bank->chip.regs + offset);
val &= ~SIRFSOC_GPIO_CTL_INTR_STS_MASK;
switch (type) {
case IRQ_TYPE_NONE:
break;
case IRQ_TYPE_EDGE_RISING:
val |= SIRFSOC_GPIO_CTL_INTR_HIGH_MASK | SIRFSOC_GPIO_CTL_INTR_TYPE_MASK;
val &= ~SIRFSOC_GPIO_CTL_INTR_LOW_MASK;
break;
case IRQ_TYPE_EDGE_FALLING:
val &= ~SIRFSOC_GPIO_CTL_INTR_HIGH_MASK;
val |= SIRFSOC_GPIO_CTL_INTR_LOW_MASK | SIRFSOC_GPIO_CTL_INTR_TYPE_MASK;
break;
case IRQ_TYPE_EDGE_BOTH:
val |= SIRFSOC_GPIO_CTL_INTR_HIGH_MASK | SIRFSOC_GPIO_CTL_INTR_LOW_MASK |
SIRFSOC_GPIO_CTL_INTR_TYPE_MASK;
break;
case IRQ_TYPE_LEVEL_LOW:
val &= ~(SIRFSOC_GPIO_CTL_INTR_HIGH_MASK | SIRFSOC_GPIO_CTL_INTR_TYPE_MASK);
val |= SIRFSOC_GPIO_CTL_INTR_LOW_MASK;
break;
case IRQ_TYPE_LEVEL_HIGH:
val |= SIRFSOC_GPIO_CTL_INTR_HIGH_MASK;
val &= ~(SIRFSOC_GPIO_CTL_INTR_LOW_MASK | SIRFSOC_GPIO_CTL_INTR_TYPE_MASK);
break;
}
writel(val, bank->chip.regs + offset);
spin_unlock_irqrestore(&sgpio_lock, flags);
return 0;
}
static struct irq_chip sirfsoc_irq_chip = {
.name = "sirf-gpio-irq",
.irq_ack = sirfsoc_gpio_irq_ack,
.irq_mask = sirfsoc_gpio_irq_mask,
.irq_unmask = sirfsoc_gpio_irq_unmask,
.irq_set_type = sirfsoc_gpio_irq_type,
};
static void sirfsoc_gpio_handle_irq(unsigned int irq, struct irq_desc *desc)
{
struct sirfsoc_gpio_bank *bank = irq_get_handler_data(irq);
u32 status, ctrl;
int idx = 0;
struct irq_chip *chip = irq_get_chip(irq);
chained_irq_enter(chip, desc);
status = readl(bank->chip.regs + SIRFSOC_GPIO_INT_STATUS(bank->id));
if (!status) {
printk(KERN_WARNING
"%s: gpio id %d status %#x no interrupt is flaged\n",
__func__, bank->id, status);
handle_bad_irq(irq, desc);
return;
}
while (status) {
ctrl = readl(bank->chip.regs + SIRFSOC_GPIO_CTRL(bank->id, idx));
/*
* Here we must check whether the corresponding GPIO's interrupt
* has been enabled, otherwise just skip it
*/
if ((status & 0x1) && (ctrl & SIRFSOC_GPIO_CTL_INTR_EN_MASK)) {
pr_debug("%s: gpio id %d idx %d happens\n",
__func__, bank->id, idx);
generic_handle_irq(irq_find_mapping(bank->domain, idx));
}
idx++;
status = status >> 1;
}
chained_irq_exit(chip, desc);
}
static inline void sirfsoc_gpio_set_input(struct sirfsoc_gpio_bank *bank, unsigned ctrl_offset)
{
u32 val;
val = readl(bank->chip.regs + ctrl_offset);
val &= ~SIRFSOC_GPIO_CTL_OUT_EN_MASK;
writel(val, bank->chip.regs + ctrl_offset);
}
static int sirfsoc_gpio_request(struct gpio_chip *chip, unsigned offset)
{
struct sirfsoc_gpio_bank *bank = sirfsoc_irqchip_to_bank(chip);
unsigned long flags;
if (pinctrl_request_gpio(chip->base + offset))
return -ENODEV;
spin_lock_irqsave(&bank->lock, flags);
/*
* default status:
* set direction as input and mask irq
*/
sirfsoc_gpio_set_input(bank, SIRFSOC_GPIO_CTRL(bank->id, offset));
__sirfsoc_gpio_irq_mask(bank, offset);
spin_unlock_irqrestore(&bank->lock, flags);
return 0;
}
static void sirfsoc_gpio_free(struct gpio_chip *chip, unsigned offset)
{
struct sirfsoc_gpio_bank *bank = sirfsoc_irqchip_to_bank(chip);
unsigned long flags;
spin_lock_irqsave(&bank->lock, flags);
__sirfsoc_gpio_irq_mask(bank, offset);
sirfsoc_gpio_set_input(bank, SIRFSOC_GPIO_CTRL(bank->id, offset));
spin_unlock_irqrestore(&bank->lock, flags);
pinctrl_free_gpio(chip->base + offset);
}
static int sirfsoc_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
{
struct sirfsoc_gpio_bank *bank = sirfsoc_irqchip_to_bank(chip);
int idx = sirfsoc_gpio_to_offset(gpio);
unsigned long flags;
unsigned offset;
offset = SIRFSOC_GPIO_CTRL(bank->id, idx);
spin_lock_irqsave(&bank->lock, flags);
sirfsoc_gpio_set_input(bank, offset);
spin_unlock_irqrestore(&bank->lock, flags);
return 0;
}
static inline void sirfsoc_gpio_set_output(struct sirfsoc_gpio_bank *bank, unsigned offset,
int value)
{
u32 out_ctrl;
unsigned long flags;
spin_lock_irqsave(&bank->lock, flags);
out_ctrl = readl(bank->chip.regs + offset);
if (value)
out_ctrl |= SIRFSOC_GPIO_CTL_DATAOUT_MASK;
else
out_ctrl &= ~SIRFSOC_GPIO_CTL_DATAOUT_MASK;
out_ctrl &= ~SIRFSOC_GPIO_CTL_INTR_EN_MASK;
out_ctrl |= SIRFSOC_GPIO_CTL_OUT_EN_MASK;
writel(out_ctrl, bank->chip.regs + offset);
spin_unlock_irqrestore(&bank->lock, flags);
}
static int sirfsoc_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int value)
{
struct sirfsoc_gpio_bank *bank = sirfsoc_irqchip_to_bank(chip);
int idx = sirfsoc_gpio_to_offset(gpio);
u32 offset;
unsigned long flags;
offset = SIRFSOC_GPIO_CTRL(bank->id, idx);
spin_lock_irqsave(&sgpio_lock, flags);
sirfsoc_gpio_set_output(bank, offset, value);
spin_unlock_irqrestore(&sgpio_lock, flags);
return 0;
}
static int sirfsoc_gpio_get_value(struct gpio_chip *chip, unsigned offset)
{
struct sirfsoc_gpio_bank *bank = sirfsoc_irqchip_to_bank(chip);
u32 val;
unsigned long flags;
spin_lock_irqsave(&bank->lock, flags);
val = readl(bank->chip.regs + SIRFSOC_GPIO_CTRL(bank->id, offset));
spin_unlock_irqrestore(&bank->lock, flags);
return !!(val & SIRFSOC_GPIO_CTL_DATAIN_MASK);
}
static void sirfsoc_gpio_set_value(struct gpio_chip *chip, unsigned offset,
int value)
{
struct sirfsoc_gpio_bank *bank = sirfsoc_irqchip_to_bank(chip);
u32 ctrl;
unsigned long flags;
spin_lock_irqsave(&bank->lock, flags);
ctrl = readl(bank->chip.regs + SIRFSOC_GPIO_CTRL(bank->id, offset));
if (value)
ctrl |= SIRFSOC_GPIO_CTL_DATAOUT_MASK;
else
ctrl &= ~SIRFSOC_GPIO_CTL_DATAOUT_MASK;
writel(ctrl, bank->chip.regs + SIRFSOC_GPIO_CTRL(bank->id, offset));
spin_unlock_irqrestore(&bank->lock, flags);
}
static int sirfsoc_gpio_irq_map(struct irq_domain *d, unsigned int irq,
irq_hw_number_t hwirq)
{
struct sirfsoc_gpio_bank *bank = d->host_data;
if (!bank)
return -EINVAL;
irq_set_chip(irq, &sirfsoc_irq_chip);
irq_set_handler(irq, handle_level_irq);
irq_set_chip_data(irq, bank);
set_irq_flags(irq, IRQF_VALID);
return 0;
}
const struct irq_domain_ops sirfsoc_gpio_irq_simple_ops = {
.map = sirfsoc_gpio_irq_map,
.xlate = irq_domain_xlate_twocell,
};
static void sirfsoc_gpio_set_pullup(const u32 *pullups)
{
int i, n;
const unsigned long *p = (const unsigned long *)pullups;
for (i = 0; i < SIRFSOC_GPIO_NO_OF_BANKS; i++) {
for_each_set_bit(n, p + i, BITS_PER_LONG) {
u32 offset = SIRFSOC_GPIO_CTRL(i, n);
u32 val = readl(sgpio_bank[i].chip.regs + offset);
val |= SIRFSOC_GPIO_CTL_PULL_MASK;
val |= SIRFSOC_GPIO_CTL_PULL_HIGH;
writel(val, sgpio_bank[i].chip.regs + offset);
}
}
}
static void sirfsoc_gpio_set_pulldown(const u32 *pulldowns)
{
int i, n;
const unsigned long *p = (const unsigned long *)pulldowns;
for (i = 0; i < SIRFSOC_GPIO_NO_OF_BANKS; i++) {
for_each_set_bit(n, p + i, BITS_PER_LONG) {
u32 offset = SIRFSOC_GPIO_CTRL(i, n);
u32 val = readl(sgpio_bank[i].chip.regs + offset);
val |= SIRFSOC_GPIO_CTL_PULL_MASK;
val &= ~SIRFSOC_GPIO_CTL_PULL_HIGH;
writel(val, sgpio_bank[i].chip.regs + offset);
}
}
}
static int sirfsoc_gpio_probe(struct device_node *np)
{
int i, err = 0;
struct sirfsoc_gpio_bank *bank;
void *regs;
struct platform_device *pdev;
bool is_marco = false;
u32 pullups[SIRFSOC_GPIO_NO_OF_BANKS], pulldowns[SIRFSOC_GPIO_NO_OF_BANKS];
pdev = of_find_device_by_node(np);
if (!pdev)
return -ENODEV;
regs = of_iomap(np, 0);
if (!regs)
return -ENOMEM;
if (of_device_is_compatible(np, "sirf,marco-pinctrl"))
is_marco = 1;
for (i = 0; i < SIRFSOC_GPIO_NO_OF_BANKS; i++) {
bank = &sgpio_bank[i];
spin_lock_init(&bank->lock);
bank->chip.gc.request = sirfsoc_gpio_request;
bank->chip.gc.free = sirfsoc_gpio_free;
bank->chip.gc.direction_input = sirfsoc_gpio_direction_input;
bank->chip.gc.get = sirfsoc_gpio_get_value;
bank->chip.gc.direction_output = sirfsoc_gpio_direction_output;
bank->chip.gc.set = sirfsoc_gpio_set_value;
bank->chip.gc.to_irq = sirfsoc_gpio_to_irq;
bank->chip.gc.base = i * SIRFSOC_GPIO_BANK_SIZE;
bank->chip.gc.ngpio = SIRFSOC_GPIO_BANK_SIZE;
bank->chip.gc.label = kstrdup(np->full_name, GFP_KERNEL);
bank->chip.gc.of_node = np;
bank->chip.gc.of_xlate = sirfsoc_gpio_of_xlate;
bank->chip.gc.of_gpio_n_cells = 2;
bank->chip.regs = regs;
bank->id = i;
bank->is_marco = is_marco;
bank->parent_irq = platform_get_irq(pdev, i);
if (bank->parent_irq < 0) {
err = bank->parent_irq;
goto out;
}
err = gpiochip_add(&bank->chip.gc);
if (err) {
pr_err("%s: error in probe function with status %d\n",
np->full_name, err);
goto out;
}
bank->domain = irq_domain_add_linear(np, SIRFSOC_GPIO_BANK_SIZE,
&sirfsoc_gpio_irq_simple_ops, bank);
if (!bank->domain) {
pr_err("%s: Failed to create irqdomain\n", np->full_name);
err = -ENOSYS;
goto out;
}
irq_set_chained_handler(bank->parent_irq, sirfsoc_gpio_handle_irq);
irq_set_handler_data(bank->parent_irq, bank);
}
if (!of_property_read_u32_array(np, "sirf,pullups", pullups,
SIRFSOC_GPIO_NO_OF_BANKS))
sirfsoc_gpio_set_pullup(pullups);
if (!of_property_read_u32_array(np, "sirf,pulldowns", pulldowns,
SIRFSOC_GPIO_NO_OF_BANKS))
sirfsoc_gpio_set_pulldown(pulldowns);
return 0;
out:
iounmap(regs);
return err;
}
static int __init sirfsoc_gpio_init(void)
{
struct device_node *np;
np = of_find_matching_node(NULL, pinmux_ids);
if (!np)
return -ENODEV;
return sirfsoc_gpio_probe(np);
}
subsys_initcall(sirfsoc_gpio_init);
MODULE_AUTHOR("Rongjun Ying <rongjun.ying@csr.com>, "
"Yuping Luo <yuping.luo@csr.com>, "
"Barry Song <baohua.song@csr.com>");
MODULE_DESCRIPTION("SIRFSOC pin control driver");
MODULE_LICENSE("GPL");
|
bc01b50252ee341c9bea5860aa401d20f9ab2969
|
431a5c28b8dfcc7d6ca6f4f97bf370cd770547a7
|
/src/tmx/Asn_J2735/src/r63/RepeatParams.c
|
e835805729090c1b1f951be4ea0be4bb882888fe
|
[
"Apache-2.0"
] |
permissive
|
usdot-fhwa-OPS/V2X-Hub
|
134061cfb55d8c83e871f7fd4bbfa5d8d3092eb0
|
aae33e6a16b8a30e1faee31a7ee863d191be06b8
|
refs/heads/develop
| 2023-08-26T10:10:59.989176
| 2023-08-24T14:58:21
| 2023-08-24T14:58:21
| 168,020,929
| 106
| 63
| null | 2023-09-11T20:24:45
| 2019-01-28T19:16:45
|
C
|
UTF-8
|
C
| false
| false
| 4,902
|
c
|
RepeatParams.c
|
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "DSRC"
* found in "J2735_201603_ASN_CC.asn"
* `asn1c -gen-PER -fcompound-names -fincludes-quoted -fskeletons-copy`
*/
#include "RepeatParams.h"
static int
memb_offset_constraint_1(const asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
long value;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
value = *(const long *)sptr;
if((value >= 0 && value <= 1439)) {
/* Constraint check succeeded */
return 0;
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: constraint failed (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
}
static int
memb_period_constraint_1(const asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
long value;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
value = *(const long *)sptr;
if((value >= 0 && value <= 1439)) {
/* Constraint check succeeded */
return 0;
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: constraint failed (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
}
static int
memb_span_constraint_1(const asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
long value;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
value = *(const long *)sptr;
if((value >= 0 && value <= 1439)) {
/* Constraint check succeeded */
return 0;
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: constraint failed (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
}
static asn_oer_constraints_t asn_OER_memb_offset_constr_2 CC_NOTUSED = {
{ 2, 1 } /* (0..1439) */,
-1};
static asn_per_constraints_t asn_PER_memb_offset_constr_2 CC_NOTUSED = {
{ APC_CONSTRAINED, 11, 11, 0, 1439 } /* (0..1439) */,
{ APC_UNCONSTRAINED, -1, -1, 0, 0 },
0, 0 /* No PER value map */
};
static asn_oer_constraints_t asn_OER_memb_period_constr_3 CC_NOTUSED = {
{ 2, 1 } /* (0..1439) */,
-1};
static asn_per_constraints_t asn_PER_memb_period_constr_3 CC_NOTUSED = {
{ APC_CONSTRAINED, 11, 11, 0, 1439 } /* (0..1439) */,
{ APC_UNCONSTRAINED, -1, -1, 0, 0 },
0, 0 /* No PER value map */
};
static asn_oer_constraints_t asn_OER_memb_span_constr_4 CC_NOTUSED = {
{ 2, 1 } /* (0..1439) */,
-1};
static asn_per_constraints_t asn_PER_memb_span_constr_4 CC_NOTUSED = {
{ APC_CONSTRAINED, 11, 11, 0, 1439 } /* (0..1439) */,
{ APC_UNCONSTRAINED, -1, -1, 0, 0 },
0, 0 /* No PER value map */
};
asn_TYPE_member_t asn_MBR_RepeatParams_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct RepeatParams, offset),
(ASN_TAG_CLASS_CONTEXT | (0 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_NativeInteger,
0,
{ &asn_OER_memb_offset_constr_2, &asn_PER_memb_offset_constr_2, memb_offset_constraint_1 },
0, 0, /* No default value */
"offset"
},
{ ATF_NOFLAGS, 0, offsetof(struct RepeatParams, period),
(ASN_TAG_CLASS_CONTEXT | (1 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_NativeInteger,
0,
{ &asn_OER_memb_period_constr_3, &asn_PER_memb_period_constr_3, memb_period_constraint_1 },
0, 0, /* No default value */
"period"
},
{ ATF_NOFLAGS, 0, offsetof(struct RepeatParams, span),
(ASN_TAG_CLASS_CONTEXT | (2 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_NativeInteger,
0,
{ &asn_OER_memb_span_constr_4, &asn_PER_memb_span_constr_4, memb_span_constraint_1 },
0, 0, /* No default value */
"span"
},
};
static const ber_tlv_tag_t asn_DEF_RepeatParams_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_RepeatParams_tag2el_1[] = {
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* offset */
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* period */
{ (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* span */
};
asn_SEQUENCE_specifics_t asn_SPC_RepeatParams_specs_1 = {
sizeof(struct RepeatParams),
offsetof(struct RepeatParams, _asn_ctx),
asn_MAP_RepeatParams_tag2el_1,
3, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
-1, /* First extension addition */
};
asn_TYPE_descriptor_t asn_DEF_RepeatParams = {
"RepeatParams",
"RepeatParams",
&asn_OP_SEQUENCE,
asn_DEF_RepeatParams_tags_1,
sizeof(asn_DEF_RepeatParams_tags_1)
/sizeof(asn_DEF_RepeatParams_tags_1[0]), /* 1 */
asn_DEF_RepeatParams_tags_1, /* Same as above */
sizeof(asn_DEF_RepeatParams_tags_1)
/sizeof(asn_DEF_RepeatParams_tags_1[0]), /* 1 */
{ 0, 0, SEQUENCE_constraint },
asn_MBR_RepeatParams_1,
3, /* Elements count */
&asn_SPC_RepeatParams_specs_1 /* Additional specs */
};
|
fca5b033ca5faf6ef649b0207f90a70d16d2cd48
|
94096248c1de2dcf46e69ca913cedfa290e44224
|
/tests/api/test-def-prop-virtual.c
|
9a76685b3c8e3397464fbdcfd28f45264c4d133b
|
[
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] |
permissive
|
svaarala/duktape
|
612110d1a6db46226c171cfd222974b1b3651ad5
|
5e169deafbbd12823665f5d30fb4c4c04e3dfa26
|
refs/heads/master
| 2023-08-06T16:43:33.014729
| 2022-11-17T21:02:08
| 2022-11-17T21:02:08
| 15,852,088
| 4,796
| 610
|
MIT
| 2023-09-11T17:13:01
| 2014-01-12T22:16:14
|
JavaScript
|
UTF-8
|
C
| false
| false
| 5,454
|
c
|
test-def-prop-virtual.c
|
/*
* Test DUK_DEFPROP_FORCE for virtual properties.
*/
/*===
*** test_array_length_enumerable_noforce (duk_safe_call)
set array .length enumerable
==> rc=1, result='TypeError: cannot (re)define property 'length' of [object Array]'
*** test_array_length_enumerable_force (duk_safe_call)
set array .length enumerable
==> rc=1, result='TypeError: cannot (re)define property 'length' of [object Array]'
*** test_array_length_configurable_noforce (duk_safe_call)
set array .length configurable
==> rc=1, result='TypeError: cannot (re)define property 'length' of [object Array]'
*** test_array_length_configurable_force (duk_safe_call)
set array .length configurable
==> rc=1, result='TypeError: cannot (re)define property 'length' of [object Array]'
*** test_array_length_overwrite_same_noforce (duk_safe_call)
["foo","bar","quux"]
final top: 0
==> rc=0, result='undefined'
*** test_array_length_overwrite_same_force (duk_safe_call)
["foo","bar","quux"]
final top: 0
==> rc=0, result='undefined'
*** test_array_length_overwrite_bigger_noforce (duk_safe_call)
==> rc=1, result='TypeError: cannot (re)define property 'length' of [object Array]'
*** test_array_length_overwrite_bigger_force (duk_safe_call)
["foo","bar","quux",undefined,undefined]
final top: 0
==> rc=0, result='undefined'
*** test_array_length_overwrite_smaller_noforce (duk_safe_call)
==> rc=1, result='TypeError: cannot (re)define property 'length' of [object Array]'
*** test_array_length_overwrite_smaller_force (duk_safe_call)
["foo"]
final top: 0
==> rc=0, result='undefined'
===*/
static duk_ret_t test__array_length_enumerable(duk_context *ctx, int force) {
duk_push_array(ctx);
duk_push_string(ctx, "length");
printf("set array .length enumerable\n");
fflush(stdout);
duk_def_prop(ctx, -2, DUK_DEFPROP_SET_ENUMERABLE | (force ? DUK_DEFPROP_FORCE : 0));
duk_eval_string(ctx,
"(function (v) { print(Duktape.enc('jx', Object.getOwnPropertyDescriptor(v, 'length' ))); })");
duk_dup(ctx, -2);
duk_call(ctx, 1);
duk_pop_2(ctx);
printf("final top: %ld\n", (long) duk_get_top(ctx));
return 0;
}
static duk_ret_t test_array_length_enumerable_noforce(duk_context *ctx, void *udata) {
(void) udata;
return test__array_length_enumerable(ctx, 0);
}
static duk_ret_t test_array_length_enumerable_force(duk_context *ctx, void *udata) {
(void) udata;
return test__array_length_enumerable(ctx, 1);
}
static duk_ret_t test__array_length_configurable(duk_context *ctx, int force) {
duk_push_array(ctx);
duk_push_string(ctx, "length");
printf("set array .length configurable\n");
fflush(stdout);
duk_def_prop(ctx, -2, DUK_DEFPROP_SET_CONFIGURABLE | (force ? DUK_DEFPROP_FORCE : 0));
duk_eval_string(ctx,
"(function (v) { print(Duktape.enc('jx', Object.getOwnPropertyDescriptor(v, 'length' ))); })");
duk_dup(ctx, -2);
duk_call(ctx, 1);
duk_pop_2(ctx);
printf("final top: %ld\n", (long) duk_get_top(ctx));
return 0;
}
static duk_ret_t test_array_length_configurable_noforce(duk_context *ctx, void *udata) {
(void) udata;
return test__array_length_configurable(ctx, 0);
}
static duk_ret_t test_array_length_configurable_force(duk_context *ctx, void *udata) {
(void) udata;
return test__array_length_configurable(ctx, 1);
}
static duk_ret_t test__length_overwrite(duk_context *ctx, int force, int new_len) {
duk_eval_string(ctx,
"(function () {\n"
" var arr = [ 'foo', 'bar', 'quux' ];\n"
" Object.defineProperty(arr, 'length', { writable: false });\n"
" return arr;\n"
"})()\n");
/* Array .length is not writable; with DUK_DEFPROP_FORCE we can still
* write it.
*/
duk_push_string(ctx, "length");
duk_push_int(ctx, new_len);
duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE | (force ? DUK_DEFPROP_FORCE : 0));
duk_eval_string(ctx,
"(function (v) { print(Duktape.enc('jx', v)); })");
duk_dup(ctx, -2);
duk_call(ctx, 1);
duk_pop_2(ctx);
printf("final top: %ld\n", (long) duk_get_top(ctx));
return 0;
}
static duk_ret_t test_array_length_overwrite_same_noforce(duk_context *ctx, void *udata) {
(void) udata;
return test__length_overwrite(ctx, 0, 3);
}
static duk_ret_t test_array_length_overwrite_same_force(duk_context *ctx, void *udata) {
(void) udata;
return test__length_overwrite(ctx, 1, 3);
}
static duk_ret_t test_array_length_overwrite_bigger_noforce(duk_context *ctx, void *udata) {
(void) udata;
return test__length_overwrite(ctx, 0, 5);
}
static duk_ret_t test_array_length_overwrite_bigger_force(duk_context *ctx, void *udata) {
(void) udata;
return test__length_overwrite(ctx, 1, 5);
}
static duk_ret_t test_array_length_overwrite_smaller_noforce(duk_context *ctx, void *udata) {
(void) udata;
return test__length_overwrite(ctx, 0, 1);
}
static duk_ret_t test_array_length_overwrite_smaller_force(duk_context *ctx, void *udata) {
(void) udata;
return test__length_overwrite(ctx, 1, 1);
}
void test(duk_context *ctx) {
TEST_SAFE_CALL(test_array_length_enumerable_noforce);
TEST_SAFE_CALL(test_array_length_enumerable_force);
TEST_SAFE_CALL(test_array_length_configurable_noforce);
TEST_SAFE_CALL(test_array_length_configurable_force);
TEST_SAFE_CALL(test_array_length_overwrite_same_noforce);
TEST_SAFE_CALL(test_array_length_overwrite_same_force);
TEST_SAFE_CALL(test_array_length_overwrite_bigger_noforce);
TEST_SAFE_CALL(test_array_length_overwrite_bigger_force);
TEST_SAFE_CALL(test_array_length_overwrite_smaller_noforce);
TEST_SAFE_CALL(test_array_length_overwrite_smaller_force);
}
|
a53e2158940f0f3a0bf28968c650692439825254
|
c26d7b0ed875357278e61627da2da0650da77986
|
/src/libm/erf.c
|
e83bbd3a4868c91994a5eefa6f1e4e9adafd62c9
|
[
"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,438
|
c
|
erf.c
|
/*
* C program for floating point error function
*
* erf(x) returns the error function of its argument
* erfc(x) returns 1.0-erf(x)
*
* erf(x) is defined by
* ${2 over sqrt(pi)} int from 0 to x e sup {-t sup 2} dt$
*
* the entry for erfc is provided because of the
* extreme loss of relative accuracy if erf(x) is
* called for large x and the result subtracted
* from 1. (e.g. for x= 10, 12 places are lost).
*
* There are no error returns.
*
* Calls exp.
*
* Coefficients for large x are #5667 from Hart & Cheney (18.72D).
*/
#include <math.h>
#define M 7
#define N 9
int errno;
static double torp = 1.1283791670955125738961589031;
static double p1[] = {
0.804373630960840172832162e5,
0.740407142710151470082064e4,
0.301782788536507577809226e4,
0.380140318123903008244444e2,
0.143383842191748205576712e2,
-.288805137207594084924010e0,
0.007547728033418631287834e0,
};
static double q1[] = {
0.804373630960840172826266e5,
0.342165257924628539769006e5,
0.637960017324428279487120e4,
0.658070155459240506326937e3,
0.380190713951939403753468e2,
0.100000000000000000000000e1,
0.0,
};
static double p2[] = {
0.18263348842295112592168999e4,
0.28980293292167655611275846e4,
0.2320439590251635247384768711e4,
0.1143262070703886173606073338e4,
0.3685196154710010637133875746e3,
0.7708161730368428609781633646e2,
0.9675807882987265400604202961e1,
0.5641877825507397413087057563e0,
0.0,
};
static double q2[] = {
0.18263348842295112595576438e4,
0.495882756472114071495438422e4,
0.60895424232724435504633068e4,
0.4429612803883682726711528526e4,
0.2094384367789539593790281779e4,
0.6617361207107653469211984771e3,
0.1371255960500622202878443578e3,
0.1714980943627607849376131193e2,
1.0,
};
double
erf(arg) double arg;{
double erfc();
int sign;
double argsq;
double d, n;
int i;
errno = 0;
sign = 1;
if(arg < 0.){
arg = -arg;
sign = -1;
}
if(arg < 0.5){
argsq = arg*arg;
for(n=0,d=0,i=M-1; i>=0; i--){
n = n*argsq + p1[i];
d = d*argsq + q1[i];
}
return(sign*torp*arg*n/d);
}
if(arg >= 10.)
return(sign*1.);
return(sign*(1. - erfc(arg)));
}
double
erfc(arg) double arg;{
double erf();
double exp();
double n, d;
int i;
errno = 0;
if(arg < 0.)
return(2. - erfc(-arg));
/*
if(arg < 0.5)
return(1. - erf(arg));
*/
if(arg >= 10.)
return(0.);
for(n=0,d=0,i=N-1; i>=0; i--){
n = n*arg + p2[i];
d = d*arg + q2[i];
}
return(exp(-arg*arg)*n/d);
}
|
fca6ede13de7134bfa18ef0cfed6bc754a3eea7f
|
79d343002bb63a44f8ab0dbac0c9f4ec54078c3a
|
/lib/libc/include/any-windows-any/lmwksta.h
|
d75be092cf9ff111d610221fe22b5975c6969127
|
[
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-public-domain",
"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
| 12,012
|
h
|
lmwksta.h
|
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the mingw-w64 runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#ifndef _LMWKSTA_
#define _LMWKSTA_
#ifdef __cplusplus
extern "C" {
#endif
#include <lmcons.h>
#include <lmuseflg.h>
NET_API_STATUS WINAPI NetWkstaGetInfo(LMSTR servername,DWORD level,LPBYTE *bufptr);
NET_API_STATUS WINAPI NetWkstaSetInfo(LMSTR servername,DWORD level,LPBYTE buffer,LPDWORD parm_err);
NET_API_STATUS WINAPI NetWkstaUserGetInfo(LMSTR reserved,DWORD level,LPBYTE *bufptr);
NET_API_STATUS WINAPI NetWkstaUserSetInfo(LMSTR reserved,DWORD level,LPBYTE buf,LPDWORD parm_err);
NET_API_STATUS WINAPI NetWkstaUserEnum(LMSTR servername,DWORD level,LPBYTE *bufptr,DWORD prefmaxlen,LPDWORD entriesread,LPDWORD totalentries,LPDWORD resumehandle);
NET_API_STATUS WINAPI NetWkstaTransportAdd(LMSTR servername,DWORD level,LPBYTE buf,LPDWORD parm_err);
NET_API_STATUS WINAPI NetWkstaTransportDel(LMSTR servername,LMSTR transportname,DWORD ucond);
NET_API_STATUS WINAPI NetWkstaTransportEnum(LMSTR servername,DWORD level,LPBYTE *bufptr,DWORD prefmaxlen,LPDWORD entriesread,LPDWORD totalentries,LPDWORD resumehandle);
typedef struct _WKSTA_INFO_100 {
DWORD wki100_platform_id;
LMSTR wki100_computername;
LMSTR wki100_langroup;
DWORD wki100_ver_major;
DWORD wki100_ver_minor;
} WKSTA_INFO_100,*PWKSTA_INFO_100,*LPWKSTA_INFO_100;
typedef struct _WKSTA_INFO_101 {
DWORD wki101_platform_id;
LMSTR wki101_computername;
LMSTR wki101_langroup;
DWORD wki101_ver_major;
DWORD wki101_ver_minor;
LMSTR wki101_lanroot;
} WKSTA_INFO_101,*PWKSTA_INFO_101,*LPWKSTA_INFO_101;
typedef struct _WKSTA_INFO_102 {
DWORD wki102_platform_id;
LMSTR wki102_computername;
LMSTR wki102_langroup;
DWORD wki102_ver_major;
DWORD wki102_ver_minor;
LMSTR wki102_lanroot;
DWORD wki102_logged_on_users;
} WKSTA_INFO_102,*PWKSTA_INFO_102,*LPWKSTA_INFO_102;
typedef struct _WKSTA_INFO_302{
DWORD wki302_char_wait;
DWORD wki302_collection_time;
DWORD wki302_maximum_collection_count;
DWORD wki302_keep_conn;
DWORD wki302_keep_search;
DWORD wki302_max_cmds;
DWORD wki302_num_work_buf;
DWORD wki302_siz_work_buf;
DWORD wki302_max_wrk_cache;
DWORD wki302_sess_timeout;
DWORD wki302_siz_error;
DWORD wki302_num_alerts;
DWORD wki302_num_services;
DWORD wki302_errlog_sz;
DWORD wki302_print_buf_time;
DWORD wki302_num_char_buf;
DWORD wki302_siz_char_buf;
LMSTR wki302_wrk_heuristics;
DWORD wki302_mailslots;
DWORD wki302_num_dgram_buf;
} WKSTA_INFO_302,*PWKSTA_INFO_302,*LPWKSTA_INFO_302;
typedef struct _WKSTA_INFO_402{
DWORD wki402_char_wait;
DWORD wki402_collection_time;
DWORD wki402_maximum_collection_count;
DWORD wki402_keep_conn;
DWORD wki402_keep_search;
DWORD wki402_max_cmds;
DWORD wki402_num_work_buf;
DWORD wki402_siz_work_buf;
DWORD wki402_max_wrk_cache;
DWORD wki402_sess_timeout;
DWORD wki402_siz_error;
DWORD wki402_num_alerts;
DWORD wki402_num_services;
DWORD wki402_errlog_sz;
DWORD wki402_print_buf_time;
DWORD wki402_num_char_buf;
DWORD wki402_siz_char_buf;
LMSTR wki402_wrk_heuristics;
DWORD wki402_mailslots;
DWORD wki402_num_dgram_buf;
DWORD wki402_max_threads;
} WKSTA_INFO_402,*PWKSTA_INFO_402,*LPWKSTA_INFO_402;
typedef struct _WKSTA_INFO_502{
DWORD wki502_char_wait;
DWORD wki502_collection_time;
DWORD wki502_maximum_collection_count;
DWORD wki502_keep_conn;
DWORD wki502_max_cmds;
DWORD wki502_sess_timeout;
DWORD wki502_siz_char_buf;
DWORD wki502_max_threads;
DWORD wki502_lock_quota;
DWORD wki502_lock_increment;
DWORD wki502_lock_maximum;
DWORD wki502_pipe_increment;
DWORD wki502_pipe_maximum;
DWORD wki502_cache_file_timeout;
DWORD wki502_dormant_file_limit;
DWORD wki502_read_ahead_throughput;
DWORD wki502_num_mailslot_buffers;
DWORD wki502_num_srv_announce_buffers;
DWORD wki502_max_illegal_datagram_events;
DWORD wki502_illegal_datagram_event_reset_frequency;
WINBOOL wki502_log_election_packets;
WINBOOL wki502_use_opportunistic_locking;
WINBOOL wki502_use_unlock_behind;
WINBOOL wki502_use_close_behind;
WINBOOL wki502_buf_named_pipes;
WINBOOL wki502_use_lock_read_unlock;
WINBOOL wki502_utilize_nt_caching;
WINBOOL wki502_use_raw_read;
WINBOOL wki502_use_raw_write;
WINBOOL wki502_use_write_raw_data;
WINBOOL wki502_use_encryption;
WINBOOL wki502_buf_files_deny_write;
WINBOOL wki502_buf_read_only_files;
WINBOOL wki502_force_core_create_mode;
WINBOOL wki502_use_512_byte_max_transfer;
} WKSTA_INFO_502,*PWKSTA_INFO_502,*LPWKSTA_INFO_502;
typedef struct _WKSTA_INFO_1010 {
DWORD wki1010_char_wait;
} WKSTA_INFO_1010,*PWKSTA_INFO_1010,*LPWKSTA_INFO_1010;
typedef struct _WKSTA_INFO_1011 {
DWORD wki1011_collection_time;
} WKSTA_INFO_1011,*PWKSTA_INFO_1011,*LPWKSTA_INFO_1011;
typedef struct _WKSTA_INFO_1012 {
DWORD wki1012_maximum_collection_count;
} WKSTA_INFO_1012,*PWKSTA_INFO_1012,*LPWKSTA_INFO_1012;
typedef struct _WKSTA_INFO_1027 {
DWORD wki1027_errlog_sz;
} WKSTA_INFO_1027,*PWKSTA_INFO_1027,*LPWKSTA_INFO_1027;
typedef struct _WKSTA_INFO_1028 {
DWORD wki1028_print_buf_time;
} WKSTA_INFO_1028,*PWKSTA_INFO_1028,*LPWKSTA_INFO_1028;
typedef struct _WKSTA_INFO_1032 {
DWORD wki1032_wrk_heuristics;
} WKSTA_INFO_1032,*PWKSTA_INFO_1032,*LPWKSTA_INFO_1032;
typedef struct _WKSTA_INFO_1013 {
DWORD wki1013_keep_conn;
} WKSTA_INFO_1013,*PWKSTA_INFO_1013,*LPWKSTA_INFO_1013;
typedef struct _WKSTA_INFO_1018 {
DWORD wki1018_sess_timeout;
} WKSTA_INFO_1018,*PWKSTA_INFO_1018,*LPWKSTA_INFO_1018;
typedef struct _WKSTA_INFO_1023 {
DWORD wki1023_siz_char_buf;
} WKSTA_INFO_1023,*PWKSTA_INFO_1023,*LPWKSTA_INFO_1023;
typedef struct _WKSTA_INFO_1033 {
DWORD wki1033_max_threads;
} WKSTA_INFO_1033,*PWKSTA_INFO_1033,*LPWKSTA_INFO_1033;
typedef struct _WKSTA_INFO_1041 {
DWORD wki1041_lock_quota;
} WKSTA_INFO_1041,*PWKSTA_INFO_1041,*LPWKSTA_INFO_1041;
typedef struct _WKSTA_INFO_1042 {
DWORD wki1042_lock_increment;
} WKSTA_INFO_1042,*PWKSTA_INFO_1042,*LPWKSTA_INFO_1042;
typedef struct _WKSTA_INFO_1043 {
DWORD wki1043_lock_maximum;
} WKSTA_INFO_1043,*PWKSTA_INFO_1043,*LPWKSTA_INFO_1043;
typedef struct _WKSTA_INFO_1044 {
DWORD wki1044_pipe_increment;
} WKSTA_INFO_1044,*PWKSTA_INFO_1044,*LPWKSTA_INFO_1044;
typedef struct _WKSTA_INFO_1045 {
DWORD wki1045_pipe_maximum;
} WKSTA_INFO_1045,*PWKSTA_INFO_1045,*LPWKSTA_INFO_1045;
typedef struct _WKSTA_INFO_1046 {
DWORD wki1046_dormant_file_limit;
} WKSTA_INFO_1046,*PWKSTA_INFO_1046,*LPWKSTA_INFO_1046;
typedef struct _WKSTA_INFO_1047 {
DWORD wki1047_cache_file_timeout;
} WKSTA_INFO_1047,*PWKSTA_INFO_1047,*LPWKSTA_INFO_1047;
typedef struct _WKSTA_INFO_1048 {
WINBOOL wki1048_use_opportunistic_locking;
} WKSTA_INFO_1048,*PWKSTA_INFO_1048,*LPWKSTA_INFO_1048;
typedef struct _WKSTA_INFO_1049 {
WINBOOL wki1049_use_unlock_behind;
} WKSTA_INFO_1049,*PWKSTA_INFO_1049,*LPWKSTA_INFO_1049;
typedef struct _WKSTA_INFO_1050 {
WINBOOL wki1050_use_close_behind;
} WKSTA_INFO_1050,*PWKSTA_INFO_1050,*LPWKSTA_INFO_1050;
typedef struct _WKSTA_INFO_1051 {
WINBOOL wki1051_buf_named_pipes;
} WKSTA_INFO_1051,*PWKSTA_INFO_1051,*LPWKSTA_INFO_1051;
typedef struct _WKSTA_INFO_1052 {
WINBOOL wki1052_use_lock_read_unlock;
} WKSTA_INFO_1052,*PWKSTA_INFO_1052,*LPWKSTA_INFO_1052;
typedef struct _WKSTA_INFO_1053 {
WINBOOL wki1053_utilize_nt_caching;
} WKSTA_INFO_1053,*PWKSTA_INFO_1053,*LPWKSTA_INFO_1053;
typedef struct _WKSTA_INFO_1054 {
WINBOOL wki1054_use_raw_read;
} WKSTA_INFO_1054,*PWKSTA_INFO_1054,*LPWKSTA_INFO_1054;
typedef struct _WKSTA_INFO_1055 {
WINBOOL wki1055_use_raw_write;
} WKSTA_INFO_1055,*PWKSTA_INFO_1055,*LPWKSTA_INFO_1055;
typedef struct _WKSTA_INFO_1056 {
WINBOOL wki1056_use_write_raw_data;
} WKSTA_INFO_1056,*PWKSTA_INFO_1056,*LPWKSTA_INFO_1056;
typedef struct _WKSTA_INFO_1057 {
WINBOOL wki1057_use_encryption;
} WKSTA_INFO_1057,*PWKSTA_INFO_1057,*LPWKSTA_INFO_1057;
typedef struct _WKSTA_INFO_1058 {
WINBOOL wki1058_buf_files_deny_write;
} WKSTA_INFO_1058,*PWKSTA_INFO_1058,*LPWKSTA_INFO_1058;
typedef struct _WKSTA_INFO_1059 {
WINBOOL wki1059_buf_read_only_files;
} WKSTA_INFO_1059,*PWKSTA_INFO_1059,*LPWKSTA_INFO_1059;
typedef struct _WKSTA_INFO_1060 {
WINBOOL wki1060_force_core_create_mode;
} WKSTA_INFO_1060,*PWKSTA_INFO_1060,*LPWKSTA_INFO_1060;
typedef struct _WKSTA_INFO_1061 {
WINBOOL wki1061_use_512_byte_max_transfer;
} WKSTA_INFO_1061,*PWKSTA_INFO_1061,*LPWKSTA_INFO_1061;
typedef struct _WKSTA_INFO_1062 {
DWORD wki1062_read_ahead_throughput;
} WKSTA_INFO_1062,*PWKSTA_INFO_1062,*LPWKSTA_INFO_1062;
typedef struct _WKSTA_USER_INFO_0 {
LMSTR wkui0_username;
} WKSTA_USER_INFO_0,*PWKSTA_USER_INFO_0,*LPWKSTA_USER_INFO_0;
typedef struct _WKSTA_USER_INFO_1 {
LMSTR wkui1_username;
LMSTR wkui1_logon_domain;
LMSTR wkui1_oth_domains;
LMSTR wkui1_logon_server;
} WKSTA_USER_INFO_1,*PWKSTA_USER_INFO_1,*LPWKSTA_USER_INFO_1;
typedef struct _WKSTA_USER_INFO_1101 {
LMSTR wkui1101_oth_domains;
} WKSTA_USER_INFO_1101,*PWKSTA_USER_INFO_1101,*LPWKSTA_USER_INFO_1101;
typedef struct _WKSTA_TRANSPORT_INFO_0 {
DWORD wkti0_quality_of_service;
DWORD wkti0_number_of_vcs;
LMSTR wkti0_transport_name;
LMSTR wkti0_transport_address;
WINBOOL wkti0_wan_ish;
} WKSTA_TRANSPORT_INFO_0,*PWKSTA_TRANSPORT_INFO_0,*LPWKSTA_TRANSPORT_INFO_0;
#define WKSTA_PLATFORM_ID_PARMNUM 100
#define WKSTA_COMPUTERNAME_PARMNUM 1
#define WKSTA_LANGROUP_PARMNUM 2
#define WKSTA_VER_MAJOR_PARMNUM 4
#define WKSTA_VER_MINOR_PARMNUM 5
#define WKSTA_LOGGED_ON_USERS_PARMNUM 6
#define WKSTA_LANROOT_PARMNUM 7
#define WKSTA_LOGON_DOMAIN_PARMNUM 8
#define WKSTA_LOGON_SERVER_PARMNUM 9
#define WKSTA_CHARWAIT_PARMNUM 10
#define WKSTA_CHARTIME_PARMNUM 11
#define WKSTA_CHARCOUNT_PARMNUM 12
#define WKSTA_KEEPCONN_PARMNUM 13
#define WKSTA_KEEPSEARCH_PARMNUM 14
#define WKSTA_MAXCMDS_PARMNUM 15
#define WKSTA_NUMWORKBUF_PARMNUM 16
#define WKSTA_MAXWRKCACHE_PARMNUM 17
#define WKSTA_SESSTIMEOUT_PARMNUM 18
#define WKSTA_SIZERROR_PARMNUM 19
#define WKSTA_NUMALERTS_PARMNUM 20
#define WKSTA_NUMSERVICES_PARMNUM 21
#define WKSTA_NUMCHARBUF_PARMNUM 22
#define WKSTA_SIZCHARBUF_PARMNUM 23
#define WKSTA_ERRLOGSZ_PARMNUM 27
#define WKSTA_PRINTBUFTIME_PARMNUM 28
#define WKSTA_SIZWORKBUF_PARMNUM 29
#define WKSTA_MAILSLOTS_PARMNUM 30
#define WKSTA_NUMDGRAMBUF_PARMNUM 31
#define WKSTA_WRKHEURISTICS_PARMNUM 32
#define WKSTA_MAXTHREADS_PARMNUM 33
#define WKSTA_LOCKQUOTA_PARMNUM 41
#define WKSTA_LOCKINCREMENT_PARMNUM 42
#define WKSTA_LOCKMAXIMUM_PARMNUM 43
#define WKSTA_PIPEINCREMENT_PARMNUM 44
#define WKSTA_PIPEMAXIMUM_PARMNUM 45
#define WKSTA_DORMANTFILELIMIT_PARMNUM 46
#define WKSTA_CACHEFILETIMEOUT_PARMNUM 47
#define WKSTA_USEOPPORTUNISTICLOCKING_PARMNUM 48
#define WKSTA_USEUNLOCKBEHIND_PARMNUM 49
#define WKSTA_USECLOSEBEHIND_PARMNUM 50
#define WKSTA_BUFFERNAMEDPIPES_PARMNUM 51
#define WKSTA_USELOCKANDREADANDUNLOCK_PARMNUM 52
#define WKSTA_UTILIZENTCACHING_PARMNUM 53
#define WKSTA_USERAWREAD_PARMNUM 54
#define WKSTA_USERAWWRITE_PARMNUM 55
#define WKSTA_USEWRITERAWWITHDATA_PARMNUM 56
#define WKSTA_USEENCRYPTION_PARMNUM 57
#define WKSTA_BUFFILESWITHDENYWRITE_PARMNUM 58
#define WKSTA_BUFFERREADONLYFILES_PARMNUM 59
#define WKSTA_FORCECORECREATEMODE_PARMNUM 60
#define WKSTA_USE512BYTESMAXTRANSFER_PARMNUM 61
#define WKSTA_READAHEADTHRUPUT_PARMNUM 62
#define WKSTA_OTH_DOMAINS_PARMNUM 101
#define TRANSPORT_QUALITYOFSERVICE_PARMNUM 201
#define TRANSPORT_NAME_PARMNUM 202
#ifdef __cplusplus
}
#endif
#endif
|
64ab344b37af40b8877b238eff3e48ba24f6bd5b
|
f367e4b66a1ee42e85830b31df88f63723c36a47
|
/plugins/in_docker/docker.h
|
d3814c390500b856c96da120c004771bab33f868
|
[
"Apache-2.0"
] |
permissive
|
fluent/fluent-bit
|
06873e441162b92941024e9a7e9e8fc934150bf7
|
1a41f49dc2f3ae31a780caa9ffd6137b1d703065
|
refs/heads/master
| 2023-09-05T13:44:55.347372
| 2023-09-05T10:14:33
| 2023-09-05T10:14:33
| 29,933,948
| 4,907
| 1,565
|
Apache-2.0
| 2023-09-14T10:17:02
| 2015-01-27T20:41:52
|
C
|
UTF-8
|
C
| false
| false
| 3,128
|
h
|
docker.h
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* Fluent Bit
* ==========
* Copyright (C) 2015-2022 The Fluent Bit Authors
*
* 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 FLB_IN_DOCKER_H
#define FLB_IN_DOCKER_H
#include <fluent-bit/flb_info.h>
#include <fluent-bit/flb_config.h>
#include <fluent-bit/flb_input.h>
#include <fluent-bit/flb_utils.h>
#include <fluent-bit/flb_log_event_encoder.h>
#define CURRENT_DIR "."
#define PREV_DIR ".."
#define OS_DIR_TYPE 4
#define DOCKER_LONG_ID_LEN 64
#define DOCKER_SHORT_ID_LEN 12
#define DOCKER_CGROUP_V1_MEM_DIR "/sys/fs/cgroup/memory/docker"
#define DOCKER_CGROUP_V1_CPU_DIR "/sys/fs/cgroup/cpu/docker"
#define DOCKER_CGROUP_V1_MEM_LIMIT_FILE "memory.limit_in_bytes"
#define DOCKER_CGROUP_V1_MEM_USAGE_FILE "memory.usage_in_bytes"
#define DOCKER_CGROUP_V1_CPU_USAGE_FILE "cpuacct.usage"
#define DOCKER_LIB_ROOT "/var/lib/docker/containers"
#define DOCKER_CONFIG_JSON "config.v2.json"
#define DOCKER_NAME_ARG "\"Name\""
#define DEFAULT_INTERVAL_SEC "1"
#define DEFAULT_INTERVAL_NSEC "0"
typedef struct docker_info {
char *id;
struct mk_list _head;
} docker_info;
typedef struct cpu_snapshot {
unsigned long used;
} cpu_snapshot;
typedef struct mem_snapshot {
uint64_t limit;
uint64_t used;
} mem_snapshot;
typedef struct docker_snapshot {
char *id;
char *name;
mem_snapshot *mem;
cpu_snapshot *cpu;
struct mk_list _head;
} docker_snapshot;
struct flb_docker;
struct cgroup_api {
int cgroup_version;
struct mk_list* (*get_active_docker_ids) ();
char* (*get_container_name) (struct flb_docker *, char *);
cpu_snapshot* (*get_cpu_snapshot) (struct flb_docker *, char *);
mem_snapshot* (*get_mem_snapshot) (struct flb_docker *, char *);
};
int in_docker_set_cgroup_api_v1(struct cgroup_api *api);
/* Docker Input configuration & context */
struct flb_docker {
int coll_fd; /* collector id/fd */
int interval_sec; /* interval collection time (Second) */
int interval_nsec; /* interval collection time (Nanosecond) */
struct mk_list *whitelist; /* dockers to monitor */
struct mk_list *blacklist; /* dockers to exclude */
struct cgroup_api cgroup_api;
struct flb_input_instance *ins;
struct flb_log_event_encoder log_encoder;
};
int in_docker_collect(struct flb_input_instance *i_ins,
struct flb_config *config, void *in_context);
docker_info *in_docker_init_docker_info(char *id);
#endif
|
e41aba216ff3e5b2c26bb8f6d6032c74409f3638
|
0b1f18c37bfbf6901749916a5935c49b1afe17e3
|
/core/lib/experimental/gtk/win/include/pango-1.0/pango/pango-fontset.h
|
0a222153eb43f0a48a0503b0aa252e966fb380b5
|
[
"OpenSSL",
"Zlib",
"BSD-3-Clause"
] |
permissive
|
objeck/objeck-lang
|
2e97ff6c070492e53d4a5f1bec88e07dda4b4296
|
627482005da67618fd46133d18ade2d66e515284
|
refs/heads/master
| 2023-08-24T05:38:15.489677
| 2023-08-22T20:06:43
| 2023-08-22T20:06:43
| 20,608,381
| 240
| 33
|
NOASSERTION
| 2023-09-06T20:13:02
| 2014-06-08T03:25:12
|
C
|
UTF-8
|
C
| false
| false
| 4,851
|
h
|
pango-fontset.h
|
/* Pango
* pango-fontset.h: Font set handling
*
* Copyright (C) 2001 Red Hat Software
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __PANGO_FONTSET_H__
#define __PANGO_FONTSET_H__
#include <pango/pango-coverage.h>
#include <pango/pango-types.h>
#include <glib-object.h>
G_BEGIN_DECLS
/*
* PangoFontset
*/
#define PANGO_TYPE_FONTSET (pango_fontset_get_type ())
#define PANGO_FONTSET(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_FONTSET, PangoFontset))
#define PANGO_IS_FONTSET(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_FONTSET))
#define PANGO_FONTSET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FONTSET, PangoFontsetClass))
#define PANGO_IS_FONTSET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_FONTSET))
#define PANGO_FONTSET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_FONTSET, PangoFontsetClass))
PANGO_AVAILABLE_IN_ALL
GType pango_fontset_get_type (void) G_GNUC_CONST;
typedef struct _PangoFontset PangoFontset;
typedef struct _PangoFontsetClass PangoFontsetClass;
/**
* PangoFontsetForeachFunc:
* @fontset: a `PangoFontset`
* @font: a font from @fontset
* @user_data: callback data
*
* Callback used when enumerating fonts in a fontset.
*
* See [method@Pango.Fontset.foreach].
*
* Returns: if %TRUE, stop iteration and return immediately.
*
* Since: 1.4
*/
typedef gboolean (*PangoFontsetForeachFunc) (PangoFontset *fontset,
PangoFont *font,
gpointer user_data);
/**
* PangoFontset:
*
* A `PangoFontset` represents a set of `PangoFont` to use when rendering text.
*
* A `PangoFontset` is the result of resolving a `PangoFontDescription`
* against a particular `PangoContext`. It has operations for finding the
* component font for a particular Unicode character, and for finding a
* composite set of metrics for the entire fontset.
*/
struct _PangoFontset
{
GObject parent_instance;
};
/**
* PangoFontsetClass:
* @parent_class: parent `GObjectClass`
* @get_font: a function to get the font in the fontset that contains the
* best glyph for the given Unicode character; see [method@Pango.Fontset.get_font]
* @get_metrics: a function to get overall metric information for the fonts
* in the fontset; see [method@Pango.Fontset.get_metrics]
* @get_language: a function to get the language of the fontset.
* @foreach: a function to loop over the fonts in the fontset. See
* [method@Pango.Fontset.foreach]
*
* The `PangoFontsetClass` structure holds the virtual functions for
* a particular `PangoFontset` implementation.
*/
struct _PangoFontsetClass
{
GObjectClass parent_class;
/*< public >*/
PangoFont * (*get_font) (PangoFontset *fontset,
guint wc);
PangoFontMetrics *(*get_metrics) (PangoFontset *fontset);
PangoLanguage * (*get_language) (PangoFontset *fontset);
void (*foreach) (PangoFontset *fontset,
PangoFontsetForeachFunc func,
gpointer data);
/*< private >*/
/* Padding for future expansion */
void (*_pango_reserved1) (void);
void (*_pango_reserved2) (void);
void (*_pango_reserved3) (void);
void (*_pango_reserved4) (void);
};
PANGO_AVAILABLE_IN_ALL
PangoFont * pango_fontset_get_font (PangoFontset *fontset,
guint wc);
PANGO_AVAILABLE_IN_ALL
PangoFontMetrics * pango_fontset_get_metrics (PangoFontset *fontset);
PANGO_AVAILABLE_IN_1_4
void pango_fontset_foreach (PangoFontset *fontset,
PangoFontsetForeachFunc func,
gpointer data);
G_END_DECLS
#endif /* __PANGO_FONTSET_H__ */
|
6b50d8b71bf5e07c53327e7c0c1fe18fc7401791
|
e65a4dbfbfb0e54e59787ba7741efee12f7687f3
|
/shells/es/files/patch-print.c
|
eef90611620692cd8235ee4502032899a9fb83d1
|
[
"BSD-2-Clause"
] |
permissive
|
freebsd/freebsd-ports
|
86f2e89d43913412c4f6b2be3e255bc0945eac12
|
605a2983f245ac63f5420e023e7dce56898ad801
|
refs/heads/main
| 2023-08-30T21:46:28.720924
| 2023-08-30T19:33:44
| 2023-08-30T19:33:44
| 1,803,961
| 916
| 918
|
NOASSERTION
| 2023-09-08T04:06:26
| 2011-05-26T11:15:35
| null |
UTF-8
|
C
| false
| false
| 378
|
c
|
patch-print.c
|
*** print.c.orig Fri Apr 11 15:54:36 1997
--- print.c Mon Mar 15 18:55:13 2004
***************
*** 279,285 ****
--- 279,289 ----
VA_START(format->args, fmt);
n += printfmt(format, fmt);
va_end(format->args);
+ #if NO_VA_LIST_ASSIGN
+ memcpy(format->args, saveargs, sizeof(va_list));
+ #else
format->args = saveargs;
+ #endif
return n + format->flushed;
}
|
a9f73316d4f48824f4bfe82c80ef5042684da532
|
5eff7a36d9a9917dce9111f0c3074375fe6f7656
|
/driver/xf86-video-intel/src/legacy/i810/i810_common.h
|
4cc10e8b615ac553af8f94455684854c0d6fea46
|
[
"HPND-sell-variant",
"MIT"
] |
permissive
|
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
| 10,195
|
h
|
i810_common.h
|
/* i810_common.h -- common header definitions for I810 2D/3D/DRM suite
*
* Copyright 2002 Tungsten Graphics, Inc., Cedar Park, Texas.
* 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
* PRECISION INSIGHT 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.
*
* Converted to common header format:
* Jens Owen <jens@tungstengraphics.com>
*
*
*/
/* WARNING: If you change any of these defines, make sure to change
* the kernel include file as well (i810_drm.h)
*/
#ifndef _I810_COMMON_H_
#define _I810_COMMON_H_
/* Provide substitutes for gcc's __FUNCTION__ on other compilers */
#if !defined(__GNUC__) && !defined(__FUNCTION__)
# if defined(__STDC__) && (__STDC_VERSION__>=199901L) /* C99 */
# define __FUNCTION__ __func__
# else
# define __FUNCTION__ ""
# endif
#endif
#define PFX __FILE__,__LINE__,__FUNCTION__
#define FUNCTION_NAME __FUNCTION__
#define KB(x) ((x) * 1024)
#define MB(x) ((x) * KB(1024))
#define ALIGN(i,m) (((i) + (m) - 1) & ~((m) - 1))
/* Using usleep() makes things noticably slow. */
#if 0
#define DELAY(x) usleep(x)
#else
#define DELAY(x) do {;} while (0)
#endif
#define PrintErrorState I810PrintErrorState
#define WaitRingFunc I810WaitLpRing
#define RecPtr pI810
static inline void memset_volatile(volatile void *b, int c, size_t len)
{
unsigned i;
for (i = 0; i < len; i++)
((volatile char *)b)[i] = c;
}
static inline void memcpy_volatile(volatile void *dst, const void *src,
size_t len)
{
unsigned i;
for (i = 0; i < len; i++)
((volatile char *)dst)[i] = ((const volatile char *)src)[i];
}
/* Memory mapped register access macros */
#define INREG8(addr) *(volatile uint8_t *)(RecPtr->MMIOBase + (addr))
#define INREG16(addr) *(volatile uint16_t *)(RecPtr->MMIOBase + (addr))
#define INREG(addr) *(volatile uint32_t *)(RecPtr->MMIOBase + (addr))
#define INGTT(addr) *(volatile uint32_t *)(RecPtr->GTTBase + (addr))
#define POSTING_READ(addr) (void)INREG(addr)
#define OUTREG8(addr, val) do { \
*(volatile uint8_t *)(RecPtr->MMIOBase + (addr)) = (val); \
if (I810_DEBUG&DEBUG_VERBOSE_OUTREG) { \
ErrorF("OUTREG8(0x%lx, 0x%lx) in %s\n", (unsigned long)(addr), \
(unsigned long)(val), FUNCTION_NAME); \
} \
} while (0)
#define OUTREG16(addr, val) do { \
*(volatile uint16_t *)(RecPtr->MMIOBase + (addr)) = (val); \
if (I810_DEBUG&DEBUG_VERBOSE_OUTREG) { \
ErrorF("OUTREG16(0x%lx, 0x%lx) in %s\n", (unsigned long)(addr), \
(unsigned long)(val), FUNCTION_NAME); \
} \
} while (0)
#define OUTREG(addr, val) do { \
*(volatile uint32_t *)(RecPtr->MMIOBase + (addr)) = (val); \
if (I810_DEBUG&DEBUG_VERBOSE_OUTREG) { \
ErrorF("OUTREG(0x%lx, 0x%lx) in %s\n", (unsigned long)(addr), \
(unsigned long)(val), FUNCTION_NAME); \
} \
} while (0)
/* To remove all debugging, make sure I810_DEBUG is defined as a
* preprocessor symbol, and equal to zero.
*/
#if 1
#define I810_DEBUG 0
#endif
#ifndef I810_DEBUG
#warning "Debugging enabled - expect reduced performance"
extern int I810_DEBUG;
#endif
#define DEBUG_VERBOSE_ACCEL 0x1
#define DEBUG_VERBOSE_SYNC 0x2
#define DEBUG_VERBOSE_VGA 0x4
#define DEBUG_VERBOSE_RING 0x8
#define DEBUG_VERBOSE_OUTREG 0x10
#define DEBUG_VERBOSE_MEMORY 0x20
#define DEBUG_VERBOSE_CURSOR 0x40
#define DEBUG_ALWAYS_SYNC 0x80
#define DEBUG_VERBOSE_DRI 0x100
#define DEBUG_VERBOSE_BIOS 0x200
/* Size of the mmio region.
*/
#define I810_REG_SIZE 0x80000
#define GTT_PAGE_SIZE KB(4)
#define PRIMARY_RINGBUFFER_SIZE KB(128)
#define MIN_SCRATCH_BUFFER_SIZE KB(16)
#define MAX_SCRATCH_BUFFER_SIZE KB(64)
#define HWCURSOR_SIZE GTT_PAGE_SIZE
#define HWCURSOR_SIZE_ARGB GTT_PAGE_SIZE * 4
/* Use a 64x64 HW cursor */
#define I810_CURSOR_X 64
#define I810_CURSOR_Y I810_CURSOR_X
#define PIPE_NAME(n) ('A' + (n))
extern struct pci_device *
intel_host_bridge (void);
/**
* Hints to CreatePixmap to tell the driver how the pixmap is going to be
* used.
*
* Compare to CREATE_PIXMAP_USAGE_* in the server.
*/
enum {
INTEL_CREATE_PIXMAP_TILING_X = 0x10000000,
INTEL_CREATE_PIXMAP_TILING_Y,
INTEL_CREATE_PIXMAP_TILING_NONE,
};
#ifndef _I810_DEFINES_
#define _I810_DEFINES_
#define I810_USE_BATCH 1
#define I810_DMA_BUF_ORDER 12
#define I810_DMA_BUF_SZ (1<<I810_DMA_BUF_ORDER)
#define I810_DMA_BUF_NR 256
#define I810_NR_SAREA_CLIPRECTS 8
/* Each region is a minimum of 64k, and there are at most 64 of them.
*/
#define I810_NR_TEX_REGIONS 64
#define I810_LOG_MIN_TEX_REGION_SIZE 16
/* Destbuffer state
* - backbuffer linear offset and pitch -- invarient in the current dri
* - zbuffer linear offset and pitch -- also invarient
* - drawing origin in back and depth buffers.
*
* Keep the depth/back buffer state here to acommodate private buffers
* in the future.
*/
#define I810_DESTREG_DI0 0 /* CMD_OP_DESTBUFFER_INFO (2 dwords) */
#define I810_DESTREG_DI1 1
#define I810_DESTREG_DV0 2 /* GFX_OP_DESTBUFFER_VARS (2 dwords) */
#define I810_DESTREG_DV1 3
#define I810_DESTREG_DR0 4 /* GFX_OP_DRAWRECT_INFO (4 dwords) */
#define I810_DESTREG_DR1 5
#define I810_DESTREG_DR2 6
#define I810_DESTREG_DR3 7
#define I810_DESTREG_DR4 8
#define I810_DEST_SETUP_SIZE 10
/* Context state
*/
#define I810_CTXREG_CF0 0 /* GFX_OP_COLOR_FACTOR */
#define I810_CTXREG_CF1 1
#define I810_CTXREG_ST0 2 /* GFX_OP_STIPPLE */
#define I810_CTXREG_ST1 3
#define I810_CTXREG_VF 4 /* GFX_OP_VERTEX_FMT */
#define I810_CTXREG_MT 5 /* GFX_OP_MAP_TEXELS */
#define I810_CTXREG_MC0 6 /* GFX_OP_MAP_COLOR_STAGES - stage 0 */
#define I810_CTXREG_MC1 7 /* GFX_OP_MAP_COLOR_STAGES - stage 1 */
#define I810_CTXREG_MC2 8 /* GFX_OP_MAP_COLOR_STAGES - stage 2 */
#define I810_CTXREG_MA0 9 /* GFX_OP_MAP_ALPHA_STAGES - stage 0 */
#define I810_CTXREG_MA1 10 /* GFX_OP_MAP_ALPHA_STAGES - stage 1 */
#define I810_CTXREG_MA2 11 /* GFX_OP_MAP_ALPHA_STAGES - stage 2 */
#define I810_CTXREG_SDM 12 /* GFX_OP_SRC_DEST_MONO */
#define I810_CTXREG_FOG 13 /* GFX_OP_FOG_COLOR */
#define I810_CTXREG_B1 14 /* GFX_OP_BOOL_1 */
#define I810_CTXREG_B2 15 /* GFX_OP_BOOL_2 */
#define I810_CTXREG_LCS 16 /* GFX_OP_LINEWIDTH_CULL_SHADE_MODE */
#define I810_CTXREG_PV 17 /* GFX_OP_PV_RULE -- Invarient! */
#define I810_CTXREG_ZA 18 /* GFX_OP_ZBIAS_ALPHAFUNC */
#define I810_CTXREG_AA 19 /* GFX_OP_ANTIALIAS */
#define I810_CTX_SETUP_SIZE 20
/* Texture state (per tex unit)
*/
#define I810_TEXREG_MI0 0 /* GFX_OP_MAP_INFO (4 dwords) */
#define I810_TEXREG_MI1 1
#define I810_TEXREG_MI2 2
#define I810_TEXREG_MI3 3
#define I810_TEXREG_MF 4 /* GFX_OP_MAP_FILTER */
#define I810_TEXREG_MLC 5 /* GFX_OP_MAP_LOD_CTL */
#define I810_TEXREG_MLL 6 /* GFX_OP_MAP_LOD_LIMITS */
#define I810_TEXREG_MCS 7 /* GFX_OP_MAP_COORD_SETS ??? */
#define I810_TEX_SETUP_SIZE 8
/* Driver specific DRM command indices
* NOTE: these are not OS specific, but they are driver specific
*/
#define DRM_I810_INIT 0x00
#define DRM_I810_VERTEX 0x01
#define DRM_I810_CLEAR 0x02
#define DRM_I810_FLUSH 0x03
#define DRM_I810_GETAGE 0x04
#define DRM_I810_GETBUF 0x05
#define DRM_I810_SWAP 0x06
#define DRM_I810_COPY 0x07
#define DRM_I810_DOCOPY 0x08
#define DRM_I810_OV0INFO 0x09
#define DRM_I810_FSTATUS 0x0a
#define DRM_I810_OV0FLIP 0x0b
#define DRM_I810_MC 0x0c
#define DRM_I810_RSTATUS 0x0d
#define DRM_I810_FLIP 0x0e
#endif
typedef enum _drmI810Initfunc {
I810_INIT_DMA = 0x01,
I810_CLEANUP_DMA = 0x02,
I810_INIT_DMA_1_4 = 0x03
} drmI810Initfunc;
typedef struct {
drmI810Initfunc func;
unsigned int mmio_offset;
unsigned int buffers_offset;
int sarea_priv_offset;
unsigned int ring_start;
unsigned int ring_end;
unsigned int ring_size;
unsigned int front_offset;
unsigned int back_offset;
unsigned int depth_offset;
unsigned int overlay_offset;
unsigned int overlay_physical;
unsigned int w;
unsigned int h;
unsigned int pitch;
unsigned int pitch_bits;
} drmI810Init;
typedef struct {
void *virtual;
int request_idx;
int request_size;
int granted;
} drmI810DMA;
/* Flags for clear ioctl
*/
#define I810_FRONT 0x1
#define I810_BACK 0x2
#define I810_DEPTH 0x4
typedef struct {
int clear_color;
int clear_depth;
int flags;
} drmI810Clear;
typedef struct {
int idx; /* buffer index */
int used; /* nr bytes in use */
int discard; /* client is finished with the buffer? */
} drmI810Vertex;
/* Flags for vertex ioctl
*/
#define PR_TRIANGLES (0x0<<18)
#define PR_TRISTRIP_0 (0x1<<18)
#define PR_TRISTRIP_1 (0x2<<18)
#define PR_TRIFAN (0x3<<18)
#define PR_POLYGON (0x4<<18)
#define PR_LINES (0x5<<18)
#define PR_LINESTRIP (0x6<<18)
#define PR_RECTS (0x7<<18)
#define PR_MASK (0x7<<18)
#endif
|
f969223737df06d7712b122026e15c0e3a3f6e8f
|
9ceacf33fd96913cac7ef15492c126d96cae6911
|
/sys/arch/sparc64/dev/ofwi2c.c
|
c94b12e8a0b8789ffcb7348ca9a18032de50159f
|
[] |
no_license
|
openbsd/src
|
ab97ef834fd2d5a7f6729814665e9782b586c130
|
9e79f3a0ebd11a25b4bff61e900cb6de9e7795e9
|
refs/heads/master
| 2023-09-02T18:54:56.624627
| 2023-09-02T15:16:12
| 2023-09-02T15:16:12
| 66,966,208
| 3,394
| 1,235
| null | 2023-08-08T02:42:25
| 2016-08-30T18:18:25
|
C
|
UTF-8
|
C
| false
| false
| 3,220
|
c
|
ofwi2c.c
|
/* $OpenBSD: ofwi2c.c,v 1.9 2014/02/21 21:28:26 deraadt Exp $ */
/*
* Copyright (c) 2006 Theo de Raadt
*
* 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.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <dev/i2c/i2cvar.h>
#include <dev/ofw/openfirm.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
#include <sparc64/pci_machdep.h>
#include <arch/sparc64/dev/ofwi2cvar.h>
void
ofwiic_pci_scan(struct device *self, struct i2cbus_attach_args *iba, void *aux)
{
struct pci_attach_args *pa = aux;
pcitag_t tag = pa->pa_tag;
int iba_node = PCITAG_NODE(tag);
char name[32];
int node;
for (node = OF_child(iba_node); node; node = OF_peer(node)) {
memset(name, 0, sizeof(name));
if (OF_getprop(node, "compatible", name, sizeof(name)) == -1)
continue;
if (name[0] == '\0')
continue;
if (strcmp(name, "i2c-smbus") == 0 ||
strcmp(name, "i2c") == 0)
ofwiic_scan(self, iba, &node);
}
}
void
ofwiic_scan(struct device *self, struct i2cbus_attach_args *iba, void *aux)
{
int iba_node = *(int *)aux;
extern int iic_print(void *, const char *);
struct i2c_attach_args ia;
char name[32];
u_int32_t reg[2];
int node;
for (node = OF_child(iba_node); node; node = OF_peer(node)) {
memset(name, 0, sizeof(name));
memset(reg, 0, sizeof(reg));
if (OF_getprop(node, "compatible", name, sizeof(name)) == -1)
continue;
if (name[0] == '\0')
continue;
if (OF_getprop(node, "reg", reg, sizeof(reg)) == -1)
continue;
memset(&ia, 0, sizeof(ia));
ia.ia_tag = iba->iba_tag;
ia.ia_addr = (reg[0] << 7) | (reg[1] >> 1);
ia.ia_name = name;
ia.ia_cookie = &node;
if (strncmp(ia.ia_name, "i2c-", strlen("i2c-")) == 0)
ia.ia_name += strlen("i2c-");
/* Skip non-SPD EEPROMs. */
if (strcmp(ia.ia_name, "at24c64") == 0 ||
strcmp(ia.ia_name, "at34c02") == 0) {
if (OF_getprop(node, "name", name, sizeof(name)) == -1)
continue;
if (strcmp(name, "dimm") == 0 ||
strcmp(name, "dimm-spd") == 0)
ia.ia_name = "spd";
else
continue;
}
/*
* XXX alipm crashes on some machines for an unknown reason
* when doing the periodic i2c accesses things like sensors
* need. However, devices accessed only at boot are fine.
*/
if (strcmp(self->dv_parent->dv_xname, "alipm0") == 0 &&
(ia.ia_addr < 0x50 || ia.ia_addr > 0x57)) {
iic_print(&ia, self->dv_parent->dv_xname);
printf(" skipped due to %s bugs\n",
self->dv_parent->dv_xname);
continue;
}
config_found(self, &ia, iic_print);
}
}
|
db1d05e236e89afb09761ce7be00410a4d04b53f
|
f7dc806f341ef5dbb0e11252a4693003a66853d5
|
/thirdparty/icu4c/common/msvcres.h
|
d71b5ac922ab858d98841a354a7d6aba9cd3bb9e
|
[
"ICU",
"NTP",
"NAIST-2003",
"LicenseRef-scancode-unicode",
"GPL-2.0-or-later",
"LicenseRef-scancode-autoconf-simple-exception",
"GPL-3.0-or-later",
"BSD-3-Clause",
"Autoconf-exception-generic",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"MIT",
"OFL-1.1",
"JSON",
"LicenseRef-scancode-nvidia-2002",
"Zlib",
"MPL-2.0",
"CC0-1.0",
"BSL-1.0",
"Libpng",
"Apache-2.0",
"Unlicense",
"LicenseRef-scancode-free-unknown",
"CC-BY-4.0",
"Bison-exception-2.2",
"LicenseRef-scancode-other-permissive",
"GPL-3.0-only",
"LicenseRef-scancode-unknown-license-reference",
"FTL",
"Bitstream-Vera",
"MIT-Modern-Variant"
] |
permissive
|
godotengine/godot
|
8a2419750f4851d1426a8f3bcb52cac5c86f23c2
|
970be7afdc111ccc7459d7ef3560de70e6d08c80
|
refs/heads/master
| 2023-08-21T14:37:00.262883
| 2023-08-21T06:26:15
| 2023-08-21T06:26:15
| 15,634,981
| 68,852
| 18,388
|
MIT
| 2023-09-14T21:42:16
| 2014-01-04T16:05:36
|
C++
|
UTF-8
|
C
| false
| false
| 912
|
h
|
msvcres.h
|
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
//{{NO_DEPENDENCIES}}
// Copyright (c) 2003-2010 International Business Machines
// Corporation and others. All Rights Reserved.
//
// Used by common.rc and other .rc files.
//Do not edit with Microsoft Developer Studio because it will modify this
//header the wrong way. This is here to prevent Visual Studio .NET from
//unnessarily building the resource files when it's not needed.
//
/*
These are defined before unicode/uversion.h in order to prevent
STLPort's broken stddef.h from being used when rc.exe parses this file.
*/
#define _STLP_OUTERMOST_HEADER_ID 0
#define _STLP_WINCE 1
#include "unicode/uversion.h"
#define ICU_WEBSITE "https://icu.unicode.org/"
#define ICU_COMPANY "The ICU Project"
#define ICU_PRODUCT_PREFIX "ICU"
#define ICU_PRODUCT "International Components for Unicode"
|
e5e67b4c7f54c95d13e82a15e6bb59b036186a66
|
4b15f318ba3332ee946cb0b2838c93e7935b9b89
|
/src/engine/engine_wo.c
|
513f7474f31bbf86d3ce477d37973f2e0a07c7c1
|
[
"BSD-3-Clause"
] |
permissive
|
Open-CAS/ocf
|
c4f8a5c9c1b254a905fda75be2c19bd7c8ebd450
|
016d7a8ee2822d672c308264e79bae4081e7930e
|
refs/heads/master
| 2023-05-28T08:40:51.328181
| 2023-05-11T08:11:57
| 2023-05-11T08:11:57
| 152,160,836
| 168
| 94
|
BSD-3-Clause
| 2023-09-14T08:01:50
| 2018-10-08T23:46:10
|
C
|
UTF-8
|
C
| false
| false
| 6,221
|
c
|
engine_wo.c
|
/*
* Copyright(c) 2019-2022 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "ocf/ocf.h"
#include "../ocf_cache_priv.h"
#include "cache_engine.h"
#include "engine_common.h"
#include "engine_rd.h"
#include "engine_pt.h"
#include "../metadata/metadata.h"
#include "../utils/utils_io.h"
#include "../utils/utils_cache_line.h"
#include "../utils/utils_user_part.h"
#include "../concurrency/ocf_concurrency.h"
#define OCF_ENGINE_DEBUG_IO_NAME "wo"
#include "engine_debug.h"
static void ocf_read_wo_cache_complete(struct ocf_request *req, int error)
{
if (error) {
ocf_core_stats_cache_error_update(req->core, OCF_READ);
req->error |= error;
}
if (env_atomic_dec_return(&req->req_remaining))
return;
OCF_DEBUG_RQ(req, "Completion");
if (req->error)
ocf_engine_error(req, true, "Failed to read data from cache");
ocf_req_unlock_rd(ocf_cache_line_concurrency(req->cache), req);
/* Complete request */
req->complete(req, req->error);
/* Release OCF request */
ocf_req_put(req);
}
static void ocf_read_wo_cache_io(struct ocf_request *req, uint64_t offset,
uint64_t size)
{
OCF_DEBUG_RQ(req, "Submit cache");
env_atomic_inc(&req->req_remaining);
ocf_submit_cache_reqs(req->cache, req, OCF_READ, offset, size, 1,
ocf_read_wo_cache_complete);
}
static int ocf_read_wo_cache_do(struct ocf_request *req)
{
ocf_cache_t cache = req->cache;
uint32_t s, e, i;
uint64_t line;
struct ocf_map_info *entry;
bool valid = false;
bool io = false;
uint64_t phys_prev, phys_curr = 0;
uint64_t io_start = 0;
uint64_t offset = 0;
uint64_t increment = 0;
env_atomic_set(&req->req_remaining, 1);
for (line = 0; line < req->core_line_count; ++line) {
entry = &req->map[line];
s = ocf_map_line_start_sector(req, line);
e = ocf_map_line_end_sector(req, line);
ocf_hb_cline_prot_lock_rd(&cache->metadata.lock,
req->lock_idx, entry->core_id,
entry->core_line);
/* if cacheline mapping is not sequential, send cache IO to
* previous cacheline(s) */
phys_prev = phys_curr;
if (entry->status != LOOKUP_MISS)
phys_curr = entry->coll_idx;
if (io && phys_prev + 1 != phys_curr) {
ocf_read_wo_cache_io(req, io_start, offset - io_start);
io = false;
}
/* try to seek directly to the last sector */
if (entry->status == LOOKUP_MISS) {
/* all sectors invalid */
i = e + 1;
increment = SECTORS_TO_BYTES(e - s + 1);
valid = false;
}
else if (ocf_engine_map_all_sec_valid(req, line)) {
/* all sectors valid */
i = e + 1;
increment = SECTORS_TO_BYTES(e - s + 1);
valid = true;
} else {
/* need to iterate through CL sector by sector */
i = s;
}
do {
if (i <= e) {
valid = metadata_test_valid_one(cache,
entry->coll_idx, i);
increment = 0;
do {
++i;
increment += SECTORS_TO_BYTES(1);
} while (i <= e && metadata_test_valid_one(
cache, entry->coll_idx, i)
== valid);
}
ocf_hb_cline_prot_unlock_rd(&cache->metadata.lock,
req->lock_idx, entry->core_id,
entry->core_line);
if (io && !valid) {
/* end of sequential valid region */
ocf_read_wo_cache_io(req, io_start,
offset - io_start);
io = false;
}
if (!io && valid) {
/* beginning of sequential valid region */
io = true;
io_start = offset;
}
offset += increment;
if (i <= e) {
ocf_hb_cline_prot_lock_rd(&cache->metadata.lock,
req->lock_idx, entry->core_id,
entry->core_line);
}
} while (i <= e);
}
if (io)
ocf_read_wo_cache_io(req, io_start, offset - io_start);
ocf_read_wo_cache_complete(req, 0);
return 0;
}
static void _ocf_read_wo_core_complete(struct ocf_request *req, int error)
{
if (error) {
req->error |= error;
req->info.core_error = 1;
ocf_core_stats_core_error_update(req->core, OCF_READ);
}
/* if all mapped cachelines are clean, the data we've read from core
* is valid and we can complete the request */
if (!req->info.dirty_any || req->error) {
OCF_DEBUG_RQ(req, "Completion");
req->complete(req, req->error);
ocf_req_unlock_rd(ocf_cache_line_concurrency(req->cache), req);
ocf_req_put(req);
return;
}
req->engine_handler = ocf_read_wo_cache_do;
ocf_engine_push_req_front(req, true);
}
int ocf_read_wo_do(struct ocf_request *req)
{
ocf_req_get(req);
/* Lack of cacheline repartitioning here is deliberate. WO cache mode
* reads should not affect cacheline status as reading data from the
* cache is just an internal optimization. Also WO cache mode is
* designed to be used with partitioning based on write life-time hints
* and read requests do not carry write lifetime hint by definition.
*/
if (ocf_engine_is_hit(req)) {
/* read hit - just fetch the data from cache */
OCF_DEBUG_RQ(req, "Submit cache hit");
ocf_read_generic_submit_hit(req);
} else {
OCF_DEBUG_RQ(req, "Submit core");
ocf_submit_volume_req(&req->core->volume, req,
_ocf_read_wo_core_complete);
}
ocf_engine_update_request_stats(req);
ocf_engine_update_block_stats(req);
ocf_req_put(req);
return 0;
}
int ocf_read_wo(struct ocf_request *req)
{
int lock = OCF_LOCK_ACQUIRED;
OCF_DEBUG_TRACE(req->cache);
/* Get OCF request - increase reference counter */
ocf_req_get(req);
/* Set resume call backs */
req->engine_handler = ocf_read_wo_do;
ocf_req_hash(req);
ocf_hb_req_prot_lock_rd(req); /*- Metadata RD access -----------------------*/
/* Traverse request to check if there are mapped cache lines */
ocf_engine_traverse(req);
if (ocf_engine_mapped_count(req)) {
/* There are mapped cache lines,
* lock request for READ access
*/
lock = ocf_req_async_lock_rd(
ocf_cache_line_concurrency(req->cache),
req, ocf_engine_on_resume);
}
ocf_hb_req_prot_unlock_rd(req); /*- END Metadata RD access -----------------*/
if (lock >= 0) {
if (lock != OCF_LOCK_ACQUIRED) {
/* Lock was not acquired, need to wait for resume */
OCF_DEBUG_RQ(req, "NO LOCK");
} else {
/* Lock was acquired can perform IO */
ocf_read_wo_do(req);
}
} else {
OCF_DEBUG_RQ(req, "LOCK ERROR %d", lock);
req->complete(req, lock);
ocf_req_put(req);
}
/* Put OCF request - decrease reference counter */
ocf_req_put(req);
return 0;
}
|
bce5521ff2717c1015d026164112f220047220ab
|
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
|
/sys/arch/evbarm/ifpga/ifpga_clock.c
|
d401fd772e8919770358320ca1b7748955efb537
|
[] |
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
| 9,956
|
c
|
ifpga_clock.c
|
/* $NetBSD: ifpga_clock.c,v 1.16 2020/05/29 12:30:39 rin Exp $ */
/*
* Copyright (c) 2001 ARM Ltd
* 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.
* 3. The name of the company may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHORS 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.
*/
/*
* The IFPGA has three timers. Timer 0 is clocked by the system bus clock,
* while timers 1 and 2 are clocked at 24MHz (1Mhz for Integrator CP). To
* keep things simple here, we use timers 1 and 2 only. All three timers
* are 16-bit counters that are programmable in either periodic mode or in
* one-shot mode.
*/
/* Include header files */
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ifpga_clock.c,v 1.16 2020/05/29 12:30:39 rin Exp $");
#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/atomic.h>
#include <sys/time.h>
#include <sys/timetc.h>
#include <sys/device.h>
#include <arm/cpufunc.h>
#include <machine/intr.h>
#include <evbarm/ifpga/ifpgavar.h>
#include <evbarm/ifpga/ifpgamem.h>
#include <evbarm/ifpga/ifpgareg.h>
/*
* Statistics clock interval and variance, in usec. Variance must be a
* power of two. Since this gives us an even number, not an odd number,
* we discard one case and compensate. That is, a variance of 1024 would
* give us offsets in [0..1023]. Instead, we take offsets in [1..1023].
* This is symmetric about the point 512, or statvar/2, and thus averages
* to that value (assuming uniform random numbers).
*/
static int statvar = 1024 / 4; /* {stat,prof}clock variance */
static int statmin; /* statclock interval - variance/2 */
static int profmin; /* profclock interval - variance/2 */
static int timer2min; /* current, from above choices */
static int statprev; /* previous value in stat timer */
#define TIMER_1_CLEAR (IFPGA_TIMER1_BASE + TIMERx_CLR)
#define TIMER_1_LOAD (IFPGA_TIMER1_BASE + TIMERx_LOAD)
#define TIMER_1_VALUE (IFPGA_TIMER1_BASE + TIMERx_VALUE)
#define TIMER_1_CTRL (IFPGA_TIMER1_BASE + TIMERx_CTRL)
#define TIMER_2_CLEAR (IFPGA_TIMER2_BASE + TIMERx_CLR)
#define TIMER_2_LOAD (IFPGA_TIMER2_BASE + TIMERx_LOAD)
#define TIMER_2_VALUE (IFPGA_TIMER2_BASE + TIMERx_VALUE)
#define TIMER_2_CTRL (IFPGA_TIMER2_BASE + TIMERx_CTRL)
#define COUNTS_PER_SEC (IFPGA_TIMER1_FREQ / 16)
static u_int ifpga_get_timecount(struct timecounter *);
static struct timecounter ifpga_timecounter = {
.tc_get_timecount = ifpga_get_timecount,
.tc_counter_mask = 0xffffffff,
.tc_frequency = COUNTS_PER_SEC,
.tc_name = "ifpga",
.tc_quality = 100,
};
static volatile uint32_t ifpga_base;
extern struct ifpga_softc *ifpga_sc;
extern device_t ifpga_dev;
static int clock_started = 0;
static int load_timer(int, int);
static inline u_int
getclock(void)
{
return bus_space_read_4(ifpga_sc->sc_iot, ifpga_sc->sc_tmr_ioh,
TIMER_1_VALUE);
}
static inline u_int
getstatclock(void)
{
return bus_space_read_4(ifpga_sc->sc_iot, ifpga_sc->sc_tmr_ioh,
TIMER_2_VALUE);
}
/*
* int clockhandler(struct clockframe *frame)
*
* Function called by timer 1 interrupts.
* This just clears the interrupt condition and calls hardclock().
*/
static int
clockhandler(void *fr)
{
struct clockframe *frame = (struct clockframe *)fr;
bus_space_write_4(ifpga_sc->sc_iot, ifpga_sc->sc_tmr_ioh,
TIMER_1_CLEAR, 0);
atomic_add_32(&ifpga_base, ifpga_sc->sc_clock_count);
hardclock(frame);
return 0; /* Pass the interrupt on down the chain */
}
/*
* int statclockhandler(struct clockframe *frame)
*
* Function called by timer 2 interrupts.
* Add some random jitter to the clock, and then call statclock().
*/
static int
statclockhandler(void *fr)
{
struct clockframe *frame = (struct clockframe *) fr;
int newint, r, var;
var = statvar;
do {
r = random() & (var - 1);
} while (r == 0);
newint = timer2min + r;
if (newint & ~0x0000ffff)
panic("statclockhandler: statclock variance too large");
/*
* The timer was automatically reloaded with the previous latch
* value at the time of the interrupts. Compensate now for the
* amount of time that has run off since then, plus one tick
* roundoff. This should keep us closer to the mean.
*/
r = (statprev - getstatclock() + 1);
if (r < newint) {
newint -= r;
r = 0;
}
else
printf("statclockhandler: Statclock overrun\n");
statprev = load_timer(IFPGA_TIMER2_BASE, newint);
statclock(frame);
if (r)
/*
* We've completely overrun the previous interval,
* make sure we report the correct number of ticks.
*/
statclock(frame);
return 0; /* Pass the interrupt on down the chain */
}
static int
load_timer(int base, int intvl)
{
int control;
if (intvl & ~0x0000ffff)
panic("clock: Invalid interval");
#if defined(INTEGRATOR_CP)
control = (TIMERx_CTRL_ENABLE | TIMERx_CTRL_MODE_PERIODIC |
TIMERx_CTRL_PRESCALE_DIV16 | TIMERx_CTRL_RAISE_IRQ);
#else
control = (TIMERx_CTRL_ENABLE | TIMERx_CTRL_MODE_PERIODIC |
TIMERx_CTRL_PRESCALE_DIV16);
#endif
bus_space_write_4(ifpga_sc->sc_iot, ifpga_sc->sc_tmr_ioh,
base + TIMERx_LOAD, intvl);
bus_space_write_4(ifpga_sc->sc_iot, ifpga_sc->sc_tmr_ioh,
base + TIMERx_CTRL, control);
bus_space_write_4(ifpga_sc->sc_iot, ifpga_sc->sc_tmr_ioh,
base + TIMERx_CLR, 0);
return intvl;
}
/*
* void setstatclockrate(int hz)
*
* We assume that hz is either stathz or profhz, and that neither will
* change after being set by cpu_initclocks(). We could recalculate the
* intervals here, but that would be a pain.
*/
void
setstatclockrate(int new_hz)
{
if (new_hz == stathz)
timer2min = statmin;
else
timer2min = profmin;
}
/*
* void cpu_initclocks(void)
*
* Initialise the clocks.
*/
void
cpu_initclocks(void)
{
int intvl;
int statint;
int profint;
int minint;
if (hz < 50 || COUNTS_PER_SEC % hz) {
printf("cannot get %d Hz clock; using 100 Hz\n", hz);
hz = 100;
tick = 1000000 / hz;
}
if (stathz == 0)
stathz = hz;
else if (stathz < 50 || COUNTS_PER_SEC % stathz) {
printf("cannot get %d Hz statclock; using 100 Hz\n", stathz);
stathz = 100;
}
if (profhz == 0)
profhz = stathz * 5;
else if (profhz < stathz || COUNTS_PER_SEC % profhz) {
printf("cannot get %d Hz profclock; using %d Hz\n", profhz,
stathz);
profhz = stathz;
}
intvl = COUNTS_PER_SEC / hz;
statint = COUNTS_PER_SEC / stathz;
profint = COUNTS_PER_SEC / profhz;
minint = statint / 2 + 100;
while (statvar > minint)
statvar >>= 1;
/* Adjust interval counts, per note above. */
intvl--;
statint--;
profint--;
/* Calculate the base reload values. */
statmin = statint - (statvar >> 1);
profmin = profint - (statvar >> 1);
timer2min = statmin;
statprev = statint;
/* Report the clock frequencies */
printf("clock: hz=%d stathz = %d profhz = %d\n", hz, stathz, profhz);
/* Setup timer 1 and claim interrupt */
ifpga_sc->sc_clockintr = ifpga_intr_establish(IFPGA_TIMER1_IRQ,
IPL_CLOCK, clockhandler, 0);
if (ifpga_sc->sc_clockintr == NULL)
panic("%s: Cannot install timer 1 interrupt handler",
device_xname(ifpga_dev));
ifpga_sc->sc_clock_count
= load_timer(IFPGA_TIMER1_BASE, intvl);
/*
* Use ticks per 256us for accuracy since ticks per us is often
* fractional e.g. @ 66MHz
*/
ifpga_sc->sc_clock_ticks_per_256us =
((((ifpga_sc->sc_clock_count * hz) / 1000) * 256) / 1000);
clock_started = 1;
/* Set up timer 2 as statclk/profclk. */
ifpga_sc->sc_statclockintr = ifpga_intr_establish(IFPGA_TIMER2_IRQ,
IPL_HIGH, statclockhandler, 0);
if (ifpga_sc->sc_statclockintr == NULL)
panic("%s: Cannot install timer 2 interrupt handler",
device_xname(ifpga_dev));
load_timer(IFPGA_TIMER2_BASE, statint);
tc_init(&ifpga_timecounter);
}
static u_int
ifpga_get_timecount(struct timecounter *tc)
{
u_int base, counter;
do {
base = ifpga_base;
counter = getclock();
} while (base != ifpga_base);
return base - counter;
}
/*
* Estimated loop for n microseconds
*/
/* Need to re-write this to use the timers */
/* One day soon I will actually do this */
int delaycount = 50;
void
delay(u_int n)
{
if (clock_started) {
u_int starttime;
u_int curtime;
u_int delta = 0;
u_int count_max = ifpga_sc->sc_clock_count;
starttime = getclock();
n *= IFPGA_TIMER1_FREQ / 1000000;
do {
n -= delta;
curtime = getclock();
delta = curtime - starttime;
if (curtime < starttime)
delta += count_max;
starttime = curtime;
} while (n > delta);
} else {
volatile u_int i;
if (n == 0) return;
while (n-- > 0) {
/* XXX - Seriously gross hack */
if (cputype == CPU_ID_SA110)
for (i = delaycount; --i;)
;
else
for (i = 8; --i;)
;
}
}
}
|
70419bb30067da8809c2a114e05264161c657488
|
d53b3727b12818d992a661266d325b27e8af013e
|
/route.c
|
adb114ae6c074ebf5616d2275f6b953f8f377bcf
|
[
"BSD-3-Clause",
"ISC",
"BSD-2-Clause"
] |
permissive
|
yellowman/nsh
|
9f496366ed4152795b970eae2b71f25a4f21f1e8
|
444134c06cbc0ad8b7366aba187ea98566b758a5
|
refs/heads/master
| 2023-08-31T21:00:58.141210
| 2023-08-22T11:30:19
| 2023-08-22T11:30:19
| 4,527,265
| 136
| 30
|
NOASSERTION
| 2023-09-10T14:57:06
| 2012-06-02T06:15:46
|
C
|
UTF-8
|
C
| false
| false
| 8,820
|
c
|
route.c
|
/*
* Copyright (c) 2002 Chris Cappuccio <chris@nmedia.net>
*
* 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.
*/
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <netdb.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/sysctl.h>
#include <netinet/in.h>
#include <net/route.h>
#include <arpa/inet.h>
#include "ip.h"
#include "externs.h"
#define ASSUME_NETMASK 1
void routeusage(void);
void
routeusage(void)
{
printf("%% route <destination>[/bits] <gateway> [flags]\n");
printf("%% route <destination>[/netmask] <gateway> [flags]\n");
printf("%% no route <destination>[/bits] [gateway] [flags]\n");
printf("%% no route <destination>[/netmask] [gateway] [flags]\n");
}
int
route(int argc, char **argv)
{
u_short cmd = 0;
u_int32_t net;
ip_t dest, gate;
struct in_addr tmp;
struct rt_metrics rt_metrics;
int ch, inits = 0, flags = RTF_STATIC | RTF_MPATH;
static struct nopts routeflags[] = {
{ "blackhole", no_arg, 'b' },
{ "cloning", no_arg, 'c' },
{ "expire", req_arg, 'e' },
{ "iface", no_arg, 'i' },
{ "llinfo", no_arg, 'l' },
{ "nompath", no_arg, 'u' },
{ "mtu", req_arg, 'm' },
{ "nostatic", no_arg, 'n' },
{ "proto1", no_arg, '1' },
{ "proto2", no_arg, '2' },
{ "reject", no_arg, 'r' },
{ NULL, 0, 0 }
};
if (NO_ARG(argv[0])) {
cmd = RTM_DELETE;
argc--;
argv++;
} else
cmd = RTM_ADD;
argc--;
argv++;
if (argc < 1) {
routeusage();
return(1);
}
memset(&rt_metrics, 0, sizeof(rt_metrics));
memset(&gate, 0, sizeof(ip_t));
memset(&dest, 0, sizeof(ip_t));
parse_ip_pfx(argv[0], ASSUME_NETMASK, &dest);
if (dest.family == 0)
/* bad arguments */
return(1);
argc--;
argv++;
if (argc >= 1) {
switch (dest.family) {
case AF_INET:
if (!inet_pton(AF_INET, argv[0], &gate.addr.in)) {
printf("%% %s is not an IPv4 address\n",
argv[0]);
return(1);
}
gate.family = AF_INET;
break;
case AF_INET6:
if (parse_ipv6(argv[0], &gate.addr.in6) != 0) {
printf("%% %s is not an IPv6 address\n",
argv[0]);
return(1);
}
gate.family = AF_INET6;
break;
default:
printf("%% unknown gateway address family %d\n", dest.family);
return(1);
}
flags |= RTF_GATEWAY;
argc--;
argv++;
} else if (cmd == RTM_ADD) {
printf("%% No gateway specified\n");
return(1);
}
if (argc >= 1) {
long long relative_expire;
/* parse flags */
noptind = 0;
while ((ch = nopt(argc, argv, routeflags)) != -1) {
switch (ch) {
const char *errmsg = NULL;
case 'b': /* blackhole */
flags |= RTF_BLACKHOLE;
break;
case 'c': /* cloning */
flags |= RTF_CLONING;
break;
case 'e': /* expire */
relative_expire = strtonum(
argv[noptind - 1], 0, INT_MAX, &errmsg);
if (errmsg) {
printf("%% Invalid expire %s: %s\n",
argv[noptind - 1], errmsg);
return(0);
}
rt_metrics.rmx_expire = relative_expire ?
relative_expire + time(NULL) : 0;
inits |= RTV_EXPIRE;
break;
case 'i': /* iface */
flags &= ~RTF_GATEWAY;
break;
case 'l': /* llinfo */
flags |= RTF_LLINFO;
break;
case 'u': /* nompath */
flags &= ~RTF_MPATH;
break;
case 'm': /* mtu */
rt_metrics.rmx_mtu = strtonum(
argv[noptind - 1], 64, 65536, &errmsg);
if (errmsg) {
printf("%% Invalid route mtu %s: %s\n",
argv[noptind - 1], errmsg);
return(0);
}
inits |= RTV_MTU;
break;
case 'n': /* nostatic */
flags &= ~RTF_STATIC;
break;
case '1': /* proto1 */
flags |= RTF_PROTO1;
break;
case '2': /* proto2 */
flags |= RTF_PROTO2;
break;
case 'r': /* reject */
flags |= RTF_REJECT;
break;
default:
printf("%% route: nopt table error\n");
return(0);
}
}
}
if (argc - noptind != 0) {
/* leftover salmon */
printf("%% %s", nopterr);
if (argv[noptind])
printf(": %s", argv[noptind]);
printf("\n");
routeusage();
return(0);
}
/*
* Detect if a user is adding a route with a non-network address.
*/
switch (dest.family) {
case AF_INET:
net = in4_netaddr(dest.addr.in.s_addr,
(u_int32_t)htonl(0xffffffff << (32 - dest.bitlen)));
if (ntohl(dest.addr.in.s_addr) != net) {
tmp.s_addr = htonl(net);
printf("%% Inconsistent address and mask (%s/%i?)\n",
inet_ntoa(tmp), dest.bitlen);
return(1);
}
case AF_INET6:
/* XXX invent check */
break;
default:
printf("%% unknown destination address family %d\n", dest.family);
return(1);
}
flags |= RTF_UP;
/*
* Do the route...
*/
if (flags & RTF_GATEWAY)
ip_route(&dest, &gate, cmd, flags, cli_rtable, rt_metrics, inits);
else
ip_route(&dest, NULL, cmd, flags, cli_rtable, rt_metrics, inits);
return(0);
}
int is_ip_addr(char *arg)
{
ip_t argip;
if (inet_pton(AF_INET, arg, &argip.addr.in))
return(1);
if (parse_ipv6(arg, &argip.addr.in6) == 0)
return(1);
return(0);
}
void show_route(char *arg, int tableid)
{
ip_t dest;
struct rt_metrics rt_metrics;
memset(&dest, 0, sizeof(ip_t));
memset(&rt_metrics, 0, sizeof(rt_metrics));
parse_ip_pfx(arg, NO_NETMASK, &dest);
if (dest.family == 0)
return;
ip_route(&dest, NULL, RTM_GET, RTF_UP, tableid, rt_metrics, 0);
/*
* ip_route() calls rtmsg() which calls
* print_getmsg() on RTM_GET to show a route,
* so nothing else needs to happen here...
*/
return;
}
int parse_ipv6(char *arg, struct in6_addr *addr)
{
struct addrinfo hints, *res;
int error;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET6;
hints.ai_flags = AI_NUMERICHOST;
hints.ai_socktype = SOCK_STREAM;
if ((error = getaddrinfo(arg, "0", &hints, &res)) != 0) {
return error;
}
if (sizeof(struct sockaddr_in6) != res->ai_addrlen) {
freeaddrinfo(res);
return EAI_ADDRFAMILY;
}
if (res->ai_next) {
/* not gonna happen with ai_flags = AI_NUMERICHOST */
printf("%% parse_ipv6: %s resolved to multiple values\n", arg);
freeaddrinfo(res);
return EAI_OVERFLOW;
}
in6_clearscopeid((struct sockaddr_in6 *)res->ai_addr);
memcpy(addr, &((struct sockaddr_in6 *)res->ai_addr)->sin6_addr,
sizeof(struct in6_addr));
freeaddrinfo(res);
return 0;
}
/*
* A return value with ip_t.family == 0 means failure
* (and fail message was displayed to user) otherwise argument was parsed
* into ip_t
*
* 'int type' is used if the user does not specify a netmask in the argument.
*
* The type can be ASSUME_NETMASK in which case we assume a host netmask
* (all ones) or NO_NETMASK in which case ip_t.bitlen = -1
*
* If ip_route() sees that the destination ip_t.bitlen == -1, it does not
* setup a netmask sockaddr in the routing message
*/
void parse_ip_pfx(char *arg, int type, ip_t *argip)
{
struct in_addr mask;
char *q, *s;
q = strchr(arg, '/');
if (q)
*q = '\0';
if (inet_pton(AF_INET, arg, &argip->addr.in)) {
argip->family = AF_INET;
} else if (parse_ipv6(arg, &argip->addr.in6) == 0) {
argip->family = AF_INET6;
} else {
argip->family = 0;
printf("%% %s is not an IPv4 or IPv6 address\n", arg);
return;
}
if (q) {
s = q + 1;
if (argip->family == AF_INET && inet_pton(AF_INET, s, &mask)) {
mask.s_addr = ntohl(mask.s_addr);
argip->bitlen = mask.s_addr ? 33 - ffs(mask.s_addr) : 0;
} else {
if(strspn(s, "0123456789") == strlen(s)) {
/* assume bits after slash */
argip->bitlen = strtoul(s, 0, 0);
if ((argip->family == AF_INET6 &&
argip->bitlen > 128) ||
(argip->family == AF_INET &&
argip->bitlen > 32)) {
printf("%% Invalid bit length\n");
argip->family = 0;
return;
}
} else {
printf("%% Invalid mask specified\n");
argip->family = 0;
return;
}
}
} else {
/*
* If no netmask was specified, we assume the user refers to
* a host and not a network. Or not.
*/
switch (type) {
case NO_NETMASK:
argip->bitlen = -1;
break;
case ASSUME_NETMASK:
argip->bitlen = argip->family == AF_INET ? 32 : 128;
break;
default:
printf("%% parse_ip: Internal error\n");
argip->family = 0;
break;
}
}
return;
}
|
c1abcd5810e8a497f2ddbff04ac8fd4cf511ba7d
|
0744dcc5394cebf57ebcba343747af6871b67017
|
/os/board/rtl8721csm/src/component/soc/realtek/amebad/fwlib/include/rtl8721d_lcdc.h
|
9f8a3ed72fb42896634eb906e71c729baff0e518
|
[
"GPL-1.0-or-later",
"BSD-3-Clause",
"ISC",
"MIT",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-other-permissive",
"Apache-2.0"
] |
permissive
|
Samsung/TizenRT
|
96abf62f1853f61fcf91ff14671a5e0c6ca48fdb
|
1a5c2e00a4b1bbf4c505bbf5cc6a8259e926f686
|
refs/heads/master
| 2023-08-31T08:59:33.327998
| 2023-08-08T06:09:20
| 2023-08-31T04:38:20
| 82,517,252
| 590
| 719
|
Apache-2.0
| 2023-09-14T06:54:49
| 2017-02-20T04:38:30
|
C
|
UTF-8
|
C
| false
| false
| 53,587
|
h
|
rtl8721d_lcdc.h
|
/**
******************************************************************************
* @file rtl8721d_lcdc.h
* @author
* @version V1.0.0
* @date 2017-08-07
* @brief This file contains all the functions prototypes for the LCDC firmware
* library.
******************************************************************************
* @attention
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
*
* Copyright(c) 2017, Realtek Semiconductor Corporation. All rights reserved.
******************************************************************************
*/
#ifndef _RTL8721D_LCDC_H_
#define _RTL8721D_LCDC_H_
/** @addtogroup AmebaD_Periph_Driver
* @{
*/
/** @defgroup LCDC
* @{
*/
/** @addtogroup LCDC
* @verbatim
*****************************************************************************************
* Introduction
*****************************************************************************************
* LCDC:
* - Base Address: LCDC (0x40070000)
* - Support RGB565 data format
* - SYS_CLK: 100MHz
* - Support 8-bit /16-bit MCU i8080 parallel interface
* Support resolution of 8-/16-bit mode can be (1024x1024) for still picture display
* Support resolution of 8-bit mode can be (645x645) for animate display when refresh rate is 30F/S
* Support resolution of 16-bit mode can be (912x912) for animate display when refresh rate is 30F/S
* - MCU I/F mode supports:
* IO mode
* Trigger DMA mode
* MCU VSYNC mode
* MCU TE mode
* - Support 6-/16-bit RGB parallel Interface
* Support resolution of 6-bit mode is less than (527x527) for animate display when refresh rate is 60F/S
* Support resolution of 16-bit mode is less than (912x912) for animate display when refresh rate is 60F/S
* - RGB I/F mode supports:
* DE mode
* HV mode
* -Support LED dot matrix display interface like 04/08/12/75
* -LED I/F mode supports:
* single channel and single color mode
* single channel and two colors mode
* single channel and three colors mode
* two channel and single color mode
* two channel and two colors mode
* two channel and three colors mode
*
*****************************************************************************************
* How to use IO mode in LCDC MCU I/F mode
*****************************************************************************************
* To use the LCDC MCU I/F IO mode, the following steps are mandatory.
*
* 1. Enable LCDC peripheral clock.
*
* 2. Configure the LCDC pinmux.
*
* 3. Use the following function to set default parameters. Change other parameters if needed, such as 8 bit
* or 16 bit parallel interface, data/write/read/cs/rs pulse active level, write/read pulse width etc.
* LCDC_MCUStructInit(LCDC_MCUInitTypeDef* LCDC_MCUInitStruct);
*
* 4. Initialize the hardware use step3 parameters.
* LCDC_MCUInit(LCDC_TypeDef* LCDCx, LCDC_MCUInitTypeDef* LCDC_MCUInitStruct);
*
* 5. Enable the LCDC using the function LCDC_Cmd().
*
* 6. Send command to LCM using the function LCDC_MCUIOWriteCmd() to initialize the LCD module.
*
* 7. write/read data to/from LCM using the function LCDC_MCUIOWriteData() and LCDC_MCUIOReadData()
* and send command to LCM to drive LCD displaying.
*
*****************************************************************************************
* How to use trigger DMA mode in LCDC MCU I/F mode
*****************************************************************************************
* To use the LCDC MCU I/F trigger DMA mode, the following steps are mandatory.
*
* 1. Enable LCDC peripheral clock.
*
* 2. Configure the LCDC pinmux.
*
* 3. Configure LCDC working in MCU IO mode, send commands and parameters to LCM to initialize LCD.
*
* 4. Configure the LCDC_MCUInitStruct parameter corresponding to trigger DMA mode; change other parameters if needed.
* LCDC_MCUStructInit(LCDC_MCUInitTypeDef* LCDC_MCUInitStruct);
* LCDC_MCUInitStruct->LCDC_MCUMode = LCDC_MCU_DMA_MODE;
* LCDC_MCUInitStruct->LCDC_MCUDMAMode = LCDC_TRIGGER_DMA_MODE;
*
* 5. Configure the LCDC_MCUInitStruct parameter corresponding to plane size.
*
* 6. Initialize the hardware use step4,5 parameters.
* LCDC_MCUInit(LCDC_TypeDef* LCDCx, LCDC_MCUInitTypeDef* LCDC_MCUInitStruct)
*
* 7. Configure the LCDC DMA parameters using the function LCDC_DMAModeConfig(), malloc image buffer and arrange
* image base address using the function LCDC_DMAImageBaseAddrConfig().
*
* 8. Enable LCDC interrupt if needed using the function LCDC_INTConfig().
*
* 9. Enable the LCDC using the function LCDC_Cmd().
*
* 10. Trigger one frame transfer using the function LCDC_MCUDMATrigger() and update the image buffer to change
* the display effect.
*
*****************************************************************************************
* How to use VSYNC mode in LCDC MCU I/F mode
*****************************************************************************************
* To use the LCDC MCU I/F VSYNC mode, the following steps are mandatory.
*
* 1. Enable LCDC peripheral clock.
*
* 2. Configure the LCDC pinmux.
*
* 3. Configure LCDC working in MCU IO mode, send commands and parameters to LCM to let LCD working in VSYNC mode.
*
* 4. Configure the LCDC_MCUInitStruct parameter corresponding to VSYNC mode; change other parameters if needed, such as
* VSYNC pulse active level, VSYNC pulse width, VSYNC idle period.
* LCDC_MCUStructInit(LCDC_MCUInitTypeDef* LCDC_MCUInitStruct);
* LCDC_MCUInitStruct->LCDC_MCUMode = LCDC_MCU_DMA_MODE;
* LCDC_MCUInitStruct->LCDC_MCUDMAMode = LCDC_AUTO_DMA_MODE;
* LCDC_MCUInitStruct->LCDC_MCUSyncMode = LCDC_MCU_SYNC_WITH_VSYNC;
*
* 5. Configure the LCDC_MCUInitStruct parameter corresponding to plane size.
*
* 6. Initialize the hardware use step4,5 parameters.
* LCDC_MCUInit(LCDC_TypeDef* LCDCx, LCDC_MCUInitTypeDef* LCDC_MCUInitStruct)
*
* 7. Configure the LCDC DMA parameters using the function LCDC_DMAModeConfig(), malloc image buffer and arrange
* image base address using the function LCDC_DMAImageBaseAddrConfig().
*
* 8. Enable the specified LCDC interrupt if needed using the function LCDC_INTConfig().
*
* 9. Enable the LCDC using the function LCDC_Cmd().
*
* 10. The LCDC can transfer image data to LCM automatically synchronized with the VSYNC signal and you can update the
* image buffer to change the display effect.
*
*****************************************************************************************
* How to use TE mode in LCDC MCU I/F mode
*****************************************************************************************
* To use the LCDC MCU I/F TE mode, the following steps are mandatory.
*
* 1. Enable LCDC peripheral clock.
*
* 2. Configure the LCDC pinmux.
*
* 3. Configure LCDC working in MCU IO mode, send commands and parameters to LCM to let LCD working in TE mode.
*
* 4. Configure the LCDC_MCUInitStruct parameter corresponding to VSYNC mode; change other parameters if needed, such as
* VSYNC pulse active level, VSYNC pulse width, VSYNC idle period etc.
* LCDC_MCUStructInit(LCDC_MCUInitTypeDef* LCDC_MCUInitStruct);
* LCDC_MCUInitStruct->LCDC_MCUMode = LCDC_MCU_DMA_MODE;
* LCDC_MCUInitStruct->LCDC_MCUDMAMode = LCDC_AUTO_DMA_MODE;
* LCDC_MCUInitStruct->LCDC_MCUSyncMode = LCDC_MCU_SYNC_WITH_TE;
*
* 5. Configure the LCDC_MCUInitStruct parameter corresponding to plane size.
*
* 6. Initialize the hardware use step 4,5 parameters.
* LCDC_MCUInit(LCDC_TypeDef* LCDCx, LCDC_MCUInitTypeDef* LCDC_MCUInitStruct)
*
* 7. Configure the LCDC DMA parameters using the function LCDC_DMAModeConfig(), malloc image buffer and arrange
* image base address using the function LCDC_DMAImageBaseAddrConfig().
*
* 8. Enable the specified LCDC interrupt if needed using the function LCDC_INTConfig().
*
* 9. Enable the LCDC using the function LCDC_Cmd().
*
* 10. The LCDC can transfer image data to LCM automatically synchronized with the TE signal from LCM and you can update the
* image buffer to change the display effect.
*
*****************************************************************************************
* How to use DE mode in LCDC RGB I/F mode
*****************************************************************************************
* To use the LCDC RGB I/F DE mode, the following steps are mandatory.
*
* 1. Enable LCDC peripheral clock.
*
* 2. Configure the LCDC pinmux.
*
* 3. Configure LCM parameters through SPI or other interfaces if needed.
*
* 4. Configure the LCDC_RGBInitStruct parameter corresponding to DE mode; change other parameters if needed, such as
* data pulse polarity, ENABLE signal active level, VSYNC pulse active level, HSYNC pulse active level, dot clock active edge,
* VFP, VBP, VSW, HBP, HFP, HSW, refresh frequency etc.
* LCDC_RGBStructInit(LCDC_RGBInitTypeDef * LCDC_RGBInitStruct);
* LCDC_RGBInitStruct->LCDC_RGBSyncMode = LCDC_RGB_DE_MODE;
*
* 5. Configure the LCDC_RGBInitStruct parameter corresponding to plane size.
*
* 6. Initialize the hardware use step 4,5 parameters.
* LCDC_RGBInit(LCDC_TypeDef* LCDCx, LCDC_RGBInitTypeDef* LCDC_RGBInitStruct)
*
* 7. Configure the LCDC DMA parameters: set burst size using the function LCDC_DMAModeConfig(),
* set DMA FIFO under flow mode and error data using the functions LCDC_DMAUnderFlowModeConfig() and
* LCDC_DMAUnderFlowModeConfig(), malloc image buffer and arrange image base address using the function
* LCDC_DMAImageBaseAddrConfig().
*
* 8. Enable the specified LCDC interrupt if needed using the functions LCDC_INTConfig() and LCDC_LineINTPosConfig().
*
* 9. Enable the LCDC using the function LCDC_Cmd().
*
* 10. The LCDC can transfer image data to LCM automatically according to the refresh frequency and you can update the
* image buffer to change the display effect.
*
*****************************************************************************************
* How to use HV mode in LCDC RGB I/F mode
*****************************************************************************************
* To use the LCDC RGB I/F HV mode, the following steps are mandatory.
*
* 1. Enable LCDC peripheral clock.
*
* 2. Configure the LCDC pinmux.
*
* 3. Configure LCM parameters through SPI or other interfaces if needed.
*
* 4. Configure the LCDC_RGBInitStruct parameter corresponding to DE mode; change other parameters if needed, such as
* data pulse polarity, VSYNC pulse active level, HSYNC pulse active level, dot clock active edge,
* VFP, VBP, VSW, HBP, HFP, HSW, 6 bit parallel I/F or 16 bit parallel I/F mode, refresh frequency.
* LCDC_RGBStructInit(LCDC_RGBInitTypeDef * LCDC_RGBInitStruct);
*
* 5. Configure the LCDC_RGBInitStruct parameter corresponding to plane size.
*
* 6. Initialize the hardware use step 4,5 parameters.
* LCDC_RGBInit(LCDC_TypeDef* LCDCx, LCDC_RGBInitTypeDef* LCDC_RGBInitStruct)
*
* 7. Configure the LCDC DMA parameters: set burst size using the function LCDC_DMAModeConfig(),
* set DMA FIFO under flow mode and error data using the functions LCDC_DMAUnderFlowModeConfig() and
* LCDC_DMAUnderFlowModeConfig(), malloc image buffer and arrange image base address using the function
* LCDC_DMAImageBaseAddrConfig().
*
* 8. Enable the specified LCDC interrupt if needed using the functions LCDC_INTConfig() and LCDC_LineINTPosConfig().
*
* 9. Enable the LCDC using the function LCDC_Cmd().
*
* 10. The LCDC can transfer image data to LCM automatically according to the refresh frequency and you can update the
* image buffer to change the display effect.
*
*****************************************************************************************
* How to use LCDC LED I/F mode
*****************************************************************************************
* To use the LCDC LED I/F mode, the following steps are mandatory.
*
* 1. Enable LCDC peripheral clock.
*
* 2. Configure the LCDC pinmux.
*
* 3. Configure the LCDC_LEDInitStruct parameter corresponding to LED I/F mode; change other parameters if needed, such as
* color channel, color numbers, timing(latch start time, latch pulse width, OE active width), refresh frequency.
* LCDC_LEDStructInit(LCDC_LEDInitTypeDef * LCDC_LEDInitStruct)
*
* 4. Configure the LCDC_LEDInitStruct parameter corresponding to plane size.
*
* 5. Initialize the hardware use step 3, 4 parameters.
* LCDC_LEDInit(LCDC_TypeDef* LCDCx, LCDC_LEDInitTypeDef* LCDC_LEDInitStruct)
*
* 6. Configure the LCDC DMA parameters: set burst size using the function LCDC_DMAModeConfig(), malloc image buffer
* and arrange image base address using the function LCDC_DMAImageBaseAddrConfig().
*
* 7. Enable the specified LCDC interrupt if needed using the functions LCDC_INTConfig() and LCDC_LineINTPosConfig().
*
* 8. Enable the LCDC using the function LCDC_Cmd().
*
* 9. The LCDC can transfer image data to LED array board automatically according to the refresh frequency and you can update the
* image buffer to change the display effect.
*
*****************************************************************************************
* @endverbatim
*/
/*===================================================================================================*/
#define LCDC_SYS_CLK (100000000)
/*===================================================================================================*/
/* Exported Types --------------------------------------------------------*/
/** @defgroup LCDC_Exported_Types LCDC Exported Types
* @{
*/
/**
* @brief LCDC MCU I/F Mode Initialization structure definition
*/
typedef struct
{
u32 LCDC_MCUIfMode; /*!< Specifies the LCDC MCU Interface Mode.
This parameter can be a value of @ref LCDC_MCU_IF_MODE_define. */
u32 LCDC_MCUMode; /*!< Specifies the LCDC MCU Mode.
This parameter can be a value of @ref LCDC_MCU_MODE_define. */
u32 LCDC_MCUDMAMode; /*!< Specifies the LCDC MCU DMA Mode.
This parameter can be a value of @ref LCDC_DMA_MODE_define. */
u32 LCDC_MCUImgHeight; /*!< Specifies the height of the LCDC PlANE SIZE.
This parameter can be a number between 0x000 and 0xfff. */
u32 LCDC_MCUImgWidth; /*!< Specifies the width of the LCDC PlANE SIZE.
This parameter can be a number between 0x000 and 0xfff. */
u32 LCDC_MCUSyncMode; /*!< Specifies the LCDC MCU synchronize mode.
This parameter can be a value of @ref LCDC_MCU_SYNC_MODE_define. */
u32 LCDC_MCUVsyncPulPlrty; /*!< Specifies the LCDC MCU vsync pulse polarity.
This parameter can be a value of @ref LCDC_MCU_VSYNC_PUL_POLARITY_define. */
u32 LCDC_MCUTEPulPlrty; /*!< Specifies the LCDC MCU TE pulse polarity.
This parameter can be a value of @ref LCDC_MCU_TE_PUL_POLARITY_define.*/
u32 LCDC_MCUTEDelay; /*!< Specifies the LCDC MCU TE delay interval, This interval is from
detected TE signal to starting frame transfer. For more details of this value,
refer to the TEDELAY field in register LCDC_MCU_CFG in the LCDC Specification.
This parameter can be a number between 5 and 65539. Unit: WR pulse width. */
u32 LCDC_MCUDataPulPlrty; /*!< Specifies the LCDC MCU data pulse polarity.
This parameter can be a value of @ref LCDC_MCU_DATA_PUL_POLARITY_define. */
u32 LCDC_MCURdPulPlrty; /*!< Specifies the LCDC MCU read pulse polarity.
This parameter can be a value of @ref LCDC_MCU_READ_PUL_POLARITY_define. */
u32 LCDC_MCUWrPulPlrty; /*!< Specifies the LCDC MCU write pulse polarity.
This parameter can be a value of @ref LCDC_MCU_WRITE_PUL_POLARITY_define. */
u32 LCDC_MCURsPulPlrty; /*!< Specifies the LCDC MCU RS pulse polarity.
This parameter can be a value of @ref LCDC_MCU_RS_PUL_POLARITY_define. */
u32 LCDC_MCUCsPulPlrty; /*!< Specifies the LCDC MCU CS pulse polarity.
This parameter can be a value of @ref LCDC_MCU_CS_PUL_POLARITY_define. */
u32 LCDC_MCUVsyncIdlePrd; /*!< Specifies the LCDC MCU VSYNC idle polarity. Unit: Write Pulse width.
This parameter can be a number between 0x0005 and (0x100000-0x5). */
u32 LCDC_MCUVsyncSigWidth; /*!< Specifies the LCDC MCU VSYNC signal width. Unit: Write Pulse width.
This parameter can be a number between 0x01 and 0x100. */
u32 LCDC_MCURdInacvWidth; /*!< Specifies the LCDC MCU Read Inactive pulse width. Unit: SYS_Clk.
This parameter can be a number between 0x01 and 0x800. */
u32 LCDC_MCURdAcvWidth; /*!< Specifies the LCDC MCU Read active pulse width. Unit: SYS_Clk.
This parameter can be a number between 0x01 and 0x800. */
u32 LCDC_MCUWrPulWidth; /*!< Specifies the LCDC MCU write active pulse width. Unit: SYS_Clk.
This parameter can be a even number between 0x02 and (0x400). */
u32 LCDC_MCUIOTimeOutClkNum; /*!< Specifies the LCDC MCU IO write/read timeout clock number. Unit: write clock.
This parameter can be a even number between 0x0 and 0xFFFF. */
} LCDC_MCUInitTypeDef;
/**
* @brief LCDC RGB I/F Mode Initialization structure definition
*
*/
typedef struct
{
u32 LCDC_RGBIfMode; /*!< Specifies the LCDC RGB Interface Mode.
This parameter can be a value of @ref LCDC_RGB_IF_MODE_define */
u32 LCDC_RGBImgHeight; /*!< Specifies the height of the LCDC PlANE SIZE.
This parameter can be a number between 0x000 and 0xfff. */
u32 LCDC_RGBImgWidth; /*!< Specifies the width of the LCDC PlANE SIZE.
This parameter can be a number between 0x000 and 0xfff. */
u32 LCDC_RGBRefreshFreq; /*!< Specifies the RGB frame refresh frequency.
This parameter can be a number between 0x000 and 0xfff.*/
u32 LCDC_RGBSyncMode; /*!< Specifies the RGB frame synchronize Mode.
This parameter can be a value of @ref LCDC_RGB_SYNC_MODE_define */
u32 LCDC_RGBDatPulPlrty; /*!< Specifies the RGB data pulse polariy.
This parameter can be a value of @ref LCDC_RGB_DATA_PUL_POLARITY_define */
u32 LCDC_RGBEnPulPlrty; /*!< Specifies the RGB ENABLE pulse polariy.
This parameter can be a value of @ref LCDC_RGB_ENABLE_PUL_POLARITY_define */
u32 LCDC_RGBHsPulPlrty; /*!< Specifies the RGB HSYNC pulse polariy.
This parameter can be a value of @ref LCDC_RGB_HSYNC_PUL_POLARITY_define */
u32 LCDC_RGBVsPulPlrty; /*!< Specifies the RGB VSYNC pulse polariy.
This parameter can be a value of @ref LCDC_RGB_VSYNC_PUL_POLARITY_define */
u32 LCDC_RGBDclkActvEdge; /*!< Specifies the RGB DCLK active edge.
This parameter can be a value of @ref LCDC_RGB_DCLK_ACTIVE_EDGE_define */
u32 LCDC_RGBVFP; /*!< Specifies the front porch line number.
This parameter can be a number between 0x1 and 0x10. Unit: line*/
u32 LCDC_RGBVBP; /*!< Specifies the back porch line number.
This parameter can be a number between 0x1 and 0x10. Unit: line*/
u32 LCDC_RGBVSW; /*!< Specifies the vertical signal width.
This parameter can be a number between 0x1 and 0x10. Unit: line*/
u32 LCDC_RGBHFP; /*!< Specifies the Horizontal front porch Unit: DCLK.
This parameter can be a number between 0x01 and 0x100. Unit: DCLK*/
u32 LCDC_RGBHBP; /*!< Specifies the Horizontal back porch Unit: DCLK.
This parameter can be a number between 0x01 and 0x100. Unit: DCLK*/
u32 LCDC_RGBHSW; /*!< Specifies the Horizontal sync signal width.
This parameter can be a number between 0x01 and 0x100. Unit: DCLK*/
} LCDC_RGBInitTypeDef;
/**
* @brief LCDC LED I/F Mode Initialization structure definition
*
*/
typedef struct
{
u32 LCDC_LEDIfMode; /*!< Specifies the LCDC LED Interface Mode.
This parameter can be a value of @ref LCDC_LED_IF_MODE_define */
u32 LCDC_LEDImgHeight; /*!< Specifies the height of the LED PlANE SIZE.
This parameter can be a number between 0x000 and 0xfff. */
u32 LCDC_LEDImgWidth; /*!< Specifies the width of the LED PlANE SIZE.
This parameter can be a number between 0x000 and 0xfff. */
u32 LCDC_LEDRefreshFreq; /*!< Specifies the LED frame refresh frequency.
This parameter can be a number between 0x000 and 0xfff.*/
u32 LCDC_LEDColorChnl; /*!< Specifies the LED I/F color channel.
This parameter can be a value of @ref LCDC_LED_COLOR_CHANNEL_define */
u32 LCDC_LEDColorNum; /*!< Specifies the LED I/F color number.
This parameter can be a value of @ref LCDC_LED_COLOR_NUMBER_define */
u32 LCDC_LEDClkPlrty; /*!< Specifies the LED I/F DCLK polarity.
This parameter can be a value of @ref LCDC_LED_DCLK_POLARITY_define */
u32 LCDC_LEDOePlrty; /*!< Specifies the LED I/F OE pulse polarity.
This parameter can be a value of @ref LCDC_LED_OE_POLARITY_define */
u32 LCDC_LEDLatPlrty; /*!< Specifies the LED I/F Latch polarity.
This parameter can be a value of @ref LCDC_LED_LATCH_POLARITY_define */
u32 LCDC_LEDDatPlrty; /*!< Specifies the LED I/F Data polarity.
This parameter can be a value of @ref LCDC_LED_Data_POLARITY_define */
u32 LCDC_LEDOEActw; /*!< Specifies the LED I/F OE Active Width Time.
This parameter can be a number between 0x001 and 0x1000. Unit: DCLK */
u32 LCDC_LEDLatchWidth; /*!< Specifies the LED I/F LAT Width Time.
This parameter can be a number between 0x01 and 0x100. Unit: DCLK */
u32 LCDC_LEDFrmIdlePd; /*!< Specifies the LED I/F Frame dile period.
This parameter can be a number between 0x001 and 0x1000. Unit: DCLK */
u32 LCDC_LEDLineIdlePd; /*!< Specifies the LED I/F Line idle period.
This parameter can be a number between 0x01 and 0x100. Unit: DCLK */
}LCDC_LEDInitTypeDef;
/**
* @}
*/
/* Exported constants --------------------------------------------------------*/
/** @defgroup LCDC_Exported_Constants LCDC Exported Constants
* @{
*/
/** @defgroup LCDC_MCU_IF_MODE_define
* @{
*/
#define LCDC_MCU_IF_8_BIT ((u32)0x00000000)
#define LCDC_MCU_IF_16_BIT ((u32)0x00010000)
#define IS_LCDC_MCU_IF_MODE(MODE) (((MODE) == LCDC_MCU_IF_8_BIT) || \
((MODE) == LCDC_MCU_IF_16_BIT))
/**
* @}
*/
/** @defgroup LCDC_MCU_MODE_define
* @{
*/
#define LCDC_MCU_DMA_MODE ((u32)0x00000000)
#define LCDC_MCU_IO_MODE ((u32)0x00000800)
#define IS_LCDC_MCU_MODE(MODE) (((MODE) == LCDC_MCU_IO_MODE) || \
((MODE) == LCDC_MCU_DMA_MODE))
/**
* @}
*/
/** @defgroup LCDC_DMA_MODE_define
* @{
*/
#define LCDC_AUTO_DMA_MODE ((u32)0x00000000)
#define LCDC_TRIGGER_DMA_MODE ((u32)0x00000001)
#define IS_LCDC_DMA_MODE(MODE) (((MODE) == LCDC_AUTO_DMA_MODE) || \
((MODE) == LCDC_TRIGGER_DMA_MODE))
/**
* @}
*/
/** @defgroup LCDC_MCU_SYNC_MODE_define
* @{
*/
#define LCDC_MCU_SYNC_WITH_INTERNAL_CLK ((u32)0x00000000)
#define LCDC_MCU_SYNC_WITH_VSYNC ((u32)0x00000200)
#define LCDC_MCU_SYNC_WITH_TE ((u32)0x00000400)
#define IS_LCDC_MCU_SYNC_MODE(MODE) (((MODE) == LCDC_MCU_SYNC_WITH_INTERNAL_CLK) || \
((MODE) == LCDC_MCU_SYNC_WITH_VSYNC) || \
((MODE) == LCDC_MCU_SYNC_WITH_TE))
/**
* @}
*/
/** @defgroup LCDC_MCU_VSYNC_PUL_POLARITY_define
* @{
*/
#define LCDC_MCU_VSYNC_PUL_LOW_LEV_ACTIVE ((u32)0x00000000)
#define LCDC_MCU_VSYNC_PUL_HIGH_LEV_ACTIVE ((u32)0x00000040)
#define IS_LCDC_MCU_VSYNC_PUL_POLARITY(POLARITY) (((POLARITY) == LCDC_MCU_VSYNC_PUL_LOW_LEV_ACTIVE) || \
((POLARITY) == LCDC_MCU_VSYNC_PUL_HIGH_LEV_ACTIVE))
/**
* @}
*/
/** @defgroup LCDC_MCU_TE_PUL_POLARITY_define
* @{
*/
#define LCDC_MCU_TE_PUL_LOW_LEV_ACTIVE ((u32)0x00000000)
#define LCDC_MCU_TE_PUL_HIGH_LEV_ACTIVE ((u32)0x00000020)
#define IS_LCDC_MCU_TE_PUL_POLARITY(POLARITY) (((POLARITY) == LCDC_MCU_TE_PUL_LOW_LEV_ACTIVE) || \
((POLARITY) == LCDC_MCU_TE_PUL_HIGH_LEV_ACTIVE))
/**
* @}
*/
/** @defgroup LCDC_MCU_DATA_PUL_POLARITY_define
* @{
*/
#define LCDC_MCU_DAT_PUL_NORMAL ((u32)0x00000000)
#define LCDC_MCU_DAT_PUL_INVERT ((u32)0x00000010)
#define IS_LCDC_MCU_DAT_PUL_POLARITY(POLARITY) (((POLARITY) == LCDC_MCU_DAT_PUL_NORMAL) || \
((POLARITY) == LCDC_MCU_DAT_PUL_INVERT))
/**
* @}
*/
/** @defgroup LCDC_MCU_READ_PUL_POLARITY_define
* @{
*/
#define LCDC_MCU_RD_PUL_RISING_EDGE_FETCH ((u32)0x00000000)
#define LCDC_MCU_RD_PUL_FALLING_EDGE_FETCH ((u32)0x00000008)
#define IS_LCDC_MCU_RD_PUL_POLARITY(POLARITY) (((POLARITY) == LCDC_MCU_RD_PUL_RISING_EDGE_FETCH) || \
((POLARITY) == LCDC_MCU_RD_PUL_FALLING_EDGE_FETCH))
/**
* @}
*/
/** @defgroup LCDC_MCU_WRITE_PUL_POLARITY_define
* @{
*/
#define LCDC_MCU_WR_PUL_RISING_EDGE_FETCH ((u32)0x00000000)
#define LCDC_MCU_WR_PUL_FALLING_EDGE_FETCH ((u32)0x00000004)
#define IS_LCDC_MCU_WR_PUL_POLARITY(POLARITY) (((POLARITY) == LCDC_MCU_WR_PUL_RISING_EDGE_FETCH) || \
((POLARITY) == LCDC_MCU_WR_PUL_FALLING_EDGE_FETCH))
/**
* @}
*/
/** @defgroup LCDC_MCU_RS_PUL_POLARITY_define
* @{
*/
#define LCDC_MCU_RS_PUL_LOW_LEV_CMD_ADDR ((u32)0x00000000)
#define LCDC_MCU_RS_PUL_HIGH_LEV_CMD_ADDR ((u32)0x00000002)
#define IS_LCDC_MCU_RS_PUL_POLARITY(POLARITY) (((POLARITY) == LCDC_MCU_RS_PUL_LOW_LEV_CMD_ADDR) || \
((POLARITY) == LCDC_MCU_RS_PUL_HIGH_LEV_CMD_ADDR))
/**
* @}
*/
/** @defgroup LCDC_MCU_CS_PUL_POLARITY_define
* @{
*/
#define LCDC_MCU_CS_PUL_LOW_LEV_ACTIVE ((u32)0x00000000)
#define LCDC_MCU_CS_PUL_HIGH_LEV_ACTIVE ((u32)0x00000001)
#define IS_LCDC_MCU_CS_PUL_POLARITY(POLARITY) (((POLARITY) == LCDC_MCU_CS_PUL_LOW_LEV_ACTIVE) || \
((POLARITY) == LCDC_MCU_CS_PUL_HIGH_LEV_ACTIVE))
/**
* @}
*/
/** @defgroup LCDC_RGB_IF_MODE_define
* @{
*/
#define LCDC_RGB_IF_6_BIT ((u32)0x00080000)
#define LCDC_RGB_IF_16_BIT ((u32)0x00090000)
#define IS_LCDC_RGB_IF_MODE(MODE) (((MODE) == LCDC_RGB_IF_6_BIT) || \
((MODE) == LCDC_RGB_IF_16_BIT))
/**
* @}
*/
/** @defgroup LCDC_RGB_SYNC_MODE_define
* @{
*/
#define LCDC_RGB_DE_MODE ((u32)0x00000000)
#define LCDC_RGB_HV_MODE ((u32)0x02000000)
#define IS_LCDC_RGB_SYNC_MODE(MODE) (((MODE) == LCDC_RGB_DE_MODE) || \
((MODE) == LCDC_RGB_HV_MODE))
/**
* @}
*/
/** @defgroup LCDC_RGB_DATA_PUL_POLARITY_define
* @{
*/
#define LCDC_RGB_DAT_PUL_NORMAL ((u32)0x00000000)
#define LCDC_RGB_DAT_PUL_INVERT ((u32)0x00100000)
#define IS_LCDC_RGB_DAT_PUL_POLARITY(POLARITY) (((POLARITY) == LCDC_RGB_DAT_PUL_NORMAL) || \
((POLARITY) == LCDC_RGB_DAT_PUL_INVERT))
/**
* @}
*/
/** @defgroup LCDC_RGB_ENABLE_PUL_POLARITY_define
* @{
*/
#define LCDC_RGB_EN_PUL_LOW_LEV_ACTIVE ((u32)0x00000000)
#define LCDC_RGB_EN_PUL_HIGH_LEV_ACTIVE ((u32)0x00080000)
#define IS_LCDC_RGB_EN_PUL_POLARITY(POLARITY) (((POLARITY) == LCDC_RGB_EN_PUL_LOW_LEV_ACTIVE) || \
((POLARITY) == LCDC_RGB_EN_PUL_HIGH_LEV_ACTIVE))
/**
* @}
*/
/** @defgroup LCDC_RGB_HSYNC_PUL_POLARITY_define
* @{
*/
#define LCDC_RGB_HS_PUL_LOW_LEV_SYNC ((u32)0x00000000)
#define LCDC_RGB_HS_PUL_HIGH_LEV_SYNC ((u32)0x00040000)
#define IS_LCDC_RGB_HS_PUL_POLARITY(POLARITY) (((POLARITY) == LCDC_RGB_HS_PUL_LOW_LEV_SYNC) || \
((POLARITY) == LCDC_RGB_HS_PUL_HIGH_LEV_SYNC))
/**
* @}
*/
/** @defgroup LCDC_RGB_VSYNC_PUL_POLARITY_define
* @{
*/
#define LCDC_RGB_VS_PUL_LOW_LEV_SYNC ((u32)0x00000000)
#define LCDC_RGB_VS_PUL_HIGH_LEV_SYNC ((u32)0x00020000)
#define IS_LCDC_RGB_VS_PUL_POLARITY(POLARITY) (((POLARITY) == LCDC_RGB_VS_PUL_LOW_LEV_SYNC) || \
((POLARITY) == LCDC_RGB_VS_PUL_HIGH_LEV_SYNC))
/**
* @}
*/
/** @defgroup LCDC_RGB_DCLK_ACTIVE_EDGE_define
* @{
*/
#define LCDC_RGB_DCLK_RISING_EDGE_FETCH ((u32)0x00000000)
#define LCDC_RGB_DCLK_FALLING_EDGE_FETCH ((u32)0x00010000)
#define IS_LCDC_RGB_DCLK_EDGE(EDGE) (((EDGE) == LCDC_RGB_DCLK_RISING_EDGE_FETCH) || \
((EDGE) == LCDC_RGB_DCLK_FALLING_EDGE_FETCH))
/**
* @}
*/
/** @defgroup LCDC_LED_IF_MODE_define
* @{
*/
#define LCDC_LED_IF ((u32)0x000f0000)
#define IS_LCDC_LED_IF_MODE(MODE) (((MODE) == LCDC_LED_IF))
/**
* @}
*/
/** @defgroup LCDC_LED_COLOR_CHANNEL_define
* @{
*/
#define LCDC_LED_ONE_CHANNEL ((u32)0x00000000)
#define LCDC_LED_TWO_CHANNEL ((u32)0x00000004)
#define IS_LCDC_LED_CHANNEL(CHANNEL) (((CHANNEL) == LCDC_LED_ONE_CHANNEL) || \
((CHANNEL) == LCDC_LED_TWO_CHANNEL))
/**
* @}
*/
/** @defgroup LCDC_LED_COLOR_NUMBER_define
* @{
*/
#define LCDC_LED_ONE_COLOR ((u32)0x00000000)
#define LCDC_LED_TWO_COLOR ((u32)0x00000001)
#define LCDC_LED_THREE_COLOR ((u32)0x00000002)
#define IS_LCDC_LED_COLOR_NUM(NUM) (((NUM) == LCDC_LED_ONE_COLOR) || \
((NUM) == LCDC_LED_TWO_COLOR) || \
((NUM) == LCDC_LED_THREE_COLOR))
/**
* @}
*/
/** @defgroup LCDC_LED_DCLK_POLARITY_define
* @{
*/
#define LCDC_LED_DCLK_RISING_EDGE_FETCH ((u32)0x00000000)
#define LCDC_LED_DCLK_FALLING_EDGE_FETCH ((u32)0x00000010)
#define IS_LCDC_LED_DCLK_EDGE(EDGE) (((EDGE) == LCDC_LED_DCLK_RISING_EDGE_FETCH) || \
((EDGE) == LCDC_LED_DCLK_FALLING_EDGE_FETCH))
/**
* @}
*/
/** @defgroup LCDC_LED_LATCH_POLARITY_define
* @{
*/
#define LCDC_LED_LACTH_RISING_EDGE_FETCH ((u32)0x00000000)
#define LCDC_LED_LATCH_FALLING_EDGE_FETCH ((u32)0x00000020)
#define IS_LCDC_LED_LATCH_EDGE(EDGE) (((EDGE) == LCDC_LED_LACTH_RISING_EDGE_FETCH) || \
((EDGE) == LCDC_LED_LATCH_FALLING_EDGE_FETCH))
/**
* @}
*/
/** @defgroup LCDC_LED_OE_POLARITY_define
* @{
*/
#define LCDC_LED_OE_LOW_LEV_ACTIVE ((u32)0x00000000)
#define LCDC_LED_OE_HIGH_LEV_ACTIVE ((u32)0x00000040)
#define IS_LCDC_LED_OE_PUL_POLARITY(POLARITY) (((POLARITY) == LCDC_LED_OE_LOW_LEV_ACTIVE) || \
((POLARITY) == LCDC_LED_OE_HIGH_LEV_ACTIVE))
/**
* @}
*/
/** @defgroup LCDC_LED_DATA_POLARITY_define
* @{
*/
#define LCDC_LED_DAT_PUL_NORMAL ((u32)0x00000000)
#define LCDC_LED_DAT_PUL_INVERT ((u32)0x00000080)
#define IS_LCDC_LED_DAT_PUL_POLARITY(POLARITY) (((POLARITY) == LCDC_LED_DAT_PUL_NORMAL) || \
((POLARITY) == LCDC_LED_DAT_PUL_INVERT))
/**
* @}
*/
/** @defgroup LCDC_DMA_UNDERFLOW_MODE_define
* @{
*/
#define LCDC_DMAUNFW_OUTPUT_LASTDATA ((u32)0x00000000)
#define LCDC_DMAUNFW_OUTPUT_ERRORDATA ((u32)0x02000000)
#define IS_LCDC_DMA_DMA_UNDERFLOW_MODE(MODE) (((MODE) == LCDC_DMAUNFW_OUTPUT_LASTDATA) || \
((MODE) == LCDC_DMAUNFW_OUTPUT_ERRORDATA))
/**
* @}
*/
/** @defgroup LCDC_INTERRUPTS_define
* @{
*/
#define LCDC_IT_FRM_START ((u32)0x00000020)
#define LCDC_IT_IO_TIMEOUT ((u32)0x00000010)
#define LCDC_IT_LINE ((u32)0x00000008)
#define LCDC_IT_FRDN ((u32)0x00000004)
#define LCDC_IT_DMAUNDFW ((u32)0x00000001)
#define IS_LCDC_CONFIG_IT(IT) (((IT) == LCDC_IT_DMAUNDFW) || \
((IT) == LCDC_IT_FRDN) || \
((IT) == LCDC_IT_LINE)|| \
((IT) == LCDC_IT_IO_TIMEOUT)|| \
((IT) == LCDC_IT_FRM_START))
#define IS_LCDC_CLEAR_IT(IT) ((((IT) & (u32)0xFFFFFFC2) == 0x00) && ((IT) != 0x00))
/**
* @}
*/
/** @defgroup LCDC_type_define
* @{
*/
#define IS_LCDC_ALL_PERIPH(PERIPH) (PERIPH == LCDC)
/**
* @}
*/
/**
* @}
*/
/* Exported functions --------------------------------------------------------*/
/** @defgroup LCDC_Exported_Functions LCDC Exported Functions
* @{
*/
/** @defgroup LCDC_MCU_Interface_functions
* @{
*/
_LONG_CALL_ void LCDC_MCUStructInit(LCDC_MCUInitTypeDef* LCDC_MCUInitStruct);
_LONG_CALL_ void LCDC_MCUInit(LCDC_TypeDef* LCDCx, LCDC_MCUInitTypeDef* LCDC_MCUInitStruct);
_LONG_CALL_ void LCDC_MCUDMATrigger(LCDC_TypeDef* LCDCx);
_LONG_CALL_ u32 LCDC_MCUGetRunStatus(LCDC_TypeDef* LCDCx);
_LONG_CALL_ void LCDC_MCUIOWriteData(LCDC_TypeDef* LCDCx, u16 Data);
_LONG_CALL_ u16 LCDC_MCUIOReadData(LCDC_TypeDef* LCDCx);
_LONG_CALL_ void LCDC_MCUIOWriteCmd(LCDC_TypeDef* LCDCx, u16 Cmd);
/**
* @}
*/
/** @defgroup LCDC_RGB_Interface_functions
* @{
*/
_LONG_CALL_ void LCDC_RGBStructInit(LCDC_RGBInitTypeDef * LCDC_RGBInitStruct);
_LONG_CALL_ void LCDC_RGBInit(LCDC_TypeDef* LCDCx, LCDC_RGBInitTypeDef* LCDC_RGBInitStruct);
_LONG_CALL_ void LCDC_RGBGetSyncStatus(LCDC_TypeDef* LCDCx, u32 * pHSStatus, u32 * pVSStatus);
/**
* @}
*/
/** @defgroup LCDC_LED_Interface_functions
* @{
*/
_LONG_CALL_ void LCDC_LEDStructInit(LCDC_LEDInitTypeDef * LCDC_LEDInitStruct);
_LONG_CALL_ void LCDC_LEDInit(LCDC_TypeDef* LCDCx, LCDC_LEDInitTypeDef* LCDC_LEDInitStruct);
_LONG_CALL_ void LCDC_LEDSetOEWidth(LCDC_TypeDef* LCDCx, u32 OEActvWidth);
/**
* @}
*/
/** @defgroup LCDC_DMA_Configure_functions
* @{
*/
_LONG_CALL_ void LCDC_DMAModeConfig(LCDC_TypeDef* LCDCx, u32 BurstSize);
_LONG_CALL_ void LCDC_DMAUnderFlowConfig(LCDC_TypeDef* LCDCx, u32 DmaUnFlwMode, u32 ErrorData);
_LONG_CALL_ void LCDC_DMAImageBaseAddrConfig(LCDC_TypeDef* LCDCx, u32 ImgBaseAddr);
/**
* @}
*/
/** @defgroup LCDC_Interrupt_functions
* @{
*/
_LONG_CALL_ void LCDC_INTConfig(LCDC_TypeDef* LCDCx, u32 LCDC_IT, u32 NewState);
_LONG_CALL_ void LCDC_LineINTPosConfig(LCDC_TypeDef* LCDCx, u32 LineNum);
_LONG_CALL_ u32 LCDC_GetINTStatus(LCDC_TypeDef* LCDCx);
_LONG_CALL_ u32 LCDC_GetRawINTStatus(LCDC_TypeDef* LCDCx);
_LONG_CALL_ void LCDC_ClearAllINT(LCDC_TypeDef* LCDCx);
_LONG_CALL_ void LCDC_ClearINT(LCDC_TypeDef* LCDCx, u32 LCDC_IT);
_LONG_CALL_ void LCDC_GetCurPosStatus(LCDC_TypeDef* LCDCx, u32* pCurPosX, u32* pCurPosY);
_LONG_CALL_ void LCDC_GetDmaUnINTCnt(LCDC_TypeDef* LCDCx, u32* DmaUnIntCnt);
/**
* @}
*/
/** @defgroup LCDC_global_functions
* @{
*/
_LONG_CALL_ void LCDC_Cmd(LCDC_TypeDef* LCDCx, u32 NewState);
_LONG_CALL_ void LCDC_InsDisable(LCDC_TypeDef* LCDCx);
_LONG_CALL_ void LCDC_DeInit(LCDC_TypeDef* LCDCx);
/**
* @}
*/
/**
* @}
*/
/* Registers Definitions --------------------------------------------------------*/
/**************************************************************************//**
* @defgroup LCDC_Register_Definitions LCDC Register Definitions
* @{
*****************************************************************************/
/**************************************************************************//**
* @defgroup LCDC_CTRL
* @{
*****************************************************************************/
#define LCDC_CTRL_LCDCEN ((u32)0x00000001) /*BIT[0], Enable LCDC*/
#define LCDC_CTRL_LCDCDIS ((u32)0x00000001<<1) /*BIT[1], Disable LCDC*/
#define LCDC_CTRL_LCDCINSDIS ((u32)0x00000001<<2) /*BIT[2], Disable LCDC instantly*/
#define LCDC_CTRL_IF_MODE ((u32)0x000F0000) /*LCDC_CTRL[19:16], bit field for LCDC Interface Mode*/
#define LCDC_CTRL_8_BIT_MCU ((u32)0x00000000) /*LCDC_CTRL[19:16]=0000B, 8 bit MCU I/F*/
#define LCDC_CTRL_16_BIT_MCU ((u32)0x00010000) /*LCDC_CTRL[19:16]=0001B, 16 bit MCU I/F*/
#define LCDC_CTRL_6_BIT_RGB ((u32)0x00080000) /*LCDC_CTRL[19:16]=1000B, 6 bit RGB I/F*/
#define LCDC_CTRL_16_BIT_RGB ((u32)0x00090000) /*LCDC_CTRL[19:16]=1001B, 16 bit RGB I/F*/
#define LCDC_CTRL_LED_IF ((u32)0x000F0000) /*LCDC_CTRL[19:16]=1111B, LED I/F*/
/** @} */
/**************************************************************************//**
* @defgroup LCDC_PLANE_SIZE
* @{
*****************************************************************************/
#define LCDC_PLANE_SIZE_IMG_HEIGHT ((u32)0x0FFF0000) /*Bit[27:16], bits for image height setting*/
#define LCDC_PLANE_SIZE_IMG_WIDTH ((u32)0x00000FFF) /*Bit[11:0], bits for image width setting*/
/** @} */
/**************************************************************************//**
* @defgroup LCDC_UNDFLW_CFG
* @{
*****************************************************************************/
#define LCDC_UNDFLW_CFG_UNDMODE ((u32)0x00000001<<25) /*Bit[25], output mode when DMA FIFO under flow happens*/
#define LCDC_UNDFLW_CFG_ERROUTDATA ((u32)0x0000FFFF) /*Bit[15:0], bits for DMA under flow error data field*/
/** @} */
/**************************************************************************//**
* @defgroup LCDC_DMA_MODE_CFG
* @{
*****************************************************************************/
#define LCDC_DMA_MODE_CFG_TRIGGER_MODE ((u32)0x00000001) /*Bit[0], trigger mode or auto mode selection*/
#define LCDC_DMA_MODE_CFG_TRIGGER_ONE_TIME ((u32)0x00000001<<1) /*Bit[1], trigger DMA to transfer one frame*/
#define LCDC_DMA_MODE_CFG_RDOTST ((u32)0x00000007<<2) /*Bit[4:2], bits for DMA burst size configuration*/
#define LCDC_DMA_MODE_CFG_DMAINTV ((u32)0xFFFFFF00) /*Bit[31:8], The interval cycle count between two DMA requests.
Unit: bus clock cycle.( for debug)*/
/** @} */
/**************************************************************************//**
* @defgroup LCDC_CLK_DIV
* @{
*****************************************************************************/
#define LCDC_CLK_DIV_DCLKDIV ((u32)0x0000FFFF) /*Bit[15:0], bits for DCLK clock divider*/
/** @} */
/**************************************************************************//**
* @defgroup LCDC_IRQ_EN
* @{
*****************************************************************************/
#define LCDC_IRQ_EN_DMAUNINTEN ((u32)0x00000001) /*Bit[0], DMA FIFO underflow interrupt enable*/
#define LCDC_IRQ_EN_LCDFRDINTEN ((u32)0x00000001<<2) /*Bit[2], LCD/LED refresh done interrupt enable*/
#define LCDC_IRQ_EN_LCDLINEINTEN ((u32)0x00000001<<3) /*Bit[3], LCD/LED line interrupt enable*/
#define LCDC_IRQ_EN_IOTIMEOUTEN ((u32)0x00000001<<4) /*Bit[4], IO write/read timeout interrupt enable*/
#define LCDC_IRQ_EN_FRMSTARTEN ((u32)0x00000001<<5) /*Bit[5], Frame start interrupt enable*/
/** @} */
/**************************************************************************//**
* @defgroup LCDC_IRQ_STATUS
* @{
*****************************************************************************/
#define LCDC_IRQ_STATUS_DMAUNINTS ((u32)0x00000001) /*Bit[0], DMA FIFO underflow interrupt status,Write 1 clear*/
#define LCDC_IRQ_STATUS_LCDFRDINTS ((u32)0x00000001<<2) /*Bit[2], LCD refresh frame done interrupt status,Write 1 clear*/
#define LCDC_IRQ_STATUS_LINEINTS ((u32)0x00000001<<3) /*Bit[3], Line Interrupt status,Write 1 clear*/
#define LCDC_IRQ_STATUS_IOTIMEOUTINTS ((u32)0x00000001<<4) /*Bit[4], IO write/read timeout Interrupt status,Write 1 clear*/
#define LCDC_IRQ_STATUS_FRMSTARTINTS ((u32)0x00000001<<5) /*Bit[5], Frame start Interrupt status,Write 1 clear*/
/** @} */
/**************************************************************************//**
* @defgroup LCDC_IRQ_RAW
* @{
*****************************************************************************/
#define LCDC_IRQ_RAW_DMAUNINTRS ((u32)0x00000001) /*Bit[0], DMA FIFO underflow interrupt raw status*/
#define LCDC_IRQ_RAW_LCDFRDINTS ((u32)0x00000001<<2) /*Bit[2], LCD refresh frame done interrupt raw status*/
#define LCDC_IRQ_RAW_LINEINTS ((u32)0x00000001<<3) /*Bit[3], Line Interrupt raw status*/
#define LCDC_IRQ_RAW_IOTIMEOUTINTS ((u32)0x00000001<<4) /*Bit[4], IO write/read timeout Interrupt raw status*/
#define LCDC_IRQ_RAW_FRMSTARTINTS ((u32)0x00000001<<5) /*Bit[5], frame start Interrupt raw status*/
/** @} */
/**************************************************************************//**
* @defgroup LCDC_LINE_INT_POS
* @{
*****************************************************************************/
#define LCDC_LINE_INTPOS ((u32)0x00000FFF) /*Bit[11:0], Bits for Line Interrupt Position*/
/** @} */
/**************************************************************************//**
* @defgroup LCDC_CUR_POS_STATUS
* @{
*****************************************************************************/
#define LCDC_CUR_POS_STS_X ((u32)0x00000FFF) /*BIT[11:0], current X position*/
#define LCDC_CUR_POS_STS_Y ((u32)0x00000FFF<<16) /*BIT[27:16], current Y position*/
/** @} */
/**************************************************************************//**
* @defgroup LCDC_STATUS
* @{
*****************************************************************************/
#define LCDC_STATUS_DMAUNINTCNT ((u32)0x0000FFFF) /*Bit[15:0], DMA FIFO underflow interrupt count*/
/** @} */
/**************************************************************************//**
* @defgroup LCDC_RGB_CFG
* @{
*****************************************************************************/
#define LCDC_RGB_CFG_DCLKPL ((u32)0x00000001<<16) /*Bit[16], The polarity of the DCLK active edge*/
#define LCDC_RGB_CFG_VSPL ((u32)0x00000001<<17) /*Bit[17], The VSYNC pulse polarity*/
#define LCDC_RGB_CFG_HSPL ((u32)0x00000001<<18) /*Bit[18], The HSYNC pulse polarity*/
#define LCDC_RGB_CFG_ENPL ((u32)0x00000001<<19) /*Bit[19], The ENABLE pulse polarity*/
#define LCDC_RGB_CFG_DATPL ((u32)0x00000001<<20) /*Bit[20], The Data pulse polarity*/
#define LCDC_RGB_CFG_RGBIFUPDATE ((u32)0x00000001<<24) /*Bit[24], Force HW updates RGB I/F parameters
after current LCD refresh frame done. CPU writes 1
to force HW updating parameters. After updating,
HW cleared this bit.(ex. DMA Address update should
take care of this bit)*/
#define LCDC_RGB_CFG_RGB_SYNC_MODE ((u32)0x000000003<<25) /*Bit[26:25], bit field for RGB sync mode*/
#define LCDC_RGB_CFG_RGB_DE_MODE ((u32)0x000000000) /*Bit[26:25] = 00B, DE mode,frame synchronized with ENABLE signal*/
#define LCDC_RGB_CFG_RGB_HV_MODE ((u32)0x000000001<<25) /*Bit[26:25] = 01B, HV mode,frame synchronized with sync signal*/
/** @} */
/**************************************************************************//**
* @defgroup LCDC_RGB_VSYNC_CFG
* @{
*****************************************************************************/
#define LCDC_RGB_VSYNC_CFG_VSW ((u32)0x0000000F) /*Bit[3:0], Vertical sync signal width*/
#define LCDC_RGB_VSYNC_CFG_VBP ((u32)0x0000000F<<8) /*Bit[11:8], Back porch line number*/
#define LCDC_RGB_VSYNC_CFG_VFP ((u32)0x0000000F<<16) /*Bit[19:16], Front porch line number*/
/** @} */
/**************************************************************************//**
* @defgroup LCDC_RGB_HSYNC_CFG
* @{
*****************************************************************************/
#define LCDC_RGB_HSYNC_CFG_HSW ((u32)0x000000FF) /*Bit[7:0], Horizontal sync signal width*/
#define LCDC_RGB_HSYNC_CFG_HBP ((u32)0x000000FF<<8) /*Bit[15:8], Horizontal back porch*/
#define LCDC_RGB_HSYNC_CFG_HFP ((u32)0x000000FF<<16) /*Bit[23:16], Horizontal front porch*/
/** @} */
/**************************************************************************//**
* @defgroup LCDC_RGB_SYNC_STATUS
* @{
*****************************************************************************/
#define LCDC_RGB_SYNC_STATUS_VSSTATUS ((u32)0x00000003) /*Bit[1:0], bit field for VSYNC Status*/
#define LCDC_RGB_SYNC_STATUS_VSYNC ((u32)0x00000000) /*Bit[1:0]=00B HSYNC*/
#define LCDC_RGB_SYNC_STATUS_VFP ((u32)0x00000001) /*Bit[1:0]=01B, HFP*/
#define LCDC_RGB_SYNC_STATUS_VACTIVE ((u32)0x00000002) /*Bit[1:0]=10B, ACTIVE*/
#define LCDC_RGB_SYNC_STATUS_VBP ((u32)0x00000003) /*Bit[1:0]=11B, HBP*/
#define LCDC_RGB_SYNC_STATUS_HSSTATUS ((u32)0x00000003<<2) /*Bit[3:2], bit field for HSYNC Status*/
#define LCDC_RGB_SYNC_STATUS_HSYNC ((u32)0x00000000<<2) /*Bit[3:2]=00B HSYNC*/
#define LCDC_RGB_SYNC_STATUS_HFP ((u32)0x00000001<<2) /*Bit[3:2]=01B, HFP*/
#define LCDC_RGB_SYNC_STATUS_HACTIVE ((u32)0x00000002<<2) /*Bit[3:2]=10B, ACTIVE*/
#define LCDC_RGB_SYNC_STATUS_HBP ((u32)0x00000003<<2) /*Bit[3:2]=11B, HBP*/
/** @} */
/**************************************************************************//**
* @defgroup LCDC_MCU_CFG
* @{
*****************************************************************************/
#define LCDC_MCU_CFG_CSPL ((u32)0x00000001) /*Bit[0], CS pulse polarity*/
#define LCDC_MCU_CFG_RSPL ((u32)0x00000001<<1) /*Bit[1], RS pulse polarity*/
#define LCDC_MCU_CFG_WRPL ((u32)0x00000001<<2) /*Bit[2], WR pulse polarity*/
#define LCDC_MCU_CFG_RDPL ((u32)0x00000001<<3) /*Bit[3], RD pulse polarity*/
#define LCDC_MCU_CFG_DATAPL ((u32)0x00000001<<4) /*Bit[4], DATA pulse polarity*/
#define LCDC_MCU_CFG_TEPL ((u32)0x00000001<<5) /*Bit[5], TE pulse polarity*/
#define LCDC_MCU_CFG_MCUSYPL ((u32)0x00000001<<6) /*Bit[6], MCU VSYNC pulse polarity*/
#define LCDC_MCU_CFG_MCUIFUPDATE ((u32)0x00000001<<8) /*Bit[8], Force HW updates MCU I/F Timing
shadow register at specific timing*/
#define LCDC_MCU_CFG_MCUSYNCMODE ((u32)0x00000003<<9) /*Bit[10:9], bit field for MCU SYNC mode setting*/
#define LCDC_MCU_CFG_SYNC_INTERNAL_CLK ((u32)0x00000000<<9) /*Bit[10:9]=00B, synchronized with the internal clock*/
#define LCDC_MCU_CFG_SYNC_VSYNC_INPUT ((u32)0x00000001<<9) /*Bit[10:9]=01B, synchronized with the VSYNC INPUT*/
#define LCDC_MCU_CFG_SYNC_TE ((u32)0x00000002<<9) /*Bit[10:9]=10B, synchronized with the TE*/
#define LCDC_MCU_CFG_IOMODE_EN ((u32)0x00000001<<11) /*Bit[11], MCU I/F mode enable*/
#define LCDC_MCU_CFG_IOMODE_RUN ((u32)0x00000001<<12) /*Bit[12], MCU I/F mode run*/
#define LCDC_MCU_CFG_IOMODE_TEDELAY ((u32)0x0000FFFF<<16) /*Bit[31:16], TE delay interval -5*/
/** @} */
/**************************************************************************//**
* @defgroup LCDC_MCU_VSYNC_CFG
* @{
*****************************************************************************/
#define LCDC_MCU_VSYNC_CFG_MCUVSW ((u32)0x000000FF) /*Bit[7:0], VSYNC signal widdth - 1*/
#define LCDC_MCU_VSYNC_CFG_MCUVSPD ((u32)0x0000FFFF<<12) /*Bit[31:12], VSYNC idle period*/
/** @} */
/**************************************************************************//**
* @defgroup LCDC_MCU_TIMING_CFG
* @{
*****************************************************************************/
#define LCDC_MCU_TIMING_CFG_WRPULW ((u32)0x000003FF) /*Bit[9:0], write pulse width */
#define LCDC_MCU_TIMING_CFG_RDACTW ((u32)0x000007FF<<10) /*Bit[20:10], RD active pulse width -1*/
#define LCDC_MCU_TIMING_CFG_RDINACTW ((u32)0x000007FF<<21) /*Bit[31:21], RD inactive pulse width -1*/
/** @} */
/**************************************************************************//**
* @defgroup LCDC_MCU_IO_DATA
* @{
*****************************************************************************/
#define LCDC_MCU_IO_WR_CMD_FG ((u32)0x80000000) /*Bit[31], bit field for writing command control*/
#define LCDC_MCU_IO_WR_DAT_FG ((u32)0x7FFFFFFF) /*For writing data mask*/
#define LCDC_MCU_IO_RW_DATA ((u32)0x0000FFFF) /*Bit[15:0], bit field for write/read data*/
/** @} */
/**************************************************************************//**
* @defgroup LCDC_MCU_IO_TO_CFG
* @{
*****************************************************************************/
#define LCDC_MCU_IO_TIMEOUT_CLK_NUM ((u32)0x0000FFFF) /*Bit[15:0], bit field for write/read timeout clock number, unit: write clock*/
/** @} */
/**************************************************************************//**
* @defgroup LCDC_LED_CFG
* @{
*****************************************************************************/
#define LCDC_LED_CFG_COLORNUM ((u32)0x00000003) /*Bit[1:0], bit field for Color number in frame buffer*/
#define LCDC_LED_CFG_ONECOLOR ((u32)0x00000000) /*Bit[1:0]=00B, one color*/
#define LCDC_LED_CFG_TWOCOLOR ((u32)0x00000001) /*Bit[1:0]=01B, two color*/
#define LCDC_LED_CFG_THREECOLOR ((u32)0x00000002) /*Bit[1:0]=10B, three color*/
#define LCDC_LED_CFG_COLORCHAN ((u32)0x00000001<<2) /*Bit[2], color channel*/
#define LCDC_LED_CFG_LEDIFUPDATE ((u32)0x00000001<<3) /*Bit[3], Force HW updates LED I/F parameters after current LED refresh frame done.*/
#define LCDC_LED_CFG_CLKPL ((u32)0x00000001<<4) /*Bit[4], The polarity of the DCLK active edge*/
#define LCDC_LED_CFG_LATPL ((u32)0x00000001<<5) /*Bit[5], The polarity of the LATCH active edge.*/
#define LCDC_LED_CFG_OEPL ((u32)0x00000001<<6) /*Bit[6], The OE pulse polarity.*/
#define LCDC_LED_CFG_DATPL ((u32)0x00000001<<7) /*Bit[7], The Data pulse polarity..*/
/** @} */
/**************************************************************************//**
* @defgroup LCDC_LED_TIMING
* @{
*****************************************************************************/
#define LCDC_LED_TIMING_LATW ((u32)0x000000FF) /*Bit[7:0], bit field for LAT Width Time - 1. Unit: dotclock*/
#define LCDC_LED_TIMING_OEACTW ((u32)0x0000FFFF<<8) /*Bit[23:8], bit field for OE Active Width Time - 1. Unit: dotclock*/
/** @} */
/**************************************************************************//**
* @defgroup LCDC_LED_IDLE
* @{
*****************************************************************************/
#define LCDC_LED_TIMING_LINEIDLE ((u32)0x000000FF) /*Bit[7:0], bit field for line idle Width Time - 1. Unit: dotclock*/
#define LCDC_LED_TIMING_FRMIDLEPD ((u32)0x00000FFF<<20) /*Bit[31:20], bit field for frame idle period interval - 1. Unit: dotclock*/
/** @} */
/**************************************************************************//**
* @defgroup LCDC_IMG_BASE_ADDR
* @{
*****************************************************************************/
#define LCDC_IMG_BASE_ADDR_MASK ((u32)0xFFFFFFFF) /*Bit[31:0], Image DMA source address.*/
/** @} */
/** @} */
/**
* @}
*/
/**
* @}
*/
/* Other Definitions --------------------------------------------------------*/
#endif
/******************* (C) COPYRIGHT 2016 Realtek Semiconductor *****END OF FILE****/
|
ccf6a3d7b84d8aefb7711dcd2fd112e55d2f3222
|
65b446d4da9446d926950079c967c05927198d6f
|
/MatrixSDK/JSONModels/Login/MXLoginSSOIdentityProviderBrand.h
|
c8e698573de702903f96f55937ce9d856df025de
|
[
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] |
permissive
|
matrix-org/matrix-ios-sdk
|
5fad7976a387a83b3a8eab2ecdabe178f922e373
|
cfca47d547185dcb9d89d5341dd6d2b4d148322f
|
refs/heads/develop
| 2023-08-31T17:29:33.650415
| 2023-08-29T09:07:22
| 2023-08-29T09:07:22
| 24,633,503
| 469
| 230
|
Apache-2.0
| 2023-09-12T06:44:21
| 2014-09-30T10:06:39
|
Objective-C
|
UTF-8
|
C
| false
| false
| 1,778
|
h
|
MXLoginSSOIdentityProviderBrand.h
|
//
// Copyright 2021 The Matrix.org Foundation C.I.C
//
// 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.
//
/// MXLoginSSOIdentityProviderBrand identifies known identity provider brands as described in MSC2858 (see https://github.com/matrix-org/matrix-doc/pull/2858).
/// Server implementations are free to add additional brands, though they should be mindful of clients which do not recognise any given brand.
/// Clients are free to implement any set of brands they wish, including all or any of the bellow, but are expected to apply a sensible unbranded fallback for any brand they do not recognise/support.
typedef NSString *const MXLoginSSOIdentityProviderBrand NS_TYPED_EXTENSIBLE_ENUM;
static MXLoginSSOIdentityProviderBrand const MXLoginSSOIdentityProviderBrandGitlab = @"gitlab";
static MXLoginSSOIdentityProviderBrand const MXLoginSSOIdentityProviderBrandGithub = @"github";
static MXLoginSSOIdentityProviderBrand const MXLoginSSOIdentityProviderBrandApple = @"apple";
static MXLoginSSOIdentityProviderBrand const MXLoginSSOIdentityProviderBrandGoogle = @"google";
static MXLoginSSOIdentityProviderBrand const MXLoginSSOIdentityProviderBrandFacebook = @"facebook";
static MXLoginSSOIdentityProviderBrand const MXLoginSSOIdentityProviderBrandTwitter = @"twitter";
|
60dd26ca61a80e55027006f5aae7ccd601b8dbda
|
88bd66842df4e38167ed0d07e29f33040029931b
|
/notes/data_structure/codes/9.4.归并排序-递归实现.c
|
487a17e304d17a5c4c32cd68f567979eeefe78df
|
[
"CC-BY-SA-4.0"
] |
permissive
|
PiperLiu/CS-courses-notes
|
3855292f4e58eac24e559c0aedea00a334a260a1
|
78315802cb61800a607575e13a17bb5d4765471e
|
refs/heads/master
| 2022-05-30T01:23:28.878483
| 2022-05-11T03:35:50
| 2022-05-11T03:35:50
| 221,176,862
| 360
| 57
|
Apache-2.0
| 2021-09-26T15:57:23
| 2019-11-12T09:16:55
|
C++
|
UTF-8
|
C
| false
| false
| 1,692
|
c
|
9.4.归并排序-递归实现.c
|
/* 归并排序 - 递归实现 */
/* L = 左边起始位置, R = 右边起始位置, RightEnd = 右边终点位置*/
void Merge(ElementType A[], ElementType TmpA[], int L, int R, int RightEnd)
{ /* 将有序的A[L]~A[R-1]和A[R]~A[RightEnd]归并成一个有序序列 */
int LeftEnd, NumElements, Tmp;
int i;
LeftEnd = R - 1; /* 左边终点位置 */
Tmp = L; /* 有序序列的起始位置 */
NumElements = RightEnd - L + 1;
while (L <= LeftEnd && R <= RightEnd)
{
if (A[L] <= A[R])
TmpA[Tmp++] = A[L++]; /* 将左边元素复制到TmpA */
else
TmpA[Tmp++] = A[R++]; /* 将右边元素复制到TmpA */
}
while (L <= LeftEnd)
TmpA[Tmp++] = A[L++]; /* 直接复制左边剩下的 */
while (R <= RightEnd)
TmpA[Tmp++] = A[R++]; /* 直接复制右边剩下的 */
for (i = 0; i < NumElements; i++, RightEnd--)
A[RightEnd] = TmpA[RightEnd]; /* 将有序的TmpA[]复制回A[] */
}
void Msort(ElementType A[], ElementType TmpA[], int L, int RightEnd)
{ /* 核心递归排序函数 */
int Center;
if (L < RightEnd)
{
Center = (L + RightEnd) / 2;
Msort(A, TmpA, L, Center); /* 递归解决左边 */
Msort(A, TmpA, Center + 1, RightEnd); /* 递归解决右边 */
Merge(A, TmpA, L, Center + 1, RightEnd); /* 合并两段有序序列 */
}
}
void MergeSort(ElementType A[], int N)
{ /* 归并排序 */
ElementType *TmpA;
TmpA = (ElementType *)malloc(N * sizeof(ElementType));
if (TmpA != NULL)
{
Msort(A, TmpA, 0, N - 1);
free(TmpA);
}
else
printf("空间不足");
}
|
f06c6ac42afc32756fbd0605c667dc2d52fa5ddd
|
6ff85b80c6fe1b3ad5416a304b93551a5e80de10
|
/C/Pointer/MallocFree.c
|
15027bf391ca9d7548f8fbef583ea21fa308960a
|
[
"MIT"
] |
permissive
|
maniero/SOpt
|
c600cc2333e0a47ce013be3516bbb8080502ff2a
|
5d17e1a9cbf115eaea6d30af2079d0c92ffff7a3
|
refs/heads/master
| 2023-08-10T16:48:46.058739
| 2023-08-10T13:42:17
| 2023-08-10T13:42:17
| 78,631,930
| 1,002
| 136
|
MIT
| 2023-01-28T12:10:01
| 2017-01-11T11:19:24
|
C#
|
UTF-8
|
C
| false
| false
| 205
|
c
|
MallocFree.c
|
#include <stdio.h>
#include <stdlib.h>
int main(){
char *ponteiro = malloc(100);
printf("String: ");
scanf("%99s", ponteiro);
free(ponteiro);
}
//https://pt.stackoverflow.com/q/45796/101
|
93c8ffa1a7fcf8b6df956e4ce172bac84af5d40e
|
f3eed0234b4d0ad2bbb2abd700cf1e2c7a0e8a1d
|
/AKWF-c/AKWF_0015/AKWF_1402.h
|
dde3c0e7fbd06c4b314fb7906d89ff71c42fa962
|
[
"CC0-1.0"
] |
permissive
|
KristofferKarlAxelEkstrand/AKWF-FREE
|
b2defa1a2d389d309be6dd2e9f968923daf80d1b
|
cf8171df36e9fec25416b5f568b72a6e2cb69194
|
refs/heads/master
| 2023-07-23T18:22:36.939705
| 2023-07-10T17:14:40
| 2023-07-10T17:14:40
| 145,817,187
| 359
| 59
|
CC0-1.0
| 2023-07-10T17:14:41
| 2018-08-23T07:26:56
| null |
UTF-8
|
C
| false
| false
| 4,672
|
h
|
AKWF_1402.h
|
/* Adventure Kid Waveforms (AKWF) converted for use with Teensy Audio Library
*
* Adventure Kid Waveforms(AKWF) Open waveforms library
* https://www.adventurekid.se/akrt/waveforms/adventure-kid-waveforms/
*
* This code is in the public domain, CC0 1.0 Universal (CC0 1.0)
* https://creativecommons.org/publicdomain/zero/1.0/
*
* Converted by Brad Roy, https://github.com/prosper00
*/
/* AKWF_1402 256 samples
+-----------------------------------------------------------------------------------------------------------------+
| **** ** |
| **** ** |
|*** *** |
|* *** |
| **** **|
| **** ** |
| ***** ** |
| ******* ** |
| ******* * |
| * ****** |
| * *** |
| * *** |
| * ** |
| * ** |
| * **** |
+-----------------------------------------------------------------------------------------------------------------+
*/
const uint16_t AKWF_1402 [] = {
32891, 33608, 34360, 35067, 35757, 36409, 37046, 37643, 38225, 38770, 39298, 39791, 40266, 40705, 41126, 41513,
41879, 42214, 42526, 42807, 43066, 43293, 43496, 43670, 43818, 43940, 44033, 44099, 44139, 44149, 44160, 44177,
44187, 44198, 44204, 44214, 44220, 44229, 44235, 44241, 44247, 44254, 44259, 44265, 44269, 44274, 44279, 44284,
44289, 44293, 44297, 44302, 44306, 44310, 44313, 44318, 44322, 44324, 44327, 44331, 44334, 44337, 44340, 44342,
44345, 44349, 44351, 44354, 44357, 44359, 44360, 44363, 44364, 44367, 44368, 44369, 44373, 44375, 44376, 44377,
44378, 44379, 44381, 44382, 44383, 44385, 44387, 44386, 44387, 44388, 44389, 44388, 44390, 44389, 44389, 44390,
44391, 44390, 44391, 44390, 44391, 44389, 44389, 44390, 44387, 44390, 44386, 44388, 44385, 44387, 44382, 44386,
44379, 44383, 44375, 44382, 44374, 44378, 44371, 44375, 44367, 44370, 44365, 44366, 44363, 44359, 44360, 44351,
44358, 44343, 44359, 44331, 44361, 44314, 44375, 44274, 44479, 43895, 42470, 41552, 40590, 39798, 38985, 38266,
37543, 36874, 36215, 35587, 34979, 34384, 33819, 33254, 32728, 32189, 31698, 31179, 30723, 30227, 29802, 29325,
28930, 28473, 28103, 27669, 27324, 26912, 26585, 26201, 25888, 25536, 25229, 24914, 24608, 24336, 24026, 23800,
23480, 23304, 22970, 22847, 22500, 22417, 22032, 21994, 21608, 21613, 21236, 21273, 20917, 20969, 20655, 20698,
20453, 20452, 20313, 20224, 20248, 19996, 20282, 19719, 20510, 19161, 21677, 7672, 0, 1367, 0, 1261,
586, 1590, 1357, 2174, 2265, 3002, 3367, 4094, 4705, 5476, 6316, 7158, 8115, 8862, 9774, 10424,
11278, 11845, 12624, 13125, 13819, 14261, 14860, 15248, 15750, 16088, 16489, 16777, 17078, 17315, 17517, 17699,
17805, 17928, 17933, 18133, 19968, 21704, 22979, 24295, 25376, 26524, 27491, 28529, 29412, 30367, 31178, 32072,
};
|
6c184fb99e5d7705d4779b6399690066f417d1fe
|
64f63e6468d7d1a8239ca8a60cb3a57671d7026e
|
/src/loadcore/clibUtils.h
|
242f0ff6c27084336146e79ed5d1287439246d22
|
[
"BSD-3-Clause",
"MIT"
] |
permissive
|
uofw/uofw
|
511c6877af464a4c18cd62405805ed92b15b39c3
|
c517e4cee6679cf2c0ecb24afaa50a86c6460cf1
|
refs/heads/master
| 2023-02-09T17:10:03.719610
| 2023-02-03T13:11:50
| 2023-02-03T13:11:50
| 6,622,246
| 312
| 93
|
NOASSERTION
| 2023-09-05T19:54:15
| 2012-11-09T23:39:19
|
C
|
UTF-8
|
C
| false
| false
| 1,442
|
h
|
clibUtils.h
|
/* Copyright (C) 2011, 2012 The uOFW team
See the file COPYING for copying permission.
*/
#ifndef CLIBUTILS_H
#define CLIBUTILS_H
#include <common_header.h>
/*
*
* Compare the string pointed to by s1 to the string pointed to by s2.
*
* Returns 1, 0 or -1 accordingly as the strong pointed to by s1 is
* greater than, equal to, or less then the string pointed to by s2.
*/
s32 strcmp(const char *s1, const char *s2);
/*
* Copy the first n characters of the array pointed to by src to the
* array pointed to by dest. If the array pointed to by src does not
* have n characters, NULL characters are copied for the remaining
* portion. If copying takes place between objects that overlap, the
* behavior is undefined.
*
* Returns the value of dest.
*/
char *strncpy(char *dest, const char *src, s32 n);
/*
* Compute the length of the string pointed to by s.
*
* Returns the number of characters that preceed the terminating NULL
* character.
*/
u32 strlen(const char *s);
/**
* Copy n characters from the object pointed to by src into the object
* pointed to by s1. If copying takes place between objects that
* overlap, the behavior is undefined. When all arguments are
* multiples of 4, copying can be executed faster via wmemcpy().
*
* Returns the value of dest.
*/
void *memcpy(void *dest, const void *src, u32 n);
#endif /* CLIBUTILS_H */
|
a2a56415c325979d290e0e94115d0373ef263472
|
fa1ad2e2ac7e376fc7cb3b3a6e1bb88eed3e80be
|
/govern/data-security/krb-1.2.1/src/lib/kadm5/admin_internal.h
|
31ba1ec6aa7a86729a1406b2bef4c17174d0f125
|
[
"BSD-4-Clause",
"LicenseRef-scancode-generic-export-compliance",
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-mit-old-style",
"BSD-4-Clause-UC",
"LicenseRef-scancode-rsa-1990",
"BSD-3-Clause",
"MIT-CMU",
"LicenseRef-scancode-mit-no-advert-export-control",
"CC-BY-SA-3.0",
"LicenseRef-scancode-mit-modification-obligations",
"LicenseRef-scancode-proprietary-license",
"GPL-2.0-or-later",
"LicenseRef-scancode-michigan-disclaimer",
"ISC",
"LicenseRef-scancode-nrl-permission",
"FreeBSD-DOC",
"LicenseRef-scancode-rsa-md4",
"RSA-MD",
"OLDAP-2.8",
"FSFULLRWD",
"BSD-2-Clause",
"LicenseRef-scancode-brian-gladman",
"MIT",
"Apache-2.0"
] |
permissive
|
alldatacenter/alldata
|
7bc7713c9f1d56ad6b8e59ea03206d1073b7e047
|
8d5f9a2d49ab8f9e85ccf058cb02c2fda287afc6
|
refs/heads/master
| 2023-08-05T07:32:25.442740
| 2023-08-03T13:17:24
| 2023-08-03T13:17:24
| 213,321,771
| 774
| 250
|
Apache-2.0
| 2023-09-06T17:35:32
| 2019-10-07T07:36:18
| null |
UTF-8
|
C
| false
| false
| 3,918
|
h
|
admin_internal.h
|
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved
*
*/
#ifndef __KADM5_ADMIN_INTERNAL_H__
#define __KADM5_ADMIN_INTERNAL_H__
#include <kadm5/admin.h>
#define KADM5_SERVER_HANDLE_MAGIC 0x12345800
#define CHECK_VERSIONS(struct_version, api_version, old_api_err, new_api_err) \
{ \
if ((struct_version & KADM5_MASK_BITS) != KADM5_STRUCT_VERSION_MASK) \
return KADM5_BAD_STRUCT_VERSION; \
if (struct_version < KADM5_STRUCT_VERSION_1) \
return KADM5_OLD_STRUCT_VERSION; \
if (struct_version > KADM5_STRUCT_VERSION_1) \
return KADM5_NEW_STRUCT_VERSION; \
if ((api_version & KADM5_MASK_BITS) != KADM5_API_VERSION_MASK) \
return KADM5_BAD_API_VERSION; \
if (api_version < KADM5_API_VERSION_2) \
return old_api_err; \
if (api_version > KADM5_API_VERSION_4) \
return new_api_err; \
}
#define GENERIC_CHECK_HANDLE(handle, old_api_err, new_api_err) \
{ \
kadm5_server_handle_t srvr = handle; \
\
if (srvr == NULL) \
return KADM5_BAD_SERVER_HANDLE; \
if (srvr->magic_number != KADM5_SERVER_HANDLE_MAGIC) \
return KADM5_BAD_SERVER_HANDLE; \
CHECK_VERSIONS(srvr->struct_version, srvr->api_version, \
old_api_err, new_api_err); \
}
/*
* _KADM5_CHECK_HANDLE calls the function _kadm5_check_handle and
* returns any non-zero error code that function returns.
* _kadm5_check_handle, in client_handle.c and server_handle.c, exists
* in both the server- and client- side libraries. In each library,
* it calls CHECK_HANDLE, which is defined by the appropriate
* _internal.h header file to call GENERIC_CHECK_HANDLE as well as
* CLIENT_CHECK_HANDLE and SERVER_CHECK_HANDLE.
*
* _KADM5_CHECK_HANDLE should be used by a function that needs to
* check the handle but wants to be the same code in both the client
* and server library; it makes a function call to the right handle
* checker. Code that only exists in one library can call the
* CHECK_HANDLE macro, which inlines the test instead of making
* another function call.
*
* Got that?
*/
#define _KADM5_CHECK_HANDLE(handle) \
{ int ecode; if ((ecode = _kadm5_check_handle((void *)handle))) return ecode;}
int _kadm5_check_handle(void *handle);
kadm5_ret_t _kadm5_chpass_principal_util(void *server_handle,
void *lhandle,
krb5_principal princ,
char *new_pw,
char **ret_pw,
char *msg_ret,
unsigned int msg_len);
/* this is needed by the alt_prof code I stole. The functions
maybe shouldn't be named krb5_*, but they are. */
krb5_error_code
krb5_string_to_keysalts(const char *string, const char *tupleseps,
const char *ksaltseps, krb5_boolean dups,
krb5_key_salt_tuple **ksaltp, krb5_int32 *nksaltp);
#endif /* __KADM5_ADMIN_INTERNAL_H__ */
|
3d149ef2a96c7478f4f669e8d91f1d438a5b79d2
|
50dd46b8ece33f3cdd174284b15d1d51f89669d4
|
/third_party/edk2/Nt32Pkg/MiscSubClassPlatformDxe/MiscBiosVendorFunction.c
|
415a8cab3aa12ee24f65d9d0d52f3b0c0dc60990
|
[
"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
| 6,848
|
c
|
MiscBiosVendorFunction.c
|
/** @file
BIOS vendor information boot time changes.
Misc. subclass type 2.
SMBIOS type 0.
Copyright (c) 2009 - 2011, 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
which 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.
**/
#include "MiscSubclassDriver.h"
/**
This function returns the value & exponent to Base2 for a given
Hex value. This is used to calculate the BiosPhysicalDeviceSize.
@param Value The hex value which is to be converted into value-exponent form
@param Exponent The exponent out of the conversion
@retval EFI_SUCCESS All parameters were valid and *Value & *Exponent have been set.
@retval EFI_INVALID_PARAMETER Invalid parameter was found.
**/
EFI_STATUS
GetValueExponentBase2(
IN OUT UINTN *Value,
OUT UINTN *Exponent
)
{
if ((Value == NULL) || (Exponent == NULL)) {
return EFI_INVALID_PARAMETER;
}
while ((*Value % 2) == 0) {
*Value=*Value/2;
(*Exponent)++;
}
return EFI_SUCCESS;
}
/**
Field Filling Function. Transform an EFI_EXP_BASE2_DATA to a byte, with '64k'
as the unit.
@param Base2Data Pointer to Base2_Data
@retval EFI_SUCCESS Transform successfully.
@retval EFI_INVALID_PARAMETER Invalid parameter was found.
**/
UINT16
Base2ToByteWith64KUnit (
IN EFI_EXP_BASE2_DATA *Base2Data
)
{
UINT16 Value;
UINT16 Exponent;
Value = Base2Data->Value;
Exponent = Base2Data->Exponent;
Exponent -= 16;
Value <<= Exponent;
return Value;
}
/**
This function makes boot time changes to the contents of the
MiscBiosVendor (Type 0).
@param RecordData Pointer to copy of RecordData from the Data Table.
@retval EFI_SUCCESS All parameters were valid.
@retval EFI_UNSUPPORTED Unexpected RecordType value.
@retval EFI_INVALID_PARAMETER Invalid parameter was found.
**/
MISC_SMBIOS_TABLE_FUNCTION(MiscBiosVendor)
{
CHAR8 *OptionalStrStart;
UINTN VendorStrLen;
UINTN VerStrLen;
UINTN DateStrLen;
CHAR16 *Version;
CHAR16 *ReleaseDate;
EFI_STATUS Status;
EFI_STRING Char16String;
STRING_REF TokenToGet;
STRING_REF TokenToUpdate;
SMBIOS_TABLE_TYPE0 *SmbiosRecord;
EFI_SMBIOS_HANDLE SmbiosHandle;
EFI_MISC_BIOS_VENDOR *ForType0InputData;
ForType0InputData = (EFI_MISC_BIOS_VENDOR *)RecordData;
//
// First check for invalid parameters.
//
if (RecordData == NULL) {
return EFI_INVALID_PARAMETER;
}
Version = (CHAR16 *) PcdGetPtr (PcdFirmwareVersionString);
if (StrLen (Version) > 0) {
TokenToUpdate = STRING_TOKEN (STR_MISC_BIOS_VERSION);
HiiSetString (mHiiHandle, TokenToUpdate, Version, NULL);
}
ReleaseDate = (CHAR16 *) PcdGetPtr (PcdFirmwareReleaseDateString);
if (StrLen(ReleaseDate) > 0) {
TokenToUpdate = STRING_TOKEN (STR_MISC_BIOS_RELEASE_DATE);
HiiSetString (mHiiHandle, TokenToUpdate, ReleaseDate, NULL);
}
TokenToGet = STRING_TOKEN (STR_MISC_BIOS_VENDOR);
Char16String = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);
VendorStrLen = StrLen(Char16String);
if (VendorStrLen > SMBIOS_STRING_MAX_LENGTH) {
return EFI_UNSUPPORTED;
}
TokenToGet = STRING_TOKEN (STR_MISC_BIOS_VERSION);
Version = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);
VerStrLen = StrLen(Version);
if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) {
return EFI_UNSUPPORTED;
}
TokenToGet = STRING_TOKEN (STR_MISC_BIOS_RELEASE_DATE);
ReleaseDate = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);
DateStrLen = StrLen(ReleaseDate);
if (DateStrLen > SMBIOS_STRING_MAX_LENGTH) {
return EFI_UNSUPPORTED;
}
//
// Two zeros following the last string.
//
SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE0) + VendorStrLen + 1 + VerStrLen + 1 + DateStrLen + 1 + 1);
ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE0) + VendorStrLen + 1 + VerStrLen + 1 + DateStrLen + 1 + 1);
SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_BIOS_INFORMATION;
SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE0);
//
// Make handle chosen by smbios protocol.add automatically.
//
SmbiosRecord->Hdr.Handle = 0;
//
// Vendor will be the 1st optional string following the formatted structure.
//
SmbiosRecord->Vendor = 1;
//
// Version will be the 2nd optional string following the formatted structure.
//
SmbiosRecord->BiosVersion = 2;
SmbiosRecord->BiosSegment = (UINT16)ForType0InputData->BiosStartingAddress;
//
// ReleaseDate will be the 3rd optional string following the formatted structure.
//
SmbiosRecord->BiosReleaseDate = 3;
//
// Nt32 has no PCD value to indicate BIOS Size, just fill 0 for simply.
//
SmbiosRecord->BiosSize = 0;
SmbiosRecord->BiosCharacteristics = *(MISC_BIOS_CHARACTERISTICS*)(&ForType0InputData->BiosCharacteristics1);
//
// CharacterExtensionBytes also store in ForType0InputData->BiosCharacteristics1 later two bytes to save size.
//
SmbiosRecord->BIOSCharacteristicsExtensionBytes[0] = *((UINT8 *) &ForType0InputData->BiosCharacteristics1 + 4);
SmbiosRecord->BIOSCharacteristicsExtensionBytes[1] = *((UINT8 *) &ForType0InputData->BiosCharacteristics1 + 5);
SmbiosRecord->SystemBiosMajorRelease = ForType0InputData->BiosMajorRelease;
SmbiosRecord->SystemBiosMinorRelease = ForType0InputData->BiosMinorRelease;
SmbiosRecord->EmbeddedControllerFirmwareMajorRelease = ForType0InputData->BiosEmbeddedFirmwareMajorRelease;
SmbiosRecord->EmbeddedControllerFirmwareMinorRelease = ForType0InputData->BiosEmbeddedFirmwareMinorRelease;
OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
UnicodeStrToAsciiStr(Char16String, OptionalStrStart);
UnicodeStrToAsciiStr(Version, OptionalStrStart + VendorStrLen + 1);
UnicodeStrToAsciiStr(ReleaseDate, OptionalStrStart + VendorStrLen + 1 + VerStrLen + 1);
//
// Now we have got the full smbios record, call smbios protocol to add this record.
//
Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord);
FreePool(SmbiosRecord);
return Status;
}
|
8bb36d1146b7537578d4ea8687b35461fa56e860
|
9ceacf33fd96913cac7ef15492c126d96cae6911
|
/sys/dev/pci/drm/include/linux/async.h
|
5cc703cfa5c5f0b4a4fd7f0234074c2737013310
|
[] |
no_license
|
openbsd/src
|
ab97ef834fd2d5a7f6729814665e9782b586c130
|
9e79f3a0ebd11a25b4bff61e900cb6de9e7795e9
|
refs/heads/master
| 2023-09-02T18:54:56.624627
| 2023-09-02T15:16:12
| 2023-09-02T15:16:12
| 66,966,208
| 3,394
| 1,235
| null | 2023-08-08T02:42:25
| 2016-08-30T18:18:25
|
C
|
UTF-8
|
C
| false
| false
| 296
|
h
|
async.h
|
/* Public domain. */
#ifndef _LINUX_ASYNC_H
#define _LINUX_ASYNC_H
#include <sys/types.h>
typedef uint64_t async_cookie_t;
typedef void (*async_func_t) (void *, async_cookie_t);
static inline async_cookie_t
async_schedule(async_func_t func, void *data)
{
func(data, 0);
return 0;
}
#endif
|
c0b92b4d212f6e88c1800ded8416abcd72af34a7
|
34cfb15a219a735d58fcaadfb71ef1606a9114dc
|
/ext/src/swow_watchdog.c
|
ffcfbdfea1f8e993e7e371b0493841c489ff9894
|
[
"Apache-2.0",
"ISC",
"BSL-1.0",
"MIT",
"BSD-2-Clause"
] |
permissive
|
swow/swow
|
e32007f3cf1c8daf4accd7d64f9b2b728f5ab103
|
231f580dd1ee84d0364f314387073c5bda9854d2
|
refs/heads/develop
| 2023-08-19T13:51:39.840737
| 2023-08-05T01:51:04
| 2023-08-05T03:13:03
| 295,651,066
| 1,085
| 117
|
Apache-2.0
| 2023-06-15T09:18:12
| 2020-09-15T07:37:43
|
C
|
UTF-8
|
C
| false
| false
| 9,021
|
c
|
swow_watchdog.c
|
/*
+--------------------------------------------------------------------------+
| Swow |
+--------------------------------------------------------------------------+
| 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. See accompanying LICENSE file. |
+--------------------------------------------------------------------------+
| Author: Twosee <twosee@php.net> |
+--------------------------------------------------------------------------+
*/
#include "swow_watchdog.h"
#include "cat_time.h" /* for time_wait() */
SWOW_API zend_class_entry *swow_watchdog_ce;
SWOW_API zend_class_entry *swow_watchdog_exception_ce;
typedef void (*swow_interrupt_function_t)(zend_execute_data *execute_data);
static swow_interrupt_function_t original_zend_interrupt_function = (swow_interrupt_function_t) -1;
SWOW_API void swow_watchdog_alert_standard(cat_watchdog_t *watchdog)
{
swow_watchdog_t *s_watchdog = swow_watchdog_get_from_handle(watchdog);
cat_bool_t vm_interrupted;
// CPU starvation (and we should try to schedule the coroutine)
vm_interrupted = cat_atomic_bool_exchange(&s_watchdog->vm_interrupted, cat_false);
zend_atomic_bool_store(s_watchdog->vm_interrupt_ptr, 1);
if (
watchdog->alert_count > 1 &&
vm_interrupted == 0 /* interrupt maybe failed */
) {
if (
watchdog->threshold > 0 && /* blocking time is greater than syscall threshold */
((cat_timeout_t) (watchdog->quantum * watchdog->alert_count)) > watchdog->threshold
) {
/* Syscall blocking
* CPU starvation is also possible,
* the machine performance is too bad (such as mine),
* VM has not interrupted yet */
cat_watchdog_alert_standard(watchdog);
}
}
}
static void swow_watchdog_interrupt_function(zend_execute_data *execute_data)
{
if (cat_watchdog_is_running()) {
swow_watchdog_t *s_watchdog = swow_watchdog_get_current();
cat_watchdog_t *watchdog = &s_watchdog->watchdog;
cat_atomic_bool_store(&s_watchdog->vm_interrupted, cat_true);
/* re-check if current switches still equal to last_switches */
if (CAT_COROUTINE_G(switches) == watchdog->last_switches) {
if (s_watchdog->alerter.function_handler == NULL) {
if (
!cat_time_wait(s_watchdog->delay) &&
cat_get_last_error_code() != CAT_ETIMEDOUT
) {
CAT_CORE_ERROR_WITH_LAST(WATCH_DOG, "Watchdog interrupt schedule failed");
}
} else {
zend_fcall_info fci;
zval retval;
fci.size = sizeof(fci);
ZVAL_UNDEF(&fci.function_name);
fci.object = NULL;
fci.param_count = 0;
fci.named_params = NULL;
fci.retval = &retval;
(void) zend_call_function(&fci, &s_watchdog->alerter);
zval_ptr_dtor(&retval);
}
}
}
if (original_zend_interrupt_function != NULL) {
original_zend_interrupt_function(execute_data);
}
}
SWOW_API cat_bool_t swow_watchdog_run(cat_timeout_t quantum, cat_timeout_t threshold, zval *z_alerter)
{
swow_watchdog_t *s_watchdog;
zend_fcall_info_cache fcc = empty_fcall_info_cache;
cat_timeout_t delay = 0;
cat_bool_t ret;
if (z_alerter != NULL) {
switch (Z_TYPE_P(z_alerter)) {
case IS_NULL:
case IS_LONG:
case IS_DOUBLE:
delay = zval_get_long(z_alerter);
z_alerter = NULL;
break;
default: {
char *error;
if (!zend_is_callable_ex(z_alerter, NULL, 0, NULL, &fcc, &error)) {
cat_update_last_error(CAT_EMISUSE, "Watchdog alerter must be numeric or callable, %s", error);
efree(error);
return cat_false;
}
efree(error);
}
}
}
s_watchdog = (swow_watchdog_t *) emalloc(sizeof(*s_watchdog));
cat_atomic_bool_init(&s_watchdog->vm_interrupted, cat_false);
s_watchdog->vm_interrupt_ptr = &EG(vm_interrupt);
s_watchdog->delay = delay;
s_watchdog->alerter = fcc;
if (z_alerter != NULL) {
ZVAL_COPY(&s_watchdog->z_alerter, z_alerter);
} else {
ZVAL_NULL(&s_watchdog->z_alerter);
}
ret = cat_watchdog_run(&s_watchdog->watchdog, quantum, threshold, swow_watchdog_alert_standard);
if (!ret) {
Z_TRY_DELREF(s_watchdog->z_alerter);
efree(s_watchdog);
return cat_false;
}
return cat_true;
}
SWOW_API cat_bool_t swow_watchdog_stop(void)
{
swow_watchdog_t *s_watchdog = swow_watchdog_get_current();
cat_bool_t ret;
ret = cat_watchdog_stop();
if (!ret) {
return cat_false;
}
zval_ptr_dtor(&s_watchdog->z_alerter);
efree(s_watchdog);
return cat_true;
}
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Swow_Watchdog_run, 0, 0, IS_VOID, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, quantum, IS_LONG, 0, "0")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, threshold, IS_LONG, 0, "0")
ZEND_ARG_TYPE_MASK(0, alerter, MAY_BE_CALLABLE | MAY_BE_LONG | MAY_BE_DOUBLE | MAY_BE_NULL, "null")
ZEND_END_ARG_INFO()
static PHP_METHOD(Swow_Watchdog, run)
{
zend_long quantum = 0;
zend_long threshold = 0;
zval *z_alerter = NULL;
cat_bool_t ret;
ZEND_PARSE_PARAMETERS_START(0, 3)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(quantum)
Z_PARAM_LONG(threshold)
Z_PARAM_ZVAL(z_alerter)
ZEND_PARSE_PARAMETERS_END();
if (original_zend_interrupt_function == (swow_interrupt_function_t) -1) {
original_zend_interrupt_function = zend_interrupt_function;
zend_interrupt_function = swow_watchdog_interrupt_function;
}
ret = swow_watchdog_run(quantum, threshold, z_alerter);
if (UNEXPECTED(!ret)) {
swow_throw_exception_with_last(swow_watchdog_exception_ce);
RETURN_THROWS();
}
}
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Swow_Watchdog_stop, 0, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()
static PHP_METHOD(Swow_Watchdog, stop)
{
cat_bool_t ret;
ZEND_PARSE_PARAMETERS_NONE();
ret = swow_watchdog_stop();
if (UNEXPECTED(!ret)) {
swow_throw_exception_with_last(swow_watchdog_exception_ce);
RETURN_THROWS();
}
}
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Swow_Watchdog_isRunning, 0, 0, _IS_BOOL, 0)
ZEND_END_ARG_INFO()
static PHP_METHOD(Swow_Watchdog, isRunning)
{
ZEND_PARSE_PARAMETERS_NONE();
RETURN_BOOL(cat_watchdog_is_running());
}
static const zend_function_entry swow_watchdog_methods[] = {
PHP_ME(Swow_Watchdog, run, arginfo_class_Swow_Watchdog_run, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
PHP_ME(Swow_Watchdog, stop, arginfo_class_Swow_Watchdog_stop, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
PHP_ME(Swow_Watchdog, isRunning, arginfo_class_Swow_Watchdog_isRunning, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
PHP_FE_END
};
zend_result swow_watchdog_module_init(INIT_FUNC_ARGS)
{
if (!cat_watchdog_module_init()) {
return FAILURE;
}
swow_watchdog_ce = swow_register_internal_class(
"Swow\\Watchdog", NULL, swow_watchdog_methods,
NULL, NULL, cat_false, cat_false,
swow_create_object_deny, NULL, 0
);
swow_watchdog_exception_ce = swow_register_internal_class(
"Swow\\WatchdogException", swow_exception_ce, NULL, NULL, NULL, cat_true, cat_true, NULL, NULL, 0
);
return SUCCESS;
}
zend_result swow_watchdog_module_shutdown(INIT_FUNC_ARGS)
{
if (!cat_watchdog_module_shutdown()) {
return FAILURE;
}
return SUCCESS;
}
zend_result swow_watchdog_runtime_init(INIT_FUNC_ARGS)
{
if (!cat_watchdog_runtime_init()) {
return FAILURE;
}
return SUCCESS;
}
zend_result swow_watchdog_runtime_shutdown(INIT_FUNC_ARGS)
{
if (cat_watchdog_is_running() && !swow_watchdog_stop()) {
CAT_CORE_ERROR_WITH_LAST(WATCH_DOG, "Watchdog stop failed");
}
if (!cat_watchdog_runtime_shutdown()) {
return FAILURE;
}
return SUCCESS;
}
|
c40458bdd72b6033e8ddf4add499a8f1f4e86656
|
f8cc1dd4b1378490386def2e0571561fab10b275
|
/src/libstddjb/socket_accept6.c
|
2c185402af7da1a077dfac0660b870e37164cb9b
|
[
"ISC"
] |
permissive
|
skarnet/skalibs
|
b1eb2a0e38663cbfa918ee0a7916f56227bd7c2d
|
1f2d5f95684e93f8523e369ef1fed7a75c444082
|
refs/heads/master
| 2023-08-23T07:33:20.996016
| 2023-08-08T09:39:15
| 2023-08-08T09:39:15
| 31,461,366
| 104
| 32
|
ISC
| 2021-04-11T10:10:54
| 2015-02-28T12:01:41
|
C
|
UTF-8
|
C
| false
| false
| 1,291
|
c
|
socket_accept6.c
|
/* ISC license. */
#include <skalibs/sysdeps.h>
#include <skalibs/nonposix.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <skalibs/uint16.h>
#include <skalibs/djbunix.h>
#include <skalibs/ip46.h>
#include <skalibs/socket.h>
#ifdef SKALIBS_IPV6_ENABLED
int socket_accept6_internal (int s, char *ip6, uint16_t *port, unsigned int options)
{
int fd ;
struct sockaddr_in6 sa ;
socklen_t dummy = sizeof sa ;
do
#ifdef SKALIBS_HASACCEPT4
fd = accept4(s, (struct sockaddr *)&sa, &dummy, ((options & O_NONBLOCK) ? SOCK_NONBLOCK : 0) | ((options & O_CLOEXEC) ? SOCK_CLOEXEC : 0)) ;
#else
fd = accept(s, (struct sockaddr *)&sa, &dummy) ;
#endif
while ((fd < 0) && (errno == EINTR)) ;
if (fd < 0) return -1 ;
#ifndef SKALIBS_HASACCEPT4
if ((((options & O_NONBLOCK) ? ndelay_on(fd) : ndelay_off(fd)) < 0)
|| (((options & O_CLOEXEC) ? coe(fd) : uncoe(fd)) < 0))
{
fd_close(fd) ;
return -1 ;
}
#endif
memcpy(ip6, sa.sin6_addr.s6_addr, 16) ;
*port = uint16_big(sa.sin6_port) ;
return fd ;
}
#else
int socket_accept6_internal (int s, char *ip6, uint16_t *port, unsigned int options)
{
(void)s ;
(void)ip6 ;
(void)port ;
(void)options ;
return (errno = ENOSYS, -1) ;
}
#endif
|
f2c8bfacf25732c0bba875684a0674c8e6381e7e
|
68cf7384555b1a3aa954e3f324729acab09c6be9
|
/output/outlib.c
|
54c8753097459f17f48b1406978a5d59358fe45d
|
[
"BSD-2-Clause"
] |
permissive
|
netwide-assembler/nasm
|
060771c90f0f4a56d23f06c864de7faa75a23562
|
a916e4127b2eaa3bf40bddf3de9b0ceefc0d98a4
|
refs/heads/master
| 2023-09-04T11:12:02.449021
| 2023-02-20T05:29:46
| 2023-02-20T05:29:46
| 130,599,566
| 1,891
| 265
|
NOASSERTION
| 2023-09-05T12:35:45
| 2018-04-22T19:15:17
|
Assembly
|
UTF-8
|
C
| false
| false
| 9,182
|
c
|
outlib.c
|
/* ----------------------------------------------------------------------- *
*
* Copyright 1996-2020 The NASM Authors - All Rights Reserved
* See the file AUTHORS included with the NASM distribution for
* the specific copyright holders.
*
* 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.
*
* 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.
*
* ----------------------------------------------------------------------- */
/*
* outlib.c
*
* Common routines for the output backends.
*/
#include "outlib.h"
#include "raa.h"
uint64_t realsize(enum out_type type, uint64_t size)
{
switch (type) {
case OUT_REL1ADR:
return 1;
case OUT_REL2ADR:
return 2;
case OUT_REL4ADR:
return 4;
case OUT_REL8ADR:
return 8;
default:
return size;
}
}
/* Common section/symbol handling */
struct ol_sect *_ol_sect_list;
uint64_t _ol_nsects; /* True sections, not external symbols */
static struct ol_sect **ol_sect_tail = &_ol_sect_list;
static struct hash_table ol_secthash;
static struct RAA *ol_sect_index_tbl;
struct ol_sym *_ol_sym_list;
uint64_t _ol_nsyms;
static struct ol_sym **ol_sym_tail = &_ol_sym_list;
static struct hash_table ol_symhash;
void ol_init(void)
{
}
static void ol_free_symbols(void)
{
struct ol_sym *s, *stmp;
hash_free(&ol_symhash);
list_for_each_safe(s, stmp, _ol_sym_list) {
nasm_free((char *)s->name);
nasm_free(s);
}
_ol_nsyms = 0;
_ol_sym_list = NULL;
ol_sym_tail = &_ol_sym_list;
}
static void ol_free_sections(void)
{
struct ol_sect *s, *stmp;
hash_free(&ol_secthash);
raa_free(ol_sect_index_tbl);
ol_sect_index_tbl = NULL;
list_for_each_safe(s, stmp, _ol_sect_list) {
saa_free(s->data);
saa_free(s->reloc);
nasm_free((char *)s->name);
nasm_free(s);
}
_ol_nsects = 0;
_ol_sect_list = NULL;
ol_sect_tail = &_ol_sect_list;
}
void ol_cleanup(void)
{
ol_free_symbols();
ol_free_sections();
}
/*
* Allocate a section index and add a section, subsection, or external
* symbol to the section-by-index table. If the index provided is zero,
* allocate a new index via seg_alloc().
*/
static uint32_t ol_seg_alloc(void *s, uint32_t ix)
{
if (!ix)
ix = seg_alloc();
ol_sect_index_tbl = raa_write_ptr(ol_sect_index_tbl, ix >> 1, s);
return ix;
}
/*
* Find a section or create a new section structure if it does not exist
* and allocate it an index value via seg_alloc().
*/
struct ol_sect *_ol_get_sect(const char *name, size_t ssize, size_t rsize)
{
struct ol_sect *s, **sp;
struct hash_insert hi;
sp = (struct ol_sect **)hash_find(&ol_secthash, name, &hi);
if (sp)
return *sp;
s = nasm_zalloc(ssize);
s->syml.tail = &s->syml.head;
s->name = nasm_strdup(name);
s->data = saa_init(1);
s->reloc = saa_init(rsize);
*ol_sect_tail = s;
ol_sect_tail = &s->next;
_ol_nsects++;
s->index = s->subindex = ol_seg_alloc(s, 0);
hash_add(&hi, s->name, s);
return s;
}
/* Find a section by name without creating one */
struct ol_sect *_ol_sect_by_name(const char *name)
{
struct ol_sect **sp;
sp = (struct ol_sect **)hash_find(&ol_secthash, name, NULL);
return sp ? *sp : NULL;
}
/* Find a section or external symbol by index; NULL if not valid */
struct ol_sect *_ol_sect_by_index(int32_t index)
{
uint32_t ix = index;
if (unlikely(ix >= SEG_ABS))
return NULL;
return raa_read_ptr(ol_sect_index_tbl, ix >> 1);
}
/*
* Start a new subsection for the given section. At the moment, once a
* subsection has been created, it is not possible to revert to an
* earlier subsection. ol_sect_by_index() will return the main section
* structure. Returns the new section index. This is used to prevent
* the front end from optimizing across subsection boundaries.
*/
int32_t _ol_new_subsection(struct ol_sect *sect)
{
if (unlikely(!sect))
return NO_SEG;
return sect->subindex = ol_seg_alloc(sect, 0);
}
/*
* Insert a symbol into a list; need to use upcasting using container_of()
* to walk the list later.
*/
static void ol_add_sym_to(struct ol_symlist *syml, struct ol_symhead *head,
uint64_t offset)
{
syml->tree.key = offset;
head->tree = rb_insert(head->tree, &syml->tree);
*head->tail = syml;
head->tail = &syml->next;
head->n++;
}
/*
* Create a location structure from seg:offs
*/
void ol_mkloc(struct ol_loc *loc, int64_t offs, int32_t seg)
{
nasm_zero(*loc);
loc->offs = offs;
if (unlikely((uint32_t)seg >= SEG_ABS)) {
if (likely(seg == NO_SEG)) {
loc->seg.t = OS_NOSEG;
} else {
loc->seg.t = OS_ABS;
loc->seg.index = seg - SEG_ABS;
}
} else {
loc->seg.index = seg & ~1;
loc->seg.t = OS_SECT | (seg & 1);
loc->seg.s.sect = _ol_sect_by_index(loc->seg.index);
}
}
/*
* Create a new symbol. If this symbol is OS_OFFS, add it to the relevant
* section, too. If the symbol already exists, return NULL; this is
* different from ol_get_section() as a single section may be invoked
* many times. On the contrary, the front end will prevent a single symbol
* from being defined more than once.
*
* If flags has OF_GLOBAL set, add it to the global symbol hash for
* the containing section if applicable.
*
* If flags has OF_IMPSEC set, allocate a segment index for it via
* seg_alloc() unless v->index is already set, and add it to the
* section by index list.
*/
struct ol_sym *_ol_new_sym(const char *name, const struct ol_loc *v,
uint32_t flags, size_t size)
{
struct hash_insert hi;
struct ol_sym *sym;
if (hash_find(&ol_symhash, name, &hi))
return NULL; /* Symbol already exists */
flags |= OF_SYMBOL;
sym = nasm_zalloc(size);
sym->name = nasm_strdup(name);
sym->v = *v;
if (sym->v.seg.t & OS_SECT) {
struct ol_sect *sect = sym->v.seg.s.sect;
if (!sect || (sect->flags & OF_SYMBOL))
/* Must be an external or common reference */
flags |= OF_IMPSEC;
if (flags & OF_IMPSEC) {
/* Metasection */
if (!sym->v.seg.s.sym) {
sym->v.seg.s.sym = sym;
sym->v.seg.index = ol_seg_alloc(sym, sym->v.seg.index);
}
} else if (sym->v.seg.t == OS_OFFS) {
struct ol_sect * const sect = sym->v.seg.s.sect;
const uint64_t offs = sym->v.offs;
ol_add_sym_to(&sym->syml, §->syml, offs);
if (flags & OF_GLOBAL)
ol_add_sym_to(&sym->symg, §->symg, offs);
}
}
sym->flags = flags;
*ol_sym_tail = sym;
ol_sym_tail = &sym->next;
_ol_nsyms++;
hash_add(&hi, sym->name, sym);
return sym;
}
/* Find a symbol in the global namespace */
struct ol_sym *_ol_sym_by_name(const char *name)
{
struct ol_sym **symp;
symp = (struct ol_sym **)hash_find(&ol_symhash, name, NULL);
return symp ? *symp : NULL;
}
/*
* Find a symbol by address in a specific section. If no symbol is defined
* at that exact address, return the immediately previously defined one.
* If global is set, then only return global symbols.
*/
struct ol_sym *_ol_sym_by_address(struct ol_sect *sect, int64_t addr,
bool global)
{
struct ol_symhead *head;
size_t t_offs;
struct rbtree *t;
if (global) {
head = §->symg;
t_offs = offsetof(struct ol_sym, symg.tree);
} else {
head = §->syml;
t_offs = offsetof(struct ol_sym, syml.tree);
}
t = rb_search(head->tree, addr);
if (!t)
return NULL;
return (struct ol_sym *)((char *)t - t_offs);
}
|
84e147e19bca3b75bcceac2d762bca5c26530581
|
1efb2283837c9b70bc6449cec877799e4efa3268
|
/test/mpi/threads/mpi_t/mpit_threading.c
|
cb23c6a9676913e8f8821b490a4da24b5495a38f
|
[
"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
| 19,853
|
c
|
mpit_threading.c
|
/*
* Copyright (C) by Argonne National Laboratory
* See COPYRIGHT in top-level directory
*/
/* This test is adapted from test/mpi/mpi_t/mpit_vars.c.
But this is a multithreading version in which multiple threads will
call MPI_T routines.
If verbose is set, thread 0 will prints out MPI_T control variables,
performance variables and their categories.
*/
#include "mpi.h"
#include "mpitest.h"
#include "mpithreadtest.h"
#include <stdio.h>
#include <strings.h>
#include <string.h>
#include <stdlib.h>
/* Num of threads to spawn */
const int NTHREADS = 8;
/* Use macro to control printing. Threads must define myThreadId.
*/
static int verbose = 0;
#define DOPRINT (verbose && myThreadId == 0)
const char *mpit_scopeToStr(int scope);
const char *mpit_bindingToStr(int binding);
const char *mpit_validDtypeStr(MPI_Datatype datatype);
const char *mpit_varclassToStr(int varClass);
const char *mpit_verbosityToStr(int verbosity);
const char *mpit_errclassToStr(int err);
int perfvarReadInt(int pvarIndex, int isContinuous, int *found);
unsigned int perfvarReadUint(int pvarIndex, int isContinuous, int *found);
double perfvarReadDouble(int pvarIndex, int isContinuous, int *found);
int PrintControlVars(FILE * fp, int myThreadId);
int PrintPerfVars(FILE * fp, int myThreadId);
int PrintCategories(FILE * fp, int myThreadId);
static MTEST_THREAD_RETURN_TYPE RunTest(void *p)
{
int myThreadId = (int) (long) p;
PrintControlVars(stdout, myThreadId);
if (DOPRINT)
fprintf(stdout, "\n");
PrintPerfVars(stdout, myThreadId);
if (DOPRINT)
fprintf(stdout, "\n");
PrintCategories(stdout, myThreadId);
return MTEST_THREAD_RETVAL_IGN;
}
int main(int argc, char *argv[])
{
int i, required, provided;
required = MPI_THREAD_MULTIPLE;
MPI_T_init_thread(required, &provided);
if (provided != MPI_THREAD_MULTIPLE) {
fprintf(stderr, "MPI_THREAD_MULTIPLE not supported by the MPI_T implementation\n");
MPI_Abort(MPI_COMM_WORLD, -1);
}
MTest_Init_thread(&argc, &argv, required, &provided);
if (provided != MPI_THREAD_MULTIPLE) {
fprintf(stderr, "MPI_THREAD_MULTIPLE not supported by the MPI implementation\n");
MPI_Abort(MPI_COMM_WORLD, -1);
}
if (getenv("MPITEST_VERBOSE"))
verbose = 1;
/* Spawn threads */
for (i = 0; i < NTHREADS; i++) {
MTest_Start_thread(RunTest, (void *) (long) i);
}
MTest_Join_threads();
/* Put MPI_T_finalize() after MPI_Finalize() will cause mpich memory
* tracing facility falsely reports memory leaks, though these memories
* are freed in MPI_T_finalize().
*/
MPI_T_finalize();
MTest_Finalize(0);
return 0;
}
int PrintControlVars(FILE * fp, int myThreadId)
{
int i, num_cvar, nameLen, verbosity, descLen, binding, scope;
int ival, hasValue;
char name[128], desc[1024];
MPI_T_enum enumtype = MPI_T_ENUM_NULL;
MPI_Datatype datatype;
MPI_T_cvar_get_num(&num_cvar);
if (DOPRINT)
fprintf(fp, "%d MPI Control Variables\n", num_cvar);
for (i = 0; i < num_cvar; i++) {
hasValue = 0;
nameLen = sizeof(name);
descLen = sizeof(desc);
MPI_T_cvar_get_info(i, name, &nameLen, &verbosity, &datatype,
&enumtype, desc, &descLen, &binding, &scope);
if (datatype == MPI_INT && enumtype != MPI_T_ENUM_NULL) {
int enameLen, enumber;
char ename[128];
enameLen = sizeof(ename);
/* TODO: Extract a useful string to show for an enum */
MPI_T_enum_get_info(enumtype, &enumber, ename, &enameLen);
}
if (datatype == MPI_INT && binding == MPI_T_BIND_NO_OBJECT) {
int count;
MPI_T_cvar_handle chandle;
MPI_T_cvar_handle_alloc(i, NULL, &chandle, &count);
if (count == 1) {
MPI_T_cvar_read(chandle, &ival);
hasValue = 1;
}
MPI_T_cvar_handle_free(&chandle);
}
if (hasValue && DOPRINT) {
fprintf(fp, "\t%s=%d\t%s\t%s\t%s\t%s\t%s\n",
name,
ival,
mpit_scopeToStr(scope),
mpit_bindingToStr(binding),
mpit_validDtypeStr(datatype), mpit_verbosityToStr(verbosity), desc);
} else if (DOPRINT) {
fprintf(fp, "\t%s\t%s\t%s\t%s\t%s\t%s\n",
name,
mpit_scopeToStr(scope),
mpit_bindingToStr(binding),
mpit_validDtypeStr(datatype), mpit_verbosityToStr(verbosity), desc);
}
}
return 0;
}
int PrintPerfVars(FILE * fp, int myThreadId)
{
int i, numPvar, nameLen, descLen, verbosity, varClass;
int binding, isReadonly, isContinuous, isAtomic;
char name[128], desc[1024];
MPI_T_enum enumtype;
MPI_Datatype datatype;
MPI_T_pvar_get_num(&numPvar);
if (DOPRINT)
fprintf(fp, "%d MPI Performance Variables\n", numPvar);
for (i = 0; i < numPvar; i++) {
nameLen = sizeof(name);
descLen = sizeof(desc);
MPI_T_pvar_get_info(i, name, &nameLen, &verbosity, &varClass,
&datatype, &enumtype, desc, &descLen, &binding,
&isReadonly, &isContinuous, &isAtomic);
if (DOPRINT)
fprintf(fp, "\t%s\t%s\t%s\t%s\t%s\tReadonly=%s\tContinuous=%s\tAtomic=%s\t%s\n",
name,
mpit_varclassToStr(varClass),
mpit_bindingToStr(binding),
mpit_validDtypeStr(datatype),
mpit_verbosityToStr(verbosity),
isReadonly ? "T" : "F", isContinuous ? "T" : "F", isAtomic ? "T" : "F", desc);
if (datatype == MPI_INT) {
int val, isFound;
val = perfvarReadInt(i, isContinuous, &isFound);
if (isFound && DOPRINT)
fprintf(fp, "\tValue = %d\n", val);
} else if (datatype == MPI_UNSIGNED) {
int isFound;
unsigned int val;
val = perfvarReadUint(i, isContinuous, &isFound);
if (isFound && DOPRINT)
fprintf(fp, "\tValue = %u\n", val);
} else if (datatype == MPI_DOUBLE) {
int isFound;
double val;
val = perfvarReadDouble(i, isContinuous, &isFound);
if (isFound && DOPRINT)
fprintf(fp, "\tValue = %e\n", val);
}
}
return 0;
}
int PrintCategories(FILE * fp, int myThreadId)
{
int i, j, numCat, nameLen, descLen, numCvars, numPvars, numSubcat;
char name[128], desc[1024];
MPI_T_category_get_num(&numCat);
if (DOPRINT) {
if (numCat > 0)
fprintf(fp, "%d MPI_T categories\n", numCat);
else
fprintf(fp, "No categories defined\n");
}
for (i = 0; i < numCat; i++) {
nameLen = sizeof(name);
descLen = sizeof(desc);
MPI_T_category_get_info(i, name, &nameLen, desc, &descLen, &numCvars,
&numPvars, &numSubcat);
if (DOPRINT)
fprintf(fp,
"Category %s has %d control variables, %d performance variables, %d subcategories\n",
name, numCvars, numPvars, numSubcat);
if (numCvars > 0) {
if (DOPRINT)
fprintf(fp, "\tControl variables include: ");
int *cvarIndex = (int *) malloc(numCvars * sizeof(int));
MPI_T_category_get_cvars(i, numCvars, cvarIndex);
for (j = 0; j < numCvars; j++) {
/* Get just the variable name */
int varnameLen, verb, binding, scope;
MPI_Datatype datatype;
char varname[128];
varnameLen = sizeof(varname);
MPI_T_cvar_get_info(cvarIndex[j], varname, &varnameLen,
&verb, &datatype, NULL, NULL, NULL, &binding, &scope);
if (DOPRINT)
fprintf(fp, "%s, ", varname);
}
free(cvarIndex);
if (DOPRINT)
fprintf(fp, "\n");
}
if (numPvars > 0) {
if (DOPRINT)
fprintf(fp, "\tPerformance variables include: ");
int *pvarIndex = (int *) malloc(numPvars * sizeof(int));
MPI_T_category_get_pvars(i, numPvars, pvarIndex);
for (j = 0; j < numPvars; j++) {
int varnameLen, verb, varclass, binding;
int isReadonly, isContinuous, isAtomic;
MPI_Datatype datatype;
char varname[128];
varnameLen = sizeof(varname);
MPI_T_pvar_get_info(pvarIndex[j], varname, &varnameLen, &verb,
&varclass, &datatype, NULL, NULL, NULL, &binding,
&isReadonly, &isContinuous, &isAtomic);
if (DOPRINT)
fprintf(fp, "%s, ", varname);
}
free(pvarIndex);
if (DOPRINT)
fprintf(fp, "\n");
}
if (numSubcat > 0) {
if (DOPRINT)
fprintf(fp, "\tSubcategories include: ");
int *subcatIndex = (int *) malloc(numSubcat * sizeof(int));
MPI_T_category_get_categories(i, numSubcat, subcatIndex);
for (j = 0; j < numSubcat; j++) {
int catnameLen, ncvars, npvars, nsubcats;
char catname[128];
catnameLen = sizeof(catname);
MPI_T_category_get_info(subcatIndex[j], catname, &catnameLen, NULL, NULL,
&ncvars, &npvars, &nsubcats);
if (DOPRINT)
fprintf(fp, "%s, ", catname);
}
free(subcatIndex);
if (DOPRINT)
fprintf(fp, "\n");
}
}
return 0;
}
/* --- Support routines --- */
const char *mpit_validDtypeStr(MPI_Datatype datatype)
{
const char *p = 0;
if (datatype == MPI_INT)
p = "MPI_INT";
else if (datatype == MPI_UNSIGNED)
p = "MPI_UNSIGNED";
else if (datatype == MPI_UNSIGNED_LONG)
p = "MPI_UNSIGNED_LONG";
else if (datatype == MPI_UNSIGNED_LONG_LONG)
p = "MPI_UNSIGNED_LONG_LONG";
else if (datatype == MPI_COUNT)
p = "MPI_COUNT";
else if (datatype == MPI_CHAR)
p = "MPI_CHAR";
else if (datatype == MPI_DOUBLE)
p = "MPI_DOUBLE";
else {
if (datatype == MPI_DATATYPE_NULL) {
p = "Invalid MPI datatype:NULL";
} else {
static char typename[MPI_MAX_OBJECT_NAME + 9];
int tlen;
strncpy(typename, "Invalid:", MPI_MAX_OBJECT_NAME);
MPI_Type_get_name(datatype, typename + 8, &tlen);
if (typename[0])
p = typename;
}
}
return p;
}
const char *mpit_scopeToStr(int scope)
{
const char *p = 0;
switch (scope) {
case MPI_T_SCOPE_CONSTANT:
p = "SCOPE_CONSTANT";
break;
case MPI_T_SCOPE_READONLY:
p = "SCOPE_READONLY";
break;
case MPI_T_SCOPE_LOCAL:
p = "SCOPE_LOCAL";
break;
case MPI_T_SCOPE_GROUP:
p = "SCOPE_GROUP";
break;
case MPI_T_SCOPE_GROUP_EQ:
p = "SCOPE_GROUP_EQ";
break;
case MPI_T_SCOPE_ALL:
p = "SCOPE_ALL";
break;
case MPI_T_SCOPE_ALL_EQ:
p = "SCOPE_ALL_EQ";
break;
default:
p = "Unrecognized scope";
break;
}
return p;
}
const char *mpit_bindingToStr(int binding)
{
const char *p;
switch (binding) {
case MPI_T_BIND_NO_OBJECT:
p = "NO_OBJECT";
break;
case MPI_T_BIND_MPI_COMM:
p = "MPI_COMM";
break;
case MPI_T_BIND_MPI_DATATYPE:
p = "MPI_DATATYPE";
break;
case MPI_T_BIND_MPI_ERRHANDLER:
p = "MPI_ERRHANDLER";
break;
case MPI_T_BIND_MPI_FILE:
p = "MPI_FILE";
break;
case MPI_T_BIND_MPI_GROUP:
p = "MPI_GROUP";
break;
case MPI_T_BIND_MPI_OP:
p = "MPI_OP";
break;
case MPI_T_BIND_MPI_REQUEST:
p = "MPI_REQUEST";
break;
case MPI_T_BIND_MPI_WIN:
p = "MPI_WIN";
break;
case MPI_T_BIND_MPI_MESSAGE:
p = "MPI_MESSAGE";
break;
case MPI_T_BIND_MPI_INFO:
p = "MPI_INFO";
break;
default:
p = "Unknown object binding";
}
return p;
}
const char *mpit_varclassToStr(int varClass)
{
const char *p = 0;
switch (varClass) {
case MPI_T_PVAR_CLASS_STATE:
p = "CLASS_STATE";
break;
case MPI_T_PVAR_CLASS_LEVEL:
p = "CLASS_LEVEL";
break;
case MPI_T_PVAR_CLASS_SIZE:
p = "CLASS_SIZE";
break;
case MPI_T_PVAR_CLASS_PERCENTAGE:
p = "CLASS_PERCENTAGE";
break;
case MPI_T_PVAR_CLASS_HIGHWATERMARK:
p = "CLASS_HIGHWATERMARK";
break;
case MPI_T_PVAR_CLASS_LOWWATERMARK:
p = "CLASS_LOWWATERMARK";
break;
case MPI_T_PVAR_CLASS_COUNTER:
p = "CLASS_COUNTER";
break;
case MPI_T_PVAR_CLASS_AGGREGATE:
p = "CLASS_AGGREGATE";
break;
case MPI_T_PVAR_CLASS_TIMER:
p = "CLASS_TIMER";
break;
case MPI_T_PVAR_CLASS_GENERIC:
p = "CLASS_GENERIC";
break;
default:
p = "Unrecognized pvar class";
break;
}
return p;
}
const char *mpit_verbosityToStr(int verbosity)
{
const char *p = 0;
switch (verbosity) {
case MPI_T_VERBOSITY_USER_BASIC:
p = "VERBOSITY_USER_BASIC";
break;
case MPI_T_VERBOSITY_USER_DETAIL:
p = "VERBOSITY_USER_DETAIL";
break;
case MPI_T_VERBOSITY_USER_ALL:
p = "VERBOSITY_USER_ALL";
break;
case MPI_T_VERBOSITY_TUNER_BASIC:
p = "VERBOSITY_TUNER_BASIC";
break;
case MPI_T_VERBOSITY_TUNER_DETAIL:
p = "VERBOSITY_TUNER_DETAIL";
break;
case MPI_T_VERBOSITY_TUNER_ALL:
p = "VERBOSITY_TUNER_ALL";
break;
case MPI_T_VERBOSITY_MPIDEV_BASIC:
p = "VERBOSITY_MPIDEV_BASIC";
break;
case MPI_T_VERBOSITY_MPIDEV_DETAIL:
p = "VERBOSITY_MPIDEV_DETAIL";
break;
case MPI_T_VERBOSITY_MPIDEV_ALL:
p = "VERBOSITY_MPIDEV_ALL";
break;
default:
p = "Invalid verbosity";
break;
}
return p;
}
const char *mpit_errclassToStr(int err)
{
const char *p = 0;
switch (err) {
case MPI_T_ERR_MEMORY:
p = "ERR_MEMORY";
break;
case MPI_T_ERR_NOT_INITIALIZED:
p = "ERR_NOT_INITIALIZED";
break;
case MPI_T_ERR_CANNOT_INIT:
p = "ERR_CANNOT_INIT";
break;
case MPI_T_ERR_INVALID_INDEX:
p = "ERR_INVALID_INDEX";
break;
case MPI_T_ERR_INVALID_HANDLE:
p = "ERR_INVALID_HANDLE";
break;
case MPI_T_ERR_OUT_OF_HANDLES:
p = "ERR_OUT_OF_HANDLES";
break;
case MPI_T_ERR_OUT_OF_SESSIONS:
p = "ERR_OUT_OF_SESSIONS";
break;
case MPI_T_ERR_INVALID_SESSION:
p = "ERR_INVALID_SESSION";
break;
case MPI_T_ERR_CVAR_SET_NOT_NOW:
p = "ERR_CVAR_SET_NOT_NOW";
break;
case MPI_T_ERR_CVAR_SET_NEVER:
p = "ERR_CVAR_SET_NEVER";
break;
case MPI_T_ERR_PVAR_NO_STARTSTOP:
p = "ERR_PVAR_NO_STARTSTOP";
break;
case MPI_T_ERR_PVAR_NO_WRITE:
p = "ERR_PVAR_NO_WRITE";
break;
case MPI_T_ERR_PVAR_NO_ATOMIC:
p = "ERR_PVAR_NO_ATOMIC";
break;
default:
p = "Unknown MPI_T_ERR class";
break;
}
return p;
}
/* Return the value of the performance variable as the value */
int perfvarReadInt(int pvarIndex, int isContinuous, int *found)
{
int count, val = -1;
int err1 = MPI_SUCCESS;
int err2 = MPI_SUCCESS;
MPI_T_pvar_session session;
MPI_T_pvar_handle pvarHandle;
MPI_T_pvar_session_create(&session);
MPI_T_pvar_handle_alloc(session, pvarIndex, NULL, &pvarHandle, &count);
if (count == 1) {
*found = 1;
if (!isContinuous) {
/* start and stop the variable (just because we can) */
err1 = MPI_T_pvar_start(session, pvarHandle);
err2 = MPI_T_pvar_stop(session, pvarHandle);
}
MPI_T_pvar_read(session, pvarHandle, &val);
}
MPI_T_pvar_handle_free(session, &pvarHandle);
MPI_T_pvar_session_free(&session);
/* Above codes imply that err1 and err2 should be MPI_SUCCESS.
* If not, catch errors here, e.g., when MPI_ERR_INTERN is returned.
*/
if (err1 != MPI_SUCCESS || err2 != MPI_SUCCESS) {
fprintf(stderr, "Unexpected MPI_T_pvar_start/stop return code\n");
abort();
}
return val;
}
/* Return the value of the performance variable as the value */
unsigned int perfvarReadUint(int pvarIndex, int isContinuous, int *found)
{
int count;
unsigned int val = 0;
int err1 = MPI_SUCCESS;
int err2 = MPI_SUCCESS;
MPI_T_pvar_session session;
MPI_T_pvar_handle pvarHandle;
*found = 0;
MPI_T_pvar_session_create(&session);
MPI_T_pvar_handle_alloc(session, pvarIndex, NULL, &pvarHandle, &count);
if (count == 1) {
*found = 1;
if (!isContinuous) {
/* start and stop the variable (just because we can) */
err1 = MPI_T_pvar_start(session, pvarHandle);
err2 = MPI_T_pvar_stop(session, pvarHandle);
}
MPI_T_pvar_read(session, pvarHandle, &val);
}
MPI_T_pvar_handle_free(session, &pvarHandle);
MPI_T_pvar_session_free(&session);
/* Above codes imply that err1 and err2 should be MPI_SUCCESS.
* If not, catch errors here, e.g., when MPI_ERR_INTERN is returned.
*/
if (err1 != MPI_SUCCESS || err2 != MPI_SUCCESS) {
fprintf(stderr, "Unexpected MPI_T_pvar_start/stop return code\n");
abort();
}
return val;
}
double perfvarReadDouble(int pvarIndex, int isContinuous, int *found)
{
int count;
double val = 0.0;
int err1 = MPI_SUCCESS;
int err2 = MPI_SUCCESS;
MPI_T_pvar_session session;
MPI_T_pvar_handle pvarHandle;
*found = 0;
MPI_T_pvar_session_create(&session);
MPI_T_pvar_handle_alloc(session, pvarIndex, NULL, &pvarHandle, &count);
if (count == 1) {
*found = 1;
if (!isContinuous) {
/* start and stop the variable (just because we can) */
err1 = MPI_T_pvar_start(session, pvarHandle);
err2 = MPI_T_pvar_stop(session, pvarHandle);
}
MPI_T_pvar_read(session, pvarHandle, &val);
}
MPI_T_pvar_handle_free(session, &pvarHandle);
MPI_T_pvar_session_free(&session);
/* Catch errors if MPI_T_pvar_start/stop are not properly implemented */
if (err1 != MPI_SUCCESS || err2 != MPI_SUCCESS) {
fprintf(stderr, "Unknown MPI_T return code when starting/stopping double pvar\n");
abort();
}
return val;
}
|
c7c1c4bf4469314fab9a7e7eb97c07a9a3654ce6
|
0744dcc5394cebf57ebcba343747af6871b67017
|
/os/fs/driver/mtd/w25.c
|
394c038cbe1c970e6112c9f7bc6784f84eef52b6
|
[
"Apache-2.0",
"GPL-1.0-or-later",
"BSD-3-Clause",
"ISC",
"MIT",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-other-permissive"
] |
permissive
|
Samsung/TizenRT
|
96abf62f1853f61fcf91ff14671a5e0c6ca48fdb
|
1a5c2e00a4b1bbf4c505bbf5cc6a8259e926f686
|
refs/heads/master
| 2023-08-31T08:59:33.327998
| 2023-08-08T06:09:20
| 2023-08-31T04:38:20
| 82,517,252
| 590
| 719
|
Apache-2.0
| 2023-09-14T06:54:49
| 2017-02-20T04:38:30
|
C
|
UTF-8
|
C
| false
| false
| 44,240
|
c
|
w25.c
|
/****************************************************************************
*
* Copyright 2018 Samsung Electronics 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.
*
****************************************************************************/
/************************************************************************************
* drivers/mtd/w25.c
* Driver for SPI-based W25x16, x32, and x64 and W25q16, q32, q64, and q128 FLASH
*
* Copyright (C) 2012-2013, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 NuttX 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.
*
************************************************************************************/
/************************************************************************************
* Included Files
************************************************************************************/
#include <tinyara/config.h>
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <debug.h>
#include <tinyara/kmalloc.h>
#include <tinyara/fs/ioctl.h>
#include <tinyara/spi/spi.h>
#include <tinyara/fs/mtd.h>
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/* Configuration ********************************************************************/
/* Per the data sheet, the W25 parts can be driven with either SPI mode 0 (CPOL=0
* and CPHA=0) or mode 3 (CPOL=1 and CPHA=1). But I have heard that other devices
* can operate in mode 0 or 1. So you may need to specify CONFIG_W25_SPIMODE to
* select the best mode for your device. If CONFIG_W25_SPIMODE is not defined,
* mode 0 will be used.
*/
#ifndef CONFIG_W25_SPIMODE
#define CONFIG_W25_SPIMODE SPIDEV_MODE0
#endif
/* SPI Frequency. May be up to 25MHz. */
#ifndef CONFIG_W25_SPIFREQUENCY
#define CONFIG_W25_SPIFREQUENCY 20000000
#endif
/* W25 Instructions *****************************************************************/
/* Command Value Description */
/* */
#define W25_WREN 0x06 /* Write enable */
#define W25_WRDI 0x04 /* Write Disable */
#define W25_RDSR 0x05 /* Read status register */
#define W25_WRSR 0x01 /* Write Status Register */
#define W25_RDDATA 0x03 /* Read data bytes */
#define W25_FRD 0x0b /* Higher speed read */
#define W25_FRDD 0x3b /* Fast read, dual output */
#define W25_PP 0x02 /* Program page */
#define W25_BE 0xd8 /* Block Erase (64KB) */
#define W25_SE 0x20 /* Sector erase (4KB) */
#define W25_CE 0xc7 /* Chip erase */
#define W25_PD 0xb9 /* Power down */
#define W25_PURDID 0xab /* Release PD, Device ID */
#define W25_RDMFID 0x90 /* Read Manufacturer / Device */
#define W25_JEDEC_ID 0x9f /* JEDEC ID read */
/* W25 Registers ********************************************************************/
/* Read ID (RDID) register values */
#define W25_MANUFACTURER 0xef /* Winbond Serial Flash */
#define W25X16_DEVID 0x14 /* W25X16 device ID (0xab, 0x90) */
#define W25X32_DEVID 0x15 /* W25X16 device ID (0xab, 0x90) */
#define W25X64_DEVID 0x16 /* W25X16 device ID (0xab, 0x90) */
/* JEDEC Read ID register values */
#define W25_JEDEC_MANUFACTURER 0xef /* SST manufacturer ID */
#define W25X_JEDEC_MEMORY_TYPE 0x30 /* W25X memory type */
#define W25Q_JEDEC_MEMORY_TYPE_A 0x40 /* W25Q memory type */
#define W25Q_JEDEC_MEMORY_TYPE_B 0x60 /* W25Q memory type */
#define W25Q_JEDEC_MEMORY_TYPE_C 0x50 /* W25Q memory type */
#define W25_JEDEC_CAPACITY_8MBIT 0x14 /* 256x4096 = 8Mbit memory capacity */
#define W25_JEDEC_CAPACITY_16MBIT 0x15 /* 512x4096 = 16Mbit memory capacity */
#define W25_JEDEC_CAPACITY_32MBIT 0x16 /* 1024x4096 = 32Mbit memory capacity */
#define W25_JEDEC_CAPACITY_64MBIT 0x17 /* 2048x4096 = 64Mbit memory capacity */
#define W25_JEDEC_CAPACITY_128MBIT 0x18 /* 4096x4096 = 128Mbit memory capacity */
#define NSECTORS_8MBIT 256 /* 256 sectors x 4096 bytes/sector = 1Mb */
#define NSECTORS_16MBIT 512 /* 512 sectors x 4096 bytes/sector = 2Mb */
#define NSECTORS_32MBIT 1024 /* 1024 sectors x 4096 bytes/sector = 4Mb */
#define NSECTORS_64MBIT 2048 /* 2048 sectors x 4096 bytes/sector = 8Mb */
#define NSECTORS_128MBIT 4096 /* 4096 sectors x 4096 bytes/sector = 16Mb */
/* Status register bit definitions */
#define W25_SR_BUSY (1 << 0) /* Bit 0: Write in progress */
#define W25_SR_WEL (1 << 1) /* Bit 1: Write enable latch bit */
#define W25_SR_BP_SHIFT (2) /* Bits 2-5: Block protect bits */
#define W25_SR_BP_MASK (15 << W25_SR_BP_SHIFT)
#define W25X16_SR_BP_NONE (0 << W25_SR_BP_SHIFT) /* Unprotected */
#define W25X16_SR_BP_UPPER32nd (1 << W25_SR_BP_SHIFT) /* Upper 32nd */
#define W25X16_SR_BP_UPPER16th (2 << W25_SR_BP_SHIFT) /* Upper 16th */
#define W25X16_SR_BP_UPPER8th (3 << W25_SR_BP_SHIFT) /* Upper 8th */
#define W25X16_SR_BP_UPPERQTR (4 << W25_SR_BP_SHIFT) /* Upper quarter */
#define W25X16_SR_BP_UPPERHALF (5 << W25_SR_BP_SHIFT) /* Upper half */
#define W25X16_SR_BP_ALL (6 << W25_SR_BP_SHIFT) /* All sectors */
#define W25X16_SR_BP_LOWER32nd (9 << W25_SR_BP_SHIFT) /* Lower 32nd */
#define W25X16_SR_BP_LOWER16th (10 << W25_SR_BP_SHIFT) /* Lower 16th */
#define W25X16_SR_BP_LOWER8th (11 << W25_SR_BP_SHIFT) /* Lower 8th */
#define W25X16_SR_BP_LOWERQTR (12 << W25_SR_BP_SHIFT) /* Lower quarter */
#define W25X16_SR_BP_LOWERHALF (13 << W25_SR_BP_SHIFT) /* Lower half */
#define W25X32_SR_BP_NONE (0 << W25_SR_BP_SHIFT) /* Unprotected */
#define W25X32_SR_BP_UPPER64th (1 << W25_SR_BP_SHIFT) /* Upper 64th */
#define W25X32_SR_BP_UPPER32nd (2 << W25_SR_BP_SHIFT) /* Upper 32nd */
#define W25X32_SR_BP_UPPER16th (3 << W25_SR_BP_SHIFT) /* Upper 16th */
#define W25X32_SR_BP_UPPER8th (4 << W25_SR_BP_SHIFT) /* Upper 8th */
#define W25X32_SR_BP_UPPERQTR (5 << W25_SR_BP_SHIFT) /* Upper quarter */
#define W25X32_SR_BP_UPPERHALF (6 << W25_SR_BP_SHIFT) /* Upper half */
#define W25X32_SR_BP_ALL (7 << W25_SR_BP_SHIFT) /* All sectors */
#define W25X32_SR_BP_LOWER64th (9 << W25_SR_BP_SHIFT) /* Lower 64th */
#define W25X32_SR_BP_LOWER32nd (10 << W25_SR_BP_SHIFT) /* Lower 32nd */
#define W25X32_SR_BP_LOWER16th (11 << W25_SR_BP_SHIFT) /* Lower 16th */
#define W25X32_SR_BP_LOWER8th (12 << W25_SR_BP_SHIFT) /* Lower 8th */
#define W25X32_SR_BP_LOWERQTR (13 << W25_SR_BP_SHIFT) /* Lower quarter */
#define W25X32_SR_BP_LOWERHALF (14 << W25_SR_BP_SHIFT) /* Lower half */
#define W25X64_SR_BP_NONE (0 << W25_SR_BP_SHIFT) /* Unprotected */
#define W25X64_SR_BP_UPPER64th (1 << W25_SR_BP_SHIFT) /* Upper 64th */
#define W25X64_SR_BP_UPPER32nd (2 << W25_SR_BP_SHIFT) /* Upper 32nd */
#define W25X64_SR_BP_UPPER16th (3 << W25_SR_BP_SHIFT) /* Upper 16th */
#define W25X64_SR_BP_UPPER8th (4 << W25_SR_BP_SHIFT) /* Upper 8th */
#define W25X64_SR_BP_UPPERQTR (5 << W25_SR_BP_SHIFT) /* Upper quarter */
#define W25X64_SR_BP_UPPERHALF (6 << W25_SR_BP_SHIFT) /* Upper half */
#define W25X46_SR_BP_ALL (7 << W25_SR_BP_SHIFT) /* All sectors */
#define W25X64_SR_BP_LOWER64th (9 << W25_SR_BP_SHIFT) /* Lower 64th */
#define W25X64_SR_BP_LOWER32nd (10 << W25_SR_BP_SHIFT) /* Lower 32nd */
#define W25X64_SR_BP_LOWER16th (11 << W25_SR_BP_SHIFT) /* Lower 16th */
#define W25X64_SR_BP_LOWER8th (12 << W25_SR_BP_SHIFT) /* Lower 8th */
#define W25X64_SR_BP_LOWERQTR (13 << W25_SR_BP_SHIFT) /* Lower quarter */
#define W25X64_SR_BP_LOWERHALF (14 << W25_SR_BP_SHIFT) /* Lower half */
/* Bit 6: Reserved */
#define W25_SR_SRP (1 << 7) /* Bit 7: Status register write protect */
#define W25_DUMMY 0xa5
/* Chip Geometries ******************************************************************/
/* All members of the family support uniform 4K-byte sectors and 256 byte pages */
#define W25_SECTOR_SHIFT 12 /* Sector size 1 << 12 = 4Kb */
#define W25_SECTOR_SIZE (1 << 12) /* Sector size 1 << 12 = 4Kb */
#define W25_PAGE_SHIFT 8 /* Sector size 1 << 8 = 256b */
#define W25_PAGE_SIZE (1 << 8) /* Sector size 1 << 8 = 256b */
#ifdef CONFIG_W25_SECTOR512 /* Simulate a 512 byte sector */
#define W25_SECTOR512_SHIFT 9 /* Sector size 1 << 9 = 512 bytes */
#define W25_SECTOR512_SIZE (1 << 9) /* Sector size 1 << 9 = 512 bytes */
#endif
#define W25_ERASED_STATE 0xff /* State of FLASH when erased */
/* Cache flags */
#define W25_CACHE_VALID (1 << 0) /* 1=Cache has valid data */
#define W25_CACHE_DIRTY (1 << 1) /* 1=Cache is dirty */
#define W25_CACHE_ERASED (1 << 2) /* 1=Backing FLASH is erased */
#define IS_VALID(p) ((((p)->flags) & W25_CACHE_VALID) != 0)
#define IS_DIRTY(p) ((((p)->flags) & W25_CACHE_DIRTY) != 0)
#define IS_ERASED(p) ((((p)->flags) & W25_CACHE_ERASED) != 0)
#define SET_VALID(p) do { (p)->flags |= W25_CACHE_VALID; } while (0)
#define SET_DIRTY(p) do { (p)->flags |= W25_CACHE_DIRTY; } while (0)
#define SET_ERASED(p) do { (p)->flags |= W25_CACHE_ERASED; } while (0)
#define CLR_VALID(p) do { (p)->flags &= ~W25_CACHE_VALID; } while (0)
#define CLR_DIRTY(p) do { (p)->flags &= ~W25_CACHE_DIRTY; } while (0)
#define CLR_ERASED(p) do { (p)->flags &= ~W25_CACHE_ERASED; } while (0)
/************************************************************************************
* Private Types
************************************************************************************/
/* This type represents the state of the MTD device. The struct mtd_dev_s must
* appear at the beginning of the definition so that you can freely cast between
* pointers to struct mtd_dev_s and struct w25_dev_s.
*/
struct w25_dev_s {
struct mtd_dev_s mtd; /* MTD interface */
FAR struct spi_dev_s *spi; /* Saved SPI interface instance */
uint16_t nsectors; /* Number of erase sectors */
uint8_t prev_instr; /* Previous instruction given to W25 device */
#if defined(CONFIG_W25_SECTOR512) && !defined(CONFIG_W25_READONLY)
uint8_t flags; /* Buffered sector flags */
uint16_t esectno; /* Erase sector number in the cache */
FAR uint8_t *sector; /* Allocated sector data */
#endif
};
/************************************************************************************
* Private Function Prototypes
************************************************************************************/
/* Helpers */
static void w25_lock(FAR struct spi_dev_s *spi);
static inline void w25_unlock(FAR struct spi_dev_s *spi);
static inline int w25_readid(FAR struct w25_dev_s *priv);
#ifndef CONFIG_W25_READONLY
static void w25_unprotect(FAR struct w25_dev_s *priv);
#endif
static uint8_t w25_waitwritecomplete(FAR struct w25_dev_s *priv);
static inline void w25_wren(FAR struct w25_dev_s *priv);
static inline void w25_wrdi(FAR struct w25_dev_s *priv);
static bool w25_is_erased(struct w25_dev_s *priv, off_t address, off_t size);
static void w25_sectorerase(FAR struct w25_dev_s *priv, off_t offset);
static inline int w25_chiperase(FAR struct w25_dev_s *priv);
static void w25_byteread(FAR struct w25_dev_s *priv, FAR uint8_t *buffer, off_t address, size_t nbytes);
#ifndef CONFIG_W25_READONLY
static void w25_pagewrite(FAR struct w25_dev_s *priv, FAR const uint8_t *buffer, off_t address, size_t nbytes);
#endif
#ifdef CONFIG_W25_SECTOR512
static void w25_cacheflush(struct w25_dev_s *priv);
static FAR uint8_t *w25_cacheread(struct w25_dev_s *priv, off_t sector);
static void w25_cacheerase(struct w25_dev_s *priv, off_t sector);
static void w25_cachewrite(FAR struct w25_dev_s *priv, FAR const uint8_t *buffer, off_t sector, size_t nsectors);
#endif
/* MTD driver methods */
static int w25_erase(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks);
static ssize_t w25_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks, FAR uint8_t *buf);
static ssize_t w25_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks, FAR const uint8_t *buf);
static ssize_t w25_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes, FAR uint8_t *buffer);
static int w25_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg);
#if defined(CONFIG_MTD_BYTE_WRITE) && !defined(CONFIG_W25_READONLY)
static ssize_t w25_write(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes, FAR const uint8_t *buffer);
#endif
/************************************************************************************
* Private Data
************************************************************************************/
/************************************************************************************
* Private Functions
************************************************************************************/
/************************************************************************************
* Name: w25_lock
************************************************************************************/
static void w25_lock(FAR struct spi_dev_s *spi)
{
/* On SPI busses where there are multiple devices, it will be necessary to
* lock SPI to have exclusive access to the busses for a sequence of
* transfers. The bus should be locked before the chip is selected.
*
* This is a blocking call and will not return until we have exclusiv access to
* the SPI buss. We will retain that exclusive access until the bus is unlocked.
*/
(void)SPI_LOCK(spi, true);
/* After locking the SPI bus, the we also need call the setfrequency, setbits, and
* setmode methods to make sure that the SPI is properly configured for the device.
* If the SPI buss is being shared, then it may have been left in an incompatible
* state.
*/
SPI_SETMODE(spi, CONFIG_W25_SPIMODE);
SPI_SETBITS(spi, 8);
(void)SPI_SETFREQUENCY(spi, CONFIG_W25_SPIFREQUENCY);
}
/************************************************************************************
* Name: w25_unlock
************************************************************************************/
static inline void w25_unlock(FAR struct spi_dev_s *spi)
{
(void)SPI_LOCK(spi, false);
}
/************************************************************************************
* Name: w25_readid
************************************************************************************/
static inline int w25_readid(struct w25_dev_s *priv)
{
uint16_t manufacturer;
uint16_t memory;
uint16_t capacity;
fvdbg("priv: %p\n", priv);
/* Lock and configure the SPI bus */
w25_lock(priv->spi);
/* Wait for any preceding write or erase operation to complete. */
(void)w25_waitwritecomplete(priv);
/* Select this FLASH part. */
SPI_SELECT(priv->spi, SPIDEV_FLASH, true);
/* Send the "Read ID (RDID)" command and read the first three ID bytes */
(void)SPI_SEND(priv->spi, W25_JEDEC_ID);
manufacturer = SPI_SEND(priv->spi, W25_DUMMY);
memory = SPI_SEND(priv->spi, W25_DUMMY);
capacity = SPI_SEND(priv->spi, W25_DUMMY);
/* Deselect the FLASH and unlock the bus */
SPI_SELECT(priv->spi, SPIDEV_FLASH, false);
w25_unlock(priv->spi);
fvdbg("manufacturer: %02x memory: %02x capacity: %02x\n", manufacturer, memory, capacity);
/* Check for a valid manufacturer and memory type */
if (manufacturer == W25_JEDEC_MANUFACTURER && (memory == W25X_JEDEC_MEMORY_TYPE || memory == W25Q_JEDEC_MEMORY_TYPE_A || memory == W25Q_JEDEC_MEMORY_TYPE_B || memory == W25Q_JEDEC_MEMORY_TYPE_C)) {
/* Okay.. is it a FLASH capacity that we understand? If so, save
* the FLASH capacity.
*/
/* 8M-bit / 1M-byte
*
* W25Q80BV
*/
if (capacity == W25_JEDEC_CAPACITY_8MBIT) {
priv->nsectors = NSECTORS_8MBIT;
}
/* 16M-bit / 2M-byte (2,097,152)
*
* W24X16, W25Q16BV, W25Q16CL, W25Q16CV, W25Q16DW
*/
else if (capacity == W25_JEDEC_CAPACITY_16MBIT) {
priv->nsectors = NSECTORS_16MBIT;
}
/* 32M-bit / M-byte (4,194,304)
*
* W25X32, W25Q32BV, W25Q32DW
*/
else if (capacity == W25_JEDEC_CAPACITY_32MBIT) {
priv->nsectors = NSECTORS_32MBIT;
}
/* 64M-bit / 8M-byte (8,388,608)
*
* W25X64, W25Q64BV, W25Q64CV, W25Q64DW
*/
else if (capacity == W25_JEDEC_CAPACITY_64MBIT) {
priv->nsectors = NSECTORS_64MBIT;
}
/* 128M-bit / 16M-byte (16,777,216)
*
* W25Q128BV
*/
else if (capacity == W25_JEDEC_CAPACITY_128MBIT) {
priv->nsectors = NSECTORS_128MBIT;
} else {
/* Nope.. we don't understand this capacity. */
return -ENODEV;
}
return OK;
}
/* We don't understand the manufacturer or the memory type */
return -ENODEV;
}
/************************************************************************************
* Name: w25_unprotect
************************************************************************************/
#ifndef CONFIG_W25_READONLY
static void w25_unprotect(FAR struct w25_dev_s *priv)
{
/* Lock and configure the SPI bus */
w25_lock(priv->spi);
/* Wait for any preceding write or erase operation to complete. */
(void)w25_waitwritecomplete(priv);
/* Send "Write enable (WREN)" */
w25_wren(priv);
/* Select this FLASH part */
SPI_SELECT(priv->spi, SPIDEV_FLASH, true);
/* Send "Write enable status (EWSR)" */
SPI_SEND(priv->spi, W25_WRSR);
/* Following by the new status value */
SPI_SEND(priv->spi, 0);
SPI_SEND(priv->spi, 0);
/* Deselect the FLASH and unlock the bus */
SPI_SELECT(priv->spi, SPIDEV_FLASH, false);
w25_unlock(priv->spi);
}
#endif
/************************************************************************************
* Name: w25_waitwritecomplete
************************************************************************************/
static uint8_t w25_waitwritecomplete(struct w25_dev_s *priv)
{
uint8_t status;
/* Loop as long as the memory is busy with a write cycle. Device sets BUSY
* flag to a 1 state whhen previous write or erase command is still executing
* and during this time, device will ignore further instructions except for
* "Read Status Register" and "Erase/Program Suspend" instructions.
*/
do {
/* Select this FLASH part */
SPI_SELECT(priv->spi, SPIDEV_FLASH, true);
/* Send "Read Status Register (RDSR)" command */
(void)SPI_SEND(priv->spi, W25_RDSR);
/* Send a dummy byte to generate the clock needed to shift out the status */
status = SPI_SEND(priv->spi, W25_DUMMY);
/* Deselect the FLASH */
SPI_SELECT(priv->spi, SPIDEV_FLASH, false);
/* Given that writing could take up to few tens of milliseconds, and erasing
* could take more. The following short delay in the "busy" case will allow
* other peripherals to access the SPI bus. Delay would slow down writing
* too much, so go to sleep only if previous operation was not a page program
* operation.
*/
if (priv->prev_instr != W25_PP && (status & W25_SR_BUSY) != 0) {
w25_unlock(priv->spi);
usleep(1000);
w25_lock(priv->spi);
}
} while ((status & W25_SR_BUSY) != 0);
return status;
}
/************************************************************************************
* Name: w25_wren
************************************************************************************/
static inline void w25_wren(struct w25_dev_s *priv)
{
/* Select this FLASH part */
SPI_SELECT(priv->spi, SPIDEV_FLASH, true);
/* Send "Write Enable (WREN)" command */
(void)SPI_SEND(priv->spi, W25_WREN);
/* Deselect the FLASH */
SPI_SELECT(priv->spi, SPIDEV_FLASH, false);
}
/************************************************************************************
* Name: w25_wrdi
************************************************************************************/
static inline void w25_wrdi(struct w25_dev_s *priv)
{
/* Select this FLASH part */
SPI_SELECT(priv->spi, SPIDEV_FLASH, true);
/* Send "Write Disable (WRDI)" command */
(void)SPI_SEND(priv->spi, W25_WRDI);
/* Deselect the FLASH */
SPI_SELECT(priv->spi, SPIDEV_FLASH, false);
}
/************************************************************************************
* Name: w25_is_erased
************************************************************************************/
static bool w25_is_erased(struct w25_dev_s *priv, off_t address, off_t size)
{
size_t npages = size >> W25_PAGE_SHIFT;
uint32_t erased_32;
unsigned int i;
uint32_t *buf;
DEBUGASSERT((address % W25_PAGE_SIZE) == 0);
DEBUGASSERT((size % W25_PAGE_SIZE) == 0);
buf = kmm_malloc(W25_PAGE_SIZE);
if (!buf) {
return false;
}
memset(&erased_32, W25_ERASED_STATE, sizeof(erased_32));
/* Walk all pages in given area. */
while (npages) {
/* Check if all bytes of page is in erased state. */
w25_byteread(priv, (unsigned char *)buf, address, W25_PAGE_SIZE);
for (i = 0; i < W25_PAGE_SIZE / sizeof(uint32_t); i++) {
if (buf[i] != erased_32) {
/* Page not in erased state! */
kmm_free(buf);
return false;
}
}
address += W25_PAGE_SIZE;
npages--;
}
kmm_free(buf);
return true;
}
/************************************************************************************
* Name: w25_sectorerase
************************************************************************************/
static void w25_sectorerase(struct w25_dev_s *priv, off_t sector)
{
off_t address = sector << W25_SECTOR_SHIFT;
fvdbg("sector: %08lx\n", (long)sector);
/* Check if sector is already erased. */
if (w25_is_erased(priv, address, W25_SECTOR_SIZE)) {
/* Sector already in erased state, so skip erase. */
return;
}
/* Wait for any preceding write or erase operation to complete. */
(void)w25_waitwritecomplete(priv);
/* Send write enable instruction */
w25_wren(priv);
/* Select this FLASH part */
SPI_SELECT(priv->spi, SPIDEV_FLASH, true);
/* Send the "Sector Erase (SE)" instruction */
(void)SPI_SEND(priv->spi, W25_SE);
priv->prev_instr = W25_SE;
/* Send the sector address high byte first. Only the most significant bits (those
* corresponding to the sector) have any meaning.
*/
(void)SPI_SEND(priv->spi, (address >> 16) & 0xff);
(void)SPI_SEND(priv->spi, (address >> 8) & 0xff);
(void)SPI_SEND(priv->spi, address & 0xff);
/* Deselect the FLASH */
SPI_SELECT(priv->spi, SPIDEV_FLASH, false);
}
/************************************************************************************
* Name: w25_chiperase
************************************************************************************/
static inline int w25_chiperase(struct w25_dev_s *priv)
{
fvdbg("priv: %p\n", priv);
/* Wait for any preceding write or erase operation to complete. */
(void)w25_waitwritecomplete(priv);
/* Send write enable instruction */
w25_wren(priv);
/* Select this FLASH part */
SPI_SELECT(priv->spi, SPIDEV_FLASH, true);
/* Send the "Chip Erase (CE)" instruction */
(void)SPI_SEND(priv->spi, W25_CE);
priv->prev_instr = W25_CE;
/* Deselect the FLASH */
SPI_SELECT(priv->spi, SPIDEV_FLASH, false);
fvdbg("Return: OK\n");
return OK;
}
/************************************************************************************
* Name: w25_byteread
************************************************************************************/
static void w25_byteread(FAR struct w25_dev_s *priv, FAR uint8_t *buffer, off_t address, size_t nbytes)
{
fvdbg("address: %08lx nbytes: %d\n", (long)address, (int)nbytes);
/* Wait for any preceding write or erase operation to complete. */
(void)w25_waitwritecomplete(priv);
/* Make sure that writing is disabled */
w25_wrdi(priv);
/* Select this FLASH part */
SPI_SELECT(priv->spi, SPIDEV_FLASH, true);
/* Send "Read from Memory " instruction */
#ifdef CONFIG_W25_SLOWREAD
(void)SPI_SEND(priv->spi, W25_RDDATA);
priv->prev_instr = W25_RDDATA;
#else
(void)SPI_SEND(priv->spi, W25_FRD);
priv->prev_instr = W25_FRD;
#endif
/* Send the address high byte first. */
(void)SPI_SEND(priv->spi, (address >> 16) & 0xff);
(void)SPI_SEND(priv->spi, (address >> 8) & 0xff);
(void)SPI_SEND(priv->spi, address & 0xff);
/* Send a dummy byte */
#ifndef CONFIG_W25_SLOWREAD
(void)SPI_SEND(priv->spi, W25_DUMMY);
#endif
/* Then read all of the requested bytes */
SPI_RECVBLOCK(priv->spi, buffer, nbytes);
/* Deselect the FLASH */
SPI_SELECT(priv->spi, SPIDEV_FLASH, false);
}
/************************************************************************************
* Name: w25_pagewrite
************************************************************************************/
#ifndef CONFIG_W25_READONLY
static void w25_pagewrite(struct w25_dev_s *priv, FAR const uint8_t *buffer, off_t address, size_t nbytes)
{
fvdbg("address: %08lx nwords: %d\n", (long)address, (int)nbytes);
DEBUGASSERT(priv && buffer && (address & 0xff) == 0 && (nbytes & 0xff) == 0);
for (; nbytes > 0; nbytes -= W25_PAGE_SIZE) {
/* Wait for any preceding write or erase operation to complete. */
(void)w25_waitwritecomplete(priv);
/* Enable write access to the FLASH */
w25_wren(priv);
/* Select this FLASH part */
SPI_SELECT(priv->spi, SPIDEV_FLASH, true);
/* Send the "Page Program (W25_PP)" Command */
SPI_SEND(priv->spi, W25_PP);
priv->prev_instr = W25_PP;
/* Send the address high byte first. */
(void)SPI_SEND(priv->spi, (address >> 16) & 0xff);
(void)SPI_SEND(priv->spi, (address >> 8) & 0xff);
(void)SPI_SEND(priv->spi, address & 0xff);
/* Then send the page of data */
SPI_SNDBLOCK(priv->spi, buffer, W25_PAGE_SIZE);
/* Deselect the FLASH and setup for the next pass through the loop */
SPI_SELECT(priv->spi, SPIDEV_FLASH, false);
/* Update addresses */
address += W25_PAGE_SIZE;
buffer += W25_PAGE_SIZE;
}
/* Disable writing */
w25_wrdi(priv);
}
#endif
/************************************************************************************
* Name: w25_bytewrite
************************************************************************************/
#if defined(CONFIG_MTD_BYTE_WRITE) && !defined(CONFIG_W25_READONLY)
static inline void w25_bytewrite(struct w25_dev_s *priv, FAR const uint8_t *buffer, off_t offset, uint16_t count)
{
fvdbg("offset: %08lx count:%d\n", (long)offset, count);
/* Wait for any preceding write to complete. We could simplify things by
* perform this wait at the end of each write operation (rather than at
* the beginning of ALL operations), but have the wait first will slightly
* improve performance.
*/
w25_waitwritecomplete(priv);
/* Enable the write access to the FLASH */
w25_wren(priv);
/* Select this FLASH part */
SPI_SELECT(priv->spi, SPIDEV_FLASH, true);
/* Send "Page Program (PP)" command */
(void)SPI_SEND(priv->spi, W25_PP);
priv->prev_instr = W25_PP;
/* Send the page offset high byte first. */
(void)SPI_SEND(priv->spi, (offset >> 16) & 0xff);
(void)SPI_SEND(priv->spi, (offset >> 8) & 0xff);
(void)SPI_SEND(priv->spi, offset & 0xff);
/* Then write the specified number of bytes */
SPI_SNDBLOCK(priv->spi, buffer, count);
/* Deselect the FLASH: Chip Select high */
SPI_SELECT(priv->spi, SPIDEV_FLASH, false);
fvdbg("Written\n");
}
#endif /* defined(CONFIG_MTD_BYTE_WRITE) && !defined(CONFIG_W25_READONLY) */
/************************************************************************************
* Name: w25_cacheflush
************************************************************************************/
#if defined(CONFIG_W25_SECTOR512) && !defined(CONFIG_W25_READONLY)
static void w25_cacheflush(struct w25_dev_s *priv)
{
/* If the cached is dirty (meaning that it no longer matches the old FLASH contents)
* or was erased (with the cache containing the correct FLASH contents), then write
* the cached erase block to FLASH.
*/
if (IS_DIRTY(priv) || IS_ERASED(priv)) {
/* Write entire erase block to FLASH */
w25_pagewrite(priv, priv->sector, (off_t) priv->esectno << W25_SECTOR_SHIFT, W25_SECTOR_SIZE);
/* The case is no long dirty and the FLASH is no longer erased */
CLR_DIRTY(priv);
CLR_ERASED(priv);
}
}
#endif
/************************************************************************************
* Name: w25_cacheread
************************************************************************************/
#if defined(CONFIG_W25_SECTOR512) && !defined(CONFIG_W25_READONLY)
static FAR uint8_t *w25_cacheread(struct w25_dev_s *priv, off_t sector)
{
off_t esectno;
int shift;
int index;
/* Convert from the 512 byte sector to the erase sector size of the device. For
* exmample, if the actual erase sector size if 4Kb (1 << 12), then we first
* shift to the right by 3 to get the sector number in 4096 increments.
*/
shift = W25_SECTOR_SHIFT - W25_SECTOR512_SHIFT;
esectno = sector >> shift;
fvdbg("sector: %ld esectno: %d shift=%d\n", sector, esectno, shift);
/* Check if the requested erase block is already in the cache */
if (!IS_VALID(priv) || esectno != priv->esectno) {
/* No.. Flush any dirty erase block currently in the cache */
w25_cacheflush(priv);
/* Read the erase block into the cache */
w25_byteread(priv, priv->sector, (esectno << W25_SECTOR_SHIFT), W25_SECTOR_SIZE);
/* Mark the sector as cached */
priv->esectno = esectno;
SET_VALID(priv); /* The data in the cache is valid */
CLR_DIRTY(priv); /* It should match the FLASH contents */
CLR_ERASED(priv); /* The underlying FLASH has not been erased */
}
/* Get the index to the 512 sector in the erase block that holds the argument */
index = sector & ((1 << shift) - 1);
/* Return the address in the cache that holds this sector */
return &priv->sector[index << W25_SECTOR512_SHIFT];
}
#endif
/************************************************************************************
* Name: w25_cacheerase
************************************************************************************/
#if defined(CONFIG_W25_SECTOR512) && !defined(CONFIG_W25_READONLY)
static void w25_cacheerase(struct w25_dev_s *priv, off_t sector)
{
FAR uint8_t *dest;
/* First, make sure that the erase block containing the 512 byte sector is in
* the cache.
*/
dest = w25_cacheread(priv, sector);
/* Erase the block containing this sector if it is not already erased.
* The erased indicated will be cleared when the data from the erase sector
* is read into the cache and set here when we erase the block.
*/
if (!IS_ERASED(priv)) {
off_t esectno = sector >> (W25_SECTOR_SHIFT - W25_SECTOR512_SHIFT);
fvdbg("sector: %ld esectno: %d\n", sector, esectno);
w25_sectorerase(priv, esectno);
SET_ERASED(priv);
}
/* Put the cached sector data into the erase state and mart the cache as dirty
* (but don't update the FLASH yet. The caller will do that at a more optimal
* time).
*/
memset(dest, W25_ERASED_STATE, W25_SECTOR512_SIZE);
SET_DIRTY(priv);
}
#endif
/************************************************************************************
* Name: w25_cachewrite
************************************************************************************/
#if defined(CONFIG_W25_SECTOR512) && !defined(CONFIG_W25_READONLY)
static void w25_cachewrite(FAR struct w25_dev_s *priv, FAR const uint8_t *buffer, off_t sector, size_t nsectors)
{
FAR uint8_t *dest;
for (; nsectors > 0; nsectors--) {
/* First, make sure that the erase block containing 512 byte sector is in
* memory.
*/
dest = w25_cacheread(priv, sector);
/* Erase the block containing this sector if it is not already erased.
* The erased indicated will be cleared when the data from the erase sector
* is read into the cache and set here when we erase the sector.
*/
if (!IS_ERASED(priv)) {
off_t esectno = sector >> (W25_SECTOR_SHIFT - W25_SECTOR512_SHIFT);
fvdbg("sector: %ld esectno: %d\n", sector, esectno);
w25_sectorerase(priv, esectno);
SET_ERASED(priv);
}
/* Copy the new sector data into cached erase block */
memcpy(dest, buffer, W25_SECTOR512_SIZE);
SET_DIRTY(priv);
/* Set up for the next 512 byte sector */
buffer += W25_SECTOR512_SIZE;
sector++;
}
/* Flush the last erase block left in the cache */
w25_cacheflush(priv);
}
#endif
/************************************************************************************
* Name: w25_erase
************************************************************************************/
static int w25_erase(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks)
{
#ifdef CONFIG_W25_READONLY
return -EACESS
#else
FAR struct w25_dev_s * priv = (FAR struct w25_dev_s *)dev;
size_t blocksleft = nblocks;
fvdbg("startblock: %08lx nblocks: %d\n", (long)startblock, (int)nblocks);
/* Lock access to the SPI bus until we complete the erase */
w25_lock(priv->spi);
while (blocksleft-- > 0) {
/* Erase each sector */
#ifdef CONFIG_W25_SECTOR512
w25_cacheerase(priv, startblock);
#else
w25_sectorerase(priv, startblock);
#endif
startblock++;
}
#ifdef CONFIG_W25_SECTOR512
/* Flush the last erase block left in the cache */
w25_cacheflush(priv);
#endif
w25_unlock(priv->spi);
return (int)nblocks;
#endif
}
/************************************************************************************
* Name: w25_bread
************************************************************************************/
static ssize_t w25_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks, FAR uint8_t *buffer)
{
ssize_t nbytes;
fvdbg("startblock: %08lx nblocks: %d\n", (long)startblock, (int)nblocks);
/* On this device, we can handle the block read just like the byte-oriented read */
#ifdef CONFIG_W25_SECTOR512
nbytes = w25_read(dev, startblock << W25_SECTOR512_SHIFT, nblocks << W25_SECTOR512_SHIFT, buffer);
if (nbytes > 0) {
nbytes >>= W25_SECTOR512_SHIFT;
}
#else
nbytes = w25_read(dev, startblock << W25_PAGE_SHIFT, nblocks << W25_PAGE_SHIFT, buffer);
if (nbytes > 0) {
nbytes >>= W25_PAGE_SHIFT;
}
#endif
return nbytes;
}
/************************************************************************************
* Name: w25_bwrite
************************************************************************************/
static ssize_t w25_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks, FAR const uint8_t *buffer)
{
#ifdef CONFIG_W25_READONLY
return -EACCESS;
#else
FAR struct w25_dev_s *priv = (FAR struct w25_dev_s *)dev;
fvdbg("startblock: %08lx nblocks: %d\n", (long)startblock, (int)nblocks);
/* Lock the SPI bus and write all of the pages to FLASH */
w25_lock(priv->spi);
#if defined(CONFIG_W25_SECTOR512)
w25_cachewrite(priv, buffer, startblock, nblocks);
#else
w25_pagewrite(priv, buffer, startblock << W25_PAGE_SHIFT, nblocks << W25_PAGE_SHIFT);
#endif
w25_unlock(priv->spi);
return nblocks;
#endif
}
/************************************************************************************
* Name: w25_read
************************************************************************************/
static ssize_t w25_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes, FAR uint8_t *buffer)
{
FAR struct w25_dev_s *priv = (FAR struct w25_dev_s *)dev;
fvdbg("offset: %08lx nbytes: %d\n", (long)offset, (int)nbytes);
/* Lock the SPI bus and select this FLASH part */
w25_lock(priv->spi);
w25_byteread(priv, buffer, offset, nbytes);
w25_unlock(priv->spi);
fvdbg("return nbytes: %d\n", (int)nbytes);
return nbytes;
}
/************************************************************************************
* Name: w25_write
************************************************************************************/
#if defined(CONFIG_MTD_BYTE_WRITE) && !defined(CONFIG_W25_READONLY)
static ssize_t w25_write(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes, FAR const uint8_t *buffer)
{
FAR struct w25_dev_s *priv = (FAR struct w25_dev_s *)dev;
int startpage;
int endpage;
int count;
int index;
int bytestowrite;
fvdbg("offset: %08lx nbytes: %d\n", (long)offset, (int)nbytes);
/* We must test if the offset + count crosses one or more pages
* and perform individual writes. The devices can only write in
* page increments.
*/
startpage = offset / W25_PAGE_SIZE;
endpage = (offset + nbytes) / W25_PAGE_SIZE;
w25_lock(priv->spi);
if (startpage == endpage) {
/* All bytes within one programmable page. Just do the write. */
w25_bytewrite(priv, buffer, offset, nbytes);
} else {
/* Write the 1st partial-page */
count = nbytes;
bytestowrite = W25_PAGE_SIZE - (offset & (W25_PAGE_SIZE - 1));
w25_bytewrite(priv, buffer, offset, bytestowrite);
/* Update offset and count */
offset += bytestowrite;
count -= bytestowrite;
index = bytestowrite;
/* Write full pages */
while (count >= W25_PAGE_SIZE) {
w25_bytewrite(priv, &buffer[index], offset, W25_PAGE_SIZE);
/* Update offset and count */
offset += W25_PAGE_SIZE;
count -= W25_PAGE_SIZE;
index += W25_PAGE_SIZE;
}
/* Now write any partial page at the end */
if (count > 0) {
w25_bytewrite(priv, &buffer[index], offset, count);
}
}
w25_unlock(priv->spi);
return nbytes;
}
#endif /* defined(CONFIG_MTD_BYTE_WRITE) && !defined(CONFIG_W25_READONLY) */
/************************************************************************************
* Name: w25_ioctl
************************************************************************************/
static int w25_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
{
FAR struct w25_dev_s *priv = (FAR struct w25_dev_s *)dev;
int ret = -EINVAL; /* Assume good command with bad parameters */
fvdbg("cmd: %d \n", cmd);
switch (cmd) {
case MTDIOC_GEOMETRY: {
FAR struct mtd_geometry_s *geo = (FAR struct mtd_geometry_s *)((uintptr_t) arg);
if (geo) {
/* Populate the geometry structure with information need to know
* the capacity and how to access the device.
*
* NOTE: that the device is treated as though it where just an array
* of fixed size blocks. That is most likely not true, but the client
* will expect the device logic to do whatever is necessary to make it
* appear so.
*/
#ifdef CONFIG_W25_SECTOR512
geo->blocksize = (1 << W25_SECTOR512_SHIFT);
geo->erasesize = (1 << W25_SECTOR512_SHIFT);
geo->neraseblocks = priv->nsectors << (W25_SECTOR_SHIFT - W25_SECTOR512_SHIFT);
#else
geo->blocksize = W25_PAGE_SIZE;
geo->erasesize = W25_SECTOR_SIZE;
geo->neraseblocks = priv->nsectors;
#endif
ret = OK;
fvdbg("blocksize: %d erasesize: %d neraseblocks: %d\n", geo->blocksize, geo->erasesize, geo->neraseblocks);
}
}
break;
case MTDIOC_BULKERASE: {
/* Erase the entire device */
w25_lock(priv->spi);
ret = w25_chiperase(priv);
w25_unlock(priv->spi);
}
break;
case MTDIOC_XIPBASE:
default:
ret = -ENOTTY; /* Bad command */
break;
}
fvdbg("return %d\n", ret);
return ret;
}
/************************************************************************************
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: w25_initialize
*
* Description:
* Create an initialize MTD device instance. MTD devices are not registered
* in the file system, but are created as instances that can be bound to
* other functions (such as a block or character driver front end).
*
************************************************************************************/
FAR struct mtd_dev_s *w25_initialize(FAR struct spi_dev_s *spi)
{
FAR struct w25_dev_s *priv;
int ret;
fvdbg("spi: %p\n", spi);
/* Allocate a state structure (we allocate the structure instead of using
* a fixed, static allocation so that we can handle multiple FLASH devices.
* The current implementation would handle only one FLASH part per SPI
* device (only because of the SPIDEV_FLASH definition) and so would have
* to be extended to handle multiple FLASH parts on the same SPI bus.
*/
priv = (FAR struct w25_dev_s *)kmm_zalloc(sizeof(struct w25_dev_s));
if (priv) {
/* Initialize the allocated structure (unsupported methods were
* nullified by kmm_zalloc).
*/
priv->mtd.erase = w25_erase;
priv->mtd.bread = w25_bread;
priv->mtd.bwrite = w25_bwrite;
priv->mtd.read = w25_read;
priv->mtd.ioctl = w25_ioctl;
#if defined(CONFIG_MTD_BYTE_WRITE) && !defined(CONFIG_W25_READONLY)
priv->mtd.write = w25_write;
#endif
priv->spi = spi;
/* Deselect the FLASH */
SPI_SELECT(spi, SPIDEV_FLASH, false);
/* Identify the FLASH chip and get its capacity */
ret = w25_readid(priv);
if (ret != OK) {
/* Unrecognized! Discard all of that work we just did and return NULL */
fdbg("ERROR: Unrecognized\n");
kmm_free(priv);
return NULL;
} else {
/* Make sure that the FLASH is unprotected so that we can write into it */
#ifndef CONFIG_W25_READONLY
w25_unprotect(priv);
#endif
#ifdef CONFIG_W25_SECTOR512 /* Simulate a 512 byte sector */
/* Allocate a buffer for the erase block cache */
priv->sector = (FAR uint8_t *)kmm_malloc(W25_SECTOR_SIZE);
if (!priv->sector) {
/* Allocation failed! Discard all of that work we just did and return NULL */
fdbg("ERROR: Allocation failed\n");
kmm_free(priv);
return NULL;
}
#endif
}
}
/* Return the implementation-specific state structure as the MTD device */
fvdbg("Return %p\n", priv);
return (FAR struct mtd_dev_s *)priv;
}
|
513b5a19f2f0b580cf670eca60e57e793cac539f
|
0744dcc5394cebf57ebcba343747af6871b67017
|
/os/board/rtl8730e/src/component/soc/amebad2/atf/include/drivers/arm/cryptocell/713/bsv_crypto_asym_api.h
|
406e1effbbd40342971076db298dcc2e71a9dc0d
|
[
"Apache-2.0",
"GPL-1.0-or-later",
"BSD-3-Clause",
"ISC",
"MIT",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-other-permissive"
] |
permissive
|
Samsung/TizenRT
|
96abf62f1853f61fcf91ff14671a5e0c6ca48fdb
|
1a5c2e00a4b1bbf4c505bbf5cc6a8259e926f686
|
refs/heads/master
| 2023-08-31T08:59:33.327998
| 2023-08-08T06:09:20
| 2023-08-31T04:38:20
| 82,517,252
| 590
| 719
|
Apache-2.0
| 2023-09-14T06:54:49
| 2017-02-20T04:38:30
|
C
|
UTF-8
|
C
| false
| false
| 4,189
|
h
|
bsv_crypto_asym_api.h
|
/*
* Copyright (c) 2017-2020 ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef _BSV_CRYPTO_ASYM_API_H
#define _BSV_CRYPTO_ASYM_API_H
#ifdef __cplusplus
extern "C"
{
#endif
/*!
@file
@brief This file contains the cryptographic Asymmetric ROM APIs of the Boot Services.
@defgroup cc_bsv_crypto_asym_api CryptoCell Boot Services cryptographic Asymmetric ROM APIs
@{
@ingroup cc_bsv
*/
#include "cc_pal_types.h"
#include "cc_pka_hw_plat_defs.h"
#include "cc_sec_defs.h"
#include "bsv_crypto_api.h"
/*! Defines the workspace size in bytes needed for internal Asymmetric operations. */
#define BSV_RSA_WORKSPACE_MIN_SIZE (4*BSV_CERT_RSA_KEY_SIZE_IN_BYTES +\
2*RSA_PKA_BARRETT_MOD_TAG_BUFF_SIZE_IN_BYTES)
/*! Definition for the RSA public modulus array. */
typedef uint32_t CCBsvNBuff_t[BSV_CERT_RSA_KEY_SIZE_IN_WORDS];
/*! Definition for the RSA Barrett mod tag array. */
typedef uint32_t CCBsvNpBuff_t[RSA_PKA_BARRETT_MOD_TAG_BUFF_SIZE_IN_BYTES];
/*! Definition for the RSA signature array. */
typedef uint32_t CCBsvSignature_t[BSV_CERT_RSA_KEY_SIZE_IN_WORDS];
/*----------------------------
PUBLIC FUNCTIONS
-----------------------------------*/
/*!
@brief This function performs the primitive operation of RSA, meaning exponent and modulus.
outBuff = (pInBuff ^ Exp) mod NBuff. ( Exp = 0x10001 )
The function supports 2k and 3K bit size of modulus, based on compile time define.
There are no restriction on pInBuff location, however its size must be equal to BSV_RSA_KEY_SIZE_IN_BYTES and its
value must be smaller than the modulus.
@return \c CC_OK on success.
@return A non-zero value from bsv_error.h on failure.
*/
CCError_t CC_BsvRsaPrimVerify (unsigned long hwBaseAddress, /*!< [in] The base address of the CryptoCell HW registers. */
CCBsvNBuff_t NBuff, /*!< [in] The modulus buffer big endian format. */
CCBsvNpBuff_t NpBuff, /*!< [in] The barret tag buffer big endian format - optional. */
uint32_t *pInBuff, /*!< [in] The DataIn buffer to be encrypted. */
size_t inBuffSize, /*!< [in] The DataIn buffer size in bytes, must be BSV_RSA_KEY_SIZE_IN_BYTES. */
CCBsvSignature_t pOutBuff, /*!< [out] The encrypted buffer in big endian format. */
uint32_t *pWorkSpace, /*!< [in] The pointer to user allocated buffer for internal use. */
size_t workBufferSize /*!< [in] The size in bytes of pWorkSpace, must be at-least BSV_RSA_WORKSPACE_MIN_SIZE. */
);
/*!
@brief This function performs RSA PSS verify.
The function should support 2k and 3K bit size of modulus, based on compile time define.
@return \c CC_OK on success.
@return A non-zero value from bsv_error.h on failure.
*/
CCError_t CC_BsvRsaPssVerify (unsigned long hwBaseAddress, /*!< [in] The base address of the CryptoCell HW registers. */
CCBsvNBuff_t NBuff, /*!< [in] The modulus buffer big endian format. */
CCBsvNpBuff_t NpBuff, /*!< [in] The barret tag buffer big endian format - optional. */
CCBsvSignature_t signature, /*!< [in] The signature buffer to verify - big endian format. */
CCHashResult_t hashedData, /*!< [in] The data-in buffer to be verified as sha256 digest. */
uint32_t *pWorkSpace, /*!< [in] The pointer to user allocated buffer for internal use. */
size_t workBufferSize, /*!< [in] The size in bytes of pWorkSpace, must be at-least BSV_RSA_WORKSPACE_MIN_SIZE. */
CCBool_t *pIsVerified /*!< [out] The flag indicates whether the signature is verified or not.
If verified value will be CC_TRUE, otherwise CC_FALSE */
);
#ifdef __cplusplus
}
#endif
#endif
/**
@}
*/
|
8db04b28cf77bfb271b05ffda87196d52c01b7bb
|
f9cc38a7c78446b73747580aacae124bb2826a58
|
/cmd/demo/usbip/usbip-win/driver/lib/devconf.c
|
174f42899c63bf34569c14de63210fb3432e9d6d
|
[
"MIT",
"GPL-3.0-only"
] |
permissive
|
bulwarkid/virtual-fido
|
dae4677d2051961c96d8f284cac7db9a8c5a45d3
|
c0256885902878809ea97dbe488d6937d75b5bc5
|
refs/heads/master
| 2023-08-09T22:09:58.891332
| 2023-07-24T22:08:36
| 2023-07-24T23:10:00
| 537,229,823
| 988
| 46
|
MIT
| 2023-07-17T21:08:29
| 2022-09-15T22:47:15
|
C
|
UTF-8
|
C
| false
| false
| 2,682
|
c
|
devconf.c
|
#include "devconf.h"
#include <usbdlib.h>
PUSB_INTERFACE_DESCRIPTOR
dsc_find_first_intf(PUSB_CONFIGURATION_DESCRIPTOR dsc_conf)
{
return (PUSB_INTERFACE_DESCRIPTOR)USBD_ParseDescriptors(dsc_conf, dsc_conf->wTotalLength, dsc_conf, USB_INTERFACE_DESCRIPTOR_TYPE);
}
PUSB_INTERFACE_DESCRIPTOR
dsc_find_intf(PUSB_CONFIGURATION_DESCRIPTOR dsc_conf, UCHAR intf_num, USHORT alt_setting)
{
return USBD_ParseConfigurationDescriptorEx(dsc_conf, dsc_conf, intf_num, alt_setting, -1, -1, -1);
}
static BOOLEAN
intf_has_matched_ep(PUSB_CONFIGURATION_DESCRIPTOR dsc_conf, PUSB_INTERFACE_DESCRIPTOR dsc_intf, PUSB_ENDPOINT_DESCRIPTOR dsc_ep)
{
PVOID start = dsc_intf;
PUSB_ENDPOINT_DESCRIPTOR dsc_ep_try;
UCHAR n_ep = dsc_intf->bNumEndpoints;
while (n_ep > 0) {
dsc_ep_try = dsc_next_ep(dsc_conf, start);
if (dsc_ep_try == NULL)
break;
if (dsc_ep->bLength == dsc_ep_try->bLength) {
if (RtlCompareMemory(dsc_ep, dsc_ep_try, dsc_ep->bLength) == dsc_ep->bLength)
return TRUE;
}
start = dsc_ep_try;
n_ep--;
}
return FALSE;
}
PUSB_INTERFACE_DESCRIPTOR
dsc_find_intf_by_ep(PUSB_CONFIGURATION_DESCRIPTOR dsc_conf, PUSB_ENDPOINT_DESCRIPTOR dsc_ep)
{
PVOID start = dsc_conf;
while (start != NULL) {
PUSB_INTERFACE_DESCRIPTOR dsc_intf;
dsc_intf = (PUSB_INTERFACE_DESCRIPTOR)USBD_ParseDescriptors(dsc_conf, dsc_conf->wTotalLength, start, USB_INTERFACE_DESCRIPTOR_TYPE);
if (dsc_intf == NULL)
break;
if (intf_has_matched_ep(dsc_conf, dsc_intf, dsc_ep))
return dsc_intf;
start = NEXT_DESC(dsc_intf);
}
return NULL;
}
PUSB_ENDPOINT_DESCRIPTOR
dsc_find_intf_ep(PUSB_CONFIGURATION_DESCRIPTOR dsc_conf, PUSB_INTERFACE_DESCRIPTOR dsc_intf, UCHAR epaddr)
{
PVOID start = dsc_intf;
PUSB_ENDPOINT_DESCRIPTOR dsc_ep;
int i;
for (i = 0; i < dsc_intf->bNumEndpoints; i++) {
dsc_ep = dsc_next_ep(dsc_conf, start);
if (dsc_ep == NULL)
return NULL;
if (dsc_ep->bEndpointAddress == epaddr)
return dsc_ep;
}
return NULL;
}
PUSB_ENDPOINT_DESCRIPTOR
dsc_next_ep(PUSB_CONFIGURATION_DESCRIPTOR dsc_conf, PVOID start)
{
PUSB_COMMON_DESCRIPTOR dsc = (PUSB_COMMON_DESCRIPTOR)start;
if (dsc->bDescriptorType == USB_ENDPOINT_DESCRIPTOR_TYPE)
dsc = NEXT_DESC(dsc);
return (PUSB_ENDPOINT_DESCRIPTOR)USBD_ParseDescriptors(dsc_conf, dsc_conf->wTotalLength, dsc, USB_ENDPOINT_DESCRIPTOR_TYPE);
}
ULONG
dsc_conf_get_n_intfs(PUSB_CONFIGURATION_DESCRIPTOR dsc_conf)
{
PVOID start = dsc_conf;
ULONG n_intfs = 0;
while (start != NULL) {
PUSB_COMMON_DESCRIPTOR desc = USBD_ParseDescriptors(dsc_conf, dsc_conf->wTotalLength, start, USB_INTERFACE_DESCRIPTOR_TYPE);
if (desc == NULL)
break;
start = NEXT_DESC(desc);
n_intfs++;
}
return n_intfs;
}
|
32ef151d20427d2ff7d4ce767b85352d12e9d30d
|
71b91eb68d95fbeb48e32fa90db9fd0697f05bbb
|
/pure-lilv/symap.c
|
a218c811f8de440772a9d0327cf7ca1be62b5fb4
|
[
"BSD-3-Clause",
"BSD-2-Clause"
] |
permissive
|
agraef/pure-lang
|
2aaa3e08440b386d92f63b4da3e85450b7c5e81c
|
01603c49f8aab295989e2e239568373c3b016298
|
refs/heads/master
| 2022-10-01T05:05:21.484845
| 2022-08-07T22:24:27
| 2022-08-07T22:24:27
| 86,244,642
| 292
| 23
| null | 2022-09-20T03:35:21
| 2017-03-26T15:49:16
|
C++
|
UTF-8
|
C
| false
| false
| 5,472
|
c
|
symap.c
|
/*
Copyright 2011-2012 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or 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.
THIS 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.
*/
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include "symap.h"
/**
@file symap.c Implementation of Symap, a basic symbol map (string interner).
This implementation is primitive, but has some desirable qualities: good
(O(lg(n)) lookup performance for already-mapped symbols, minimal space
overhead, extremely fast (O(1)) reverse mapping (ID to string), simple code,
no dependencies.
The tradeoff is that mapping new symbols may be quite slow. In other words,
this implementation is ideal for use cases with a relatively limited set of
symbols, or where most symbols are mapped early. It will not fare so well
with very dynamic sets of symbols. For that, you're better off with a
tree-based implementation (and the associated space cost, especially if you
need reverse mapping).
*/
struct SymapImpl {
/**
Unsorted array of strings, such that the symbol for ID i is found
at symbols[i - 1].
*/
char** symbols;
/**
Array of IDs, sorted by corresponding string in @ref symbols.
*/
uint32_t* index;
/**
Number of symbols (number of items in @ref symbols and @ref index).
*/
uint32_t size;
};
Symap*
symap_new(void)
{
Symap* map = (Symap*)malloc(sizeof(Symap));
map->symbols = NULL;
map->index = NULL;
map->size = 0;
return map;
}
void
symap_free(Symap* map)
{
for (uint32_t i = 0; i < map->size; ++i) {
free(map->symbols[i]);
}
free(map->symbols);
free(map->index);
free(map);
}
static char*
symap_strdup(const char* str)
{
const size_t len = strlen(str);
char* copy = (char*)malloc(len + 1);
memcpy(copy, str, len + 1);
return copy;
}
/**
Return the index into map->index (not the ID) corresponding to @c sym,
or the index where a new entry for @c sym should be inserted.
*/
static uint32_t
symap_search(const Symap* map, const char* sym, bool* exact)
{
*exact = false;
if (map->size == 0) {
return 0; // Empty map, insert at 0
} else if (strcmp(map->symbols[map->index[map->size - 1] - 1], sym) < 0) {
return map->size; // Greater than last element, append
}
uint32_t lower = 0;
uint32_t upper = map->size - 1;
uint32_t i = upper;
int cmp;
while (upper >= lower) {
i = lower + ((upper - lower) / 2);
cmp = strcmp(map->symbols[map->index[i] - 1], sym);
if (cmp == 0) {
*exact = true;
return i;
} else if (cmp > 0) {
if (i == 0) {
break; // Avoid underflow
}
upper = i - 1;
} else {
lower = ++i;
}
}
assert(!*exact || strcmp(map->symbols[map->index[i] - 1], sym) > 0);
return i;
}
uint32_t
symap_try_map(Symap* map, const char* sym)
{
bool exact;
const uint32_t index = symap_search(map, sym, &exact);
if (exact) {
assert(!strcmp(map->symbols[map->index[index]], sym));
return map->index[index];
}
return 0;
}
uint32_t
symap_map(Symap* map, const char* sym)
{
bool exact;
const uint32_t index = symap_search(map, sym, &exact);
if (exact) {
assert(!strcmp(map->symbols[map->index[index] - 1], sym));
return map->index[index];
}
const uint32_t id = ++map->size;
char* const str = symap_strdup(sym);
/* Append new symbol to symbols array */
map->symbols = (char**)realloc(map->symbols, map->size * sizeof(str));
map->symbols[id - 1] = str;
/* Insert new index element into sorted index */
map->index = (uint32_t*)realloc(map->index, map->size * sizeof(uint32_t));
if (index < map->size - 1) {
memmove(map->index + index + 1,
map->index + index,
(map->size - index - 1) * sizeof(uint32_t));
}
map->index[index] = id;
return id;
}
const char*
symap_unmap(Symap* map, uint32_t id)
{
if (id == 0) {
return NULL;
} else if (id <= map->size) {
return map->symbols[id - 1];
}
return NULL;
}
#ifdef STANDALONE
#include <stdio.h>
static void
symap_dump(Symap* map)
{
fprintf(stderr, "{\n");
for (uint32_t i = 0; i < map->size; ++i) {
fprintf(stderr, "\t%u = %s\n",
map->index[i], map->symbols[map->index[i] - 1]);
}
fprintf(stderr, "}\n");
}
int
main()
{
#define N_SYMS 5
char* syms[N_SYMS] = {
"hello", "bonjour", "goodbye", "aloha", "salut"
};
Symap* map = symap_new();
for (int i = 0; i < N_SYMS; ++i) {
if (symap_try_map(map, syms[i])) {
fprintf(stderr, "error: Symbol already mapped\n");
return 1;
}
const uint32_t id = symap_map(map, syms[i]);
if (strcmp(map->symbols[id - 1], syms[i])) {
fprintf(stderr, "error: Corrupt symbol table\n");
return 1;
}
if (symap_map(map, syms[i]) != id) {
fprintf(stderr, "error: Remapped symbol to a different ID\n");
return 1;
}
symap_dump(map);
}
symap_free(map);
return 0;
}
#endif /* STANDALONE */
|
04c70c6c6925382a52202be7df9e988d7d0e8625
|
5816ae8b5fdfe9ab93b3653742b5d4c2a1567111
|
/hitcon-2018/abyss/src/hypervisor/hypercall_table.h
|
5dee6e3f33b192ecba9fb27fe8811e7526168202
|
[] |
no_license
|
david942j/ctf-writeups
|
6c2ff633d80809e422f0263b8ac9a69607d31e84
|
a4d086684a939000286d0876dd29463ccdceea2e
|
refs/heads/master
| 2022-09-07T00:27:23.594820
| 2021-12-14T10:50:47
| 2021-12-14T10:50:47
| 77,058,219
| 316
| 49
| null | null | null | null |
UTF-8
|
C
| false
| false
| 469
|
h
|
hypercall_table.h
|
#ifndef HYPERCALL_TABLE_H
#define HYPERCALL_TABLE_H
#define HP_NR_MARK 0x8000
#define NR_HP_open (HP_NR_MARK | 0)
#define NR_HP_read (HP_NR_MARK | 1)
#define NR_HP_write (HP_NR_MARK | 2)
#define NR_HP_lseek (HP_NR_MARK | 3)
#define NR_HP_close (HP_NR_MARK | 4)
#define NR_HP_fstat (HP_NR_MARK | 5)
#define NR_HP_exit (HP_NR_MARK | 6)
#define NR_HP_access (HP_NR_MARK | 7)
#define NR_HP_ioctl (HP_NR_MARK | 8)
#define NR_HP_panic (HP_NR_MARK | 0x7fff)
#endif
|
d25dc516e6e20d724084fbfb79de50d171ef0e76
|
2e5070a7874e115b7238b328050762d37085e546
|
/src/core/utils.h
|
072a20e4db84448fbe9a0291d48de6b27e28aaea
|
[
"MIT",
"GPL-1.0-or-later",
"LGPL-2.0-or-later"
] |
permissive
|
wangwenx190/framelesshelper
|
f5cea08ca9c70a1e538b237bed5e44433271581d
|
97112f853f7f1841aed7edb3b712d705cc56efe6
|
refs/heads/main
| 2023-09-03T06:33:28.968122
| 2023-08-31T10:26:49
| 2023-08-31T10:26:49
| 250,978,405
| 762
| 197
|
MIT
| 2023-09-03T10:54:00
| 2020-03-29T07:37:30
|
C++
|
UTF-8
|
C
| false
| false
| 54
|
h
|
utils.h
|
#include "../../include/FramelessHelper/Core/utils.h"
|
5d17ece642e1f52b2a9b284dc006e996da5bb42e
|
88ae8695987ada722184307301e221e1ba3cc2fa
|
/third_party/xnnpack/src/src/math/f32-expm1minus-scalar-rr2-p6.c
|
e559853be0422f119ecfbd28c3e974e3a19c86dc
|
[
"BSD-3-Clause",
"LicenseRef-scancode-generic-cla",
"Apache-2.0",
"LGPL-2.0-or-later",
"MIT",
"GPL-1.0-or-later"
] |
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,444
|
c
|
f32-expm1minus-scalar-rr2-p6.c
|
// Copyright 2020 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.
#include <assert.h>
#include <stddef.h>
#include <xnnpack/common.h>
#include <xnnpack/math.h>
#include <xnnpack/math-stubs.h>
void xnn_math_f32_expm1minus__scalar_rr2_p6(
size_t n,
const float* input,
float* output)
{
assert(n % (4 * sizeof(float)) == 0);
// Large number such that ulp(magic bias) == 1 and magic bias === 127 mod 2**22.
const float vmagic_bias = 0x1.8000FEp23f;
const float vlog2e = 0x1.715476p+0f;
// The largest x for which expm1f(x) is saturated at -1.0f.
const float vsat_cutoff = -0x1.154246p+4f;
// Last 5 bits are zeroes
const float vminus_ln2_hi = -0x1.62E440p-1f;
const float vminus_ln2_lo = 0x1.0105C6p-21f;
// Coefficient of polynomial approximation
// exp(t) - 1 ~ t * (1 + t * (c2 + t * (c3 + t * (c4 + t * (c5 + t * c6)))))
// on [-log(2)/2, log(2)/2]
const float vc6 = 0x1.6b7338p-10f;
const float vc5 = 0x1.12278Ep-7f;
const float vc4 = 0x1.555716p-5f;
const float vc3 = 0x1.5554B0p-3f;
const float vc2 = 0x1.FFFFFEp-2f;
const float vone = 1.0f;
for (; n != 0; n -= sizeof(float)) {
float vx = *input++;
// Compute reduced argument n := round(x / log(2)).
// We do it by adding a large number (magic bias), which cause rounding of the result to integer, then subtracing
// the large number back. The trick with adding large number is valid only within certain bounds
// (|x / log(2)| <= 2**22, i.e. |x| <= 0x1.62E43p+21 = 2907270.0), but that is acceptable, because inputs x are
// restricted to [-17.328680, 0].
// Note that addition-subtraction of the large number doesn't cause overflow for inputs in this range.
float vn = vx * vlog2e + vmagic_bias;
// Create a floating-point number s (scale) such that s == 2**n for valid inputs, i.e.
// -17.328680 <= x <= 0.0, and -25 <= n <= 0 accordingly.
float vs = uint32_as_float(float_as_uint32(vn) << 23);
// Subtract the large number back to get final n := round(x / log(2)).
vn -= vmagic_bias;
// Compute reduced argument t := x - n * log(2).
// Use Cody-Waite range reduction method (note two constants to represent log(2)) to improve accuracy.
float vt = vn * vminus_ln2_hi + vx;
vt = vn * vminus_ln2_lo + vt;
// The function saturates at -1 for large negative inputs: expm1f(x) == -1.0f for x <= sat_cutoff ~= -17.328680.
// To guarantee this behaviour, we zero out s (scale) and t (reduced argument) for x <= sat_cutoff.
if XNN_UNPREDICTABLE(vx <= vsat_cutoff) {
vs = 0.0f;
vt = 0.0f;
}
// Compute degree-6 polynomial approximation for exp(t) - 1 on [-log(2)/2, log(2)/2].
// P(t) = t * (1 + t * (c2 + t * (c3 + t * (c4 + t * (c5 + t * c6)))))
// = t + t * (t * (c2 + t * (c3 + t * (c4 + t * (c5 + t * c6))))) = t + t * p
float vp = vc6 * vt + vc5;
vp = vp * vt + vc4;
vp = vp * vt + vc3;
vp = vp * vt + vc2;
vp *= vt;
// Reconstruct the exp(x) - 1 value:
// exp(x) - 1 = s * (1 + t * (1 + t * (c2 + t * (c3 + t * (c4 + t * (c5 + t * c6)))))) - 1
// = (s - 1) + s * (t + t * p)
// = ((t * s) + (t * s) * p) + (s - 1)
vt *= vs;
const float vsm1 = vs - vone;
vp = vp * vt + vt;
const float vf = vp + vsm1;
*output++ = vf;
}
}
|
bb0dc3d4470a9e448f669c2df9529fdaa5271934
|
a519061e401f7554bc632b93212b519391dfcd06
|
/examples/mbed-rtos-mesh-minimal/src/mbedtls_wisun_config.h
|
0606f6c786f760573d577bbef55d03d8a40f7a79
|
[
"Apache-2.0"
] |
permissive
|
platformio/platform-ststm32
|
dd8452a64abb695384c3289d90e9ad2c7a0f7e29
|
d1ef4d128849c064121984bb2c7f23aa713a7ac1
|
refs/heads/master
| 2023-09-02T21:29:25.155371
| 2023-07-28T10:56:33
| 2023-07-28T10:56:33
| 59,845,233
| 382
| 357
|
Apache-2.0
| 2023-08-29T18:11:29
| 2016-05-27T15:38:10
|
Python
|
UTF-8
|
C
| false
| false
| 6,105
|
h
|
mbedtls_wisun_config.h
|
/*
* Copyright (c) 2019, Arm Limited and affiliates.
* 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_WISUN_CONFIG_H_
#define MBEDTLS_WISUN_CONFIG_H_
#define MBEDTLS_ENTROPY_MAX_SOURCES 4 // save 320 bytes of RAM (default is 20 entropy source)
#define MBEDTLS_SSL_MAX_CONTENT_LEN 4096 // Use 4kB buffers for input and output instead of 16kB
//#define MBEDTLS_DEBUG_C
/* mbed TLS feature support */
#define MBEDTLS_ECP_NIST_OPTIM
#define MBEDTLS_ECP_DP_SECP256R1_ENABLED
#undef MBEDTLS_ECP_DP_SECP192R1_ENABLED
#undef MBEDTLS_ECP_DP_SECP224R1_ENABLED
#undef MBEDTLS_ECP_DP_SECP384R1_ENABLED
#undef MBEDTLS_ECP_DP_SECP521R1_ENABLED
#undef MBEDTLS_ECP_DP_SECP192K1_ENABLED
#undef MBEDTLS_ECP_DP_SECP224K1_ENABLED
#undef MBEDTLS_ECP_DP_SECP256K1_ENABLED
#undef MBEDTLS_ECP_DP_BP256R1_ENABLED
#undef MBEDTLS_ECP_DP_BP384R1_ENABLED
#undef MBEDTLS_ECP_DP_BP512R1_ENABLED
#undef MBEDTLS_ECP_DP_CURVE25519_ENABLED
#ifdef MBEDTLS_SSL_TLS_C
#define MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
#define MBEDTLS_SSL_PROTO_TLS1_2
#define MBEDTLS_SSL_EXPORT_KEYS
#define MBEDTLS_SSL_ALL_ALERT_MESSAGES
#endif
/* mbed TLS modules */
#define MBEDTLS_BIGNUM_C
#define MBEDTLS_CIPHER_C
#define MBEDTLS_AES_C
#define MBEDTLS_CCM_C
#define MBEDTLS_CTR_DRBG_C
#define MBEDTLS_ECP_C
#define MBEDTLS_MD_C
#define MBEDTLS_PK_C
#define MBEDTLS_SHA256_C
#ifdef MBEDTLS_SSL_TLS_C
#define MBEDTLS_SSL_COOKIE_C
#define MBEDTLS_SSL_CLI_C
#define MBEDTLS_SSL_SRV_C
#endif
#define MBEDTLS_NIST_KW_C
#define MBEDTLS_PEM_PARSE_C
#define MBEDTLS_BASE64_C
#define MBEDTLS_SHA1_C
/* Save RAM at the expense of ROM */
#define MBEDTLS_AES_ROM_TABLES
#define MBEDTLS_AES_FEWER_TABLES
/* Save RAM by adjusting to our exact needs */
#define MBEDTLS_ECP_MAX_BITS 256
#undef MBEDTLS_MPI_MAX_SIZE
#define MBEDTLS_MPI_MAX_SIZE 128 // 256 bits is 32 bytes
/* Save ROM and a few bytes of RAM by specifying our own ciphersuite list */
#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8
/* Optimization. Remove all not needed stuff */
#define MBEDTLS_X509_USE_C
#define MBEDTLS_X509_CRT_PARSE_C
#undef MBEDTLS_SSL_SERVER_NAME_INDICATION
#undef MBEDTLS_SELF_TEST
#undef MBEDTLS_SSL_ENCRYPT_THEN_MAC
#undef MBEDTLS_SSL_EXTENDED_MASTER_SECRET
#define MBEDTLS_ASN1_PARSE_C
#define MBEDTLS_ASN1_WRITE_C
#define MBEDTLS_ECDH_C
#define MBEDTLS_ECDSA_C
#undef MBEDTLS_ERROR_C
#define MBEDTLS_GCM_C
#define MBEDTLS_OID_C
#define MBEDTLS_PK_PARSE_C
#define MBEDTLS_PK_WRITE_C
#undef MBEDTLS_RSA_C
#undef MBEDTLS_VERSION_C
#undef MBEDTLS_CERTS_C
#undef MBEDTLS_HMAC_DRBG_C
#define MBEDTLS_CIPHER_MODE_CBC
#undef MBEDTLS_CIPHER_PADDING_PKCS7
#undef MBEDTLS_ECDSA_DETERMINISTIC
#undef MBEDTLS_SSL_SESSION_TICKETS
#undef MBEDTLS_VERSION_FEATURES
#undef MBEDTLS_X509_CHECK_KEY_USAGE
#undef MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE
#undef MBEDTLS_ERROR_STRERROR_DUMMY
#undef MBEDTLS_SSL_ALPN
#undef MBEDTLS_SSL_TICKET_C
#undef MBEDTLS_HAVE_SSE2
#undef MBEDTLS_PLATFORM_MEMORY
#undef MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
#undef MBEDTLS_DEPRECATED_WARNING
#undef MBEDTLS_DEPRECATED_REMOVED
#undef MBEDTLS_CAMELLIA_SMALL_MEMORY
#undef MBEDTLS_CIPHER_MODE_CFB
#undef MBEDTLS_CIPHER_MODE_CTR
#undef MBEDTLS_CIPHER_NULL_CIPHER
#undef MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS
#undef MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN
#undef MBEDTLS_CIPHER_PADDING_ZEROS
#undef MBEDTLS_ENABLE_WEAK_CIPHERSUITES
#define MBEDTLS_REMOVE_ARC4_CIPHERSUITES
#undef MBEDTLS_ECP_DP_CURVE25519_ENABLED
#define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED
#undef MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED
#define MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED
#undef MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED
#undef MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
#undef MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED
#undef MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED
#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
#undef MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
#undef MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED
#undef MBEDTLS_PK_PARSE_EC_EXTENDED
#undef MBEDTLS_GENPRIME
#undef MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
#undef MBEDTLS_MEMORY_DEBUG
#undef MBEDTLS_MEMORY_BACKTRACE
#undef MBEDTLS_PK_RSA_ALT_SUPPORT
#undef MBEDTLS_PKCS1_V15
#undef MBEDTLS_PKCS1_V21
#undef MBEDTLS_RSA_NO_CRT
#undef MBEDTLS_SSL_AEAD_RANDOM_IV
#undef MBEDTLS_RSA_NO_CRT
#undef MBEDTLS_SSL_DEBUG_ALL
#undef MBEDTLS_SSL_FALLBACK_SCSV
#undef MBEDTLS_SSL_HW_RECORD_ACCEL
#undef MBEDTLS_SSL_CBC_RECORD_SPLITTING
#undef MBEDTLS_SSL_RENEGOTIATION
#undef MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO
#undef MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE
#undef MBEDTLS_SSL_PROTO_TLS1
#undef MBEDTLS_SSL_PROTO_TLS1_1
#undef MBEDTLS_SSL_DTLS_BADMAC_LIMIT
#undef MBEDTLS_SSL_TRUNCATED_HMAC
#undef MBEDTLS_THREADING_ALT
#undef MBEDTLS_THREADING_PTHREAD
#undef MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3
#undef MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION
#undef MBEDTLS_X509_RSASSA_PSS_SUPPORT
#undef MBEDTLS_ZLIB_SUPPORT
#undef MBEDTLS_AESNI_C
#undef MBEDTLS_ARC4_C
#undef MBEDTLS_BLOWFISH_C
#undef MBEDTLS_CAMELLIA_C
#undef MBEDTLS_DES_C
#undef MBEDTLS_DHM_C
#undef MBEDTLS_HAVEGE_C
#undef MBEDTLS_MD2_C
#undef MBEDTLS_MD4_C
#undef MBEDTLS_MD5_C
#undef MBEDTLS_MEMORY_BUFFER_ALLOC_C
#undef MBEDTLS_PADLOCK_C
#undef MBEDTLS_PEM_WRITE_C
#undef MBEDTLS_PKCS5_C
#undef MBEDTLS_PKCS11_C
#undef MBEDTLS_PKCS12_C
#undef MBEDTLS_PLATFORM_C
#undef MBEDTLS_RIPEMD160_C
#undef MBEDTLS_SHA512_C
#undef MBEDTLS_SSL_CACHE_C
#undef MBEDTLS_THREADING_C
#define MBEDTLS_X509_CREATE_C
#define MBEDTLS_X509_CRT_WRITE_C
#undef MBEDTLS_XTEA_C
#include "mbedtls/check_config.h"
#endif /* MBEDTLS_WISUN_CONFIG_H */
|
521f59e03cd7e424dd3439614ab33256fd69572f
|
8a87f5b889a9ce7d81421515f06d9c9cbf6ce64a
|
/3rdParty/boost/1.78.0/boost/predef/version_number.h
|
903578245b72ce31ce082599aaeb71d78283eb3e
|
[
"BSL-1.0",
"Apache-2.0",
"BSD-3-Clause",
"ICU",
"Zlib",
"GPL-1.0-or-later",
"OpenSSL",
"ISC",
"LicenseRef-scancode-gutenberg-2020",
"MIT",
"GPL-2.0-only",
"CC0-1.0",
"LicenseRef-scancode-autoconf-simple-exception",
"LicenseRef-scancode-pcre",
"Bison-exception-2.2",
"LicenseRef-scancode-public-domain",
"JSON",
"BSD-2-Clause",
"LicenseRef-scancode-unknown-license-reference",
"Unlicense",
"BSD-4-Clause",
"Python-2.0",
"LGPL-2.1-or-later"
] |
permissive
|
arangodb/arangodb
|
0980625e76c56a2449d90dcb8d8f2c485e28a83b
|
43c40535cee37fc7349a21793dc33b1833735af5
|
refs/heads/devel
| 2023-08-31T09:34:47.451950
| 2023-08-31T07:25:02
| 2023-08-31T07:25:02
| 2,649,214
| 13,385
| 982
|
Apache-2.0
| 2023-09-14T17:02:16
| 2011-10-26T06:42:00
|
C++
|
UTF-8
|
C
| false
| false
| 2,184
|
h
|
version_number.h
|
/*
Copyright Rene Rivera 2005-2016
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_PREDEF_VERSION_NUMBER_H
#define BOOST_PREDEF_VERSION_NUMBER_H
/* tag::reference[]
= `BOOST_VERSION_NUMBER`
[source]
----
BOOST_VERSION_NUMBER(major,minor,patch)
----
Defines standard version numbers, with these properties:
* Decimal base whole numbers in the range [0,1000000000).
The number range is designed to allow for a (2,2,5) triplet.
Which fits within a 32 bit value.
* The `major` number can be in the [0,99] range.
* The `minor` number can be in the [0,99] range.
* The `patch` number can be in the [0,99999] range.
* Values can be specified in any base. As the defined value
is an constant expression.
* Value can be directly used in both preprocessor and compiler
expressions for comparison to other similarly defined values.
* The implementation enforces the individual ranges for the
major, minor, and patch numbers. And values over the ranges
are truncated (modulo).
*/ // end::reference[]
#define BOOST_VERSION_NUMBER(major,minor,patch) \
( (((major)%100)*10000000) + (((minor)%100)*100000) + ((patch)%100000) )
#define BOOST_VERSION_NUMBER_MAX \
BOOST_VERSION_NUMBER(99,99,99999)
#define BOOST_VERSION_NUMBER_ZERO \
BOOST_VERSION_NUMBER(0,0,0)
#define BOOST_VERSION_NUMBER_MIN \
BOOST_VERSION_NUMBER(0,0,1)
#define BOOST_VERSION_NUMBER_AVAILABLE \
BOOST_VERSION_NUMBER_MIN
#define BOOST_VERSION_NUMBER_NOT_AVAILABLE \
BOOST_VERSION_NUMBER_ZERO
/* tag::reference[]
[source]
----
BOOST_VERSION_NUMBER_MAJOR(N), BOOST_VERSION_NUMBER_MINOR(N), BOOST_VERSION_NUMBER_PATCH(N)
----
The macros extract the major, minor, and patch portion from a well formed
version number resulting in a preprocessor expression in the range of
[0,99] or [0,99999] for the major and minor, or patch numbers
respectively.
*/ // end::reference[]
#define BOOST_VERSION_NUMBER_MAJOR(N) \
( ((N)/10000000)%100 )
#define BOOST_VERSION_NUMBER_MINOR(N) \
( ((N)/100000)%100 )
#define BOOST_VERSION_NUMBER_PATCH(N) \
( (N)%100000 )
#endif
|
b035adf86f86eab6de3f6776fb0796103c002386
|
0c6f50fec57f1b6552a3ed76c040c24c84366f9e
|
/gf16/gfmat_coeff.c
|
df31276bb0d91f29efe533529724474a7821dbeb
|
[
"CC0-1.0",
"LicenseRef-scancode-public-domain"
] |
permissive
|
animetosho/ParPar
|
93c3ff93c553204a2db0e191d3f84816a1b3cb89
|
c2c4ee5d605a82a73b435dbee0f3b08b55912b5d
|
refs/heads/master
| 2023-08-08T17:31:58.644991
| 2023-05-28T03:51:21
| 2023-05-28T03:51:21
| 43,628,609
| 156
| 22
| null | 2023-08-16T16:36:13
| 2015-10-04T07:30:18
|
C
|
UTF-8
|
C
| false
| false
| 2,633
|
c
|
gfmat_coeff.c
|
#include "gfmat_coeff.h"
#include <stdlib.h>
static int8_t* input_diff = NULL; // difference between predicted input coefficient and actual (number range is -4...5, so could be compressed to 4 bits, but I don't feel it's worth the savings)
static uint16_t* gf_exp = NULL; // pre-calculated exponents in GF(2^16), missing bottom 3 bits, followed by 128-entry polynomial shift table
void gfmat_init() {
if(input_diff) return;
input_diff = (int8_t*)malloc(32768);
gf_exp = (uint16_t*)malloc((8192+128)*2);
int exp = 0, n = 1;
for (int i = 0; i < 32768; i++) {
do {
if((exp & 7) == 0) gf_exp[exp>>3] = n;
exp++; // exp will reach 65534 by the end of the loop
n <<= 1;
if(n > 65535) n ^= 0x1100B;
} while( !(exp%3) || !(exp%5) || !(exp%17) || !(exp%257) );
input_diff[i] = exp - i*2;
}
// correction values for handling the missing bottom 3 bits of exp
// essentially this is a table to speed up multiplication by 0...127 by applying the effects of polynomial masking
for (int i = 0; i < 128; i++) {
n = i << 9;
for (int j = 0; j < 7; j++) {
n <<= 1;
if(n > 65535) n ^= 0x1100B;
}
gf_exp[8192+i] = n;
}
}
void gfmat_free() {
free(input_diff);
free(gf_exp);
input_diff = NULL;
gf_exp = NULL;
}
HEDLEY_CONST uint16_t gf16_exp(uint_fast16_t v) {
uint_fast32_t result = gf_exp[v>>3];
result <<= (v&7);
return result ^ gf_exp[8192 + (result>>16)];
/* alternative idea which only omits bottom bit of gf_exp lookup, but avoids a second lookup
// GCC doesn't handle the unpredictable check that well
uint_fast32_t result0 = gf_exp[result>>1];
uint_fast32_t result1 = (result0 << 1) ^ (-(result0 >> 15) & 0x1100B); // multiply by 2?
return HEDLEY_UNPREDICTABLE(result & 1) ? result1 : result0;
*/
}
HEDLEY_CONST uint16_t gfmat_input_log(uint_fast16_t inputBlock) {
return (inputBlock*2 + input_diff[inputBlock]);
}
HEDLEY_CONST uint16_t gfmat_coeff_log(uint_fast16_t inputLog, uint_fast16_t recoveryBlock) {
//assert(recoveryBlock < 65535); // if ==65535, gets an invalid exponent
// calculate POW(inputBlockConstant, recoveryBlock) in GF
uint_fast32_t result = inputLog * recoveryBlock;
// clever bit hack for 'result %= 65535' from MultiPar sources
result = (result >> 16) + (result & 65535);
result += result >> 16;
return result;
}
HEDLEY_CONST uint16_t gfmat_coeff_from_log(uint_fast16_t inputLog, uint_fast16_t recoveryBlock) {
return gf16_exp(gfmat_coeff_log(inputLog, recoveryBlock));
}
HEDLEY_CONST uint16_t gfmat_coeff(uint_fast16_t inputBlock, uint_fast16_t recoveryBlock) {
return gfmat_coeff_from_log(gfmat_input_log(inputBlock), recoveryBlock);
}
|
68b51a8455ab76b372c149fcb97929cbabb78e67
|
9de0cec678bc4a3bec2b4adabef9f39ff5b4afac
|
/PWGCF/FLOW/Forward/PWGCFFlowForwardLinkDef.h
|
5775edd50058465e3ce9872444a60458fa193cac
|
[] |
permissive
|
alisw/AliPhysics
|
91bf1bd01ab2af656a25ff10b25e618a63667d3e
|
5df28b2b415e78e81273b0d9bf5c1b99feda3348
|
refs/heads/master
| 2023-08-31T20:41:44.927176
| 2023-08-31T14:51:12
| 2023-08-31T14:51:12
| 61,661,378
| 129
| 1,150
|
BSD-3-Clause
| 2023-09-14T18:48:45
| 2016-06-21T19:31:29
|
C++
|
UTF-8
|
C
| false
| false
| 604
|
h
|
PWGCFFlowForwardLinkDef.h
|
#ifdef __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ class AliForwardSettings+;
#pragma link C++ class AliForwardFlowUtil+;
#pragma link C++ class AliForwardWeights+;
#pragma link C++ class AliForwardTaskValidation+;
#pragma link C++ class AliForwardGenericFramework+;
#pragma link C++ class AliForwardFlowRun2Task+;
#pragma link C++ class AliForwardNUATask+;
#pragma link C++ class AliForwardNUETask+;
#pragma link C++ class AliForwardSecondariesTask+;
#pragma link C++ class AliForwardFlowResultStorage+;
#endif /* __CINT__ */
|
5acdcea0453e26deafd178824518a608e9aa7ef0
|
88dea29c69d1b003e188a9a7819931eb1fbd17d8
|
/agent/mibgroup/ucd-snmp/vmstat_bsdi4.h
|
8f2adc12a2d1468f3e8e6537f061f99cde98e07e
|
[
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-other-permissive",
"BSD-3-Clause",
"MIT",
"MIT-CMU"
] |
permissive
|
net-snmp/net-snmp
|
388733e7094495d25d052834e36691bcfc8b5bad
|
9ff837bfae4d985e40c8eaf3734a377898d8753a
|
refs/heads/master
| 2023-09-01T09:19:14.133409
| 2023-08-31T02:54:49
| 2023-08-31T15:11:53
| 128,822,274
| 241
| 236
|
NOASSERTION
| 2023-09-11T18:00:01
| 2018-04-09T19:19:27
|
C
|
UTF-8
|
C
| false
| false
| 270
|
h
|
vmstat_bsdi4.h
|
/*
* vmstat mib groups
*
*/
#ifndef _MIBGROUP_VMSTAT_BSDI4_H
#define _MIBGROUP_VMSTAT_BSDI4_H
config_require(util_funcs/header_generic);
#include "mibdefs.h"
void init_vmstat_bsdi4(void);
#endif /* _MIBGROUP_VMSTAT_BSDI4_H */
|
a26e71f74d9f44f95c13527e4f4511929f1809c8
|
35c04ea32351dc95bc18d46e5c70dda9c1e08668
|
/Examples/FreeRTOS_Ports/IAR/FreeRTOS_FRDM-KL25Z/Sources/main.c
|
d68e1883e88053bbe1fbf6d247ef5447f4665774
|
[
"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
| 4,677
|
c
|
main.c
|
//#include "MKL25Z128LK4.h"
#include "MKL25Z4.h"
#include "FreeRTOS/FreeRTOS.h"
//! @brief Init hardware for FRDM-KL25Z4 board.
#define RED (18) /* Red LED is on BTB18 */
#define GREEN (19) /* Red LED is on BTB19 */
#define RED_SHIFT (1<<RED)
#define GREEN_SHIFT (1<<GREEN)
#define BLUE (1)
#define BLUE_SHIFT (1<<BLUE)
#define RED_OFF() (GPIOB_PSOR = RED_SHIFT)
#define RED_ON() (GPIOB_PCOR = RED_SHIFT)
#define RED_TOGGLE() (GPIOB_PTOR = RED_SHIFT)
#define GREEN_OFF() (GPIOB_PSOR = GREEN_SHIFT)
#define GREEN_ON() (GPIOB_PCOR = GREEN_SHIFT)
#define GREEN_TOGGLE() (GPIOB_PTOR = GREEN_SHIFT)
#define BLUE_OFF() (GPIOD_PSOR = BLUE_SHIFT)
#define BLUE_ON (GPIOD_PCOR = BLUE_SHIFT)
#define BLUE_TOGGLE (GPIOD_PTOR = BLUE_SHIFT)
static void InitLED(void) {
/*
* Initialize the Red LED (PTB18)
*/
{
/* Turn on clock to PortB module */
SIM_SCGC5 |= SIM_SCGC5_PORTB_MASK;
/* Set the PTB18 pin multiplexer to GPIO mode */
PORTB_PCR18 = PORT_PCR_MUX(1);
/* Set the initial output state to high */
GPIOB_PSOR |= RED_SHIFT;
/* Set the pins direction to output */
GPIOB_PDDR |= RED_SHIFT;
}
/*
* Initialize the Green LED (PTB19)
*/
{
/* Turn on clock to PortB module */
SIM_SCGC5 |= SIM_SCGC5_PORTB_MASK;
/* Set the PTB19 pin multiplexer to GPIO mode */
PORTB_PCR19 = PORT_PCR_MUX(1);
/* Set the initial output state to high */
GPIOB_PSOR |= GREEN_SHIFT;
/* Set the pins direction to output */
GPIOB_PDDR |= GREEN_SHIFT;
}
/*
* Initialize the Blue LED (PTD1)
*/
{
/* Turn on clock to PortB module */
SIM_SCGC5 |= SIM_SCGC5_PORTD_MASK;
/* Set the PTD1 pin multiplexer to GPIO mode */
PORTD_PCR1 = PORT_PCR_MUX(1);
/* Set the initial output state to high */
GPIOD_PSOR = BLUE_SHIFT;
/* Set the pins direction to output */
GPIOD_PDDR |= BLUE_SHIFT;
}
}
static void init_hardware(void)
{
InitLED();
}
/* Service constants */
#define COP_PDD_KEY_1 0x55U /**< First key */
#define COP_PDD_KEY_2 0xAAU /**< Second key */
static portTASK_FUNCTION(redTask, pvParameters) {
(void)pvParameters; /* parameter not used */
for(;;) {
RED_TOGGLE();
//SIM_SRVCOP = COP_PDD_KEY_1;
//SIM_SRVCOP = COP_PDD_KEY_2;
vTaskDelay(10/portTICK_RATE_MS);
}
}
static portTASK_FUNCTION(greenTask, pvParameters) {
(void)pvParameters; /* parameter not used */
for(;;) {
GREEN_TOGGLE();
vTaskDelay(1200/portTICK_RATE_MS); /* wait time, so the other task can give token */
}
}
static xTaskHandle redTaskHandle, greenTaskHandle;
static void start(void) {
if (xTaskCreate(
redTask, /* pointer to the task */
(signed char *)"Red", /* task name for kernel awareness debugging */
configMINIMAL_STACK_SIZE, /* task stack size */
(void*)NULL, /* optional task startup argument */
tskIDLE_PRIORITY, /* initial priority */
(xTaskHandle*)&redTaskHandle /* optional task handle to create */
) != pdPASS) {
/*lint -e527 */
for(;;){}; /* error! probably out of memory */
/*lint +e527 */
}
if (xTaskCreate(
greenTask, /* pointer to the task */
(signed char *)"Green", /* task name for kernel awareness debugging */
configMINIMAL_STACK_SIZE, /* task stack size */
(void*)NULL, /* optional task startup argument */
tskIDLE_PRIORITY, /* initial priority */
(xTaskHandle*)&greenTaskHandle /* optional task handle to create */
) != pdPASS) {
/*lint -e527 */
for(;;){}; /* error! probably out of memory */
/*lint +e527 */
}
vTaskStartScheduler(); /* does not return */
}
void SystemInit(void) {
SCB_VTOR = (uint32_t)(&__vector_table); /* Set the interrupt vector table position */
/* Disable the WDOG module */
/* SIM_COPC: ??=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,COPT=0,COPCLKS=0,COPW=0 */
SIM_COPC = SIM_COPC_COPT(0x00);
/* Disable the WDOG module */
/* SIM_COPC: COPT=0,COPCLKS=0,COPW=0 */
SIM_COPC = (uint32_t)0x00u;
SIM_SCGC5 |= (SIM_SCGC5_PORTA_MASK
| SIM_SCGC5_PORTB_MASK
| SIM_SCGC5_PORTC_MASK
| SIM_SCGC5_PORTD_MASK
| SIM_SCGC5_PORTE_MASK );
}
int main(void)
{
init_hardware();
start();
return 0;
}
|
9fe5ce15401decaaf3386944131c33bc4c56fab5
|
aa3befea459382dc5c01c925653d54f435b3fb0f
|
/arch/arm/include/samd2l2/chip.h
|
22f4b55a2e85309c0d3b49619f0b7529fa9f2a01
|
[
"MIT-open-group",
"BSD-3-Clause",
"HPND-sell-variant",
"BSD-4-Clause-UC",
"LicenseRef-scancode-warranty-disclaimer",
"MIT-0",
"LicenseRef-scancode-bsd-atmel",
"LicenseRef-scancode-gary-s-brown",
"LicenseRef-scancode-proprietary-license",
"SunPro",
"MIT",
"LicenseRef-scancode-public-domain-disclaimer",
"LicenseRef-scancode-other-permissive",
"HPND",
"ISC",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"GPL-1.0-or-later",
"CC-BY-2.0",
"CC-BY-4.0"
] |
permissive
|
apache/nuttx
|
14519a7bff4a87935d94fb8fb2b19edb501c7cec
|
606b6d9310fb25c7d92c6f95bf61737e3c79fa0f
|
refs/heads/master
| 2023-08-25T06:55:45.822534
| 2023-08-23T16:03:31
| 2023-08-24T21:25:47
| 228,103,273
| 407
| 241
|
Apache-2.0
| 2023-09-14T18:26:05
| 2019-12-14T23:27:55
|
C
|
UTF-8
|
C
| false
| false
| 43,948
|
h
|
chip.h
|
/****************************************************************************
* arch/arm/include/samd2l2/chip.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
*
* 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 __ARCH_ARM_INCLUDE_SAMD2L2_CHIP_H
#define __ARCH_ARM_INCLUDE_SAMD2L2_CHIP_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/****************************************************************************
* Pre-processor Prototypes
****************************************************************************/
/* Get customizations for each supported chip */
/* SAMD20 Family ************************************************************/
/* FEATURE SAM D20J SAM D20G SAM D20E
* ------------------- ------------------ ------------------ --------
* No. of pins 64 48 32
* Flash 256/128/64/ 256/128/64/ 256/128/64/
* 32/16KB 32/16KB 32/16KB
* SRAM 32/16/8/4/2KB 32/16/8/4/2KB 32/16/8/4/2KB
* Max. Freq. 48MHz 48MHz 48MHz
* Event channels 8 8 8
* Timer/counters 8 6 6
* TC output channels 2 2 2
* SERCOM 6 6 4
* ADC channels 20 14 10
* Comparators 2 2 2
* DAC channels 1 1 1
* RTC Yes Yes Yes
* RTC alarms 1 1 1
* RTC compare 1 32-bit/ 1 32-bit/ 1 32-bit/
* 2 16-bit 2 16-bit 2 16-bit
* External interrupts 16 16 16
* PTC X an Y 16x16 12x10 10x6
* Packages QFN/TQFP QFN/TQFP QFN/TQFP
* Oscillators XOSC32, XOSC, OSC32K, OSCULP32K, OSC8M, and DFLL48M
* SW Debug interface Yes Yes Yes
* Watchdog timer Yes Yes Yes
*/
#if defined(CONFIG_ARCH_CHIP_SAMD20E14)
# define SAMD20 1 /* SAMD20 family */
# define SAMD20E 1 /* SAMD20E */
# undef SAMD20G
# undef SAMD20J
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (16*1024) /* 16KB */
# define SAMD2L2_SRAM0_SIZE (2*1024) /* 2KB */
# define SAMD2L2_LPRAM_SIZE (0*1024) /* None */
#elif defined(CONFIG_ARCH_CHIP_SAMD20E15)
# define SAMD20 1 /* SAMD20 family */
# define SAMD20E 1 /* SAMD20E */
# undef SAMD20G
# undef SAMD20J
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (32*1024) /* 32KB */
# define SAMD2L2_SRAM0_SIZE (4*1024) /* 4KB */
# define SAMD2L2_LPRAM_SIZE (0*1024) /* None */
#elif defined(CONFIG_ARCH_CHIP_SAMD20E16)
# define SAMD20 1 /* SAMD20 family */
# define SAMD20E 1 /* SAMD20E */
# undef SAMD20G
# undef SAMD20J
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (64*1024) /* 64KB */
# define SAMD2L2_SRAM0_SIZE (8*1024) /* 8KB */
# define SAMD2L2_LPRAM_SIZE (0*1024) /* None */
#elif defined(CONFIG_ARCH_CHIP_SAMD20E17)
# define SAMD20 1 /* SAMD20 family */
# define SAMD20E 1 /* SAMD20E */
# undef SAMD20G
# undef SAMD20J
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (128*1024) /* 128KB */
# define SAMD2L2_SRAM0_SIZE (16*1024) /* 16KB */
# define SAMD2L2_LPRAM_SIZE (0*1024) /* None */
#elif defined(CONFIG_ARCH_CHIP_SAMD20E18)
# define SAMD20 1 /* SAMD20 family */
# define SAMD20E 1 /* SAMD20E */
# undef SAMD20G
# undef SAMD20J
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (256*1024) /* 256KB */
# define SAMD2L2_SRAM0_SIZE (32*1024) /* 32KB */
# define SAMD2L2_LPRAM_SIZE (0*1024) /* None */
#elif defined(CONFIG_ARCH_CHIP_SAMD20G14)
# define SAMD20 1 /* SAMD20 family */
# undef SAMD20E
# define SAMD20G 1 /* SAMD20G */
# undef SAMD20J
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (16*1024) /* 16KB */
# define SAMD2L2_SRAM0_SIZE (2*1024) /* 2KB */
# define SAMD2L2_LPRAM_SIZE (0*1024) /* None */
#elif defined(CONFIG_ARCH_CHIP_SAMD20G15)
# define SAMD20 1 /* SAMD20 family */
# undef SAMD20E
# define SAMD20G 1 /* SAMD20G */
# undef SAMD20J
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (32*1024) /* 32KB */
# define SAMD2L2_SRAM0_SIZE (4*1024) /* 4KB */
# define SAMD2L2_LPRAM_SIZE (0*1024) /* None */
#elif defined(CONFIG_ARCH_CHIP_SAMD20G16)
# define SAMD20 1 /* SAMD20 family */
# undef SAMD20E
# define SAMD20G 1 /* SAMD20G */
# undef SAMD20J
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (64*1024) /* 64KB */
# define SAMD2L2_SRAM0_SIZE (8*1024) /* 8KB */
# define SAMD2L2_LPRAM_SIZE (0*1024) /* None */
#elif defined(CONFIG_ARCH_CHIP_SAMD20G17)
# define SAMD20 1 /* SAMD20 family */
# undef SAMD20E
# define SAMD20G 1 /* SAMD20G */
# undef SAMD20J
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (128*1024) /* 128KB */
# define SAMD2L2_SRAM0_SIZE (16*1024) /* 16KB */
# define SAMD2L2_LPRAM_SIZE (0*1024) /* None */
#elif defined(CONFIG_ARCH_CHIP_SAMD20G18)
# define SAMD20 1 /* SAMD20 family */
# undef SAMD20E
# define SAMD20G 1 /* SAMD20G */
# undef SAMD20J
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (256*1024) /* 256KB */
# define SAMD2L2_SRAM0_SIZE (32*1024) /* 32KB */
# define SAMD2L2_LPRAM_SIZE (0*1024) /* None */
#elif defined(CONFIG_ARCH_CHIP_SAMD20J14)
# define SAMD20 1 /* SAMD20 family */
# undef SAMD20E
# undef SAMD20G
# define SAMD20J 1 /* SAMD20J */
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (16*1024) /* 16KB */
# define SAMD2L2_SRAM0_SIZE (2*1024) /* 2KB */
# define SAMD2L2_LPRAM_SIZE (0*1024) /* None */
#elif defined(CONFIG_ARCH_CHIP_SAMD20J15)
# define SAMD20 1 /* SAMD20 family */
# undef SAMD20E
# undef SAMD20G
# define SAMD20J 1 /* SAMD20J */
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (32*1024) /* 32KB */
# define SAMD2L2_SRAM0_SIZE (4*1024) /* 4KB */
# define SAMD2L2_LPRAM_SIZE (0*1024) /* None */
#elif defined(CONFIG_ARCH_CHIP_SAMD20J16)
# define SAMD20 1 /* SAMD20 family */
# undef SAMD20E
# undef SAMD20G
# define SAMD20J 1 /* SAMD20J */
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (64*1024) /* 64KB */
# define SAMD2L2_SRAM0_SIZE (8*1024) /* 8KB */
# define SAMD2L2_LPRAM_SIZE (0*1024) /* None */
#elif defined(CONFIG_ARCH_CHIP_SAMD20J17)
# define SAMD20 1 /* SAMD20 family */
# undef SAMD20E
# undef SAMD20G
# define SAMD20J 1 /* SAMD20J */
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (128*1024) /* 128KB */
# define SAMD2L2_SRAM0_SIZE (16*1024) /* 16KB */
# define SAMD2L2_LPRAM_SIZE (0*1024) /* None */
#elif defined(CONFIG_ARCH_CHIP_SAMD20J18)
# define SAMD20 1 /* SAMD20 family */
# undef SAMD20E
# undef SAMD20G
# define SAMD20J 1 /* SAMD20J */
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (256*1024) /* 256KB */
# define SAMD2L2_SRAM0_SIZE (32*1024) /* 32KB */
# define SAMD2L2_LPRAM_SIZE (0*1024) /* None */
#else
# undef SAMD20 /* Not SAMD20 family */
# undef SAMD20E
# undef SAMD20G
# undef SAMD20J
#endif
/* SAMD20 Peripherals */
#if defined(SAMD20E)
# define SAMD2L2_NEVENTS 8 /* 8 event channels */
# define SAMD2L2_NTC 6 /* 6 Timer/counters */
# define SAMD2L2_NTCOUT 2 /* 2 TC output channels */
# define SAMD2L2_NTCC 0 /* No TC control channels */
# define SAMD2L2_NTCCOUT 0 /* No TCC output channels */
# define SAMD2L2_NDMACHAN 0 /* No DMA channels */
# define SAMD2L2_NUSBIF 0 /* No USB interface */
# define SAMD2L2_NAES 0 /* No AES engine */
# define SAMD2L2_NCCL 0 /* No Counfigurable Custom Logic */
# define SAMD2L2_NTRNG 0 /* No True random number generator */
# define SAMD2L2_NSERCOM 4 /* 4 SERCOM */
# define SAMD2L2_NI2S 0 /* No I2S */
# define SAMD2L2_NADC 10 /* 10 ADC channels */
# define SAMD2L2_NCMP 2 /* 2 Comparators */
# define SAMD2L2_NDAC 1 /* 1 DAC channel */
# define SAMD2L2_NOPAMP 0 /* No OpAmps */
# define SAMD2L2_RTC 1 /* Have RTC */
# define SAMD2L2_NALARMS 1 /* 1 RTC alarm */
# define SAMD2L2_NRTCMP 1 /* RTC compare: 1 32-bit/2 16-bit */
# define SAMD2L2_NEXTINT 16 /* 16 External interrupts */
# define SAMD2L2_NPTCX 10 /* PTC X */
# define SAMD2L2_NPTCY 6 /* PTC Y */
# define SAMD2L2_WDT 1 /* Have watchdog timer */
#elif defined(SAMD20G)
# define SAMD2L2_NEVENTS 8 /* 8 event channels */
# define SAMD2L2_NTC 6 /* 6 Timer/counters */
# define SAMD2L2_NTCOUT 2 /* 2 TC output channels */
# define SAMD2L2_NTCC 0 /* No TC control channels */
# define SAMD2L2_NTCCOUT 0 /* No TCC output channels */
# define SAMD2L2_NDMACHAN 0 /* No DMA channels */
# define SAMD2L2_NUSBIF 0 /* No USB interface */
# define SAMD2L2_NAES 0 /* No AES engine */
# define SAMD2L2_NCCL 0 /* No Counfigurable Custom Logic */
# define SAMD2L2_NTRNG 0 /* No True random number generator */
# define SAMD2L2_NSERCOM 6 /* 6 SERCOM */
# define SAMD2L2_NI2S 0 /* No I2S */
# define SAMD2L2_NADC 15 /* 14 ADC channels */
# define SAMD2L2_NCMP 2 /* 2 Comparators */
# define SAMD2L2_NDAC 1 /* 1 DAC channel */
# define SAMD2L2_NOPAMP 0 /* No OpAmps */
# define SAMD2L2_RTC 1 /* Have RTC */
# define SAMD2L2_NALARMS 1 /* 1 RTC alarm */
# define SAMD2L2_NRTCMP 1 /* RTC compare: 1 32-bit/2 16-bit */
# define SAMD2L2_NEXTINT 16 /* 16 External interrupts */
# define SAMD2L2_NPTCX 12 /* PTC X */
# define SAMD2L2_NPTCY 10 /* PTC Y */
# define SAMD2L2_WDT 1 /* Have watchdog timer */
#elif defined(SAMD20J)
# define SAMD2L2_NEVENTS 8 /* 8 event channels */
# define SAMD2L2_NTC 8 /* 8 Timer/counters */
# define SAMD2L2_NTCOUT 2 /* 2 TC output channels */
# define SAMD2L2_NTCC 0 /* No TC control channels */
# define SAMD2L2_NTCCOUT 0 /* No TCC output channels */
# define SAMD2L2_NDMACHAN 0 /* No DMA channels */
# define SAMD2L2_NUSBIF 0 /* No USB interface */
# define SAMD2L2_NAES 0 /* No AES engine */
# define SAMD2L2_NCCL 0 /* No Counfigurable Custom Logic */
# define SAMD2L2_NTRNG 0 /* No True random number generator */
# define SAMD2L2_NSERCOM 6 /* 6 SERCOM */
# define SAMD2L2_NI2S 0 /* No I2S */
# define SAMD2L2_NADC 20 /* 20 ADC channels */
# define SAMD2L2_NCMP 2 /* 2 Comparators */
# define SAMD2L2_NDAC 1 /* 1 DAC channel */
# define SAMD2L2_NOPAMP 0 /* No OpAmps */
# define SAMD2L2_RTC 1 /* Have RTC */
# define SAMD2L2_NALARMS 1 /* 1 RTC alarm */
# define SAMD2L2_NRTCMP 1 /* RTC compare: 1 32-bit/2 16-bit */
# define SAMD2L2_NEXTINT 16 /* 16 External interrupts */
# define SAMD2L2_NPTCX 16 /* PTC X */
# define SAMD2L2_NPTCY 16 /* PTC Y */
# define SAMD2L2_WDT 1 /* Have watchdog timer */
#endif
/* SAMD21 Family ************************************************************/
/* FEATURE SAM D21J SAM D21G SAM D21E
* ------------------- ------------------ ------------------ --------
* No. of pins 64 48 32
* Flash 256/128/64/32/16KB 256/128/64/32KB 256/128/64/32KB
* SRAM 32/16/8/4/2KB 32/16/8/4/2KB 32/16/8/4KB
* Max. Freq. 48MHz 48MHz 48MHz
* Event channels 12 12 12
* Timer/counters 5 3 3
* TC output channels 2 2 2
* T/C Control 3 3 3
* TCC output channels 2 2 2
* TCC waveform output 8/4/2 8/4/2 6/4/2
* DMA channels 12 12 12
* USB interface 1 1 1
* SERCOM 6 6 4
* I2S 1 1 1
* ADC channels 20 14 10
* Comparators 2 2 2
* DAC channels 1 1 1
* RTC Yes Yes Yes
* RTC alarms 1 1 1
* RTC compare 1 32-bit/ 1 32-bit/ 1 32-bit/
* 2 16-bit 2 16-bit 2 16-bit
* External interrupts 16 16 16
* PTC X an Y 16x16 12x10 10x6
* Packages QFN/TQFP QFN/TQFP/WLCSP QFN/TQFP/UFBGA
* Oscillators XOSC32, XOSC, OSC32K, OSCULP32K, OSC8M,
* DFLL48M, and FDPLL96M
* SW Debug interface Yes Yes Yes
* Watchdog timer Yes Yes Yes
*/
#if defined(CONFIG_ARCH_CHIP_SAMD21E15A) || defined(CONFIG_ARCH_CHIP_SAMD21E15B)
# define SAMD21 1 /* SAMD21 family */
# define SAMD21E 1 /* SAMD21E */
# undef SAMD21G
# undef SAMD21J
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (32*1024) /* 32KB */
# define SAMD2L2_SRAM0_SIZE (4*1024) /* 4KB */
# define SAMD2L2_LPRAM_SIZE (0*1024) /* None */
# if defined(CONFIG_ARCH_CHIP_SAMD21E15A)
# define SAMD2L2_FLASHRWW_SIZE (0*1024) /* None */
# else
# define SAMD2L2_FLASHRWW_SIZE (1*1024) /* 1KB */
# endif
#elif defined(CONFIG_ARCH_CHIP_SAMD21E16A) || defined(CONFIG_ARCH_CHIP_SAMD21E16B)
# define SAMD21 1 /* SAMD21 family */
# define SAMD21E 1 /* SAMD21E */
# undef SAMD21G
# undef SAMD21J
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (64*1024) /* 64KB */
# define SAMD2L2_SRAM0_SIZE (8*1024) /* 8KB */
# define SAMD2L2_LPRAM_SIZE (0*1024) /* None */
# if defined(CONFIG_ARCH_CHIP_SAMD21E16A)
# define SAMD2L2_FLASHRWW_SIZE (0*1024) /* None */
# else
# define SAMD2L2_FLASHRWW_SIZE (2*1024) /* 2KB */
# endif
#elif defined(CONFIG_ARCH_CHIP_SAMD21E17A)
# define SAMD21 1 /* SAMD21 family */
# define SAMD21E 1 /* SAMD21E */
# undef SAMD21G
# undef SAMD21J
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (128*1024) /* 128KB */
# define SAMD2L2_FLASHRWW_SIZE (0*1024) /* None */
# define SAMD2L2_SRAM0_SIZE (16*1024) /* 16KB */
# define SAMD2L2_LPRAM_SIZE (0*1024) /* None */
#elif defined(CONFIG_ARCH_CHIP_SAMD21E18A)
# define SAMD21 1 /* SAMD21 family */
# define SAMD21E 1 /* SAMD21E */
# undef SAMD21G
# undef SAMD21J
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (256*1024) /* 256KB */
# define SAMD2L2_FLASHRWW_SIZE (0*1024) /* None */
# define SAMD2L2_SRAM0_SIZE (32*1024) /* 32KB */
# define SAMD2L2_LPRAM_SIZE (0*1024) /* None */
#elif defined(CONFIG_ARCH_CHIP_SAMD21G15A) || defined(CONFIG_ARCH_CHIP_SAMD21G15B)
# define SAMD21 1 /* SAMD21 family */
# undef SAMD21E
# define SAMD21G 1 /* SAMD21G */
# undef SAMD21J
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (32*1024) /* 32KB */
# define SAMD2L2_SRAM0_SIZE (4*1024) /* 4KB */
# define SAMD2L2_LPRAM_SIZE (0*1024) /* None */
# if defined(CONFIG_ARCH_CHIP_SAMD21G15A)
# define SAMD2L2_FLASHRWW_SIZE (0*1024) /* None */
# else
# define SAMD2L2_FLASHRWW_SIZE (1*1024) /* 1KB */
# endif
#elif defined(CONFIG_ARCH_CHIP_SAMD21G16A) || defined(CONFIG_ARCH_CHIP_SAMD21G16B)
# define SAMD21 1 /* SAMD21 family */
# undef SAMD21E
# define SAMD21G 1 /* SAMD21G */
# undef SAMD21J
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (64*1024) /* 64KB */
# define SAMD2L2_SRAM0_SIZE (8*1024) /* 8KB */
# define SAMD2L2_LPRAM_SIZE (0*1024) /* None */
# if defined(CONFIG_ARCH_CHIP_SAMD21G16A)
# define SAMD2L2_FLASHRWW_SIZE (0*1024) /* None */
# else
# define SAMD2L2_FLASHRWW_SIZE (2*1024) /* 2KB */
# endif
#elif defined(CONFIG_ARCH_CHIP_SAMD21G17A)
# define SAMD21 1 /* SAMD21 family */
# undef SAMD21E
# define SAMD21G 1 /* SAMD21G */
# undef SAMD21J
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (128*1024) /* 128KB */
# define SAMD2L2_FLASHRWW_SIZE (0*1024) /* None */
# define SAMD2L2_SRAM0_SIZE (16*1024) /* 16KB */
# define SAMD2L2_LPRAM_SIZE (0*1024) /* None */
#elif defined(CONFIG_ARCH_CHIP_SAMD21G18A)
# define SAMD21 1 /* SAMD21 family */
# undef SAMD21E
# define SAMD21G 1 /* SAMD21G */
# undef SAMD21J
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (256*1024) /* 256KB */
# define SAMD2L2_FLASHRWW_SIZE (0*1024) /* None */
# define SAMD2L2_SRAM0_SIZE (32*1024) /* 32KB */
# define SAMD2L2_LPRAM_SIZE (0*1024) /* None */
#elif defined(CONFIG_ARCH_CHIP_SAMD21J15A) || defined(CONFIG_ARCH_CHIP_SAMD21J15B)
# define SAMD21 1 /* SAMD21 family */
# undef SAMD21E
# undef SAMD21G
# define SAMD21J 1 /* SAMD21J */
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (32*1024) /* 32KB */
# define SAMD2L2_SRAM0_SIZE (4*1024) /* 4KB */
# define SAMD2L2_LPRAM_SIZE (0*1024) /* None */
# if defined(CONFIG_ARCH_CHIP_SAMD21J15A)
# define SAMD2L2_FLASHRWW_SIZE (0*1024) /* None */
# else
# define SAMD2L2_FLASHRWW_SIZE (1*1024) /* 1KB */
# endif
#elif defined(CONFIG_ARCH_CHIP_SAMD21J16A) || defined(CONFIG_ARCH_CHIP_SAMD21J16B)
# define SAMD21 1 /* SAMD21 family */
# undef SAMD21E
# undef SAMD21G
# define SAMD21J 1 /* SAMD21J */
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (64*1024) /* 64KB */
# define SAMD2L2_SRAM0_SIZE (8*1024) /* 8KB */
# define SAMD2L2_LPRAM_SIZE (0*1024) /* None */
# if defined(CONFIG_ARCH_CHIP_SAMD21J16A)
# define SAMD2L2_FLASHRWW_SIZE (0*1024) /* None */
# else
# define SAMD2L2_FLASHRWW_SIZE (2*1024) /* 2KB */
# endif
#elif defined(CONFIG_ARCH_CHIP_SAMD21J17A)
# define SAMD21 1 /* SAMD21 family */
# undef SAMD21E
# undef SAMD21G
# define SAMD21J 1 /* SAMD21J */
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (128*1024) /* 128KB */
# define SAMD2L2_FLASHRWW_SIZE (0*1024) /* None */
# define SAMD2L2_SRAM0_SIZE (16*1024) /* 16KB */
# define SAMD2L2_LPRAM_SIZE (0*1024) /* None */
#elif defined(CONFIG_ARCH_CHIP_SAMD21J18A)
# define SAMD21 1 /* SAMD21 family */
# undef SAMD21E
# undef SAMD21G
# define SAMD21J 1 /* SAMD21J */
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (256*1024) /* 256KB */
# define SAMD2L2_FLASHRWW_SIZE (0*1024) /* None */
# define SAMD2L2_SRAM0_SIZE (32*1024) /* 32KB */
# define SAMD2L2_LPRAM_SIZE (0*1024) /* None */
#else
# undef SAMD21 /* Not SAMD21 family */
# undef SAMD21E
# undef SAMD21G
# undef SAMD21J
#endif
#if defined(SAMD21E)
# define SAMD2L2_NEVENTS 12 /* 12 event channels */
# define SAMD2L2_NTC 3 /* 3 Timer/counters */
# define SAMD2L2_NTCOUT 2 /* 2 TC output channels */
# define SAMD2L2_NTCC 3 /* 3 TC control channels */
# define SAMD2L2_NTCCOUT 2 /* 2 TCC output channels */
# define SAMD2L2_TCC_NWAVEFORMS 8 /* Each TCC has a different number of outputs */
# define SAMD2L2_NDMACHAN 12 /* 12 DMA channels */
# define SAMD2L2_NUSBIF 1 /* 1 USB interface */
# define SAMD2L2_NAES 1 /* 1 AES engine */
# define SAMD2L2_NCCL 4 /* 4 Counfigurable Custom Logic */
# define SAMD2L2_NTRNG 1 /* 1 True random number generator */
# define SAMD2L2_NSERCOM 4 /* 4 SERCOM */
# define SAMD2L2_NI2S 1 /* 1 I2S */
# define SAMD2L2_NADC 10 /* 10 ADC channels */
# define SAMD2L2_NCMP 2 /* 2 Comparators */
# define SAMD2L2_NDAC 1 /* 1 DAC channel */
# define SAMD2L2_NOPAMP 3 /* 3 OpAmps */
# define SAMD2L2_RTC 1 /* Have RTC */
# define SAMD2L2_NALARMS 1 /* 1 RTC alarm */
# define SAMD2L2_NRTCMP 1 /* RTC compare: 1 32-bit/2 16-bit */
# define SAMD2L2_NEXTINT 16 /* 16 External interrupts */
# define SAMD2L2_NPTCX 10 /* 10x6 */
# define SAMD2L2_NPTCY 6 /* 10x6*/
# define SAMD2L2_WDT 1 /* Have watchdog timer */
#elif defined(SAMD21G)
# define SAMD2L2_NEVENTS 12 /* 12 event channels */
# define SAMD2L2_NTC 3 /* 3 Timer/counters */
# define SAMD2L2_NTCOUT 2 /* 2 TC output channels */
# define SAMD2L2_NTCC 3 /* 3 TC control channels */
# define SAMD2L2_NTCCOUT 2 /* 2 TCC output channels */
# define SAMD2L2_TCC_NWAVEFORMS 8 /* Each TCC has a different number of outputs */
# define SAMD2L2_NDMACHAN 12 /* 12 DMA channels */
# define SAMD2L2_NUSBIF 1 /* 1 USB interface */
# define SAMD2L2_NAES 1 /* 1 AES engine */
# define SAMD2L2_NCCL 4 /* 4 Counfigurable Custom Logic */
# define SAMD2L2_NTRNG 1 /* 1 True random number generator */
# define SAMD2L2_NSERCOM 6 /* 6 SERCOM */
# define SAMD2L2_NI2S 1 /* 1 I2S */
# define SAMD2L2_NADC 14 /* 14 ADC channels */
# define SAMD2L2_NCMP 2 /* 2 Comparators */
# define SAMD2L2_NDAC 1 /* 1 DAC channel */
# define SAMD2L2_NOPAMP 3 /* 3 OpAmps */
# define SAMD2L2_RTC 1 /* Have RTC */
# define SAMD2L2_NALARMS 1 /* 1 RTC alarm */
# define SAMD2L2_NRTCMP 1 /* RTC compare: 1 32-bit/2 16-bit */
# define SAMD2L2_NEXTINT 16 /* 16 External interrupts */
# define SAMD2L2_NPTCX 12 /* 12x10 */
# define SAMD2L2_NPTCY 10 /* 12x10 */
# define SAMD2L2_WDT 1 /* Have watchdog timer */
#elif defined(SAMD21J)
# define SAMD2L2_NEVENTS 12 /* 12 event channels */
# define SAMD2L2_NTC 5 /* 5 Timer/counters */
# define SAMD2L2_NTCOUT 2 /* 2 TC output channels */
# define SAMD2L2_NTCC 3 /* 3 TC control channels */
# define SAMD2L2_NTCCOUT 2 /* 2 TCC output channels */
# define SAMD2L2_TCC_NWAVEFORMS 8 /* Each TCC has a different number of outputs */
# define SAMD2L2_NDMACHAN 12 /* 12 DMA channels */
# define SAMD2L2_NUSBIF 1 /* 1 USB interface */
# define SAMD2L2_NAES 1 /* 1 AES engine */
# define SAMD2L2_NCCL 4 /* 4 Counfigurable Custom Logic */
# define SAMD2L2_NTRNG 1 /* 1 True random number generator */
# define SAMD2L2_NSERCOM 6 /* 6 SERCOM */
# define SAMD2L2_NI2S 1 /* 1 I2S */
# define SAMD2L2_NADC 20 /* 20 ADC channels */
# define SAMD2L2_NCMP 2 /* 2 Comparators */
# define SAMD2L2_NDAC 1 /* 1 DAC channel */
# define SAMD2L2_NOPAMP 3 /* 3 OpAmps */
# define SAMD2L2_RTC 1 /* Have RTC */
# define SAMD2L2_NALARMS 1 /* 1 RTC alarm */
# define SAMD2L2_NRTCMP 1 /* RTC compare: 1 32-bit/2 16-bit */
# define SAMD2L2_NEXTINT 16 /* 16 External interrupts */
# define SAMD2L2_NPTCX 16 /* 16x16 */
# define SAMD2L2_NPTCY 16 /* 16x16*/
# define SAMD2L2_WDT 1 /* Have watchdog timer */
#endif
/* SAML21 Family ************************************************************/
/* FEATURE SAM L21J SAM L21G SAM L21E
* ------------------- ------------------ ------------------ --------
* No. of pins 64 48 32
* Flash 256/128/64KB 256/128/64KB 256/128/64/32KB
* Flash RWW 8/4/2KB 8/4/2KB 8/4/2/1KB
* SRAM 32/16/8KB 32/16/8KB 32/16/8/4KB
* Max. Freq. 48MHz 48MHz 48MHz
* Event channels 12 12 12
* Timer/counters 5 3 3
* TC output channels 2 2 2
* T/C Control 3 3 3
* TCC output channels 2 2 2
* TCC waveform output 8/4/2 8/4/2 6/4/2
* DMA channels 16 16 16
* USB interface 1 1 1
* AES engine 1 1 1
* CCLs 4 4 4
* TRNG 1 1 1
* SERCOM 6 6 4
* ADC channels 20 14 10
* Comparators 2 2 2
* DAC channels 2 2 2
* OPAMP 3 3 3
* RTC Yes Yes Yes
* RTC alarms 1 1 1
* RTC compare 1 32-bit/ 1 32-bit/ 1 32-bit/
* 2 16-bit 2 16-bit 2 16-bit
* External interrupts 16 16 16
* PTC X an Y 12x16 8x12 6x10
* 16x12 12x8 10x6
* Packages QFN/TQFP QFN/TQFP QFN/TQFP
* Oscillators XOSC32, XOSC, OSC32K, OSCULP32K,
* OSC16M, DFLL48M, and FDPLL96M
* SW Debug interface Yes Yes Yes
* Watchdog timer Yes Yes Yes
*/
#if defined(CONFIG_ARCH_CHIP_SAML21E15)
# define SAML21 1 /* SAML21 family */
# define SAML21E 1 /* SAML21E */
# undef SAML21G
# undef SAML21J
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (32*1024) /* 32KB */
# define SAMD2L2_FLASHRWW_SIZE (1*1024) /* 1KB */
# define SAMD2L2_SRAM0_SIZE (4*1024) /* 4KB */
# define SAMD2L2_LPRAM_SIZE (2*1024) /* 2KB */
/* TCC waveform outputs */
# define SAMD2L2_TCC_NWAVEFORMS 2 /* 2 TCC waveform outputs */
#elif defined(CONFIG_ARCH_CHIP_SAML21E16)
# define SAML21 1 /* SAML21 family */
# define SAML21E 1 /* SAML21E */
# undef SAML21G
# undef SAML21J
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (64*1024) /* 64KB */
# define SAMD2L2_FLASHRWW_SIZE (2*1024) /* 2KB */
# define SAMD2L2_SRAM0_SIZE (8*1024) /* 8KB */
# define SAMD2L2_LPRAM_SIZE (4*1024) /* 4KB */
/* TCC waveform outputs */
# define SAMD2L2_TCC_NWAVEFORMS 2 /* 2 TCC waveform outputs */
#elif defined(CONFIG_ARCH_CHIP_SAML21E17)
# define SAML21 1 /* SAML21 family */
# define SAML21E 1 /* SAML21E */
# undef SAML21G
# undef SAML21J
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (128*1024) /* 128KB */
# define SAMD2L2_FLASHRWW_SIZE (4*1024) /* 4KB */
# define SAMD2L2_SRAM0_SIZE (16*1024) /* 16KB */
# define SAMD2L2_LPRAM_SIZE (8*1024) /* 8KB */
/* TCC waveform outputs */
# define SAMD2L2_TCC_NWAVEFORMS 4 /* 4 TCC waveform outputs */
#elif defined(CONFIG_ARCH_CHIP_SAML21E18)
# define SAML21 1 /* SAML21 family */
# define SAML21E 1 /* SAML21E */
# undef SAML21G
# undef SAML21J
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (256*1024) /* 256KB */
# define SAMD2L2_FLASHRWW_SIZE (8*1024) /* 8KB */
# define SAMD2L2_SRAM0_SIZE (32*1024) /* 32KB */
# define SAMD2L2_LPRAM_SIZE (8*1024) /* 8KB */
/* TCC waveform outputs */
# define SAMD2L2_TCC_NWAVEFORMS 6 /* 6 TCC waveform outputs */
#elif defined(CONFIG_ARCH_CHIP_SAML21G16)
# define SAML21 1 /* SAML21 family */
# undef SAML21E
# define SAML21G 1 /* SAML21G */
# undef SAML21J
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (64*1024) /* 64KB */
# define SAMD2L2_FLASHRWW_SIZE (2*1024) /* 2KB */
# define SAMD2L2_SRAM0_SIZE (8*1024) /* 8KB */
# define SAMD2L2_LPRAM_SIZE (4*1024) /* 4KB */
/* TCC waveform outputs */
# define SAMD2L2_TCC_NWAVEFORMS 2 /* 2 TCC waveform outputs */
#elif defined(CONFIG_ARCH_CHIP_SAML21G17)
# define SAML21 1 /* SAML21 family */
# undef SAML21E
# define SAML21G 1 /* SAML21G */
# undef SAML21J
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (128*1024) /* 128KB */
# define SAMD2L2_FLASHRWW_SIZE (4*1024) /* 4KB */
# define SAMD2L2_SRAM0_SIZE (16*1024) /* 16KB */
# define SAMD2L2_LPRAM_SIZE (8*1024) /* 8KB */
/* TCC waveform outputs */
# define SAMD2L2_TCC_NWAVEFORMS 4 /* 4 TCC waveform outputs */
#elif defined(CONFIG_ARCH_CHIP_SAML21G18)
# define SAML21 1 /* SAML21 family */
# undef SAML21E
# define SAML21G 1 /* SAML21G */
# undef SAML21J
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (256*1024) /* 256KB */
# define SAMD2L2_FLASHRWW_SIZE (8*1024) /* 8KB */
# define SAMD2L2_SRAM0_SIZE (32*1024) /* 32KB */
# define SAMD2L2_LPRAM_SIZE (8*1024) /* 8KB */
/* TCC waveform outputs */
# define SAMD2L2_TCC_NWAVEFORMS 8 /* 8 TCC waveform outputs */
#elif defined(CONFIG_ARCH_CHIP_SAML21J16)
# define SAML21 1 /* SAML21 family */
# undef SAML21E
# undef SAML21G
# define SAML21J 1 /* SAML21J */
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (64*1024) /* 64KB */
# define SAMD2L2_FLASHRWW_SIZE (2*1024) /* 2KB */
# define SAMD2L2_SRAM0_SIZE (8*1024) /* 8KB */
# define SAMD2L2_LPRAM_SIZE (8*1024) /* 4KB */
/* TCC waveform outputs */
# define SAMD2L2_TCC_NWAVEFORMS 2 /* 2 TCC waveform outputs */
#elif defined(CONFIG_ARCH_CHIP_SAML21J17)
# define SAML21 1 /* SAML21 family */
# undef SAML21E
# undef SAML21G
# define SAML21J 1 /* SAML21J */
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (128*1024) /* 128KB */
# define SAMD2L2_FLASHRWW_SIZE (4*1024) /* 4KB */
# define SAMD2L2_SRAM0_SIZE (16*1024) /* 16KB */
# define SAMD2L2_LPRAM_SIZE (8*1024) /* 8KB */
/* TCC waveform outputs */
# define SAMD2L2_TCC_NWAVEFORMS 4 /* 4 TCC waveform outputs */
#elif defined(CONFIG_ARCH_CHIP_SAML21J18)
# define SAML21 1 /* SAML21 family */
# undef SAML21E
# undef SAML21G
# define SAML21J 1 /* SAML21J */
/* Internal memory */
# define SAMD2L2_FLASH_SIZE (256*1024) /* 256KB */
# define SAMD2L2_FLASHRWW_SIZE (8*1024) /* 8KB */
# define SAMD2L2_SRAM0_SIZE (32*1024) /* 32KB */
# define SAMD2L2_LPRAM_SIZE (8*1024) /* 8KB */
/* TCC waveform outputs */
# define SAMD2L2_TCC_NWAVEFORMS 8 /* 8 TCC waveform outputs */
#else
# undef SAML21 /* Not SAML21 family */
# undef SAML21E
# undef SAML21G
# undef SAML21J
#endif
#if defined(SAML21E)
# define SAMD2L2_NEVENTS 12 /* 12 event channels */
# define SAMD2L2_NTC 3 /* 3 Timer/counters */
# define SAMD2L2_NTCOUT 2 /* 2 TC output channels */
# define SAMD2L2_NTCC 3 /* 3 TC control channels */
# define SAMD2L2_NTCCOUT 2 /* 2 TCC output channels */
# define SAMD2L2_NDMACHAN 16 /* 16 DMA channels */
# define SAMD2L2_NUSBIF 1 /* 1 USB interface */
# define SAMD2L2_NAES 1 /* 1 AES engine */
# define SAMD2L2_NCCL 4 /* 4 Counfigurable Custom Logic */
# define SAMD2L2_NTRNG 1 /* 1 True random number generator */
# define SAMD2L2_NSERCOM 4 /* 4 SERCOM */
# define SAMD2L2_NI2S 0 /* No I2S */
# define SAMD2L2_NADC 10 /* 10 ADC channels */
# define SAMD2L2_NCMP 2 /* 2 Comparators */
# define SAMD2L2_NDAC 2 /* 2 DAC channels */
# define SAMD2L2_NOPAMP 3 /* 3 OpAmps */
# define SAMD2L2_RTC 1 /* Have RTC */
# define SAMD2L2_NALARMS 1 /* 1 RTC alarm */
# define SAMD2L2_NRTCMP 1 /* RTC compare: 1 32-bit/2 16-bit */
# define SAMD2L2_NEXTINT 16 /* 16 External interrupts */
# define SAMD2L2_NPTCX 10 /* PTC X 6 or 10 */
# define SAMD2L2_NPTCY 10 /* PTC Y 6 or 10*/
# define SAMD2L2_WDT 1 /* Have watchdog timer */
#elif defined(SAML21G)
# define SAMD2L2_NEVENTS 12 /* 12 event channels */
# define SAMD2L2_NTC 3 /* 3 Timer/counters */
# define SAMD2L2_NTCOUT 2 /* 2 TC output channels */
# define SAMD2L2_NTCC 3 /* 3 TC control channels */
# define SAMD2L2_NTCCOUT 2 /* 2 TCC output channels */
# define SAMD2L2_NDMACHAN 16 /* 16 DMA channels */
# define SAMD2L2_NUSBIF 1 /* 1 USB interface */
# define SAMD2L2_NAES 1 /* 1 AES engine */
# define SAMD2L2_NCCL 4 /* 4 Counfigurable Custom Logic */
# define SAMD2L2_NTRNG 1 /* 1 True random number generator */
# define SAMD2L2_NSERCOM 6 /* 6 SERCOM */
# define SAMD2L2_NI2S 0 /* No I2S */
# define SAMD2L2_NADC 14 /* 14 ADC channels */
# define SAMD2L2_NCMP 2 /* 2 Comparators */
# define SAMD2L2_NDAC 2 /* 2 DAC channels */
# define SAMD2L2_NOPAMP 3 /* 3 OpAmps */
# define SAMD2L2_RTC 1 /* Have RTC */
# define SAMD2L2_NALARMS 1 /* 1 RTC alarm */
# define SAMD2L2_NRTCMP 1 /* RTC compare: 1 32-bit/2 16-bit */
# define SAMD2L2_NEXTINT 16 /* 16 External interrupts */
# define SAMD2L2_NPTCX 12 /* PTC X 8 or 12 */
# define SAMD2L2_NPTCY 12 /* PTC Y 8 or 12*/
# define SAMD2L2_WDT 1 /* Have watchdog timer */
#elif defined(SAML21J)
# define SAMD2L2_NEVENTS 12 /* 12 event channels */
# define SAMD2L2_NTC 5 /* 5 Timer/counters */
# define SAMD2L2_NTCOUT 2 /* 2 TC output channels */
# define SAMD2L2_NTCC 3 /* 3 TC control channels */
# define SAMD2L2_NTCCOUT 2 /* 2 TCC output channels */
# define SAMD2L2_NDMACHAN 16 /* 16 DMA channels */
# define SAMD2L2_NUSBIF 1 /* 1 USB interface */
# define SAMD2L2_NAES 1 /* 1 AES engine */
# define SAMD2L2_NCCL 4 /* 4 Counfigurable Custom Logic */
# define SAMD2L2_NTRNG 1 /* 1 True random number generator */
# define SAMD2L2_NSERCOM 6 /* 6 SERCOM */
# define SAMD2L2_NI2S 0 /* No I2S */
# define SAMD2L2_NADC 20 /* 20 ADC channels */
# define SAMD2L2_NCMP 2 /* 2 Comparators */
# define SAMD2L2_NDAC 2 /* 2 DAC channels */
# define SAMD2L2_NOPAMP 3 /* 3 OpAmps */
# define SAMD2L2_RTC 1 /* Have RTC */
# define SAMD2L2_NALARMS 1 /* 1 RTC alarm */
# define SAMD2L2_NRTCMP 1 /* RTC compare: 1 32-bit/2 16-bit */
# define SAMD2L2_NEXTINT 16 /* 16 External interrupts */
# define SAMD2L2_NPTCX 16 /* PTC X 12 or 16 */
# define SAMD2L2_NPTCY 16 /* PTC Y 12 or 16*/
# define SAMD2L2_WDT 1 /* Have watchdog timer */
#endif
/* NVIC priority levels *****************************************************/
/* Each priority field holds a priority value, 0-3. The lower the value, the
* greater the priority of the corresponding interrupt. The processor
* implements only bits[7:6] of each field, bits[5:0] read as zero and ignore
* writes.
*/
#define NVIC_SYSH_PRIORITY_MIN 0xc0 /* All bits[7:6] set is minimum priority */
#define NVIC_SYSH_PRIORITY_DEFAULT 0x80 /* Midpoint is the default */
#define NVIC_SYSH_PRIORITY_MAX 0x00 /* Zero is maximum priority */
#define NVIC_SYSH_PRIORITY_STEP 0x40 /* Five bits of interrupt priority used */
/****************************************************************************
* Public Types
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Public Functions Prototypes
****************************************************************************/
#endif /* __ARCH_ARM_INCLUDE_SAMD2L2_CHIP_H */
|
7e72a4c38c23234431e9bc963b54e474b5705268
|
b14db9403f921df7ff32b884de73dad877243552
|
/nvidia-include/cpuopsys.h
|
ee911b77f6971bcb82e97d2a69ff81838cd4b5c4
|
[
"MIT"
] |
permissive
|
elFarto/nvidia-vaapi-driver
|
a91d91e927779ea9c59a52b0b1a4bd3a44924127
|
cd54d4029490d6703de5a9080f1475e40efc242a
|
refs/heads/master
| 2023-09-04T11:47:26.834407
| 2023-08-26T20:47:20
| 2023-08-26T20:47:20
| 428,422,859
| 951
| 60
|
NOASSERTION
| 2023-09-11T07:11:32
| 2021-11-15T21:11:36
|
C
|
UTF-8
|
C
| false
| false
| 11,774
|
h
|
cpuopsys.h
|
/*
* SPDX-FileCopyrightText: Copyright (c) 2018-2018 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* 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.
*/
/*! \brief
* Define compile time symbols for CPU type and operating system type.
* This file should only contain preprocessor commands so that
* there are no dependencies on other files.
*
* cpuopsys.h
*
* Copyright (c) 2001, Nvidia Corporation. All rights reserved.
*/
/*!
* Uniform names are defined for compile time options to distinguish
* CPU types and Operating systems.
* Distinctions between CPU and OpSys should be orthogonal.
*
* These uniform names have initially been defined by keying off the
* makefile/build names defined for builds in the OpenGL group.
* Getting the uniform names defined for other builds may require
* different qualifications.
*
* The file is placed here to allow for the possibility of all driver
* components using the same naming convention for conditional compilation.
*/
#ifndef CPUOPSYS_H
#define CPUOPSYS_H
/*****************************************************************************/
/* Define all OS/CPU-Chip related symbols */
/* ***** WINDOWS variations */
#if defined(_WIN32) || defined(_WIN16)
# define NV_WINDOWS
# if defined(_WIN32_WINNT)
# define NV_WINDOWS_NT
# elif defined(_WIN32_WCE)
# define NV_WINDOWS_CE
# else
# define NV_WINDOWS_9X
# endif
#endif /* _WIN32 || defined(_WIN16) */
/* ***** Unix variations */
#if defined(__linux__) && !defined(NV_LINUX) && !defined(NV_VMWARE)
# define NV_LINUX
#endif /* defined(__linux__) */
#if defined(__VMWARE__) && !defined(NV_VMWARE)
# define NV_VMWARE
#endif /* defined(__VMWARE__) */
/* SunOS + gcc */
#if defined(__sun__) && defined(__svr4__) && !defined(NV_SUNOS)
# define NV_SUNOS
#endif /* defined(__sun__) && defined(__svr4__) */
/* SunOS + Sun Compiler (named SunPro, Studio or Forte) */
#if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
# define NV_SUNPRO_C
# define NV_SUNOS
#endif /* defined(_SUNPRO_C) || defined(__SUNPRO_CC) */
#if defined(__FreeBSD__) && !defined(NV_BSD)
# define NV_BSD
#endif /* defined(__FreeBSD__) */
/* XXXar don't define NV_UNIX on MacOSX or vxworks or QNX */
#if (defined(__unix__) || defined(__unix) || defined(__INTEGRITY) ) && !defined(nvmacosx) && !defined(vxworks) && !defined(NV_UNIX) && !defined(__QNX__) && !defined(__QNXNTO__)/* XXX until removed from Makefiles */
# define NV_UNIX
#endif /* defined(__unix__) */
#if (defined(__QNX__) || defined(__QNXNTO__)) && !defined(NV_QNX)
# define NV_QNX
#endif
#if (defined(__ANDROID__) || defined(ANDROID)) && !defined(NV_ANDROID)
# define NV_ANDROID
#endif
#if defined(DceCore) && !defined(NV_DCECORE)
# define NV_DCECORE
#endif
/* ***** Apple variations */
#if defined(macintosh) || defined(__APPLE__)
# define NV_MACINTOSH
# if defined(__MACH__)
# define NV_MACINTOSH_OSX
# else
# define NV_MACINTOSH_OS9
# endif
# if defined(__LP64__)
# define NV_MACINTOSH_64
# endif
#endif /* defined(macintosh) */
/* ***** VxWorks */
/* Tornado 2.21 is gcc 2.96 and #defines __vxworks. */
/* Tornado 2.02 is gcc 2.7.2 and doesn't define any OS symbol, so we rely on */
/* the build system #defining vxworks. */
#if defined(__vxworks) || defined(vxworks)
# define NV_VXWORKS
#endif
/* ***** Integrity OS */
#if defined(__INTEGRITY)
# if !defined(NV_INTEGRITY)
# define NV_INTEGRITY
# endif
#endif
/* ***** Processor type variations */
/* Note: The prefix NV_CPU_* is taken by Nvcm.h */
#if ((defined(_M_IX86) || defined(__i386__) || defined(__i386)) && !defined(NVCPU_X86)) /* XXX until removed from Makefiles */
/* _M_IX86 for windows, __i386__ for Linux (or any x86 using gcc) */
/* __i386 for Studio compiler on Solaris x86 */
# define NVCPU_X86 /* any IA32 machine (not x86-64) */
# define NVCPU_MIN_PAGE_SHIFT 12
#endif
#if defined(NV_LINUX) && defined(__ia64__)
# define NVCPU_IA64_LINUX /* any IA64 for Linux opsys */
#endif
#if defined(NVCPU_IA64_WINDOWS) || defined(NVCPU_IA64_LINUX) || defined(IA64)
# define NVCPU_IA64 /* any IA64 for any opsys */
#endif
#if (defined(NV_MACINTOSH) && !(defined(__i386__) || defined(__x86_64__))) || defined(__PPC__) || defined(__ppc)
# if defined(__powerpc64__) && defined(__LITTLE_ENDIAN__)
# ifndef NVCPU_PPC64LE
# define NVCPU_PPC64LE /* PPC 64-bit little endian */
# endif
# else
# ifndef NVCPU_PPC
# define NVCPU_PPC /* any non-PPC64LE PowerPC architecture */
# endif
# ifndef NV_BIG_ENDIAN
# define NV_BIG_ENDIAN
# endif
# endif
# define NVCPU_FAMILY_PPC
#endif
#if defined(__x86_64) || defined(AMD64) || defined(_M_AMD64)
# define NVCPU_X86_64 /* any x86-64 for any opsys */
#endif
#if defined(NVCPU_X86) || defined(NVCPU_X86_64)
# define NVCPU_FAMILY_X86
#endif
#if defined(__riscv) && (__riscv_xlen==64)
# define NVCPU_RISCV64
# if defined(__nvriscv)
# define NVCPU_NVRISCV64
# endif
#endif
#if defined(__arm__) || defined(_M_ARM)
/*
* 32-bit instruction set on, e.g., ARMv7 or AArch32 execution state
* on ARMv8
*/
# define NVCPU_ARM
# define NVCPU_MIN_PAGE_SHIFT 12
#endif
#if defined(__aarch64__) || defined(__ARM64__) || defined(_M_ARM64)
# define NVCPU_AARCH64 /* 64-bit A64 instruction set on ARMv8 */
# define NVCPU_MIN_PAGE_SHIFT 12
#endif
#if defined(NVCPU_ARM) || defined(NVCPU_AARCH64)
# define NVCPU_FAMILY_ARM
#endif
#if defined(__SH4__)
# ifndef NVCPU_SH4
# define NVCPU_SH4 /* Renesas (formerly Hitachi) SH4 */
# endif
# if defined NV_WINDOWS_CE
# define NVCPU_MIN_PAGE_SHIFT 12
# endif
#endif
/* For Xtensa processors */
#if defined(__XTENSA__)
# define NVCPU_XTENSA
# if defined(__XTENSA_EB__)
# define NV_BIG_ENDIAN
# endif
#endif
/*
* Other flavors of CPU type should be determined at run-time.
* For example, an x86 architecture with/without SSE.
* If it can compile, then there's no need for a compile time option.
* For some current GCC limitations, these may be fixed by using the Intel
* compiler for certain files in a Linux build.
*/
/* The minimum page size can be determined from the minimum page shift */
#if defined(NVCPU_MIN_PAGE_SHIFT)
#define NVCPU_MIN_PAGE_SIZE (1 << NVCPU_MIN_PAGE_SHIFT)
#endif
#if defined(NVCPU_IA64) || defined(NVCPU_X86_64) || \
defined(NV_MACINTOSH_64) || defined(NVCPU_AARCH64) || \
defined(NVCPU_PPC64LE) || defined(NVCPU_RISCV64)
# define NV_64_BITS /* all architectures where pointers are 64 bits */
#else
/* we assume 32 bits. I don't see a need for NV_16_BITS. */
#endif
/* For verification-only features not intended to be included in normal drivers */
#if (defined(NV_MODS) || defined(NV_GSP_MODS)) && defined(DEBUG) && !defined(DISABLE_VERIF_FEATURES)
#define NV_VERIF_FEATURES
#endif
/*
* New, safer family of #define's -- these ones use 0 vs. 1 rather than
* defined/!defined. This is advantageous because if you make a typo,
* say misspelled ENDIAN:
*
* #if NVCPU_IS_BIG_ENDAIN
*
* ...some compilers can give you a warning telling you that you screwed up.
* The compiler can also give you a warning if you forget to #include
* "cpuopsys.h" in your code before the point where you try to use these
* conditionals.
*
* Also, the names have been prefixed in more cases with "CPU" or "OS" for
* increased clarity. You can tell the names apart from the old ones because
* they all use "_IS_" in the name.
*
* Finally, these can be used in "if" statements and not just in #if's. For
* example:
*
* if (NVCPU_IS_BIG_ENDIAN) x = Swap32(x);
*
* Maybe some day in the far-off future these can replace the old #define's.
*/
#define NV_IS_MODS 0
#if defined(NV_GSP_MODS)
#define NV_IS_GSP_MODS 1
#else
#define NV_IS_GSP_MODS 0
#endif
#define NVOS_IS_WINDOWS 0
#if defined(NV_WINDOWS_CE)
#define NVOS_IS_WINDOWS_CE 1
#else
#define NVOS_IS_WINDOWS_CE 0
#endif
#if defined(NV_LINUX)
#define NVOS_IS_LINUX 1
#else
#define NVOS_IS_LINUX 0
#endif
#if defined(NV_UNIX)
#define NVOS_IS_UNIX 1
#else
#define NVOS_IS_UNIX 0
#endif
#if defined(NV_BSD)
#define NVOS_IS_FREEBSD 1
#else
#define NVOS_IS_FREEBSD 0
#endif
#if defined(NV_SUNOS)
#define NVOS_IS_SOLARIS 1
#else
#define NVOS_IS_SOLARIS 0
#endif
#define NVOS_IS_VMWARE 0
#if defined(NV_QNX)
#define NVOS_IS_QNX 1
#else
#define NVOS_IS_QNX 0
#endif
#if defined(NV_ANDROID)
#define NVOS_IS_ANDROID 1
#else
#define NVOS_IS_ANDROID 0
#endif
#if defined(NV_MACINTOSH)
#define NVOS_IS_MACINTOSH 1
#else
#define NVOS_IS_MACINTOSH 0
#endif
#if defined(NV_VXWORKS)
#define NVOS_IS_VXWORKS 1
#else
#define NVOS_IS_VXWORKS 0
#endif
#if defined(NV_LIBOS)
#define NVOS_IS_LIBOS 1
#else
#define NVOS_IS_LIBOS 0
#endif
#if defined(NV_INTEGRITY)
#define NVOS_IS_INTEGRITY 1
#else
#define NVOS_IS_INTEGRITY 0
#endif
#if defined(NVCPU_X86)
#define NVCPU_IS_X86 1
#else
#define NVCPU_IS_X86 0
#endif
#if defined(NVCPU_RISCV64)
#define NVCPU_IS_RISCV64 1
#else
#define NVCPU_IS_RISCV64 0
#endif
#if defined(NVCPU_NVRISCV64)
#define NVCPU_IS_NVRISCV64 1
#else
#define NVCPU_IS_NVRISCV64 0
#endif
#if defined(NVCPU_IA64)
#define NVCPU_IS_IA64 1
#else
#define NVCPU_IS_IA64 0
#endif
#if defined(NVCPU_X86_64)
#define NVCPU_IS_X86_64 1
#else
#define NVCPU_IS_X86_64 0
#endif
#if defined(NVCPU_FAMILY_X86)
#define NVCPU_IS_FAMILY_X86 1
#else
#define NVCPU_IS_FAMILY_X86 0
#endif
#if defined(NVCPU_PPC)
#define NVCPU_IS_PPC 1
#else
#define NVCPU_IS_PPC 0
#endif
#if defined(NVCPU_PPC64LE)
#define NVCPU_IS_PPC64LE 1
#else
#define NVCPU_IS_PPC64LE 0
#endif
#if defined(NVCPU_FAMILY_PPC)
#define NVCPU_IS_FAMILY_PPC 1
#else
#define NVCPU_IS_FAMILY_PPC 0
#endif
#if defined(NVCPU_ARM)
#define NVCPU_IS_ARM 1
#else
#define NVCPU_IS_ARM 0
#endif
#if defined(NVCPU_AARCH64)
#define NVCPU_IS_AARCH64 1
#else
#define NVCPU_IS_AARCH64 0
#endif
#if defined(NVCPU_FAMILY_ARM)
#define NVCPU_IS_FAMILY_ARM 1
#else
#define NVCPU_IS_FAMILY_ARM 0
#endif
#if defined(NVCPU_SH4)
#define NVCPU_IS_SH4 1
#else
#define NVCPU_IS_SH4 0
#endif
#if defined(NVCPU_XTENSA)
#define NVCPU_IS_XTENSA 1
#else
#define NVCPU_IS_XTENSA 0
#endif
#if defined(NV_BIG_ENDIAN)
#define NVCPU_IS_BIG_ENDIAN 1
#else
#define NVCPU_IS_BIG_ENDIAN 0
#endif
#if defined(NV_64_BITS)
#define NVCPU_IS_64_BITS 1
#else
#define NVCPU_IS_64_BITS 0
#endif
#if defined(NVCPU_FAMILY_ARM)
#define NVCPU_IS_PCIE_CACHE_COHERENT 0
#else
#define NVCPU_IS_PCIE_CACHE_COHERENT 1
#endif
#if defined(NV_DCECORE)
#define NVOS_IS_DCECORE 1
#else
#define NVOS_IS_DCECORE 0
#endif
/*****************************************************************************/
#endif /* CPUOPSYS_H */
|
7b5f960217169b783cb9f7512bb9ff1c8ce977e4
|
21c92afbd7fd022a206fb31294c523aebb770104
|
/SuiteSparse/GraphBLAS/Source/Template/GB_cij_dot_product.c
|
89896c973d27a7d3e5d3412e428fc3cb0143e4a2
|
[
"BSD-3-Clause",
"LicenseRef-scancode-free-unknown",
"LicenseRef-scancode-unknown-license-reference",
"GPL-2.0-or-later",
"GPL-3.0-only",
"LGPL-2.1-or-later",
"LGPL-2.0-or-later",
"GPL-1.0-or-later",
"LicenseRef-scancode-other-copyleft",
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0",
"LicenseRef-scancode-generic-cla"
] |
permissive
|
jlblancoc/suitesparse-metis-for-windows
|
70e6bcab2b525afb41758d61f823efa0618f67cf
|
5ee2eb4bc7bfd6d27af2f7fb027b1545cfc0fa3f
|
refs/heads/master
| 2023-08-30T21:15:39.624300
| 2023-03-09T10:16:48
| 2023-03-09T10:16:48
| 16,236,582
| 423
| 251
|
BSD-3-Clause
| 2023-03-09T10:18:08
| 2014-01-25T18:06:21
|
C
|
UTF-8
|
C
| false
| false
| 10,762
|
c
|
GB_cij_dot_product.c
|
//------------------------------------------------------------------------------
// GB_cij_dot_product: compute C(i,j) = A(:,i)'*B(:,j)
//------------------------------------------------------------------------------
// SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2018, All Rights Reserved.
// http://suitesparse.com See GraphBLAS/Doc/License.txt for license.
//------------------------------------------------------------------------------
// computes C(i,j) = A (:,i)'*B(:,j) via sparse dot product, optionally
// scattering B(:,j) into size-bvlen workspace.
// FUTURE: some add operators can terminate their outer loop early. For
// example, if the add monoid is the logical OR, then the outer loop can
// terminate as soon as cij is true. If the add operator is FIRST, of any
// type, then it can terminate immediately after the first cij = assignment.
// If the add operator is SECOND, of any type, then the loop to accumuate cij
// could be down backwards, and the loop would terminate after the first
// assignment.
// cij += A(k,i) * B(k,j)
#define GB_DOT_MULTADD(pA,pB) \
GB_DOT_GETA (pA) ; /* aki = A(k,i) */ \
GB_DOT_GETB (pB) ; /* bkj = B(k,j) */ \
GB_DOT_MULT (bkj) ; /* t = aki * bkj */ \
GB_DOT_ADD ; /* cij += t */
// cij = t (and flag cij as existing) or cij += t
#define GB_DOT_ACCUM \
{ \
if (cij_exists) \
{ \
GB_DOT_ADD ; /* cij += t */ \
} \
else \
{ \
/* cij = A(k,i) * B(k,j), and add to the pattern */ \
cij_exists = true ; \
GB_DOT_COPY ; /* cij = t */ \
} \
}
// cij += A(k,i) * B(k,j), for merge operation
#define GB_DOT_MERGE \
{ \
GB_DOT_GETA (pA++) ; /* aki = A(k,i) */ \
GB_DOT_GETB (pB++) ; /* bkj = B(k,j) */ \
GB_DOT_MULT (bkj) ; /* t = aki * bkj */ \
GB_DOT_ACCUM ; /* cij = t or += t */ \
}
{
//--------------------------------------------------------------------------
// get the start of A(:,i) and B(:,j)
//--------------------------------------------------------------------------
bool cij_exists = false ; // C(i,j) not yet in the pattern
int64_t pA = pA_start ;
int64_t pB = pB_start ;
int64_t ainz = pA_end - pA_start ;
ASSERT (ainz >= 0) ;
//--------------------------------------------------------------------------
// ensure enough space exists in C
//--------------------------------------------------------------------------
if (cnz == C->nzmax)
{
GrB_Info info = GB_ix_realloc (C, 2*(C->nzmax), true, Context) ;
if (info != GrB_SUCCESS)
{
// out of memory
GB_MATRIX_FREE (Chandle) ;
GB_DOT_FREE_WORK ;
return (info) ;
}
Ci = C->i ;
Cx = C->x ;
// reacquire cij since C->x has moved
GB_DOT_REACQUIRE ;
}
//--------------------------------------------------------------------------
// compute C(i,j)
//--------------------------------------------------------------------------
if (ainz == 0)
{
//----------------------------------------------------------------------
// A(:,i) is empty so C(i,j) cannot be present
//----------------------------------------------------------------------
;
}
else if (Ai [pA_end-1] < ib_first || ib_last < Ai [pA_start])
{
//----------------------------------------------------------------------
// pattern of A(:,i) and B(:,j) do not overlap
//----------------------------------------------------------------------
;
}
else if (bjnz == bvlen && ainz == bvlen)
{
//----------------------------------------------------------------------
// both A(:,i) and B(:,j) are dense
//----------------------------------------------------------------------
cij_exists = true ;
GB_DOT_CLEAR ; // cij = identity
for (int64_t k = 0 ; k < bvlen ; k++)
{
GB_DOT_MULTADD (pA+k, pB+k) ; // cij += A(k,i) * B(k,j)
}
}
else if (ainz == bvlen)
{
//----------------------------------------------------------------------
// A(:,i) is dense and B(:,j) is sparse
//----------------------------------------------------------------------
cij_exists = true ;
GB_DOT_CLEAR ; // cij = identity
for ( ; pB < pB_end ; pB++)
{
int64_t k = Bi [pB] ;
GB_DOT_MULTADD (pA+k, pB) ; // cij += A(k,i) * B(k,j)
}
}
else if (bjnz == bvlen)
{
//----------------------------------------------------------------------
// A(:,i) is sparse and B(:,j) is dense
//----------------------------------------------------------------------
cij_exists = true ;
GB_DOT_CLEAR ; // cij = identity
for ( ; pA < pA_end ; pA++)
{
int64_t k = Ai [pA] ;
GB_DOT_MULTADD (pA, pB+k) ; // cij += A(k,i) * B(k,j)
}
}
else if (ainz > 8 * bjnz)
{
//----------------------------------------------------------------------
// B(:,j) is very sparse compared to A(:,i)
//----------------------------------------------------------------------
while (pA < pA_end && pB < pB_end)
{
int64_t ia = Ai [pA] ;
int64_t ib = Bi [pB] ;
if (ia < ib)
{
// A(ia,i) appears before B(ib,j)
// discard all entries A(ia:ib-1,i)
int64_t pleft = pA + 1 ;
int64_t pright = pA_end - 1 ;
GB_BINARY_TRIM_SEARCH (ib, Ai, pleft, pright) ;
ASSERT (pleft > pA) ;
pA = pleft ;
}
else if (ib < ia)
{
// B(ib,j) appears before A(ia,i)
pB++ ;
}
else // ia == ib == k
{
// A(k,i) and B(k,j) are the next entries to merge
GB_DOT_MERGE ;
}
}
}
else if (B_can_scatter)
{
//----------------------------------------------------------------------
// scatter B(:,j) into size-bvlen workspace
//----------------------------------------------------------------------
if (Flag == NULL)
{
// allocate Flag and Work space of size bvlen
GB_CALLOC_MEMORY (Flag, bvlen, sizeof (int8_t)) ;
GB_MALLOC_MEMORY (Work, bvlen, bkj_size) ;
if (Flag == NULL || Work == NULL)
{
// out of memory
double memory = GBYTES (bvlen, sizeof (int8_t)) +
GBYTES (bvlen, bkj_size) ;
GB_MATRIX_FREE (Chandle) ;
GB_DOT_FREE_WORK ;
return (GB_OUT_OF_MEMORY (memory)) ;
}
}
if (!B_scattered)
{
// scatter B into the workspace
for ( ; pB < pB_end ; pB++)
{
int64_t k = Bi [pB] ;
// Work [k] = Bx [pB] ;
GB_DOT_SCATTER ;
Flag [k] = 1 ;
}
B_scattered = true ;
}
for ( ; pA < pA_end ; pA++)
{
int64_t k = Ai [pA] ;
if (Flag [k])
{
// cij += A(k,i) * Work [k], where Work [k] == B(k,j)
GB_DOT_GETA (pA) ; // aki = A (k,i)
GB_DOT_MULT (GB_DOT_WORK(k)) ; // t = aki * Work [k]
GB_DOT_ACCUM ; // cij = t or += t
}
}
}
else if (bjnz > 8 * ainz)
{
//----------------------------------------------------------------------
// A(:,i) is very sparse compared to B(:,j)
//----------------------------------------------------------------------
while (pA < pA_end && pB < pB_end)
{
int64_t ia = Ai [pA] ;
int64_t ib = Bi [pB] ;
if (ia < ib)
{
// A(ia,i) appears before B(ib,j)
pA++ ;
}
else if (ib < ia)
{
// B(ib,j) appears before A(ia,i)
// discard all entries B(ib:ia-1,j)
int64_t pleft = pB + 1 ;
int64_t pright = pB_end - 1 ;
GB_BINARY_TRIM_SEARCH (ia, Bi, pleft, pright) ;
ASSERT (pleft > pB) ;
pB = pleft ;
}
else // ia == ib == k
{
// A(k,i) and B(k,j) are the next entries to merge
GB_DOT_MERGE ;
}
}
}
else
{
//----------------------------------------------------------------------
// A(:,i) and B(:,j) have about the same sparsity
//----------------------------------------------------------------------
while (pA < pA_end && pB < pB_end)
{
int64_t ia = Ai [pA] ;
int64_t ib = Bi [pB] ;
if (ia < ib)
{
// A(ia,i) appears before B(ib,j)
pA++ ;
}
else if (ib < ia)
{
// B(ib,j) appears before A(ia,i)
pB++ ;
}
else // ia == ib == k
{
// A(k,i) and B(k,j) are the next entries to merge
GB_DOT_MERGE ;
}
}
}
//--------------------------------------------------------------------------
// save C(i,j)
//--------------------------------------------------------------------------
if (cij_exists)
{
// C(i,j) = cij
GB_DOT_SAVE ;
Ci [cnz++] = i ;
}
}
#undef GB_DOT_MULTADD
#undef GB_DOT_MERGE
#undef GB_DOT_ACCUM
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.