Alex Liu
Alex Liu

Reputation: 105

What does 0xa55a mean in cga_init() in xv6 source code?

What does 0xa55a mean here?

Code:

*cp = (uint16_t) 0xA55A;   
if (*cp != 0xA55A) {      /* 0xa55a means that? */
cp = (uint16_t*) (KERNBASE + MONO_BUF);
    addr_6845 = MONO_BASE;
} 

Upvotes: 0

Views: 237

Answers (1)

Blownhither Ma
Blownhither Ma

Reputation: 1471

This code tests if cp is a writable address to determine whether the mode should be CGA or MONO. If writing does not work then we cannot use this part of memory. The thing (garbage) to be written should be arbitrary. It has no special meaning as far as I know.

Before this, the program saves the value at cp in was so the garbage won't poison the memory.

Upvotes: 5

Related Questions