Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-2-0]: src/sys/arch/acorn32/stand/boot32 Pull up revision 1.18 (re...



details:   https://anonhg.NetBSD.org/src/rev/abcb754520c9
branches:  netbsd-2-0
changeset: 561047:abcb754520c9
user:      he <he%NetBSD.org@localhost>
date:      Sat May 22 17:11:58 2004 +0000

description:
Pull up revision 1.18 (requested by abs in ticket #369):
  Add qsort to libsa (taken from sys/dev/vinum/vinumqsort.c)
  and use instead of bubblesort in acorn32 bootloader. Reduces
  time to sort memory on A710 equipped RiscPC from over twenty
  seconds to effectively instantaneous.  Update boot version
  to 3.30

diffstat:

 sys/arch/acorn32/stand/boot32/boot32.c |  29 ++++++++---------------------
 1 files changed, 8 insertions(+), 21 deletions(-)

diffs (59 lines):

diff -r 8b68a41c88e8 -r abcb754520c9 sys/arch/acorn32/stand/boot32/boot32.c
--- a/sys/arch/acorn32/stand/boot32/boot32.c    Sat May 22 17:04:24 2004 +0000
+++ b/sys/arch/acorn32/stand/boot32/boot32.c    Sat May 22 17:11:58 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: boot32.c,v 1.16.2.1 2004/05/22 16:59:37 he Exp $       */
+/*     $NetBSD: boot32.c,v 1.16.2.2 2004/05/22 17:11:58 he Exp $       */
 
 /*-
  * Copyright (c) 2002 Reinoud Zandijk
@@ -133,7 +133,7 @@
 void    get_memory_map(void);
 void    create_initial_page_tables(void);
 void    add_pagetables_at_top(void);
-void    sort_memory_map(void);
+int     page_info_cmp(const void *a, const void *);
 void    add_initvectors(void);
 void    create_configuration(int argc, char **argv, int start_args);
 void    prepare_and_check_relocation_system(void);
@@ -516,7 +516,8 @@
        osmemory_page_op(inout, mem_pages_info, totalpages);
 
        printf(" ; sorting ");
-       sort_memory_map();
+       qsort(mem_pages_info, totalpages, sizeof(struct page_info),
+           &page_info_cmp);
        printf(".\n");
 
        /* get the first DRAM index and show the physical memory fragments we got */
@@ -850,26 +851,12 @@
 }
 
 
-/* This sort routine needs to be re-implemented in either assembler or use other algorithm one day; its slow */
-void sort_memory_map(void) {
-       int out, in, count;
-       struct page_info *out_page, *in_page, temp_page;
-
-       count = 0;
-       for (out = 0, out_page = mem_pages_info; out < totalpages; out++, out_page++) {
-               for (in = out+1, in_page = out_page+1; in < totalpages; in++, in_page++) {
-                       if (in_page->physical < out_page->physical) {
-                               memcpy(&temp_page, in_page,    sizeof(struct page_info));
-                               memcpy(in_page,    out_page,   sizeof(struct page_info));
-                               memcpy(out_page,   &temp_page, sizeof(struct page_info));
-                       };
-                       count++;
-                       if ((count & 0x3ffff) == 0) twirl();
-               };
-       };
+/* We can rely on the fact that two entries never have identical ->physical */
+int page_info_cmp(const void *a, const void *b) {
+       return (((struct page_info *)a)->physical <
+           ((struct page_info *)b)->physical) ? -1 : 1;
 }
 
-
 struct page_info *get_relocated_page(u_long destination, int size) {
        struct page_info *page;
 



Home | Main Index | Thread Index | Old Index