cleanup in preparation for merging with loader codebase

This commit is contained in:
bushing 2009-05-05 15:22:57 -07:00
parent ba942c27af
commit 8611805aa9
2 changed files with 27 additions and 18 deletions

View File

@ -1,6 +1,7 @@
include ../../starlet.mk include ../../starlet.mk
ASFLAGS += -D_LANGUAGE_ASSEMBLY ASFLAGS += -D_LANGUAGE_ASSEMBLY
CFLAGS += -DCAN_HAZ_IRQ -DCAN_HAZ_IPC
LDSCRIPT = mini.ld LDSCRIPT = mini.ld
LIBS = -lgcc LIBS = -lgcc

View File

@ -61,6 +61,14 @@ extern u32 __page_table[4096];
#define HW_188 (HW_REG_BASE + 0x188) #define HW_188 (HW_REG_BASE + 0x188)
#define HW_18C (HW_REG_BASE + 0x18c) #define HW_18C (HW_REG_BASE + 0x18c)
#ifdef LOADER
#define IRQ_PREAMBLE /* */
#define IRQ_POSTAMBLE /* */
#else
#define IRQ_PREAMBLE u32 cookie = irq_kill();
#define IRQ_POSTAMBLE irq_restore(cookie);
#endif
// what is this thing doing anyway? // what is this thing doing anyway?
// and why only on reads? // and why only on reads?
u32 _mc_read32(u32 addr) u32 _mc_read32(u32 addr)
@ -162,17 +170,17 @@ void _ahb_flush_to(enum AHBDEV dev) {
// invalidate device and then starlet // invalidate device and then starlet
void ahb_flush_to(enum AHBDEV type) void ahb_flush_to(enum AHBDEV type)
{ {
u32 cookie = irq_kill(); IRQ_PREAMBLE
_ahb_flush_to(type); _ahb_flush_to(type);
if(type != AHB_STARLET) if(type != AHB_STARLET)
_ahb_flush_to(AHB_STARLET); _ahb_flush_to(AHB_STARLET);
irq_restore(cookie); IRQ_POSTAMBLE
} }
// flush device and also invalidate memory // flush device and also invalidate memory
void ahb_flush_from(enum AHBDEV dev) void ahb_flush_from(enum AHBDEV dev)
{ {
u32 cookie = irq_kill(); IRQ_PREAMBLE
u16 req = 0; u16 req = 0;
u16 ack; u16 ack;
int i; int i;
@ -193,8 +201,7 @@ void ahb_flush_from(enum AHBDEV dev)
break; break;
default: default:
gecko_printf("ahb_flush(%d): Invalid device\n", dev); gecko_printf("ahb_flush(%d): Invalid device\n", dev);
irq_restore(cookie); goto done;
return;
} }
write16(MEM_FLUSHREQ, req); write16(MEM_FLUSHREQ, req);
@ -209,12 +216,13 @@ void ahb_flush_from(enum AHBDEV dev)
if(i>=1000000) { if(i>=1000000) {
gecko_printf("ahb_flush(%d): Flush (0x%x) did not ack!\n", dev, req); gecko_printf("ahb_flush(%d): Flush (0x%x) did not ack!\n", dev, req);
} }
irq_restore(cookie); done:
IRQ_POSTAMBLE
} }
void dc_flushrange(const void *start, u32 size) void dc_flushrange(const void *start, u32 size)
{ {
u32 cookie = irq_kill(); IRQ_PREAMBLE
if(size > 0x4000) { if(size > 0x4000) {
_dc_flush(); _dc_flush();
} else { } else {
@ -224,34 +232,34 @@ void dc_flushrange(const void *start, u32 size)
} }
_drain_write_buffer(); _drain_write_buffer();
ahb_flush_from(AHB_1); ahb_flush_from(AHB_1);
irq_restore(cookie); IRQ_POSTAMBLE
} }
void dc_invalidaterange(void *start, u32 size) void dc_invalidaterange(void *start, u32 size)
{ {
u32 cookie = irq_kill(); IRQ_PREAMBLE
void *end = ALIGN_FORWARD(((u8*)start) + size, LINESIZE); void *end = ALIGN_FORWARD(((u8*)start) + size, LINESIZE);
start = ALIGN_BACKWARD(start, LINESIZE); start = ALIGN_BACKWARD(start, LINESIZE);
_dc_inval_entries(start, (end - start) / LINESIZE); _dc_inval_entries(start, (end - start) / LINESIZE);
ahb_flush_to(AHB_STARLET); ahb_flush_to(AHB_STARLET);
irq_restore(cookie); IRQ_POSTAMBLE
} }
void dc_flushall(void) void dc_flushall(void)
{ {
u32 cookie = irq_kill(); IRQ_PREAMBLE
_dc_flush(); _dc_flush();
_drain_write_buffer(); _drain_write_buffer();
ahb_flush_from(AHB_1); ahb_flush_from(AHB_1);
irq_restore(cookie); IRQ_POSTAMBLE
} }
void ic_invalidateall(void) void ic_invalidateall(void)
{ {
u32 cookie = irq_kill(); IRQ_PREAMBLE
_ic_inval(); _ic_inval();
ahb_flush_to(AHB_STARLET); ahb_flush_to(AHB_STARLET);
irq_restore(cookie); IRQ_POSTAMBLE
} }
void mem_protect(int enable, void *start, void *end) void mem_protect(int enable, void *start, void *end)
@ -319,7 +327,7 @@ void map_section(u32 from, u32 to, u32 size, u32 attributes)
void mem_initialize(void) void mem_initialize(void)
{ {
u32 cr; u32 cr;
u32 cookie = irq_kill(); IRQ_PREAMBLE
gecko_printf("MEM: cleaning up\n"); gecko_printf("MEM: cleaning up\n");
@ -362,12 +370,12 @@ void mem_initialize(void)
gecko_printf("MEM: init done\n"); gecko_printf("MEM: init done\n");
irq_restore(cookie); IRQ_POSTAMBLE
} }
void mem_shutdown(void) void mem_shutdown(void)
{ {
u32 cookie = irq_kill(); IRQ_PREAMBLE
_dc_flush(); _dc_flush();
_drain_write_buffer(); _drain_write_buffer();
u32 cr = get_cr(); u32 cr = get_cr();
@ -376,6 +384,6 @@ void mem_shutdown(void)
_ic_inval(); _ic_inval();
_dc_inval(); _dc_inval();
_tlb_inval(); _tlb_inval();
irq_restore(cookie); IRQ_POSTAMBLE
} }