Skip to content

Commit 2352888

Browse files
SamulKyullSamulKyull
authored andcommitted
bump to bsp v1.2
1 parent 56b382f commit 2352888

File tree

159 files changed

+156289
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+156289
-2
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,5 +161,4 @@ x509.genkey
161161
sphinx_*/
162162

163163
# Kernel DIr
164-
kernel/
165-
drivers/
164+
kernel/

bsp/drivers/drm/error_img.h

Lines changed: 16349 additions & 0 deletions
Large diffs are not rendered by default.

bsp/drivers/drm/fonts.h

Lines changed: 931 additions & 0 deletions
Large diffs are not rendered by default.

bsp/drivers/drm/kernel_panic_printf.c

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
/* SPDX-License-Identifier: GPL-2.0-or-later */
2+
/* Copyright(c) 2020 - 2023 Allwinner Technology Co.,Ltd. All rights reserved. */
3+
/*
4+
* kernel_panic_printf/kernel_panic_printf.c
5+
*
6+
* Copyright (c) 2007-2023 Allwinnertech Co., Ltd.
7+
* Author: zhengxiaobin <[email protected]>
8+
*
9+
*
10+
* This software is licensed under the terms of the GNU General Public
11+
* License version 2, as published by the Free Software Foundation, and
12+
* may be copied, distributed, and modified under those terms.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU General Public License for more details.
18+
*
19+
*/
20+
#include <linux/fb.h>
21+
#include <sunxi-log.h>
22+
#include "error_img.h"
23+
#include "fonts.h"
24+
struct fb_info *sunxi_get_fb_info(int fb_id);
25+
int sunxi_fb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info);
26+
27+
struct graphic_buffer {
28+
int width;
29+
int height;
30+
unsigned char *buffer;
31+
};
32+
33+
void draw_color(struct graphic_buffer *img, u32 color)
34+
{
35+
int offset = 0, i, j;
36+
for (i = 0; i < img->height; i++)
37+
for (j = 0; j < img->width; j++) {
38+
unsigned int *p =
39+
(unsigned int *)(img->buffer + offset);
40+
*p = color;
41+
offset += 4;
42+
}
43+
}
44+
45+
void draw_pixel(struct graphic_buffer *img, int x, int y, u32 color)
46+
{
47+
int offset = (img->width * y + x) * 4;
48+
unsigned int *p = (unsigned int *)(img->buffer + offset);
49+
*p = color;
50+
}
51+
52+
void draw_img(struct graphic_buffer *img, int px, int py,
53+
const unsigned char *raw, int w, int h)
54+
{
55+
int offset = 0, i = 0, j = 0;
56+
u32 color;
57+
58+
for (i = 0; i < h; i++) {
59+
for (j = 0; j < w; j++) {
60+
unsigned int r = raw[offset];
61+
unsigned int g = raw[offset + 1];
62+
unsigned int b = raw[offset + 2];
63+
offset += 3;
64+
color = ((int)0xff << 24) | (r << 16) | (g << 8) | b;
65+
draw_pixel(img, px + j, py + i, color);
66+
}
67+
}
68+
}
69+
70+
struct glyph_info *glyph_find(unsigned char t)
71+
{
72+
int i = 0;
73+
struct glyph_info *glyph;
74+
75+
for (i = 0; i < character_list_size; i++) {
76+
glyph = &character_list[i];
77+
if (glyph->character == t)
78+
return glyph;
79+
}
80+
return NULL;
81+
}
82+
83+
void draw_glyph(struct graphic_buffer *img, int px, int py,
84+
const struct glyph_info *info)
85+
{
86+
const unsigned char *glyph =
87+
(const unsigned char *)font_glyph_bitmap + info->offset;
88+
int i = 0, j = 0;
89+
for (i = 0; i < info->h; i++) {
90+
for (j = 0; j < info->w; j++) {
91+
u32 color = glyph[i * info->w + j];
92+
color = ((color & 0xff) << 16) | (color & 0xff00) | ((color & 0xff0000) >> 16);
93+
draw_pixel(img, px + j, py + i, color | 0xff000000);
94+
}
95+
}
96+
}
97+
98+
void glyph_reander_string(char *str, int px, int *py, struct graphic_buffer *img)
99+
{
100+
int i = 0;
101+
unsigned char t;
102+
struct glyph_info *glyph;
103+
int origin_px = px, line_height = 0;
104+
105+
line_height = character_font_size * 3 / 2;
106+
for (i = 0; i < strlen(str); i++) {
107+
t = str[i];
108+
if (px + character_font_size > img->width) {
109+
*py += line_height;
110+
px = origin_px;
111+
--i;
112+
113+
if (*py > img->height)
114+
break;
115+
continue;
116+
}
117+
if (*py + line_height > img->height)
118+
break;
119+
if (t == ' ') {
120+
px += (character_font_size / 2);
121+
continue;
122+
}
123+
glyph = glyph_find(t);
124+
if (glyph) {
125+
px += glyph->bitmap_left;
126+
draw_glyph(img, px, *py - glyph->bitmap_top, glyph);
127+
px += (glyph->w + 1);
128+
}
129+
}
130+
*py += line_height;
131+
}
132+
133+
void sunxi_kernel_panic_printf(const char *str, ...)
134+
{
135+
#if IS_ENABLED (CONFIG_DRM_FBDEV_EMULATION)
136+
struct graphic_buffer img;
137+
struct fb_info *p_info = NULL;
138+
int px, py, i = 0, j = 0;
139+
char temp[81] = {0};
140+
char *string = NULL;
141+
va_list args;
142+
143+
if (!str || !strlen(str)) {
144+
printk(KERN_ERR "Null string\n");
145+
return;
146+
}
147+
148+
string = kzalloc(512, GFP_KERNEL);
149+
if (!string)
150+
printk(KERN_ERR "String malloc err\n");
151+
va_start(args, str);
152+
i = vsnprintf(string, 512, str, args);
153+
va_end(args);
154+
if (i > 512 || i == 0) {
155+
printk(KERN_ERR "Out of string length\n");
156+
goto err_free;
157+
}
158+
/*DE_WARN("zxb:%s\n", string);*/
159+
160+
p_info = sunxi_get_fb_info(0);
161+
if (!p_info) {
162+
printk(KERN_ERR "Null fb info\n");
163+
goto err_free;
164+
}
165+
img.width = p_info->var.xres;
166+
img.height = p_info->var.yres;
167+
img.buffer = p_info->screen_base;
168+
if (!img.buffer) {
169+
printk(KERN_ERR "NULL fb buffer\n");
170+
goto err_free;
171+
}
172+
173+
draw_color(&img, 0xff000000);
174+
px = crashdump_raw_width + 64;
175+
py = img.height / 2;
176+
draw_img(&img, 32, py - 2 * character_font_size, crashdump_img_raw,
177+
crashdump_raw_width, crashdump_raw_height);
178+
179+
i = 0;
180+
j = 0;
181+
while (string[i] != '\0') {
182+
if (string[i] == '\n') {
183+
temp[j] = '\0';
184+
glyph_reander_string(temp, px, &py, &img);
185+
j = 0;
186+
} else {
187+
temp[j] = string[i];
188+
++j;
189+
if (j == 80) {
190+
temp[j] = '\0';
191+
j = 0;
192+
glyph_reander_string(temp, px, &py, &img);
193+
}
194+
}
195+
++i;
196+
}
197+
temp[j] = '\0';
198+
glyph_reander_string(temp, px, &py, &img);
199+
p_info->var.reserved[0] = FB_ACTIVATE_FORCE;
200+
//platform_swap_rb_order(p_info, true);
201+
sunxi_fb_pan_display(&p_info->var, p_info);
202+
203+
err_free:
204+
kfree(string);
205+
return ;
206+
#else
207+
printk(KERN_ERR "fbdev not enable\n");
208+
#endif
209+
}
210+
EXPORT_SYMBOL_GPL(sunxi_kernel_panic_printf);
211+
212+
// End of File

bsp/drivers/drm/lib/inc/sha1.h

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/* SPDX-License-Identifier: GPL-2.0-or-later */
2+
/*
3+
* sha1.h
4+
*
5+
* Description:
6+
* This is the header file for code which implements the Secure
7+
* Hashing Algorithm 1 as defined in FIPS PUB 180-1 published
8+
* April 17, 1995.
9+
*
10+
* Many of the variable names in this code, especially the
11+
* single character names, were used because those were the names
12+
* used in the publication.
13+
*
14+
* Please read the file sha1.c for more information.
15+
*
16+
* Copyright (c) 2007-2022 Allwinnertech Co., Ltd.
17+
* Author: huangyongxing <[email protected]>
18+
*
19+
* This program is free software; you can redistribute it and/or modify
20+
* it under the terms of the GNU General Public License version 2 as
21+
* published by the Free Software Foundation.
22+
*
23+
*/
24+
#ifndef __SHA1_H__
25+
#define __SHA1_H__
26+
//#include <stdint.h>
27+
#include <linux/types.h>
28+
#define SHA1HashSize 20
29+
30+
enum {
31+
shaSuccess = 0,
32+
shaNull, /* Null pointer parameter */
33+
shaInputTooLong, /* input data too long */
34+
shaStateError /* called Input after Result */
35+
};
36+
37+
/*
38+
* This structure will hold context information for the SHA-1
39+
* hashing operation
40+
*/
41+
typedef struct SHA1Context {
42+
uint32_t Intermediate_Hash[SHA1HashSize / 4]; // Message Digest
43+
uint32_t Length_Low; // Message length in bits
44+
uint32_t Length_High; // Message length in bits
45+
short int Message_Block_Index; // Index into message block array
46+
uint8_t Message_Block[64]; // 512-bit message blocks
47+
int Computed; // Is the digest computed?
48+
int Corrupted; // Is the message digest corrupted?
49+
} SHA1Context;
50+
51+
int SHA1Reset(SHA1Context *);
52+
int SHA1Input(SHA1Context *, const uint8_t *, unsigned int);
53+
int SHA1Result(SHA1Context *, uint8_t Message_Digest[SHA1HashSize]);
54+
55+
#endif

bsp/drivers/drm/lib/inc/sha256.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/* SPDX-License-Identifier: GPL-2.0-or-later */
2+
//------------------------------------------------------------------------------
3+
//
4+
// COPYRIGHT (c) 2018-2022 TRILINEAR TECHNOLOGIES, INC.
5+
// CONFIDENTIAL AND PROPRIETARY
6+
//
7+
// THE SOURCE CODE CONTAINED HEREIN IS PROVIDED ON AN "AS IS" BASIS.
8+
// TRILINEAR TECHNOLOGIES, INC. DISCLAIMS ANY AND ALL WARRANTIES,
9+
// WHETHER EXPRESS, IMPLIED, OR STATUTORY, INCLUDING ANY IMPLIED
10+
// WARRANTIES OF MERCHANTABILITY OR OF FITNESS FOR A PARTICULAR PURPOSE.
11+
// IN NO EVENT SHALL TRILINEAR TECHNOLOGIES, INC. BE LIABLE FOR ANY
12+
// INCIDENTAL, PUNITIVE, OR CONSEQUENTIAL DAMAGES OF ANY KIND WHATSOEVER
13+
// ARISING FROM THE USE OF THIS SOURCE CODE.
14+
//
15+
// THIS DISCLAIMER OF WARRANTY EXTENDS TO THE USER OF THIS SOURCE CODE
16+
// AND USER'S CUSTOMERS, EMPLOYEES, AGENTS, TRANSFEREES, SUCCESSORS,
17+
// AND ASSIGNS.
18+
//
19+
// THIS IS NOT A GRANT OF PATENT RIGHTS
20+
//------------------------------------------------------------------------------
21+
//
22+
// Original License:
23+
// public domain sha256 implementation based on fips180-3
24+
//
25+
//------------------------------------------------------------------------------
26+
#ifndef __SHA256_H__
27+
#define __SHA256_H__
28+
#define SHA256_DIGEST_LENGTH 32
29+
30+
typedef struct {
31+
uint64_t len; /* processed message length */
32+
uint32_t h[8]; /* hash state */
33+
uint8_t buf[64]; /* message block buffer */
34+
} sha256_t;
35+
36+
void sha256_init(sha256_t *ctx);
37+
void sha256_update(sha256_t *ctx, const void *m, uint32_t len);
38+
void sha256_sum(sha256_t *ctx, uint8_t md[SHA256_DIGEST_LENGTH]);
39+
40+
#endif

0 commit comments

Comments
 (0)