Rev 2131 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2131 | Rev 2248 | ||
---|---|---|---|
Line 43... | Line 43... | ||
43 | #include <ddi.h> |
43 | #include <ddi.h> |
44 | #include <align.h> |
44 | #include <align.h> |
45 | #include <bool.h> |
45 | #include <bool.h> |
46 | #include <errno.h> |
46 | #include <errno.h> |
47 | #include <async.h> |
47 | #include <async.h> |
- | 48 | #include <stdlib.h> |
|
- | 49 | #include <unistd.h> |
|
- | 50 | #include <align.h> |
|
- | 51 | #include <async.h> |
|
- | 52 | #include <ddi.h> |
|
- | 53 | #include <sysinfo.h> |
|
- | 54 | #include <libarch/ddi.h> |
|
- | 55 | ||
- | 56 | #include "rd.h" |
|
- | 57 | ||
- | 58 | #define EOK 0 |
|
48 | 59 | ||
- | 60 | static void * rd_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 | int block_size = 512; |
|
- | 70 | ipcarg_t dst, offset; |
|
57 | 71 | ||
58 | while (1) { |
72 | while (1) { |
59 | callid = async_get_call(&call); |
73 | callid = async_get_call(&call); |
60 | switch (IPC_GET_METHOD(call)) { |
74 | switch (IPC_GET_METHOD(call)) { |
61 | case IPC_M_PHONE_HUNGUP: |
75 | case IPC_M_PHONE_HUNGUP: |
62 | ipc_answer_fast(callid, 0,0,0); |
76 | ipc_answer_fast(callid, 0,0,0); |
63 | return; |
77 | return; |
- | 78 | case BD_READ_BLOCK: |
|
- | 79 | //returnt the block data |
|
- | 80 | dst = IPC_GET_ARG1(call); |
|
- | 81 | offset = IPC_GET_ARG2(call); |
|
- | 82 | //copy_from_uspace(dst, rd_addr+offset,block_size); |
|
- | 83 | memcpy((void *) dst, rd_addr+offset, block_size); |
|
- | 84 | retval = EOK; |
|
- | 85 | break; |
|
64 | default: |
86 | default: |
65 | retval = EINVAL; |
87 | retval = EINVAL; |
66 | } |
88 | } |
67 | ipc_answer_fast(callid, retval, 0, 0); |
89 | ipc_answer_fast(callid, retval, 0, 0); |
68 | } |
90 | } |
Line 76... | Line 98... | ||
76 | int rd_color = (int) sysinfo_value("rd.address.color"); |
98 | int rd_color = (int) sysinfo_value("rd.address.color"); |
77 | 99 | ||
78 | if (rd_size == 0) |
100 | if (rd_size == 0) |
79 | return false; |
101 | return false; |
80 | 102 | ||
81 | void * rd_addr = as_get_mappable_page(rd_size, rd_color); |
103 | rd_addr = as_get_mappable_page(rd_size, rd_color); |
82 | 104 | ||
83 | physmem_map(rd_ph_addr, rd_addr, ALIGN_UP(rd_size, PAGE_SIZE) >> PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE); |
105 | physmem_map(rd_ph_addr, rd_addr, ALIGN_UP(rd_size, PAGE_SIZE) >> PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE); |
84 | 106 | ||
85 | return true; |
107 | return true; |
86 | } |
108 | } |