Rev 2141 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2141 | Rev 2445 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* |
1 | /* |
- | 2 | * Copyright (c) 2007 Michal Konopa |
|
2 | * Copyright (c) 2006 Martin Decky |
3 | * Copyright (c) 2007 Martin Jelen |
- | 4 | * Copyright (c) 2007 Peter Majer |
|
3 | * All rights reserved. |
5 | * All rights reserved. |
4 | * |
6 | * |
5 | * Redistribution and use in source and binary forms, with or without |
7 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
8 | * modification, are permitted provided that the following conditions |
7 | * are met: |
9 | * are met: |
Line 43... | Line 45... | ||
43 | #include <ddi.h> |
45 | #include <ddi.h> |
44 | #include <align.h> |
46 | #include <align.h> |
45 | #include <bool.h> |
47 | #include <bool.h> |
46 | #include <errno.h> |
48 | #include <errno.h> |
47 | #include <async.h> |
49 | #include <async.h> |
- | 50 | #include <stdlib.h> |
|
- | 51 | #include <unistd.h> |
|
- | 52 | #include <align.h> |
|
- | 53 | #include <async.h> |
|
- | 54 | #include <ddi.h> |
|
- | 55 | #include <libarch/ddi.h> |
|
- | 56 | #include <stdio.h> |
|
- | 57 | #include "rd.h" |
|
48 | 58 | ||
- | 59 | static void *rd_addr; |
|
- | 60 | static void *fs_addr; |
|
49 | 61 | ||
50 | static void rd_connection(ipc_callid_t iid, ipc_call_t *icall) |
62 | static void rd_connection(ipc_callid_t iid, ipc_call_t *icall) |
51 | { |
63 | { |
52 | ipc_callid_t callid; |
64 | ipc_callid_t callid; |
53 | ipc_call_t call; |
65 | ipc_call_t call; |
54 | int retval; |
66 | int retval; |
55 | 67 | ||
56 | ipc_answer_fast(iid, 0, 0, 0); |
68 | ipc_answer_fast(iid, 0, 0, 0); |
- | 69 | ipcarg_t offset; |
|
57 | 70 | ||
58 | while (1) { |
71 | while (1) { |
59 | callid = async_get_call(&call); |
72 | callid = async_get_call(&call); |
60 | switch (IPC_GET_METHOD(call)) { |
73 | switch (IPC_GET_METHOD(call)) { |
61 | case IPC_M_PHONE_HUNGUP: |
74 | case IPC_M_PHONE_HUNGUP: |
62 | ipc_answer_fast(callid, 0,0,0); |
75 | ipc_answer_fast(callid, 0,0,0); |
63 | return; |
76 | return; |
- | 77 | case IPC_M_AS_AREA_SEND: |
|
- | 78 | ipc_answer_fast(callid, 0, (uintptr_t)fs_addr, 0); |
|
- | 79 | continue; |
|
- | 80 | case RD_READ_BLOCK: |
|
- | 81 | offset = IPC_GET_ARG1(call); |
|
- | 82 | memcpy((void *)fs_addr, rd_addr+offset, BLOCK_SIZE); |
|
- | 83 | retval = EOK; |
|
- | 84 | break; |
|
64 | default: |
85 | default: |
65 | retval = EINVAL; |
86 | retval = EINVAL; |
66 | } |
87 | } |
67 | ipc_answer_fast(callid, retval, 0, 0); |
88 | ipc_answer_fast(callid, retval, 0, 0); |
68 | } |
89 | } |
69 | } |
90 | } |
70 | 91 | ||
71 | 92 | ||
72 | static bool rd_init(void) |
93 | static bool rd_init(void) |
73 | { |
94 | { |
- | 95 | int retval, flags; |
|
- | 96 | ||
74 | size_t rd_size = sysinfo_value("rd.size"); |
97 | size_t rd_size = sysinfo_value("rd.size"); |
75 | void * rd_ph_addr = (void *) sysinfo_value("rd.address.physical"); |
98 | void * rd_ph_addr = (void *) sysinfo_value("rd.address.physical"); |
76 | 99 | ||
77 | if (rd_size == 0) |
100 | if (rd_size == 0) |
78 | return false; |
101 | return false; |
79 | 102 | ||
80 | void * rd_addr = as_get_mappable_page(rd_size); |
103 | rd_addr = as_get_mappable_page(rd_size); |
81 | 104 | ||
- | 105 | flags = AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE; |
|
82 | physmem_map(rd_ph_addr, rd_addr, ALIGN_UP(rd_size, PAGE_SIZE) >> PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE); |
106 | retval = physmem_map(rd_ph_addr, rd_addr, ALIGN_UP(rd_size, PAGE_SIZE) >> PAGE_WIDTH, flags); |
- | 107 | ||
- | 108 | if (retval < 0) |
|
- | 109 | return false; |
|
83 | 110 | ||
- | 111 | size_t fs_size = ALIGN_UP(BLOCK_SIZE * sizeof(char), PAGE_SIZE); |
|
- | 112 | fs_addr = as_get_mappable_page(fs_size); |
|
- | 113 | ||
84 | return true; |
114 | return true; |
85 | } |
115 | } |
86 | 116 | ||
87 | - | ||
88 | int main(int argc, char **argv) |
117 | int main(int argc, char **argv) |
89 | { |
118 | { |
90 | if (rd_init()) { |
119 | if (rd_init()) { |
91 | ipcarg_t phonead; |
120 | ipcarg_t phonead; |
92 | 121 |