2 * Copyright (c) 1998 Doug Rabson
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * $FreeBSD: src/sys/boot/arc/lib/arch/alpha/rpb.c,v 1.2 1999/08/28 00:39:40 peter Exp $
30 #include <machine/rpb.h>
36 {"HWRPB"}, /* rpb_magic */
37 HWRPB_DSRDB_MINVERS, /* rpb_version */
38 sizeof(struct rpb), /* rpb_size */
39 0, /* rpb_primary_cpu_id */
40 8192, /* rpb_page_size */
41 43, /* rpb_phys_addr_size */
44 ST_EB164, /* rpb_type */
45 SV_ST_ALPHAPC164LX_533, /* rpb_variation */
46 {"0000"}, /* rpb_revision */
47 1024*4096, /* rpb_intr_freq */
48 533*1024*1024, /* rpb_cc_freq */
50 0, /* rpb_reserved_arch */
51 0, /* rpb_tbhint_off */
59 0, /* rpb_memdat_off */
60 0, /* rpb_condat_off */
62 0, /* rpb_save_term */
63 0, /* rpb_save_term_val */
64 0, /* rpb_rest_term */
65 0, /* rpb_rest_term_val */
67 0, /* rpb_restart_val */
68 0, /* rpb_reserve_os */
69 0, /* rpb_reserve_hw */
73 0, /* rpb_dsrdb_off */
74 {0}, /* rpb_rpb_tbhint */
77 #define ROUNDUP(x) (((x) + sizeof(u_int64_t) - 1) \
78 & ~(sizeof(u_int64_t) - 1))
81 checksum(void *p, size_t size)
84 u_int64_t *lp = (u_int64_t *)p;
87 printf("checksum(%p, %d)\n", p, size);
88 size = ROUNDUP(size) / sizeof(u_int64_t);
89 for (i = 0; i < size; i++)
97 MEMORY_DESCRIPTOR *desc;
99 for (desc = GetMemoryDescriptor(NULL); desc;
100 desc = GetMemoryDescriptor(desc)) {
104 return ROUNDUP(sizeof(struct mddt)
105 + (count - 1) * sizeof(struct mddt_cluster));
109 write_mddt(struct mddt *mddt, size_t size)
112 MEMORY_DESCRIPTOR *desc;
115 memset(mddt, 0, sizeof(struct mddt));
116 for (desc = GetMemoryDescriptor(NULL); desc;
117 desc = GetMemoryDescriptor(desc)) {
118 struct mddt_cluster *mc;
119 mc = &mddt->mddt_clusters[count];
120 mc->mddt_pfn = desc->BasePage;
121 mc->mddt_pg_cnt = desc->PageCount;
122 mc->mddt_pg_test = 0;
123 mc->mddt_v_bitaddr = 0;
124 mc->mddt_p_bitaddr = 0;
125 mc->mddt_bit_cksum = 0;
128 * Not sure about the FirmwareTemporary bit but my 164LX has
129 * about 60Mb marked this way.
131 if (desc->Type == MemoryFree || desc->Type == MemoryFirmwareTemporary)
132 mc->mddt_usage = MDDT_SYSTEM;
133 else if (desc->Type == MemorySpecialMemory)
134 mc->mddt_usage = MDDT_NONVOLATILE; /* ?? */
136 mc->mddt_usage = MDDT_PALCODE;
139 mddt->mddt_cluster_cnt = count;
140 mddt->mddt_cksum = checksum(mddt, size);
146 return sizeof(struct rpb) + size_mddt();
150 write_rpb(struct rpb *rpb)
152 EXTENDED_SYSTEM_INFORMATION sysinfo;
155 ReturnExtendedSystemInformation(&sysinfo);
157 memset(rpb, 0, sizeof(struct rpb));
158 rpb->rpb_phys = 0; /* XXX */
159 strcpy(rpb->rpb_magic, "HWRPB");
160 rpb->rpb_version = HWRPB_DSRDB_MINVERS;
161 rpb->rpb_size = sizeof(struct rpb);
162 rpb->rpb_primary_cpu_id = 0; /* XXX */
163 rpb->rpb_page_size = sysinfo.ProcessorPageSize;
164 rpb->rpb_phys_addr_size = sysinfo.NumberOfPhysicalAddressBits;
165 rpb->rpb_max_asn = sysinfo.MaximumAddressSpaceNumber;
166 rpb->rpb_type = ST_EB164; /* XXX */
167 rpb->rpb_variation = SV_ST_ALPHAPC164LX_533; /* XXX */
168 rpb->rpb_intr_freq = 1024*4096; /* XXX */
169 rpb->rpb_cc_freq = 533000000; /* XXX */
170 rpb->rpb_memdat_off = sizeof(struct rpb);
171 write_mddt((struct mddt *)((caddr_t) rpb + rpb->rpb_memdat_off),
173 rpb->rpb_checksum = checksum(rpb, 280); /* only sum first 280 bytes */
179 EXTENDED_SYSTEM_INFORMATION sysinfo;
182 ReturnExtendedSystemInformation(&sysinfo);
183 printf("sysinfo.ProcessorId = %x\n", sysinfo.ProcessorId);
184 printf("sysinfo.ProcessorRevision = %d\n", sysinfo.ProcessorRevision);
185 printf("sysinfo.ProcessorPageSize = %d\n", sysinfo.ProcessorPageSize);
186 printf("sysinfo.NumberOfPhysicalAddressBits = %d\n", sysinfo.NumberOfPhysicalAddressBits);
187 printf("sysinfo.MaximumAddressSpaceNumber = %d\n", sysinfo.MaximumAddressSpaceNumber);
188 printf("sysinfo.ProcessorCycleCounterPeriod = %d\n", sysinfo.ProcessorCycleCounterPeriod);
189 printf("sysinfo.SystemRevision = %d\n", sysinfo.SystemRevision);
190 printf("sysinfo.SystemSerialNumber = %s\n", sysinfo.SystemSerialNumber);
191 printf("sysinfo.FirmwareVersion = %s\n", sysinfo.FirmwareVersion);
193 rpb = malloc(size_rpb());