Author: cgutman
Date: Tue Jan 26 05:20:06 2010
New Revision: 45257
URL: http://svn.reactos.org/svn/reactos?rev=45257&view=rev
Log:
- Define OSKIT so we can use special oskit functions
- Implement oskit buffer functions to track references and allocate buffers
- Remove unneeded mbuf freeing hacks now that we track references (fixes random crashes would occur when an mbuf was freed inside ip_output)
- Remove the "ACK hack" that we used to hack around our loopback implementation
- Remove unneeded mbuf pool initialization
- Remove unused code in sleep.c
Added:
branches/aicom-network-branch/lib/drivers/oskittcp/include/osenv.h (with props)
branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp/osenv.c (with props)
Modified:
branches/aicom-network-branch/lib/drivers/oskittcp/include/freebsd/src/sys/sys/malloc.h
branches/aicom-network-branch/lib/drivers/oskittcp/include/freebsd/src/sys/sys/proc.h
branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp.rbuild
branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp/interface.c
branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp/ip_output.c
branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp/sleep.c
branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp/tcp_output.c
branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp/tcp_subr.c
branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp/uipc_mbuf.c
Modified: branches/aicom-network-branch/lib/drivers/oskittcp/include/freebsd/src/sys/sys/malloc.h
URL: http://svn.reactos.org/svn/reactos/branches/aicom-network-branch/lib/driver…
==============================================================================
--- branches/aicom-network-branch/lib/drivers/oskittcp/include/freebsd/src/sys/sys/malloc.h [iso-8859-1] (original)
+++ branches/aicom-network-branch/lib/drivers/oskittcp/include/freebsd/src/sys/sys/malloc.h [iso-8859-1] Tue Jan 26 05:20:06 2010
@@ -36,7 +36,7 @@
#ifndef _SYS_MALLOC_H_
#define _SYS_MALLOC_H_
-#ifndef OSKIT
+#if !defined(OSKIT) || defined(__REACTOS__)
#define KMEMSTATS
#endif
@@ -288,7 +288,6 @@
#define MALLOC(space, cast, size, type, flags) \
(space) = (cast)fbsd_malloc((u_long)(size), __FILE__, __LINE__, type, flags)
#define FREE(addr, type) fbsd_free((caddr_t)(addr), __FILE__, __LINE__, type)
-
#else /* do not collect statistics */
#define MALLOC(space, cast, size, type, flags) { \
register struct kmembuckets *kbp = &bucket[BUCKETINDX(size)]; \
Modified: branches/aicom-network-branch/lib/drivers/oskittcp/include/freebsd/src/sys/sys/proc.h
URL: http://svn.reactos.org/svn/reactos/branches/aicom-network-branch/lib/driver…
==============================================================================
--- branches/aicom-network-branch/lib/drivers/oskittcp/include/freebsd/src/sys/sys/proc.h [iso-8859-1] (original)
+++ branches/aicom-network-branch/lib/drivers/oskittcp/include/freebsd/src/sys/sys/proc.h [iso-8859-1] Tue Jan 26 05:20:06 2010
@@ -65,7 +65,11 @@
#include <sys/socketvar.h>
#ifdef OSKIT
+#ifndef __REACTOS__
#include <oskit/dev/dev.h>
+#else
+#include <osenv.h>
+#endif
#endif
/*
Added: branches/aicom-network-branch/lib/drivers/oskittcp/include/osenv.h
URL: http://svn.reactos.org/svn/reactos/branches/aicom-network-branch/lib/driver…
==============================================================================
--- branches/aicom-network-branch/lib/drivers/oskittcp/include/osenv.h (added)
+++ branches/aicom-network-branch/lib/drivers/oskittcp/include/osenv.h [iso-8859-1] Tue Jan 26 05:20:06 2010
@@ -1,0 +1,14 @@
+#ifndef OSENV_H
+#define OSENV_H
+
+static __inline void osenv_intr_enable(void) {}
+static __inline void osenv_intr_disable(void) {}
+
+void oskit_bufio_addref(void *buf);
+void oskit_bufio_release(void *buf);
+void* oskit_bufio_create(int len);
+void oskit_bufio_map(void *srcbuf, void**dstbuf, int off, int len);
+
+#define osenv_sleeprec_t void*
+
+#endif
Propchange: branches/aicom-network-branch/lib/drivers/oskittcp/include/osenv.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp.rbuild
URL: http://svn.reactos.org/svn/reactos/branches/aicom-network-branch/lib/driver…
==============================================================================
--- branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp.rbuild [iso-8859-1] (original)
+++ branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp.rbuild [iso-8859-1] Tue Jan 26 05:20:06 2010
@@ -3,6 +3,7 @@
<module name="oskittcp" type="staticlibrary">
<define name="__NTDRIVER__"/>
<define name="KERNEL"/>
+ <define name="OSKIT"/>
<include base="oskittcp">include/freebsd</include>
<include base="oskittcp">include/freebsd/sys/include</include>
<include base="oskittcp">include/freebsd/src/sys</include>
@@ -22,6 +23,7 @@
<file>ip_output.c</file>
<file>kern_clock.c</file>
<file>kern_subr.c</file>
+ <file>osenv.c</file>
<file>param.c</file>
<file>radix.c</file>
<file>random.c</file>
Modified: branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp/interface.c
URL: http://svn.reactos.org/svn/reactos/branches/aicom-network-branch/lib/driver…
==============================================================================
--- branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp/interface.c [iso-8859-1] (original)
+++ branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp/interface.c [iso-8859-1] Tue Jan 26 05:20:06 2010
@@ -48,8 +48,6 @@
void InitOskitTCP() {
OS_DbgPrint(OSK_MID_TRACE,("Init Called\n"));
KeInitializeSpinLock(&OSKLock);
- OS_DbgPrint(OSK_MID_TRACE,("MB Init\n"));
- mbinit();
OS_DbgPrint(OSK_MID_TRACE,("Rawip Init\n"));
rip_init();
raw_init();
Modified: branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp/ip_output.c
URL: http://svn.reactos.org/svn/reactos/branches/aicom-network-branch/lib/driver…
==============================================================================
--- branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp/ip_output.c [iso-8859-1] (original)
+++ branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp/ip_output.c [iso-8859-1] Tue Jan 26 05:20:06 2010
@@ -393,6 +393,7 @@
error = OtcpEvent.PacketSend( OtcpEvent.ClientData,
(OSK_PCHAR)new_m->m_data, new_m->m_len );
m_free( new_m );
+ m_freem( m );
goto done;
}
#else
@@ -532,6 +533,7 @@
error = OtcpEvent.PacketSend( OtcpEvent.ClientData,
(OSK_PCHAR)new_m->m_data, new_m->m_len );
m_free( new_m );
+ m_freem( m );
}
OS_DbgPrint(OSK_MID_TRACE,("Error from upper layer: %d\n", error));
Added: branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp/osenv.c
URL: http://svn.reactos.org/svn/reactos/branches/aicom-network-branch/lib/driver…
==============================================================================
--- branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp/osenv.c (added)
+++ branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp/osenv.c [iso-8859-1] Tue Jan 26 05:20:06 2010
@@ -1,0 +1,45 @@
+#include "oskittcp.h"
+
+unsigned oskit_freebsd_cpl;
+
+/* We have to store a reference count somewhere so we
+ * don't free a buffer being referenced in another mbuf.
+ * I just decided to add an extra char to the beginning of
+ * the buffer and store the reference count there. I doubt the ref count
+ * will ever even get close to 0xFF so we should be ok. Remember that
+ * only one thread can ever be inside oskit due to OSKLock so this should
+ * be safe.
+ */
+
+void oskit_bufio_addref(void *buf)
+{
+ unsigned char* fullbuf = ((unsigned char*)buf) - sizeof(char);
+
+#if DBG
+ if (fullbuf[0] == 0xFF)
+ panic("oskit_bufio_addref: ref count overflow");
+#endif
+
+ fullbuf[0]++;
+}
+void oskit_bufio_release(void *buf)
+{
+ unsigned char* fullbuf = ((unsigned char*)buf) - sizeof(char);
+
+ if (--fullbuf[0] == 0)
+ free(fullbuf, 0);
+}
+void* oskit_bufio_create(int len)
+{
+ unsigned char* fullbuf = malloc(len + sizeof(char), __FILE__, __LINE__);
+ if (fullbuf == NULL)
+ return NULL;
+
+ fullbuf[0] = 1;
+
+ return (void*)(fullbuf + sizeof(char));
+}
+void oskit_bufio_map(void *srcbuf, void**dstbuf, int off, int len)
+{
+ *dstbuf = srcbuf;
+}
Propchange: branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp/osenv.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp/sleep.c
URL: http://svn.reactos.org/svn/reactos/branches/aicom-network-branch/lib/driver…
==============================================================================
--- branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp/sleep.c [iso-8859-1] (original)
+++ branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp/sleep.c [iso-8859-1] Tue Jan 26 05:20:06 2010
@@ -91,53 +91,3 @@
/* Start a clock we can use for timeouts */
}
-
-extern unsigned bio_imask; /* group of interrupts masked with splbio() */
-extern unsigned cpl; /* current priority level mask */
-extern volatile unsigned idelayed; /* interrupts to become pending */
-extern volatile unsigned ipending; /* active interrupts masked by cpl */
-extern unsigned net_imask; /* group of interrupts masked with splimp() */
-extern unsigned stat_imask; /* interrupts masked with splstatclock() */
-extern unsigned tty_imask; /* group of interrupts masked with spltty() */
-
-/*
- * ipending has to be volatile so that it is read every time it is accessed
- * in splx() and spl0(), but we don't want it to be read nonatomically when
- * it is changed. Pretending that ipending is a plain int happens to give
- * suitable atomic code for "ipending |= constant;".
- */
-#define setdelayed() (*(unsigned *)&ipending |= loadandclear(&idelayed))
-#define setsoftast() (*(unsigned *)&ipending |= SWI_AST_PENDING)
-#define setsoftclock() (*(unsigned *)&ipending |= SWI_CLOCK_PENDING)
-#define setsoftnet() (*(unsigned *)&ipending |= SWI_NET_PENDING)
-#define setsofttty() (*(unsigned *)&ipending |= SWI_TTY_PENDING)
-
-#define schedsofttty() (*(unsigned *)&idelayed |= SWI_TTY_PENDING)
-
-#define GENSPL(name, set_cpl) \
-static __inline int name(void) \
-{ \
- unsigned x; \
- \
- __asm __volatile("" : : : "memory"); \
- x = cpl; \
- set_cpl; \
- return (x); \
-}
-
-void splz(void) {
- OS_DbgPrint(OSK_MID_TRACE,("Called SPLZ\n"));
-}
-
-/*
- * functions to save and restore the current cpl
- */
-void save_cpl(unsigned *x)
-{
- *x = cpl;
-}
-
-void restore_cpl(unsigned x)
-{
- cpl = x;
-}
Modified: branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp/tcp_output.c
URL: http://svn.reactos.org/svn/reactos/branches/aicom-network-branch/lib/driver…
==============================================================================
--- branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp/tcp_output.c [iso-8859-1] (original)
+++ branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp/tcp_output.c [iso-8859-1] Tue Jan 26 05:20:06 2010
@@ -708,38 +708,8 @@
((struct ip *)ti)->ip_off |= IP_DF;
}
#endif
- /*
- * XXX: It seems that osktittcp expects that packets are
- * synchronously processed. The current implementation feeds
- * oskittcp with the packets asynchronously. That's not a
- * problem normally when the packets are transfered over
- * network, but it starts to be a problem when it comes to
- * loopback packets.
- * The ACK bits are set in tcp_input which calls tcp_output and
- * expects them to be cleared before further processing.
- * Instead tcp_output calls ip_output which produces a packet
- * and ends up in tcp_input and we're stuck in infinite loop.
- * Normally the flags are masked out at the end of this function
- * and the incomming packets are processed then, but since
- * currently the loopback packet is delivered during the
- * ip_output call, the function end is never reached...
- */
-#ifdef __REACTOS__
- tp->t_flags &= ~(TF_ACKNOW|TF_DELACK);
-#endif
error = ip_output(m, tp->t_inpcb->inp_options, &tp->t_inpcb->inp_route,
so->so_options & SO_DONTROUTE, 0);
-#ifdef __REACTOS__
- /* We allocated m, so we are responsible for freeing it. If the mbuf
- contains a pointer to an external datablock, we (or rather, m_copy)
- didn't allocate it but pointed it to the data to send. So we have
- to cheat a little bit and keep M_FREE from freeing the external
- data block */
- while (NULL != m) {
- m->m_flags &= ~M_EXT;
- m = m_free(m);
- }
-#endif
}
if (error) {
out:
Modified: branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp/tcp_subr.c
URL: http://svn.reactos.org/svn/reactos/branches/aicom-network-branch/lib/driver…
==============================================================================
--- branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp/tcp_subr.c [iso-8859-1] (original)
+++ branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp/tcp_subr.c [iso-8859-1] Tue Jan 26 05:20:06 2010
@@ -163,7 +163,6 @@
tcp_seq ack, seq;
int flags;
{
- struct mbuf *n;
register int tlen;
int win = 0;
struct route *ro = 0;
@@ -222,18 +221,6 @@
tcp_trace(TA_OUTPUT, 0, tp, ti, 0);
#endif
(void) ip_output(m, NULL, ro, 0, NULL);
-#ifdef __REACTOS__
- /* We allocated m, so we are responsible for freeing it. If the mbuf
- contains a pointer to an external datablock, we (or rather, m_copy)
- didn't allocate it but pointed it to the data to send. So we have
- to cheat a little bit and keep M_FREE from freeing the external
- data block */
- while (NULL != m) {
- m->m_flags &= ~M_EXT;
- MFREE(m, n);
- m = n;
- }
-#endif
}
/*
Modified: branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp/uipc_mbuf.c
URL: http://svn.reactos.org/svn/reactos/branches/aicom-network-branch/lib/driver…
==============================================================================
--- branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp/uipc_mbuf.c [iso-8859-1] (original)
+++ branches/aicom-network-branch/lib/drivers/oskittcp/oskittcp/uipc_mbuf.c [iso-8859-1] Tue Jan 26 05:20:06 2010
@@ -663,7 +663,7 @@
return (n);
}
-#ifndef OSKIT
+#if !defined(OSKIT) || defined(__REACTOS__)
/* currently not OS Kit approved, and shouldn't be needed in the first place */
/*
Author: cfinck
Date: Tue Jan 26 00:26:50 2010
New Revision: 45256
URL: http://svn.reactos.org/svn/reactos?rev=45256&view=rev
Log:
Add another parameter to the Buildtoolchain script to automatically create the "mingw_runtime_dev" package from the "mingw_runtime" and "w32api" packages.
This one is needed for RosBE-Unix, because this platform has no Win32 host compiler, so all Win32 libs need to be precompiled. We don't want to use the MinGW-provided dev package, since we add our "ofmt_stub.a" to this package.
Modified:
trunk/tools/RosBE/RosBE-Windows/Buildtoolchain/rosbe_1.5/buildtoolchain.sh
Modified: trunk/tools/RosBE/RosBE-Windows/Buildtoolchain/rosbe_1.5/buildtoolchain.sh
URL: http://svn.reactos.org/svn/reactos/trunk/tools/RosBE/RosBE-Windows/Buildtoo…
==============================================================================
--- trunk/tools/RosBE/RosBE-Windows/Buildtoolchain/rosbe_1.5/buildtoolchain.sh [iso-8859-1] (original)
+++ trunk/tools/RosBE/RosBE-Windows/Buildtoolchain/rosbe_1.5/buildtoolchain.sh [iso-8859-1] Tue Jan 26 00:26:50 2010
@@ -61,7 +61,7 @@
# We don't want too less parameters
if [ "$2" == "" ]; then
- echo -n "Syntax: ./buildtoolchain.sh <sources> <workdir>"
+ echo -n "Syntax: ./buildtoolchain.sh <sources> <workdir> [make_dev]"
for module in $MODULES; do
echo -n " [$module]"
@@ -72,6 +72,9 @@
echo " sources - Path to the directory containing RosBE-Unix toolchain packages (.tar.bz2 files)"
echo " workdir - Path to the directory used for building. Will contain the final executables and"
echo " temporary files."
+ echo " make_dev - Pass 1 here if you want to build the \"mingw_runtime_dev\" package required for"
+ echo " RosBE-Unix. All following options will be ignored in this case."
+ echo " Otherwise pass 0, which is the default option."
echo
echo "The rest of the arguments are optional. You specify them if you want to prevent a component"
echo "from being (re)built. Do this by passing 0 as the argument of the appropriate component."
@@ -107,16 +110,41 @@
rs_prefixdir="$rs_workdir/mingw"
rs_supportprefixdir="$rs_workdir/support"
-# Set the rs_process_* variables based on the parameters
-for module in $MODULES; do
- if [ "$1" = "0" ]; then
+# Find out if we just want to build the "mingw_runtime_dev" package
+if [ "$1" = "1" ]; then
+ make_dev_package=true
+else
+ make_dev_package=false
+fi
+
+shift
+
+if $make_dev_package; then
+ # Disable processing all modules
+ for module in $MODULES; do
eval "rs_process_$module=false"
- else
- eval "rs_process_$module=true"
- fi
-
- shift
-done
+ done
+
+ # Only process w32api and mingw_runtime
+ rs_process_w32api=true
+ rs_process_mingw_runtime=true
+
+ # Set a prefix different to the one used for w32api, so that we can later package the built files
+ mingw_runtime_prefix="$rs_prefixdir/mingw_runtime_dev"
+else
+ # Set the rs_process_* variables based on the parameters
+ for module in $MODULES; do
+ if [ "$1" = "0" ]; then
+ eval "rs_process_$module=false"
+ else
+ eval "rs_process_$module=true"
+ fi
+
+ shift
+ done
+
+ mingw_runtime_prefix="$rs_prefixdir/$rs_target"
+fi
rs_mkdir_empty "$SYSHEADERDIR"
@@ -126,6 +154,7 @@
rs_mkdir_if_not_exists "$rs_prefixdir/$rs_target"
rs_mkdir_if_not_exists "$rs_supportprefixdir"
+rs_mkdir_if_not_exists "$mingw_runtime_prefix"
rs_extract_module "w32api" "$rs_prefixdir/$rs_target"
@@ -136,7 +165,7 @@
export CFLAGS="$rs_target_cflags"
export C_INCLUDE_PATH="$rs_prefixdir/$rs_target/include"
- rs_do_command ../mingw_runtime/configure --prefix="$rs_prefixdir/$rs_target" --host="$rs_target" --build="$rs_target" --disable-werror
+ rs_do_command ../mingw_runtime/configure --prefix="$mingw_runtime_prefix" --host="$rs_target" --build="$rs_target" --disable-werror
rs_do_command $rs_makecmd -j $rs_cpucount
rs_do_command $rs_makecmd install
@@ -145,12 +174,10 @@
# As we use MinGW's libmingwex.a, but our own libmsvcrt.a, linking to MinGW's libmingwex.a will fail by default. Therefore we have to create an archive for the compiled
# _get_output_format stub, copy it to our "lib" directory and include it when linking to libmingwex.a.
ar r ofmt_stub.a ofmt_stub.o >& /dev/null
- cp ofmt_stub.a "$rs_prefixdir/$rs_target/lib"
+ cp ofmt_stub.a "$mingw_runtime_prefix/lib"
rs_clean_module "mingw_runtime"
- # The "mingw_runtime_dev" package needed for RosBE-Unix is manually created from the result of this build.
-
unset CFLAGS
unset C_INCLUDE_PATH
fi
@@ -223,5 +250,11 @@
find -name "*.o" -type f -exec strip -d {} ";"
##### END almost shared buildtoolchain/RosBE-Unix building part ###############
+# Create the package out of the built files if we want to build the "mingw_runtime_dev" package
+if $make_dev_package; then
+ echo "Creating the \"mingw_runtime_dev.tar.bz2\" archive..."
+ cd "$mingw_runtime_prefix"
+ tar -cjf "mingw_runtime_dev.tar.bz2" include lib
+fi
echo "Finished!"