1*355f6c61Stsutsui /* $NetBSD: extern.h,v 1.5 2022/09/05 14:14:42 tsutsui Exp $ */ 2f8bc0014Sigy 3f8bc0014Sigy /* 48f53455cSigy * Copyright (c) 2003 Naoto Shimazaki. 5f8bc0014Sigy * All rights reserved. 6f8bc0014Sigy * 7f8bc0014Sigy * Redistribution and use in source and binary forms, with or without 8f8bc0014Sigy * modification, are permitted provided that the following conditions 9f8bc0014Sigy * are met: 10f8bc0014Sigy * 1. Redistributions of source code must retain the above copyright 11f8bc0014Sigy * notice, this list of conditions and the following disclaimer. 12f8bc0014Sigy * 2. Redistributions in binary form must reproduce the above copyright 13f8bc0014Sigy * notice, this list of conditions and the following disclaimer in the 14f8bc0014Sigy * documentation and/or other materials provided with the distribution. 15f8bc0014Sigy * 168f53455cSigy * THIS SOFTWARE IS PROVIDED BY NAOTO SHIMAZAKI AND CONTRIBUTORS ``AS IS'' 178f53455cSigy * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 188f53455cSigy * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 198f53455cSigy * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE NAOTO OR CONTRIBUTORS BE 208f53455cSigy * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21f8bc0014Sigy * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22f8bc0014Sigy * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23f8bc0014Sigy * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24f8bc0014Sigy * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 258f53455cSigy * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 268f53455cSigy * THE POSSIBILITY OF SUCH DAMAGE. 27f8bc0014Sigy */ 28f8bc0014Sigy 29f8bc0014Sigy #ifndef _LOCORE 30f8bc0014Sigy #include <sys/types.h> 318f53455cSigy 328f53455cSigy #include <netinet/in.h> 338f53455cSigy #include <netinet/in_systm.h> 348f53455cSigy 358f53455cSigy #include <lib/libsa/net.h> 368f53455cSigy #include <lib/libsa/netif.h> 378f53455cSigy 38f8bc0014Sigy #include <mips/cpuregs.h> 39f8bc0014Sigy 40f8bc0014Sigy #include <dev/ic/comreg.h> 41f8bc0014Sigy #include <dev/ic/ns16550reg.h> 42f8bc0014Sigy #include <dev/ic/st16650reg.h> 43f8bc0014Sigy #define com_lcr com_cfcr 44f8bc0014Sigy 45f8bc0014Sigy struct bootmenu_command { 46f8bc0014Sigy const char *c_name; 47f8bc0014Sigy void (*c_fn)(char*); 48f8bc0014Sigy }; 49f8bc0014Sigy 508f53455cSigy #define BOOTOPT_MAGIC 0x4c43424fU /* LCBO */ 518f53455cSigy #define B_F_USE_BOOTP 0x00000001 528f53455cSigy 538f53455cSigy struct boot_option { 548f53455cSigy u_int32_t b_magic; 558f53455cSigy u_int32_t b_flags; 568f53455cSigy struct in_addr b_remote_ip; 578f53455cSigy struct in_addr b_local_ip; 588f53455cSigy struct in_addr b_gate_ip; 598f53455cSigy u_long b_netmask; 608f53455cSigy char b_pathname[FNAME_SIZE]; 618f53455cSigy }; 628f53455cSigy 63f8bc0014Sigy #define ROMCS0_BASE 0xbe000000U 64f8bc0014Sigy #define ROMCS3_BASE 0xbf800000U 65f8bc0014Sigy #define FLASH_BASE ROMCS0_BASE 668f53455cSigy #define BOOTOPTS_BASE 0xbfd20000U 678f53455cSigy 688f53455cSigy /* ElapsedTime registers */ 698f53455cSigy #define VRETIMEL 0x0b0000c0 708f53455cSigy #define VRETIMEM 0x0b0000c2 718f53455cSigy #define VRETIMEH 0x0b0000c4 72f8bc0014Sigy 73f8bc0014Sigy #ifdef ROMICE 74f8bc0014Sigy #define KERN_ROMBASE 0x80800000U 75f8bc0014Sigy #else 76f8bc0014Sigy #define KERN_ROMBASE 0xbf800000U 77f8bc0014Sigy #endif 78f8bc0014Sigy 79f8bc0014Sigy #define __REG_1(reg) *((volatile u_int8_t*) (reg)) 80f8bc0014Sigy #define __REG_2(reg) *((volatile u_int16_t*) (reg)) 81f8bc0014Sigy #define __REG_4(reg) *((volatile u_int32_t*) (reg)) 82f8bc0014Sigy 83f8bc0014Sigy #define REGWRITE_1(base, off, val) \ 84f8bc0014Sigy (__REG_1(MIPS_PHYS_TO_KSEG1((u_int32_t) (base) + (off))) \ 85f8bc0014Sigy = (val)) 86f8bc0014Sigy #define REGWRITE_2(base, off, val) \ 87f8bc0014Sigy (__REG_2(MIPS_PHYS_TO_KSEG1((u_int32_t) (base) + (off))) \ 88f8bc0014Sigy = (val)) 89f8bc0014Sigy #define REGWRITE_4(base, off, val) \ 90f8bc0014Sigy (__REG_4(MIPS_PHYS_TO_KSEG1((u_int32_t) (base) + (off))) \ 91f8bc0014Sigy = (val)) 92f8bc0014Sigy 93f8bc0014Sigy #define REGREAD_1(base, off) \ 94f8bc0014Sigy (__REG_1(MIPS_PHYS_TO_KSEG1((u_int32_t) (base) + (off)))) 95f8bc0014Sigy #define REGREAD_2(base, off) \ 96f8bc0014Sigy (__REG_2(MIPS_PHYS_TO_KSEG1((u_int32_t) (base) + (off)))) 97f8bc0014Sigy #define REGREAD_4(base, off) \ 98f8bc0014Sigy (__REG_4(MIPS_PHYS_TO_KSEG1((u_int32_t) (base) + (off)))) 99f8bc0014Sigy 100f8bc0014Sigy #define ISKEY ISSET(REGREAD_1(VR4181_SIU_ADDR, com_lsr), LSR_RXRDY) 101f8bc0014Sigy 102f8bc0014Sigy #define bus_space_write_1(iot, ioh, off, val) REGWRITE_1((ioh), (off), (val)) 103f8bc0014Sigy #define bus_space_write_2(iot, ioh, off, val) REGWRITE_2((ioh), (off), (val)) 104f8bc0014Sigy #define bus_space_write_4(iot, ioh, off, val) REGWRITE_4((ioh), (off), (val)) 105f8bc0014Sigy #define bus_space_read_1(iot, ioh, off) REGREAD_1((ioh), (off)) 106f8bc0014Sigy #define bus_space_read_2(iot, ioh, off) REGREAD_2((ioh), (off)) 107f8bc0014Sigy #define bus_space_read_4(iot, ioh, off) REGREAD_4((ioh), (off)) 108f8bc0014Sigy typedef void *bus_space_tag_t; 109f8bc0014Sigy typedef u_int32_t bus_space_handle_t; 110f8bc0014Sigy typedef size_t bus_size_t; 111f8bc0014Sigy 1128f53455cSigy extern struct netif_driver cs_driver; 1138f53455cSigy extern struct boot_option bootopts; 1148f53455cSigy 115f8bc0014Sigy void comcninit(void); 116f8bc0014Sigy int iskey(void); 117f8bc0014Sigy void start_netbsd(void); 118f8bc0014Sigy int i28f128_probe(void *base); 119f8bc0014Sigy int i28f128_region_write(void *dst, const void *src, size_t len); 120f8bc0014Sigy 1211625aa91Sigy /* dev_flash */ 1221625aa91Sigy int flash_strategy(void *, int, daddr_t, size_t, void *, size_t *); 1231625aa91Sigy int flash_open(struct open_file *, ...); 1241625aa91Sigy int flash_close(struct open_file *); 1251625aa91Sigy int flash_ioctl(struct open_file *, u_long, void *); 1261625aa91Sigy 1278f53455cSigy /* dev_net */ 1288f53455cSigy int net_strategy(void *, int, daddr_t, size_t, void *, size_t *); 1298f53455cSigy int net_open(struct open_file *, ...); 1308f53455cSigy int net_close(struct open_file *); 1318f53455cSigy int net_ioctl(struct open_file *, u_long, void *); 1328f53455cSigy 133f8bc0014Sigy #endif /* !_LOCORE */ 134f8bc0014Sigy 135f8bc0014Sigy #define LCBOOT_STARTADDR 0x80001000 136f8bc0014Sigy #define LCBOOT_ROMSTARTADDR 0xbfd01000 137f8bc0014Sigy #define NETBSD_STARTADDR 0x80040000 138