From b7cf0602fd08f6a367d42f0b6adadb8322b3d35d Mon Sep 17 00:00:00 2001 From: Alan Korr Date: Sun, 21 Apr 2002 12:21:14 +0000 Subject: removing all that stuff permanently. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@159 a1c6a512-1295-4272-9138-f99709370657 --- firmware/test/memory/config.h | 27 --- firmware/test/memory/defines.h | 39 ---- firmware/test/memory/functions.h | 94 -------- firmware/test/memory/inlines.h | 26 --- firmware/test/memory/makefile | 23 -- firmware/test/memory/memory-block.c | 76 ------- firmware/test/memory/memory-block.txt | 0 firmware/test/memory/memory-misc.c | 48 ---- firmware/test/memory/memory-misc.txt | 0 firmware/test/memory/memory-page.c | 408 --------------------------------- firmware/test/memory/memory-page.h | 59 ----- firmware/test/memory/memory-page.txt | 74 ------ firmware/test/memory/memory-slab.c | 409 ---------------------------------- firmware/test/memory/memory-slab.h | 62 ------ firmware/test/memory/memory-slab.txt | 0 firmware/test/memory/memory.h | 27 --- firmware/test/memory/return_values.h | 31 --- firmware/test/memory/test.l | 23 -- firmware/test/memory/test.y | 180 --------------- firmware/test/memory/types.h | 32 --- 20 files changed, 1638 deletions(-) delete mode 100644 firmware/test/memory/config.h delete mode 100644 firmware/test/memory/defines.h delete mode 100644 firmware/test/memory/functions.h delete mode 100644 firmware/test/memory/inlines.h delete mode 100644 firmware/test/memory/makefile delete mode 100644 firmware/test/memory/memory-block.c delete mode 100644 firmware/test/memory/memory-block.txt delete mode 100644 firmware/test/memory/memory-misc.c delete mode 100644 firmware/test/memory/memory-misc.txt delete mode 100644 firmware/test/memory/memory-page.c delete mode 100644 firmware/test/memory/memory-page.h delete mode 100644 firmware/test/memory/memory-page.txt delete mode 100644 firmware/test/memory/memory-slab.c delete mode 100644 firmware/test/memory/memory-slab.h delete mode 100644 firmware/test/memory/memory-slab.txt delete mode 100644 firmware/test/memory/memory.h delete mode 100644 firmware/test/memory/return_values.h delete mode 100644 firmware/test/memory/test.l delete mode 100644 firmware/test/memory/test.y delete mode 100644 firmware/test/memory/types.h (limited to 'firmware/test/memory') diff --git a/firmware/test/memory/config.h b/firmware/test/memory/config.h deleted file mode 100644 index aba52b5599..0000000000 --- a/firmware/test/memory/config.h +++ /dev/null @@ -1,27 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_MEMORY_H__ -# error "This header file must be included ONLY from memory.h." -#endif -#ifndef __LIBRARY_MEMORY_CONFIG_H__ -# define __LIBRARY_MEMORY_CONFIG_H__ -# define PACKAGE_NAME "memory" -# define PACKAGE_VERSION "0.1.1" -# define MEMORY_PAGE_USE_SPLAY_TREE 1 -#endif diff --git a/firmware/test/memory/defines.h b/firmware/test/memory/defines.h deleted file mode 100644 index 804731cea3..0000000000 --- a/firmware/test/memory/defines.h +++ /dev/null @@ -1,39 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_MEMORY_H__ -# error "This header file must be included ONLY from memory.h." -#endif -#ifndef __LIBRARY_MEMORY_DEFINES_H__ -# define __LIBRARY_MEMORY_DEFINES_H__ -# ifndef MEMORY_PAGE_MINIMAL_ORDER -# define MEMORY_PAGE_MINIMAL_ORDER (9) /* 512 bytes */ -# endif -# ifndef MEMORY_PAGE_MAXIMAL_ORDER -# define MEMORY_PAGE_MAXIMAL_ORDER (21) /* 2 Mbytes */ -# endif -# ifndef MEMORY_PAGE_MINIMAL_SIZE -# define MEMORY_PAGE_MINIMAL_SIZE (1 << MEMORY_PAGE_MINIMAL_ORDER) -# endif -# ifndef MEMORY_PAGE_MAXIMAL_SIZE -# define MEMORY_PAGE_MAXIMAL_SIZE (1 << MEMORY_PAGE_MAXIMAL_ORDER) -# endif -# define MEMORY_TOTAL_PAGES (MEMORY_PAGE_MAXIMAL_SIZE / MEMORY_PAGE_MINIMAL_SIZE) -# define MEMORY_TOTAL_BYTES (MEMORY_PAGE_MAXIMAL_SIZE) -# define MEMORY_TOTAL_ORDERS (1 + MEMORY_PAGE_MAXIMAL_ORDER - MEMORY_PAGE_MINIMAL_ORDER) -#endif diff --git a/firmware/test/memory/functions.h b/firmware/test/memory/functions.h deleted file mode 100644 index c856a934cf..0000000000 --- a/firmware/test/memory/functions.h +++ /dev/null @@ -1,94 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_MEMORY_H__ -# error "This header file must be included ONLY from memory.h." -#endif -# ifndef __LIBRARY_MEMORY_FUNCTIONS_H__ -# define __LIBRARY_MEMORY_FUNCTIONS_H__ - -///////////////////////////////////////////////////////////////////// -// MEMORY : -/////////// - -extern void memory_copy (void *target,void const *source,unsigned int count); -extern void memory_set (void *target,int byte,unsigned int count); - -///////////////////////////////////////////////////////////////////// -// MEMORY PAGE : -//////////////// -// -// - memory_allocate_page : allocate a page -// - memory_release_page : release a page -// - -extern int memory_release_page (void *address); -extern void *memory_allocate_page (int order); -extern void memory_setup (void); - -// -///////////////////////////////////////////////////////////////////// - -///////////////////////////////////////////////////////////////////// -// MEMORY SLAB : -//////////////// -// -// - memory_grow_cache : allocate a new slab for a cache -// - memory_shrink_cache : release free slabs from a cache -// - memory_create_cache : create a new cache of size-fixed blocks -// - memory_destroy_cache : destroy the cache and release all the slabs -// - memory_cache_allocate : allocate a block from the cache -// - memory_cache_release : release a block in the cache -// - -extern struct memory_slab *memory_grow_cache (struct memory_cache *cache); -extern int memory_shrink_cache (struct memory_cache *cache,int all); -extern struct memory_cache *memory_create_cache (unsigned int size,int align,int flags); -extern int memory_destroy_cache (struct memory_cache *cache); -extern void *memory_cache_allocate (struct memory_cache *cache); -extern int memory_cache_release (struct memory_cache *cache,void *address); - -// -///////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -// MEMORY BLOCK : -///////////////// -// -// - memory_allocate_small_block : allocate a small block (no page) -// - memory_release_small_block : release a small block (no page) -// - memory_allocate_block : allocate a block (or a page) -// - memory_release_block : release a block (or a page) -// - -extern void *memory_allocate_small_block (int order); -extern int memory_release_small_block (int order,void *address); -extern void *memory_allocate_block (unsigned int size); -extern int memory_release_block (void *address); - -// -///////////////////////////////////////////////////////////////////// - - - -# ifdef TEST -void memory_spy_page (void *address); -void memory_dump (int order); -void memory_check (int order); -# endif -#endif diff --git a/firmware/test/memory/inlines.h b/firmware/test/memory/inlines.h deleted file mode 100644 index 003c611153..0000000000 --- a/firmware/test/memory/inlines.h +++ /dev/null @@ -1,26 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_MEMORY_H__ -# error "This header file must be included ONLY from memory.h." -#endif -# ifndef __LIBRARY_MEMORY_INLINES_H__ -#define __LIBRARY_MEMORY_INLINES_H__ - - -#endif diff --git a/firmware/test/memory/makefile b/firmware/test/memory/makefile deleted file mode 100644 index 2878500e45..0000000000 --- a/firmware/test/memory/makefile +++ /dev/null @@ -1,23 +0,0 @@ -############################################################################# -## __________ __ ___. -## Open \______ \ ____ ____ | | _\_ |__ _______ ___ -## Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -## Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -## Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -## \/ \/ \/ \/ \/ -## Copyright Alan Korr, 2002. All rights reserved. -## -## Permission to use, copy, modify, and distribute this software for any -## purpose is hereby granted without fee, provided that this copyright and -## permissions notice appear in all copies and derivatives, and that no -## charge may be made for the software and its documentation except to cover -## cost of distribution. -## -## This software is provided "as is" without express or implied warranty. -############################################################################# -ARCH = test -PACKAGE = memory -VERSION = 0.1.1 --include ../makefile-vars --include ../makefile-rules - diff --git a/firmware/test/memory/memory-block.c b/firmware/test/memory/memory-block.c deleted file mode 100644 index c5cf3ce9f8..0000000000 --- a/firmware/test/memory/memory-block.c +++ /dev/null @@ -1,76 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#if 0 -#include -#include "memory-page.h" -#include "memory-slab.h" - -static struct memory_cache *__memory_free_block_cache[MEMORY_PAGE_MINIMAL_ORDER - 2]; - -/////////////////////////////////////////////////////////////////////////////// -// MEMORY BLOCK : -///////////////// -// -// - memory_allocate_block : allocate a power-of-2-sized block (or a page) -// - memory_release_block : release a power-of-2-sized block (or a page) -// - -static inline void *__memory_allocate_block (int order) - { - struct memory_cache *cache = __memory_free_block_cache[order - 2]; - do - { - if (cache) - return memory_cache_allocate (cache); - } - while ((__memory_free_block_cache[order] = cache = memory_create_cache (size,0,0))); - return MEMORY_RETURN_FAILURE; - } - -void *memory_allocate_block (int order) - { - if (order < 2) - order = 2; - if (order < MEMORY_PAGE_MINIMAL_ORDER) - return __memory_allocate_block (order); - if (order < MEMORY_PAGE_MAXIMAL_ORDER) - return memory_allocate_page (order); - return MEMORY_RETURN_FAILURE; - } - -static inline int __memory_release_block (int order,void *address) - { - struct memory_cache *cache = __memory_free_block_cache[order - 2]; - if (cache) - return memory_cache_release (cache,address); - return MEMORY_RETURN_FAILURE; - } - -int memory_release_block (int order,void *address) - { - if (order < 2) - order = 2; - if (order < MEMORY_PAGE_MINIMAL_ORDER) - return __memory_release_block (order); - if (order < MEMORY_PAGE_MAXIMAL_ORDER) - return memory_release_page (address); - return MEMORY_RETURN_FAILURE; - } - -#endif diff --git a/firmware/test/memory/memory-block.txt b/firmware/test/memory/memory-block.txt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/firmware/test/memory/memory-misc.c b/firmware/test/memory/memory-misc.c deleted file mode 100644 index 765600765b..0000000000 --- a/firmware/test/memory/memory-misc.c +++ /dev/null @@ -1,48 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#include -#include "memory-page.h" -#if 0 -#include "memory-slab.h" -#endif - -/* NOT VERY OPTIMIZED AT ALL BUT WE WILL DO IT WHEN PRIORITY COMES */ -void memory_copy (void *target,void const *source,unsigned int count) - { - while (count--) - *((char *)target)++ = *((char const *)source)++; - } - -/* NOT VERY OPTIMIZED AT ALL BUT WE WILL DO IT WHEN PRIORITY COMES */ -void memory_set (void *target,int byte,unsigned int count) - { - while (count--) - *((char *)target)++ = (char)byte; - } - -void memory_setup (void) - { -#if 1 - memory_set (__memory_free_page,0,MEMORY_TOTAL_BYTES); - memory_set (__memory_free_page_bin,0,MEMORY_TOTAL_ORDERS *sizeof (struct memory_free_page *)); - memory_set (__memory_free_page_order + 1,0,MEMORY_TOTAL_PAGES); -#endif - __memory_free_page_order[0] = MEMORY_TOTAL_ORDERS - 1; - __memory_free_page_bin[MEMORY_TOTAL_ORDERS - 1] = __memory_free_page; - } diff --git a/firmware/test/memory/memory-misc.txt b/firmware/test/memory/memory-misc.txt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/firmware/test/memory/memory-page.c b/firmware/test/memory/memory-page.c deleted file mode 100644 index 1327cf57c9..0000000000 --- a/firmware/test/memory/memory-page.c +++ /dev/null @@ -1,408 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#include -#include "memory-page.h" -#if 0 -#include "memory-slab.h" -#endif - -#ifdef TEST - -// IA32 has no problem with shift operation -static inline unsigned int __memory_get_size (int order) - { - return (MEMORY_PAGE_MINIMAL_SIZE << order); - } - -// Arghhhh ! I cannot align 'free_page' on 512-byte boundary (max is 16-byte for Cygwin) -static inline struct memory_free_page *__memory_get_neighbour (struct memory_free_page *node,unsigned int size) - { - return ((struct memory_free_page *)((unsigned)__memory_free_page + (((unsigned)node - (unsigned)__memory_free_page) ^ size))); - } - -#else - -// SH1 has very poor shift instructions (only <<1,>>1,<<2,>>2,<<8,>>8,<<16 and >>16). -// so we should use a lookup table to speedup. -static inline unsigned int __memory_get_size (int order) - { - static unsigned short size [MEMORY_TOTAL_ORDERS] = - { - 1<less)) - { - if (node < down) - { - root->less = down->more; - down->more = root; - root = down; - if (!root->less) - break; - } - more->less = root; - more = root; - root = root->less; - continue; - } - break; - } - if (root < node) - { - if ((down = root->more)) - { - if (root < node) - { - root->more = down->less; - down->less = root; - root = down; - if (!root->more) - break; - } - less->more = root; - less = root; - root = root->more; - continue; - } - } - break; - } - less->more = root->less; - more->less = root->more; - root->less = head.more; - root->more = head.less; - return root; - } - -static inline void __memory_insert_page (int order,struct memory_free_page *node) - { - struct memory_free_page *root = __memory_free_page_bin[order]; - if (!root) - { - node->less = - node->more = 0; - } - else if (node < (root = __memory_splay_page (root,node))) - { - node->less = root->less; - node->more = root; - root->less = 0; - } - else if (node > root) - { - node->less = root; - node->more = root->more; - node->more = 0; - } - __memory_free_page_bin[order] = node; - __memory_set_order (node,order); - return; - } - -static inline struct memory_free_page *__memory_pop_page (int order,int want) - { - struct memory_free_page *root = __memory_free_page_bin[order]; - if (root) - { - root = __memory_splay_page (root,__memory_free_page); - __memory_free_page_bin[order] = root->more; - __memory_set_order (root,~want); - } - return root; - } - -static inline void __memory_remove_page (int order,struct memory_free_page *node) - { - struct memory_free_page *root = __memory_free_page_bin[order]; - root = __memory_splay_page (root,node); - if (root->less) - { - node = __memory_splay_page (root->less,node); - node->more = root->more; - } - else - node = root->more; - __memory_free_page_bin[order] = node; - } - -#else - -static inline void __memory_insert_page (int order,struct memory_free_page *node) - { - struct memory_free_page *head = __memory_free_page_bin[order]; - node->less = 0; - node->more = head; - if (head) - head->less = node; - __memory_free_page_bin[order] = node; - __memory_set_order (node,order); - } - -static inline struct memory_free_page *pop_page (int order,int want) - { - struct memory_free_page *node = __memory_free_page_bin[order]; - if (node) - { - __memory_free_page_bin[order] = node->more; - if (node->more) - node->more->less = 0; - __memory_set_order (node,~want); - } - return node; - } - -static inline void __memory_remove_page (int order,struct memory_free_page *node) - { - if (node->less) - node->less->more = node->more; - else - __memory_free_page_bin[order] = node->more; - if (node->more) - node->more->less = node->less; - } - -#endif - -static inline void __memory_push_page (int order,struct memory_free_page *node) - { - node->less = 0; - node->more = 0; - __memory_free_page_bin[order] = node; - __memory_set_order (node,order); - } - -static struct memory_free_page *__memory_allocate_page (unsigned int size,int order) - { - struct memory_free_page *node; - int min = order; - while ((unsigned)order <= (MEMORY_TOTAL_ORDERS - 1)) - // order is valid ? - { - if (!(node = __memory_pop_page (order,min))) - // no free page of this order ? - { - ++order; size <<= 1; - continue; - } - while (order > min) - // split our larger page in smaller pages - { - --order; size >>= 1; - __memory_push_page (order,(struct memory_free_page *)((unsigned int)node + size)); - } - return node; - } - return MEMORY_RETURN_FAILURE; - } - -static inline void __memory_release_page (struct memory_free_page *node,unsigned int size,int order) - { - struct memory_free_page *neighbour; - while ((order <= (MEMORY_TOTAL_ORDERS - 1)) && - ((neighbour = __memory_get_neighbour (node,size)), - (__memory_get_order (neighbour) == order))) - // merge our released page with its contiguous page into a larger page - { - __memory_remove_page (order,neighbour); - ++order; size <<= 1; - if (neighbour < node) - node = neighbour; - } - __memory_insert_page (order,node); - } - - -/*****************************************************************************/ -/* PUBLIC FUNCTIONS */ -/*****************************************************************************/ - -void *memory_allocate_page (int order) - { - if (order < 0) - return MEMORY_RETURN_FAILURE; - return __memory_allocate_page (__memory_get_size (order),order); - } - -// release a page : -// when called, 'address' MUST be a valid address pointing -// to &dram[i], where i ranges from 0 to MEMORY_TOTAL_PAGES - 1. -// FAILURE if block is already freed. -int memory_release_page (void *address) - { - struct memory_free_page *node = (struct memory_free_page *)address; - int order = ~__memory_get_order (node); - if (order < 0) - return MEMORY_RETURN_FAILURE; - __memory_release_page (node,__memory_get_size (order),order); - return MEMORY_RETURN_SUCCESS; - } - - -#ifdef TEST -# include -# include -# if MEMORY_PAGE_USE_SPLAY_TREE - -void __memory_dump_splay_node (struct memory_free_page *node,int level) - { - if (!node) - return; - __memory_dump_splay_node (node->less,level+1); - printf ("\n%*s[%d-%d]",level,"",(node - __memory_free_page),(node - __memory_free_page) + (1 << __memory_get_order (node)) - 1); - __memory_dump_splay_node (node->more,level+1); - } - -void __memory_dump_splay_tree (struct memory_free_page *root) - { - __memory_dump_splay_node (root,2); fflush (stdout); - } - -# endif - -void __memory_spy_page (void *address) - { - struct memory_free_page *node = (struct memory_free_page *)address; - int order,used; - if (node) - { - order = __memory_get_order (node); - used = order < 0; - if (used) - order = ~order; - printf("\n(%s,%2d,%7d)",(used ? "used" : "free"),order,__memory_get_size (order)); - } - } - -void __memory_dump (int order) - { - struct memory_free_page *node = __memory_free_page_bin[order]; - printf("\n(%s,%2d,%7d)",node ? "free" : "none",order,__memory_get_size (order)); -# if MEMORY_PAGE_USE_SPLAY_TREE - __memory_dump_splay_tree (node); -# else - while (node) - { - printf("[%d-%d]",(node - __memory_free_page),(node - __memory_free_page) + (1<more; - } -# endif - - } - -void __memory_check (int order) - { - struct memory_free_page *node[4096],*swap; - unsigned int i = 0,j = 0; - while (i <= 12) - __memory_dump (i++); - i = 0; - printf ("\nallocating...\n"); - while (order >= 0) - { - j = order; - while ((swap = memory_allocate_page (j))) - { - node[i++] = swap; - printf("[%d-%d]",(swap - __memory_free_page),(swap - __memory_free_page) + ((1 << j)-1)); - for (j += (rand () & 15); j > (unsigned int)order; j -= order); - } - --order; - } - node[i] = 0; - while (j <= 12) - __memory_dump (j++); - j = 0; - printf ("\nreleasing..."); - --i; - while (i > 0) - { - unsigned int k = 0; -# if 0 - printf ("\n"); -# endif - swap = node[k++]; -# if 0 - while (swap) - { - printf("[%d-%d]",(swap - __memory_free_page),(swap - __memory_free_page) + ((1 << ~__memory_get_order (swap))-1)); - swap = node[k++]; - } -# endif - for (j += 1 + (rand () & 15); j >= i; j -= i); - swap = node[j]; - node[j] = node[i]; - memory_release_page (swap); - node[i] = 0; - --i; - } - memory_release_page (node[0]); - i = 0; - while (i <= 12) - __memory_dump (i++); - printf("\n\n%s !",(__memory_get_order (__memory_free_page) == 12) ? "SUCCESS" : "FAILURE"); - } - -#endif diff --git a/firmware/test/memory/memory-page.h b/firmware/test/memory/memory-page.h deleted file mode 100644 index ab360447d7..0000000000 --- a/firmware/test/memory/memory-page.h +++ /dev/null @@ -1,59 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id: - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_MEMORY_PAGE_H__ -#define __LIBRARY_MEMORY_PAGE_H__ - -struct memory_free_page - { - struct memory_free_page - *less,*more; - char - reserved[MEMORY_PAGE_MINIMAL_SIZE - 2*sizeof (struct memory_free_page *)]; - }; - -#define LESS -1 -#define MORE +1 - -#ifdef TEST - -struct memory_free_page __memory_free_page[MEMORY_TOTAL_PAGES]; - -#else - -extern struct memory_free_page __memory_free_page[MEMORY_TOTAL_PAGES] asm("dram"); - -#endif - -char __memory_free_page_order[MEMORY_TOTAL_PAGES]; -struct memory_free_page *__memory_free_page_bin[MEMORY_TOTAL_ORDERS]; - -#ifdef TEST -# if MEMORY_PAGE_USE_SPLAY_TREE - -void __memory_dump_splay_node (struct memory_free_page *node,int level); -void __memory_dump_splay_tree (struct memory_free_page *root); - -# endif - -void __memory_spy_page (void *address); -void __memory_dump (int order); -void __memory_check (int order); - -#endif -#endif \ No newline at end of file diff --git a/firmware/test/memory/memory-page.txt b/firmware/test/memory/memory-page.txt deleted file mode 100644 index 03811f9bde..0000000000 --- a/firmware/test/memory/memory-page.txt +++ /dev/null @@ -1,74 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id: - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -Best-fit via binning represent the main ideas of the algorithm. - -The memory-page allocator uses an array which contains the power-of-two -orders of each free or used pages to retrieve their sizes. - -Available pages are maintained in bins, grouped by size. Depending on -its size, a free page is stored in the bin corresponding to the correct -size range (bins are detailed further): 512 B, 1 KB, 2 KB, 4 KB, 8 KB, -16 KB, 32 KB, 64 KB, 128 KB, 256 KB, 512 KB, 1 MB or 2 MB. - -Searches for available pages are processed in smallest-first, best-fit -order. - -Two implementations to chain same-sized pages are provided: -* using doubly linked stack (unordered list) as bin, pages are left - unsorted within bins, so that the best-fit strategy should only be - approximate. -* using splay tree (ordered list) as bin, pages are instead sorted - by address within bins. - -Using splay trees is slower than using doubly linked stacks but affords us -to allocate contiguous pages when possible : since doubly linked stack is -not ordered, it cannot warrant a contiguous allocation of pages. However, -there is no evidence that using splay trees really helps unfragmenting -much more than using doubly linked stack. - -All procedures maintain the invariant that no free page physically -borders another one (two bordering unused pages are always coalesced -into one larger page). - -* Alignment of pages: power-of-two, the same as their sizes. -* Minimum overhead per allocated pages: no overhead. -* Minimum allocated size: minimal page size, i.e, 512 bytes. -* Maximum allocated size: maximal page size, i.e, 2 megabytes. - --- ALGORITHMS ----------------------------------------------------------------- - -Unoptimized and recursive algorithm to allocate an N-sized page : - -* If there is no pages in the bin of N-sized pages, try to allocate - a (2xN)-sized page and split it into two N-sized pages and free - both if they are not N-sized pages or just free one and keep - the other to mark it used if they are N-sized pages. - -Unoptimized and recursive algorithm to release an N-sized page : - -* If there is a "contiguous" page, merge it with our N-sized page and - try to release it as a (2xN)-sized page. Otherwise mark it free. - -Notes: -* Two pages are "contiguous" if they are also N-aligned and mergeable - as a 2xN-aligned page. -* The address of a "contiguous" page is quickly given by : - - address("contiguous" page) = (address(page) ^ size(page)) diff --git a/firmware/test/memory/memory-slab.c b/firmware/test/memory/memory-slab.c deleted file mode 100644 index 35ab96f787..0000000000 --- a/firmware/test/memory/memory-slab.c +++ /dev/null @@ -1,409 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#if 0 -#include -#include "memory-page.h" -#include "memory-slab.h" - -/////////////////////////////////////////////////////////////////////////////// -// MEMORY SLAB : -//////////////// -// -// - -static inline struct memory_slab *__memory_push_slab (struct memory_slab *head,struct memory_slab *node) - { - node->less = head; - if (head) - { - node->more = head->more; - head->more = node; - } - else - node->more = 0; - return node; - } - -static inline struct memory_slab *__memory_pop_slab (struct memory_slab *head,struct memory_slab *node) - { - if (head) - head->more = node->more; - return node->more; - } - -static inline struct memory_slab *__memory_move_slab (struct memory_slab **from,struct memory_slab **to) - { - struct memory_slab *head = *from; - *from = (*from)->more; - if (*from) - (*from)->less = head->less; - head->less = 0; - head->more = (*to); - if (*to) - (*to)->prev = head; - *to = head; - return head; - } - -// -/////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -// MEMORY CACHE : -///////////////// -// -// - -static struct memory_cache *cache_tree; - -static inline int __memory_get_order (unsigned size) - { - int order = 0; - size = (size + sizeof(struct memory_free_block) - 1) & - sizeof(struct memory_free_block); - while (size > 0) - { - ++order; size <<= 1; - } - return order; - } - -static inline struct memory_slab *__memory_get_slab (struct memory_cache *cache,void *address) - { -#ifdef TEST - return (struct memory_slab *)((((unsigned)address + cache->page_size) & -cache->page_size) - sizeof (struct memory_slab)); -#else - return (struct memory_slab *)((free_page + (((unsigned)address - free_page + cache->page_size) & -cache->page_size) - sizeof (struct memory_slab))); -#endif - } - -static struct memory_cache *__memory_splay_cache (struct memory_cache *root,unsigned int left) - { - struct memory_cache *down; - struct memory_cache *less; - struct memory_cache *more; - struct memory_cache head; - head.less = - head.more = 0; - less = - more = &head; - while (1) - { - if (left < root->left) - { - if ((down = root->less)) - { - if (left < down->left) - { - root->less = down->more; - down->more = root; - root = down; - if (!root->less) - break; - } - more->less = root; - more = root; - root = root->less; - continue; - } - break; - } - if (root->left < left) - { - if ((down = root->more)) - { - if (root->left < left) - { - root->more = down->less; - down->less = root; - root = down; - if (!root->more) - break; - } - less->more = root; - less = root; - root = root->more; - continue; - } - } - break; - } - less->more = root->less; - more->less = root->more; - root->less = head.more; - root->more = head.less; - return root; - } - -static inline struct memory_cache *__memory_insert_cache (struct memory_cache *root,struct memory_cache *node) - { - node->less = - node->more = - node->same = 0; - if (root) - { - if (node->left == ((root = __memory_splay_cache (root,node))->left)) - { - node->less = root.less; - node->more = root.more; - node->same = root; - root->less = node; - } - else if (node < root) - { - node->less = root->less; - node->more = root; - root->less = 0; - } - else - { - node->less = root; - node->more = root->more; - node->more = 0; - } - } - return node; - } - -static inline struct memory_cache *__memory_remove_cache (struct memory_cache *root,struct memory_cache *node) - { - if (root) - { - root = __memory_splay_cache (root,node); - if (root != node) - { - node->less->same = node->same; - if (node->same) - node->same->less = node->less; - return root; - } - if (root->less) - { - node = __memory_splay_page (root->less,node); - node->more = root->more; - } - else - node = root->more; - } - return root; - } - -static inline struct memory_cache *__memory_move_cache (struct memory_cache *root,struct memory_cache *node,int delta) - { - if ((root = __memory_remove_cache (root,node))) - { - node->left += delta; - root = __memory_insert_cache (root,node); - } - return root; - } - -// -///////////////////// -// PUBLIC FUNCTIONS : -///////////////////// -// -// - memory_grow_cache : allocate a new slab for a cache -// - memory_shrink_cache : release free slabs from a cache -// - memory_create_cache : create a new cache of size-fixed blocks -// - memory_destroy_cache : destroy the cache and release all the slabs -// - memory_cache_allocate : allocate a block from the cache -// - memory_cache_release : release a block in the cache -// - -struct memory_slab *memory_grow_cache (struct memory_cache *cache) - { - struct memory_slab *slab; - unsigned int page; - if (cache) - { - page = (unsigned int)memory_allocate_page (cache->page_order); - if (page) - { - struct memory_free_block *block,**link; - slab = (struct memory_slab *)(page + cache->page_size - sizeof (struct memory_slab)); - slab->free = 0; - slab->left = 0; - link = &slab->free; - for ((unsigned int)block = page; - (unsigned int)block + cache->size < (unsigned int)slab; - (unsigned int)block += cache->size) - { - *link = block; - link = &block->link; - ++slab->free; - } - *link = 0; - cache->blocks_per_slab = slab->free; - cache->reap = __memory_push_slab (cache->reap,slab); - cache_tree = __memory_move_cache (cache_tree,cache,+1); - return slab; - } - } - return MEMORY_RETURN_FAILURE; - } - -static int __memory_shrink_cache (struct memory_cache *cache,int all,int move) - { - struct memory_slab *slab; - unsigned int slabs = 0; - if (cache) - { - while ((slab = cache->reap)) - { - ++slabs; - cache->reap = __memory_pop_slab (cache->reap,slab); - memory_release_page ((void *)slab); - if (all) - continue; - if (move) - cache_tree = __memory_move_cache (cache_tree,cache,-slabs); - return MEMORY_RETURN_SUCCESS; - } - } - return MEMORY_RETURN_FAILURE; - } - -int memory_shrink_cache (struct memory_cache *cache,int all) - { - return __memory_shrink_cache (cache,all,1 /* move cache in cache_tree */); - } - -struct memory_cache *memory_create_cache (unsigned int size,int align,int flags) - { - struct memory_cache *cache; - unsigned int waste = 0,blocks_per_page; - int page_order; - unsigned int page_size; - unsigned int original_size = size; - - // Align size on 'align' bytes ('align' should equal 1< 4) ? ((size + align - 1) & -align) : ((size + sizeof (int) - 1) & -sizeof (int)); - if (!(cache = memory_cache_allocate (&cache_cache)) - return MEMORY_RETURN_FAILURE; - - cache->flags = - cache->left = 0; - - cache->used = - cache->free = - cache->reap = 0; - - cache->original_size = original_size; - cache->size = size; - - page_size = 0; - page_order = MEMORY_PAGE_MINIMAL_SIZE;; - - // Trying to determine what is the best number of pages per slab - for (;; ++order,(page_size <<= 1)) - { - if (page_order >= MEMORY_MAXIMUM_PAGE_ORDER_PER_SLAB) - { - memory_cache_release (&cache_cache,cache); - return MEMORY_RETURN_FAILURE; - } - - waste = page_size; - waste -= sizeof (struct memory_slab); - - blocks_per_slab = waste / size; - waste -= block_per_slab * size; - - if (blocks_per_slab < MEMORY_MINIMUM_BLOCKS_PER_SLAB) - { - ++page_order; page_size <<= 1; - continue; - } - - // below 3% of lost space is correct - if ((waste << 16) / page_size) < 1967) - break; - ++page_order; page_size <<= 1; - } - - cache->page_size = page_size; - cache->page_order = page_order; - - cache_tree = __memory_insert_cache (cache_tree,cache); - - return cache; - } - -int memory_destroy_cache (struct memory_cache *cache) - { - /* FIX ME : this function shouldn't be called if there are still used blocks */ - if (cache && !cache->free && !cache->used) - { - cache_tree = __memory_remove_cache (cache_tree,cache); - if (__memory_shrink_cache (cache,1 /* release all free slabs */,0 /* don't move in cache_tree */)) - return memory_cache_release (&cache_cache,cache); - } - return MEMORY_RETURN_FAILURE; - } - -void *memory_cache_allocate (struct memory_cache *cache) - { - if (cache) - { - do - { - struct memory_slab *slab; - if ((slab = cache->free)) - { - if (slab->left > 0) - { -ok: struct memory_free_block *block = slab->free; - slab->free = block->link; - if (--slab->left == 0) - __memory_move_slab (&cache->free,&cache->used); - return block; - } - } - if (cache->reap) - { - slab = __memory_move_slab (&cache->reap,&cache->free); - cache_tree = __memory_move_cache (cache_tree,cache,-1); - goto ok; - } - } - while (__memory_grow_cache (cache)); - } - return MEMORY_RETURN_FAILURE; - } - -int memory_cache_release (struct memory_cache *cache,void *address) - { - struct memory_slab *slab = __memory_get_slab (cache,address); - ((struct memory_free_block *)address)->link = slab->free; - slab->free = (struct memory_free_block *)address; - if (slab->left++ == 0) - __memory_move_slab (&cache->used,&cache->free); - else if (slab->left == cache->blocks_per_slab) - { - __memory_move_slab (&cache->free,&cache->reap); - cache_tree = __memory_move_cache (cache_tree,cache,+1); - } - return MEMORY_RETURN_SUCCESS; - } - -// -/////////////////////////////////////////////////////////////////////////////// - -#endif diff --git a/firmware/test/memory/memory-slab.h b/firmware/test/memory/memory-slab.h deleted file mode 100644 index f58897c3ec..0000000000 --- a/firmware/test/memory/memory-slab.h +++ /dev/null @@ -1,62 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id: - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_MEMORY_SLAB_H__ -#define __LIBRARY_MEMORY_SLAB_H__ - -struct memory_free_block - { - struct memory_free_block - *link; - }; - -struct memory_slab - { - struct memory_slab - *less,*more; - unsigned int // left == number of free blocks left - left; - struct memory_free_block - *free; - }; - -struct memory_cache - { - struct memory_cache - *less,*more,*same; - unsigned int - left; // number of free slabs - struct memory_slab - *used; - struct memory_slab - *free; - struct memory_slab - *reap; - unsigned int - size,original_size; - unsigned int - page_size; - unsigned int - blocks_per_slab; - int - page_order; - unsigned int - flags; - }; - -#endif diff --git a/firmware/test/memory/memory-slab.txt b/firmware/test/memory/memory-slab.txt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/firmware/test/memory/memory.h b/firmware/test/memory/memory.h deleted file mode 100644 index fde6ac3ad1..0000000000 --- a/firmware/test/memory/memory.h +++ /dev/null @@ -1,27 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_MEMORY_H__ -# define __LIBRARY_MEMORY_H__ -# include -# include -# include -# include -# include -# include -#endif diff --git a/firmware/test/memory/return_values.h b/firmware/test/memory/return_values.h deleted file mode 100644 index fe3cf8f88d..0000000000 --- a/firmware/test/memory/return_values.h +++ /dev/null @@ -1,31 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_MEMORY_H__ -# error "This header file must be included ONLY from memory.h." -#endif -# ifndef __LIBRARY_MEMORY_RETURN_VALUES_H__ -#define __LIBRARY_MEMORY_RETURN_VALUES_H__ - -enum - { - MEMORY_RETURN_SUCCESS = 1, - MEMORY_RETURN_FAILURE = 0 - }; - -#endif diff --git a/firmware/test/memory/test.l b/firmware/test/memory/test.l deleted file mode 100644 index 7b938e9330..0000000000 --- a/firmware/test/memory/test.l +++ /dev/null @@ -1,23 +0,0 @@ -%{ -#include "test.tab.h" -#define YY_INPUT(buf,result,max_size) \ - result = read_input (buf,max_size); -%} - -%s GETNUMBER - -%% - -[0-9]+ { yylval = atoi(yytext); return NUMBER;} - -"a"|"allocate" { BEGIN GETNUMBER; return ALLOCATE; } -"r"|"release" { BEGIN GETNUMBER; return RELEASE; } -"s"|"spy" { BEGIN GETNUMBER; return SPY; } -"c"|"check" { BEGIN GETNUMBER; return CHECK; } -"i"|"init" { return INIT; } -"d"|"dump" { return DUMP; } -"q"|"quit" { return QUIT; } -[ \t] ; -\n|. { BEGIN 0; return yytext[0]; } -%% - diff --git a/firmware/test/memory/test.y b/firmware/test/memory/test.y deleted file mode 100644 index b3b39acc26..0000000000 --- a/firmware/test/memory/test.y +++ /dev/null @@ -1,180 +0,0 @@ -%{ -#include "memory.h" -#include "memory-page.h" -#include -#include -#include -void allocate (int); -void release (int); -void spy (int); -void dump (void); -void prompt (void); -%} - -%token NUMBER -%token ALLOCATE -%token RELEASE -%token DUMP -%token SPY -%token CHECK -%token INIT -%token QUIT - -%left '+' '-' -%left '*' '/' -%nonassoc UMINUS - -%% -commands - : command ';' - { } - | commands command ';' - { } - | error ';' - { yyerrok; } - ; - -command - : allocate - | release - | spy - | check - | INIT - { memory_setup (); } - | DUMP - { dump (); } - | QUIT - { return 0; } - ; - -allocate - : ALLOCATE expression - { allocate (yylval); } - ; - -release - : RELEASE expression - { release (yylval); } - ; - -spy - : SPY expression - { spy (yylval); } - ; - -check - : CHECK expression - { __memory_check (yylval); } - ; - -expression - : expression '+' expression - { $$ = $1 + $3; } - | expression '-' expression - { $$ = $1 - $3; } - | expression '*' expression - { $$ = $1 * $3; } - | expression '/' expression - { - if($3 == 0) - yyerror("divide by zero"); - else - $$ = $1 / $3; - } - | '-' expression %prec UMINUS - { - $$ = -$2; - } - | '(' expression ')' - { - $$ = $2; - } - | NUMBER - { - $$ = $1; - } - ; - -%% - -#include -#include - -int yyerror(char *s) - { - fprintf(stderr,"\nBad command"); - return 1; - } - -void prompt (void) - { - printf("\n>"); fflush (stdout); - } - -void allocate (int order) - { - void *address; - printf("\nallocating a page of %d bytes...",512< 21) - printf (" bad order !"); - else if ((address = memory_allocate_page (order))) - printf (" page #%d allocated !",((char *)address - (char *)__memory_free_page) >> 9); - else - printf (" cannot allocate a page !"); - } - -void release (int page) - { - void *address = (void *)((char *)__memory_free_page + (page << 9)); - printf("\nreleasing page #%d...",page); - if ((unsigned)page >= (2*1024*1024/512)) - printf (" bad page number !"); - else if (memory_release_page (address)) - printf (" page #%d released !",page); - else - printf (" cannot release this page !"); - } - -void spy (int page) - { - void *address = (void *)((char *)__memory_free_page + (page << 9)); - printf("\nspying page #%d...",page); - if ((unsigned)page >= (2*1024*1024/512)) - printf (" bad page number !"); - else - __memory_spy_page (address); - } - -void dump (void) - { - int order; - printf("\ndumping free pages list..."); - for (order = 0; order < 13; ++order) - __memory_dump (order); - } - -int main () - { - yyparse(); - return 0; - } - -int read_input (char *buffer,int max) - { - char *line = 0; - while (1) - { - line = readline ("\n>"); - if (!line) - break; - if (*line) - add_history(line); - strncpy (buffer,line,max); - strcat (buffer,";"); - free (line); - return strlen (buffer); - } - buffer[0] = ';'; - return 1; - } - diff --git a/firmware/test/memory/types.h b/firmware/test/memory/types.h deleted file mode 100644 index 4d2be940b5..0000000000 --- a/firmware/test/memory/types.h +++ /dev/null @@ -1,32 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 by Alan Korr - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __LIBRARY_MEMORY_H__ -# error "This header file must be included ONLY from memory.h." -#endif -#ifndef __LIBRARY_MEMORY_TYPES_H__ -# define __LIBRARY_MEMORY_TYPES_H__ - -struct memory_free_page; -struct memory_free_block; -struct memory_slab; -struct memory_cache; - - - -#endif -- cgit v1.2.3