|
From: NIIBE Y. <gn...@ch...> - 2000-05-22 09:10:40
|
I managed to get success on build zImage. It boots. But it crashes
after gdb_detach of sh-sci.c. I don't know the reason.
And one bug fix. The bug was found by Toshinobu Sugioka.
--------------------------
2000-05-22 NIIBE Yutaka <gn...@m1...>
* arch/sh/Makefile (OBJCOPY): Added -R .stab and -R .stabstr too.
* arch/sh/vmlinux.lds.S: Fill nop (=0x0009) for .text section.
(.empty_zero_page): Make it independent section.
* arch/sh/boot/compressed/Makefile: Remove setting of CFLAGS here.
(ZIMAGE_OFFSET): Calculate the value by shell.
(piggy.o: OBJCOPY): Added -R .empty_zero_page.
* arch/sh/boot/compressed/head.S (kernel_start_addr): Use _text.
Remove __ASSEMBLY__ for newer kernel.
* arch/sh/boot/compressed/misc.c (decompress_kernel): Return type
changed to void (was: int).
(memcpy): Let it return value.
(memset): Ditto.
(HEAP_SIZE): Make it big enough.
(decompress_kernel): Use _text for initialization of output_ptr.
* drivers/char/sh-sci.c (put_char, put_string, get_char,
handle_error, lowhex, highhex, hexchars): Moved to ...
drivers/char/sh-sci.h: ...here.
drivers/char/sh-sci.c (gdb_detach): Added __init qualifier.
Bug fix.
* include/asm-sh/uaccess.h (__copy_user): Bug fix for __N == 0.
Reported by Toshinobu Sugioka <su...@it...>.
Index: arch/sh/Makefile
===================================================================
RCS file: /cvsroot/linuxsh/kernel/arch/sh/Makefile,v
retrieving revision 1.4
diff -u -r1.4 Makefile
--- arch/sh/Makefile 2000/04/14 19:14:00 1.4
+++ arch/sh/Makefile 2000/05/22 09:00:14
@@ -29,7 +29,7 @@
# endif
LD =$(CROSS_COMPILE)ld $(LDFLAGS)
-OBJCOPY=$(CROSS_COMPILE)objcopy -O binary -R .note -R .comment -S
+OBJCOPY=$(CROSS_COMPILE)objcopy -O binary -R .note -R .comment -R .stab -R .stabstr -S
MODFLAGS +=
Index: arch/sh/vmlinux.lds.S
===================================================================
RCS file: /cvsroot/linuxsh/kernel/arch/sh/vmlinux.lds.S,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 vmlinux.lds.S
--- arch/sh/vmlinux.lds.S 2000/04/14 16:49:01 1.1.1.1
+++ arch/sh/vmlinux.lds.S 2000/05/22 09:00:14
@@ -15,12 +15,14 @@
. = 0x80000000 + CONFIG_MEMORY_START + 0x1000;
_text = .; /* Text and read-only data */
text = .; /* Text and read-only data */
- .text : {
+ .empty_zero_page : {
*(.empty_zero_page)
+ } = 0
+ .text : {
*(.text)
*(.fixup)
*(.gnu.warning)
- } = 0
+ } = 0x0009
.text.lock : { *(.text.lock) } /* out-of-line lock text */
.rodata : { *(.rodata) }
.kstrtab : { *(.kstrtab) }
Index: arch/sh/boot/compressed/Makefile
===================================================================
RCS file: /cvsroot/linuxsh/kernel/arch/sh/boot/compressed/Makefile,v
retrieving revision 1.1
diff -u -r1.1 Makefile
--- arch/sh/boot/compressed/Makefile 2000/05/18 09:34:17 1.1
+++ arch/sh/boot/compressed/Makefile 2000/05/22 09:00:14
@@ -9,13 +9,12 @@
OBJECTS = $(HEAD) misc.o
-CFLAGS = -O2 -DSTDC_HEADERS
ZLDFLAGS = -e startup -T $(TOPDIR)/arch/sh/vmlinux.lds
#
# ZIMAGE_OFFSET is the load offset of the compression loader
#
-ZIMAGE_OFFSET = 0x88080000
+ZIMAGE_OFFSET = $(shell printf "0x%8x" $$[0x80000000+0x$(CONFIG_MEMORY_START)+0x100000])
ZLINKFLAGS = -Ttext $(ZIMAGE_OFFSET) $(ZLDFLAGS)
@@ -30,7 +29,7 @@
piggy.o: $(SYSTEM)
tmppiggy=_tmp_$$$$piggy; \
rm -f $$tmppiggy $$tmppiggy.gz $$tmppiggy.lnk; \
- $(OBJCOPY) $(SYSTEM) $$tmppiggy; \
+ $(OBJCOPY) -R .empty_zero_page $(SYSTEM) $$tmppiggy; \
gzip -f -9 < $$tmppiggy > $$tmppiggy.gz; \
echo "SECTIONS { .data : { input_len = .; LONG(input_data_end - input_data) input_data = .; *(.data) input_data_end = .; }}" > $$tmppiggy.lnk; \
$(LD) -r -o piggy.o -b binary $$tmppiggy.gz -b elf32-shl -T $$tmppiggy.lnk; \
Index: arch/sh/boot/compressed/head.S
===================================================================
RCS file: /cvsroot/linuxsh/kernel/arch/sh/boot/compressed/head.S,v
retrieving revision 1.1
diff -u -r1.1 head.S
--- arch/sh/boot/compressed/head.S 2000/05/18 09:34:17 1.1
+++ arch/sh/boot/compressed/head.S 2000/05/22 09:00:14
@@ -6,7 +6,6 @@
.text
-#define __ASSEMBLY__
#include <linux/linkage.h>
.global startup
@@ -51,4 +50,4 @@
decompress_kernel_addr:
.long decompress_kernel
kernel_start_addr:
- .long 0x88003000
+ .long _text+0x1000
Index: arch/sh/boot/compressed/misc.c
===================================================================
RCS file: /cvsroot/linuxsh/kernel/arch/sh/boot/compressed/misc.c,v
retrieving revision 1.1
diff -u -r1.1 misc.c
--- arch/sh/boot/compressed/misc.c 2000/05/18 09:34:17 1.1
+++ arch/sh/boot/compressed/misc.c 2000/05/22 09:00:14
@@ -9,6 +9,7 @@
* Adapted for SH by Stuart Menefy, Aug 1999
*/
+#include <linux/config.h>
#include <asm/uaccess.h>
/*
@@ -86,11 +87,12 @@
static void puts(const char *);
+extern int _text; /* Defined in vmlinux.lds.S */
extern int _end;
static unsigned long free_mem_ptr;
static unsigned long free_mem_end_ptr;
-#define HEAP_SIZE 0x2000
+#define HEAP_SIZE 0x10000
#include "../../../../lib/inflate.c"
@@ -126,21 +128,24 @@
free_mem_ptr = (long) *ptr;
}
-#if 0
-#include <asm/sci.h>
+#ifdef CONFIG_DEBUG_KERNEL_WITH_GDB_STUB
+#define IN_GDB 1
#endif
-void puts(const char *s)
+#include <asm/io.h>
+#include "../../../../drivers/char/sh-sci.h"
+
+static int strlen(const char *s)
{
-#if 0
- volatile sci_t* sci = (volatile sci_t*)SCI_BASE_ADDR;
+ int i = 0;
- while (*s != '\0') {
- while (!(sci->SCSSR & SCSSR_TDRE))
- ;
- sci->SCTDR = *s++;
- sci->SCSSR = (~ (unsigned int)SCSSR_TDRE);
- }
-#endif
+ while (*s++)
+ i++;
+ return i;
+}
+
+void puts(const char *s)
+{
+ put_string(s, strlen(s));
}
void* memset(void* s, int c, size_t n)
@@ -149,6 +154,7 @@
char *ss = (char*)s;
for (i=0;i<n;i++) ss[i] = c;
+ return s;
}
void* memcpy(void* __dest, __const void* __src,
@@ -158,13 +164,14 @@
char *d = (char *)__dest, *s = (char *)__src;
for (i=0;i<__n;i++) d[i] = s[i];
+ return __dest;
}
/* ===========================================================================
* Fill the input buffer. This is called only when the buffer is empty
* and at least one byte is really needed.
*/
-static int fill_inbuf()
+static int fill_inbuf(void)
{
if (insize != 0) {
error("ran out of input data\n");
@@ -180,7 +187,7 @@
* Write the output window window[0..outcnt-1] and update crc and bytes_out.
* (Used for the decompressed data only.)
*/
-static void flush_window()
+static void flush_window(void)
{
ulg c = crc; /* temporary variable */
unsigned n;
@@ -211,11 +218,12 @@
long user_stack [STACK_SIZE];
long* stack_start = &user_stack[STACK_SIZE];
-int decompress_kernel(void)
+void decompress_kernel(void)
{
- free_mem_ptr = (long)&_end;
+ output_data = 0;
+ output_ptr = (unsigned long)&_text+0x20001000;
+ free_mem_ptr = (unsigned long)&_end;
free_mem_end_ptr = free_mem_ptr + HEAP_SIZE;
- output_ptr = 0x88003000;
makecrc();
puts("Uncompressing Linux... ");
Index: drivers/char/sh-sci.c
===================================================================
RCS file: /cvsroot/linuxsh/kernel/drivers/char/sh-sci.c,v
retrieving revision 1.7
diff -u -r1.7 sh-sci.c
--- drivers/char/sh-sci.c 2000/05/07 23:31:59 1.7
+++ drivers/char/sh-sci.c 2000/05/22 09:00:19
@@ -40,11 +40,13 @@
#include <asm/bitops.h>
#include <linux/generic_serial.h>
-#include "sh-sci.h"
#ifdef CONFIG_DEBUG_KERNEL_WITH_GDB_STUB
static void gdb_detach(void);
+static int in_gdb = 1;
+#define IN_GDB in_gdb
#endif
+#include "sh-sci.h"
struct sci_port sci_ports[1];
@@ -802,68 +804,10 @@
* ------------------------------------------------------------
*/
-static inline void put_char(char c)
-{
- unsigned long flags;
- unsigned short status;
-
- save_and_cli(flags);
-
- do
- status = ctrl_in(SC_SR);
- while (!(status & SCI_TD_E));
-
- ctrl_outb(c, SC_TDR);
- ctrl_in(SC_SR); /* Dummy read */
- ctrl_out(SCI_TD_E_CLEAR, SC_SR);
-
- restore_flags(flags);
-}
-
#ifdef CONFIG_DEBUG_KERNEL_WITH_GDB_STUB
-static int in_gdb = 1;
-static inline void handle_error(void)
-{ /* Clear error flags */
- ctrl_out(SCI_ERROR_CLEAR, SC_SR);
-}
-
-static inline int get_char(void)
+static void __init gdb_detach(void)
{
- unsigned long flags;
- unsigned short status;
- int c;
-
- save_and_cli(flags);
- do {
- status = ctrl_in(SC_SR);
- if (status & SCI_ERRORS) {
- handle_error();
- continue;
- }
- } while (!(status & SCI_RD_F));
- c = ctrl_inb(SC_RDR);
- ctrl_in(SC_SR); /* Dummy read */
- ctrl_out(SCI_RDRF_CLEAR, SC_SR);
- restore_flags(flags);
-
- return c;
-}
-
-/* Taken from sh-stub.c of GDB 4.18 */
-static const char hexchars[] = "0123456789abcdef";
-static char highhex(int x)
-{
- return hexchars[(x >> 4) & 0xf];
-}
-
-static char lowhex(int x)
-{
- return hexchars[x & 0xf];
-}
-
-static void gdb_detach(void)
-{
asm volatile("trapa #0xff");
if (in_gdb == 1) {
@@ -874,48 +818,6 @@
}
}
#endif
-
-/* send the packet in buffer. The host get's one chance to read it.
- This routine does not wait for a positive acknowledge. */
-
-static void
-put_string(const char *buffer, int count)
-{
- int i;
- const unsigned char *p = buffer;
-#ifdef CONFIG_DEBUG_KERNEL_WITH_GDB_STUB
- int checksum;
-
-if (in_gdb) {
- /* $<packet info>#<checksum>. */
- do {
- unsigned char c;
- put_char('$');
- put_char('O'); /* 'O'utput to console */
- checksum = 'O';
-
- for (i=0; i<count; i++) { /* Don't use run length encoding */
- int h, l;
-
- c = *p++;
- h = highhex(c);
- l = lowhex(c);
- put_char(h);
- put_char(l);
- checksum += h + l;
- }
- put_char('#');
- put_char(highhex(checksum));
- put_char(lowhex(checksum));
- } while (get_char() != '+');
-} else
-#endif
- for (i=0; i<count; i++) {
- if (*p == 10)
- put_char('\r');
- put_char(*p++);
- }
-}
/*
* Print a string to the serial port trying not to disturb
Index: drivers/char/sh-sci.h
===================================================================
RCS file: /cvsroot/linuxsh/kernel/drivers/char/sh-sci.h,v
retrieving revision 1.5
diff -u -r1.5 sh-sci.h
--- drivers/char/sh-sci.h 2000/05/05 03:46:04 1.5
+++ drivers/char/sh-sci.h 2000/05/22 09:00:20
@@ -171,10 +171,12 @@
#define SCI_MAGIC 0xbabeface
+#ifdef GENERIC_SERIAL_H
struct sci_port {
struct gs_port gs;
unsigned int old_cflag;
};
+#endif
#define WAIT_RFCR_COUNTER 200
@@ -215,3 +217,106 @@
#define BPS_19200 SCBRR_VALUE(19200)
#define BPS_38400 SCBRR_VALUE(38400)
#define BPS_115200 SCBRR_VALUE(115200)
+
+#ifdef CONFIG_DEBUG_KERNEL_WITH_GDB_STUB
+/* Taken from sh-stub.c of GDB 4.18 */
+static const char hexchars[] = "0123456789abcdef";
+
+static __inline__ char highhex(int x)
+{
+ return hexchars[(x >> 4) & 0xf];
+}
+
+static __inline__ char lowhex(int x)
+{
+ return hexchars[x & 0xf];
+}
+#endif
+
+static __inline__ void put_char(char c)
+{
+ unsigned long flags;
+ unsigned short status;
+
+ save_and_cli(flags);
+
+ do
+ status = ctrl_in(SC_SR);
+ while (!(status & SCI_TD_E));
+
+ ctrl_outb(c, SC_TDR);
+ ctrl_in(SC_SR); /* Dummy read */
+ ctrl_out(SCI_TD_E_CLEAR, SC_SR);
+
+ restore_flags(flags);
+}
+
+static __inline__ void handle_error(void)
+{ /* Clear error flags */
+ ctrl_out(SCI_ERROR_CLEAR, SC_SR);
+}
+
+static __inline__ int get_char(void)
+{
+ unsigned long flags;
+ unsigned short status;
+ int c;
+
+ save_and_cli(flags);
+ do {
+ status = ctrl_in(SC_SR);
+ if (status & SCI_ERRORS) {
+ handle_error();
+ continue;
+ }
+ } while (!(status & SCI_RD_F));
+ c = ctrl_inb(SC_RDR);
+ ctrl_in(SC_SR); /* Dummy read */
+ ctrl_out(SCI_RDRF_CLEAR, SC_SR);
+ restore_flags(flags);
+
+ return c;
+}
+
+/*
+ * Send the packet in buffer. The host get's one chance to read it.
+ * This routine does not wait for a positive acknowledge.
+ */
+
+static __inline__ void put_string(const char *buffer, int count)
+{
+ int i;
+ const unsigned char *p = buffer;
+#ifdef CONFIG_DEBUG_KERNEL_WITH_GDB_STUB
+ int checksum;
+
+if (IN_GDB) {
+ /* $<packet info>#<checksum>. */
+ do {
+ unsigned char c;
+ put_char('$');
+ put_char('O'); /* 'O'utput to console */
+ checksum = 'O';
+
+ for (i=0; i<count; i++) { /* Don't use run length encoding */
+ int h, l;
+
+ c = *p++;
+ h = highhex(c);
+ l = lowhex(c);
+ put_char(h);
+ put_char(l);
+ checksum += h + l;
+ }
+ put_char('#');
+ put_char(highhex(checksum));
+ put_char(lowhex(checksum));
+ } while (get_char() != '+');
+} else
+#endif
+ for (i=0; i<count; i++) {
+ if (*p == 10)
+ put_char('\r');
+ put_char(*p++);
+ }
+}
Index: include/asm-sh/uaccess.h
===================================================================
RCS file: /cvsroot/linuxsh/kernel/include/asm-sh/uaccess.h,v
retrieving revision 1.4
diff -u -r1.4 uaccess.h
--- include/asm-sh/uaccess.h 2000/04/14 19:14:01 1.4
+++ include/asm-sh/uaccess.h 2000/05/22 09:00:42
@@ -216,6 +216,7 @@
unsigned long __dummy, _f, _t;
__kernel_size_t res;
+ if ((res = __n))
__asm__ __volatile__(
"9:\n\t"
"mov.b @%2+, %1\n\t"
@@ -239,7 +240,7 @@
" .long 1b,2b\n"
".previous"
: "=r" (res), "=&z" (__dummy), "=r" (_f), "=r" (_t)
- : "2" (__from), "3" (__to), "0" (__n), "i" (-EFAULT)
+ : "2" (__from), "3" (__to), "0" (res), "i" (-EFAULT)
: "memory");
return res;
|