From: Lawrence S. <ljs...@us...> - 2015-02-08 21:23:30
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 37efbd3d3ae01027d580fc4cded94ccb2132bb0c (commit) from 0fbcec655e5aaa5a9823f34c1f8f9abb6fe023ec (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 37efbd3d3ae01027d580fc4cded94ccb2132bb0c Author: Lawrence Sebald <ljs...@us...> Date: Sun Feb 8 16:22:53 2015 -0500 Get our IP address from dcload-ip when it matters. ----------------------------------------------------------------------- Summary of changes: include/kos/net.h | 8 +++++++- kernel/arch/dreamcast/fs/fs_dclsocket.c | 8 +++++++- kernel/arch/dreamcast/kernel/init.c | 18 +++++++++++++++--- kernel/net/net_core.c | 13 ++++++++++--- 4 files changed, 39 insertions(+), 8 deletions(-) diff --git a/include/kos/net.h b/include/kos/net.h index cfb7428..bb42f1f 100644 --- a/include/kos/net.h +++ b/include/kos/net.h @@ -745,9 +745,15 @@ int net_reg_device(netif_t *device); int net_unreg_device(netif_t *device); /** \brief Init network support. + \param ip The IPv4 address to set on the default device, in + host byte order. + \return 0 on success, <0 on failure. + \note To auto-detect the IP address to assign to the + default device (i.e, over DHCP or from the flashrom + on the Dreamcast), pass 0 as the IP parameter. */ -int net_init(void); +int net_init(uint32 ip); /** \brief Shutdown network support. */ void net_shutdown(void); diff --git a/kernel/arch/dreamcast/fs/fs_dclsocket.c b/kernel/arch/dreamcast/fs/fs_dclsocket.c index 70d9bb1..d4c94f5 100644 --- a/kernel/arch/dreamcast/fs/fs_dclsocket.c +++ b/kernel/arch/dreamcast/fs/fs_dclsocket.c @@ -1,7 +1,7 @@ /* KallistiOS ##version## kernel/arch/dreamcast/fs/fs_dclsocket.c - Copyright (C) 2007, 2008, 2012, 2013 Lawrence Sebald + Copyright (C) 2007, 2008, 2012, 2013, 2015 Lawrence Sebald Based on fs_dclnative.c and related files Copyright (C) 2003 Dan Potter @@ -760,6 +760,12 @@ void fs_dclsocket_init_console() { initted = 1; } +uint32 _fs_dclsocket_get_ip(void) { + uint32 ip, port; + + return dcloadsyscall(DCLOAD_GETHOSTINFO, &ip, &port); +} + int fs_dclsocket_init() { struct sockaddr_in addr; int err; diff --git a/kernel/arch/dreamcast/kernel/init.c b/kernel/arch/dreamcast/kernel/init.c index 9f0c5d8..85369cf 100644 --- a/kernel/arch/dreamcast/kernel/init.c +++ b/kernel/arch/dreamcast/kernel/init.c @@ -1,7 +1,8 @@ /* KallistiOS ##version## init.c - Copyright (C)2003 Dan Potter + Copyright (C) 2003 Dan Potter + Copyright (C) 2015 Lawrence Sebald */ #include <stdio.h> @@ -29,8 +30,8 @@ void fini(void); void __verify_newlib_patch(); #endif -/* Ditto */ int main(int argc, char **argv); +uint32 _fs_dclsocket_get_ip(void); /* We have to put this here so we can include plat-specific devices */ dbgio_handler_t * dbgio_handlers[] = { @@ -46,6 +47,11 @@ int dbgio_handler_cnt = sizeof(dbgio_handlers) / sizeof(dbgio_handler_t *); to be running in your build, and also below in arch_main() */ /* #if 0 */ int __attribute__((weak)) arch_auto_init() { + union { + uint32 ipl; + uint8 ipb[4]; + } ip; + /* Initialize memory management */ mm_init(); @@ -117,13 +123,19 @@ int __attribute__((weak)) arch_auto_init() { } if(__kos_init_flags & INIT_NET) { + ip.ipl = 0; + /* Check if the dcload-ip console is up, and if so, disable it, otherwise we'll crash when we attempt to bring up the BBA */ if(!(__kos_init_flags & INIT_NO_DCLOAD) && dcload_type == DCLOAD_TYPE_IP) { + /* Grab the IP address from dcload before we disable dbgio... */ + ip.ipl = _fs_dclsocket_get_ip(); + dbglog(DBG_INFO, "dc-load says our IP is %d.%d.%d.%d\n", ip.ipb[3], + ip.ipb[2], ip.ipb[1], ip.ipb[0]); dbgio_disable(); } - net_init(); /* Enable networking (and drivers) */ + net_init(ip.ipl); /* Enable networking (and drivers) */ if(!(__kos_init_flags & INIT_NO_DCLOAD) && dcload_type == DCLOAD_TYPE_IP) { fs_dclsocket_init_console(); diff --git a/kernel/net/net_core.c b/kernel/net/net_core.c index 73c8575..c453b92 100644 --- a/kernel/net/net_core.c +++ b/kernel/net/net_core.c @@ -140,7 +140,7 @@ int net_dev_init(void) { } /* Init */ -int net_init(void) { +int net_init(uint32 ip) { int rv = 0; /* Make sure we haven't already done this */ @@ -179,8 +179,15 @@ int net_init(void) { /* Initialize the DHCP system */ net_dhcp_init(); - if(net_default_dev && !net_default_dev->ip_addr[0]) { - rv = net_dhcp_request(); + if(net_default_dev) { + /* Did we get a requested IP address? If so, set it. */ + if(ip) + net_ipv4_parse_address(ip, net_default_dev->ip_addr); + + /* We didn't get a requested IP address, if we don't already have one + set, then do so via DHCP. */ + else if(!net_default_dev->ip_addr[0]) + rv = net_dhcp_request(); } net_initted = 1; hooks/post-receive -- A pseudo Operating System for the Dreamcast. |