Rev 3684 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 3684 | Rev 4377 | ||
|---|---|---|---|
| Line 23... | Line 23... | ||
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | */ |
27 | */ |
| 28 | 28 | ||
| 29 | #include <ofw.h> |
29 | #include <ofw.h> |
| 30 | #include <ofwarch.h> |
30 | #include <ofwarch.h> |
| 31 | #include <printf.h> |
31 | #include <printf.h> |
| 32 | #include <asm.h> |
32 | #include <asm.h> |
| 33 | #include <types.h> |
33 | #include <types.h> |
| Line 201... | Line 201... | ||
| 201 | void *ofw_translate(const void *virt) |
201 | void *ofw_translate(const void *virt) |
| 202 | { |
202 | { |
| 203 | ofw_arg_t result[4]; |
203 | ofw_arg_t result[4]; |
| 204 | int shift; |
204 | int shift; |
| 205 | 205 | ||
| 206 | if (ofw_call("call-method", 3, 5, result, "translate", ofw_mmu, |
206 | if (ofw_call("call-method", 4, 5, result, "translate", ofw_mmu, |
| 207 | virt) != 0) { |
207 | virt, 0) != 0) { |
| 208 | puts("Error: MMU method translate() failed, halting.\n"); |
208 | puts("Error: MMU method translate() failed, halting.\n"); |
| 209 | halt(); |
209 | halt(); |
| 210 | } |
210 | } |
| 211 | 211 | ||
| 212 | if (ofw_translate_failed(result[0])) |
212 | if (ofw_translate_failed(result[0])) |
| Line 296... | Line 296... | ||
| 296 | { |
296 | { |
| 297 | unsigned int ac = ofw_get_address_cells(ofw_memory) / |
297 | unsigned int ac = ofw_get_address_cells(ofw_memory) / |
| 298 | (sizeof(uintptr_t) / sizeof(uint32_t)); |
298 | (sizeof(uintptr_t) / sizeof(uint32_t)); |
| 299 | unsigned int sc = ofw_get_size_cells(ofw_memory) / |
299 | unsigned int sc = ofw_get_size_cells(ofw_memory) / |
| 300 | (sizeof(uintptr_t) / sizeof(uint32_t)); |
300 | (sizeof(uintptr_t) / sizeof(uint32_t)); |
| 301 | printf("address cells: %d, size cells: %d. ", ac, sc); |
- | |
| 302 | 301 | ||
| 303 | uintptr_t buf[((ac + sc) * MEMMAP_MAX_RECORDS)]; |
302 | uintptr_t buf[((ac + sc) * MEMMAP_MAX_RECORDS)]; |
| 304 | int ret = ofw_get_property(ofw_memory, "reg", buf, sizeof(buf)); |
303 | int ret = ofw_get_property(ofw_memory, "reg", buf, sizeof(buf)); |
| 305 | if (ret <= 0) /* ret is the number of written bytes */ |
304 | if (ret <= 0) /* ret is the number of written bytes */ |
| 306 | return false; |
305 | return false; |
| Line 371... | Line 370... | ||
| 371 | return false; |
370 | return false; |
| 372 | 371 | ||
| 373 | return true; |
372 | return true; |
| 374 | } |
373 | } |
| 375 | 374 | ||
| - | 375 | #define RED(i) (((i) >> 5) & ((1 << 3) - 1)) |
|
| - | 376 | #define GREEN(i) (((i) >> 3) & ((1 << 2) - 1)) |
|
| - | 377 | #define BLUE(i) ((i) & ((1 << 3) - 1)) |
|
| - | 378 | #define CLIP(i) ((i) <= 255 ? (i) : 255) |
|
| - | 379 | ||
| - | 380 | ||
| 376 | /** |
381 | /** |
| 377 | * Sets up the palette for the 8-bit color depth configuration so that the |
382 | * Sets up the palette for the 8-bit color depth configuration so that the |
| 378 | * 3:2:3 color scheme can be used. Checks that setting the palette makes sense |
383 | * 3:2:3 color scheme can be used. Checks that setting the palette makes sense |
| 379 | * (appropriate nodes exist in the OBP tree and the color depth is not greater |
384 | * (appropriate nodes exist in the OBP tree and the color depth is not greater |
| 380 | * than 8). |
385 | * than 8). |
| - | 386 | * |
|
| - | 387 | * @return true if the palette has been set, false otherwise |
|
| 381 | * |
388 | * |
| 382 | * @return true if the palette has been set, false otherwise |
- | |
| 383 | */ |
389 | */ |
| 384 | int setup_palette(void) |
390 | int ofw_setup_palette(void) |
| 385 | { |
391 | { |
| 386 | char device_name[BUF_SIZE]; |
392 | char device_name[BUF_SIZE]; |
| 387 | 393 | ||
| 388 | /* resolve alias */ |
394 | /* resolve alias */ |
| 389 | if (ofw_get_property(ofw_aliases, "screen", device_name, |
395 | if (ofw_get_property(ofw_aliases, "screen", device_name, |
| 390 | sizeof(device_name)) <= 0) |
396 | sizeof(device_name)) <= 0) |
| 391 | return false; |
397 | return false; |
| 392 | 398 | ||
| 393 | /* for depth greater than 8 it makes no sense to set up the palette */ |
399 | /* for depth greater than 8 it makes no sense to set up the palette */ |
| 394 | uint32_t depth; |
400 | uint32_t depth; |
| 395 | phandle device = ofw_find_device(device_name); |
401 | phandle device = ofw_find_device(device_name); |
| 396 | if (device == -1) |
402 | if (device == -1) |
| 397 | return false; |
403 | return false; |
| Line 402... | Line 408... | ||
| 402 | 408 | ||
| 403 | /* required in order to be able to make a method call */ |
409 | /* required in order to be able to make a method call */ |
| 404 | ihandle screen = ofw_open(device_name); |
410 | ihandle screen = ofw_open(device_name); |
| 405 | if (screen == -1) |
411 | if (screen == -1) |
| 406 | return false; |
412 | return false; |
| 407 | 413 | ||
| 408 | /* setup the palette so that the 3:2:3 scheme is usable */ |
414 | /* setup the palette so that the (inverted) 3:2:3 scheme is usable */ |
| 409 | unsigned int i; |
415 | unsigned int i; |
| 410 | for (i = 0; i < 256; i++) |
416 | for (i = 0; i < 256; i++) |
| 411 | if (ofw_call("call-method", 6, 1, NULL, "color!", screen, |
417 | ofw_call("call-method", 6, 1, NULL, "color!", screen, |
| 412 | i, |
- | |
| 413 | i << 5, |
- | |
| 414 | (i >> 3) << 6, |
- | |
| 415 | (i >> 5) << 5) != 0); |
418 | 255 - i, CLIP(BLUE(i) * 37), GREEN(i) * 85, CLIP(RED(i) * 37)); |
| 416 | return true; |
419 | return true; |
| 417 | } |
420 | } |
| 418 | 421 | ||
| 419 | void ofw_quiesce(void) |
422 | void ofw_quiesce(void) |
| 420 | { |
423 | { |