Re: [PATCH v2] Virtual memory size detection for 64 bit MIPS CPUs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Guenter Roeck wrote:
[...]
+static inline void cpu_set_vmbits(struct cpuinfo_mips *c)
+{
+	if (cpu_has_64bits) {
+		unsigned long zbits;
+
+		asm volatile(".set mips64\n"
+			     "and %0, 0\n"
+			     "dsubu %0, 1\n"
+			     "dmtc0 %0, $10, 0\n"
+			     "dmfc0 %0, $10, 0\n"
+			     "dsll %0, %0, 2\n"
+			     "dsra %0, %0, 2\n"
+			     "dclz %0, %0\n"
+			     ".set mips0\n"
+			     : "=r" (zbits));
+		c->vmbits = 64 - zbits;
+	} else
+		c->vmbits = 32;
+}
+

It should be possible to express this in 'pure' C using read_c0_entryhi()/write_c0_entryhi(), also you need to be sure you are not writing 1s to any reserved bits of the register.


David Daney


[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux