1 /******************************************************************************
2 * Copyright (c) 2007, 2012, 2013 IBM Corporation
4 * This program and the accompanying materials
5 * are made available under the terms of the BSD License
6 * which accompanies this distribution, and is available at
7 * http://www.opensource.org/licenses/bsd-license.php
10 * IBM Corporation - initial implementation
11 *****************************************************************************/
13 * All functions concerning interface to slof
23 * get msec-timer value
24 * access to HW register
25 * overrun will occur if boot exceeds 1.193 hours (49 days)
28 * @return actual timer value in ms as 32bit
30 uint32_t SLOF_GetTimer(void)
32 forth_eval("get-msecs");
33 return (uint32_t) forth_pop();
36 void SLOF_msleep(uint32_t time)
38 time = SLOF_GetTimer() + time;
39 while (time > SLOF_GetTimer())
43 void SLOF_usleep(uint32_t time)
49 void *SLOF_dma_alloc(long size)
52 forth_eval("dma-alloc");
53 return (void *)forth_pop();
56 void SLOF_dma_free(void *virt, long size)
58 forth_push((long)virt);
60 forth_eval("dma-free");
63 void *SLOF_alloc_mem(long size)
66 forth_eval("alloc-mem");
67 return (void *)forth_pop();
70 void *SLOF_alloc_mem_aligned(long size, long align)
72 unsigned long addr = (unsigned long)SLOF_alloc_mem(size + align - 1);
73 addr = addr + align - 1;
74 addr = addr & ~(align - 1);
79 void SLOF_free_mem(void *addr, long size)
81 forth_push((long)addr);
83 forth_eval("free-mem");
86 long SLOF_dma_map_in(void *virt, long size, int cacheable)
88 forth_push((long)virt);
90 forth_push(cacheable);
91 forth_eval("dma-map-in");
95 void SLOF_dma_map_out(long phys, void *virt, long size)
97 forth_push((long)virt);
98 forth_push((long)phys);
100 forth_eval("dma-map-out");
103 long SLOF_pci_config_read32(long offset)
106 forth_eval("config-l@");
110 long SLOF_pci_config_read16(long offset)
113 forth_eval("config-w@");
117 void SLOF_pci_config_write32(long offset, long value)
121 forth_eval("config-l!");
124 void SLOF_pci_config_write16(long offset, long value)
128 forth_eval("config-w!");
131 void *SLOF_translate_my_address(void *addr)
133 forth_push((long)addr);
134 forth_eval("translate-my-address");
135 return (void *)forth_pop();