summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Config.lb3
-rw-r--r--src/lib/memcpy.c11
-rw-r--r--src/lib/memmove.c20
-rw-r--r--src/lib/uart8250.c16
4 files changed, 44 insertions, 6 deletions
diff --git a/src/lib/Config.lb b/src/lib/Config.lb
index a0de47c570..bd6a2a9090 100644
--- a/src/lib/Config.lb
+++ b/src/lib/Config.lb
@@ -6,10 +6,11 @@ object uart8250.o
object memset.o
object memcpy.o
object memcmp.o
+object memmove.o
object malloc.o
object delay.o
if HAVE_FALLBACK_BOOT
- object fallback_boot.o
+ object fallback_boot.o
end
object compute_ip_checksum.o
object version.o
diff --git a/src/lib/memcpy.c b/src/lib/memcpy.c
index ad8e8bd3f0..16db67766d 100644
--- a/src/lib/memcpy.c
+++ b/src/lib/memcpy.c
@@ -1,11 +1,12 @@
#include <string.h>
-void *memcpy(void *__dest, __const void *__src, size_t __n)
+void *memcpy(void *vdest, const void *vsrc, size_t bytes)
{
+ const char *src = vsrc;
+ char *dest = vdest;
int i;
- char *d = (char *) __dest, *s = (char *) __src;
- for (i = 0; i < __n; i++)
- d[i] = s[i];
+ for (i = 0; i < bytes; i++)
+ dest[i] = src[i];
- return __dest;
+ return vdest;
}
diff --git a/src/lib/memmove.c b/src/lib/memmove.c
new file mode 100644
index 0000000000..0a4908325e
--- /dev/null
+++ b/src/lib/memmove.c
@@ -0,0 +1,20 @@
+#include <string.h>
+void *memmove(void *vdest, const void *vsrc, size_t count)
+{
+ const char *src = vsrc;
+ char *dest = vdest;
+ int i;
+
+ if (dest <= src) {
+ while (count--) {
+ *dest++ = *src++;
+ }
+ } else {
+ src += count - 1;
+ dest += count - 1;
+ while(count--) {
+ *dest-- = *src--;
+ }
+ }
+ return vdest;
+}
diff --git a/src/lib/uart8250.c b/src/lib/uart8250.c
index ceb4e4aa86..67b0a95cfb 100644
--- a/src/lib/uart8250.c
+++ b/src/lib/uart8250.c
@@ -58,3 +58,19 @@ void uart8250_init(unsigned base_port, unsigned divisor, unsigned lcs)
outb((divisor >> 8) & 0xFF, base_port + UART_DLM);
outb(lcs, base_port + UART_LCR);
}
+
+/* Initialize a generic uart */
+void init_uart8250(unsigned base_port, struct uart8250 *uart)
+{
+ int divisor;
+ int lcs;
+ divisor = 115200/(uart->baud ? uart->baud: 1);
+ lcs = 3;
+ if (base_port == TTYS0_BASE) {
+ /* Don't reinitialize the console serial port,
+ * This is espeically nasty in SMP.
+ */
+ return;
+ }
+ uart8250_init(base_port, divisor, lcs);
+}