Skip to content

Commit

Permalink
Sat Aug 17 13:58:16 UTC 2024 Kernel update
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Aug 17, 2024
1 parent 6fdf97b commit eeebf49
Show file tree
Hide file tree
Showing 158 changed files with 156,288 additions and 0 deletions.
16,349 changes: 16,349 additions & 0 deletions bsp/drivers/drm/error_img.h

Large diffs are not rendered by default.

931 changes: 931 additions & 0 deletions bsp/drivers/drm/fonts.h

Large diffs are not rendered by default.

212 changes: 212 additions & 0 deletions bsp/drivers/drm/kernel_panic_printf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/* Copyright(c) 2020 - 2023 Allwinner Technology Co.,Ltd. All rights reserved. */
/*
* kernel_panic_printf/kernel_panic_printf.c
*
* Copyright (c) 2007-2023 Allwinnertech Co., Ltd.
* Author: zhengxiaobin <[email protected]>
*
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include <linux/fb.h>
#include <sunxi-log.h>
#include "error_img.h"
#include "fonts.h"
struct fb_info *sunxi_get_fb_info(int fb_id);
int sunxi_fb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info);

struct graphic_buffer {
int width;
int height;
unsigned char *buffer;
};

void draw_color(struct graphic_buffer *img, u32 color)
{
int offset = 0, i, j;
for (i = 0; i < img->height; i++)
for (j = 0; j < img->width; j++) {
unsigned int *p =
(unsigned int *)(img->buffer + offset);
*p = color;
offset += 4;
}
}

void draw_pixel(struct graphic_buffer *img, int x, int y, u32 color)
{
int offset = (img->width * y + x) * 4;
unsigned int *p = (unsigned int *)(img->buffer + offset);
*p = color;
}

void draw_img(struct graphic_buffer *img, int px, int py,
const unsigned char *raw, int w, int h)
{
int offset = 0, i = 0, j = 0;
u32 color;

for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
unsigned int r = raw[offset];
unsigned int g = raw[offset + 1];
unsigned int b = raw[offset + 2];
offset += 3;
color = ((int)0xff << 24) | (r << 16) | (g << 8) | b;
draw_pixel(img, px + j, py + i, color);
}
}
}

struct glyph_info *glyph_find(unsigned char t)
{
int i = 0;
struct glyph_info *glyph;

for (i = 0; i < character_list_size; i++) {
glyph = &character_list[i];
if (glyph->character == t)
return glyph;
}
return NULL;
}

void draw_glyph(struct graphic_buffer *img, int px, int py,
const struct glyph_info *info)
{
const unsigned char *glyph =
(const unsigned char *)font_glyph_bitmap + info->offset;
int i = 0, j = 0;
for (i = 0; i < info->h; i++) {
for (j = 0; j < info->w; j++) {
u32 color = glyph[i * info->w + j];
color = ((color & 0xff) << 16) | (color & 0xff00) | ((color & 0xff0000) >> 16);
draw_pixel(img, px + j, py + i, color | 0xff000000);
}
}
}

void glyph_reander_string(char *str, int px, int *py, struct graphic_buffer *img)
{
int i = 0;
unsigned char t;
struct glyph_info *glyph;
int origin_px = px, line_height = 0;

line_height = character_font_size * 3 / 2;
for (i = 0; i < strlen(str); i++) {
t = str[i];
if (px + character_font_size > img->width) {
*py += line_height;
px = origin_px;
--i;

if (*py > img->height)
break;
continue;
}
if (*py + line_height > img->height)
break;
if (t == ' ') {
px += (character_font_size / 2);
continue;
}
glyph = glyph_find(t);
if (glyph) {
px += glyph->bitmap_left;
draw_glyph(img, px, *py - glyph->bitmap_top, glyph);
px += (glyph->w + 1);
}
}
*py += line_height;
}

void sunxi_kernel_panic_printf(const char *str, ...)
{
#if IS_ENABLED (CONFIG_DRM_FBDEV_EMULATION)
struct graphic_buffer img;
struct fb_info *p_info = NULL;
int px, py, i = 0, j = 0;
char temp[81] = {0};
char *string = NULL;
va_list args;

if (!str || !strlen(str)) {
printk(KERN_ERR "Null string\n");
return;
}

string = kzalloc(512, GFP_KERNEL);
if (!string)
printk(KERN_ERR "String malloc err\n");
va_start(args, str);
i = vsnprintf(string, 512, str, args);
va_end(args);
if (i > 512 || i == 0) {
printk(KERN_ERR "Out of string length\n");
goto err_free;
}
/*DE_WARN("zxb:%s\n", string);*/

p_info = sunxi_get_fb_info(0);
if (!p_info) {
printk(KERN_ERR "Null fb info\n");
goto err_free;
}
img.width = p_info->var.xres;
img.height = p_info->var.yres;
img.buffer = p_info->screen_base;
if (!img.buffer) {
printk(KERN_ERR "NULL fb buffer\n");
goto err_free;
}

draw_color(&img, 0xff000000);
px = crashdump_raw_width + 64;
py = img.height / 2;
draw_img(&img, 32, py - 2 * character_font_size, crashdump_img_raw,
crashdump_raw_width, crashdump_raw_height);

i = 0;
j = 0;
while (string[i] != '\0') {
if (string[i] == '\n') {
temp[j] = '\0';
glyph_reander_string(temp, px, &py, &img);
j = 0;
} else {
temp[j] = string[i];
++j;
if (j == 80) {
temp[j] = '\0';
j = 0;
glyph_reander_string(temp, px, &py, &img);
}
}
++i;
}
temp[j] = '\0';
glyph_reander_string(temp, px, &py, &img);
p_info->var.reserved[0] = FB_ACTIVATE_FORCE;
//platform_swap_rb_order(p_info, true);
sunxi_fb_pan_display(&p_info->var, p_info);

err_free:
kfree(string);
return ;
#else
printk(KERN_ERR "fbdev not enable\n");
#endif
}
EXPORT_SYMBOL_GPL(sunxi_kernel_panic_printf);

// End of File
55 changes: 55 additions & 0 deletions bsp/drivers/drm/lib/inc/sha1.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* sha1.h
*
* Description:
* This is the header file for code which implements the Secure
* Hashing Algorithm 1 as defined in FIPS PUB 180-1 published
* April 17, 1995.
*
* Many of the variable names in this code, especially the
* single character names, were used because those were the names
* used in the publication.
*
* Please read the file sha1.c for more information.
*
* Copyright (c) 2007-2022 Allwinnertech Co., Ltd.
* Author: huangyongxing <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
*/
#ifndef __SHA1_H__
#define __SHA1_H__
//#include <stdint.h>
#include <linux/types.h>
#define SHA1HashSize 20

enum {
shaSuccess = 0,
shaNull, /* Null pointer parameter */
shaInputTooLong, /* input data too long */
shaStateError /* called Input after Result */
};

/*
* This structure will hold context information for the SHA-1
* hashing operation
*/
typedef struct SHA1Context {
uint32_t Intermediate_Hash[SHA1HashSize / 4]; // Message Digest
uint32_t Length_Low; // Message length in bits
uint32_t Length_High; // Message length in bits
short int Message_Block_Index; // Index into message block array
uint8_t Message_Block[64]; // 512-bit message blocks
int Computed; // Is the digest computed?
int Corrupted; // Is the message digest corrupted?
} SHA1Context;

int SHA1Reset(SHA1Context *);
int SHA1Input(SHA1Context *, const uint8_t *, unsigned int);
int SHA1Result(SHA1Context *, uint8_t Message_Digest[SHA1HashSize]);

#endif
40 changes: 40 additions & 0 deletions bsp/drivers/drm/lib/inc/sha256.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
//------------------------------------------------------------------------------
//
// COPYRIGHT (c) 2018-2022 TRILINEAR TECHNOLOGIES, INC.
// CONFIDENTIAL AND PROPRIETARY
//
// THE SOURCE CODE CONTAINED HEREIN IS PROVIDED ON AN "AS IS" BASIS.
// TRILINEAR TECHNOLOGIES, INC. DISCLAIMS ANY AND ALL WARRANTIES,
// WHETHER EXPRESS, IMPLIED, OR STATUTORY, INCLUDING ANY IMPLIED
// WARRANTIES OF MERCHANTABILITY OR OF FITNESS FOR A PARTICULAR PURPOSE.
// IN NO EVENT SHALL TRILINEAR TECHNOLOGIES, INC. BE LIABLE FOR ANY
// INCIDENTAL, PUNITIVE, OR CONSEQUENTIAL DAMAGES OF ANY KIND WHATSOEVER
// ARISING FROM THE USE OF THIS SOURCE CODE.
//
// THIS DISCLAIMER OF WARRANTY EXTENDS TO THE USER OF THIS SOURCE CODE
// AND USER'S CUSTOMERS, EMPLOYEES, AGENTS, TRANSFEREES, SUCCESSORS,
// AND ASSIGNS.
//
// THIS IS NOT A GRANT OF PATENT RIGHTS
//------------------------------------------------------------------------------
//
// Original License:
// public domain sha256 implementation based on fips180-3
//
//------------------------------------------------------------------------------
#ifndef __SHA256_H__
#define __SHA256_H__
#define SHA256_DIGEST_LENGTH 32

typedef struct {
uint64_t len; /* processed message length */
uint32_t h[8]; /* hash state */
uint8_t buf[64]; /* message block buffer */
} sha256_t;

void sha256_init(sha256_t *ctx);
void sha256_update(sha256_t *ctx, const void *m, uint32_t len);
void sha256_sum(sha256_t *ctx, uint8_t md[SHA256_DIGEST_LENGTH]);

#endif
Loading

0 comments on commit eeebf49

Please sign in to comment.