When viewing the photo above of Himeiji Castle, notice the structures sticking out of the first floor above the foundation motte. Don't know the Japanese name for these at the top of my head, but the literal translation for these structures are "rock drops." These essentially allowed the defenders to be out and over the attackers below so they could drop rocks on them, as if through murderholes, found in European gatehouses.
Though I'd like to post a plan of the out buildings and outlying structures, few actual complete castle grounds and surrounding walls remain in Japan. Himeiji, though an exception to that was built during the time - gunpowder was being used and much of the outlying structures were built with guns and cannons in mind. So much of what was included in older Japanese castles do not apply to Himeiji's construction.
However, The Shiro or main donjon is usually in the center of multiple courtyards each with their own set of walls surrounding them. Basically attackers were forced into a spiral movement through the maze of walls and courtyards to get to the center and attack the main fortress itself. This allowed greater and longer exposure to the missle weapons being fired from the fortress onto the attacking forces.
Also because the attackers were forced to travel round and round the castle to reach it, secondary donjons are castle structures were built on corners and areas adjacent to the main fortress. Though this allowed additional defenders to attack from the real purpose was subterfuge. Wearing armor, traveling in formations while being attacked from the donjon and spiralling around the castle. Attackers would get confused on which tower was the actual fortress.
One additional feature is that each courtyard and access path had its own gatehouse leading to the next courtyard further inside the complex. These gatehouse were built at 90 degree angles to the courtyard within. Attackers who successfully batter down through the gatehouse would find themselves being attacked in the flank by the defenders within. Making bypassing gatehouses even more dangerous.
Below is an example of this type of gatehouse construction. The red arrow represents the attacking force, the arrows represent the flank formation of defenders.
If I can find a complete castle grounds layout, I'll post it here as well.
That's about the extent of my understanding of Japanese fortifications.
One of the these days, I'd like to create a complete Japanese castle plan with outlying buildings and the wall and gatehouse complex for use in the many RPGs based on ancient Japan, like L5R.
GP