[include][lib] move most of the dangling top level include/lib/.h files into their lib
Only remaining one is console.h which is a little funny and will need to be dealt with separately.
This commit is contained in:
@@ -28,13 +28,15 @@
|
||||
#include <lk/err.h>
|
||||
#include <lib/console.h>
|
||||
#include <lib/bio.h>
|
||||
#include <lib/partition.h>
|
||||
#include <platform.h>
|
||||
#include <kernel/thread.h>
|
||||
|
||||
#if WITH_LIB_CKSUM
|
||||
#include <lib/cksum.h>
|
||||
#endif
|
||||
#if WITH_LIB_PARTITION
|
||||
#include <lib/partition.h>
|
||||
#endif
|
||||
|
||||
#define DMA_ALIGNMENT (CACHE_LINE)
|
||||
#define THREE_BYTE_ADDR_BOUNDARY (16777216)
|
||||
|
||||
73
lib/bytes/include/lib/bytes.h
Normal file
73
lib/bytes/include/lib/bytes.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 2013 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 __BYTES_H
|
||||
#define __BYTES_H
|
||||
|
||||
#include <endian.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
#define bytes_read_u16(x) bytes_read_u16_be(x)
|
||||
#define bytes_read_u24(x) bytes_read_u24_be(x)
|
||||
#define bytes_read_u32(x) bytes_read_u32_be(x)
|
||||
#define bytes_write_u16(x, y) bytes_write_u16_be(x, y)
|
||||
#define bytes_write_u24(x, y) bytes_write_u24_be(x, y)
|
||||
#define bytes_write_u32(x, y) bytes_write_u32_be(x, y)
|
||||
#elif BYTE_ORDER == LITTLE_ENDIAN
|
||||
#define bytes_read_u16(x) bytes_read_u16_le(x)
|
||||
#define bytes_read_u24(x) bytes_read_u24_le(x)
|
||||
#define bytes_read_u32(x) bytes_read_u32_le(x)
|
||||
#define bytes_write_u16(x, y) bytes_write_u16_le(x, y)
|
||||
#define bytes_write_u24(x, y) bytes_write_u24_le(x, y)
|
||||
#define bytes_write_u32(x, y) bytes_write_u32_le(x, y)
|
||||
#else
|
||||
#error "Endianness not defined!"
|
||||
#endif
|
||||
|
||||
|
||||
// Big endian interfaces
|
||||
uint16_t bytes_read_u16_be(const uint8_t *buf);
|
||||
uint32_t bytes_read_u24_be(const uint8_t *buf);
|
||||
uint32_t bytes_read_u32_be(const uint8_t *buf);
|
||||
|
||||
uint8_t *bytes_write_u16_be(uint8_t *buf, uint16_t val);
|
||||
uint8_t *bytes_write_u24_be(uint8_t *buf, uint32_t val);
|
||||
uint8_t *bytes_write_u32_be(uint8_t *buf, uint32_t val);
|
||||
|
||||
// Little endian interfaces
|
||||
uint16_t bytes_read_u16_le(const uint8_t *buf);
|
||||
uint32_t bytes_read_u24_le(const uint8_t *buf);
|
||||
uint32_t bytes_read_u32_le(const uint8_t *buf);
|
||||
|
||||
uint8_t *bytes_write_u16_le(uint8_t *buf, uint16_t val);
|
||||
uint8_t *bytes_write_u24_le(uint8_t *buf, uint32_t val);
|
||||
uint8_t *bytes_write_u32_le(uint8_t *buf, uint32_t val);
|
||||
|
||||
// Bit swapping interfaces
|
||||
uint8_t bytes_swap_bits_u8(uint8_t val);
|
||||
uint16_t bytes_swap_bits_u16(uint16_t val);
|
||||
uint32_t bytes_swap_bits_u24(uint32_t val);
|
||||
uint32_t bytes_swap_bits_u32(uint32_t val);
|
||||
|
||||
#endif
|
||||
|
||||
36
lib/dpc/include/lib/dpc.h
Normal file
36
lib/dpc/include/lib/dpc.h
Normal 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 __KERNEL_DPC_H
|
||||
#define __KERNEL_DPC_H
|
||||
|
||||
#include <lk/list.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef void (*dpc_callback)(void *arg);
|
||||
|
||||
#define DPC_FLAG_NORESCHED 0x1
|
||||
|
||||
status_t dpc_queue(dpc_callback, void *arg, uint flags);
|
||||
|
||||
#endif
|
||||
|
||||
61
lib/evlog/include/lib/evlog.h
Normal file
61
lib/evlog/include/lib/evlog.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2012 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_EVLOG_H
|
||||
#define __LIB_EVLOG_H
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef struct evlog {
|
||||
uint head;
|
||||
uint unitsize;
|
||||
uint len_pow2;
|
||||
uintptr_t *items;
|
||||
} evlog_t;
|
||||
|
||||
status_t evlog_init_etc(evlog_t *e, uint len, uint unitsize, uintptr_t *items);
|
||||
status_t evlog_init(evlog_t *e, uint len, uint unitsize);
|
||||
|
||||
/* callback to evlog_dump. */
|
||||
typedef void (*evlog_dump_cb)(const uintptr_t *);
|
||||
|
||||
void evlog_dump(evlog_t *e, evlog_dump_cb cb);
|
||||
|
||||
/* bump the head pointer and return the old one.
|
||||
*/
|
||||
uint evlog_bump_head(evlog_t *e);
|
||||
|
||||
/*
|
||||
* It's assumed you're following a pattern similar to the following:
|
||||
*
|
||||
void evlog_add2(evlog_t *e, uintptr_t a, uintptr_t b)
|
||||
{
|
||||
uint index = evlog_bump_head(e);
|
||||
|
||||
e->items[index] = a;
|
||||
e->items[index + 1] = b;
|
||||
}
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
39
lib/font/include/lib/font.h
Normal file
39
lib/font/include/lib/font.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2010 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_FONT_H
|
||||
#define __LIB_FONT_H
|
||||
|
||||
#include <lib/gfx.h>
|
||||
#include <lk/compiler.h>
|
||||
|
||||
#define FONT_X 6
|
||||
#define FONT_Y 12
|
||||
|
||||
__BEGIN_CDECLS
|
||||
|
||||
void font_draw_char(gfx_surface *surface, unsigned char c, int x, int y, uint32_t color);
|
||||
|
||||
__END_CDECLS
|
||||
|
||||
#endif
|
||||
|
||||
122
lib/gfx/include/lib/gfx.h
Normal file
122
lib/gfx/include/lib/gfx.h
Normal file
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright (c) 2010 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_GFX_H
|
||||
#define __LIB_GFX_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <sys/types.h>
|
||||
#include <inttypes.h>
|
||||
#include <lk/compiler.h>
|
||||
|
||||
// gfx library
|
||||
|
||||
__BEGIN_CDECLS
|
||||
|
||||
// different graphics formats
|
||||
typedef enum {
|
||||
GFX_FORMAT_NONE,
|
||||
GFX_FORMAT_RGB_565,
|
||||
GFX_FORMAT_RGB_332,
|
||||
GFX_FORMAT_RGB_2220,
|
||||
GFX_FORMAT_ARGB_8888,
|
||||
GFX_FORMAT_RGB_x888,
|
||||
GFX_FORMAT_MONO,
|
||||
|
||||
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
|
||||
uint32_t (*translate_color)(uint32_t input);
|
||||
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);
|
||||
|
||||
// draw a single pixel line between x1,y1 and x2,y1
|
||||
void gfx_line(gfx_surface *surface, uint x1, uint y1, uint x2, uint y2, 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 framebuffer
|
||||
struct display_framebuffer;
|
||||
gfx_surface *gfx_create_surface_from_display(struct display_framebuffer *) __NONNULL((1));
|
||||
|
||||
// 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);
|
||||
|
||||
__END_CDECLS
|
||||
|
||||
#endif
|
||||
|
||||
32
lib/gfxconsole/include/lib/gfxconsole.h
Normal file
32
lib/gfxconsole/include/lib/gfxconsole.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2010 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_GFXCONSOLE_H
|
||||
#define __LIB_GFXCONSOLE_H
|
||||
|
||||
#include <lib/gfx.h>
|
||||
|
||||
void gfxconsole_start_on_display(void);
|
||||
void gfxconsole_start(gfx_surface *surface);
|
||||
|
||||
#endif
|
||||
|
||||
69
lib/heap/include/lib/page_alloc.h
Normal file
69
lib/heap/include/lib/page_alloc.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Google, Inc. 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 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_PAGE_ALLOC_H
|
||||
#define __LIB_PAGE_ALLOC_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
#include <lk/compiler.h>
|
||||
|
||||
// to pick up PAGE_SIZE, PAGE_ALIGN, etc
|
||||
#if WITH_KERNEL_VM
|
||||
#include <kernel/vm.h>
|
||||
#else
|
||||
#include <kernel/novm.h>
|
||||
#endif
|
||||
|
||||
/* A simple page-aligned wrapper around the pmm or novm implementation of
|
||||
* the underlying physical page allocator. Used by system heaps or any
|
||||
* other user that wants pages of memory but doesn't want to use LK
|
||||
* specific apis.
|
||||
*/
|
||||
|
||||
__BEGIN_CDECLS
|
||||
|
||||
#define PAGE_ALLOC_ANY_ARENA (-1)
|
||||
|
||||
/* Pass PAGE_ALLOC_ANY_ARENA as the arena mask if you don't care which arena
|
||||
* the allocation comes from. The arena mask is only used on non-virtual memory
|
||||
* platforms.
|
||||
*/
|
||||
void *page_alloc(size_t pages, int arena_mask);
|
||||
void page_free(void *ptr, size_t pages);
|
||||
|
||||
#if WITH_KERNEL_VM
|
||||
struct page_range {
|
||||
void *address;
|
||||
size_t size;
|
||||
};
|
||||
#endif
|
||||
|
||||
int page_get_arenas(struct page_range *ranges, int number_of_ranges);
|
||||
|
||||
// You can call this once at the start, and it will either return a page or it
|
||||
// will return some non-page-aligned memory that would otherwise go to waste.
|
||||
void *page_first_alloc(size_t *size_return);
|
||||
|
||||
__END_CDECLS
|
||||
|
||||
#endif
|
||||
35
lib/partition/include/lib/partition.h
Normal file
35
lib/partition/include/lib/partition.h
Normal 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
|
||||
|
||||
47
lib/ptable/include/lib/ptable.h
Normal file
47
lib/ptable/include/lib/ptable.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Google, Inc. All rights reserved
|
||||
* Copyright (c) 2014, 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.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <lk/compiler.h>
|
||||
#include <sys/types.h>
|
||||
#include <lib/bio.h>
|
||||
|
||||
#define MAX_FLASH_PTABLE_NAME_LEN 12
|
||||
#define FLASH_PTABLE_ALLOC_END 0x1
|
||||
|
||||
struct ptable_entry {
|
||||
uint64_t offset;
|
||||
uint64_t length;
|
||||
uint32_t flags;
|
||||
uint8_t name[MAX_FLASH_PTABLE_NAME_LEN];
|
||||
};
|
||||
|
||||
bool ptable_found_valid(void);
|
||||
bdev_t *ptable_get_device(void);
|
||||
status_t ptable_scan(const char *bdev_name, uint64_t offset);
|
||||
status_t ptable_find(const char *name, struct ptable_entry *entry) __NONNULL((1));
|
||||
status_t ptable_create_default(const char *bdev_name, uint64_t offset) __NONNULL();
|
||||
status_t ptable_add(const char *name, uint64_t min_len, uint32_t flags) __NONNULL();
|
||||
status_t ptable_remove(const char *name) __NONNULL();
|
||||
void ptable_dump(void);
|
||||
48
lib/sysparam/include/lib/sysparam.h
Normal file
48
lib/sysparam/include/lib/sysparam.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Google, Inc. 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 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.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <sys/types.h>
|
||||
#include <lib/bio.h>
|
||||
|
||||
#ifndef SYSPARAM_ALLOW_WRITE
|
||||
#define SYSPARAM_ALLOW_WRITE 0
|
||||
#endif
|
||||
|
||||
status_t sysparam_scan(bdev_t *bdev, off_t offset, size_t len);
|
||||
status_t sysparam_reload(void);
|
||||
|
||||
void sysparam_dump(bool show_all);
|
||||
|
||||
ssize_t sysparam_length(const char *name);
|
||||
ssize_t sysparam_read(const char *name, void *data, size_t len);
|
||||
status_t sysparam_get_ptr(const char *name, const void **ptr, size_t *len);
|
||||
|
||||
#if SYSPARAM_ALLOW_WRITE
|
||||
status_t sysparam_add(const char *name, const void *value, size_t len);
|
||||
status_t sysparam_remove(const char *name);
|
||||
status_t sysparam_lock(const char *name);
|
||||
status_t sysparam_write(void);
|
||||
#endif
|
||||
|
||||
36
lib/text/include/lib/text.h
Normal file
36
lib/text/include/lib/text.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2010 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_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
|
||||
|
||||
Reference in New Issue
Block a user