Changeset 4872160 in mainline for boot/generic
- Timestamp:
- 2010-05-04T10:44:55Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 568db0f
- Parents:
- bb252ca
- Location:
- boot/generic
- Files:
-
- 12 added
- 3 deleted
- 9 moved
Legend:
- Unmodified
- Added
- Removed
-
boot/generic/include/align.h
rbb252ca r4872160 1 1 /* 2 * Copyright (c) 200 6Jakub Jermar2 * Copyright (c) 2005 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup generic 30 * @{ 31 */ 32 /** @file 29 /** 30 * @file 31 * @brief Macros for making values and addresses aligned. 33 32 */ 34 33 … … 36 35 #define BOOT_ALIGN_H_ 37 36 37 /** Align to the nearest lower address. 38 * 39 * @param s Address or size to be aligned. 40 * @param a Size of alignment, must be power of 2. 41 */ 42 #define ALIGN_DOWN(s, a) ((s) & ~((a) - 1)) 43 38 44 /** Align to the nearest higher address. 39 45 * 40 * @param addrAddress or size to be aligned.41 * @param a lignSize of alignment, must be power of 2.46 * @param s Address or size to be aligned. 47 * @param a Size of alignment, must be power of 2. 42 48 */ 43 #define ALIGN_UP( addr, align) (((addr) + ((align) - 1)) & ~((align) - 1))49 #define ALIGN_UP(s, a) (((s) + ((a) - 1)) & ~((a) - 1)) 44 50 45 51 #endif -
boot/generic/include/balloc.h
rbb252ca r4872160 30 30 #define BOOT_BALLOC_H_ 31 31 32 #include <type s.h>32 #include <typedefs.h> 33 33 34 34 typedef struct { … … 37 37 } ballocs_t; 38 38 39 extern void balloc_init(ballocs_t * ball, uintptr_t base, uintptr_t kernel_base);40 extern void *balloc(size_t size, size_t alignment);41 extern void *balloc_rebase(void * ptr);39 extern void balloc_init(ballocs_t *, void *, uintptr_t, size_t); 40 extern void *balloc(size_t, size_t); 41 extern void *balloc_rebase(void *); 42 42 43 43 #endif -
boot/generic/include/halt.h
rbb252ca r4872160 1 1 /* 2 * Copyright (c) 20 06 Jakub Jermar2 * Copyright (c) 2010 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 #ifndef BOOT_ ia64_STACK_H_30 #define BOOT_ ia64_STACK_H_29 #ifndef BOOT_HALT_H_ 30 #define BOOT_HALT_H_ 31 31 32 #define STACK_ALIGNMENT 16 33 #define STACK_BIAS 2047 34 #define STACK_WINDOW_SAVE_AREA_SIZE (16*8) 32 extern void halt(void) __attribute__((noreturn)); 35 33 36 34 #endif 35 36 /** @} 37 */ -
boot/generic/include/macros.h
rbb252ca r4872160 1 1 /* 2 * Copyright (c) 200 9 Martin Decky2 * Copyright (c) 2005 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup libc30 * @{31 */32 29 /** @file 33 30 */ … … 37 34 38 35 #define min(a, b) ((a) < (b) ? (a) : (b)) 39 #define max(a, b) ((a) > (b) ? (a) : (b))40 36 41 #define SIZE2KB(size) ((size) >> 10) 42 #define SIZE2MB(size) ((size) >> 20) 43 44 #define KB2SIZE(kb) ((kb) << 10) 45 #define MB2SIZE(mb) ((mb) << 20) 37 #define isdigit(d) (((d) >= '0') && ((d) <= '9')) 46 38 47 39 #define STRING(arg) STRING_ARG(arg) -
boot/generic/include/memstr.h
rbb252ca r4872160 1 1 /* 2 * Copyright (c) 200 9 Martin Decky2 * Copyright (c) 2001-2004 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup generic30 * @{31 */32 29 /** @file 33 30 */ … … 36 33 #define BOOT_MEMSTR_H_ 37 34 38 extern void memcpy(void *dst, const void *src, unsigned int cnt); 35 #include <typedefs.h> 36 37 extern void *memcpy(void *, const void *, size_t); 39 38 40 39 #endif -
boot/generic/include/printf.h
rbb252ca r4872160 1 1 /* 2 * Copyright (c) 200 6 Martin Decky2 * Copyright (c) 2001-2004 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup generic30 * @{31 */32 29 /** @file 33 30 */ 34 31 35 #ifndef BOOT_PRINT F_H_36 #define BOOT_PRINT F_H_32 #ifndef BOOT_PRINT_H_ 33 #define BOOT_PRINT_H_ 37 34 38 #define INT8 1 39 #define INT16 2 40 #define INT32 4 41 #define INT64 8 35 #include <typedefs.h> 36 #include <stdarg.h> 42 37 43 extern void puts(const char *str); 44 extern void printf(const char *fmt, ...); 38 #define EOF (-1) 45 39 46 extern void write(const char *str, const int len); 40 extern int puts(const char *); 41 extern int printf(const char *, ...); 42 extern int vprintf(const char *, va_list); 47 43 48 44 #endif -
boot/generic/include/putchar.h
rbb252ca r4872160 1 1 /* 2 * Copyright (c) 200 6 Martin Decky2 * Copyright (c) 2001-2004 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 35 #ifndef BOOT_ GENTYPES_H_36 #define BOOT_ GENTYPES_H_35 #ifndef BOOT_PUTCHAR_H_ 36 #define BOOT_PUTCHAR_H_ 37 37 38 #define NULL 0 39 #define false 0 40 #define true 1 41 42 typedef unsigned long size_t; 38 extern void putchar(const wchar_t); 43 39 44 40 #endif -
boot/generic/include/stdarg.h
rbb252ca r4872160 27 27 */ 28 28 29 /** @addtogroup generic30 * @{31 */32 29 /** @file 33 30 */ 34 31 35 #ifndef STDARG_H__36 #define STDARG_H__32 #ifndef BOOT_STDARG_H__ 33 #define BOOT_STDARG_H__ 37 34 38 35 typedef __builtin_va_list va_list; 39 36 40 #define va_start(ap, last) 41 #define va_arg(ap, type) 42 #define va_end(ap) 37 #define va_start(ap, last) __builtin_va_start(ap, last) 38 #define va_arg(ap, type) __builtin_va_arg(ap, type) 39 #define va_end(ap) __builtin_va_end(ap) 43 40 44 41 #endif -
boot/generic/src/balloc.c
rbb252ca r4872160 28 28 29 29 #include <balloc.h> 30 #include <asm.h> 31 #include <types.h> 30 #include <typedefs.h> 32 31 #include <align.h> 33 32 34 33 static ballocs_t *ballocs; 35 34 static uintptr_t phys_base; 35 static size_t max_size; 36 36 37 void balloc_init(ballocs_t *ball, uintptr_t base, uintptr_t kernel_base) 37 void balloc_init(ballocs_t *ball, void *base, uintptr_t kernel_base, 38 size_t size) 38 39 { 39 40 ballocs = ball; 40 phys_base = base; 41 phys_base = (uintptr_t) base; 42 max_size = size; 41 43 ballocs->base = kernel_base; 42 44 ballocs->size = 0; … … 45 47 void *balloc(size_t size, size_t alignment) 46 48 { 49 if (alignment == 0) 50 return NULL; 51 47 52 /* Enforce minimal alignment. */ 48 53 alignment = ALIGN_UP(alignment, 4); … … 50 55 uintptr_t addr = phys_base + ALIGN_UP(ballocs->size, alignment); 51 56 52 if (ALIGN_UP(ballocs->size, alignment) + size > BALLOC_MAX_SIZE)57 if (ALIGN_UP(ballocs->size, alignment) + size >= max_size) 53 58 return NULL; 54 59
Note:
See TracChangeset
for help on using the changeset viewer.