M7350v1_en_gpl

This commit is contained in:
T
2024-09-09 08:52:07 +00:00
commit f9cc65cfda
65988 changed files with 26357421 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
/*
* Copyright (c) 2007 Travis Geiselbrecht
*
* 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.
*/
#ifndef __LIB_BCACHE_H
#define __LIB_BCACHE_H
#include <lib/bio.h>
typedef void * bcache_t;
bcache_t bcache_create(bdev_t *dev, size_t block_size, int block_count);
void bcache_destroy(bcache_t);
int bcache_read_block(bcache_t, void *, uint block);
// get and put a pointer directly to the block
int bcache_get_block(bcache_t, void **, uint block);
int bcache_put_block(bcache_t, uint block);
#endif

View File

@@ -0,0 +1,81 @@
/*
* Copyright (c) 2009 Travis Geiselbrecht
*
* 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.
*/
#ifndef __LIB_BIO_H
#define __LIB_BIO_H
#include <sys/types.h>
#include <list.h>
typedef uint32_t bnum_t;
typedef struct bdev {
struct list_node node;
volatile int ref;
/* info about the block device */
char *name;
off_t size;
size_t block_size;
bnum_t block_count;
/* function pointers */
ssize_t (*read)(struct bdev *, void *buf, off_t offset, size_t len);
ssize_t (*read_block)(struct bdev *, void *buf, bnum_t block, uint count);
ssize_t (*write)(struct bdev *, const void *buf, off_t offset, size_t len);
ssize_t (*write_block)(struct bdev *, const void *buf, bnum_t block, uint count);
ssize_t (*erase)(struct bdev *, off_t offset, size_t len);
int (*ioctl)(struct bdev *, int request, void *argp);
void (*close)(struct bdev *);
} bdev_t;
/* user api */
bdev_t *bio_open(const char *name);
void bio_close(bdev_t *dev);
ssize_t bio_read(bdev_t *dev, void *buf, off_t offset, size_t len);
ssize_t bio_read_block(bdev_t *dev, void *buf, bnum_t block, uint count);
ssize_t bio_write(bdev_t *dev, const void *buf, off_t offset, size_t len);
ssize_t bio_write_block(bdev_t *dev, const void *buf, bnum_t block, uint count);
ssize_t bio_erase(bdev_t *dev, off_t offset, size_t len);
int bio_ioctl(bdev_t *dev, int request, void *argp);
/* intialize the block device layer */
void bio_init(void);
/* register a block device */
void bio_register_device(bdev_t *dev);
void bio_unregister_device(bdev_t *dev);
/* used during bdev construction */
void bio_initialize_bdev(bdev_t *dev, const char *name, size_t block_size, bnum_t block_count);
/* debug stuff */
void bio_dump_devices(void);
/* subdevice support */
status_t bio_publish_subdevice(const char *parent_dev, const char *subdev, bnum_t startblock, size_t len);
/* memory based block device */
int create_membdev(const char *name, void *ptr, size_t len);
#endif

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2009 Travis Geiselbrecht
*
* 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.
*/
#ifndef __LIB_CBUF_H
#define __LIB_CBUF_H
#include <sys/types.h>
#include <kernel/event.h>
typedef struct cbuf {
uint head;
uint tail;
uint len_pow2;
char *buf;
event_t event;
} cbuf_t;
void cbuf_initialize(cbuf_t *cbuf, size_t len);
size_t cbuf_read(cbuf_t *cbuf, void *_buf, size_t buflen, bool block);
size_t cbuf_write(cbuf_t *cbuf, const void *_buf, size_t len, bool canreschedule);
#endif

View File

@@ -0,0 +1,62 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* 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.
*/
#ifndef __LIB_CONSOLE_H
#define __LIB_CONSOLE_H
#include <sys/types.h>
#include <compiler.h>
/* command args */
typedef struct {
const char *str;
unsigned int u;
int i;
} cmd_args;
typedef int (*console_cmd)(int argc, const cmd_args *argv);
/* a block of commands to register */
typedef struct {
const char *cmd_str;
const char *help_str;
const console_cmd cmd_callback;
} cmd;
typedef struct _cmd_block {
struct _cmd_block *next;
size_t count;
const cmd *list;
} cmd_block;
/* register a static block of commands at init time */
#define STATIC_COMMAND_START static const cmd _cmd_list[] = {
#define STATIC_COMMAND_END(name) }; const cmd_block _cmd_block_##name __SECTION(".commands")= { NULL, sizeof(_cmd_list) / sizeof(_cmd_list[0]), _cmd_list }
/* external api */
int console_init(void);
void console_start(void);
void console_register_commands(cmd_block *block);
int console_run_command(const char *string);
#endif

View File

@@ -0,0 +1,12 @@
#ifndef __LIB_FONT_H
#define __LIB_FONT_H
#include <lib/gfx.h>
#define FONT_X 6
#define FONT_Y 12
void font_draw_char(gfx_surface *surface, unsigned char c, int x, int y, uint32_t color);
#endif

View File

@@ -0,0 +1,52 @@
/*
* Copyright (c) 2009 Travis Geiselbrecht
*
* 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.
*/
#ifndef __LIB_FS_H
#define __LIB_FS_H
void fs_init(void);
struct file_stat {
bool is_dir;
off_t size;
};
typedef void *filecookie;
typedef void *fscookie;
int fs_mount(const char *path, const char *device);
int fs_unmount(const char *path);
/* file api */
int fs_open_file(const char *path, filecookie *fcookie);
int fs_read_file(filecookie fcookie, void *buf, off_t offset, size_t len);
int fs_close_file(filecookie fcookie);
int fs_stat_file(filecookie fcookie, struct file_stat *);
/* convenience routines */
ssize_t fs_load_file(const char *path, void *ptr, size_t maxlen);
/* walk through a path string, removing duplicate path seperators, flattening . and .. references */
void fs_normalize_path(char *path);
#endif

View File

@@ -0,0 +1,86 @@
#ifndef __LIB_GFX_H
#define __LIB_GFX_H
#include <sys/types.h>
// gfx library
// different graphics formats
typedef enum {
GFX_FORMAT_RGB_565,
GFX_FORMAT_ARGB_8888,
GFX_FORMAT_RGB_x888,
GFX_FORMAT_MAX
} gfx_format;
#define MAX_ALPHA 255
/**
* @brief Describe a graphics drawing surface
*
* The gfx_surface object represents a framebuffer that can be rendered
* to. Elements include a pointer to the actual pixel memory, its size, its
* layout, and pointers to basic drawing functions.
*
* @ingroup graphics
*/
typedef struct gfx_surface {
void *ptr;
bool free_on_destroy;
gfx_format format;
uint width;
uint height;
uint stride;
uint pixelsize;
size_t len;
uint alpha;
// function pointers
void (*copyrect)(struct gfx_surface *, uint x, uint y, uint width, uint height, uint x2, uint y2);
void (*fillrect)(struct gfx_surface *, uint x, uint y, uint width, uint height, uint color);
void (*putpixel)(struct gfx_surface *, uint x, uint y, uint color);
void (*flush)(uint starty, uint endy);
} gfx_surface;
// copy a rect from x,y with width x height to x2, y2
void gfx_copyrect(gfx_surface *surface, uint x, uint y, uint width, uint height, uint x2, uint y2);
// fill a rect within the surface with a color
void gfx_fillrect(gfx_surface *surface, uint x, uint y, uint width, uint height, uint color);
// draw a pixel at x, y in the surface
void gfx_putpixel(gfx_surface *surface, uint x, uint y, uint color);
// clear the entire surface with a color
static inline void gfx_clear(gfx_surface *surface, uint color)
{
surface->fillrect(surface, 0, 0, surface->width, surface->height, color);
if (surface->flush)
surface->flush(0, surface->height-1);
}
// blend between two surfaces
void gfx_surface_blend(struct gfx_surface *target, struct gfx_surface *source, uint destx, uint desty);
void gfx_flush(struct gfx_surface *surface);
void gfx_flush_rows(struct gfx_surface *surface, uint start, uint end);
// surface setup
gfx_surface *gfx_create_surface(void *ptr, uint width, uint height, uint stride, gfx_format format);
// utility routine to make a surface out of a display info
struct display_info;
gfx_surface *gfx_create_surface_from_display(struct display_info *);
// free the surface
// optionally frees the buffer if the free bit is set
void gfx_surface_destroy(struct gfx_surface *surface);
// utility routine to fill the display with a little moire pattern
void gfx_draw_pattern(void);
#endif

View File

@@ -0,0 +1,10 @@
#ifndef __LIB_GFXCONSOLE_H
#define __LIB_GFXCONSOLE_H
#include <lib/gfx.h>
void gfxconsole_start_on_display(void);
void gfxconsole_start(gfx_surface *surface);
#endif

View File

@@ -0,0 +1,36 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* 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.
*/
#ifndef __LIB_HEAP_H
#define __LIB_HEAP_H
#include <sys/types.h>
void *heap_alloc(size_t, unsigned int alignment);
void *heap_realloc(void *ptr, size_t size);
void heap_free(void *);
void heap_init(void);
#endif

View File

@@ -0,0 +1,35 @@
/*
* Copyright (c) 2009 Travis Geiselbrecht
*
* 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.
*/
#ifndef __LIB_PARTITION_H
#define __LIB_PARTITION_H
#include <sys/types.h>
/* examine and try to publish partitions on a particular device at a particular offset */
int partition_publish(const char *device, off_t offset);
/* remove any published subdevices on this device */
int partition_unpublish(const char *device);
#endif

View File

@@ -0,0 +1,71 @@
/*
* Copyright (c) 2008, Google Inc.
* All rights reserved.
*
* Copyright (c) 2009-2012, The Linux Foundation. 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.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef __LIB_PTABLE_H
#define __LIB_PTABLE_H
/* flash partitions are defined in terms of blocks
* (flash erase units)
*/
#define MAX_PTENTRY_NAME 16
#define MAX_PTABLE_PARTS 32
#define TYPE_MODEM_PARTITION 1
#define TYPE_APPS_PARTITION 0
#define PERM_NON_WRITEABLE 0
#define PERM_WRITEABLE 1
struct ptentry
{
char name[MAX_PTENTRY_NAME];
unsigned start;
unsigned length;
unsigned flags;
char type;
char perm;
};
struct ptable
{
struct ptentry parts[MAX_PTABLE_PARTS];
int count;
};
/* tools to populate and query the partition table */
void ptable_init(struct ptable *ptable);
void ptable_add(struct ptable *ptable, char *name, unsigned start,
unsigned length, unsigned flags, char type, char perm);
struct ptentry *ptable_find(struct ptable *ptable, const char *name);
struct ptentry *ptable_get(struct ptable *ptable, int n);
int ptable_get_index(struct ptable *ptable, const char *name);
int ptable_size(struct ptable *ptable);
void ptable_dump(struct ptable *ptable);
#endif /* __LIB_PTABLE_H */

View File

@@ -0,0 +1,14 @@
#ifndef __LIB_TEXT_H
#define __LIB_TEXT_H
#include <lib/font.h>
/* super cheezy mechanism to stick lines of text up on top of whatever is being drawn */
/* XXX replace with something more generic later */
void text_draw(int x, int y, const char *string);
/* super dumb, someone has to call this to refresh everything */
void text_update(void);
#endif

View File

@@ -0,0 +1,10 @@
#ifndef __LIB_TGA_H
#define __LIB_TGA_H
#include <lib/gfx.h>
#include <sys/types.h>
gfx_surface *tga_decode(const void *ptr, size_t len, gfx_format format);
#endif