Changeset 0ffa3ef5 in mainline
- Timestamp:
- 2006-07-10T20:57:30Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 11675207
- Parents:
- 7f1c620
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/sparc64/include/asm.h
r7f1c620 r0ffa3ef5 27 27 */ 28 28 29 29 /** @addtogroup sparc64 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 35 #ifndef __sparc64_ASM_H__36 #define __sparc64_ASM_H__35 #ifndef KERN_sparc64_ASM_H_ 36 #define KERN_sparc64_ASM_H_ 37 37 38 38 #include <typedefs.h> … … 305 305 } 306 306 307 308 309 307 void cpu_halt(void); 310 308 void cpu_sleep(void); … … 313 311 #endif 314 312 315 /** @} 316 */ 317 313 /** @} 314 */ -
arch/sparc64/include/atomic.h
r7f1c620 r0ffa3ef5 27 27 */ 28 28 29 29 /** @addtogroup sparc64 30 30 * @{ 31 31 */ … … 100 100 #endif 101 101 102 102 /** @} 103 103 */ 104 -
arch/sparc64/include/barrier.h
r7f1c620 r0ffa3ef5 27 27 */ 28 28 29 29 /** @addtogroup sparc64 30 30 * @{ 31 31 */ … … 70 70 #endif 71 71 72 72 /** @} 73 73 */ 74 -
arch/sparc64/include/console.h
r7f1c620 r0ffa3ef5 27 27 */ 28 28 29 29 /** @addtogroup sparc64 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 35 #ifndef __sparc64_CONSOLE_H__36 #define __sparc64_CONSOLE_H__35 #ifndef KERN_sparc64_CONSOLE_H_ 36 #define KERN_sparc64_CONSOLE_H_ 37 37 38 extern void kofwinput(void *arg);39 38 extern void kkbdpoll(void *arg); 40 39 extern void ofw_sparc64_console_init(void); … … 43 42 #endif 44 43 45 44 /** @} 46 45 */ 47 -
arch/sparc64/include/drivers/fb.h
r7f1c620 r0ffa3ef5 27 27 */ 28 28 29 29 /** @addtogroup sparc64 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 35 #ifndef __sparc64_FB_H__36 #define __sparc64_FB_H__35 #ifndef KERN_sparc64_FB_H_ 36 #define KERN_sparc64_FB_H_ 37 37 38 38 #define FB_PHYS_ADDRESS 0x1c901000000ULL … … 45 45 #endif 46 46 47 47 /** @} 48 48 */ 49 -
arch/sparc64/include/drivers/i8042.h
r7f1c620 r0ffa3ef5 27 27 */ 28 28 29 29 /** @addtogroup sparc64 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 35 #ifndef __sparc64_I8042_H__36 #define __sparc64_I8042_H__35 #ifndef KERN_sparc64_I8042_H_ 36 #define KERN_sparc64_I8042_H_ 37 37 38 38 #include <arch/types.h> … … 72 72 #endif 73 73 74 74 /** @} 75 75 */ 76 -
arch/sparc64/include/elf.h
r7f1c620 r0ffa3ef5 27 27 */ 28 28 29 29 /** @addtogroup sparc64 30 30 * @{ 31 31 */ … … 42 42 #endif 43 43 44 44 /** @} 45 45 */ 46 -
arch/sparc64/include/register.h
r7f1c620 r0ffa3ef5 27 27 */ 28 28 29 29 /** @addtogroup sparc64 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 35 #ifndef __sparc64_REGISTER_H__ 36 #define __sparc64_REGISTER_H__ 35 #ifndef KERN_sparc64_REGISTER_H_ 36 #define KERN_sparc64_REGISTER_H_ 37 38 #ifdef __ASM__ 39 #define PSTATE_IE_BIT 2 40 #define PSTATE_AM_BIT 8 41 #else 37 42 38 43 #include <arch/types.h> … … 107 112 #endif 108 113 109 /** @} 114 #endif 115 116 /** @} 110 117 */ 111 -
arch/sparc64/include/stack.h
r7f1c620 r0ffa3ef5 27 27 */ 28 28 29 29 /** @addtogroup sparc64 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 35 #ifndef __sparc64_STACK_H__36 #define __sparc64_STACK_H__35 #ifndef KERN_sparc64_STACK_H_ 36 #define KERN_sparc64_STACK_H_ 37 37 38 38 #define STACK_ITEM_SIZE 8 … … 53 53 #endif 54 54 55 55 /** @} 56 56 */ 57 -
arch/sparc64/include/trap/interrupt.h
r7f1c620 r0ffa3ef5 79 79 /** @} 80 80 */ 81 -
arch/sparc64/src/asm.S
r7f1c620 r0ffa3ef5 27 27 # 28 28 29 #include <arch/stack.h> 30 #include <arch/register.h> 31 29 32 .text 30 33 … … 35 38 .global memcpy_to_uspace_failover_address 36 39 .global memsetb 40 37 41 38 42 memcpy: … … 52 56 nop 53 57 58 .global ofw 59 ofw: 60 save %sp, -STACK_WINDOW_SAVE_AREA_SIZE, %sp 61 set ofw_cif, %l0 62 ldx [%l0], %l0 63 64 rdpr %pstate, %l1 65 and %l1, ~PSTATE_AM_BIT, %l2 66 wrpr %l2, 0, %pstate 67 68 jmpl %l0, %o7 69 mov %i0, %o0 70 71 wrpr %l1, 0, %pstate 72 73 ret 74 restore %o0, 0, %o0 -
arch/sparc64/src/console.c
r7f1c620 r0ffa3ef5 52 52 53 53 static void ofw_sparc64_putchar(chardev_t *d, const char ch); 54 static char ofw_sparc64_getchar(chardev_t *d);55 static void ofw_sparc64_suspend(chardev_t *d);56 static void ofw_sparc64_resume(chardev_t *d);57 58 mutex_t canwork;59 54 60 55 static volatile int ofw_console_active; … … 63 58 static chardev_operations_t ofw_sparc64_console_ops = { 64 59 .write = ofw_sparc64_putchar, 65 .read = ofw_sparc64_getchar,66 .resume = ofw_sparc64_resume,67 .suspend = ofw_sparc64_suspend68 60 }; 69 61 … … 72 64 { 73 65 chardev_initialize("ofw_sparc64_console", &ofw_sparc64_console, &ofw_sparc64_console_ops); 74 stdin = &ofw_sparc64_console;66 stdin = NULL; 75 67 stdout = &ofw_sparc64_console; 76 mutex_initialize(&canwork);77 68 ofw_console_active = 1; 78 69 } … … 95 86 void ofw_sparc64_putchar(chardev_t *d, const char ch) 96 87 { 97 pstate_reg_t pstate;98 99 /*100 * 32-bit OpenFirmware depends on PSTATE.AM bit set.101 */102 pstate.value = pstate_read();103 pstate.am = true;104 pstate_write(pstate.value);105 106 88 if (ch == '\n') 107 89 ofw_putchar('\r'); 108 90 ofw_putchar(ch); 109 110 pstate.am = false;111 pstate_write(pstate.value);112 }113 114 /** Read one character using OpenFirmware.115 *116 * The call is non-blocking.117 *118 * @param d Character device (ignored).119 * @return Character read or zero if no character was read.120 */121 char ofw_sparc64_getchar(chardev_t *d)122 {123 char ch;124 pstate_reg_t pstate;125 126 /*127 * 32-bit OpenFirmware depends on PSTATE.AM bit set.128 */129 pstate.value = pstate_read();130 pstate.am = true;131 pstate_write(pstate.value);132 133 ch = ofw_getchar();134 135 pstate.am = false;136 pstate_write(pstate.value);137 138 return ch;139 }140 141 void ofw_sparc64_suspend(chardev_t *d)142 {143 mutex_lock(&canwork);144 }145 146 void ofw_sparc64_resume(chardev_t *d)147 {148 mutex_unlock(&canwork);149 }150 151 /** Kernel thread for pushing characters read from OFW to input buffer.152 *153 * @param arg Ignored.154 */155 void kofwinput(void *arg)156 {157 158 while (ofw_console_active) {159 char ch = 0;160 161 mutex_lock(&canwork);162 mutex_unlock(&canwork);163 164 ch = ofw_sparc64_getchar(NULL);165 if (ch) {166 if (ch == '\r')167 ch = '\n';168 chardev_push_character(&ofw_sparc64_console, ch);169 }170 thread_usleep(KEYBOARD_POLL_PAUSE);171 }172 91 } 173 92 -
arch/sparc64/src/drivers/i8042.c
r7f1c620 r0ffa3ef5 27 27 */ 28 28 29 29 /** @addtogroup sparc64 30 30 * @{ 31 31 */ … … 46 46 } 47 47 48 48 /** @} 49 49 */ 50 -
arch/sparc64/src/mm/frame.c
r7f1c620 r0ffa3ef5 27 27 */ 28 28 29 29 /** @addtogroup sparc64mm 30 30 * @{ 31 31 */ … … 52 52 } 53 53 54 54 /** @} 55 55 */ 56 -
arch/sparc64/src/mm/memory_init.c
r7f1c620 r0ffa3ef5 27 27 */ 28 28 29 29 /** @addtogroup sparc64mm 30 30 * @{ 31 31 */ … … 42 42 } 43 43 44 44 /** @} 45 45 */ 46 46 -
arch/sparc64/src/proc/scheduler.c
r7f1c620 r0ffa3ef5 27 27 */ 28 28 29 29 /** @addtogroup sparc64proc 30 30 * @{ 31 31 */ … … 80 80 } 81 81 82 82 /** @} 83 83 */ 84 -
arch/sparc64/src/sparc64.c
r7f1c620 r0ffa3ef5 41 41 #include <console/console.h> 42 42 43 #include <print.h> 44 #include <genarch/ofw/ofw.h> 45 #include <arch/asm.h> 46 #include <arch/register.h> 43 47 void arch_pre_mm_init(void) 44 48 { 45 49 interrupts_disable(); 46 50 ofw_sparc64_console_init(); 51 47 52 trap_init(); 48 53 tick_init(); … … 61 66 { 62 67 thread_t *t; 63 64 /*65 * Create thread that reads characters from OFW's input.66 */67 t = thread_create(kofwinput, NULL, TASK, 0, "kofwinput");68 if (!t)69 panic("cannot create kofwinput\n");70 thread_ready(t);71 68 72 69 /* -
arch/sparc64/src/start.S
r7f1c620 r0ffa3ef5 28 28 29 29 #include <arch/boot/boot.h> 30 #include <arch/register.h> 30 31 31 32 .register %g2, #scratch … … 38 39 /* 39 40 * Here is where the kernel is passed control. 40 * The code must be position independent until41 * the kernel relocates itself to its VMA.42 41 */ 43 42 … … 46 45 flushw ! flush all but the active register window 47 46 48 set ofw, %l0 47 rdpr %pstate, %l0 48 and %l0, ~PSTATE_AM_BIT, %l0 49 wrpr %l0, 0, %pstate 50 51 set ofw_cif, %l0 49 52 50 53 call ofw_init -
genarch/include/ofw/memory_init.h
r7f1c620 r0ffa3ef5 27 27 */ 28 28 29 29 /** @addtogroup genarch 30 30 * @{ 31 31 */ … … 44 44 #endif 45 45 46 46 /** @} 47 47 */ 48 48 -
genarch/include/ofw/ofw.h
r7f1c620 r0ffa3ef5 27 27 */ 28 28 29 29 /** @addtogroup genarch 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 35 #ifndef __OFW_H__36 #define __OFW_H__35 #ifndef KERN_OFW_H_ 36 #define KERN_OFW_H_ 37 37 38 38 #include <arch/types.h> 39 39 40 #define MAX_OFW_ARGS 1 040 #define MAX_OFW_ARGS 12 41 41 42 42 typedef unative_t ofw_arg_t; 43 typedef int ihandle;44 typedef int phandle;43 typedef unsigned int ihandle; 44 typedef unsigned int phandle; 45 45 46 46 /** OpenFirmware command structure … … 48 48 */ 49 49 typedef struct { 50 const char *service; 51 unative_t nargs; 52 unative_t nret; 53 ofw_arg_t args[MAX_OFW_ARGS]; /**< List ofarguments */50 const char *service; /**< Command name */ 51 unative_t nargs; /**< Number of in arguments */ 52 unative_t nret; /**< Number of out arguments */ 53 ofw_arg_t args[MAX_OFW_ARGS]; /**< Buffer for in and out arguments */ 54 54 } ofw_args_t; 55 55 56 typedef void (*ofw_entry)(ofw_args_t *); 57 58 extern ofw_entry ofw; 56 extern int ofw(ofw_args_t *); /**< OpenFirmware Client Interface entry point. */ 59 57 60 58 extern void ofw_init(void); 61 59 extern void ofw_done(void); 62 extern unative_t ofw_call(const char *service, const int nargs, const int nret, ...);60 extern ofw_arg_t ofw_call(const char *service, const int nargs, const int nret, ofw_arg_t *rets, ...); 63 61 extern void ofw_putchar(const char ch); 64 extern char ofw_getchar(void);65 62 extern phandle ofw_find_device(const char *name); 66 extern int ofw_get_property(const phandle device, const char *name, void *buf, const int buflen); 63 extern int ofw_get_property(const phandle device, const char *name, const void *buf, const int buflen); 64 extern void *ofw_translate(const void *addr); 67 65 extern void *ofw_claim(const void *addr, const int size, const int align); 68 66 69 67 #endif 70 68 71 69 /** @} 72 70 */ 73 -
genarch/src/ofw/memory_init.c
r7f1c620 r0ffa3ef5 27 27 */ 28 28 29 29 /** @addtogroup genarch 30 30 * @{ 31 31 */ … … 94 94 } 95 95 96 96 /** @} 97 97 */ 98 -
genarch/src/ofw/ofw.c
r7f1c620 r0ffa3ef5 39 39 #include <arch/types.h> 40 40 41 ofw_entry ofw; 41 uintptr_t ofw_cif; /**< OpenFirmware Client Interface address. */ 42 42 43 43 phandle ofw_chosen; 44 ihandle ofw_stdin;45 44 ihandle ofw_stdout; 45 ihandle ofw_mmu; 46 46 47 47 void ofw_init(void) … … 51 51 ofw_done(); 52 52 53 if (ofw_get_property(ofw_chosen, "stdin", &ofw_stdin, sizeof(ofw_stdin)) <= 0)54 ofw_stdin = 0;55 56 53 if (ofw_get_property(ofw_chosen, "stdout", &ofw_stdout, sizeof(ofw_stdout)) <= 0) 57 54 ofw_stdout = 0; 55 56 if (ofw_get_property(ofw_chosen, "mmu", &ofw_mmu, sizeof(ofw_mmu)) <= 0) 57 ofw_mmu = 0; 58 58 } 59 59 60 60 void ofw_done(void) 61 61 { 62 (void) ofw_call("exit", 0, 0);62 (void) ofw_call("exit", 0, 1, NULL); 63 63 cpu_halt(); 64 64 } 65 65 66 unative_t ofw_call(const char *service, const int nargs, const int nret, ...) 66 /** Perform a call to OpenFirmware client interface. 67 * 68 * @param service String identifying the service requested. 69 * @param nargs Number of input arguments. 70 * @param nret Number of output arguments. This includes the return value. 71 * @param rets Buffer for output arguments or NULL. The buffer must accomodate nret - 1 items. 72 * 73 * @return Return value returned by the client interface. 74 */ 75 ofw_arg_t ofw_call(const char *service, const int nargs, const int nret, ofw_arg_t *rets, ...) 67 76 { 68 77 va_list list; … … 74 83 args.nret = nret; 75 84 76 va_start(list, nret);85 va_start(list, rets); 77 86 for (i = 0; i < nargs; i++) 78 87 args.args[i] = va_arg(list, ofw_arg_t); … … 82 91 args.args[i + nargs] = 0; 83 92 84 ofw(&args); 85 93 (void) ofw(&args); 94 95 for (i = 1; i < nret; i++) 96 rets[i - 1] = args.args[i + nargs]; 97 86 98 return args.args[nargs]; 87 99 } … … 92 104 return; 93 105 94 (void) ofw_call("write", 3, 1, ofw_stdout, &ch, 1); 95 } 96 97 /** Read character from OFW's input. 98 * 99 * This call is non-blocking. 100 * 101 * @return 0 if no character was read, character read otherwise. 102 */ 103 char ofw_getchar(void) 104 { 105 char ch; 106 107 if (ofw_stdin == 0) 108 return 0; 109 110 if (ofw_call("read", 3, 1, ofw_stdin, &ch, 1) == 1) 111 return ch; 112 else 113 return 0; 106 (void) ofw_call("write", 3, 1, NULL, ofw_stdout, &ch, 1); 114 107 } 115 108 116 109 phandle ofw_find_device(const char *name) 117 110 { 118 return (phandle) ofw_call("finddevice", 1, 1, name);111 return (phandle) ofw_call("finddevice", 1, 1, NULL, name); 119 112 } 120 113 121 int ofw_get_property(const phandle device, const char *name, void *buf, const int buflen)114 int ofw_get_property(const phandle device, const char *name, const void *buf, const int buflen) 122 115 { 123 return (int) ofw_call("getprop", 4, 1, device, name, buf, buflen); 116 return (int) ofw_call("getprop", 4, 1, NULL, device, name, buf, buflen); 117 } 118 119 /** Translate virtual address to physical address using OpenFirmware. 120 * 121 * Use this function only when OpenFirmware is in charge. 122 * 123 * @param virt Virtual address. 124 * @return NULL on failure or physical address on success. 125 */ 126 void *ofw_translate(const void *virt) 127 { 128 ofw_arg_t result[4]; 129 int shift; 130 131 if (!ofw_mmu) 132 return NULL; 133 134 if (ofw_call("call-method", 3, 5, result, "translate", ofw_mmu, virt) != 0) 135 return NULL; 136 137 if (result[0] != -1) 138 return NULL; 139 140 if (sizeof(unative_t) == 8) 141 shift = 32; 142 else 143 shift = 0; 144 145 return (void *) ((result[2]<<shift)|result[3]); 124 146 } 125 147 126 148 void *ofw_claim(const void *addr, const int size, const int align) 127 149 { 128 return (void *) ofw_call("claim", 3, 1, addr, size, align);150 return (void *) ofw_call("claim", 3, 1, NULL, addr, size, align); 129 151 } 130 152
Note:
See TracChangeset
for help on using the changeset viewer.