diff --git a/util/baremetal/bootselect/Makefile b/util/baremetal/bootselect/Makefile index f81e436847..55e084eaa0 100644 --- a/util/baremetal/bootselect/Makefile +++ b/util/baremetal/bootselect/Makefile @@ -3,7 +3,7 @@ ARCH = i386 CC = gcc -CFLAGS = -I ../include -I ../include/$(ARCH) -O2 +CFLAGS = -I ../include -I ../include/$(ARCH) -O2 -DZKERNEL_START=0xfff00000 DEPS = bootselect.o rom_fill_inbuf.o chooser.o ../lib/baremetal.a diff --git a/util/baremetal/bootselect/chooser.c b/util/baremetal/bootselect/chooser.c index b7f41d0b20..0a6546eac2 100644 --- a/util/baremetal/bootselect/chooser.c +++ b/util/baremetal/bootselect/chooser.c @@ -50,7 +50,7 @@ int choose_stream(struct stream *stream) current += current->block_count+1; } - j=2; + j=1; if(iskey()) { j = ttys0_rx_char(); j=-1; diff --git a/util/baremetal/include/cpu/p6/msr.h b/util/baremetal/include/cpu/p6/msr.h new file mode 100644 index 0000000000..4977b0201d --- /dev/null +++ b/util/baremetal/include/cpu/p6/msr.h @@ -0,0 +1,33 @@ +#ifndef CPU_P6_MSR_H +#define CPU_P6_MSR_H + +/* + * Access to machine-specific registers (available on 586 and better only) + * Note: the rd* operations modify the parameters directly (without using + * pointer indirection), this allows gcc to optimize better + */ + +#define rdmsr(msr,val1,val2) \ + __asm__ __volatile__("rdmsr" \ + : "=a" (val1), "=d" (val2) \ + : "c" (msr)) + +#define wrmsr(msr,val1,val2) \ + __asm__ __volatile__("wrmsr" \ + : /* no outputs */ \ + : "c" (msr), "a" (val1), "d" (val2)) + +#define rdtsc(low,high) \ + __asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high)) + +#define rdtscl(low) \ + __asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx") + +#define rdtscll(val) \ + __asm__ __volatile__ ("rdtsc" : "=A" (val)) + +#define rdpmc(counter,low,high) \ + __asm__ __volatile__("rdpmc" \ + : "=a" (low), "=d" (high) \ + : "c" (counter)) +#endif /* CPU_P6_MSR_H */ diff --git a/util/baremetal/include/string.h b/util/baremetal/include/string.h index cf9bbb14d2..5370c16dea 100644 --- a/util/baremetal/include/string.h +++ b/util/baremetal/include/string.h @@ -6,7 +6,7 @@ // yes, linux has fancy ones. We don't care. This stuff gets used // hardly at all. And the pain of including those files is just too high. -//extern inline void strcpy(char *dst, char *src) {while (*src) *dst++ = *src++;} +extern inline void strcpy(char *dst, char *src) {while (*src) *dst++ = *src++;} //extern inline int strlen(char *src) { int i = 0; while (*src++) i++; return i;} diff --git a/util/baremetal/lib/Makefile b/util/baremetal/lib/Makefile index 0fe88872fe..a7962daa1f 100644 --- a/util/baremetal/lib/Makefile +++ b/util/baremetal/lib/Makefile @@ -6,7 +6,7 @@ CFLAGS = -I ../include -I ../include/$(ARCH) -O2 LB_SOURCE=../../../src -DEPS = printk.o serial_subr.o subr.o vsprintf.o memcpy.o malloc.o memset.o compute_ip_checksum.o elfboot.o boot.o ide.o linuxbios.o +DEPS = printk.o serial_subr.o subr.o vsprintf.o memcpy.o malloc.o memset.o compute_ip_checksum.o elfboot.o boot.o ide.o linuxbios.o delay_tsc.o baremetal.a : $(DEPS) ar -cr baremetal.a $(DEPS) @@ -32,5 +32,8 @@ malloc.o: $(LB_SOURCE)/lib/malloc.c printk.o: $(LB_SOURCE)/lib/printk.c $(CC) $(CFLAGS) -c $< +delay_tsc.o: $(LB_SOURCE)/cpu/p5/delay_tsc.c + $(CC) $(CFLAGS) -c $< + clean: rm -f $(DEPS) baremetal.a