Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 1735f3e in mainline


Ignore:
Timestamp:
2010-01-31T18:22:37Z (12 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
fc2e71e
Parents:
430de97 (diff), 2e07f62c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge from mainline.

Files:
81 added
1 deleted
63 edited
13 moved

Legend:

Unmodified
Added
Removed
  • HelenOS.config

    r430de97 r1735f3e  
    3131
    3232% Platform
     33@ "abs32le" abstract 32-bit little endian
    3334@ "amd64" AMD64/Intel EM64T (PC)
    3435@ "arm32" ARM 32-bit
     
    9192
    9293% Kernel architecture
     94@ "abs32le"
     95! [PLATFORM=abs32le] KARCH (choice)
     96
     97% Kernel architecture
    9398@ "amd64"
    9499! [PLATFORM=amd64] KARCH (choice)
     
    130135
    131136% User space architecture
     137@ "abs32le"
     138! [PLATFORM=abs32le] UARCH (choice)
     139
     140% User space architecture
    132141@ "amd64"
    133142! [PLATFORM=amd64] UARCH (choice)
     
    167176
    168177## Mapping between platform and boot architecture
     178
     179% Boot architecture
     180@ "abs32le"
     181! [PLATFORM=abs32le] BARCH (choice)
    169182
    170183% Boot architecture
     
    243256! [PLATFORM=arm32|PLATFORM=mips32|PLATFORM=ppc32] COMPILER (choice)
    244257
     258% Compiler
     259@ "gcc_native" GNU C Compiler (native)
     260@ "clang" Clang
     261! [PLATFORM=abs32le] COMPILER (choice)
     262
    245263
    246264## Kernel configuration
     
    259277
    260278% Hierarchical page tables support
    261 ! [PLATFORM=ia32|PLATFORM=amd64|PLATFORM=arm32|PLATFORM=mips32|PLATFORM=ppc32] CONFIG_PAGE_PT (y)
     279! [PLATFORM=abs32le|PLATFORM=ia32|PLATFORM=amd64|PLATFORM=arm32|PLATFORM=mips32|PLATFORM=ppc32] CONFIG_PAGE_PT (y)
    262280
    263281% Page hash table support
     
    486504% Mount /data on startup
    487505! [CONFIG_START_BD=y] CONFIG_MOUNT_DATA (n/y)
     506
     507% Verbose task dumps
     508! CONFIG_VERBOSE_DUMPS (n/y)
  • Makefile

    r430de97 r1735f3e  
    5959
    6060distclean: clean
    61         rm -f $(CSCOPE).out Makefile.config config.h config.defs tools/*.pyc
     61        rm -f $(CSCOPE).out Makefile.config config.h config.defs tools/*.pyc tools/checkers/*.pyc
    6262
    6363clean:
  • boot/Makefile.common

    r430de97 r1735f3e  
    5656        $(USPACEDIR)/srv/fs/devfs/devfs \
    5757        $(USPACEDIR)/srv/fs/tmpfs/tmpfs \
    58         $(USPACEDIR)/srv/fs/fat/fat
     58        $(USPACEDIR)/srv/fs/fat/fat \
     59        $(USPACEDIR)/srv/taskmon/taskmon
    5960
    6061RD_APPS = \
     
    6566        $(USPACEDIR)/app/mkfat/mkfat \
    6667        $(USPACEDIR)/app/redir/redir \
     68        $(USPACEDIR)/app/taskdump/taskdump \
    6769        $(USPACEDIR)/app/tester/tester \
    6870        $(USPACEDIR)/app/tetris/tetris \
  • boot/arch/amd64/Makefile.inc

    r430de97 r1735f3e  
    3333        $(USPACEDIR)/srv/hw/char/i8042/i8042 \
    3434        $(USPACEDIR)/srv/hw/bus/pci/pci \
    35         $(USPACEDIR)/srv/hid/c_mouse/c_mouse
     35        $(USPACEDIR)/srv/hid/char_mouse/char_ms
    3636
    3737MODULES := $(notdir $(COMPONENTS))
  • boot/arch/ia64/loader/Makefile.common

    r430de97 r1735f3e  
    4949        RD_SRVS += \
    5050                $(USPACEDIR)/srv/hw/char/i8042/i8042 \
    51                 $(USPACEDIR)/srv/hid/c_mouse/c_mouse
     51                $(USPACEDIR)/srv/hid/char_mouse/char_ms
    5252endif
  • boot/arch/ppc32/loader/Makefile.common

    r430de97 r1735f3e  
    4343KERNELDIR = ../../../../kernel
    4444USPACEDIR = ../../../../uspace
     45
     46RD_SRVS += \
     47        $(USPACEDIR)/srv/hid/adb_mouse/adb_ms \
     48        $(USPACEDIR)/srv/hw/bus/cuda_adb/cuda_adb
  • kernel/arch/amd64/src/amd64.c

    r430de97 r1735f3e  
    278278}
    279279
     280void irq_initialize_arch(irq_t *irq)
     281{
     282        (void) irq;
     283}
     284
    280285/** @}
    281286 */
  • kernel/arch/arm32/src/arm32.c

    r430de97 r1735f3e  
    179179}
    180180
     181void irq_initialize_arch(irq_t *irq)
     182{
     183        (void) irq;
     184}
     185
    181186/** @}
    182187 */
  • kernel/arch/ia32/src/ia32.c

    r430de97 r1735f3e  
    234234}
    235235
     236void irq_initialize_arch(irq_t *irq)
     237{
     238        (void) irq;
     239}
     240
    236241/** @}
    237242 */
  • kernel/arch/ia64/src/ia64.c

    r430de97 r1735f3e  
    4444#include <arch/stack.h>
    4545#include <arch/mm/page.h>
     46#include <interrupt.h>
    4647#include <mm/as.h>
    4748#include <config.h>
     
    280281}
    281282
     283void irq_initialize_arch(irq_t *irq)
     284{
     285        (void) irq;
     286}
     287
    282288/** @}
    283289 */
  • kernel/arch/mips32/src/mips32.c

    r430de97 r1735f3e  
    4646#include <sysinfo/sysinfo.h>
    4747#include <arch/interrupt.h>
     48#include <interrupt.h>
    4849#include <console/chardev.h>
    4950#include <arch/barrier.h>
     
    257258}
    258259
     260void irq_initialize_arch(irq_t *irq)
     261{
     262        (void) irq;
     263}
     264
    259265/** @}
    260266 */
  • kernel/arch/ppc32/src/ppc32.c

    r430de97 r1735f3e  
    3939#include <genarch/kbrd/kbrd.h>
    4040#include <arch/interrupt.h>
     41#include <interrupt.h>
    4142#include <genarch/fb/fb.h>
    4243#include <genarch/fb/visuals.h>
     
    4748#include <proc/uarg.h>
    4849#include <console/console.h>
     50#include <sysinfo/sysinfo.h>
    4951#include <ddi/irq.h>
    5052#include <arch/drivers/pic.h>
     
    5860
    5961bootinfo_t bootinfo;
     62
     63static cir_t pic_cir;
     64static void *pic_cir_arg;
    6065
    6166/** Performs ppc32-specific initialization before main_bsp() is called. */
     
    186191        if (assigned_address) {
    187192                /* Initialize PIC */
    188                 cir_t cir;
    189                 void *cir_arg;
    190                 pic_init(assigned_address[0].addr, PAGE_SIZE, &cir, &cir_arg);
    191                
     193                pic_init(assigned_address[0].addr, PAGE_SIZE, &pic_cir,
     194                    &pic_cir_arg);
     195
    192196#ifdef CONFIG_MAC_KBD
    193197                uintptr_t pa = assigned_address[0].addr + 0x16000;
     
    201205                /* Initialize I/O controller */
    202206                cuda_instance_t *cuda_instance =
    203                     cuda_init(cuda, IRQ_CUDA, cir, cir_arg);
     207                    cuda_init(cuda, IRQ_CUDA, pic_cir, pic_cir_arg);
    204208                if (cuda_instance) {
    205209                        kbrd_instance_t *kbrd_instance = kbrd_init();
     
    211215                        }
    212216                }
     217
     218                /*
     219                 * This is the necessary evil until the userspace driver is entirely
     220                 * self-sufficient.
     221                 */
     222                sysinfo_set_item_val("cuda", NULL, true);
     223                sysinfo_set_item_val("cuda.inr", NULL, IRQ_CUDA);
     224                sysinfo_set_item_val("cuda.address.physical", NULL, pa);
     225                sysinfo_set_item_val("cuda.address.kernel", NULL,
     226                    (uintptr_t) cuda);
    213227#endif
    214228        }
     
    216230        /* Consider only a single device for now */
    217231        return false;
     232}
     233
     234void irq_initialize_arch(irq_t *irq)
     235{
     236        irq->cir = pic_cir;
     237        irq->cir_arg = pic_cir_arg;
     238        irq->preack = true;
    218239}
    219240
  • kernel/arch/sparc64/src/sparc64.c

    r430de97 r1735f3e  
    4444#include <arch/mm/page.h>
    4545#include <arch/stack.h>
     46#include <interrupt.h>
    4647#include <genarch/ofw/ofw_tree.h>
    4748#include <userspace.h>
     
    166167}
    167168
     169void irq_initialize_arch(irq_t *irq)
     170{
     171        (void) irq;
     172}
     173
    168174/** @}
    169175 */
  • kernel/generic/include/interrupt.h

    r430de97 r1735f3e  
    4646typedef void (* iroutine)(int n, istate_t *istate);
    4747
    48 #define fault_if_from_uspace(istate, fmt, ...) \
    49 { \
    50         if (istate_from_uspace(istate)) { \
    51                 task_t *task = TASK; \
    52                 printf("Task %s (%" PRIu64 ") killed due to an exception at " \
    53                     "program counter %p.\n", task->name, task->taskid, istate_get_pc(istate)); \
    54                 stack_trace_istate(istate); \
    55                 printf("Kill message: " fmt "\n", ##__VA_ARGS__); \
    56                 task_kill(task->taskid); \
    57                 thread_exit(); \
    58         } \
    59 }
    60 
     48extern void fault_if_from_uspace(istate_t *istate, char *fmt, ...);
    6149extern iroutine exc_register(int n, const char *name, iroutine f);
    6250extern void exc_dispatch(int n, istate_t *t);
    6351void exc_init(void);
     52
     53extern void irq_initialize_arch(irq_t *irq);
    6454
    6555#endif
  • kernel/generic/include/ipc/event_types.h

    r430de97 r1735f3e  
    3737
    3838typedef enum event_type {
     39        /** New data available in kernel log */
    3940        EVENT_KLOG = 0,
     41        /** Returning from kernel console to userspace */
    4042        EVENT_KCONSOLE,
     43        /** A thread has faulted and will be terminated */
     44        EVENT_FAULT,
    4145        EVENT_END
    4246} event_type_t;
  • kernel/generic/include/mm/as.h

    r430de97 r1735f3e  
    3636#define KERN_AS_H_
    3737
     38#ifdef KERNEL
     39#include <arch/types.h>
     40#else
     41#include <sys/types.h>
     42#endif
     43
    3844/** Address space area flags. */
    3945#define AS_AREA_READ            1
     
    4147#define AS_AREA_EXEC            4
    4248#define AS_AREA_CACHEABLE       8
     49
     50/** Address space area info exported to userspace. */
     51typedef struct {
     52        /** Starting address */
     53        uintptr_t start_addr;
     54
     55        /** Area size */
     56        size_t size;
     57
     58        /** Area flags */
     59        int flags;
     60} as_area_info_t;
    4361
    4462#ifdef KERNEL
     
    268286
    269287/* Introspection functions. */
     288extern void as_get_area_info(as_t *as, as_area_info_t **obuf, size_t *osize);
    270289extern void as_print(as_t *as);
    271290
  • kernel/generic/include/udebug/udebug.h

    r430de97 r1735f3e  
    2727 */
    2828
    29 /** @addtogroup generic 
     29/** @addtogroup generic
    3030 * @{
    3131 */
     
    8383UDEBUG_M_ARGS_READ,
    8484
     85/** Read thread's userspace register state (istate_t).
     86 *
     87 * - ARG2 - thread identification
     88 * - ARG3 - destination address in the caller's address space
     89 *
     90 * or, on error, retval will be
     91 * - ENOENT - thread does not exist
     92 * - EBUSY - register state not available
     93 */
     94UDEBUG_M_REGS_READ,
     95
    8596/** Read the list of the debugged tasks's threads.
    8697 *
     
    97108UDEBUG_M_THREAD_READ,
    98109
     110/** Read the name of the debugged task.
     111 *
     112 * - ARG2 - destination address in the caller's address space
     113 * - ARG3 - size of receiving buffer in bytes
     114 *
     115 * The kernel fills the buffer with a non-terminated string.
     116 *
     117 * - ARG2 - number of bytes that were actually copied
     118 * - ARG3 - number of bytes of the complete data
     119 *
     120 */
     121UDEBUG_M_NAME_READ,
     122
     123/** Read the list of the debugged task's address space areas.
     124 *
     125 * - ARG2 - destination address in the caller's address space
     126 * - ARG3 - size of receiving buffer in bytes
     127 *
     128 * The kernel fills the buffer with a series of as_area_info_t structures.
     129 * Upon answer, the kernel will set:
     130 *
     131 * - ARG2 - number of bytes that were actually copied
     132 * - ARG3 - number of bytes of the complete data
     133 *
     134 */
     135UDEBUG_M_AREAS_READ,
     136
    99137/** Read the debugged tasks's memory.
    100138 *
     
    108146} udebug_method_t;
    109147
    110                                
     148
    111149typedef enum {
    112150        UDEBUG_EVENT_FINISHED = 1,      /**< Debuging session has finished */
     
    139177
    140178#include <synch/mutex.h>
     179#include <synch/condvar.h>
    141180#include <arch/interrupt.h>
    142181#include <atomic.h>
     
    181220        bool stoppable;         /**< thread is stoppable */
    182221        bool active;            /**< thread is in a debugging session */
     222        condvar_t active_cv;
    183223} udebug_thread_t;
    184224
     
    202242
    203243int udebug_task_cleanup(struct task *ta);
     244void udebug_thread_fault(void);
    204245
    205246#endif
  • kernel/generic/include/udebug/udebug_ops.h

    r430de97 r1735f3e  
    4545int udebug_stop(thread_t *t, call_t *call);
    4646
    47 int udebug_thread_read(void **buffer, size_t buf_size, size_t *n);
     47int udebug_thread_read(void **buffer, size_t buf_size, size_t *stored,
     48    size_t *needed);
     49int udebug_name_read(char **data, size_t *data_size);
    4850int udebug_args_read(thread_t *t, void **buffer);
     51
     52int udebug_regs_read(thread_t *t, void **buffer);
    4953
    5054int udebug_mem_read(unative_t uspace_addr, size_t n, void **buffer);
  • kernel/generic/src/ddi/irq.c

    r430de97 r1735f3e  
    7474#include <synch/spinlock.h>
    7575#include <console/console.h>
     76#include <interrupt.h>
    7677#include <memstr.h>
    7778#include <arch.h>
     
    169170        irq->inr = -1;
    170171        irq->devno = -1;
     172
     173        irq_initialize_arch(irq);
    171174}
    172175
  • kernel/generic/src/interrupt/interrupt.c

    r430de97 r1735f3e  
    4444#include <console/console.h>
    4545#include <console/cmd.h>
     46#include <ipc/event.h>
     47#include <synch/mutex.h>
     48#include <time/delay.h>
     49#include <macros.h>
    4650#include <panic.h>
    4751#include <print.h>
     
    107111        fault_if_from_uspace(istate, "Unhandled exception %d.", n);
    108112        panic("Unhandled exception %d.", n);
     113}
     114
     115/** Terminate thread and task if exception came from userspace. */
     116void fault_if_from_uspace(istate_t *istate, char *fmt, ...)
     117{
     118        task_t *task = TASK;
     119        va_list args;
     120
     121        if (!istate_from_uspace(istate))
     122                return;
     123
     124        printf("Task %s (%" PRIu64 ") killed due to an exception at "
     125            "program counter %p.\n", task->name, task->taskid,
     126            istate_get_pc(istate));
     127
     128        stack_trace_istate(istate);
     129
     130        printf("Kill message: ");
     131        va_start(args, fmt);
     132        vprintf(fmt, args);
     133        va_end(args);
     134        printf("\n");
     135
     136        /*
     137         * Userspace can subscribe for FAULT events to take action
     138         * whenever a thread faults. (E.g. take a dump, run a debugger).
     139         * The notification is always available, but unless Udebug is enabled,
     140         * that's all you get.
     141         */
     142        if (event_is_subscribed(EVENT_FAULT)) {
     143                /* Notify the subscriber that a fault occurred. */
     144                event_notify_3(EVENT_FAULT, LOWER32(TASK->taskid),
     145                    UPPER32(TASK->taskid), (unative_t) THREAD);
     146
     147#ifdef CONFIG_UDEBUG
     148                /* Wait for a debugging session. */
     149                udebug_thread_fault();
     150#endif
     151        }
     152
     153        task_kill(task->taskid);
     154        thread_exit();
    109155}
    110156
  • kernel/generic/src/ipc/ipc.c

    r430de97 r1735f3e  
    212212 *
    213213 * @param call          Call structure to be answered.
    214  */
    215 static void _ipc_answer_free_call(call_t *call)
     214 * @param selflocked    If true, then TASK->answebox is locked.
     215 */
     216static void _ipc_answer_free_call(call_t *call, bool selflocked)
    216217{
    217218        answerbox_t *callerbox = call->callerbox;
     219        bool do_lock = ((!selflocked) || callerbox != (&TASK->answerbox));
    218220
    219221        call->flags |= IPC_CALL_ANSWERED;
     
    226228        }
    227229
    228         spinlock_lock(&callerbox->lock);
     230        if (do_lock)
     231                spinlock_lock(&callerbox->lock);
    229232        list_append(&call->link, &callerbox->answers);
    230         spinlock_unlock(&callerbox->lock);
     233        if (do_lock)
     234                spinlock_unlock(&callerbox->lock);
    231235        waitq_wakeup(&callerbox->wq, WAKEUP_FIRST);
    232236}
     
    244248        spinlock_unlock(&box->lock);
    245249        /* Send back answer */
    246         _ipc_answer_free_call(call);
     250        _ipc_answer_free_call(call, false);
    247251}
    248252
     
    261265        atomic_inc(&phone->active_calls);
    262266        IPC_SET_RETVAL(call->data, err);
    263         _ipc_answer_free_call(call);
     267        _ipc_answer_free_call(call, false);
    264268}
    265269
     
    300304                if (call->flags & IPC_CALL_FORWARDED) {
    301305                        IPC_SET_RETVAL(call->data, EFORWARD);
    302                         _ipc_answer_free_call(call);
     306                        _ipc_answer_free_call(call, false);
    303307                } else {
    304308                        if (phone->state == IPC_PHONE_HUNGUP)
     
    455459
    456460                IPC_SET_RETVAL(call->data, EHANGUP);
    457                 _ipc_answer_free_call(call);
     461                _ipc_answer_free_call(call, true);
    458462        }
    459463}
  • kernel/generic/src/mm/as.c

    r430de97 r1735f3e  
    19201920}
    19211921
     1922/** Get list of adress space areas.
     1923 *
     1924 * @param as            Address space.
     1925 * @param obuf          Place to save pointer to returned buffer.
     1926 * @param osize         Place to save size of returned buffer.
     1927 */
     1928void as_get_area_info(as_t *as, as_area_info_t **obuf, size_t *osize)
     1929{
     1930        ipl_t ipl;
     1931        size_t area_cnt, area_idx, i;
     1932        link_t *cur;
     1933
     1934        as_area_info_t *info;
     1935        size_t isize;
     1936
     1937        ipl = interrupts_disable();
     1938        mutex_lock(&as->lock);
     1939
     1940        /* First pass, count number of areas. */
     1941
     1942        area_cnt = 0;
     1943
     1944        for (cur = as->as_area_btree.leaf_head.next;
     1945            cur != &as->as_area_btree.leaf_head; cur = cur->next) {
     1946                btree_node_t *node;
     1947
     1948                node = list_get_instance(cur, btree_node_t, leaf_link);
     1949                area_cnt += node->keys;
     1950        }
     1951
     1952        isize = area_cnt * sizeof(as_area_info_t);
     1953        info = malloc(isize, 0);
     1954
     1955        /* Second pass, record data. */
     1956
     1957        area_idx = 0;
     1958
     1959        for (cur = as->as_area_btree.leaf_head.next;
     1960            cur != &as->as_area_btree.leaf_head; cur = cur->next) {
     1961                btree_node_t *node;
     1962
     1963                node = list_get_instance(cur, btree_node_t, leaf_link);
     1964
     1965                for (i = 0; i < node->keys; i++) {
     1966                        as_area_t *area = node->value[i];
     1967
     1968                        ASSERT(area_idx < area_cnt);
     1969                        mutex_lock(&area->lock);
     1970
     1971                        info[area_idx].start_addr = area->base;
     1972                        info[area_idx].size = FRAMES2SIZE(area->pages);
     1973                        info[area_idx].flags = area->flags;
     1974                        ++area_idx;
     1975
     1976                        mutex_unlock(&area->lock);
     1977                }
     1978        }
     1979
     1980        mutex_unlock(&as->lock);
     1981        interrupts_restore(ipl);
     1982
     1983        *obuf = info;
     1984        *osize = isize;
     1985}
     1986
     1987
    19221988/** Print out information about address space.
    19231989 *
  • kernel/generic/src/udebug/udebug.c

    r430de97 r1735f3e  
    6969        mutex_initialize(&ut->lock, MUTEX_PASSIVE);
    7070        waitq_initialize(&ut->go_wq);
     71        condvar_initialize(&ut->active_cv);
    7172
    7273        ut->go_call = NULL;
     
    446447                                waitq_wakeup(&t->udebug.go_wq, WAKEUP_FIRST);
    447448                        }
     449                        mutex_unlock(&t->udebug.lock);
     450                        condvar_broadcast(&t->udebug.active_cv);
     451                } else {
     452                        mutex_unlock(&t->udebug.lock);
    448453                }
    449                 mutex_unlock(&t->udebug.lock);
    450454        }
    451455
     
    456460}
    457461
     462/** Wait for debugger to handle a fault in this thread.
     463 *
     464 * When a thread faults and someone is subscribed to the FAULT kernel event,
     465 * this function is called to wait for a debugging session to give userspace
     466 * a chance to examine the faulting thead/task. When the debugging session
     467 * is over, this function returns (so that thread/task cleanup can continue).
     468 */
     469void udebug_thread_fault(void)
     470{
     471        udebug_stoppable_begin();
     472
     473        /* Wait until a debugger attends to us. */
     474        mutex_lock(&THREAD->udebug.lock);
     475        while (!THREAD->udebug.active)
     476                condvar_wait(&THREAD->udebug.active_cv, &THREAD->udebug.lock);
     477        mutex_unlock(&THREAD->udebug.lock);
     478
     479        /* Make sure the debugging session is over before proceeding. */
     480        mutex_lock(&THREAD->udebug.lock);
     481        while (THREAD->udebug.active)
     482                condvar_wait(&THREAD->udebug.active_cv, &THREAD->udebug.lock);
     483        mutex_unlock(&THREAD->udebug.lock);
     484
     485        udebug_stoppable_end();
     486}
    458487
    459488/** @}
  • kernel/generic/src/udebug/udebug_ipc.c

    r430de97 r1735f3e  
    4141#include <proc/task.h>
    4242#include <proc/thread.h>
     43#include <mm/as.h>
    4344#include <arch.h>
    4445#include <errno.h>
     
    165166static void udebug_receive_thread_read(call_t *call)
    166167{
     168        uintptr_t uspace_addr;
     169        size_t buf_size;
     170        void *buffer;
     171        size_t copied, needed;
     172        int rc;
     173
     174        uspace_addr = IPC_GET_ARG2(call->data); /* Destination address */
     175        buf_size = IPC_GET_ARG3(call->data);    /* Dest. buffer size */
     176
     177        /*
     178         * Read thread list. Variable n will be filled with actual number
     179         * of threads times thread-id size.
     180         */
     181        rc = udebug_thread_read(&buffer, buf_size, &copied, &needed);
     182        if (rc < 0) {
     183                IPC_SET_RETVAL(call->data, rc);
     184                ipc_answer(&TASK->kb.box, call);
     185                return;
     186        }
     187
     188        /*
     189         * Make use of call->buffer to transfer data to caller's userspace
     190         */
     191
     192        IPC_SET_RETVAL(call->data, 0);
     193        /* ARG1=dest, ARG2=size as in IPC_M_DATA_READ so that
     194           same code in process_answer() can be used
     195           (no way to distinguish method in answer) */
     196        IPC_SET_ARG1(call->data, uspace_addr);
     197        IPC_SET_ARG2(call->data, copied);
     198        IPC_SET_ARG3(call->data, needed);
     199        call->buffer = buffer;
     200
     201        ipc_answer(&TASK->kb.box, call);
     202}
     203
     204/** Process a NAME_READ call.
     205 *
     206 * Returns a string containing the name of the task.
     207 *
     208 * @param call  The call structure.
     209 */
     210static void udebug_receive_name_read(call_t *call)
     211{
    167212        unative_t uspace_addr;
    168213        unative_t to_copy;
    169         unsigned total_bytes;
    170         unsigned buf_size;
    171         void *buffer;
    172         size_t n;
    173         int rc;
     214        size_t data_size;
     215        size_t buf_size;
     216        void *data;
    174217
    175218        uspace_addr = IPC_GET_ARG2(call->data); /* Destination address */
     
    177220
    178221        /*
    179          * Read thread list. Variable n will be filled with actual number
    180          * of threads times thread-id size.
    181          */
    182         rc = udebug_thread_read(&buffer, buf_size, &n);
    183         if (rc < 0) {
    184                 IPC_SET_RETVAL(call->data, rc);
    185                 ipc_answer(&TASK->kb.box, call);
    186                 return;
    187         }
    188 
    189         total_bytes = n;
    190 
    191         /* Copy MAX(buf_size, total_bytes) bytes */
    192 
    193         if (buf_size > total_bytes)
    194                 to_copy = total_bytes;
     222         * Read task name.
     223         */
     224        udebug_name_read((char **) &data, &data_size);
     225
     226        /* Copy MAX(buf_size, data_size) bytes */
     227
     228        if (buf_size > data_size)
     229                to_copy = data_size;
    195230        else
    196231                to_copy = buf_size;
     
    207242        IPC_SET_ARG2(call->data, to_copy);
    208243
    209         IPC_SET_ARG3(call->data, total_bytes);
    210         call->buffer = buffer;
    211 
    212         ipc_answer(&TASK->kb.box, call);
    213 }
     244        IPC_SET_ARG3(call->data, data_size);
     245        call->buffer = data;
     246
     247        ipc_answer(&TASK->kb.box, call);
     248}
     249
     250/** Process an AREAS_READ call.
     251 *
     252 * Returns a list of address space areas in the current task, as an array
     253 * of as_area_info_t structures.
     254 *
     255 * @param call  The call structure.
     256 */
     257static void udebug_receive_areas_read(call_t *call)
     258{
     259        unative_t uspace_addr;
     260        unative_t to_copy;
     261        size_t data_size;
     262        size_t buf_size;
     263        void *data;
     264
     265        uspace_addr = IPC_GET_ARG2(call->data); /* Destination address */
     266        buf_size = IPC_GET_ARG3(call->data);    /* Dest. buffer size */
     267
     268        /*
     269         * Read area list.
     270         */
     271        as_get_area_info(AS, (as_area_info_t **) &data, &data_size);
     272
     273        /* Copy MAX(buf_size, data_size) bytes */
     274
     275        if (buf_size > data_size)
     276                to_copy = data_size;
     277        else
     278                to_copy = buf_size;
     279
     280        /*
     281         * Make use of call->buffer to transfer data to caller's userspace
     282         */
     283
     284        IPC_SET_RETVAL(call->data, 0);
     285        /* ARG1=dest, ARG2=size as in IPC_M_DATA_READ so that
     286           same code in process_answer() can be used
     287           (no way to distinguish method in answer) */
     288        IPC_SET_ARG1(call->data, uspace_addr);
     289        IPC_SET_ARG2(call->data, to_copy);
     290
     291        IPC_SET_ARG3(call->data, data_size);
     292        call->buffer = data;
     293
     294        ipc_answer(&TASK->kb.box, call);
     295}
     296
    214297
    215298/** Process an ARGS_READ call.
     
    250333        ipc_answer(&TASK->kb.box, call);
    251334}
     335
     336/** Receive a REGS_READ call.
     337 *
     338 * Reads the thread's register state (istate structure).
     339 */
     340static void udebug_receive_regs_read(call_t *call)
     341{
     342        thread_t *t;
     343        unative_t uspace_addr;
     344        unative_t to_copy;
     345        void *buffer;
     346        int rc;
     347
     348        t = (thread_t *) IPC_GET_ARG2(call->data);
     349
     350        rc = udebug_regs_read(t, &buffer);
     351        if (rc < 0) {
     352                IPC_SET_RETVAL(call->data, rc);
     353                ipc_answer(&TASK->kb.box, call);
     354                return;
     355        }
     356
     357        /*
     358         * Make use of call->buffer to transfer data to caller's userspace
     359         */
     360
     361        uspace_addr = IPC_GET_ARG3(call->data);
     362        to_copy = sizeof(istate_t);
     363
     364        IPC_SET_RETVAL(call->data, 0);
     365        /* ARG1=dest, ARG2=size as in IPC_M_DATA_READ so that
     366           same code in process_answer() can be used
     367           (no way to distinguish method in answer) */
     368        IPC_SET_ARG1(call->data, uspace_addr);
     369        IPC_SET_ARG2(call->data, to_copy);
     370
     371        call->buffer = buffer;
     372
     373        ipc_answer(&TASK->kb.box, call);
     374}
     375
    252376
    253377/** Process an MEM_READ call.
     
    331455                udebug_receive_thread_read(call);
    332456                break;
     457        case UDEBUG_M_NAME_READ:
     458                udebug_receive_name_read(call);
     459                break;
     460        case UDEBUG_M_AREAS_READ:
     461                udebug_receive_areas_read(call);
     462                break;
    333463        case UDEBUG_M_ARGS_READ:
    334464                udebug_receive_args_read(call);
    335465                break;
     466        case UDEBUG_M_REGS_READ:
     467                udebug_receive_regs_read(call);
     468                break;
    336469        case UDEBUG_M_MEM_READ:
    337470                udebug_receive_mem_read(call);
  • kernel/generic/src/udebug/udebug_ops.c

    r430de97 r1735f3e  
    4646#include <errno.h>
    4747#include <print.h>
     48#include <string.h>
    4849#include <syscall/copy.h>
    4950#include <ipc/ipc.h>
     
    209210
    210211                mutex_lock(&t->udebug.lock);
    211                 if ((t->flags & THREAD_FLAG_USPACE) != 0)
     212                if ((t->flags & THREAD_FLAG_USPACE) != 0) {
    212213                        t->udebug.active = true;
    213                 mutex_unlock(&t->udebug.lock);
     214                        mutex_unlock(&t->udebug.lock);
     215                        condvar_broadcast(&t->udebug.active_cv);
     216                } else {
     217                        mutex_unlock(&t->udebug.lock);
     218                }
    214219        }
    215220
     
    355360 *
    356361 * If the sequence is longer than @a buf_size bytes, only as much hashes
    357  * as can fit are copied. The number of thread hashes copied is stored
    358  * in @a n.
     362 * as can fit are copied. The number of bytes copied is stored in @a stored.
     363 * The total number of thread bytes that could have been saved had there been
     364 * enough space is stored in @a needed.
    359365 *
    360366 * The rationale for having @a buf_size is that this function is only
     
    364370 * @param buffer        The buffer for storing thread hashes.
    365371 * @param buf_size      Buffer size in bytes.
    366  * @param n             The actual number of hashes copied will be stored here.
    367  */
    368 int udebug_thread_read(void **buffer, size_t buf_size, size_t *n)
     372 * @param stored        The actual number of bytes copied will be stored here.
     373 * @param needed        Total number of hashes that could have been saved.
     374 */
     375int udebug_thread_read(void **buffer, size_t buf_size, size_t *stored,
     376    size_t *needed)
    369377{
    370378        thread_t *t;
    371379        link_t *cur;
    372380        unative_t tid;
    373         unsigned copied_ids;
     381        size_t copied_ids;
     382        size_t extra_ids;
    374383        ipl_t ipl;
    375384        unative_t *id_buffer;
     
    380389
    381390        /* Allocate a buffer to hold thread IDs */
    382         id_buffer = malloc(buf_size, 0);
     391        id_buffer = malloc(buf_size + 1, 0);
    383392
    384393        mutex_lock(&TASK->udebug.lock);
     
    396405        max_ids = buf_size / sizeof(unative_t);
    397406        copied_ids = 0;
     407        extra_ids = 0;
    398408
    399409        /* FIXME: make sure the thread isn't past debug shutdown... */
    400410        for (cur = TASK->th_head.next; cur != &TASK->th_head; cur = cur->next) {
    401                 /* Do not write past end of buffer */
    402                 if (copied_ids >= max_ids) break;
    403 
    404411                t = list_get_instance(cur, thread_t, th_link);
    405412
     
    409416
    410417                /* Not interested in kernel threads. */
    411                 if ((flags & THREAD_FLAG_USPACE) != 0) {
     418                if ((flags & THREAD_FLAG_USPACE) == 0)
     419                        continue;
     420
     421                if (copied_ids < max_ids) {
    412422                        /* Using thread struct pointer as identification hash */
    413423                        tid = (unative_t) t;
    414424                        id_buffer[copied_ids++] = tid;
     425                } else {
     426                        extra_ids++;
    415427                }
    416428        }
     
    422434
    423435        *buffer = id_buffer;
    424         *n = copied_ids * sizeof(unative_t);
     436        *stored = copied_ids * sizeof(unative_t);
     437        *needed = (copied_ids + extra_ids) * sizeof(unative_t);
     438
     439        return 0;
     440}
     441
     442/** Read task name.
     443 *
     444 * Returns task name as non-terminated string in a newly allocated buffer.
     445 * Also returns the size of the data.
     446 *
     447 * @param data          Place to store pointer to newly allocated block.
     448 * @param data_size     Place to store size of the data.
     449 *
     450 * @returns             EOK.
     451 */
     452int udebug_name_read(char **data, size_t *data_size)
     453{
     454        size_t name_size;
     455
     456        name_size = str_size(TASK->name) + 1;
     457        *data = malloc(name_size, 0);
     458        *data_size = name_size;
     459
     460        memcpy(*data, TASK->name, name_size);
    425461
    426462        return 0;
     
    437473 * this function will fail with an EINVAL error code.
    438474 *
    439  * @param buffer        The buffer for storing thread hashes.
     475 * @param t             Thread where call arguments are to be read.
     476 * @param buffer        Place to store pointer to new buffer.
     477 * @return              EOK on success, ENOENT if @a t is invalid, EINVAL
     478 *                      if thread state is not valid for this operation.
    440479 */
    441480int udebug_args_read(thread_t *t, void **buffer)
     
    469508}
    470509
     510/** Read the register state of the thread.
     511 *
     512 * The contents of the thread's istate structure are copied to a newly
     513 * allocated buffer and a pointer to it is written to @a buffer. The size of
     514 * the buffer will be sizeof(istate_t).
     515 *
     516 * Currently register state cannot be read if the thread is inside a system
     517 * call (as opposed to an exception). This is an implementation limit.
     518 *
     519 * @param t             Thread whose state is to be read.
     520 * @param buffer        Place to store pointer to new buffer.
     521 * @return              EOK on success, ENOENT if @a t is invalid, EINVAL
     522 *                      if thread is not in valid state, EBUSY if istate
     523 *                      is not available.
     524 */
     525int udebug_regs_read(thread_t *t, void **buffer)
     526{
     527        istate_t *state, *state_buf;
     528        int rc;
     529
     530        /* Prepare a buffer to hold the data. */
     531        state_buf = malloc(sizeof(istate_t), 0);
     532
     533        /* On success, this will lock t->udebug.lock */
     534        rc = _thread_op_begin(t, false);
     535        if (rc != EOK) {
     536                return rc;
     537        }
     538
     539        state = t->udebug.uspace_state;
     540        if (state == NULL) {
     541                _thread_op_end(t);
     542                return EBUSY;
     543        }
     544
     545        /* Copy to the allocated buffer */
     546        memcpy(state_buf, state, sizeof(istate_t));
     547
     548        _thread_op_end(t);
     549
     550        *buffer = (void *) state_buf;
     551        return 0;
     552}
     553
    471554/** Read the memory of the debugged task.
    472555 *
  • uspace/Makefile

    r430de97 r1735f3e  
    4040        app/mkfat \
    4141        app/redir \
     42        app/taskdump \
    4243        app/tester \
    4344        app/tetris \
     
    4748        srv/loader \
    4849        srv/ns \
     50        srv/taskmon \
    4951        srv/vfs \
    5052        srv/bd/ata_bd \
     
    5759        srv/fs/tmpfs \
    5860        srv/fs/devfs \
     61        srv/hid/adb_mouse \
    5962        srv/hid/console \
    60         srv/hid/c_mouse \
     63        srv/hid/char_mouse \
    6164        srv/hid/fb \
    6265        srv/hid/kbd \
     
    6972ifeq ($(UARCH),ia32)
    7073        DIRS += srv/hw/bus/pci
     74endif
     75
     76ifeq ($(UARCH),ppc32)
     77        DIRS += srv/hw/bus/cuda_adb
    7178endif
    7279
  • uspace/app/init/init.c

    r430de97 r1735f3e  
    233233}
    234234
     235static void mount_scratch(void)
     236{
     237        int rc;
     238
     239        printf("Trying to mount null/0 on /scratch... ");
     240        fflush(stdout);
     241
     242        rc = mount("tmpfs", "/scratch", "null/0", "", 0);
     243        if (rc == EOK)
     244                printf("OK\n");
     245        else
     246                printf("Failed\n");
     247}
     248
    235249static void mount_data(void)
    236250{
     
    255269                return -1;
    256270        }
     271
     272        /* Make sure tmpfs is running. */
     273        if (str_cmp(STRING(RDFMT), "tmpfs") != 0) {
     274                spawn("/srv/tmpfs");
     275        }
    257276       
    258277        spawn("/srv/devfs");
     278        spawn("/srv/taskmon");
    259279       
    260280        if (!mount_devfs()) {
     
    262282                return -2;
    263283        }
     284
     285        mount_scratch();
    264286       
    265287        spawn("/srv/fhc");
    266288        spawn("/srv/obio");
     289        srv_start("/srv/cuda_adb");
    267290        srv_start("/srv/i8042");
    268         srv_start("/srv/c_mouse");
     291        srv_start("/srv/adb_ms");
     292        srv_start("/srv/char_ms");
    269293
    270294        spawn("/srv/fb");
     
    298322        getterm("term/vc5", "/app/bdsh");
    299323        getterm("term/vc6", "/app/klog");
    300        
     324
    301325        return 0;
    302326}
  • uspace/app/mkfat/mkfat.c

    r430de97 r1735f3e  
    4444#include <devmap.h>
    4545#include <byteorder.h>
     46#include <sys/types.h>
     47#include <sys/typefmt.h>
     48#include <inttypes.h>
    4649#include <errno.h>
    4750#include "fat.h"
     
    157160                printf(NAME ": Warning, failed to obtain block device size.\n");
    158161        } else {
    159                 printf(NAME ": Block device has %llu blocks.\n", dev_nblocks);
     162                printf(NAME ": Block device has %" PRIuBN " blocks.\n",
     163                    dev_nblocks);
    160164                cfg.total_sectors = dev_nblocks;
    161165        }
  • uspace/app/trace/ipcp.c

    r430de97 r1735f3e  
    3636#include <stdlib.h>
    3737#include <adt/hash_table.h>
     38#include <sys/typefmt.h>
    3839
    3940#include "ipc_desc.h"
     
    200201
    201202        if ((display_mask & DM_IPC) != 0) {
    202                 printf("Call ID: 0x%lx, phone: %d, proto: %s, method: ", hash,
     203                printf("Call ID: %p, phone: %d, proto: %s, method: ", hash,
    203204                        phone, (proto ? proto->name : "n/a"));
    204205                ipc_m_print(proto, IPC_GET_METHOD(*call));
    205                 printf(" args: (%lu, %lu, %lu, %lu, %lu)\n", args[1], args[2],
     206                printf(" args: (%" PRIuIPCARG ", %" PRIuIPCARG ", %" PRIuIPCARG
     207                    ", %" PRIuIPCARG ", %" PRIuIPCARG ")\n", args[1], args[2],
    206208                    args[3], args[4], args[5]);
    207209        }
     
    279281
    280282        if ((display_mask & DM_IPC) != 0) {
    281                 printf("Response to 0x%lx: retval=%ld, args = (%lu, %lu, %lu, %lu, %lu)\n",
    282                         hash, retval, IPC_GET_ARG1(*answer),
    283                         IPC_GET_ARG2(*answer), IPC_GET_ARG3(*answer),
    284                         IPC_GET_ARG4(*answer), IPC_GET_ARG5(*answer));
     283                printf("Response to %p: retval=%ld, args = (%" PRIuIPCARG
     284                    ", %" PRIuIPCARG ", %" PRIuIPCARG ", %" PRIuIPCARG
     285                    ", %" PRIuIPCARG ")\n",
     286                    hash, retval, IPC_GET_ARG1(*answer),
     287                    IPC_GET_ARG2(*answer), IPC_GET_ARG3(*answer),
     288                    IPC_GET_ARG4(*answer), IPC_GET_ARG5(*answer));
    285289        }
    286290
     
    336340                /* Not a response */
    337341                if ((display_mask & DM_IPC) != 0) {
    338                         printf("Not a response (hash 0x%lx)\n", hash);
     342                        printf("Not a response (hash %p)\n", hash);
    339343                }
    340344                return;
  • uspace/app/trace/trace.c

    r430de97 r1735f3e  
    4949#include <io/keycode.h>
    5050#include <fibril_synch.h>
     51#include <sys/types.h>
     52#include <sys/typefmt.h>
    5153
    5254#include <libc.h>
     
    159161        if (rc < 0) {
    160162                printf("Error connecting\n");
    161                 printf("ipc_connect_task(%lld) -> %d ", task_id, rc);
     163                printf("ipc_connect_task(%" PRIdTASKID ") -> %d ", task_id, rc);
    162164                return rc;
    163165        }
     
    198200        printf("Threads:");
    199201        for (i = 0; i < n_threads; i++) {
    200                 printf(" [%d] (hash 0x%lx)", 1+i, thread_hash_buf[i]);
     202                printf(" [%d] (hash %p)", 1+i, thread_hash_buf[i]);
    201203        }
    202204        printf("\ntotal of %u threads\n", tb_needed / sizeof(uintptr_t));
     
    222224        case V_HASH:
    223225        case V_PTR:
    224                 printf("0x%08lx", val);
     226                printf("%p", val);
    225227                break;
    226228
     
    275277
    276278        putchar('(');
    277         if (n > 0) printf("%ld", sc_args[0]);
     279        if (n > 0) printf("%" PRIdSYSARG, sc_args[0]);
    278280        for (i = 1; i < n; i++) {
    279                 printf(", %ld", sc_args[i]);
     281                printf(", %" PRIdSYSARG, sc_args[i]);
    280282        }
    281283        putchar(')');
     
    508510        }
    509511
    510         printf("Start tracing thread [%d] (hash 0x%lx).\n", thread_id, thread_hash);
     512        printf("Start tracing thread [%d] (hash %p).\n", thread_id, thread_hash);
    511513
    512514        while (!abort_trace) {
     
    552554                                break;
    553555                        case UDEBUG_EVENT_THREAD_E:
    554                                 printf("Thread 0x%lx exited.\n", val0);
     556                                printf("Thread %p exited.\n", val0);
    555557                                fibril_mutex_lock(&state_lock);
    556558                                abort_trace = true;
     
    972974        rc = connect_task(task_id);
    973975        if (rc < 0) {
    974                 printf("Failed connecting to task %lld.\n", task_id);
     976                printf("Failed connecting to task %" PRIdTASKID ".\n", task_id);
    975977                return 1;
    976978        }
    977979
    978         printf("Connected to task %lld.\n", task_id);
     980        printf("Connected to task %" PRIdTASKID ".\n", task_id);
    979981
    980982        if (task_ldr != NULL)
  • uspace/lib/libc/arch/amd64/Makefile.inc

    r430de97 r1735f3e  
    3737        arch/$(UARCH)/src/fibril.S \
    3838        arch/$(UARCH)/src/tls.c \
    39         arch/$(UARCH)/src/stacktrace.S
     39        arch/$(UARCH)/src/stacktrace.c \
     40        arch/$(UARCH)/src/stacktrace_asm.S
    4041
    4142GCC_CFLAGS += -fno-omit-frame-pointer
  • uspace/lib/libc/arch/amd64/include/types.h

    r430de97 r1735f3e  
    3636#define LIBC_amd64_TYPES_H_
    3737
     38#define __64_BITS__
     39
    3840typedef unsigned long long sysarg_t;
    3941
  • uspace/lib/libc/arch/amd64/src/stacktrace_asm.S

    r430de97 r1735f3e  
    2929.text
    3030
    31 .global frame_pointer_get
    32 .global frame_pointer_prev
    33 .global frame_pointer_validate
    34 .global return_address_get
    35 .global program_counter_get
     31.global stacktrace_prepare
     32.global stacktrace_fp_get
     33.global stacktrace_pc_get
    3634
    37 frame_pointer_get:
     35stacktrace_prepare:
     36        ret
     37
     38stacktrace_fp_get:
    3839        movq %rbp, %rax
    3940        ret
    4041
    41 frame_pointer_prev:
    42         movq (%rdi), %rax
    43         ret
    44 
    45 frame_pointer_validate:
    46         movq %rdi, %rax
    47         ret
    48 
    49 return_address_get:
    50         movq 8(%rdi), %rax
    51         ret
    52 
    53 program_counter_get:
     42stacktrace_pc_get:
    5443        movq (%rsp), %rax
    5544        ret
  • uspace/lib/libc/arch/arm32/Makefile.inc

    r430de97 r1735f3e  
    3838        arch/$(UARCH)/src/tls.c \
    3939        arch/$(UARCH)/src/eabi.S \
    40         arch/$(UARCH)/src/stacktrace.S
     40        arch/$(UARCH)/src/stacktrace.c \
     41        arch/$(UARCH)/src/stacktrace_asm.S
    4142
    4243GCC_CFLAGS += -ffixed-r9 -mtp=soft -mapcs-frame -fno-omit-frame-pointer
  • uspace/lib/libc/arch/arm32/include/types.h

    r430de97 r1735f3e  
    3737#define LIBC_arm32_TYPES_H_
    3838
     39#define __32_BITS__
     40
    3941typedef unsigned int sysarg_t;
    4042
  • uspace/lib/libc/arch/arm32/src/stacktrace_asm.S

    r430de97 r1735f3e  
    2929.text
    3030
    31 .global frame_pointer_get
    32 .global frame_pointer_prev
    33 .global frame_pointer_validate
    34 .global return_address_get
    35 .global program_counter_get
     31.global stacktrace_prepare
     32.global stacktrace_fp_get
     33.global stacktrace_pc_get
    3634
    37 frame_pointer_get:
     35stacktrace_prepare:
     36        mov pc, lr
     37
     38stacktrace_fp_get:
    3839        mov r0, fp
    3940        mov pc, lr
    4041
    41 frame_pointer_prev:
    42         ldr r0, [r0, #-12]
    43         mov pc, lr
    44 
    45 frame_pointer_validate:
    46         mov pc, lr
    47 
    48 return_address_get:
    49         ldr r0, [r0, #-4]
    50         mov pc, lr
    51 
    52 program_counter_get:
     42stacktrace_pc_get:
    5343        mov r0, lr
    5444        mov pc, lr
    55 
  • uspace/lib/libc/arch/ia32/Makefile.inc

    r430de97 r1735f3e  
    3838        arch/$(UARCH)/src/tls.c \
    3939        arch/$(UARCH)/src/setjmp.S \
    40         arch/$(UARCH)/src/stacktrace.S
     40        arch/$(UARCH)/src/stacktrace.c \
     41        arch/$(UARCH)/src/stacktrace_asm.S
    4142
    4243GCC_CFLAGS += -march=pentium
  • uspace/lib/libc/arch/ia32/include/types.h

    r430de97 r1735f3e  
    3636#define LIBC_ia32_TYPES_H_
    3737
     38#define __32_BITS__
     39
    3840typedef unsigned int sysarg_t;
    3941
  • uspace/lib/libc/arch/ia32/src/stacktrace_asm.S

    r430de97 r1735f3e  
    2929.text
    3030
    31 .global frame_pointer_get
    32 .global frame_pointer_prev
    33 .global frame_pointer_validate
    34 .global return_address_get
    35 .global program_counter_get
     31.global stacktrace_prepare
     32.global stacktrace_fp_get
     33.global stacktrace_pc_get
    3634
    37 frame_pointer_get:
     35stacktrace_prepare:
     36        ret
     37
     38stacktrace_fp_get:
    3839        movl %ebp, %eax
    3940        ret
    4041
    41 frame_pointer_prev:
    42         movl 4(%esp), %eax
    43         movl (%eax), %eax
    44         ret
    45 
    46 frame_pointer_validate:
    47         movl 4(%esp), %eax
    48         ret
    49 
    50 return_address_get:
    51         movl 4(%esp), %eax
    52         movl 4(%eax), %eax
    53         ret
    54 
    55 program_counter_get:
     42stacktrace_pc_get:
    5643        movl (%esp), %eax
    5744        ret
  • uspace/lib/libc/arch/ia64/Makefile.inc

    r430de97 r1735f3e  
    3737        arch/$(UARCH)/src/tls.c \
    3838        arch/$(UARCH)/src/ddi.c \
    39         arch/$(UARCH)/src/stacktrace.S
     39        arch/$(UARCH)/src/stacktrace.c \
     40        arch/$(UARCH)/src/stacktrace_asm.S
    4041
    4142GCC_CFLAGS += -fno-unwind-tables
  • uspace/lib/libc/arch/ia64/include/types.h

    r430de97 r1735f3e  
    3636#define LIBC_ia64_TYPES_H_
    3737
     38#define __64_BITS__
     39
    3840typedef unsigned long long sysarg_t;
    3941
  • uspace/lib/libc/arch/ia64/src/stacktrace_asm.S

    r430de97 r1735f3e  
    2929.text
    3030
    31 .global frame_pointer_get
    32 .global frame_pointer_prev
    33 .global frame_pointer_validate
    34 .global return_address_get
    35 .global program_counter_get
     31.global stacktrace_prepare
     32.global stacktrace_fp_get
     33.global stacktrace_pc_get
    3634
    37 frame_pointer_get:
    38 frame_pointer_prev:
    39 frame_pointer_validate:
    40 return_address_get:
    41 program_counter_get:
     35stacktrace_prepare:
     36        br.ret.sptk.many b0
     37
     38stacktrace_fp_get:
     39stacktrace_pc_get:
    4240        mov r8 = r0
    4341        br.ret.sptk.many b0
  • uspace/lib/libc/arch/mips32/Makefile.inc

    r430de97 r1735f3e  
    3636        arch/$(UARCH)/src/fibril.S \
    3737        arch/$(UARCH)/src/tls.c \
    38         arch/$(UARCH)/src/stacktrace.S
     38        arch/$(UARCH)/src/stacktrace.c \
     39        arch/$(UARCH)/src/stacktrace_asm.S
    3940
    4041GCC_CFLAGS += -mips3
  • uspace/lib/libc/arch/mips32/include/types.h

    r430de97 r1735f3e  
    3737#define LIBC_mips32_TYPES_H_
    3838
     39#define __32_BITS__
     40
    3941typedef unsigned int sysarg_t;
    4042
  • uspace/lib/libc/arch/mips32/src/stacktrace_asm.S

    r430de97 r1735f3e  
    3232.set noreorder
    3333
    34 .global frame_pointer_get
    35 .global frame_pointer_prev
    36 .global frame_pointer_validate
    37 .global return_address_get
    38 .global program_counter_get
     34.global stacktrace_prepare
     35.global stacktrace_fp_get
     36.global stacktrace_pc_get
    3937
    40 frame_pointer_get:
    41 frame_pointer_prev:
    42 frame_pointer_validate:
    43 return_address_get:
    44 program_counter_get:
     38stacktrace_prepare:
     39stacktrace_fp_get:
     40stacktrace_pc_get:
    4541        j $ra
    4642        xor $v0, $v0
  • uspace/lib/libc/arch/mips32eb/Makefile.inc

    r430de97 r1735f3e  
    3636        arch/$(UARCH)/src/fibril.S \
    3737        arch/$(UARCH)/src/tls.c \
    38         arch/$(UARCH)/src/stacktrace.S
     38        arch/$(UARCH)/src/stacktrace.c \
     39        arch/$(UARCH)/src/stacktrace_asm.S
    3940
    4041GCC_CFLAGS += -mips3
  • uspace/lib/libc/arch/ppc32/Makefile.inc

    r430de97 r1735f3e  
    3636        arch/$(UARCH)/src/fibril.S \
    3737        arch/$(UARCH)/src/tls.c \
    38         arch/$(UARCH)/src/stacktrace.S
     38        arch/$(UARCH)/src/stacktrace.c \
     39        arch/$(UARCH)/src/stacktrace_asm.S
    3940
    4041GCC_CFLAGS += -mcpu=powerpc -msoft-float -m32
  • uspace/lib/libc/arch/ppc32/include/types.h

    r430de97 r1735f3e  
    3636#define LIBC_ppc32_TYPES_H_
    3737
     38#define __32_BITS__
     39
    3840typedef unsigned int sysarg_t;
    3941
  • uspace/lib/libc/arch/ppc32/src/stacktrace_asm.S

    r430de97 r1735f3e  
    3131#include <libarch/regname.h>
    3232
    33 .global frame_pointer_get
    34 .global frame_pointer_prev
    35 .global frame_pointer_validate
    36 .global return_address_get
    37 .global program_counter_get
     33.global stacktrace_prepare
     34.global stacktrace_fp_get
     35.global stacktrace_pc_get
    3836
    39 frame_pointer_get:
     37stacktrace_prepare:
     38        blr
     39
     40stacktrace_fp_get:
    4041        mr r3, sp
    4142        blr
    4243
    43 frame_pointer_prev:
    44         lwz r3, 0(r3)
    45         blr
    46 
    47 frame_pointer_validate:
    48         blr
    49 
    50 return_address_get:
    51         lwz r3, 4(r3)
    52         blr
    53 
    54 program_counter_get:
     44stacktrace_pc_get:
    5545        mflr r3
    5646        blr
  • uspace/lib/libc/arch/sparc64/Makefile.inc

    r430de97 r1735f3e  
    3535ARCH_SOURCES += arch/$(UARCH)/src/fibril.S \
    3636        arch/$(UARCH)/src/tls.c \
    37         arch/$(UARCH)/src/stacktrace.S
     37        arch/$(UARCH)/src/stacktrace.c \
     38        arch/$(UARCH)/src/stacktrace_asm.S
    3839
    3940GCC_CFLAGS += -mcpu=ultrasparc -m64
  • uspace/lib/libc/arch/sparc64/include/types.h

    r430de97 r1735f3e  
    3636#define LIBC_sparc64_TYPES_H_
    3737
     38#define __64_BITS__
     39
    3840typedef unsigned long sysarg_t;
    3941
  • uspace/lib/libc/generic/stacktrace.c

    r430de97 r1735f3e  
    11/*
    22 * Copyright (c) 2009 Jakub Jermar
     3 * Copyright (c) 2010 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    3637#include <stdio.h>
    3738#include <sys/types.h>
     39#include <errno.h>
    3840
    39 void stack_trace_fp_pc(uintptr_t fp, uintptr_t pc)
     41static int stacktrace_read_uintptr(void *arg, uintptr_t addr, uintptr_t *data);
     42
     43void stacktrace_print_fp_pc(uintptr_t fp, uintptr_t pc)
    4044{
    41         while (frame_pointer_validate(fp)) {
     45        stacktrace_t st;
     46        uintptr_t nfp;
     47
     48        st.op_arg = NULL;
     49        st.read_uintptr = stacktrace_read_uintptr;
     50
     51        while (stacktrace_fp_valid(&st, fp)) {
    4252                printf("%p: %p()\n", fp, pc);
    43                 pc = return_address_get(fp);
    44                 fp = frame_pointer_prev(fp);
     53                (void) stacktrace_ra_get(&st, fp, &pc);
     54                (void) stacktrace_fp_prev(&st, fp, &nfp);
     55                fp = nfp;
    4556        }
    4657}
    4758
    48 void stack_trace(void)
     59void stacktrace_print(void)
    4960{
    50         stack_trace_fp_pc(frame_pointer_get(), program_counter_get());
     61        stacktrace_prepare();
     62        stacktrace_print_fp_pc(stacktrace_fp_get(), stacktrace_pc_get());
    5163        /*
    5264         * Prevent the tail call optimization of the previous call by
    5365         * making it a non-tail call.
    5466         */
    55         (void) frame_pointer_get();
     67        (void) stacktrace_fp_get();
     68}
     69
     70static int stacktrace_read_uintptr(void *arg, uintptr_t addr, uintptr_t *data)
     71{
     72        (void) arg;
     73        *data = *((uintptr_t *) addr);
     74        return EOK;
    5675}
    5776
  • uspace/lib/libc/generic/udebug.c

    r430de97 r1735f3e  
    6969}
    7070
     71int udebug_name_read(int phoneid, void *buffer, size_t n,
     72        size_t *copied, size_t *needed)
     73{
     74        ipcarg_t a_copied, a_needed;
     75        int rc;
     76
     77        rc = async_req_3_3(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_NAME_READ,
     78                (sysarg_t)buffer, n, NULL, &a_copied, &a_needed);
     79
     80        *copied = (size_t)a_copied;
     81        *needed = (size_t)a_needed;
     82
     83        return rc;
     84}
     85
     86int udebug_areas_read(int phoneid, void *buffer, size_t n,
     87        size_t *copied, size_t *needed)
     88{
     89        ipcarg_t a_copied, a_needed;
     90        int rc;
     91
     92        rc = async_req_3_3(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_AREAS_READ,
     93                (sysarg_t)buffer, n, NULL, &a_copied, &a_needed);
     94
     95        *copied = (size_t)a_copied;
     96        *needed = (size_t)a_needed;
     97
     98        return rc;
     99}
     100
    71101int udebug_mem_read(int phoneid, void *buffer, uintptr_t addr, size_t n)
    72102{
     
    78108{
    79109        return async_req_3_0(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_ARGS_READ,
     110            tid, (sysarg_t)buffer);
     111}
     112
     113int udebug_regs_read(int phoneid, thash_t tid, void *buffer)
     114{
     115        return async_req_3_0(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_REGS_READ,
    80116            tid, (sysarg_t)buffer);
    81117}
  • uspace/lib/libc/include/stacktrace.h

    r430de97 r1735f3e  
    11/*
    22 * Copyright (c) 2009 Jakub Jermar
     3 * Copyright (c) 2010 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    3940#include <bool.h>
    4041
    41 extern void stack_trace(void);
    42 extern void stack_trace_fp_pc(uintptr_t, uintptr_t);
     42typedef struct {
     43        void *op_arg;
     44        int (*read_uintptr)(void *, uintptr_t, uintptr_t *);
     45} stacktrace_t;
     46
     47extern void stacktrace_print(void);
     48extern void stacktrace_print_fp_pc(uintptr_t, uintptr_t);
    4349
    4450/*
    4551 * The following interface is to be implemented by each architecture.
    4652 */
    47 extern bool frame_pointer_validate(uintptr_t);
    48 extern uintptr_t frame_pointer_get(void);
    49 extern uintptr_t frame_pointer_prev(uintptr_t);
    50 extern uintptr_t return_address_get(uintptr_t);
    51 extern uintptr_t program_counter_get();
     53extern bool stacktrace_fp_valid(stacktrace_t *, uintptr_t);
     54extern int stacktrace_fp_prev(stacktrace_t *, uintptr_t, uintptr_t *);
     55extern int stacktrace_ra_get(stacktrace_t *, uintptr_t, uintptr_t *);
     56
     57extern void stacktrace_prepare(void);
     58extern uintptr_t stacktrace_fp_get(void);
     59extern uintptr_t stacktrace_pc_get();
    5260
    5361#endif
  • uspace/lib/libc/include/stdlib.h

    r430de97 r1735f3e  
    4242#define abort() \
    4343        do { \
    44                 stack_trace(); \
     44                stacktrace_print(); \
    4545                _exit(1); \
    4646        } while (0)
  • uspace/lib/libc/include/udebug.h

    r430de97 r1735f3e  
    4747int udebug_thread_read(int phoneid, void *buffer, size_t n,
    4848        size_t *copied, size_t *needed);
     49int udebug_name_read(int phoneid, void *buffer, size_t n,
     50        size_t *copied, size_t *needed);
     51int udebug_areas_read(int phoneid, void *buffer, size_t n,
     52        size_t *copied, size_t *needed);
    4953int udebug_mem_read(int phoneid, void *buffer, uintptr_t addr, size_t n);
    5054int udebug_args_read(int phoneid, thash_t tid, sysarg_t *buffer);
     55int udebug_regs_read(int phoneid, thash_t tid, void *buffer);
    5156int udebug_go(int phoneid, thash_t tid, udebug_event_t *ev_type,
    5257        sysarg_t *val0, sysarg_t *val1);
  • uspace/srv/bd/ata_bd/ata_bd.c

    r430de97 r1735f3e  
    5959#include <devmap.h>
    6060#include <sys/types.h>
     61#include <inttypes.h>
    6162#include <errno.h>
    6263#include <bool.h>
     
    112113        printf(NAME ": ATA disk driver\n");
    113114
    114         printf("I/O address 0x%p/0x%p\n", ctl_physical, cmd_physical);
     115        printf("I/O address %p/%p\n", ctl_physical, cmd_physical);
    115116
    116117        if (ata_bd_init() != EOK)
     
    180181        }
    181182
    182         printf(" %llu blocks", d->blocks, d->blocks / (2 * 1024));
     183        printf(" %" PRIu64 " blocks", d->blocks, d->blocks / (2 * 1024));
    183184
    184185        mbytes = d->blocks / (2 * 1024);
    185186        if (mbytes > 0)
    186                 printf(" %llu MB.", mbytes);
     187                printf(" %" PRIu64 " MB.", mbytes);
    187188
    188189        printf("\n");
  • uspace/srv/bd/part/guid_part/guid_part.c

    r430de97 r1735f3e  
    5454#include <devmap.h>
    5555#include <sys/types.h>
     56#include <sys/typefmt.h>
     57#include <inttypes.h>
    5658#include <libblock.h>
    5759#include <devmap.h>
     
    196198                size_mb = (part->length * block_size + 1024 * 1024 - 1)
    197199                    / (1024 * 1024);
    198                 printf(NAME ": Registered device %s: %llu blocks %llu MB.\n",
    199                     name, part->length, size_mb);
     200                printf(NAME ": Registered device %s: %" PRIu64 " blocks "
     201                    "%" PRIuBN " MB.\n", name, part->length, size_mb);
    200202
    201203                part->dev = dev;
  • uspace/srv/bd/part/mbr_part/mbr_part.c

    r430de97 r1735f3e  
    6464#include <devmap.h>
    6565#include <sys/types.h>
     66#include <sys/typefmt.h>
     67#include <inttypes.h>
    6668#include <libblock.h>
    6769#include <devmap.h>
     
    247249                size_mb = (part->length * block_size + 1024 * 1024 - 1)
    248250                    / (1024 * 1024);
    249                 printf(NAME ": Registered device %s: %llu blocks %llu MB.\n",
    250                     name, part->length, size_mb);
     251                printf(NAME ": Registered device %s: %" PRIuBN " blocks "
     252                    "%" PRIu64 " MB.\n", name, part->length, size_mb);
    251253
    252254                part->dev = dev;
     
    274276        if (brb == NULL) {
    275277                printf(NAME ": Failed allocating memory.\n");
    276                 return ENOMEM; 
     278                return ENOMEM;
    277279        }
    278280
     
    289291        sgn = uint16_t_le2host(brb->signature);
    290292        if (sgn != BR_SIGNATURE) {
    291                 printf(NAME ": Invalid boot record signature 0x%04X.\n", sgn);
     293                printf(NAME ": Invalid boot record signature 0x%04" PRIX16
     294                    ".\n", sgn);
    292295                return EINVAL;
    293296        }
     
    333336                rc = block_read_direct(indev_handle, ba, 1, brb);
    334337                if (rc != EOK) {
    335                         printf(NAME ": Failed reading EBR block at %u.\n", ba);
     338                        printf(NAME ": Failed reading EBR block at %"
     339                            PRIu32 ".\n", ba);
    336340                        return rc;
    337341                }
     
    339343                sgn = uint16_t_le2host(brb->signature);
    340344                if (sgn != BR_SIGNATURE) {
    341                         printf(NAME ": Invalid boot record signature 0x%04X "
    342                             " in EBR at %u.\n", sgn, ba);
     345                        printf(NAME ": Invalid boot record signature 0x%04"
     346                            PRIX16 " in EBR at %" PRIu32 ".\n", sgn, ba);
    343347                        return EINVAL;
    344348                }
  • uspace/srv/hid/char_mouse/Makefile

    r430de97 r1735f3e  
    3232EXTRA_CFLAGS = -Iinclude
    3333
    34 OUTPUT = c_mouse
     34OUTPUT = char_ms
    3535
    3636SOURCES = \
    3737        proto/ps2.c \
    38         c_mouse.c \
     38        char_mouse.c \
    3939        chardev.c
    4040
  • uspace/srv/hid/char_mouse/char_mouse.c

    r430de97 r1735f3e  
    4747#include <devmap.h>
    4848
    49 #include <c_mouse.h>
     49#include <char_mouse.h>
    5050#include <mouse_port.h>
    5151#include <mouse_proto.h>
  • uspace/srv/hid/char_mouse/chardev.c

    r430de97 r1735f3e  
    4141#include <errno.h>
    4242
    43 #include <c_mouse.h>
     43#include <char_mouse.h>
    4444#include <mouse_port.h>
    4545
  • uspace/srv/hid/char_mouse/include/char_mouse.h

    r430de97 r1735f3e  
    3434 */
    3535
    36 #ifndef C_MOUSE_H_
    37 #define C_MOUSE_H_
     36#ifndef CHAR_MOUSE_H_
     37#define CHAR_MOUSE_H_
    3838
    3939extern void mouse_handle_byte(int);
  • uspace/srv/hid/char_mouse/proto/ps2.c

    r430de97 r1735f3e  
    3737#include <stdio.h>
    3838#include <mouse_proto.h>
    39 #include <c_mouse.h>
     39#include <char_mouse.h>
    4040
    4141#define BUFSIZE 3
  • uspace/srv/hid/kbd/Makefile.build

    r430de97 r1735f3e  
    125125ifeq ($(UARCH),ppc32)
    126126        SOURCES += \
    127                 port/dummy.c \
    128                 ctl/stty.c
     127                port/adb.c \
     128                ctl/apple.c
    129129endif
    130130
  • uspace/srv/loader/arch/amd64/Makefile.inc

    r430de97 r1735f3e  
    2727#
    2828
    29 EXTRA_CFLAGS = -D__64_BITS__
    3029ARCH_SOURCES := arch/$(UARCH)/amd64.s
  • uspace/srv/loader/arch/arm32/Makefile.inc

    r430de97 r1735f3e  
    2727#
    2828
    29 EXTRA_CFLAGS = -D__32_BITS__
    3029ARCH_SOURCES := arch/$(UARCH)/arm32.s
  • uspace/srv/loader/arch/ia32/Makefile.inc

    r430de97 r1735f3e  
    2727#
    2828
    29 EXTRA_CFLAGS = -D__32_BITS__
    3029ARCH_SOURCES := arch/$(UARCH)/ia32.s
  • uspace/srv/loader/arch/ia64/Makefile.inc

    r430de97 r1735f3e  
    2727#
    2828
    29 EXTRA_CFLAGS = -D__64_BITS__
    3029ARCH_SOURCES := arch/$(UARCH)/ia64.s
    3130AFLAGS += -xexplicit
  • uspace/srv/loader/arch/mips32/Makefile.inc

    r430de97 r1735f3e  
    2727#
    2828
    29 EXTRA_CFLAGS = -D__32_BITS__
    3029ARCH_SOURCES := arch/$(UARCH)/mips32.s
  • uspace/srv/loader/arch/ppc32/Makefile.inc

    r430de97 r1735f3e  
    2727#
    2828
    29 EXTRA_CFLAGS = -D__32_BITS__
    3029ARCH_SOURCES := arch/$(UARCH)/ppc32.s
  • uspace/srv/loader/arch/sparc64/Makefile.inc

    r430de97 r1735f3e  
    2727#
    2828
    29 EXTRA_CFLAGS = -D__64_BITS__
    3029ARCH_SOURCES := arch/$(UARCH)/sparc64.s
  • uspace/srv/loader/elf_load.c

    r430de97 r1735f3e  
    342342        seg_ptr = (void *) seg_addr;
    343343
    344         DPRINTF("Load segment at addr 0x%x, size 0x%x\n", seg_addr,
    345                 entry->p_memsz);       
     344        DPRINTF("Load segment at addr %p, size 0x%x\n", seg_addr,
     345                entry->p_memsz);
    346346
    347347        if (entry->p_align > 1) {
     
    370370        mem_sz = entry->p_memsz + (entry->p_vaddr - base);
    371371
    372         DPRINTF("Map to seg_addr=0x%x-0x%x.\n", seg_addr,
     372        DPRINTF("Map to seg_addr=%p-%p.\n", seg_addr,
    373373        entry->p_vaddr + bias + ALIGN_UP(entry->p_memsz, PAGE_SIZE));
    374374
     
    384384        }
    385385
    386         DPRINTF("as_area_create(0x%lx, 0x%x, %d) -> 0x%lx\n",
     386        DPRINTF("as_area_create(%p, 0x%x, %d) -> 0x%lx\n",
    387387                base + bias, mem_sz, flags, (uintptr_t)a);
    388388
     
    461461                elf->info->dynamic =
    462462                    (void *)((uint8_t *)entry->sh_addr + elf->bias);
    463                 DPRINTF("Dynamic section found at 0x%x.\n",
     463                DPRINTF("Dynamic section found at %p.\n",
    464464                        (uintptr_t)elf->info->dynamic);
    465465                break;
  • uspace/srv/loader/main.c

    r430de97 r1735f3e  
    392392                /* Dynamically linked program */
    393393                DPRINTF("Run ELF interpreter.\n");
    394                 DPRINTF("Entry point: 0x%lx\n", interp_info.entry);
     394                DPRINTF("Entry point: %p\n", interp_info.entry);
    395395               
    396396                ipc_answer_0(rid, EOK);
Note: See TracChangeset for help on using the changeset viewer.