1 /* -*-C++-*- $NetBSD: arch.cpp,v 1.14 2006/03/05 04:05:39 uwe Exp $ */
4 * Copyright (c) 2001, 2002, 2004 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
35 #include <menu/window.h>
36 #include <menu/rootwindow.h> // MessageBox
42 #include <framebuffer.h>
44 Architecture::Architecture(Console
*&cons
, MemoryManager
*&mem
)
45 :_cons(cons
), _mem(mem
)
53 Architecture::~Architecture(void)
61 Architecture::allocateMemory(size_t sz
)
64 sz
= _mem
->estimateTaggedPageSize(sz
);
65 //pvec + BootArgs + 2 nd bootloader + bootloader stack.
66 sz
+= _mem
->getPageSize() * 4;
67 sz
= _mem
->roundRegion(sz
);
68 return _mem
->reservePage(sz
);
72 Architecture::setupBootInfo(Loader
&loader
)
74 HpcMenuInterface
&menu
= HpcMenuInterface::Instance();
79 _boot_arg
= reinterpret_cast <struct BootArgs
*>(v
);
81 _boot_arg
->argc
= menu
.setup_kernel_args(v
+ sizeof(struct BootArgs
),
82 p
+ sizeof(struct BootArgs
),
83 _mem
->getTaggedPageSize() - sizeof(struct BootArgs
));
84 _boot_arg
->argv
= ptokv(p
+ sizeof(struct BootArgs
));
85 menu
.setup_bootinfo(_boot_arg
->bi
);
86 _boot_arg
->bi
.bi_cnuse
= _cons
->getBootConsole();
88 _boot_arg
->bootinfo
= ptokv(p
+ offsetof(struct BootArgs
, bi
));
89 _boot_arg
->kernel_entry
= loader
.jumpAddr();
91 struct bootinfo
&bi
= _boot_arg
->bi
;
92 DPRINTF((TEXT("framebuffer: %dx%d type=%d linebytes=%d addr=0x%08x\n"),
93 bi
.fb_width
, bi
.fb_height
, bi
.fb_type
, bi
.fb_line_bytes
,
95 DPRINTF((TEXT("console = %d\n"), bi
.bi_cnuse
));
101 Architecture::_load_func(const TCHAR
* name
)
105 _dll
= LoadLibrary(TEXT("coredll.dll"));
108 HWND owner
= HpcMenuInterface::Instance()._root
->_window
;
110 TEXT("Can't load coredll.dll."), TEXT("WARNING"),
111 MB_ICONWARNING
| MB_OK
);
117 return reinterpret_cast <void *>(GetProcAddress(_dll
, name
));
121 Architecture::systemInfo(void)
126 DPRINTF((TEXT("_WIN32_WCE = %d\n"), _WIN32_WCE
));
128 // WCE200 ... GetVersionEx
129 // WCE210 or later ... GetVersionExA or GetVersionExW
132 BOOL (*getVersionEx
)(LPOSVERSIONINFO
);
133 getVersionEx
= reinterpret_cast <BOOL(*)(LPOSVERSIONINFO
)>
134 (_load_func(TEXT("GetVersionEx")));
137 getVersionEx(&WinCEVersion
);
138 DPRINTF((TEXT("GetVersionEx\n")));
140 GetVersionEx(&WinCEVersion
);
141 DPRINTF((TEXT("GetVersionExW\n")));
144 DPRINTF((TEXT("Windows CE %d.%d\n"), WinCEVersion
.dwMajorVersion
,
145 WinCEVersion
.dwMinorVersion
));
148 DPRINTF((TEXT("GetSystemInfo:\n")));
149 #if _WIN32_WCE >= 200
150 DPRINTF((TEXT("wProcessorArchitecture 0x%x\n"),
151 si
.wProcessorArchitecture
));
152 DPRINTF((TEXT("wProcessorLevel 0x%x\n"),
153 si
.wProcessorLevel
));
154 DPRINTF((TEXT("wProcessorRevision 0x%x\n"),
155 si
.wProcessorRevision
));
157 DPRINTF((TEXT("dwPageSize 0x%x\n"),
159 DPRINTF((TEXT("dwAllocationGranularity 0x%08x\n"),
160 si
.dwAllocationGranularity
));
161 DPRINTF((TEXT("dwProcessorType 0x%x\n"),
162 si
.dwProcessorType
));
163 // inquire default setting.
164 FrameBufferInfo
fb(0, 0);
165 DPRINTF((TEXT("Display: %dx%d %dbpp\n"), fb
.width(), fb
.height(),
169 BOOL(*Architecture::_load_LockPages(void))(LPVOID
, DWORD
, PDWORD
, int)
172 return reinterpret_cast <BOOL(*)(LPVOID
, DWORD
, PDWORD
, int)>
173 (_load_func(TEXT("LockPages")));
176 BOOL(*Architecture::_load_UnlockPages(void))(LPVOID
, DWORD
)
179 return reinterpret_cast <BOOL(*)(LPVOID
, DWORD
)>
180 (_load_func(TEXT("UnlockPages")));